Search in sources :

Example 1 with SelectionChangedListener

use of com.extjs.gxt.ui.client.event.SelectionChangedListener in project kapua by eclipse.

the class WestNavigationView method onRender.

protected void onRender(final Element parent, int index) {
    super.onRender(parent, index);
    setLayout(new FitLayout());
    setBorders(false);
    // 
    // accordion
    m_accordionLayout = new AccordionLayout();
    m_accordionLayout.setFill(true);
    m_accordionPanel = new ContentPanel();
    m_accordionPanel.setBorders(false);
    m_accordionPanel.setBodyBorder(false);
    m_accordionPanel.setLayout(m_accordionLayout);
    m_accordionPanel.setHeaderVisible(false);
    m_accordionPanel.setId("accordion-panel");
    add(m_accordionPanel);
    // 
    // Top managing panel
    m_accountPanel = new ContentPanel();
    m_accountPanel.setBorders(false);
    m_accountPanel.setBodyBorder(true);
    m_accountPanel.setAnimCollapse(true);
    m_accountPanel.setHeaderVisible(false);
    m_accountPanel.setScrollMode(Scroll.AUTOY);
    // 
    // Bottom manage panel
    m_managePanel = new ContentPanel();
    m_managePanel.setBorders(false);
    m_managePanel.setBodyBorder(false);
    m_managePanel.setHeading(MSGS.manageHeading());
    m_managePanel.setHeaderVisible(true);
    m_accountStore = new TreeStore<ModelData>();
    m_manageStore = new TreeStore<ModelData>();
    // 
    // Adding item to stores
    // 
    addMenuItems();
    ColumnConfig name = new ColumnConfig("name", "Name", 100);
    name.setRenderer(new WidgetTreeGridCellRenderer<ModelData>() {

        @Override
        public Widget getWidget(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
            Label label = new Label((String) model.get(property));
            label.setStyleAttribute("padding-left", "5px");
            if (((String) model.get(property)).equals("Dashboard")) {
                // Adding refresh button
                label.setStyleAttribute("padding-right", "50px");
                label.setStyleAttribute("background-color", "transparent");
                ContentPanel dashboardLabelPanel = new ContentPanel();
                dashboardLabelPanel.setHeaderVisible(false);
                dashboardLabelPanel.setBorders(false);
                dashboardLabelPanel.setBodyBorder(false);
                dashboardLabelPanel.setLayout(new FitLayout());
                dashboardLabelPanel.setStyleAttribute("background-color", "transparent");
                dashboardLabelPanel.add(label);
                imgRefreshLabel = new Label("<image src=\"eclipse/org/eclipse/kapua/app/console/icon/refresh.png\" " + "width=\"15\" height=\"15\" " + "style=\"vertical-align: middle\" title=\"" + MSGS.refreshButton() + "\"/>");
                dashboardLabelPanel.add(imgRefreshLabel);
                dashboardLabelPanel.setBodyStyle("background-color:transparent");
                imgRefreshLabel.addListener(Events.OnClick, new Listener<BaseEvent>() {

                    @Override
                    public void handleEvent(BaseEvent be) {
                        if (dashboardSelected) {
                            m_dashboardView.refresh();
                        }
                    }
                });
                return dashboardLabelPanel;
            }
            return label;
        }
    });
    ColumnModel cm = new ColumnModel(Arrays.asList(name));
    m_accountTree = new TreeGrid<ModelData>(m_accountStore, cm);
    m_accountTree.setBorders(false);
    m_accountTree.setHideHeaders(true);
    m_accountTree.setAutoExpandColumn("name");
    m_accountTree.getTreeView().setRowHeight(36);
    m_accountTree.getTreeView().setForceFit(true);
    m_accountTree.setIconProvider(new ModelIconProvider<ModelData>() {

        public AbstractImagePrototype getIcon(ModelData model) {
            if (model.get("icon") != null) {
                ImageResource ir = (ImageResource) model.get("icon");
                return AbstractImagePrototype.create(ir);
            } else {
                return null;
            }
        }
    });
    m_accountTree.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    m_accountTree.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<ModelData>() {

        @Override
        public void selectionChanged(SelectionChangedEvent<ModelData> se) {
            ModelData selected = se.getSelectedItem();
            if (selected == null)
                return;
            if (dashboardSelected && ((String) selected.get("id")).equals("dashboard")) {
                return;
            }
            m_manageTree.getSelectionModel().deselectAll();
            m_centerPanel.removeAll();
            ContentPanel panel = new ContentPanel(new FitLayout());
            panel.setBorders(false);
            panel.setBodyBorder(false);
            String selectedId = (String) selected.get("id");
            if ("dashboard".equals(selectedId)) {
                panel.setHeaderVisible(false);
                m_dashboardView = new DashboardView(m_currentSession);
                panel.add(m_dashboardView);
                m_centerPanel.add(panel);
                m_centerPanel.layout();
                dashboardSelected = true;
            } else if ("devices".equals(selectedId)) {
                panel.setHeaderVisible(false);
                panel.add(new DevicesView(m_currentSession));
                m_centerPanel.add(panel);
                m_centerPanel.layout();
                dashboardSelected = false;
            } else if ("user".equals(selectedId)) {
                panel.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.users16()));
                panel.setHeading(MSGS.users());
                UserView userView = new UserView(m_currentSession);
                userView.setAccount(m_currentSession.getSelectedAccount());
                panel.add(userView);
                m_centerPanel.add(panel);
                m_centerPanel.layout();
                userView.refresh();
                dashboardSelected = false;
            } else if ("mysettings".equals(selectedId)) {
                panel.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.settings()));
                panel.setHeading(MSGS.settings());
                AccountDetailsView settingView = new AccountDetailsView(null, m_currentSession);
                settingView.setAccount(m_currentSession.getSelectedAccount());
                panel.add(settingView);
                m_centerPanel.add(panel);
                m_centerPanel.layout();
                settingView.refresh();
            }
            imgRefreshLabel.setVisible(dashboardSelected);
        }
    });
    ColumnConfig name1 = new ColumnConfig("name", "Name", 100);
    name1.setRenderer(new WidgetTreeGridCellRenderer<ModelData>() {

        @Override
        public Widget getWidget(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
            Label label = new Label((String) model.get(property));
            label.setStyleAttribute("padding-left", "5px");
            return label;
        }
    });
    ColumnModel cm1 = new ColumnModel(Arrays.asList(name1));
    m_manageTree = new TreeGrid<ModelData>(m_manageStore, cm1);
    m_manageTree.setBorders(false);
    m_manageTree.setHideHeaders(true);
    m_manageTree.setAutoExpandColumn("name");
    m_manageTree.getTreeView().setRowHeight(36);
    m_manageTree.getTreeView().setForceFit(true);
    m_manageTree.setIconProvider(new ModelIconProvider<ModelData>() {

        public AbstractImagePrototype getIcon(ModelData model) {
            if (model.get("icon") != null) {
                ImageResource ir = (ImageResource) model.get("icon");
                return AbstractImagePrototype.create(ir);
            } else {
                return null;
            }
        }
    });
    m_manageTree.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    m_manageTree.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<ModelData>() {

        @Override
        public void selectionChanged(SelectionChangedEvent<ModelData> se) {
            ModelData selected = se.getSelectedItem();
            if (selected == null)
                return;
            m_accountTree.getSelectionModel().deselectAll();
            m_centerPanel.removeAll();
            ContentPanel panel = new ContentPanel(new FitLayout());
            panel.setBorders(false);
            panel.setBodyBorder(false);
            String selectedId = (String) selected.get("id");
            if ("childaccounts".equals(selectedId)) {
                panel.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.childAccounts16()));
                panel.setHeading(MSGS.childaccounts());
                AccountView accountView = new AccountView(m_currentSession);
                panel.add(accountView);
                dashboardSelected = false;
            }
            imgRefreshLabel.setVisible(dashboardSelected);
            m_centerPanel.add(panel);
            m_centerPanel.layout();
        }
    });
    m_accountPanel.add(m_accountTree);
    m_accountPanel.add(m_managePanel);
    m_accountPanel.add(m_manageTree);
    m_accountTree.getSelectionModel().select(0, false);
    m_accordionPanel.add(m_accountPanel);
}
Also used : AbstractImagePrototype(com.google.gwt.user.client.ui.AbstractImagePrototype) ModelData(com.extjs.gxt.ui.client.data.ModelData) BaseModelData(com.extjs.gxt.ui.client.data.BaseModelData) Listener(com.extjs.gxt.ui.client.event.Listener) SelectionChangedListener(com.extjs.gxt.ui.client.event.SelectionChangedListener) ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) Widget(com.google.gwt.user.client.ui.Widget) Label(com.extjs.gxt.ui.client.widget.Label) UserView(org.eclipse.kapua.app.console.client.user.UserView) DashboardView(org.eclipse.kapua.app.console.client.overview.DashboardView) ColumnData(com.extjs.gxt.ui.client.widget.grid.ColumnData) AccountDetailsView(org.eclipse.kapua.app.console.client.account.AccountDetailsView) ImageResource(com.google.gwt.resources.client.ImageResource) AccountView(org.eclipse.kapua.app.console.client.account.AccountView) FitLayout(com.extjs.gxt.ui.client.widget.layout.FitLayout) AccordionLayout(com.extjs.gxt.ui.client.widget.layout.AccordionLayout) BaseEvent(com.extjs.gxt.ui.client.event.BaseEvent) ContentPanel(com.extjs.gxt.ui.client.widget.ContentPanel) ColumnModel(com.extjs.gxt.ui.client.widget.grid.ColumnModel) DevicesView(org.eclipse.kapua.app.console.client.device.DevicesView)

