Mercurial > dive4elements > river
changeset 8874:7ebe5d463740
Fixed some minro layout problems and initial selection.
author | gernotbelger |
---|---|
date | Wed, 07 Feb 2018 18:04:53 +0100 |
parents | b78aad3bcf70 |
children | 8d1df8639563 |
files | gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ModuleSelection.java |
diffstat | 1 files changed, 39 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ModuleSelection.java Wed Feb 07 12:11:05 2018 +0100 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ModuleSelection.java Wed Feb 07 18:04:53 2018 +0100 @@ -152,24 +152,24 @@ protected final void setModules(Module[] newmodules) { modulesRiverMap.clear(); - + if( newmodules == null ) return; - + for(final Module module : newmodules) { final String name = module.getName(); - + /* remember rivers per module */ modulesRiverMap.put(name, module.getRivers()); /* hash by name */ modulesByName.put(name, module); - + /* hash by group */ final ModuleGroup group = module.getGroup(); if( !modulesByGroup.containsKey( group ) ) modulesByGroup.put(group, new LinkedList<Module>()); - + final List<Module> modulesGroup = modulesByGroup.get(group); modulesGroup.add(module); } @@ -192,9 +192,9 @@ layout.addMember(label); layout.addMember(radioPanel); - + updateRadioPanels(); - + return layout; } @@ -221,26 +221,11 @@ final ModuleGroup group = groupEntry.getKey(); final List<Module> groupModule = groupEntry.getValue(); - final HLayout groupPanel = new HLayout(); - - if( group.showGroupFrame() ) - { - final LayoutSpacer spacer = new LayoutSpacer(); - spacer.setWidth(25); - groupPanel.addMember(spacer); - - final Label label = new Label(group.toString()); - label.setWidth(25); - label.setHeight(25); - groupPanel.addMember(label); - } - final DynamicForm groupForm = new DynamicForm(); - final RadioGroupItem moduleRadio = new RadioGroupItem("modulegroup" + count++); moduleRadio.setShowTitle(false); - moduleRadio.setVertical(true); - + moduleRadio.setWrap(false); + moduleRadio.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { @@ -248,25 +233,49 @@ handleModuleSelected(selectedModuleName); } }); - - groupForm.setItems(moduleRadio); - groupPanel.addMember(groupForm); + Module selected = null; final LinkedHashMap<String, String> values = new LinkedHashMap<String, String>(); for(final Module module : groupModule) { values.put(module.getName(), module.getLocalizedName()); if (module.isSelected()) { GWT.log("Module " + module.getName() + " is selected."); selectedModule = module; - moduleRadio.setValue(module.getName()); + selected = module; } } + moduleRadio.setValueMap(values); + + final DynamicForm groupForm = new DynamicForm(); + groupForm.setItems(moduleRadio); + groupForm.setColWidths(60,"*"); + + final Canvas groupPanel; + if( group.showGroupFrame() ) + { + final HLayout layout = new HLayout(); + + final LayoutSpacer spacer = new LayoutSpacer(); + // so text is on the same level as other items (with radio-icon), lets hope 25px is always right + spacer.setWidth(25); + layout.addMember(spacer); + + final Label label = new Label(group.toString()); + layout.addMember(label); + + layout.addMember(groupForm); + + groupPanel = layout; + } + else + groupPanel = groupForm; this.groupToRadios.put( group, moduleRadio ); this.groupToCanvas.put( group, groupPanel ); - moduleRadio.setValueMap(values); - + /* selection must be done after value-map was set; and, only if the selection holds for this group */ + if( selected != null ) + moduleRadio.setValue(selected.getName()); radioPanel.addMember(groupPanel); }