Search in sources :

Example 1 with Window

use of com.extjs.gxt.ui.client.widget.Window in project kura by eclipse.

the class WirelessConfigTab method createWifiNetworksWindow.

private Window createWifiNetworksWindow() {
    final Window window = new Window();
    window.setSize(700, 400);
    window.setPlain(true);
    window.setModal(true);
    window.setBlinkModal(true);
    window.setHeading("Wireless Networks");
    // Create a table to layout the content
    VerticalPanel dialogContents = new VerticalPanel();
    dialogContents.setSpacing(4);
    window.add(dialogContents);
    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
    ColumnConfig column = null;
    column = new ColumnConfig("ssid", "SSID", 100);
    column.setAlignment(HorizontalAlignment.LEFT);
    configs.add(column);
    column = new ColumnConfig("macAddress", "MAC Address", 100);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("signalStrength", "Signal (dBm)", 100);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("channel", "Channel", 100);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("frequency", "Frequency", 100);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("security", "Security", 100);
    column.setAlignment(HorizontalAlignment.LEFT);
    configs.add(column);
    /*
        CheckColumnConfig checkColumn = new CheckColumnConfig("selectAP", "Select", 55);
        CellEditor checkBoxEditor = new CellEditor(new CheckBox());  
        checkColumn.setEditor(checkBoxEditor);
        configs.add(checkColumn); 
		 */
    // rpc data proxy
    RpcProxy<ListLoadResult<GwtWifiHotspotEntry>> proxy = new RpcProxy<ListLoadResult<GwtWifiHotspotEntry>>() {

        @Override
        protected void load(Object loadConfig, final AsyncCallback<ListLoadResult<GwtWifiHotspotEntry>> callback) {
            gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {

                @Override
                public void onFailure(Throwable ex) {
                    FailureHandler.handle(ex);
                }

                @Override
                public void onSuccess(GwtXSRFToken token) {
                    gwtNetworkService.findWifiHotspots(token, m_selectNetIfConfig.getName(), callback);
                }
            });
        }
    };
    m_wifiHotspotLoader = new BaseListLoader<ListLoadResult<GwtWifiHotspotEntry>>(proxy);
    m_wifiHotspotLoader.setSortDir(SortDir.ASC);
    m_wifiHotspotLoader.setSortField("signalStrength");
    // m_wifiHotspotLoader.setRemoteSort(true);
    SwappableListStore<GwtWifiHotspotEntry> store = new SwappableListStore<GwtWifiHotspotEntry>(m_wifiHotspotLoader);
    store.setKeyProvider(new ModelKeyProvider<GwtWifiHotspotEntry>() {

        public String getKey(GwtWifiHotspotEntry wifiHotspotEntry) {
            return wifiHotspotEntry.getSignalStrength().toString();
        }
    });
    m_grid = new Grid<GwtWifiHotspotEntry>(store, new ColumnModel(configs));
    m_grid.setBorders(false);
    m_grid.setStateful(false);
    m_grid.setLoadMask(true);
    m_grid.setStripeRows(true);
    m_grid.setColumnLines(true);
    m_grid.setColumnReordering(true);
    m_grid.setAutoExpandColumn("ssid");
    m_grid.getView().setAutoFill(true);
    // m_grid.addPlugin(checkColumn);
    m_wifiHotspotLoader.addLoadListener(new DataLoadListener(m_grid));
    GridSelectionModel<GwtWifiHotspotEntry> selectionModel = new GridSelectionModel<GwtWifiHotspotEntry>();
    selectionModel.setSelectionMode(SelectionMode.SINGLE);
    m_grid.setSelectionModel(selectionModel);
    // m_grid.addPlugin(selectionModel);
    m_grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GwtWifiHotspotEntry>() {

        @Override
        public void selectionChanged(SelectionChangedEvent<GwtWifiHotspotEntry> se) {
            if (se != null) {
                List<GwtWifiHotspotEntry> list = se.getSelection();
                if ((list != null) && (list.size() > 0)) {
                    GwtWifiHotspotEntry wifiHotspotEntry = list.get(0);
                    if (wifiHotspotEntry != null) {
                        m_ssidField.setValue(GwtSafeHtmlUtils.htmlUnescape(wifiHotspotEntry.getSSID()));
                        String security = wifiHotspotEntry.getSecurity();
                        if (security.equals("None")) {
                            m_securityCombo.setSimpleValue(MessageUtils.get(GwtWifiSecurity.netWifiSecurityNONE.name()));
                        } else if (security.equals("WEP")) {
                            m_securityCombo.setSimpleValue(MessageUtils.get(GwtWifiSecurity.netWifiSecurityWEP.name()));
                        } else if (security.equals("WPA")) {
                            m_securityCombo.setSimpleValue(MessageUtils.get(GwtWifiSecurity.netWifiSecurityWPA.name()));
                        } else if (security.equals("WPA2") || security.equals("WPA/WPA2")) {
                            m_securityCombo.setSimpleValue(MessageUtils.get(GwtWifiSecurity.netWifiSecurityWPA2.name()));
                        } else {
                            m_securityCombo.setSimpleValue(MessageUtils.get(GwtWifiSecurity.netWifiSecurityNONE.name()));
                        }
                        if (security.equals("WPA") || security.equals("WPA2") || security.equals("WPA/WPA2")) {
                            GwtWifiCiphers pairwiseCiphers = wifiHotspotEntry.getPairwiseCiphersEnum();
                            if (pairwiseCiphers == GwtWifiCiphers.netWifiCiphers_TKIP) {
                                m_pairwiseCiphersCombo.setSimpleValue(MessageUtils.get(GwtWifiCiphers.netWifiCiphers_TKIP.name()));
                            } else if (pairwiseCiphers == GwtWifiCiphers.netWifiCiphers_CCMP) {
                                m_pairwiseCiphersCombo.setSimpleValue(MessageUtils.get(GwtWifiCiphers.netWifiCiphers_CCMP.name()));
                            } else if (pairwiseCiphers == GwtWifiCiphers.netWifiCiphers_CCMP_TKIP) {
                                m_pairwiseCiphersCombo.setSimpleValue(MessageUtils.get(GwtWifiCiphers.netWifiCiphers_CCMP_TKIP.name()));
                            } else {
                                // let's set it for CCMP TKIP
                                m_pairwiseCiphersCombo.setSimpleValue(MessageUtils.get(GwtWifiCiphers.netWifiCiphers_CCMP_TKIP.name()));
                            }
                            GwtWifiCiphers groupCiphers = wifiHotspotEntry.getGroupCiphersEnum();
                            if (groupCiphers == GwtWifiCiphers.netWifiCiphers_TKIP) {
                                m_groupCiphersCombo.setSimpleValue(MessageUtils.get(GwtWifiCiphers.netWifiCiphers_TKIP.name()));
                            } else if (groupCiphers == GwtWifiCiphers.netWifiCiphers_CCMP) {
                                m_groupCiphersCombo.setSimpleValue(MessageUtils.get(GwtWifiCiphers.netWifiCiphers_CCMP.name()));
                            } else if (groupCiphers == GwtWifiCiphers.netWifiCiphers_CCMP_TKIP) {
                                m_groupCiphersCombo.setSimpleValue(MessageUtils.get(GwtWifiCiphers.netWifiCiphers_CCMP_TKIP.name()));
                            } else {
                                // let's set it for CCMP TKIP
                                m_groupCiphersCombo.setSimpleValue(MessageUtils.get(GwtWifiCiphers.netWifiCiphers_CCMP_TKIP.name()));
                            }
                        }
                        // deselect all channels
                        for (int channel = 1; channel <= MAX_WIFI_CHANNEL; channel++) {
                            m_checkboxChannelSelectionModel.deselect(channel - 1);
                        }
                        // select proper channels
                        m_checkboxChannelSelectionModel.select(wifiHotspotEntry.getChannel() - 1, true);
                        window.hide();
                    }
                }
            }
        }
    });
    ContentPanel cp = new ContentPanel();
    cp.setHeading("Wireless Networks in Range");
    cp.setFrame(true);
    cp.setSize(680, 365);
    FillLayout layout = new FillLayout();
    layout.setAdjustForScroll(true);
    cp.setLayout(layout);
    cp.add(m_grid);
    dialogContents.add(cp);
    window.add(dialogContents);
    return window;
}
Also used : ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) GwtWifiCiphers(org.eclipse.kura.web.shared.model.GwtWifiCiphers) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) ArrayList(java.util.ArrayList) GwtXSRFToken(org.eclipse.kura.web.shared.model.GwtXSRFToken) RpcProxy(com.extjs.gxt.ui.client.data.RpcProxy) SwappableListStore(org.eclipse.kura.web.client.util.SwappableListStore) NodeList(com.google.gwt.dom.client.NodeList) List(java.util.List) ArrayList(java.util.ArrayList) Window(com.extjs.gxt.ui.client.widget.Window) GridSelectionModel(com.extjs.gxt.ui.client.widget.grid.GridSelectionModel) FillLayout(com.extjs.gxt.ui.client.widget.layout.FillLayout) ContentPanel(com.extjs.gxt.ui.client.widget.ContentPanel) ListLoadResult(com.extjs.gxt.ui.client.data.ListLoadResult) VerticalPanel(com.extjs.gxt.ui.client.widget.VerticalPanel) GwtWifiHotspotEntry(org.eclipse.kura.web.shared.model.GwtWifiHotspotEntry) ColumnModel(com.extjs.gxt.ui.client.widget.grid.ColumnModel)

