Search in sources :

Example 1 with EditLinker

use of org.jahia.ajax.gwt.client.widget.edit.EditLinker in project jahia by Jahia.

the class EngineWindow method setEngine.

public void setEngine(Component component, String header, ButtonBar buttonsBar, GWTJahiaLanguage language, final Linker linker) {
    removeAll();
    add(component);
    setHeadingHtml(header);
    if (buttonsBar != null) {
        setBottomComponent(buttonsBar);
    }
    if (linker instanceof EditLinker || linker instanceof SidePanelLinker) {
        EditLinker editLinker = linker instanceof EditLinker ? (EditLinker) linker : ((SidePanelLinker) linker).getEditLinker();
        if (GXT.isIE) {
            // resize to fit main module area
            MainModule main = editLinker.getMainModule();
            setSize(main.getOffsetWidth(), main.getOffsetHeight());
            Element element = main.getElement();
            setPosition(WindowUtil.getAbsoluteLeft(element), WindowUtil.getAbsoluteTop(element));
            setBorders(false);
        } else if (editLinker.getMainAreaComponent() != null) {
            setContainer(editLinker.getMainAreaComponent().getElement());
        }
    }
}
Also used : EditLinker(org.jahia.ajax.gwt.client.widget.edit.EditLinker) SidePanelLinker(org.jahia.ajax.gwt.client.widget.edit.sidepanel.SidePanelTabItem.SidePanelLinker) Element(com.google.gwt.user.client.Element) MainModule(org.jahia.ajax.gwt.client.widget.edit.mainarea.MainModule)

Example 2 with EditLinker

use of org.jahia.ajax.gwt.client.widget.edit.EditLinker 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 3 with EditLinker

use of org.jahia.ajax.gwt.client.widget.edit.EditLinker in project jahia by Jahia.

the class SwitchModeActionItem method handleNewLinkerSelection.

public void handleNewLinkerSelection() {
    if (showOpenInNewWindowSubmenu) {
        Menu m = new Menu();
        MenuItem menuItem = new MenuItem(Messages.get("label.openInNewWindow", "Open in new window"));
        menuItem.setIcon(ToolbarIconProvider.getInstance().getIcon("openWindow"));
        menuItem.addStyleName(getGwtToolbarItem().getClassName() + "-openWindow");
        menuItem.addSelectionListener(new SelectionListener<MenuEvent>() {

            @Override
            public void componentSelected(MenuEvent ce) {
                onComponentSelection(true);
            }
        });
        m.add(menuItem);
        setSubMenu(m);
    }
    final String workspace = getPropertyValue(getGwtToolbarItem(), "workspace");
    if ((linker instanceof EditLinker && ((EditLinker) linker).isInSettingsPage()) || !hasPermission(linker.getSelectionContext().getMainNode()) || !isNodeTypeAllowed(linker.getSelectionContext().getMainNode())) {
        setEnabled(false);
    } else {
        if (workspace.equalsIgnoreCase("live")) {
            final GWTJahiaNode node = linker.getSelectionContext().getMainNode();
            if (node == null) {
                setEnabled(false);
            } else {
                GWTJahiaPublicationInfo publicationInfo = node.getAggregatedPublicationInfo() != null ? node.getAggregatedPublicationInfo() : node.getQuickPublicationInfo();
                if (publicationInfo.getStatus() == GWTJahiaPublicationInfo.NOT_PUBLISHED || publicationInfo.getStatus() == GWTJahiaPublicationInfo.UNPUBLISHED) {
                    setEnabled(false);
                } else {
                    setEnabled(true);
                }
            }
        } else {
            setEnabled(true);
        }
    }
}
Also used : EditLinker(org.jahia.ajax.gwt.client.widget.edit.EditLinker) GWTJahiaNode(org.jahia.ajax.gwt.client.data.node.GWTJahiaNode) GWTJahiaPublicationInfo(org.jahia.ajax.gwt.client.data.publication.GWTJahiaPublicationInfo) MenuItem(com.extjs.gxt.ui.client.widget.menu.MenuItem) Menu(com.extjs.gxt.ui.client.widget.menu.Menu) MenuEvent(com.extjs.gxt.ui.client.event.MenuEvent)

Example 4 with EditLinker

use of org.jahia.ajax.gwt.client.widget.edit.EditLinker in project jahia by Jahia.

the class UndeleteActionItem method onComponentSelection.

