Search in sources :

Example 1 with GWTJahiaLanguage

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

the class CreateButtonItem method continuePrepareAndSave.

protected void continuePrepareAndSave(final AbstractContentEngine engine, final boolean closeAfterSave, String nodeName) {
    GWTJahiaNodeACL newNodeACL = new GWTJahiaNodeACL();
    List<GWTJahiaNode> children = new ArrayList<GWTJahiaNode>();
    newNodeACL.setAce(new ArrayList<GWTJahiaNodeACE>());
    final Set<String> addedTypes = new HashSet<String>();
    for (TabItem tab : engine.getTabs().getItems()) {
        EditEngineTabItem item = tab.getData("item");
        if (item instanceof ContentTabItem) {
            if (((ContentTabItem) item).isNodeNameFieldDisplayed()) {
                nodeName = ((ContentTabItem) item).getName().getValue();
            }
            final List<CheckBox> values = ((ContentTabItem) item).getCheckedLanguagesCheckBox();
            if (values != null) {
                // Checkboxes are not null so they are displayed, if list is empty this means that this
                // content is not visible in any language
                final List<GWTJahiaLanguage> siteLanguages = JahiaGWTParameters.getSiteLanguages();
                if (values.size() != siteLanguages.size()) {
                    List<String> strings = new ArrayList<String>(siteLanguages.size());
                    for (GWTJahiaLanguage siteLanguage : siteLanguages) {
                        strings.add(siteLanguage.getLanguage());
                    }
                    GWTJahiaNodeProperty gwtJahiaNodeProperty = new GWTJahiaNodeProperty();
                    gwtJahiaNodeProperty.setName("j:invalidLanguages");
                    gwtJahiaNodeProperty.setMultiple(true);
                    for (CheckBox value : values) {
                        if (value.getValue()) {
                            strings.remove(value.getValueAttribute());
                        }
                    }
                    if (strings.size() > 0) {
                        gwtJahiaNodeProperty.setValues(new ArrayList<GWTJahiaNodePropertyValue>());
                        for (String string : strings) {
                            gwtJahiaNodeProperty.getValues().add(new GWTJahiaNodePropertyValue(string));
                        }
                    }
                    final List<GWTJahiaNodePropertyValue> gwtJahiaNodePropertyValues = gwtJahiaNodeProperty.getValues();
                    if (gwtJahiaNodePropertyValues != null && gwtJahiaNodePropertyValues.size() > 0) {
                        engine.getChangedProperties().add(gwtJahiaNodeProperty);
                        addedTypes.add("jmix:i18n");
                    }
                }
            }
        }
        item.doSave(engine.getNode(), engine.getChangedProperties(), engine.getChangedI18NProperties(), addedTypes, new HashSet<String>(), children, newNodeACL);
    }
    doSave((CreateContentEngine) engine, nodeName, engine.getChangedProperties(), engine.getChangedI18NProperties(), new ArrayList<String>(addedTypes), children, newNodeACL, closeAfterSave);
}
Also used : GWTJahiaLanguage(org.jahia.ajax.gwt.client.data.GWTJahiaLanguage) GWTJahiaNode(org.jahia.ajax.gwt.client.data.node.GWTJahiaNode) GWTJahiaNodeACE(org.jahia.ajax.gwt.client.data.acl.GWTJahiaNodeACE) GWTJahiaNodeACL(org.jahia.ajax.gwt.client.data.acl.GWTJahiaNodeACL) TabItem(com.extjs.gxt.ui.client.widget.TabItem) GWTJahiaNodePropertyValue(org.jahia.ajax.gwt.client.data.definition.GWTJahiaNodePropertyValue) GWTJahiaNodeProperty(org.jahia.ajax.gwt.client.data.definition.GWTJahiaNodeProperty) CheckBox(com.extjs.gxt.ui.client.widget.form.CheckBox)

Example 2 with GWTJahiaLanguage

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

the class TranslateMenuActionItem method initMenu.

