Search in sources :

Example 1 with GWTJahiaValueDisplayBean

use of org.jahia.ajax.gwt.client.data.GWTJahiaValueDisplayBean in project jahia by Jahia.

the class LayoutTabItem method attachPropertiesEditor.

@Override
public void attachPropertiesEditor(final NodeHolder engine, final AsyncTabItem tab) {
    if (engine.getNode() != null && engine.getLinker() instanceof EditLinker) {
        final PropertiesEditor.PropertyAdapterField templateField = propertiesEditor.getFieldsMap().get("j:view");
        final PropertiesEditor.PropertyAdapterField skinField = propertiesEditor.getFieldsMap().get("j:skin");
        final PropertiesEditor.PropertyAdapterField subNodesViewField = propertiesEditor.getFieldsMap().get("j:subNodesView");
        listener = new SelectionChangedListener<GWTJahiaValueDisplayBean>() {

            public void selectionChanged(SelectionChangedEvent<GWTJahiaValueDisplayBean> se) {
                Map<String, List<String>> contextParams = new HashMap<String, List<String>>();
                if (skinField != null && skinField.getValue() != null) {
                    contextParams.put("forcedSkin", Arrays.asList(((ComboBox<GWTJahiaValueDisplayBean>) skinField.getField()).getValue().getValue()));
                }
                if (subNodesViewField != null && subNodesViewField.getValue() != null) {
                    contextParams.put("forcedSubNodesTemplate", Arrays.asList(((ComboBox<GWTJahiaValueDisplayBean>) subNodesViewField.getField()).getValue().getValue()));
                }
                String template = (templateField != null && templateField.getValue() != null) ? ((ComboBox<GWTJahiaValueDisplayBean>) templateField.getField()).getValue().getValue() : null;
                if (engine.getNode() != null) {
                    JahiaContentManagementService.App.getInstance().getRenderedContent(engine.getNode().getPath(), null, LayoutTabItem.this.language, template, "preview", contextParams, false, null, null, null, new BaseAsyncCallback<GWTRenderResult>() {

                        public void onSuccess(GWTRenderResult result) {
                            HTML html = new HTML(result.getResult());
                            setHTML(html);
                            tab.layout();
                        }
                    });
                } else {
                    setHTML(null);
                }
            }
        };
        if (templateField != null) {
            ((ComboBox<GWTJahiaValueDisplayBean>) templateField.getField()).addSelectionChangedListener(listener);
        }
        if (skinField != null) {
            ((ComboBox<GWTJahiaValueDisplayBean>) skinField.getField()).addSelectionChangedListener(listener);
        }
        if (subNodesViewField != null) {
            ((ComboBox<GWTJahiaValueDisplayBean>) subNodesViewField.getField()).addSelectionChangedListener(listener);
        }
        tab.setLayout(new FillLayout());
        if (ctn == null) {
            ctn = new LayoutContainer(new FitLayout());
            tab.add(ctn);
            htmlPreview = new LayoutContainer();
            htmlPreview.addStyleName(cssWrapper);
            htmlPreview.setStyleAttribute("background-color", "white");
            FieldSet f = new FieldSet();
            f.addStyleName("x-panel");
            f.setHeadingHtml(Messages.get("label.preview", "Preview"));
            f.setScrollMode(Style.Scroll.AUTO);
            f.add(htmlPreview);
            tab.add(f);
        }
        ctn.add(propertiesEditor);
    } else {
        super.attachPropertiesEditor(engine, tab);
    }
}
Also used : PropertiesEditor(org.jahia.ajax.gwt.client.widget.definition.PropertiesEditor) GWTRenderResult(org.jahia.ajax.gwt.client.data.GWTRenderResult) ComboBox(com.extjs.gxt.ui.client.widget.form.ComboBox) HTML(com.google.gwt.user.client.ui.HTML) FillLayout(com.extjs.gxt.ui.client.widget.layout.FillLayout) EditLinker(org.jahia.ajax.gwt.client.widget.edit.EditLinker) FieldSet(com.extjs.gxt.ui.client.widget.form.FieldSet) LayoutContainer(com.extjs.gxt.ui.client.widget.LayoutContainer) BaseAsyncCallback(org.jahia.ajax.gwt.client.core.BaseAsyncCallback) List(java.util.List) GWTJahiaValueDisplayBean(org.jahia.ajax.gwt.client.data.GWTJahiaValueDisplayBean) HashMap(java.util.HashMap) Map(java.util.Map) FitLayout(com.extjs.gxt.ui.client.widget.layout.FitLayout)