Example 2 with Window

use of com.extjs.gxt.ui.client.widget.Window in project jahia by Jahia.

the class SaveAsViewButtonItem method create.

@Override
public BoxComponent create(final AbstractContentEngine engine) {
    Button button = new Button(Messages.get("label.saveAs", "Save as ..."));
    button.addStyleName("button-saveas");
    button.setHeight(BUTTON_HEIGHT);
    button.setIcon(StandardIconsProvider.STANDARD_ICONS.engineButtonOK());
    button.addSelectionListener(new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent event) {
            GWTJahiaNode node = engine.getNode();
            if (node == null) {
                node = engine.getTargetNode();
            }
            final String[] filePath = node.getPath().split("/");
            final String moduleVersion;
            final String fileType;
            final String fileTemplateType;
            final String fileName;
            final String fileView;
            if ("modules".equals(filePath[1])) {
                moduleVersion = (String) JahiaGWTParameters.getSiteNode().getProperties().get("j:versionInfo");
                if (engine instanceof CreateContentEngine) {
                    // extract view name from target name
                    final String targetName = ((CreateContentEngine) engine).getTargetName();
                    final int periodIndex = targetName.indexOf('.');
                    if (periodIndex > 0) {
                        fileType = targetName.substring(0, periodIndex);
                        fileView = targetName.substring(periodIndex + 1);
                    } else {
                        fileType = targetName;
                        fileView = "default";
                    }
                    final int nsIndex = fileType.indexOf('_');
                    fileName = nsIndex > 1 ? fileType.substring(nsIndex + 1) + ".jsp" : fileType + ".jsp";
                    fileTemplateType = "html";
                } else {
                    fileType = filePath[INDEX_OF_FILE_TYPE];
                    fileName = filePath[INDEX_OF_FILE_NAME];
                    fileTemplateType = filePath[INDEX_OF_TEMPLATE_TYPE];
                    fileView = "default";
                }
            } else {
                MessageBox.alert(Messages.get("label.error", "Error"), Messages.getWithArgs("label.issueOccursTryingResolve", "An issue occurred when trying to resolve {0}", new Object[] { node.getPath() }), null).getDialog().addStyleName("engine-save-error");
                return;
            }
            final String modulePath = "/modules/" + filePath[INDEX_OF_MODULE_NAME];
            final String moduleName = filePath[INDEX_OF_MODULE_NAME];
            // Open popup to select module
            final Window popup = new Window();
            popup.addStyleName("save-as-view-modal");
            popup.setHeadingHtml(Messages.get("label.saveAsView", "Save as view"));
            popup.setHeight(200);
            popup.setWidth(350);
            popup.setModal(true);
            FormPanel f = new FormPanel();
            f.setHeaderVisible(false);
            final SimpleComboBox<String> dependenciesCombo = new SimpleComboBox<String>();
            if (JahiaGWTParameters.getSiteNode() != null) {
                dependenciesCombo.setStore(new ListStore<SimpleComboValue<String>>());
                dependenciesCombo.setFieldLabel(Messages.get("label.module", "Module"));
                dependenciesCombo.setTriggerAction(ComboBox.TriggerAction.ALL);
                dependenciesCombo.add(moduleName);
                for (GWTJahiaNode n : JahiaGWTParameters.getSitesMap().values()) {
                    dependenciesCombo.add(n.getName());
                }
                dependenciesCombo.getStore().sort("value", Style.SortDir.ASC);
                dependenciesCombo.setSimpleValue(moduleName);
                f.add(dependenciesCombo);
            }
            final TextField<String> templateType = new TextField<String>();
            templateType.setFieldLabel(Messages.get("label.templateType", "template Type"));
            templateType.setValue(fileTemplateType);
            f.add(templateType);
            final TextField<String> viewName = new TextField<String>();
            viewName.setFieldLabel(Messages.get("label.viewName", "View name"));
            viewName.setValue(fileView);
            f.add(viewName);
            Button b = new Button(Messages.get("label.submit", "submit"));
            b.addStyleName("button-submit");
            f.addButton(b);
            b.addSelectionListener(new SelectionListener<ButtonEvent>() {

                @Override
                public void componentSelected(ButtonEvent buttonEvent) {
                    String newModuleName = moduleName;
                    String newModulePath = modulePath;
                    String newModuleVersion = moduleVersion;
                    GWTJahiaNode newModuleNode = null;
                    final String dependenciesValue = dependenciesCombo.getSimpleValue();
                    if (!newModuleName.equals(dependenciesValue)) {
                        for (GWTJahiaNode n : JahiaGWTParameters.getSitesMap().values()) {
                            if (n.getName().equals(dependenciesValue)) {
                                newModuleNode = n;
                                newModuleName = dependenciesValue;
                                newModulePath = n.getPath();
                                newModuleVersion = (String) n.getProperties().get("j:versionInfo");
                                break;
                            }
                        }
                    }
                    final String templateTypeValue = templateType.getValue();
                    String newfileTemplateType = !"".equals(templateTypeValue) ? templateTypeValue : fileTemplateType;
                    String newfileView;
                    String viewNameValue = viewName.getValue();
                    if (viewNameValue == null || viewNameValue.equals("default") || viewNameValue.trim().equals("")) {
                        newfileView = "";
                    } else {
                        newfileView = "." + viewNameValue;
                    }
                    final String versionSourceTypePath = "/" + newModuleVersion + VIEWS_SOURCE_PATH + "/" + fileType;
                    final String templatePath = versionSourceTypePath + "/" + newfileTemplateType;
                    newModulePath = newModulePath + templatePath;
                    final int nsIndex = fileType.indexOf('_');
                    String ft = nsIndex > 1 ? fileType.substring(nsIndex + 1) : fileName;
                    String newViewName = ft + newfileView + fileName.substring(fileName.lastIndexOf('.'));
                    Map<String, String> parentNodesType = new LinkedHashMap<java.lang.String, java.lang.String>();
                    final String modulePathStart = "/modules/" + newModuleName;
                    parentNodesType.put(modulePathStart + versionSourceTypePath, "jnt:folder");
                    parentNodesType.put(modulePathStart + templatePath, "jnt:folder");
                    parentNodesType.put(newfileTemplateType, "jnt:folder");
                    prepareAndSave(newModulePath, newViewName, parentNodesType, engine, newModuleNode);
                    popup.hide();
                }
            });
            Button c = new Button(Messages.get("label.cancel", "Cancel"));
            c.addStyleName("button-cancel");
            c.addSelectionListener(new SelectionListener<ButtonEvent>() {

                @Override
                public void componentSelected(ButtonEvent buttonEvent) {
                    popup.hide();
                }
            });
            f.addButton(c);
            f.setButtonAlign(Style.HorizontalAlignment.CENTER);
            FormButtonBinding binding = new FormButtonBinding(f);
            binding.addButton(b);
            popup.add(f);
            popup.setFocusWidget(viewName);
            popup.show();
            viewName.setCursorPos(viewName.getValue().length());
        }
    });
    return button;
}
Also used : Window(com.extjs.gxt.ui.client.widget.Window) GWTJahiaNode(org.jahia.ajax.gwt.client.data.node.GWTJahiaNode) ListStore(com.extjs.gxt.ui.client.store.ListStore) Button(com.extjs.gxt.ui.client.widget.button.Button) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent) SelectionListener(com.extjs.gxt.ui.client.event.SelectionListener)

