# HG changeset patch # User gernotbelger # Date 1518023093 -3600 # Node ID 7ebe5d463740cab84c7b25a13eda955699d81844 # Parent b78aad3bcf70483e09b9ebace5f6dde692e3e352 Fixed some minro layout problems and initial selection. diff -r b78aad3bcf70 -r 7ebe5d463740 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ModuleSelection.java --- 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()); - + final List 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 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 values = new LinkedHashMap(); 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); }