Example 2 with SelectionChangedListener

use of com.extjs.gxt.ui.client.event.SelectionChangedListener in project geo-platform by geosdi.

the class BBOXCQLButton method initialize.

@Override
protected void initialize() {
    formData = new FormData("98%");
    final CQLLayerAttributesComboBox attributesComboBox = new CQLLayerAttributesComboBox(this.treePanel);
    attributesComboBox.setFieldLabel(LayerFiltersModuleConstants.INSTANCE.BBOXCQLButton_attributeComboBoxLabelText());
    this.minXField.setFieldLabel(LayerFiltersModuleConstants.INSTANCE.BBOXCQLButton_minXLabelText());
    this.maxXField.setFieldLabel(LayerFiltersModuleConstants.INSTANCE.BBOXCQLButton_maxXLabelText());
    this.minYField.setFieldLabel(LayerFiltersModuleConstants.INSTANCE.BBOXCQLButton_minYLabelText());
    this.maxYField.setFieldLabel(LayerFiltersModuleConstants.INSTANCE.BBOXCQLButton_maxYLabelText());
    final Button insertButton = new Button(ButtonsConstants.INSTANCE.insertText(), new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent be) {
            String theGeom = attributesComboBox.getValue().get(GPAttributeKey.ATTRIBUTE_VALUE.toString()).toString();
            BBOXCQLButton.super.insertTextIntoFilterArea("BBOX(" + theGeom + ", " + minXField.getValue() + ", " + maxXField.getValue() + ", " + minYField.getValue() + ", " + maxYField.getValue() + ")");
            window.hide();
        }
    });
    super.window = new GeoPlatformWindow(true) {

        @Override
        public void addComponent() {
            add(new Label(LayerFiltersModuleConstants.INSTANCE.BBOXCQLButton_windowInsertParametersLabelText()));
            add(attributesComboBox, formData);
            add(minXField, formData);
            add(minYField, formData);
            add(maxXField, formData);
            add(maxYField, formData);
            add(new Label(LayerFiltersModuleConstants.INSTANCE.BBOXCQLButton_windowResultLabelText()));
            insertButton.disable();
            addButton(insertButton);
        }

        @Override
        public void initSize() {
            super.setSize("300", "280");
        }

        @Override
        public void setWindowProperties() {
            super.setHeadingHtml(LayerFiltersModuleConstants.INSTANCE.BBOXCQLButton_windowHeadingText());
            super.setLayout(new FormLayout());
        }
    };
    final Listener listener = new Listener<BaseEvent>() {

        @Override
        public void handleEvent(BaseEvent be) {
            String theGeomValue = attributesComboBox.getValue().get(GPAttributeKey.ATTRIBUTE_VALUE.toString()).toString();
            Number minXValue = minXField.getValue();
            Number maxXValue = maxXField.getValue();
            Number maxYValue = maxYField.getValue();
            Number minYValue = minYField.getValue();
            if (minXValue == null || minXValue.toString().isEmpty() || maxXValue == null || maxXValue.toString().isEmpty() || maxYValue == null || maxYValue.toString().isEmpty() || minYValue == null || minYValue.toString().isEmpty() || theGeomValue == null || theGeomValue.isEmpty()) {
                insertButton.disable();
            } else {
                insertButton.enable();
            }
        }
    };
    minXField.addListener(Events.OnKeyUp, listener);
    maxXField.addListener(Events.OnKeyUp, listener);
    maxYField.addListener(Events.OnKeyUp, listener);
    minYField.addListener(Events.OnKeyUp, listener);
    attributesComboBox.addSelectionChangedListener(new SelectionChangedListener<GPLayerAttributes>() {

        @Override
        public void selectionChanged(SelectionChangedEvent<GPLayerAttributes> se) {
            listener.handleEvent(se);
        }
    });
    super.initialized = Boolean.TRUE;
}
Also used : FormData(com.extjs.gxt.ui.client.widget.layout.FormData) FormLayout(com.extjs.gxt.ui.client.widget.layout.FormLayout) Listener(com.extjs.gxt.ui.client.event.Listener) SelectionChangedListener(com.extjs.gxt.ui.client.event.SelectionChangedListener) SelectionListener(com.extjs.gxt.ui.client.event.SelectionListener) GPLayerAttributes(org.geosdi.geoplatform.gui.model.tree.GPLayerAttributes) Label(com.extjs.gxt.ui.client.widget.Label) BaseEvent(com.extjs.gxt.ui.client.event.BaseEvent) GeoPlatformWindow(org.geosdi.geoplatform.gui.client.widget.GeoPlatformWindow) Button(com.extjs.gxt.ui.client.widget.button.Button) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent) CQLLayerAttributesComboBox(org.geosdi.geoplatform.gui.client.widget.cql.combobox.CQLLayerAttributesComboBox)

