Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: 16a46270 by Tony CHEMIT at 2018-04-08T09:48:52Z Simplificiation du layout de content - - - - - 5 changed files: - client/src/main/java/fr/ird/observe/client/ui/ObserveMainUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/ObserveMainUI.jcss - client/src/main/java/fr/ird/observe/client/ui/ObserveMainUIInitializer.java - client/src/main/java/fr/ird/observe/client/ui/content/ContentUIManager.java - client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationUI.jcss Changes: ===================================== client/src/main/java/fr/ird/observe/client/ui/ObserveMainUI.jaxx ===================================== --- a/client/src/main/java/fr/ird/observe/client/ui/ObserveMainUI.jaxx +++ b/client/src/main/java/fr/ird/observe/client/ui/ObserveMainUI.jaxx @@ -121,8 +121,6 @@ <ClientDataContext id='dataContext' initializer='ObserveSwingApplicationContext.get().getDataContext()'/> - <CardLayout2 id='contentLayout'/> - <CardLayout2Ext id='bodyLayout' constructorParams='this, "body"'/> <ObserveBlockingLayerUI id='busyBlockLayerUI'/> @@ -260,8 +258,8 @@ protected void finalize() throws Throwable { <!-- right up : content --> - <JPanel id="content"> - <JPanel id="emptySelection" constraints='"emptySelection"' layout="{new BorderLayout()}"> + <JPanel id="content" layout="{new BorderLayout()}"> + <JPanel id="emptySelection" layout="{new BorderLayout()}" constraints="BorderLayout.CENTER"> <JLabel id="emptySelectionLabel" constraints="BorderLayout.CENTER"/> </JPanel> </JPanel> ===================================== client/src/main/java/fr/ird/observe/client/ui/ObserveMainUI.jcss ===================================== --- a/client/src/main/java/fr/ird/observe/client/ui/ObserveMainUI.jcss +++ b/client/src/main/java/fr/ird/observe/client/ui/ObserveMainUI.jcss @@ -328,10 +328,6 @@ JSplitPane { resizeWeight: 0.80; } -#contentLayout { - useOnlyVisibleComponentDimension: true; -} - #navigationView { title: "observe.view.navigation"; } ===================================== client/src/main/java/fr/ird/observe/client/ui/ObserveMainUIInitializer.java ===================================== --- a/client/src/main/java/fr/ird/observe/client/ui/ObserveMainUIInitializer.java +++ b/client/src/main/java/fr/ird/observe/client/ui/ObserveMainUIInitializer.java @@ -62,7 +62,6 @@ import javax.swing.border.Border; import javax.swing.border.LineBorder; import javax.swing.event.TreeSelectionEvent; import javax.swing.tree.TreePath; -import java.awt.Component; import java.awt.Container; import java.awt.Cursor; import java.awt.event.KeyEvent; @@ -88,8 +87,6 @@ public class ObserveMainUIInitializer { /** Logger */ private static final Log log = LogFactory.getLog(ObserveMainUIInitializer.class); - private static final String EMPTY_SELECTION = "emptySelection"; - private final ObserveMainUI ui; private Border focusBorder; private Border noFocusBorder; @@ -183,25 +180,15 @@ public class ObserveMainUIInitializer { } if (ui.getNavigationUI().getTree().isSelectionEmpty()) { log.debug("No selection, show empty panel..."); - - boolean foundEmptySelection = false; - for (Component component : ui.getContent().getComponents()) { - if (component.getName().equals(EMPTY_SELECTION)) { - foundEmptySelection = true; - } - } - if (!foundEmptySelection) { - ui.getContent().add(ui.getEmptySelection(), EMPTY_SELECTION); - } - ui.getContentLayout().show(ui.getContent(), EMPTY_SELECTION); + ui.getContentUIManager().removeSelectedContentUI(); return; } TreePath path = event.getPath(); NavigationTreeNodeSupport node = (NavigationTreeNodeSupport) path.getLastPathComponent(); - ContentUIManager manager = ui.getContentUIManager(); // obtain the ui type to show + @SuppressWarnings("unchecked") Class<? extends ContentUI<?, ?>> uiClass = node.getContentClass(); if (log.isDebugEnabled()) { log.debug("new selected path = " + node + ", ui = " + uiClass); @@ -525,7 +512,7 @@ public class ObserveMainUIInitializer { public void cleanNavigationUI(ProgressModel progressModel) { // reset content uis - ui.getContentLayout().reset(ui.getContent()); + ui.getContentUIManager().removeSelectedContentUI(); progressModel.incrementsCurrentStep(); // clean messages ===================================== client/src/main/java/fr/ird/observe/client/ui/content/ContentUIManager.java ===================================== --- a/client/src/main/java/fr/ird/observe/client/ui/content/ContentUIManager.java +++ b/client/src/main/java/fr/ird/observe/client/ui/content/ContentUIManager.java @@ -6,15 +6,15 @@ * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the + * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public + * + * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% @@ -26,14 +26,15 @@ import fr.ird.observe.client.ObserveSwingSessionHelper; import fr.ird.observe.client.ui.ObserveMainUI; import fr.ird.observe.client.ui.util.UIHelper; import fr.ird.observe.dto.AbstractObserveDto; -import java.awt.Component; -import java.lang.reflect.Constructor; -import javax.swing.JPanel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.jaxx.runtime.JAXXContext; import org.nuiton.jaxx.runtime.context.JAXXInitialContext; -import org.nuiton.jaxx.runtime.swing.CardLayout2; + +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.lang.reflect.Constructor; /** * Manager des ecrans d'editions @@ -46,30 +47,21 @@ public class ContentUIManager { /** Logger */ private static final Log log = LogFactory.getLog(ContentUIManager.class); - public <U extends ContentUI<?, ?>> U getContent(Class<U> uiClass) { - - CardLayout2 layout = getLayout(); + public <U extends ContentUI<?, ?>> U getContent() { JPanel layoutContent = getLayoutContent(); - String constraints = uiClass.getName(); - - if (!layout.contains(constraints)) { - - // pas trouvé + Component currentContent = layoutContent.getComponent(0); + if (!(currentContent instanceof ContentUI)) { return null; } - - @SuppressWarnings("unchecked") U content = (U) layout.getComponent(layoutContent, constraints); - + @SuppressWarnings("unchecked") U content = (U) currentContent; if (log.isDebugEnabled()) { - log.debug("Will use existing content [" + constraints + "] : " + content.getClass().getName()); + log.debug(String.format("Will use existing content: %s", content.getClass().getName())); } return content; } public <U extends ContentUI<?, ?>> U createContent(Class<U> uiClass) { - String constraints = uiClass.getName(); - U result; try { Constructor<U> constructor = uiClass.getConstructor(JAXXContext.class); @@ -84,9 +76,10 @@ public class ContentUIManager { try { // ajout du content dans son parent - getLayoutContent().add(result, constraints); + getLayoutContent().removeAll(); + getLayoutContent().add(result, BorderLayout.CENTER); if (log.isDebugEnabled()) { - log.debug("Add new content [" + constraints + "] : " + result.getClass().getName()); + log.debug(String.format("Add new content: %s", result.getClass().getName())); } getMainUI().getModel().attachFocusOnBody(result); @@ -117,8 +110,8 @@ public class ContentUIManager { } catch (Exception e) { UIHelper.handlingError(e); } finally { - - getLayout().show(getLayoutContent(), constraints); + getLayoutContent().removeAll(); + getLayoutContent().add(content, BorderLayout.CENTER); getMainUI().getHandler().updateContentSize(); content.opened(); @@ -127,7 +120,8 @@ public class ContentUIManager { } public void close() { - getLayout().reset(getLayoutContent()); + getLayoutContent().removeAll(); + getLayoutContent().add(getMainUI().getEmptySelection(), BorderLayout.CENTER); } public ContentUI<?, ?> getSelectedContentUI() { @@ -162,13 +156,12 @@ public class ContentUIManager { } public void removeSelectedContentUI() { - ContentUI<?, ?> selectedContentUI = getSelectedContentUI(); if (selectedContentUI != null) { - getLayout().removeLayoutComponent(selectedContentUI, selectedContentUI.getClass().getName()); - getLayoutContent().remove(selectedContentUI); + getLayoutContent().removeAll(); selectedContentUI.destroy(); } + getLayoutContent().add(getMainUI().getEmptySelection(), BorderLayout.CENTER); } public void restartEdit() { @@ -211,25 +204,22 @@ public class ContentUIManager { return getMainUI().getContent(); } - private CardLayout2 getLayout() { - return getMainUI().getContentLayout(); - } +// private CardLayout2 getLayout() { +// return getMainUI().getContentLayout(); +// } private ObserveMainUI getMainUI() { return ObserveSwingApplicationContext.get().getMainUI(); } private ContentUI<?, ?> getSelectedContentUI(ObserveMainUI ui) { - if (ui == null) { // no ui, so no modification return null; } - ContentUI<?, ?> result = null; - CardLayout2 layout = ui.getContentLayout(); JPanel container = ui.getContent(); - Component currentContent = layout.getVisibleComponent(container); + Component currentContent = container.getComponent(0); if (currentContent instanceof ContentUI<?, ?>) { result = (ContentUI<?, ?>) currentContent; } ===================================== client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationUI.jcss ===================================== --- a/client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationUI.jcss +++ b/client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationUI.jcss @@ -65,3 +65,7 @@ JButton { actionIcon:generate; toolTipText:"observe.tree.action.configure.tip"; } + +#tree { + font-size:11; +} View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/16a4627037064e9c1ccf18263cd3... --- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/16a4627037064e9c1ccf18263cd3... You're receiving this email because of your account on gitlab.com.