@Override
public void onComponentSelection() {
    final LinkerSelectionContext lh = linker.getSelectionContext();
    if (!lh.getMultipleSelection().isEmpty()) {
        String message = null;
        if (lh.getMultipleSelection().size() > 1) {
            message = Messages.getWithArgs("message.undelete.multiple.confirm", "Do you really want to undelete the {0} selected resources?", new String[] { String.valueOf(lh.getMultipleSelection().size()) });
        } else {
            message = Messages.getWithArgs("message.undelete.confirm", "Do you really want to undelete the selected resource {0}?", new String[] { lh.getSingleSelection().getDisplayName() });
        }
        MessageBox.confirm(Messages.get("label.information", "Information"), message, new Listener<MessageBoxEvent>() {

            public void handleEvent(MessageBoxEvent be) {
                if (be.getButtonClicked().getItemId().equalsIgnoreCase(Dialog.YES)) {
                    final List<String> l = new ArrayList<String>();
                    for (GWTJahiaNode node : lh.getMultipleSelection()) {
                        l.add(node.getPath());
                    }
                    JahiaContentManagementService.App.getInstance().undeletePaths(l, new BaseAsyncCallback() {

                        @Override
                        public void onApplicationFailure(Throwable throwable) {
                            Log.error(throwable.getMessage(), throwable);
                            MessageBox.alert(Messages.get("label.error", "Error"), throwable.getMessage(), null);
                        }

                        public void onSuccess(Object result) {
                            EditLinker el = null;
                            if (linker instanceof SidePanelTabItem.SidePanelLinker) {
                                el = ((SidePanelTabItem.SidePanelLinker) linker).getEditLinker();
                            } else if (linker instanceof EditLinker) {
                                el = (EditLinker) linker;
                            }
                            Map<String, Object> data = new HashMap<String, Object>();
                            if (el != null && l.contains(el.getSelectionContext().getMainNode().getPath())) {
                                data.put("node", el.getSelectionContext().getMainNode());
                            } else {
                                data.put(Linker.REFRESH_ALL, true);
                            }
                            linker.refresh(data);
                        }
                    });
                }
            }
        });
    }
}
Also used : HashMap(java.util.HashMap) GWTJahiaNode(org.jahia.ajax.gwt.client.data.node.GWTJahiaNode) SidePanelTabItem(org.jahia.ajax.gwt.client.widget.edit.sidepanel.SidePanelTabItem) MessageBoxEvent(com.extjs.gxt.ui.client.event.MessageBoxEvent) EditLinker(org.jahia.ajax.gwt.client.widget.edit.EditLinker) BaseAsyncCallback(org.jahia.ajax.gwt.client.core.BaseAsyncCallback) LinkerSelectionContext(org.jahia.ajax.gwt.client.widget.LinkerSelectionContext) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with EditLinker

use of org.jahia.ajax.gwt.client.widget.edit.EditLinker in project jahia by Jahia.

the class ChannelDisplayActionItem method initMainComponent.

/**
 * init main component
 */
private void initMainComponent() {
    final ComboBox<GWTJahiaChannel> comboBox = new ComboBox<GWTJahiaChannel>();
    comboBox.setDisplayField("display");
    comboBox.setTriggerAction(ComboBox.TriggerAction.ALL);
    comboBox.setStore(new ListStore<GWTJahiaChannel>());
    comboBox.getStore().add(JahiaGWTParameters.getChannels());
    comboBox.setTemplate(getChannelTemplate());
    comboBox.setItemSelector("div.thumb-wrap");
    comboBox.addSelectionChangedListener(new SelectionChangedListener<GWTJahiaChannel>() {

        @Override
        public void selectionChanged(SelectionChangedEvent<GWTJahiaChannel> event) {
            GWTJahiaChannel selectedChannel = event.getSelectedItem();
            if (linker instanceof EditLinker) {
                ((EditLinker) linker).getMainModule().switchChannel(selectedChannel, null);
            }
        }
    });
    horizontalPanel = new HorizontalPanel();
    horizontalPanel.add(comboBox);
    horizontalPanel.addStyleName(getGwtToolbarItem().getClassName());
    horizontalPanel.addStyleName("action-bar-menu-item");
    setEnabled(true);
}
Also used : EditLinker(org.jahia.ajax.gwt.client.widget.edit.EditLinker) ComboBox(com.extjs.gxt.ui.client.widget.form.ComboBox) HorizontalPanel(com.extjs.gxt.ui.client.widget.HorizontalPanel) GWTJahiaChannel(org.jahia.ajax.gwt.client.data.GWTJahiaChannel)

Aggregations

EditLinker (org.jahia.ajax.gwt.client.widget.edit.EditLinker)17 GWTJahiaNode (org.jahia.ajax.gwt.client.data.node.GWTJahiaNode)11 LinkerSelectionContext (org.jahia.ajax.gwt.client.widget.LinkerSelectionContext)6 BaseAsyncCallback (org.jahia.ajax.gwt.client.core.BaseAsyncCallback)4 HashMap (java.util.HashMap)3 List (java.util.List)3 SidePanelTabItem (org.jahia.ajax.gwt.client.widget.edit.sidepanel.SidePanelTabItem)3 TabItem (com.extjs.gxt.ui.client.widget.TabItem)2 ComboBox (com.extjs.gxt.ui.client.widget.form.ComboBox)2 HTML (com.google.gwt.user.client.ui.HTML)2 Map (java.util.Map)2 GWTJahiaLanguage (org.jahia.ajax.gwt.client.data.GWTJahiaLanguage)2 DeleteItemWindow (org.jahia.ajax.gwt.client.widget.content.DeleteItemWindow)2 AreaModule (org.jahia.ajax.gwt.client.widget.edit.mainarea.AreaModule)2 MainModule (org.jahia.ajax.gwt.client.widget.edit.mainarea.MainModule)2 Module (org.jahia.ajax.gwt.client.widget.edit.mainarea.Module)2 RpcMap (com.extjs.gxt.ui.client.data.RpcMap)1 MenuEvent (com.extjs.gxt.ui.client.event.MenuEvent)1 MessageBoxEvent (com.extjs.gxt.ui.client.event.MessageBoxEvent)1 HorizontalPanel (com.extjs.gxt.ui.client.widget.HorizontalPanel)1