Aggregations

BaseEvent (com.extjs.gxt.ui.client.event.BaseEvent)2 Listener (com.extjs.gxt.ui.client.event.Listener)2 SelectionChangedListener (com.extjs.gxt.ui.client.event.SelectionChangedListener)2 Label (com.extjs.gxt.ui.client.widget.Label)2 BaseModelData (com.extjs.gxt.ui.client.data.BaseModelData)1 ModelData (com.extjs.gxt.ui.client.data.ModelData)1 ButtonEvent (com.extjs.gxt.ui.client.event.ButtonEvent)1 SelectionListener (com.extjs.gxt.ui.client.event.SelectionListener)1 ContentPanel (com.extjs.gxt.ui.client.widget.ContentPanel)1 Button (com.extjs.gxt.ui.client.widget.button.Button)1 ColumnConfig (com.extjs.gxt.ui.client.widget.grid.ColumnConfig)1 ColumnData (com.extjs.gxt.ui.client.widget.grid.ColumnData)1 ColumnModel (com.extjs.gxt.ui.client.widget.grid.ColumnModel)1 AccordionLayout (com.extjs.gxt.ui.client.widget.layout.AccordionLayout)1 FitLayout (com.extjs.gxt.ui.client.widget.layout.FitLayout)1 FormData (com.extjs.gxt.ui.client.widget.layout.FormData)1 FormLayout (com.extjs.gxt.ui.client.widget.layout.FormLayout)1 ImageResource (com.google.gwt.resources.client.ImageResource)1 AbstractImagePrototype (com.google.gwt.user.client.ui.AbstractImagePrototype)1 Widget (com.google.gwt.user.client.ui.Widget)1