private void initMenu(final Linker linker) {
    boolean notEmpty = false;
    menu.removeAll();
    final String currentLanguage = JahiaGWTParameters.getLanguage();
    for (final GWTJahiaLanguage sourceLang : JahiaGWTParameters.getSiteLanguages()) {
        for (final GWTJahiaLanguage destLang : JahiaGWTParameters.getSiteLanguages()) {
            if (!destLang.getDisplayName().equals(sourceLang.getDisplayName()) && (destLang.getLanguage().equals(currentLanguage) || sourceLang.getLanguage().equals(currentLanguage))) {
                final LinkerSelectionContext lh = linker.getSelectionContext();
                if (PermissionsUtils.isPermitted("jcr:modifyProperties_" + JahiaGWTParameters.getWorkspace() + "_" + destLang.getLanguage(), lh.getSelectionPermissions())) {
                    final GWTJahiaNode selection = lh.getSingleSelection();
                    if (selection != null && (!selection.isLocked() || !selection.getLockInfos().containsKey(destLang.getLanguage()))) {
                        MenuItem item = new MenuItem(sourceLang.getDisplayName() + "->" + destLang.getDisplayName());
                        item.addSelectionListener(new SelectionListener<MenuEvent>() {

                            @Override
                            public void componentSelected(MenuEvent ce) {
                                new TranslateContentEngine(selection, linker, sourceLang, destLang).show();
                            }
                        });
                        item.addStyleName("toolbar-item-translatemenu-item");
                        menu.add(item);
                        notEmpty = true;
                    }
                }
            }
        }
    }
    if (notEmpty) {
        setSubMenu(menu);
    }
    setEnabled(notEmpty);
}
Also used : GWTJahiaLanguage(org.jahia.ajax.gwt.client.data.GWTJahiaLanguage) TranslateContentEngine(org.jahia.ajax.gwt.client.widget.contentengine.TranslateContentEngine) GWTJahiaNode(org.jahia.ajax.gwt.client.data.node.GWTJahiaNode) LinkerSelectionContext(org.jahia.ajax.gwt.client.widget.LinkerSelectionContext) MenuItem(com.extjs.gxt.ui.client.widget.menu.MenuItem) MenuEvent(com.extjs.gxt.ui.client.event.MenuEvent)

Example 3 with GWTJahiaLanguage

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

the class PublicationWorkflow method openPublicationWorkflow.

public static void openPublicationWorkflow(List<String> uuids, final Linker linker, final boolean allSubTree, final boolean allLanguages, final boolean checkForUnpublication) {
    BaseAsyncCallback<List<GWTJahiaPublicationInfo>> asyncCallback = new OpenPublicationWorkflowCallback(linker, checkForUnpublication);
    // todo
    if (!allLanguages) {
        JahiaContentManagementService.App.getInstance().getPublicationInfo(uuids, allSubTree, checkForUnpublication, asyncCallback);
    } else {
        Set<String> languages = new HashSet<>();
        for (GWTJahiaLanguage gwtJahiaLanguage : JahiaGWTParameters.getSiteLanguages()) {
            if (Boolean.TRUE.equals(gwtJahiaLanguage.isActive())) {
                languages.add(gwtJahiaLanguage.getLanguage());
            }
        }
        JahiaContentManagementService.App.getInstance().getPublicationInfo(uuids, allSubTree, checkForUnpublication, languages, asyncCallback);
    }
}
Also used : GWTJahiaLanguage(org.jahia.ajax.gwt.client.data.GWTJahiaLanguage)

Example 4 with GWTJahiaLanguage

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

the class PublicationManagerEngine method init.

/**
 * init
 */
