private void addButton(Type type, AbstractImagePrototype icon) { ToggleButton button = new ToggleButton("", icon); button.setToggleGroup(TYPE_DATA); button.setData(TYPE_DATA, type); button.addSelectionListener(listener); buttons.add(button); }
/** * Creates the button that can convert to ui designer view. * * @return the toggle button */ private ToggleButton createUDButton() { final ToggleButton udButton = new ToggleButton(); udButton.setToolTip("UI Designer"); udButton.setIcon(icons.udIcon()); udButton.addSelectionListener( new SelectionListener<ButtonEvent>() { public void componentSelected(ButtonEvent ce) { if (!udButton.isPressed()) { udButton.toggle(true); } else { modelerContainer.remove(buildingModelerView); modelerContainer.add(uiDesignerView); Cookies.setCookie(Constants.CURRETN_ROLE, Role.ROLE_DESIGNER); modelerContainer.layout(); } } }); udButton.setToggleGroup("modeler-switch"); if (Role.ROLE_DESIGNER.equals(Cookies.getCookie(Constants.CURRETN_ROLE))) { udButton.toggle(true); } return udButton; }
/** * Set up and get a button bar with buttons to expand or collapse the tree. * * @return */ public ToolBar getButtonsBar() { ButtonBar toolbar = new ButtonBar(); toolbar.setAlignment(HorizontalAlignment.CENTER); pieButton = new ToggleButton("Pie Chart"); pieButton.setToggleGroup("chartType"); IconSupplier.forceIcon(pieButton, IconSupplier.getPieChartIconName()); pieButton.addSelectionListener( new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { chartType = PIE_CHART; redoChart(); } }); barButton = new ToggleButton("Bar Graph"); barButton.setToggleGroup("chartType"); IconSupplier.forceIcon(barButton, IconSupplier.getBarChartIconName()); barButton.addSelectionListener( new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { chartType = BAR_CHART; redoChart(); } }); if (chartType == BAR_CHART) barButton.toggle(true); else pieButton.toggle(true); valueCombo = FieldFactory.getModelDataComboField( "valueBox", "", 100, "Select the value to chart.", getValueComboStore(), "value", "description"); valueCombo.enable(); setValueCombo(); valueCombo.addSelectionChangedListener( new SelectionChangedListener<ModelData>() { @Override public void selectionChanged(SelectionChangedEvent<ModelData> se) { if (se.getSelectedItem() != null && se.getSelectedItem().get("value") != null) { valueCol = se.getSelectedItem().get("value").toString(); valueLabel = se.getSelectedItem().get("description").toString(); redoChart(); } } }); groupCombo = FieldFactory.getModelDataComboField( "valueBox", "", 100, "Select the value to chart.", getGroupComboStore(), "value", "description"); groupCombo.enable(); setGroupCombo(); groupCombo.addSelectionChangedListener( new SelectionChangedListener<ModelData>() { @Override public void selectionChanged(SelectionChangedEvent<ModelData> se) { if (se.getSelectedItem() != null && se.getSelectedItem().get("value") != null) { groupCol = se.getSelectedItem().get("value").toString(); groupLabel = se.getSelectedItem().get("description").toString(); labelCol = groupCol; textCol = groupCol; redoChart(); } } }); toolbar.add(pieButton); toolbar.add(barButton); toolbar.add(new SeparatorToolItem()); toolbar.add(new Html("Chart")); toolbar.add(valueCombo); toolbar.add(new Html("By")); toolbar.add(groupCombo); return toolbar; }
@Override public void addComponent() { this.dimensionRadioGroup = new RadioGroup(); this.dimensionRadioGroup.setFieldLabel( LayerModuleConstants.INSTANCE.LayerTimeFilterWidget_dimensionRadioLabelText()); fixedDimensionRadio.setBoxLabel( LayerModuleConstants.INSTANCE.LayerTimeFilterWidget_fixedDimensionRadioLabelText()); fixedDimensionRadio.setHideLabel(Boolean.TRUE); this.dimensionRadioGroup.add(fixedDimensionRadio); variableDimensionRadio.setBoxLabel( LayerModuleConstants.INSTANCE.LayerTimeFilterWidget_variableDimensionRadioLabelText()); variableDimensionRadio.setHideLabel(Boolean.TRUE); this.dimensionRadioGroup.add(variableDimensionRadio); this.fixedDimensionContainer.setVisible(Boolean.FALSE); this.variableDimensionContainer.setVisible(Boolean.FALSE); this.fixedDimensionRadio.addListener( Events.Change, new Listener<FieldEvent>() { @Override public void handleEvent(FieldEvent fe) { if (fixedDimensionRadio.getValue()) { fixedDimensionContainer.setVisible(Boolean.TRUE); variableDimensionContainer.setVisible(Boolean.FALSE); } } }); this.variableDimensionRadio.addListener( Events.Change, new Listener<FieldEvent>() { @Override public void handleEvent(FieldEvent fe) { if (variableDimensionRadio.getValue()) { variableDimensionContainer.setVisible(Boolean.TRUE); fixedDimensionContainer.setVisible(Boolean.FALSE); } } }); this.startStore = new ListStore<DimensionData>(); this.startDimensionComboBox = new ComboBox<DimensionData>(); this.startDimensionComboBox.setFieldLabel( LayerModuleConstants.INSTANCE.LayerTimeFilterWidget_startDimensionComboLabelText()); this.startDimensionComboBox.setStore(this.startStore); this.startDimensionComboBox.setDisplayField(DimensionData.DIMENSION_KEY); this.startDimensionComboBox.setEditable(Boolean.FALSE); this.startDimensionComboBox.addSelectionChangedListener( new SelectionChangedListener<DimensionData>() { @Override public void selectionChanged(SelectionChangedEvent<DimensionData> se) { if (se.getSelectedItem() != null) { endStore.removeAll(); int indexStart = startStore.getModels().indexOf(se.getSelectedItem()) + 1; // System.out.println("Sublist start: " + indexStart); // System.out.println("Sublist end: " + // (startStore.getModels().size() - 1)); if (indexStart < startStore.getModels().size()) { endDimensionComboBox.enable(); endStore.add( startStore .getModels() .subList( startStore.indexOf(se.getSelectedItem()) + 1, startStore.getModels().size())); } else { endDimensionComboBox.disable(); } } } }); this.endStore = new ListStore<DimensionData>(); this.endDimensionComboBox = new ComboBox<DimensionData>(); this.endDimensionComboBox.setFieldLabel( LayerModuleConstants.INSTANCE.LayerTimeFilterWidget_endDimensionComboLabelText()); this.endDimensionComboBox.setStore(this.endStore); this.endDimensionComboBox.setDisplayField(DimensionData.DIMENSION_KEY); this.endDimensionComboBox.disable(); this.endDimensionComboBox.setEditable(Boolean.FALSE); dimensionSizeLabel = new Label(); dimensionSizeLabel.setStyleAttribute("font-size", "12px"); this.startFilterNumberField = new NumberField(); this.startFilterNumberField.setFireChangeEventOnSetValue(Boolean.TRUE); this.startFilterNumberField.addListener( Events.Change, new Listener<BaseEvent>() { @Override public void handleEvent(BaseEvent be) { if (checkStartFieldValue()) { int fromFilter = startFilterNumberField.getValue().intValue(); int position = startStore.getModels().size() - fromFilter - 1; String tooltip = (String) startStore.getModels().get(position).get(DimensionData.DIMENSION_KEY); // startStore.getModels().size() - fromFilter - 1).get( startFilterNumberField.setToolTip(tooltip); startTimeLabel.setHtml(tooltip); slider.setValue(position); } else { startTimeLabel.setHtml(""); startFilterNumberField.setToolTip(""); } } }); startTimeLabel = new Label(); startTimeLabel.setStyleAttribute("font-size", "1.3em"); this.startFilterNumberField.setSize(50, 30); this.endFilterNumberField = new NumberField(); this.endFilterNumberField.setFireChangeEventOnSetValue(Boolean.TRUE); endTimeLabel = new Label(); endTimeLabel.setStyleAttribute("font-size", "1.3em"); this.endFilterNumberField.addListener( Events.Change, new Listener<BaseEvent>() { @Override public void handleEvent(BaseEvent be) { if (checkEndFieldValue()) { int endFilter = endFilterNumberField.getValue().intValue(); String tooltip = (String) startStore.getModels().get(endFilter).get(DimensionData.DIMENSION_KEY); // startStore.getModels().size() - endFilter - 1). endFilterNumberField.setToolTip(tooltip); endTimeLabel.setHtml(tooltip); } else { endTimeLabel.setHtml(""); endFilterNumberField.setToolTip(""); } } }); this.endFilterNumberField.setSize(50, 30); FormPanel panel = new FormPanel(); panel.setHeaderVisible(Boolean.FALSE); panel.setFrame(Boolean.TRUE); panel.setBorders(Boolean.FALSE); panel.setHeight(WIDGET_HEIGHT - 67); panel.add(this.dimensionRadioGroup); panel.setStyleAttribute("background-color", "white"); this.variableDimensionContainer.add(dimensionSizeLabel, new FormData("100%")); Portal portal = new Portal(3); portal.setBorders(false); portal.setColumnWidth(0, .20); portal.setColumnWidth(1, .60); portal.setColumnWidth(2, .20); Portlet portlet = new Portlet(); portlet.setLayout(new FitLayout()); portlet.setHeaderVisible(false); portlet.setSize(50, 30); portlet.add(this.startFilterNumberField); portal.add(portlet, 0); portlet = new Portlet(new CenterLayout()); portlet.setHeaderVisible(false); portlet.setSize(100, 30); this.rangeCheckBox = new CheckBox(); rangeCheckBox.setValue(true); rangeCheckBox.setBoxLabel("range"); portlet.add(rangeCheckBox); portlet.setBorders(false); portal.add(portlet, 1); portlet = new Portlet(); portlet.setHeaderVisible(false); portlet.setSize(50, 30); portlet.add(this.endFilterNumberField); portal.add(portlet, 2); this.variableDimensionContainer.add(portal, new FormData("99%")); // this.slider = new Slider() { @Override public void setValue(int value) { super.setValue(value); super.setMessage("" + (startStore.getModels().size() - value)); } }; slider.setIncrement(1); this.variableDimensionContainer.add(slider, new FormData("98%")); this.fixedDimensionContainer.add(this.startDimensionComboBox); this.fixedDimensionContainer.add(this.endDimensionComboBox); panel.add(this.fixedDimensionContainer, new FormData("100%")); panel.add(this.variableDimensionContainer, new FormData("100%")); super.add(panel); this.playSelectioListener = new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { // System.out.println("Play button status: "); if (!playButton.isPressed()) { playButton.setText(ButtonsConstants.INSTANCE.playText()); playButton.setIcon(AbstractImagePrototype.create(LayerResources.ICONS.playTime())); animationTimer.cancel(); } else { Number startValueNumber = startFilterNumberField.getValue(); if (startValueNumber == null) { GeoPlatformMessage.alertMessage( LayerModuleConstants.INSTANCE .LayerTimeFilterWidget_timeFilterWarningTitleText(), LayerModuleConstants.INSTANCE .LayerTimeFilterWidget_timeFilterWarningBodyText()); } else { slider.setValue(startStore.getModels().size() - startValueNumber.intValue() - 1); playButton.setIcon(AbstractImagePrototype.create(LayerResources.ICONS.pauseTime())); playButton.setText(ButtonsConstants.INSTANCE.pauseText()); playTimeFilter(); } } } }; playButton.addSelectionListener(playSelectioListener); playButton.setHeight(30); super.addButton(playButton); Button apply = new Button(ButtonsConstants.INSTANCE.applyText()); this.applyFilterSelectionListener = new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { GPLayerTreeModel layerSelected = (GPLayerTreeModel) treePanel.getSelectionModel().getSelectedItem(); IMementoSave mementoSave = MementoModuleInjector.MainInjector.getInstance().getMementoSave(); AbstractMementoOriginalProperties memento = mementoSave.copyOriginalProperties(layerSelected); String layerName; if (layerSelected.getAlias() != null && layerSelected.getAlias().indexOf(LAYER_TIME_DELIMITER) != -1) { layerName = layerSelected .getAlias() .substring(0, layerSelected.getAlias().indexOf(LAYER_TIME_DELIMITER)); } else { layerName = layerSelected.getLabel(); } if (fixedDimensionRadio.getValue()) { String timeFilter = (String) startDimensionComboBox.getValue().get(DimensionData.DIMENSION_KEY); if (endDimensionComboBox.getValue() != null) { timeFilter += "/" + (String) endDimensionComboBox.getValue().get(DimensionData.DIMENSION_KEY); } layerSelected.setTimeFilter(timeFilter); layerSelected.setVariableTimeFilter(null); layerSelected.setAlias( layerName + LAYER_TIME_DELIMITER + layerSelected.getTimeFilter() + "]"); WidgetPropertiesHandlerManager.fireEvent(labelEvent); } else { if ((rangeCheckBox.getValue() && !checkEndFieldValue()) || !checkStartFieldValue()) { GeoPlatformMessage.errorMessage( LayerModuleConstants.INSTANCE.LayerTimeFilterWidget_timeFilterErrorTitleText(), LayerModuleConstants.INSTANCE.LayerTimeFilterWidget_timeFilterErrorBodyText()); return; } else { int fromFilter = slider.getValue(); String timeFilter = "" + (startStore.getModels().size() - fromFilter - 1); String variableTimeFilter = (String) startStore.getModels().get(fromFilter).get(DimensionData.DIMENSION_KEY); if (rangeCheckBox.getValue() && playButton.isPressed()) { fromFilter = startStore.getModels().size() - startFilterNumberField.getValue().intValue() - 1; timeFilter = "" + startFilterNumberField.getValue().intValue(); variableTimeFilter = (String) startStore.getModels().get(fromFilter).get(DimensionData.DIMENSION_KEY); // int toFilter = slider.getValue(); timeFilter += "/" + (startStore.getModels().size() - slider.getValue() - 1); variableTimeFilter += "/" + (String) startStore.getModels().get(toFilter).get(DimensionData.DIMENSION_KEY); } // This is usefull when press Apply button to show all the elements in range else if (rangeCheckBox.getValue() && endFilterNumberField.getValue() != null) { fromFilter = startStore.getModels().size() - startFilterNumberField.getValue().intValue() - 1; timeFilter = "" + startFilterNumberField.getValue().intValue(); variableTimeFilter = (String) startStore.getModels().get(fromFilter).get(DimensionData.DIMENSION_KEY); // int toFilter = startStore.getModels().size() - endFilterNumberField.getValue().intValue() - 1; timeFilter += "/" + endFilterNumberField.getValue().intValue(); variableTimeFilter += "/" + (String) startStore.getModels().get(toFilter).get(DimensionData.DIMENSION_KEY); } layerSelected.setTimeFilter(timeFilter); layerSelected.setVariableTimeFilter(variableTimeFilter); layerSelected.setAlias( layerName + LAYER_TIME_DELIMITER + layerSelected.getVariableTimeFilter() + "]"); WidgetPropertiesHandlerManager.fireEvent(labelEvent); slider.setMessage(variableTimeFilter); GeoPlatformMessage.infoMessage( LayerModuleConstants.INSTANCE .LayerTimeFilterWidget_timeFilterMessageTitleText(), LayerModuleMessages.INSTANCE.LayerTimeFilterWidget_layerStatusShowedMessage( timeFilter)); } } mementoSave.putOriginalPropertiesInCache(memento); timeFilterLayerMapEvent.setLayerBean(layerSelected); GPHandlerManager.fireEvent(timeFilterLayerMapEvent); treePanel.refresh(layerSelected); } }; apply.addSelectionListener(applyFilterSelectionListener); super.addButton(apply); Button close = new Button( ButtonsConstants.INSTANCE.closeText(), new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { startFilterNumberField.clear(); startTimeLabel.setHtml(""); endTimeLabel.setHtml(""); endFilterNumberField.clear(); hide(); } }); super.addButton(close); }