Example 3 with Window

use of com.extjs.gxt.ui.client.widget.Window in project jahia by Jahia.

the class CreateButtonItem method showNamePopup.

protected void showNamePopup(final AbstractContentEngine engine, final boolean closeAfterSave) {
    final Window popup = new Window();
    popup.addStyleName("set-name-modal");
    popup.setHeadingHtml(Messages.get("label.saveAs", "Save as ..."));
    popup.setHeight(120);
    popup.setWidth(350);
    popup.setModal(true);
    FormPanel f = new FormPanel();
    f.setHeaderVisible(false);
    f.setBorders(false);
    final TextField<String> name = new TextField<String>();
    name.setFieldLabel(Messages.get("label.name", "Name"));
    name.setMinLength(1);
    f.add(name);
    Button b = new Button(Messages.get("label.submit", "submit"));
    b.addStyleName("button-submit");
    f.addButton(b);
    b.addSelectionListener(new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent buttonEvent) {
            continuePrepareAndSave(engine, closeAfterSave, name.getValue());
            popup.hide();
        }
    });
    Button c = new Button(Messages.get("label.cancel", "Cancel"));
    c.addStyleName("button-cancel");
    c.addSelectionListener(new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent buttonEvent) {
            popup.hide();
        }
    });
    f.addButton(c);
    f.setButtonAlign(Style.HorizontalAlignment.CENTER);
    FormButtonBinding binding = new FormButtonBinding(f);
    binding.addButton(b);
    popup.add(f);
    popup.setFocusWidget(name);
    popup.show();
}
Also used : Window(com.extjs.gxt.ui.client.widget.Window) FormPanel(com.extjs.gxt.ui.client.widget.form.FormPanel) Button(com.extjs.gxt.ui.client.widget.button.Button) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent) FormButtonBinding(com.extjs.gxt.ui.client.widget.form.FormButtonBinding) TextField(com.extjs.gxt.ui.client.widget.form.TextField)