private void init() {
    setHeadingHtml(Messages.get("label.publicationmanager", "Publication Manager"));
    setLayout(new FitLayout());
    setSize(800, 600);
    setBorders(false);
    setBodyBorder(false);
    setModal(true);
    setMaximizable(true);
    getHeader().setBorders(false);
    getHeader().setIcon(ToolbarIconProvider.getInstance().getIcon("siteRepository"));
    // tree component
    GWTJahiaNodeTreeFactory factory = new GWTJahiaNodeTreeFactory(Arrays.asList("/sites/" + linker.getSelectionContext().getMainNode().getSiteKey()), true);
    factory.setNodeTypes(nodeTypes);
    factory.setFields(Arrays.asList(GWTJahiaNode.NAME, GWTJahiaNode.DISPLAY_NAME, GWTJahiaNode.PUBLICATION_INFOS, GWTJahiaNode.WORKFLOW_INFOS));
    factory.setSelectedPath(linker.getSelectionContext().getMainNode().getPath());
    loader = factory.getLoader();
    List<ColumnConfig> columns = new LinkedList<ColumnConfig>();
    ColumnConfig config = new ColumnConfig("displayName", Messages.get("label.name", "Name"), 150);
    config.setRenderer(NodeColumnConfigList.NAME_TREEGRID_RENDERER);
    config.setSortable(false);
    columns.add(config);
    checkboxMap = new HashMap<String, LayoutContainer>();
    for (GWTJahiaLanguage language : languages) {
        config = new PublicationCheckColumnConfig("publicationInfos", language.getDisplayName(), 100);
        config.setDataIndex(language.getLanguage());
        config.setSortable(false);
        TableData td = new TableData();
        td.setHorizontalAlign(Style.HorizontalAlignment.CENTER);
        td.setVerticalAlign(Style.VerticalAlignment.MIDDLE);
        HorizontalPanel p = new HorizontalPanel();
        // final LayoutContainer ctn = new LayoutContainer();
        // ctn.addStyleName("x-grid3-check-col");
        // ctn.setWidth(16);
        // ctn.setHeight(16);
        // p.add(ctn,td);
        p.add(new Text(language.getDisplayName()), td);
        config.setWidget(p, language.getLanguage());
        // checkboxMap.put(language.getLanguage(), ctn);
        columns.add(config);
    }
    ColumnModel cm = new ColumnModel(columns);
    // cm.addHeaderGroup(0, 1, new HeaderGroupConfig("Publication Info", 1, columns.size() - 1));
    m_tree = factory.getTreeGrid(cm);
    for (ColumnConfig column : columns) {
        if (column instanceof CheckColumnConfig) {
            m_tree.addPlugin((ComponentPlugin) column);
        }
    }
    m_tree.setHideHeaders(false);
    m_tree.setIconProvider(ContentModelIconProvider.getInstance());
    m_tree.setAutoExpand(false);
    m_tree.setAutoExpandMax(1000);
    m_tree.setAutoExpandMin(150);
    m_tree.setAutoExpandColumn("displayName");
    m_tree.setBorders(true);
    setScrollMode(Style.Scroll.AUTO);
    add(m_tree);
    ButtonBar buttonBar = new ButtonBar();
    buttonBar.setAlignment(Style.HorizontalAlignment.CENTER);
    Button button = new Button(Messages.get("label.publish", "Publish"));
    button.addStyleName("button-publish");
    buttonBar.add(button);
    Button cancelButton = new Button(Messages.get("label.cancel", "Cancel"));
    cancelButton.addStyleName("button-cancel");
    buttonBar.add(cancelButton);
    setBottomComponent(buttonBar);
    m_tree.mask(Messages.get("label.loading", "Loading..."), "x-mask-loading");
    loader.addLoadListener(new LoadListener() {

        public void loaderLoad(LoadEvent le) {
            m_tree.unmask();
        }
    });
    loader.load();
    cancelButton.addListener(Events.Select, new Listener<ComponentEvent>() {

        public void handleEvent(ComponentEvent ce) {
            hide();
        }
    });
    button.addSelectionListener(new StartWorkflowButtonSelectionListener(this));
}
Also used : GWTJahiaLanguage(org.jahia.ajax.gwt.client.data.GWTJahiaLanguage) ButtonBar(com.extjs.gxt.ui.client.widget.button.ButtonBar) LoadEvent(com.extjs.gxt.ui.client.data.LoadEvent) Button(com.extjs.gxt.ui.client.widget.button.Button) GWTJahiaNodeTreeFactory(org.jahia.ajax.gwt.client.widget.node.GWTJahiaNodeTreeFactory) TableData(com.extjs.gxt.ui.client.widget.layout.TableData) FitLayout(com.extjs.gxt.ui.client.widget.layout.FitLayout)