Example 2 with GWTJahiaValueDisplayBean

use of org.jahia.ajax.gwt.client.data.GWTJahiaValueDisplayBean in project jahia by Jahia.

the class AbstractContentEngine method refillDependantListWidgetOn.

protected void refillDependantListWidgetOn(final String propertyId, final List<String> dependentProperties) {
    final String nodeTypeName = propertyId.substring(0, propertyId.indexOf('.'));
    final String propertyName = propertyId.substring(propertyId.indexOf('.') + 1);
    Map<String, List<GWTJahiaNodePropertyValue>> dependentValues = new HashMap<String, List<GWTJahiaNodePropertyValue>>();
    for (TabItem tab : tabs.getItems()) {
        EditEngineTabItem item = tab.getData("item");
        if (item instanceof PropertiesTabItem) {
            for (PropertiesEditor pe : ((PropertiesTabItem) item).getLangPropertiesEditorMap().values()) {
                if (pe != null) {
                    for (Field<?> field : pe.getFields()) {
                        if (field instanceof PropertiesEditor.PropertyAdapterField) {
                            String name = ((PropertiesEditor.PropertyAdapterField) field).getDefinition().getName();
                            if (dependentProperties.contains(name)) {
                                dependentValues.put(name, PropertiesEditor.getPropertyValues(field, pe.getGWTJahiaItemDefinition(name)));
                            }
                        }
                    }
                }
            }
        }
    }
    JahiaContentManagementService.App.getInstance().getFieldInitializerValues(nodeTypeName, propertyName, parentPath, dependentValues, new BaseAsyncCallback<GWTChoiceListInitializer>() {

        @Override
        public void onSuccess(GWTChoiceListInitializer result) {
            choiceListInitializersValues.put(propertyId, result);
            if (result.getDisplayValues() != null) {
                String nameForDualFields = "from-" + propertyName;
                for (TabItem tab : tabs.getItems()) {
                    EditEngineTabItem item = tab.getData("item");
                    if (item instanceof PropertiesTabItem) {
                        PropertiesEditor pe = ((PropertiesTabItem) item).getPropertiesEditor();
                        if (pe != null) {
                            for (Field<?> field : pe.getFields()) {
                                if (field instanceof PropertiesEditor.PropertyAdapterField) {
                                    field = ((PropertiesEditor.PropertyAdapterField) field).getField();
                                }
                                if (propertyName.equals(field.getName()) || (field instanceof DualListField<?> && nameForDualFields.equals(field.getName()))) {
                                    if (field instanceof DualListField<?>) {
                                        @SuppressWarnings("unchecked") DualListField<GWTJahiaValueDisplayBean> dualListField = (DualListField<GWTJahiaValueDisplayBean>) field;
                                        ListStore<GWTJahiaValueDisplayBean> store = dualListField.getToField().getStore();
                                        for (GWTJahiaValueDisplayBean toValue : store.getModels()) {
                                            if (!result.getDisplayValues().contains(toValue)) {
                                                store.remove(toValue);
                                            }
                                        }
                                        dualListField.getToField().getListView().refresh();
                                        store = dualListField.getFromField().getStore();
                                        store.removeAll();
                                        store.add(result.getDisplayValues());
                                        dualListField.getFromField().getListView().refresh();
                                    } else if (field instanceof ComboBox<?>) {
                                        @SuppressWarnings("unchecked") ComboBox<GWTJahiaValueDisplayBean> comboBox = (ComboBox<GWTJahiaValueDisplayBean>) field;
                                        if (comboBox.getValue() != null && !result.getDisplayValues().contains(comboBox.getValue())) {
                                            try {
                                                comboBox.clear();
                                            } catch (Exception ex) {
                                            /*
                                                             * it could happen that the combobox is empty and so exception is thrown
                                                             * and combobox isn't reinitialized
                                                             */
                                            }
                                        }
                                        ListStore<GWTJahiaValueDisplayBean> store = new ListStore<GWTJahiaValueDisplayBean>();
                                        store.add(result.getDisplayValues());
                                        comboBox.setStore(store);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        @Override
        public void onApplicationFailure(Throwable caught) {
            Log.error("Unable to load avalibale mixin", caught);
        }
    });
}
Also used : ListStore(com.extjs.gxt.ui.client.store.ListStore) GWTJahiaNodePropertyValue(org.jahia.ajax.gwt.client.data.definition.GWTJahiaNodePropertyValue) DualListField(com.extjs.gxt.ui.client.widget.form.DualListField) Field(com.extjs.gxt.ui.client.widget.form.Field) PropertiesEditor(org.jahia.ajax.gwt.client.widget.definition.PropertiesEditor) ComboBox(com.extjs.gxt.ui.client.widget.form.ComboBox) GWTChoiceListInitializer(org.jahia.ajax.gwt.client.data.GWTChoiceListInitializer) TabItem(com.extjs.gxt.ui.client.widget.TabItem) AsyncTabItem(org.jahia.ajax.gwt.client.widget.AsyncTabItem) DualListField(com.extjs.gxt.ui.client.widget.form.DualListField) GWTJahiaValueDisplayBean(org.jahia.ajax.gwt.client.data.GWTJahiaValueDisplayBean)

Example 3 with GWTJahiaValueDisplayBean

use of org.jahia.ajax.gwt.client.data.GWTJahiaValueDisplayBean in project jahia by Jahia.

the class CodeEditorTabItem method getModeCombo.

private ComboBox<GWTJahiaValueDisplayBean> getModeCombo() {
    ComboBox<GWTJahiaValueDisplayBean> modes = new ComboBox<GWTJahiaValueDisplayBean>();
    modes.setTypeAhead(true);
    modes.getListView().setStyleAttribute(FONT_SIZE, FONT_SIZE_VALUE);
    modes.setTriggerAction(ComboBox.TriggerAction.ALL);
    modes.setForceSelection(true);
    modes.setStore(new ListStore<GWTJahiaValueDisplayBean>());
    modes.setDisplayField("display");
    for (Map.Entry<String, String> m : availableCodeMirrorModes.entrySet()) {
        String label = m.getValue();
        if (label == null || label.length() == 0) {
            label = Messages.get("label.none", "none");
        }
        GWTJahiaValueDisplayBean option = new GWTJahiaValueDisplayBean(m.getKey(), label);
        modes.getStore().add(option);
        if (codeMirrorMode != null && codeMirrorMode.equals(m.getKey())) {
            ArrayList<GWTJahiaValueDisplayBean> selection = new ArrayList<GWTJahiaValueDisplayBean>();
            selection.add(option);
            modes.setSelection(selection);
        }
    }
    modes.addSelectionChangedListener(new SelectionChangedListener<GWTJahiaValueDisplayBean>() {

        @Override
        public void selectionChanged(SelectionChangedEvent<GWTJahiaValueDisplayBean> se) {
            codeField.setMode(se.getSelectedItem().getValue());
        }
    });
    return modes;
}
Also used : ComboBox(com.extjs.gxt.ui.client.widget.form.ComboBox) ArrayList(java.util.ArrayList) GWTJahiaValueDisplayBean(org.jahia.ajax.gwt.client.data.GWTJahiaValueDisplayBean) Map(java.util.Map) RpcMap(com.extjs.gxt.ui.client.data.RpcMap)

Example 4 with GWTJahiaValueDisplayBean

use of org.jahia.ajax.gwt.client.data.GWTJahiaValueDisplayBean in project jahia by Jahia.

the class CodeEditorTabItem method init.

@Override
public void init(final NodeHolder engine, final AsyncTabItem tab, String locale) {
    gwtJahiaNode = engine.getNode();
    tab.setLayout(new BorderLayout());
    tab.setScrollMode(Style.Scroll.AUTO);
    final HorizontalPanel horizontalPanel = new HorizontalPanel();
    horizontalPanel.setSpacing(10);
    horizontalPanel.setVerticalAlign(Style.VerticalAlignment.MIDDLE);
    tab.add(horizontalPanel, new BorderLayoutData(Style.LayoutRegion.NORTH, 40));
    final HorizontalPanel actions = new HorizontalPanel();
    actions.setVerticalAlign(Style.VerticalAlignment.MIDDLE);
    horizontalPanel.add(actions);
    if (!tab.isProcessed()) {
        // Add list of properties
        GWTJahiaNodeProperty typeName = engine.getProperties().get("nodeTypeName");
        if (typeName == null) {
            typeName = engine.getPresetProperties().get("nodeTypeName");
        }
        if (engine.getProperties().containsKey(codePropertyName)) {
            codeProperty = engine.getProperties().get(codePropertyName);
        } else {
            codeProperty = new GWTJahiaNodeProperty(codePropertyName, "", GWTJahiaNodePropertyType.STRING);
        }
        Button indentButton = new Button(Messages.get("label.indentAll"));
        indentButton.addStyleName("button-indent");
        indentButton.addSelectionListener(new SelectionListener<ButtonEvent>() {

            @Override
            public void componentSelected(ButtonEvent buttonEvent) {
                if (codeField != null) {
                    codeField.indent();
                }
            }
        });
        if (stubType != null) {
            // stub type is defined -> create combos for code snippets
            final Button addAllButton = new Button(Messages.get("label.addAll"));
            addAllButton.addStyleName("button-addAll");
            final Button addButton = new Button(Messages.get("label.add"));
            addButton.addStyleName("button-add");
            snippetType = new ComboBox<GWTJahiaValueDisplayBean>();
            snippetType.setTypeAhead(true);
            snippetType.getListView().setStyleAttribute(FONT_SIZE, FONT_SIZE_VALUE);
            snippetType.setTriggerAction(ComboBox.TriggerAction.ALL);
            snippetType.setForceSelection(true);
            snippetType.setWidth(200);
            snippetType.removeAllListeners();
            snippetType.setStore(new ListStore<GWTJahiaValueDisplayBean>());
            snippetType.setAllowBlank(false);
            snippetType.setDisplayField("display");
            snippetType.addSelectionChangedListener(new SelectionChangedListener<GWTJahiaValueDisplayBean>() {

                @Override
                public void selectionChanged(SelectionChangedEvent<GWTJahiaValueDisplayBean> se) {
                    // snippet type has changed -> populate code snippets
                    mirrorTemplates.clear();
                    mirrorTemplates.getStore().removeAll();
                    mirrorTemplates.getStore().add(snippets.get(se.getSelectedItem().getValue()));
                    if (mirrorTemplates.getStore().getModels().size() > 0) {
                        addAllButton.enable();
                        mirrorTemplates.setEmptyText(Messages.get("label.stub.choose.codeTemplate"));
                    } else {
                        addAllButton.disable();
                    }
                    addButton.disable();
                }
            });
            // code templates combo
            mirrorTemplates = new ComboBox<GWTJahiaValueDisplayBean>() {

                public void doQuery(String q, boolean forceAll) {
                    final String query = q;
                    StoreFilter<GWTJahiaValueDisplayBean> filter = new StoreFilter<GWTJahiaValueDisplayBean>() {

                        @Override
                        public boolean select(Store<GWTJahiaValueDisplayBean> store, GWTJahiaValueDisplayBean parent, GWTJahiaValueDisplayBean item, String property) {
                            return item.getDisplay().contains(query);
                        }
                    };
                    if (q == null) {
                        q = "";
                    }
                    FieldEvent fe = new FieldEvent(this);
                    fe.setValue(q);
                    if (!fireEvent(Events.BeforeQuery, fe)) {
                        return;
                    }
                    if (q.length() >= 1) {
                        if (!q.equals(lastQuery)) {
                            lastQuery = q;
                            store.clearFilters();
                            if (store.getFilters() != null) {
                                store.getFilters().clear();
                            }
                            store.addFilter(filter);
                            store.applyFilters(getDisplayField());
                            expand();
                        }
                    } else {
                        lastQuery = "";
                        store.clearFilters();
                        if (store.getFilters() != null) {
                            store.getFilters().clear();
                        }
                        expand();
                    }
                }
            };
            mirrorTemplates.setTypeAhead(true);
            mirrorTemplates.getListView().setStyleAttribute(FONT_SIZE, FONT_SIZE_VALUE);
            mirrorTemplates.setTriggerAction(ComboBox.TriggerAction.ALL);
            mirrorTemplates.setForceSelection(true);
            mirrorTemplates.setWidth(300);
            mirrorTemplates.removeAllListeners();
            mirrorTemplates.setStore(new ListStore<GWTJahiaValueDisplayBean>());
            mirrorTemplates.getStore().sort("display", Style.SortDir.ASC);
            mirrorTemplates.setAllowBlank(true);
            mirrorTemplates.setDisplayField("display");
            String path = engine.isExistingNode() ? engine.getNode().getPath() : engine.getTargetNode().getPath();
            String nodeType = typeName != null ? typeName.getValues().get(0).getString() : null;
            // get code editor data from the server
            JahiaContentManagementService.App.getInstance().initializeCodeEditor(path, !engine.isExistingNode(), nodeType, stubType, new BaseAsyncCallback<RpcMap>() {

                public void onSuccess(RpcMap result) {
                    if (!result.isEmpty() && result.get("snippets") != null) {
                        // we have got snippets -> populate snippet type combo
                        snippets = (Map<String, List<GWTJahiaValueDisplayBean>>) result.get("snippets");
                        for (String type : snippets.keySet()) {
                            snippetType.getStore().add(new GWTJahiaValueDisplayBean(type, Messages.get("label.snippetType." + type, type)));
                        }
                        snippetType.setValue(snippetType.getStore().getAt(0));
                        addButton.addSelectionListener(new SelectionListener<ButtonEvent>() {

                            @Override
                            public void componentSelected(ButtonEvent buttonEvent) {
                                if (mirrorTemplates.getValue() != null) {
                                    codeField.insertProperty(mirrorTemplates.getValue().getValue());
                                }
                            }
                        });
                        Label label = new Label(Messages.get("label.snippetType", "Snippet Type"));
                        label.setStyleAttribute(FONT_SIZE, FONT_SIZE_VALUE);
                        actions.add(label);
                        actions.add(snippetType);
                        label = new Label(Messages.get("label.codeMirrorTemplates", "Code Template"));
                        label.setStyleAttribute(FONT_SIZE, FONT_SIZE_VALUE);
                        actions.add(label);
                        actions.add(mirrorTemplates);
                        addButton.disable();
                        mirrorTemplates.addSelectionChangedListener(new SelectionChangedListener<GWTJahiaValueDisplayBean>() {

                            @Override
                            public void selectionChanged(SelectionChangedEvent<GWTJahiaValueDisplayBean> se) {
                                addButton.enable();
                            }
                        });
                        actions.add(addButton);
                        // create add all snippets addButton
                        addAllButton.addSelectionListener(new SelectionListener<ButtonEvent>() {

                            @Override
                            public void componentSelected(ButtonEvent ce) {
                                StringBuilder s = new StringBuilder();
                                for (GWTJahiaValueDisplayBean value : mirrorTemplates.getStore().getModels()) {
                                    s.append(value.getValue()).append("\n");
                                }
                                codeField.insertProperty(s.toString());
                            }
                        });
                        actions.add(addAllButton);
                    }
                    if (!engine.getProperties().containsKey(codePropertyName)) {
                        Map<String, String> stubs = (Map<String, String>) result.get("stubs");
                        if (stubs.size() == 1) {
                            codeProperty = new GWTJahiaNodeProperty(codePropertyName, stubs.values().iterator().next(), GWTJahiaNodePropertyType.STRING);
                            initEditor(tab);
                        } else if (stubs.size() > 1) {
                            actions.hide();
                            final LayoutContainer w = new LayoutContainer(new CenterLayout());
                            final ComboBox<GWTJahiaValueDisplayBean> stubsCombo = new ComboBox<GWTJahiaValueDisplayBean>();
                            stubsCombo.setWidth(300);
                            stubsCombo.setTypeAhead(true);
                            stubsCombo.getListView().setStyleAttribute(FONT_SIZE, FONT_SIZE_VALUE);
                            stubsCombo.setTriggerAction(ComboBox.TriggerAction.ALL);
                            stubsCombo.setForceSelection(true);
                            stubsCombo.setStore(new ListStore<GWTJahiaValueDisplayBean>());
                            stubsCombo.setDisplayField("display");
                            stubsCombo.setEmptyText(Messages.get("label.stub.select"));
                            for (String stub : stubs.keySet()) {
                                String display;
                                String viewName;
                                if (stub.indexOf('/') != -1) {
                                    viewName = stub.substring(stub.indexOf("."), stub.lastIndexOf("."));
                                    display = Messages.get("label.stub" + viewName);
                                } else {
                                    display = Messages.get("label.stub.default");
                                    viewName = "";
                                }
                                GWTJahiaValueDisplayBean value = new GWTJahiaValueDisplayBean(stubs.get(stub), display);
                                value.set("viewName", viewName);
                                stubsCombo.getStore().add(value);
                            }
                            stubsCombo.addSelectionChangedListener(new SelectionChangedListener<GWTJahiaValueDisplayBean>() {

                                @Override
                                public void selectionChanged(SelectionChangedEvent<GWTJahiaValueDisplayBean> se) {
                                    w.removeFromParent();
                                    initEditor(tab);
                                    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {

                                        public void execute() {
                                            codeField.insertProperty(stubsCombo.getValue().getValue());
                                        }
                                    });
                                    if (engine instanceof CreateContentEngine) {
                                        final CreateContentEngine createContentEngine = (CreateContentEngine) engine;
                                        createContentEngine.setTargetName(createContentEngine.getTargetName() + stubsCombo.getValue().get("viewName"));
                                    }
                                    actions.show();
                                    codeField.show();
                                }
                            });
                            w.add(stubsCombo);
                            tab.add(w, new BorderLayoutData(Style.LayoutRegion.CENTER));
                            tab.layout();
                        } else {
                            initEditor(tab);
                        }
                    } else {
                        initEditor(tab);
                    }
                }
            });
        } else {
            if (availableCodeMirrorModes != null && availableCodeMirrorModes.size() > 0) {
                actions.add(new Label(Messages.get("label.selectSyntaxHighlighting", "Select syntax highlighting") + ": "));
                actions.add(getModeCombo());
            }
            initEditor(tab);
        }
        if (isEditable(gwtJahiaNode)) {
            actions.add(indentButton);
        }
        actions.show();
        tab.setProcessed(true);
        readOnly = engine.getNode() != null && engine.getNode().isLocked();
        if (codeField != null) {
            codeField.setReadOnly(readOnly);
        }
    }
}
Also used : Label(com.extjs.gxt.ui.client.widget.Label) RpcMap(com.extjs.gxt.ui.client.data.RpcMap) BorderLayout(com.extjs.gxt.ui.client.widget.layout.BorderLayout) GWTJahiaNodeProperty(org.jahia.ajax.gwt.client.data.definition.GWTJahiaNodeProperty) Button(com.extjs.gxt.ui.client.widget.button.Button) HorizontalPanel(com.extjs.gxt.ui.client.widget.HorizontalPanel) CenterLayout(com.extjs.gxt.ui.client.widget.layout.CenterLayout) BorderLayoutData(com.extjs.gxt.ui.client.widget.layout.BorderLayoutData) ComboBox(com.extjs.gxt.ui.client.widget.form.ComboBox) LayoutContainer(com.extjs.gxt.ui.client.widget.LayoutContainer) StoreFilter(com.extjs.gxt.ui.client.store.StoreFilter) GWTJahiaValueDisplayBean(org.jahia.ajax.gwt.client.data.GWTJahiaValueDisplayBean) Map(java.util.Map) RpcMap(com.extjs.gxt.ui.client.data.RpcMap)

Example 5 with GWTJahiaValueDisplayBean

use of org.jahia.ajax.gwt.client.data.GWTJahiaValueDisplayBean in project jahia by Jahia.

the class DistributionServerWindow method onRender.

@Override
protected void onRender(Element parent, int pos) {
    super.onRender(parent, pos);
    addStyleName("distribution-server-window");
    setLayout(new FitLayout());
    setHeadingHtml(Messages.get("label.releaseModule.distributionServer", "Distribution server (Maven)"));
    setModal(true);
    setWidth(500);
    setHeight(380);
    VerticalPanel p = new VerticalPanel();
    p.add(new Label(Messages.get("label.releaseModule.distributionServer.notProvided", "No target distribution server configured for this module yet.")));
    p.add(new HTML("<br/>"));
    p.add(new Label(Messages.get("label.releaseModule.distributionServer.purpose", "A target distribution server is a Maven repository," + " where built module artifacts (module JAR file)" + " are pushed to during module release process.")));
    p.add(new Label(Messages.get("label.releaseModule.distributionServer.authentication", "If your distribution server requires authentication, please, provide the corresponding" + " <server/> section in your Maven's settings.xml file.")));
    p.add(new HTML("<br/>"));
    p.add(new Label(Messages.get("label.releaseModule.distributionServer.provideNow", "Would you like to configure the distribution server now?")));
    final FormPanel formPanel = new FormPanel();
    formPanel.setHeaderVisible(false);
    formPanel.setLabelWidth(100);
    formPanel.setFieldWidth(330);
    formPanel.setButtonAlign(Style.HorizontalAlignment.CENTER);
    formPanel.setBorders(false);
    final ComboBox<GWTJahiaValueDisplayBean> combo = new ComboBox<GWTJahiaValueDisplayBean>();
    combo.setFieldLabel("Repository type");
    combo.setValueField("value");
    combo.setDisplayField("display");
    combo.setStore(new ListStore<GWTJahiaValueDisplayBean>());
    combo.getStore().add(new GWTJahiaValueDisplayBean("forge", "Jahia Private App Store"));
    combo.getStore().add(new GWTJahiaValueDisplayBean("maven", "Maven repository"));
    combo.setForceSelection(true);
    combo.setTypeAhead(false);
    combo.setTriggerAction(ComboBox.TriggerAction.ALL);
    formPanel.add(combo);
    final FieldSet forgeFs = new FieldSet();
    final FormLayout forgeFl = new FormLayout();
    forgeFl.setLabelWidth(100);
    forgeFl.setDefaultWidth(330);
    forgeFs.setLayout(forgeFl);
    final TextField<String> tfForgeUrl = new TextField<String>();
    tfForgeUrl.setFieldLabel(Messages.get("label.url", "URL"));
    String separator = tfForgeUrl.getLabelSeparator() != null ? tfForgeUrl.getLabelSeparator() : "";
    tfForgeUrl.setLabelSeparator(separator + " <img width='16px' height='16px' src='" + JahiaGWTParameters.getContextPath() + "/modules/default/images/icons/information.png' title='" + Messages.get("label.releaseModule.distributionServer.url.help", "Copy URL displayed on the Private App Store home page").replace("'", " ") + "'/>");
    tfForgeUrl.setAllowBlank(false);
    if (info.getForgeUrl() != null) {
        tfForgeUrl.setValue(info.getForgeUrl());
    }
    forgeFs.add(tfForgeUrl);
    final TextField<String> tfUsername = new TextField<String>();
    final TextField<String> tfPassword = new TextField<String>();
    tfUsername.setFieldLabel(Messages.get("label.username", "Username"));
    tfPassword.setFieldLabel(Messages.get("label.password", "Password"));
    tfPassword.setPassword(true);
    tfUsername.setValue(ForgeLoginWindow.username);
    tfPassword.setValue(ForgeLoginWindow.password);
    forgeFs.add(tfUsername);
    forgeFs.add(tfPassword);
    final FieldSet mavenFs = new FieldSet();
    final FormLayout mavenfl = new FormLayout();
    mavenfl.setLabelWidth(30);
    mavenfl.setDefaultWidth(400);
    mavenFs.setLayout(mavenfl);
    final TextField<String> tfRepoId = new TextField<String>();
    tfRepoId.setFieldLabel(Messages.get("label.id", "ID"));
    tfRepoId.setAllowBlank(false);
    if (info.getRepositoryId() != null) {
        tfRepoId.setValue(info.getRepositoryId());
    }
    mavenFs.add(tfRepoId);
    final TextField<String> tfRepoUrl = new TextField<String>();
    tfRepoUrl.setFieldLabel(Messages.get("label.url", "URL"));
    tfRepoUrl.setAllowBlank(false);
    if (info.getRepositoryUrl() != null) {
        tfRepoUrl.setValue(info.getRepositoryUrl());
    }
    mavenFs.add(tfRepoUrl);
    formPanel.add(mavenFs);
    if (info.getForgeUrl() == null && info.getRepositoryUrl() != null) {
        combo.setValue(combo.getStore().getAt(1));
        forgeFs.hide();
    } else {
        combo.setValue(combo.getStore().getAt(0));
        mavenFs.hide();
    }
    formPanel.add(forgeFs);
    combo.addSelectionChangedListener(new SelectionChangedListener<GWTJahiaValueDisplayBean>() {

        @Override
        public void selectionChanged(SelectionChangedEvent<GWTJahiaValueDisplayBean> se) {
            if (se.getSelectedItem().getValue().equals("forge")) {
                mavenFs.hide();
                forgeFs.show();
            } else {
                forgeFs.hide();
                mavenFs.show();
            }
            formPanel.layout();
        }
    });
    final Window w = this;
    Button button = new Button(Messages.get("label.save", "Save"), new SelectionListener<ButtonEvent>() {

        public void componentSelected(ButtonEvent event) {
            w.hide();
            if (combo.getValue().getValue().equals("forge")) {
                info.setForgeUrl(tfForgeUrl.getValue());
                info.setUsername(tfUsername.getValue());
                info.setPassword(tfPassword.getValue());
                ForgeLoginWindow.username = tfUsername.getValue();
                ForgeLoginWindow.password = tfPassword.getValue();
            } else {
                info.setForgeUrl(null);
                info.setRepositoryUrl(tfRepoUrl.getValue());
                info.setRepositoryId(tfRepoId.getValue());
            }
            callback(info);
        }
    });
    button.addStyleName("button-save");
    formPanel.addButton(button);
    Button skip = new Button(Messages.get("label.skip", "Skip"), new SelectionListener<ButtonEvent>() {

        public void componentSelected(ButtonEvent event) {
            w.hide();
            callback(null);
        }
    });
    skip.addStyleName("button-skip");
    formPanel.addButton(skip);
    p.add(formPanel);
    add(p, new MarginData(5));
}
Also used : FormLayout(com.extjs.gxt.ui.client.widget.layout.FormLayout) Window(com.extjs.gxt.ui.client.widget.Window) Label(com.extjs.gxt.ui.client.widget.Label) HTML(com.google.gwt.user.client.ui.HTML) MarginData(com.extjs.gxt.ui.client.widget.layout.MarginData) VerticalPanel(com.extjs.gxt.ui.client.widget.VerticalPanel) Button(com.extjs.gxt.ui.client.widget.button.Button) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent) GWTJahiaValueDisplayBean(org.jahia.ajax.gwt.client.data.GWTJahiaValueDisplayBean) FitLayout(com.extjs.gxt.ui.client.widget.layout.FitLayout)

Aggregations

GWTJahiaValueDisplayBean (org.jahia.ajax.gwt.client.data.GWTJahiaValueDisplayBean)18 ComboBox (com.extjs.gxt.ui.client.widget.form.ComboBox)5 RpcMap (com.extjs.gxt.ui.client.data.RpcMap)4 Button (com.extjs.gxt.ui.client.widget.button.Button)3 Map (java.util.Map)3 GWTChoiceListInitializer (org.jahia.ajax.gwt.client.data.GWTChoiceListInitializer)3 PropertiesEditor (org.jahia.ajax.gwt.client.widget.definition.PropertiesEditor)3 TagField (org.jahia.ajax.gwt.client.widget.form.tag.TagField)3 ButtonEvent (com.extjs.gxt.ui.client.event.ButtonEvent)2 ListStore (com.extjs.gxt.ui.client.store.ListStore)2 Label (com.extjs.gxt.ui.client.widget.Label)2 LayoutContainer (com.extjs.gxt.ui.client.widget.LayoutContainer)2 DualListField (com.extjs.gxt.ui.client.widget.form.DualListField)2 FitLayout (com.extjs.gxt.ui.client.widget.layout.FitLayout)2 HTML (com.google.gwt.user.client.ui.HTML)2 MessageFormat (java.text.MessageFormat)2 RepositoryException (javax.jcr.RepositoryException)2 GWTResourceBundleEntry (org.jahia.ajax.gwt.client.data.GWTResourceBundleEntry)2 GWTJahiaNode (org.jahia.ajax.gwt.client.data.node.GWTJahiaNode)2 El (com.extjs.gxt.ui.client.core.El)1