Search in sources :

Example 1 with SaveViewportAction

use of org.geosdi.geoplatform.gui.client.action.viewport.SaveViewportAction in project geo-platform by geosdi.

the class ViewportGridFieldSet method addComponents.

@Override
public void addComponents() {
    store.addStoreListener(new StoreListener<GPClientViewport>() {

        @Override
        public void storeUpdate(StoreEvent<GPClientViewport> se) {
            super.storeUpdate(se);
            ViewportGridFieldSet.this.saveButton.enable();
        }
    });
    this.add(createViewportFilter());
    this.add(this.generateGrid(), new FormData("100%"));
    ButtonBar buttonBar = new ButtonBar();
    Button addEntryButton = new Button(MapModuleConstants.INSTANCE.ViewportGridFieldSet_buttonAddViewportText(), AbstractImagePrototype.create(BasicWidgetResources.ICONS.done()), new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            ViewportGridFieldSet.this.store.add(ViewportUtility.generateViewportFromMap(map));
            viewportGrid.startEditing(store.getCount() - 1, 1);
            ViewportGridFieldSet.this.saveButton.enable();
        }
    });
    buttonBar.add(addEntryButton);
    this.deleteViewportButton = new Button(MapModuleConstants.INSTANCE.ViewportGridFieldSet_buttonDeleteViewportText(), AbstractImagePrototype.create(BasicWidgetResources.ICONS.delete()), new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            final List<GPClientViewport> viewportList = viewportGrid.getSelectionModel().getSelectedItems();
            if (viewportList != null) {
                GeoPlatformMessage.confirmMessage(MapModuleConstants.INSTANCE.ViewportGridFieldSet_confirmDeleteViewportTitleText(), MapModuleConstants.INSTANCE.ViewportGridFieldSet_confirmDeleteViewportBodyText(), new Listener<MessageBoxEvent>() {

                    @Override
                    public void handleEvent(MessageBoxEvent be) {
                        if (Dialog.YES.equals(be.getButtonClicked().getItemId())) {
                            for (GPClientViewport viewport : viewportList) {
                                store.remove(viewport);
                                ViewportGridFieldSet.this.saveButton.enable();
                            }
                        }
                    }
                });
            }
        }
    });
    deleteViewportButton.setEnabled(Boolean.FALSE);
    buttonBar.add(deleteViewportButton);
    this.gotoViewportButton = new Button(MapModuleConstants.INSTANCE.ViewportGridFieldSet_buttonGoToViewportText(), AbstractImagePrototype.create(BasicWidgetResources.ICONS.gotoXY()), new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            final List<GPClientViewport> viewportList = viewportGrid.getSelectionModel().getSelectedItems();
            if (viewportList != null && viewportList.size() == 1) {
                ViewportUtility.gotoViewportLocation(map, viewportList.get(0));
            } else {
                GeoPlatformMessage.alertMessage(MapModuleConstants.INSTANCE.ViewportGridFieldSet_singleSelectionAlertTitleText(), MapModuleConstants.INSTANCE.ViewportGridFieldSet_singleSelectionAlertBodyText());
            }
        }
    });
    gotoViewportButton.setEnabled(Boolean.FALSE);
    buttonBar.add(gotoViewportButton);
    this.setDefaultViewportButton = new Button(ButtonsConstants.INSTANCE.setDefautlText(), AbstractImagePrototype.create(BasicWidgetResources.ICONS.select()), new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            final List<GPClientViewport> viewportList = viewportGrid.getSelectionModel().getSelectedItems();
            if (viewportList != null && viewportList.size() == 1) {
                GPClientViewport selectedViewport = viewportList.get(0);
                for (GPClientViewport viewport : ViewportGridFieldSet.this.store.getModels()) {
                    if (viewport.isDefault()) {
                        viewport.set(ViewportEnum.IS_DEFAULT.toString(), Boolean.FALSE);
                        store.update(viewport);
                    } else if (selectedViewport.equals(viewport)) {
                        viewport.set(ViewportEnum.IS_DEFAULT.toString(), Boolean.TRUE);
                        store.update(viewport);
                    }
                }
            } else {
                GeoPlatformMessage.alertMessage(MapModuleConstants.INSTANCE.ViewportGridFieldSet_setDefaultViewportAlertTitleText(), MapModuleConstants.INSTANCE.ViewportGridFieldSet_singleSelectionAlertBodyText());
            }
        }
    });
    setDefaultViewportButton.setEnabled(Boolean.FALSE);
    buttonBar.add(setDefaultViewportButton);
    SaveViewportAction saveViewportAction = new SaveViewportAction(GPTrustedLevel.LOW, this.store);
    this.saveButton = new GPSecureButton(ButtonsConstants.INSTANCE.saveText(), AbstractImagePrototype.create(BasicWidgetResources.ICONS.save()), saveViewportAction);
    buttonBar.add(this.saveButton);
    this.add(buttonBar, new FormData("100%"));
}
Also used : FormData(com.extjs.gxt.ui.client.widget.layout.FormData) ButtonBar(com.extjs.gxt.ui.client.widget.button.ButtonBar) GPSecureButton(org.geosdi.geoplatform.gui.action.button.GPSecureButton) SaveViewportAction(org.geosdi.geoplatform.gui.client.action.viewport.SaveViewportAction) GPClientViewport(org.geosdi.geoplatform.gui.configuration.map.client.GPClientViewport) GPSecureButton(org.geosdi.geoplatform.gui.action.button.GPSecureButton) Button(com.extjs.gxt.ui.client.widget.button.Button)

Aggregations

Button (com.extjs.gxt.ui.client.widget.button.Button)1 ButtonBar (com.extjs.gxt.ui.client.widget.button.ButtonBar)1 FormData (com.extjs.gxt.ui.client.widget.layout.FormData)1 GPSecureButton (org.geosdi.geoplatform.gui.action.button.GPSecureButton)1 SaveViewportAction (org.geosdi.geoplatform.gui.client.action.viewport.SaveViewportAction)1 GPClientViewport (org.geosdi.geoplatform.gui.configuration.map.client.GPClientViewport)1