Example 4 with Window

use of com.extjs.gxt.ui.client.widget.Window in project jahia by Jahia.

the class CreateResourceButtonItem method create.

@Override
public BoxComponent create(final AbstractContentEngine engine) {
    Button button = new Button(Messages.get("label.save", "Save"));
    button.setHeight(BUTTON_HEIGHT);
    button.addStyleName("button-save");
    button.setIcon(StandardIconsProvider.STANDARD_ICONS.engineButtonOK());
    button.addSelectionListener(new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent event) {
            GWTJahiaNode node = engine.getNode();
            if (node == null) {
                node = engine.getTargetNode();
            }
            final String nodePath = node.getPath();
            final Window popup = new Window();
            popup.addStyleName("create-resource-save-modal");
            popup.setHeadingHtml(Messages.get("label.saveAs", "Save as..."));
            popup.setHeight(120);
            popup.setWidth(350);
            popup.setModal(true);
            FormPanel f = new FormPanel();
            f.setHeaderVisible(false);
            f.setBorders(false);
            final TextField<String> name = new TextField<String>();
            name.setFieldLabel(Messages.get("label.name", "Name"));
            name.setMinLength(1);
            f.add(name);
            Button b = new Button(Messages.get("label.submit", "submit"));
            b.addStyleName("button-submit");
            f.addButton(b);
            b.addSelectionListener(new SelectionListener<ButtonEvent>() {

                @Override
                public void componentSelected(ButtonEvent buttonEvent) {
                    Map<String, String> parentNodesType = new LinkedHashMap<String, String>();
                    parentNodesType.put(nodePath, "jnt:folder");
                    String finalName = name.getValue();
                    if (fileExtension != null && !finalName.endsWith("." + fileExtension)) {
                        finalName += "." + fileExtension;
                    }
                    prepareAndSave(nodePath, finalName, parentNodesType, (CreateContentEngine) engine);
                    popup.hide();
                }
            });
            Button c = new Button(Messages.get("label.cancel", "Cancel"));
            c.addStyleName("button-cancel");
            c.addSelectionListener(new SelectionListener<ButtonEvent>() {

                @Override
                public void componentSelected(ButtonEvent buttonEvent) {
                    popup.hide();
                }
            });
            f.addButton(c);
            f.setButtonAlign(Style.HorizontalAlignment.CENTER);
            FormButtonBinding binding = new FormButtonBinding(f);
            binding.addButton(b);
            popup.add(f);
            popup.setFocusWidget(name);
            popup.show();
        }
    });
    return button;
}
Also used : Window(com.extjs.gxt.ui.client.widget.Window) GWTJahiaNode(org.jahia.ajax.gwt.client.data.node.GWTJahiaNode) FormButtonBinding(com.extjs.gxt.ui.client.widget.form.FormButtonBinding) FormPanel(com.extjs.gxt.ui.client.widget.form.FormPanel) Button(com.extjs.gxt.ui.client.widget.button.Button) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent) TextField(com.extjs.gxt.ui.client.widget.form.TextField) SelectionListener(com.extjs.gxt.ui.client.event.SelectionListener)

