From 8bb1555f12223878da63e29ffc3f82ac3cd34170 Mon Sep 17 00:00:00 2001 From: Yuriy Artamonov Date: Wed, 10 Apr 2013 13:41:53 +0000 Subject: [PATCH] Havana SCSS theme, Tree styles #PL-1995 --- .../cuba/gui/data/HierarchicalDatasource.java | 8 +- .../data/impl/HierarchicalDatasourceImpl.java | 18 ++-- .../HierarchicalPropertyDatasourceImpl.java | 7 +- .../ui/core/settings/messages_ru.properties | 2 +- .../gui/components/WebComponentsHelper.java | 39 ++------- .../web/gui/data/HierarchicalDsWrapper.java | 3 +- modules/web/themes/havana/app/app-window.scss | 2 +- .../tree/sprites/item-collapsed.png | Bin 0 -> 427 bytes .../components/tree/sprites/item-expanded.png | Bin 0 -> 402 bytes .../tree/sprites/tree-line-last.png | Bin 0 -> 208 bytes .../components/tree/sprites/tree-line.png | Bin 0 -> 202 bytes .../themes/havana/components/tree/tree.scss | 82 ++++++++++++++++++ .../web/themes/havana/havana-defaults.scss | 6 +- modules/web/themes/havana/havana.scss | 2 + 14 files changed, 123 insertions(+), 46 deletions(-) create mode 100644 modules/web/themes/havana/components/tree/sprites/item-collapsed.png create mode 100644 modules/web/themes/havana/components/tree/sprites/item-expanded.png create mode 100644 modules/web/themes/havana/components/tree/sprites/tree-line-last.png create mode 100644 modules/web/themes/havana/components/tree/sprites/tree-line.png create mode 100644 modules/web/themes/havana/components/tree/tree.scss diff --git a/modules/gui/src/com/haulmont/cuba/gui/data/HierarchicalDatasource.java b/modules/gui/src/com/haulmont/cuba/gui/data/HierarchicalDatasource.java index 04940eb943..9b62816edc 100644 --- a/modules/gui/src/com/haulmont/cuba/gui/data/HierarchicalDatasource.java +++ b/modules/gui/src/com/haulmont/cuba/gui/data/HierarchicalDatasource.java @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2009 Haulmont Technology Ltd. All Rights Reserved. + * Haulmont Technology proprietary and confidential. + * Use is subject to license terms. + */ + package com.haulmont.cuba.gui.data; import com.haulmont.cuba.core.entity.Entity; @@ -34,4 +40,4 @@ public interface HierarchicalDatasource, K> extends Collecti /** True if item with ID specified can ever has children */ boolean canHasChildren(K itemId); -} +} \ No newline at end of file diff --git a/modules/gui/src/com/haulmont/cuba/gui/data/impl/HierarchicalDatasourceImpl.java b/modules/gui/src/com/haulmont/cuba/gui/data/impl/HierarchicalDatasourceImpl.java index dc0515d4c7..9f2daf0526 100644 --- a/modules/gui/src/com/haulmont/cuba/gui/data/impl/HierarchicalDatasourceImpl.java +++ b/modules/gui/src/com/haulmont/cuba/gui/data/impl/HierarchicalDatasourceImpl.java @@ -22,21 +22,24 @@ public class HierarchicalDatasourceImpl, K> protected String hierarchyPropertyName; + @Override public String getHierarchyPropertyName() { return hierarchyPropertyName; } + @Override public void setHierarchyPropertyName(String hierarchyPropertyName) { this.hierarchyPropertyName = hierarchyPropertyName; } + @Override public Collection getChildren(K itemId) { if (hierarchyPropertyName != null) { final Entity item = getItem(itemId); if (item == null) return Collections.emptyList(); - List res = new ArrayList(); + List res = new ArrayList<>(); Collection ids = getItemIds(); for (K id : ids) { @@ -51,6 +54,7 @@ public class HierarchicalDatasourceImpl, K> return Collections.emptyList(); } + @Override public K getParent(K itemId) { if (hierarchyPropertyName != null) { Instance item = getItem(itemId); @@ -64,11 +68,12 @@ public class HierarchicalDatasourceImpl, K> return null; } + @Override public Collection getRootItemIds() { Collection ids = getItemIds(); if (hierarchyPropertyName != null) { - Set result = new LinkedHashSet(); + Set result = new LinkedHashSet<>(); for (K id : ids) { Entity item = getItemNN(id); Object value = item.getValue(hierarchyPropertyName); @@ -77,10 +82,11 @@ public class HierarchicalDatasourceImpl, K> } return result; } else { - return new LinkedHashSet(ids); + return new LinkedHashSet<>(ids); } } + @Override public boolean isRoot(K itemId) { Instance item = getItem(itemId); if (item == null) return false; @@ -93,6 +99,7 @@ public class HierarchicalDatasourceImpl, K> } } + @Override public boolean hasChildren(K itemId) { final Entity item = getItem(itemId); if (item == null) return false; @@ -110,7 +117,8 @@ public class HierarchicalDatasourceImpl, K> return false; } + @Override public boolean canHasChildren(K itemId) { - return true; + return hasChildren(itemId); } -} +} \ No newline at end of file diff --git a/modules/gui/src/com/haulmont/cuba/gui/data/impl/HierarchicalPropertyDatasourceImpl.java b/modules/gui/src/com/haulmont/cuba/gui/data/impl/HierarchicalPropertyDatasourceImpl.java index 96966a7b90..957065d95e 100644 --- a/modules/gui/src/com/haulmont/cuba/gui/data/impl/HierarchicalPropertyDatasourceImpl.java +++ b/modules/gui/src/com/haulmont/cuba/gui/data/impl/HierarchicalPropertyDatasourceImpl.java @@ -41,7 +41,7 @@ public class HierarchicalPropertyDatasourceImpl, K> if (item == null) return Collections.emptyList(); - List res = new ArrayList(); + List res = new ArrayList<>(); Collection ids = getItemIds(); for (K id : ids) { @@ -136,7 +136,7 @@ public class HierarchicalPropertyDatasourceImpl, K> @Override public boolean canHasChildren(K itemId) { - return true; + return hasChildren(itemId); } /** @@ -153,5 +153,4 @@ public class HierarchicalPropertyDatasourceImpl, K> public void setSortPropertyName(String sortPropertyName) { this.sortPropertyName = sortPropertyName; } -} - +} \ No newline at end of file diff --git a/modules/web/src/com/haulmont/cuba/web/app/ui/core/settings/messages_ru.properties b/modules/web/src/com/haulmont/cuba/web/app/ui/core/settings/messages_ru.properties index d01a88a700..27748e34a5 100644 --- a/modules/web/src/com/haulmont/cuba/web/app/ui/core/settings/messages_ru.properties +++ b/modules/web/src/com/haulmont/cuba/web/app/ui/core/settings/messages_ru.properties @@ -8,6 +8,6 @@ modeSingle=Без закладок changePassw=Сменить пароль -modeChangeNotification=Режим главного окна и тема оформления
вступят в силу при следующем входе в систему +modeChangeNotification=Режим главного окна и тема оформления вступят в силу при следующем входе в систему mainWindowThemeMsg=Заполните поле "Тема главного окна" \ No newline at end of file diff --git a/modules/web/src/com/haulmont/cuba/web/gui/components/WebComponentsHelper.java b/modules/web/src/com/haulmont/cuba/web/gui/components/WebComponentsHelper.java index 463d3335bf..2100184381 100644 --- a/modules/web/src/com/haulmont/cuba/web/gui/components/WebComponentsHelper.java +++ b/modules/web/src/com/haulmont/cuba/web/gui/components/WebComponentsHelper.java @@ -46,25 +46,6 @@ public class WebComponentsHelper { } } - /* - public static class ComponentPath { - String[] elements; - com.haulmont.cuba.gui.components.Component[] components; - - public ComponentPath(String[] elements, com.haulmont.cuba.gui.components.Component[] components) { - this.elements = elements; - this.components = components; - } - - public String[] getElements() { - return elements; - } - - public com.haulmont.cuba.gui.components.Component[] getComponents() { - return components; - } - }*/ - public static Collection getComponents(ComponentContainer container, Class aClass) { List res = new ArrayList<>(); for (Object aContainer : container) { @@ -95,10 +76,6 @@ public class WebComponentsHelper { return (com.vaadin.ui.Component) comp; } - /* - public static com.haulmont.cuba.web.toolkit.Timer unwrap(com.haulmont.cuba.gui.components.Timer timer) { - return (com.haulmont.cuba.web.toolkit.Timer) timer; - } */ /** * Returns underlying Vaadin component, which serves as the outermost container for the supplied GUI component. @@ -116,6 +93,7 @@ public class WebComponentsHelper { return (com.vaadin.ui.Component) comp; } + /** * @deprecated Use ComponentsHelper.getComponents() instead */ @@ -146,15 +124,15 @@ public class WebComponentsHelper { if (elements.length == 1) { final com.haulmont.cuba.gui.components.Component component = comp.getOwnComponent(id); - if (component == null) { - return (T) getComponentByIterate(container, id); - } else { + if (component == null) + return getComponentByIterate(container, id); + else return (T) component; - } + } else { com.haulmont.cuba.gui.components.Component component = comp.getOwnComponent(elements[0]); if (component == null) { - return (T) getComponentByIterate(container, id); + return getComponentByIterate(container, id); } else { final List subpath = Arrays.asList(elements).subList(1, elements.length); if (component instanceof com.haulmont.cuba.gui.components.Component.Container) { @@ -169,9 +147,8 @@ public class WebComponentsHelper { protected static T getComponentByIterate(ComponentContainer container, String id) { com.haulmont.cuba.gui.components.Component component; - final Iterator iterator = container.getComponentIterator(); - while (iterator.hasNext()) { - Component c = (Component) iterator.next(); + for (Object aContainer : container) { + Component c = (Component) aContainer; if (c instanceof com.haulmont.cuba.gui.components.Component.Container) { component = ((com.haulmont.cuba.gui.components.Component.Container) c).getComponent(id); diff --git a/modules/web/src/com/haulmont/cuba/web/gui/data/HierarchicalDsWrapper.java b/modules/web/src/com/haulmont/cuba/web/gui/data/HierarchicalDsWrapper.java index 355b2c2e2d..12ddfc1052 100644 --- a/modules/web/src/com/haulmont/cuba/web/gui/data/HierarchicalDsWrapper.java +++ b/modules/web/src/com/haulmont/cuba/web/gui/data/HierarchicalDsWrapper.java @@ -55,14 +55,13 @@ public class HierarchicalDsWrapper extends CollectionDsWrapper implements Contai return false; } + @Override public boolean areChildrenAllowed(Object itemId) { - //return true; return ((HierarchicalDatasource, Object>) datasource).canHasChildren(itemId); } @Override public boolean setChildrenAllowed(Object itemId, boolean areChildrenAllowed) throws UnsupportedOperationException { - //return true; return false; // due to vaadin javadoc, return false if method is not implemented } diff --git a/modules/web/themes/havana/app/app-window.scss b/modules/web/themes/havana/app/app-window.scss index 12c8bc5a11..0def076dd2 100644 --- a/modules/web/themes/havana/app/app-window.scss +++ b/modules/web/themes/havana/app/app-window.scss @@ -60,7 +60,7 @@ } .cuba-app-appname-label { - color: white; + color: #fff; font-size: 14px; font-weight: bold; font-family: $theme_fonts; diff --git a/modules/web/themes/havana/components/tree/sprites/item-collapsed.png b/modules/web/themes/havana/components/tree/sprites/item-collapsed.png new file mode 100644 index 0000000000000000000000000000000000000000..c8fbeeb590bf9aba92923f4d3a72937dd0379598 GIT binary patch literal 427 zcmeAS@N?(olHy`uVBq!ia0vp@Ak4uAB#T}@sR2?f#ZI0f96(URkrMq>1fPyk5t`Q}{`DrEPiAAXljw$&`sS0kHMXBZaMcKs)&cP;Zn=UT^suKgL zb1q6vEXmBzQwYh-O=U1N&^IvEH#GRONv)TGfsxtM#W6%<;@(MyUd(|4ZTnAZMJ5RZ zvPi#ecHeMD*2d{v@>+2Let{gFty?ZfnP?~mPFoRqzxwyL?Ke~eVp~l740+D*{Qu6M zJSoCdN;{t+`}3nmzx=|#_a_9XHXb-5u;{ksgC8$0FidDssajt9S9I^@ea|*?tMVlE z%m|g6oHBP2M+3*b#;gwqI1VP7IWzAm7qLsXI+=FEo-ffMQfx_Px5-_G1y{2+@7&t` zJ^rhg(-Dc2n+#KRZrr<>Y$EgEv!-5sd{ES(-zSdksPW=qY}o#=K|*FD$5(as6K>~g z{EQZr--(&``PZig7EfiyTl=T)np^9aH{W1Z$FoDrRW_{JpYUtD`7gHV`)9uSv}x~V QV1O}ry85}Sb4q9e0HrMq>1fPyk5t`Q}{`DrEPiAAXljw$&`sS0kHMXBZaMcKs)&cP;Zn=UT^suKgL zb1q6vEXmBzQwYh-O=U1N&^IvEH#GRONv#*C;+3b1V~EDYy_0PH4m$|6?pK@`#G65Llc|;MS6XRi{rFMMK3x^X&eN}>|BCv`ds?d+D<5mvs&t?%RxrkQ z|3ycpJ>@ebgI+Co;AJLXY5mZ=#l@@fW5uTJKR#dno2c3#q3pU*$*q4FdgVi-nU-!1O)qwPc`>WQl7;iF1B# zZfaf$gL6@8Vo7R>LV0FMhJw4NZ$Nk>pEyvFwx^3@h{fsTgaxV`TwK4-8!Sk;!rFY2 sHDH!tuRTYM$8>`PnF8?wo__^Q3|2RUr|fBF1i78T)78&qol`;+01R|DT>t<8 literal 0 HcmV?d00001 diff --git a/modules/web/themes/havana/components/tree/sprites/tree-line.png b/modules/web/themes/havana/components/tree/sprites/tree-line.png new file mode 100644 index 0000000000000000000000000000000000000000..06d0a3f1d214090927a992cca217d2f0d7924262 GIT binary patch literal 202 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRp!3HFQtmCqP6k~CayA#8@b22Z19JVBHcNd2L zAh=-f^2tCE&H|6fVg?3oVGw3ym^DWND9B#o>FdgVi-nU-!1CGVSsp+k$r9Iy66gHf z+|;}h2Ir#G#FEq$h4Rdj3bP0l+XkK?Qk|! literal 0 HcmV?d00001 diff --git a/modules/web/themes/havana/components/tree/tree.scss b/modules/web/themes/havana/components/tree/tree.scss new file mode 100644 index 0000000000..879acdac4a --- /dev/null +++ b/modules/web/themes/havana/components/tree/tree.scss @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2013 Haulmont Technology Ltd. All Rights Reserved. + * Haulmont Technology proprietary and confidential. + * Use is subject to license terms. + */ + +// Version: $Id$ + +@mixin havana-tree($primaryStyleName: v-tree) { + .#{$primaryStyleName} { + text-align: left; + background: #fff; + border: 1px solid $theme_fieldBorderColor; + overflow: auto; + outline: none; + padding: 0; + + .#{$primaryStyleName}-node-caption { + margin-left: 16px; + span { + cursor: default; + padding-left: 2px; + padding-right: 2px; + padding: 0 2px; + display: inline; + white-space: nowrap; + font-size: 12px; + color: $theme_treeCaptionColor; + } + .v-icon { + display: inline; + vertical-align: text-bottom; + } + } + + .#{$primaryStyleName}-node { + background: transparent; + background-repeat: no-repeat; + background-image: url(sprites/item-collapsed.png); + background-position: 0 2px; + } + + .#{$primaryStyleName}-node-expanded { + background-image: url(sprites/item-expanded.png); + } + + .#{$primaryStyleName}-node-children .#{$primaryStyleName}-node { + background-image: url(sprites/item-collapsed.png); + } + + .#{$primaryStyleName}-node-children .#{$primaryStyleName}-node-expanded { + background-image: url(sprites/item-expanded.png); + } + + .#{$primaryStyleName}-node.#{$primaryStyleName}-node-leaf { + background-image: url(sprites/tree-line.png); + } + + .#{$primaryStyleName}-node-children-last.#{$primaryStyleName}-node.#{$primaryStyleName}-node-leaf { + background-image: url(sprites/tree-line.png); + } + + .#{$primaryStyleName}-node.#{$primaryStyleName}-node-leaf.#{$primaryStyleName}-node-leaf-last { + background-image: url(sprites/tree-line-last.png); + } + + .#{$primaryStyleName}-node-selected span { + background: $theme_treeSelectionColor; + color: $theme_treeCaptionSelectedColor; + padding: 0 2px; + cursor: default; + } + } + + .#{$primaryStyleName} > div { + padding: 5px; + } + + .#{$primaryStyleName}:focus { + border-color: $theme_fieldFocusedBorderColor; + } +} \ No newline at end of file diff --git a/modules/web/themes/havana/havana-defaults.scss b/modules/web/themes/havana/havana-defaults.scss index 5a67231e2c..0cfae1c1d2 100644 --- a/modules/web/themes/havana/havana-defaults.scss +++ b/modules/web/themes/havana/havana-defaults.scss @@ -55,4 +55,8 @@ $theme_tableRowBackgroundColor: #fff; $theme_tableRowOddBackgroundColor: #f6f8fa; $theme_tableRowSelectionBackgroundColor: #c3e1ff; $theme_tableRowHoverBackgroundColor: #f5f4b9; -$theme_tableCellSeparatorColor: #edf3f9; \ No newline at end of file +$theme_tableCellSeparatorColor: #edf3f9; + +$theme_treeSelectionColor: #5daee8; +$theme_treeCaptionColor: #1e3146; +$theme_treeCaptionSelectedColor: #000; \ No newline at end of file diff --git a/modules/web/themes/havana/havana.scss b/modules/web/themes/havana/havana.scss index f063db1f1e..d444a6a0b7 100644 --- a/modules/web/themes/havana/havana.scss +++ b/modules/web/themes/havana/havana.scss @@ -16,6 +16,7 @@ @import "components/common/common"; // Components +@import "components/tree/tree"; @import "components/table/table"; @import "components/panel/panel"; @import "components/window/window"; @@ -44,6 +45,7 @@ @include havana-common; + @include havana-tree; @include havana-table; @include havana-panel; @include havana-window;