comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java @ 1533:7fcec57c2f2c

Add cross sections loaded from datacage to the master artifacts list. flys-client/trunk@3743 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 20 Jan 2012 15:47:14 +0000
parents a6f6c61b18be
children c057ef91b268
comparison
equal deleted inserted replaced
1532:916c94b32be2 1533:7fcec57c2f2c
84 protected static String CS_IS_MASTER = "cross_section.master?"; 84 protected static String CS_IS_MASTER = "cross_section.master?";
85 85
86 /** Whether or not to move through all cross sections synchronously. */ 86 /** Whether or not to move through all cross sections synchronously. */
87 protected boolean synchronNavigation; 87 protected boolean synchronNavigation;
88 88
89 /** Data for master artifact combobox.*/
90 protected LinkedHashMap<String, String> masters;
91
92 /** Combobox for master artifacts.*/
93 protected SelectItem masterCb;
89 94
90 /** 95 /**
91 * Trivial constructor. 96 * Trivial constructor.
92 */ 97 */
93 public CrossSectionChartThemePanel( 98 public CrossSectionChartThemePanel(
181 @Override 186 @Override
182 protected VLayout createLayout() { 187 protected VLayout createLayout() {
183 layout = super.createLayout(); 188 layout = super.createLayout();
184 189
185 // Create "set master" combobox. 190 // Create "set master" combobox.
186 SelectItem cbItem = new SelectItem(); 191 masterCb = new SelectItem();
187 192
188 cbItem.setTitle(MSG.chart_themepanel_set_master()); 193 masterCb.setTitle(MSG.chart_themepanel_set_master());
189 cbItem.setType("comboBox"); 194 masterCb.setType("comboBox");
190 final LinkedHashMap<String, String> valueMap = 195 masters = getThemeList().toMapArtifactUUIDDescription("cross_section");
191 getThemeList().toMapArtifactUUIDDescription("cross_section"); 196 masterCb.setValueMap(masters);
192 cbItem.setValueMap(valueMap);
193 197
194 final DynamicForm form = new DynamicForm(); 198 final DynamicForm form = new DynamicForm();
195 form.setWidth(200); 199 form.setWidth(200);
196 form.setFields(cbItem); 200 form.setFields(masterCb);
197 layout.addMember(form); 201 layout.addMember(form);
198 202
199 Config config = Config.getInstance(); 203 Config config = Config.getInstance();
200 final String locale = config.getLocale(); 204 final String locale = config.getLocale();
201 findCurrentCSMaster(); 205 findCurrentCSMaster();
202 cbItem.setValue(getCurrentCSMaster()); 206 masterCb.setValue(getCurrentCSMaster());
203 207
204 // Add Change Handler to first unset the old master and then set the 208 // Add Change Handler to first unset the old master and then set the
205 // new master. 209 // new master.
206 cbItem.addChangeHandler(new ChangeHandler() { 210 masterCb.addChangeHandler(new ChangeHandler() {
207 public void onChange(ChangeEvent event) { 211 public void onChange(ChangeEvent event) {
208 String selectedItem = (String) event.getValue(); 212 String selectedItem = (String) event.getValue();
209 final String artifact = selectedItem; 213 final String artifact = selectedItem;
210 214
211 disable(); 215 disable();
607 }); 611 });
608 contextMenu.addItem(synchronNavigationMenuItem); 612 contextMenu.addItem(synchronNavigationMenuItem);
609 613
610 return contextMenu; 614 return contextMenu;
611 } 615 }
616
617
618 /**
619 * This method is used to clear the current theme grid and add new updated
620 * data.
621 */
622 @Override
623 protected void updateGrid() {
624 GWT.log("CrossSectionChartThemePanel.updateGrid");
625
626 ListGridRecord[] selected = list.getSelectedRecords();
627
628 clearGrid();
629
630 ThemeList themeList = getThemeList();
631
632 if (themeList == null) {
633 GWT.log("ERROR: No theme list.");
634 return;
635 }
636
637 int count = themeList.getThemeCount();
638
639 for (int i = 1; i <= count; i++) {
640 Theme theme = themeList.getThemeAt(i);
641
642 if(theme.getFacet().equals("empty.facet")) {
643 theme.setVisible(0);
644 }
645
646 if (theme == null || theme.getVisible() == 0) {
647 continue;
648 }
649
650 if (theme.getFacet().equals("cross_section")) {
651 addToReferences(theme);
652 }
653
654 FacetRecord newRecord = createRecord(theme);
655 addFacetRecord(newRecord);
656
657 String newArtifact = theme.getArtifact();
658 String newFacet = theme.getFacet();
659 int newIndex = theme.getIndex();
660
661 for (ListGridRecord r: selected) {
662 FacetRecord sel = (FacetRecord) r;
663 Theme oldTheme = sel.getTheme();
664
665 if (oldTheme.getArtifact().equals(newArtifact)
666 && oldTheme.getFacet().equals(newFacet)
667 && oldTheme.getIndex() == newIndex) {
668 list.selectRecord(newRecord);
669 }
670 }
671 }
672
673 fireOutputParameterChanged();
674
675 }
676
677
678 /**
679 * Adds a cross section theme to the master artifacts combobox and finds
680 * a new master if necessary.
681 *
682 * @param theme The cross section theme.
683 */
684 protected void addToReferences(Theme theme) {
685 masters.put(theme.getArtifact(), theme.getDescription());
686 masterCb.setValueMap(masters);
687 findCurrentCSMaster();
688 if (masterCb.getSelectedRecord() == null) {
689 masterCb.setValue(getCurrentCSMaster());
690 }
691 }
612 } 692 }
613 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 693 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org