Example 5 with Window

use of com.extjs.gxt.ui.client.widget.Window in project jahia by Jahia.

the class ContentPickerField method onTriggerClick.

@Override
protected void onTriggerClick(ComponentEvent ce) {
    super.onTriggerClick(ce);
    if (disabled || isReadOnly()) {
        return;
    }
    if (configuration.equals("userpicker")) {
        new UserGroupSelect(new UserPickerAdder(), UserGroupSelect.VIEW_USERS, JahiaGWTParameters.getSiteNode().getName(), !multiple);
    } else if (configuration.equals("usergrouppicker")) {
        new UserGroupSelect(new UserPickerAdder(), UserGroupSelect.VIEW_TABS, JahiaGWTParameters.getSiteNode().getName(), !multiple);
    } else if (configuration.equals("custompicker")) {
        JahiaContentManagementService.App.getInstance().getManagerConfiguration(selectorOptions.get("config"), null, new BaseAsyncCallback<GWTManagerConfiguration>() {

            public void onSuccess(GWTManagerConfiguration config) {
                PermissionsUtils.loadPermissions(config.getPermissions());
                final Window w = new Window();
                w.setLayout(new FitLayout());
                w.setId("JahiaGxtCustomContentPickerWindow");
                w.addStyleName("modal-" + configuration);
                final CustomContentPicker contentPicker = new CustomContentPicker(config.getCustomPickerConfiguration(), getValue(), config.getSiteNode());
                if (config.getTitle() != null) {
                    w.setHeadingHtml(config.getTitle());
                } else {
                    w.setHeadingHtml(Messages.get("label." + config.getName(), config.getName()));
                }
                int windowHeight = com.google.gwt.user.client.Window.getClientHeight() - 10;
                w.setModal(true);
                w.setSize(900, windowHeight);
                w.setResizable(true);
                w.setMaximizable(true);
                w.setBodyBorder(false);
                final ButtonBar bar = new ButtonBar();
                bar.setAlignment(Style.HorizontalAlignment.CENTER);
                final Button ok = new Button(Messages.get("label.save"), new SelectionListener<ButtonEvent>() {

                    public void componentSelected(ButtonEvent event) {
                        List<String> values = contentPicker.getValues();
                        JahiaContentManagementService.App.getInstance().getNodes(values, null, new BaseAsyncCallback<List<GWTJahiaNode>>() {

                            @Override
                            public void onSuccess(List<GWTJahiaNode> gwtJahiaNodes) {
                                setValue(gwtJahiaNodes);
                                w.hide();
                            }
                        });
                    }
                });
                ok.addStyleName("button-save");
                ok.setIcon(StandardIconsProvider.STANDARD_ICONS.engineButtonOK());
                bar.add(ok);
                if (getValue() == null || getValue().size() == 0) {
                    ok.setEnabled(false);
                }
                ok.setEnabled(true);
                final Button cancel = new Button(Messages.get("label.cancel"), new SelectionListener<ButtonEvent>() {

                    public void componentSelected(ButtonEvent event) {
                        w.hide();
                    }
                });
                cancel.setIcon(StandardIconsProvider.STANDARD_ICONS.engineButtonCancel());
                cancel.addStyleName("button-cancel");
                bar.add(cancel);
                w.add(contentPicker);
                w.setBottomComponent(bar);
                w.show();
                contentPicker.loadData();
            }

            public void onApplicationFailure(Throwable throwable) {
                Log.error("Error while loading user permission", throwable);
            }
        });
    } else {
        JahiaContentManagementService.App.getInstance().getManagerConfiguration(configuration, null, new BaseAsyncCallback<GWTManagerConfiguration>() {

            public void onSuccess(GWTManagerConfiguration config) {
                PermissionsUtils.loadPermissions(config.getPermissions());
                final Window w = new Window();
                w.setLayout(new FitLayout());
                w.setId("JahiaGxtContentPickerWindow");
                w.addStyleName("modal-" + configuration);
                final ContentPicker contentPicker = new ContentPicker(selectorOptions, getValue(), types, filters, mimeTypes, config, multiple);
                if (config.getTitle() != null) {
                    w.setHeadingHtml(config.getTitle());
                } else {
                    w.setHeadingHtml(Messages.get("label." + config.getName(), config.getName()));
                }
                int windowHeight = com.google.gwt.user.client.Window.getClientHeight() - 10;
                w.setModal(true);
                w.setSize(900, windowHeight);
                w.setResizable(true);
                w.setMaximizable(true);
                w.setBodyBorder(false);
                final ButtonBar bar = new ButtonBar();
                bar.setAlignment(Style.HorizontalAlignment.CENTER);
                final Button ok = new Button(Messages.get("label.save"), new SelectionListener<ButtonEvent>() {

                    public void componentSelected(ButtonEvent event) {
                        List<GWTJahiaNode> selection = contentPicker.getSelectedNodes();
                        setValue(selection);
                        w.hide();
                    }
                });
                ok.addStyleName("button-save");
                ok.setIcon(StandardIconsProvider.STANDARD_ICONS.engineButtonOK());
                bar.add(ok);
                contentPicker.setSaveButton(ok);
                if (getValue() == null || getValue().size() == 0) {
                    ok.setEnabled(false);
                }
                final Button cancel = new Button(Messages.get("label.cancel"), new SelectionListener<ButtonEvent>() {

                    public void componentSelected(ButtonEvent event) {
                        w.hide();
                    }
                });
                cancel.setIcon(StandardIconsProvider.STANDARD_ICONS.engineButtonCancel());
                cancel.addStyleName("button-cancel");
                bar.add(cancel);
                w.add(contentPicker);
                w.setBottomComponent(bar);
                w.show();
            }

            public void onApplicationFailure(Throwable throwable) {
                Log.error("Error while loading user permission", throwable);
            }
        });
    }
}
Also used : Window(com.extjs.gxt.ui.client.widget.Window) ButtonBar(com.extjs.gxt.ui.client.widget.button.ButtonBar) GWTJahiaNode(org.jahia.ajax.gwt.client.data.node.GWTJahiaNode) GWTManagerConfiguration(org.jahia.ajax.gwt.client.data.toolbar.GWTManagerConfiguration) UserGroupSelect(org.jahia.ajax.gwt.client.widget.usergroup.UserGroupSelect) Button(com.extjs.gxt.ui.client.widget.button.Button) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent) ArrayList(java.util.ArrayList) List(java.util.List) FitLayout(com.extjs.gxt.ui.client.widget.layout.FitLayout) SelectionListener(com.extjs.gxt.ui.client.event.SelectionListener)