Example 5 with GWTJahiaLanguage

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

the class LanguageSwitcherActionItem method updateSite.

private void updateSite() {
    if (!JahiaGWTParameters.getSiteLanguages().equals(mainComponent.getStore().getModels())) {
        events = false;
        mainComponent.getStore().removeAll();
        mainComponent.reset();
        mainComponent.getStore().add(JahiaGWTParameters.getSiteLanguages());
        mainComponent.getListView().getSelectionModel().setSelectionMode(Style.SelectionMode.SINGLE);
        if (mainComponent.getSelection().isEmpty() || !JahiaGWTParameters.getLanguage().equals(mainComponent.getSelection().get(0).getLanguage())) {
            // The getSelection() call above filters the store, so we explicitly clear the filters after that.
            mainComponent.getStore().clearFilters();
            for (GWTJahiaLanguage language : JahiaGWTParameters.getSiteLanguages()) {
                if (language.getLanguage().equals(JahiaGWTParameters.getLanguage())) {
                    mainComponent.setSelection(Arrays.asList(language));
                    break;
                }
            }
        }
        events = true;
        if (!JahiaGWTParameters.getSiteLanguages().contains(mainComponent.getSelection().get(0))) {
            mainComponent.setSelection(Arrays.asList((GWTJahiaLanguage) JahiaGWTParameters.getSiteNode().get("j:defaultLanguage")));
        }
    }
    if (!JahiaGWTParameters.getLanguage().equals(mainComponent.getSelection().get(0).getLanguage())) {
        events = false;
        GWTJahiaLanguage language = JahiaGWTParameters.getLanguage(JahiaGWTParameters.getLanguage());
        if (language != null) {
            mainComponent.setSelection(Arrays.asList(language));
        }
        events = true;
    }
}
Also used : GWTJahiaLanguage(org.jahia.ajax.gwt.client.data.GWTJahiaLanguage)

Aggregations

GWTJahiaLanguage (org.jahia.ajax.gwt.client.data.GWTJahiaLanguage)11 GWTJahiaNode (org.jahia.ajax.gwt.client.data.node.GWTJahiaNode)6 GWTJahiaNodeProperty (org.jahia.ajax.gwt.client.data.definition.GWTJahiaNodeProperty)3 TabItem (com.extjs.gxt.ui.client.widget.TabItem)2 CheckBox (com.extjs.gxt.ui.client.widget.form.CheckBox)2 GWTJahiaNodePropertyValue (org.jahia.ajax.gwt.client.data.definition.GWTJahiaNodePropertyValue)2 EditLinker (org.jahia.ajax.gwt.client.widget.edit.EditLinker)2 LoadEvent (com.extjs.gxt.ui.client.data.LoadEvent)1 RpcMap (com.extjs.gxt.ui.client.data.RpcMap)1 FieldEvent (com.extjs.gxt.ui.client.event.FieldEvent)1 MenuEvent (com.extjs.gxt.ui.client.event.MenuEvent)1 Margins (com.extjs.gxt.ui.client.util.Margins)1 Label (com.extjs.gxt.ui.client.widget.Label)1 Button (com.extjs.gxt.ui.client.widget.button.Button)1 ButtonBar (com.extjs.gxt.ui.client.widget.button.ButtonBar)1 Field (com.extjs.gxt.ui.client.widget.form.Field)1 FieldSet (com.extjs.gxt.ui.client.widget.form.FieldSet)1 TextField (com.extjs.gxt.ui.client.widget.form.TextField)1 FitLayout (com.extjs.gxt.ui.client.widget.layout.FitLayout)1 TableData (com.extjs.gxt.ui.client.widget.layout.TableData)1