Aggregations

Window (com.extjs.gxt.ui.client.widget.Window)19 Button (com.extjs.gxt.ui.client.widget.button.Button)14 FitLayout (com.extjs.gxt.ui.client.widget.layout.FitLayout)12 ButtonEvent (com.extjs.gxt.ui.client.event.ButtonEvent)11 GWTJahiaNode (org.jahia.ajax.gwt.client.data.node.GWTJahiaNode)9 FormPanel (com.extjs.gxt.ui.client.widget.form.FormPanel)7 List (java.util.List)6 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)5 ArrayList (java.util.ArrayList)5 RpcProxy (com.extjs.gxt.ui.client.data.RpcProxy)4 SelectionListener (com.extjs.gxt.ui.client.event.SelectionListener)4 Label (com.extjs.gxt.ui.client.widget.Label)4 VerticalPanel (com.extjs.gxt.ui.client.widget.VerticalPanel)4 BaseAsyncCallback (org.jahia.ajax.gwt.client.core.BaseAsyncCallback)4 ListStore (com.extjs.gxt.ui.client.store.ListStore)3 ContentPanel (com.extjs.gxt.ui.client.widget.ContentPanel)3 ButtonBar (com.extjs.gxt.ui.client.widget.button.ButtonBar)3 FormButtonBinding (com.extjs.gxt.ui.client.widget.form.FormButtonBinding)3 TextField (com.extjs.gxt.ui.client.widget.form.TextField)3 CenterLayout (com.extjs.gxt.ui.client.widget.layout.CenterLayout)3