Search in sources :

Example 6 with FillLayout

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

the class NewViewActionItem method newView.

@SuppressWarnings("unchecked")
private void newView(final Linker linker, boolean isLoading) {
    final GWTJahiaNode selectedNode = linker.getSelectionContext().getSingleSelection();
    if (selectedNode.getNodeTypes().contains("jnt:moduleVersionFolder")) {
        // Open popup to select nodeType
        ArrayList<String> paths = new ArrayList<String>();
        paths.add(JahiaGWTParameters.getSiteNode().getPath());
        for (String s : (List<String>) JahiaGWTParameters.getSiteNode().getProperties().get("j:resolvedDependencies")) {
            for (GWTJahiaNode n : JahiaGWTParameters.getSitesMap().values()) {
                if (n.getName().equals(s)) {
                    paths.add(n.getPath());
                }
            }
        }
        if (!isLoading) {
            linker.loading(Messages.get("label.loading", "Loading"));
        }
        JahiaContentManagementService.App.getInstance().getContentTypesAsTree(Arrays.asList("nt:base"), null, true, new BaseAsyncCallback<List<GWTJahiaNodeType>>() {

            @Override
            public void onSuccess(List<GWTJahiaNodeType> result) {
                linker.loaded();
                final com.extjs.gxt.ui.client.widget.Window popup = new com.extjs.gxt.ui.client.widget.Window();
                popup.addStyleName("new-view-modal");
                popup.setHeadingHtml(Messages.get("label.addView", "Add view"));
                popup.setHeight(400);
                popup.setWidth(350);
                popup.setModal(true);
                popup.setLayout(new FillLayout());
                ContentTypeTree contentTypeTree = new ContentTypeTree();
                contentTypeTree.fillStore(result);
                TreeGrid<?> treeGrid = contentTypeTree.getTreeGrid();
                treeGrid.sinkEvents(Event.ONDBLCLICK + Event.ONCLICK);
                treeGrid.addListener(Events.OnDoubleClick, new Listener<TreeGridEvent<GWTJahiaNodeType>>() {

                    public void handleEvent(TreeGridEvent<GWTJahiaNodeType> baseEvent) {
                        GWTJahiaNodeType gwtJahiaNodeType = baseEvent.getModel();
                        if (gwtJahiaNodeType != null && linker != null) {
                            GWTJahiaNodeType engineNodeType = TEMPLATE.equals(gwtJahiaNodeType.getName()) ? fileNodeTypes.get(TEMPLATE_FILE) : fileNodeTypes.get(VIEW_FILE);
                            createEngine(engineNodeType, selectedNode, gwtJahiaNodeType.getName());
                            popup.hide();
                        }
                    }
                });
                popup.add(contentTypeTree);
                popup.show();
            }

            @Override
            public void onFailure(Throwable caught) {
                linker.loaded();
                super.onFailure(caught);
            }
        });
    } else {
        if (isLoading) {
            linker.loaded();
        }
        GWTJahiaNodeType fileNodeType = TEMPLATE.equals(findNodeType(selectedNode)) ? fileNodeTypes.get(TEMPLATE_FILE) : fileNodeTypes.get(VIEW_FILE);
        createEngine(fileNodeType, selectedNode, findNodeType(selectedNode));
    }
}
Also used : Listener(com.extjs.gxt.ui.client.event.Listener) GWTJahiaNode(org.jahia.ajax.gwt.client.data.node.GWTJahiaNode) ContentTypeTree(org.jahia.ajax.gwt.client.widget.edit.ContentTypeTree) FillLayout(com.extjs.gxt.ui.client.widget.layout.FillLayout) TreeGridEvent(com.extjs.gxt.ui.client.event.TreeGridEvent) TreeGrid(com.extjs.gxt.ui.client.widget.treegrid.TreeGrid) GWTJahiaNodeType(org.jahia.ajax.gwt.client.data.definition.GWTJahiaNodeType)

Example 7 with FillLayout

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

the class VisibilityTabItem method init.

@Override
public void init(NodeHolder engine, AsyncTabItem tab, String language) {
    if (engine.getNode() == null) {
        return;
    }
    final GWTJahiaNode node = engine.getNode();
    tab.setLayout(new RowLayout());
    tab.setProcessed(true);
    final boolean editable = (!engine.isExistingNode() || (PermissionsUtils.isPermitted("jcr:modifyProperties", engine.getNode()) && !engine.getNode().isLocked()));
    LayoutContainer header = new LayoutContainer(new FillLayout(Style.Orientation.VERTICAL));
    tab.add(header, new RowData(1, 25, new Margins(5)));
    final HorizontalPanel timeZonePanel = new HorizontalPanel();
    timeZonePanel.setVerticalAlign(Style.VerticalAlignment.MIDDLE);
    timeZonePanel.add(new HTML(Messages.get("label.visibility.timeZone", "All the visibility conditions are using the server timezone") + ":&nbsp;" + JahiaGWTParameters.getServerDisplayableTimeZone()));
    header.add(timeZonePanel);
    LayoutContainer top = new LayoutContainer(new FillLayout(Style.Orientation.VERTICAL));
    tab.add(top, new RowData(1, 60, new Margins(5)));
    final HorizontalPanel statusPanel = new HorizontalPanel();
    statusPanel.setVerticalAlign(Style.VerticalAlignment.MIDDLE);
    top.add(statusPanel);
    statusBar = new StatusBar(node, statusPanel, editable);
    HorizontalPanel addPanel = new HorizontalPanel();
    addPanel.setVerticalAlign(Style.VerticalAlignment.MIDDLE);
    if (editable) {
        top.add(addPanel);
    }
    addPanel.add(new HTML(Messages.get("label.visibility.allConditionsMatch", "All conditions should match") + ":&nbsp;"));
    allConditionsMatch = new CheckBox();
    allConditionsMatch.setEnabled(editable);
    allConditionsMatch.addListener(Events.Change, new Listener<ComponentEvent>() {

        public void handleEvent(ComponentEvent event) {
            changed = true;
            refreshConditionsList();
            statusBar.update();
        }
    });
    addPanel.add(allConditionsMatch);
    addPanel.add(new HTML("&nbsp;&nbsp;&nbsp;" + Messages.get("label.visibility.addCondition", "Add new condition") + ":&nbsp;"));
    final ListStore<GWTJahiaNodeType> typesStore = new ListStore<GWTJahiaNodeType>();
    final ComboBox<GWTJahiaNodeType> types = new ComboBox<GWTJahiaNodeType>();
    types.setDisplayField("label");
    types.setStore(typesStore);
    types.setTypeAhead(true);
    types.setTriggerAction(ComboBox.TriggerAction.ALL);
    types.setForceSelection(true);
    types.setEditable(false);
    types.setWidth(250);
    types.setEnabled(editable);
    addPanel.add(types);
    final Map<String, GWTJahiaNodeType> typesMap = new HashMap<String, GWTJahiaNodeType>();
    final Button add = new Button();
    add.setIcon(StandardIconsProvider.STANDARD_ICONS.plusRound());
    add.setEnabled(false);
    addPanel.add(add);
    conditionsStore = new ListStore<GWTJahiaNode>();
    deleted = new ArrayList<GWTJahiaNode>();
    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
    ColumnConfig name = new ColumnConfig("name", Messages.get("label.title"), 500);
    name.setRenderer(new GridCellRenderer<GWTJahiaNode>() {

        public Object render(GWTJahiaNode condition, String property, com.extjs.gxt.ui.client.widget.grid.ColumnData config, int rowIndex, int colIndex, ListStore<GWTJahiaNode> store, Grid<GWTJahiaNode> grid) {
            String typeName = condition.getNodeTypes().get(0);
            XTemplate tpl = typesMap.get(typeName).get("compiledTemplate");
            convertStringToDate(condition);
            return tpl.applyTemplate(com.extjs.gxt.ui.client.util.Util.getJsObject(condition));
        }
    });
    name.setFixed(true);
    configs.add(name);
    ColumnConfig conditionStatus = new ColumnConfig("status", Messages.get("label.status"), 100);
    conditionStatus.setRenderer(new GridCellRenderer<GWTJahiaNode>() {

        public Object render(GWTJahiaNode model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<GWTJahiaNode> gwtJahiaNodeListStore, Grid<GWTJahiaNode> gwtJahiaNodeGrid) {
            Boolean match = model.get("conditionMatch");
            if (match != null) {
                if (match.equals(Boolean.TRUE)) {
                    AbstractImagePrototype icon = ToolbarIconProvider.getInstance().getIcon("visibilityStatusGreen");
                    return icon.getHTML();
                } else {
                    AbstractImagePrototype icon = ToolbarIconProvider.getInstance().getIcon("visibilityStatusRed");
                    return icon.getHTML();
                }
            }
            AbstractImagePrototype icon = ToolbarIconProvider.getInstance().getIcon("visibilityStatusUnknown");
            return icon.getHTML();
        }
    });
    configs.add(conditionStatus);
    if (editable) {
        ColumnConfig remove = new ColumnConfig("remove", Messages.get("label.remove"), 100);
        remove.setRenderer(new GridCellRenderer<GWTJahiaNode>() {

            public Object render(final GWTJahiaNode condition, String property, com.extjs.gxt.ui.client.widget.grid.ColumnData config, final int rowIndex, final int colIndex, ListStore<GWTJahiaNode> listStore, final Grid<GWTJahiaNode> grid) {
                final Button button;
                if (condition.get("node-removed") == null || condition.isMarkedForDeletion()) {
                    button = new Button(Messages.get("label.remove"));
                    button.addStyleName("button-remove");
                    button.setIcon(StandardIconsProvider.STANDARD_ICONS.minusRound());
                } else {
                    button = new Button(Messages.get("label.undelete"));
                    button.addStyleName("button-undelete");
                    button.setIcon(StandardIconsProvider.STANDARD_ICONS.restore());
                }
                button.addSelectionListener(new SelectionListener<ButtonEvent>() {

                    @Override
                    public void componentSelected(ButtonEvent buttonEvent) {
                        conditionsStore.remove(condition);
                        propertiesEditorMap.remove(condition.getPath());
                        if (condition.get("new-node") == null) {
                            deleted.add(condition);
                            condition.set("node-removed", Boolean.TRUE);
                        }
                        changed = true;
                        refreshConditionsList();
                        statusBar.update();
                    }
                });
                return button;
            }
        });
        configs.add(remove);
    }
    // ColumnConfig publicationInfo = new ColumnConfig("publish", Messages.get("label.publish"), 100);
    // publicationInfo.setRenderer(new GridCellRenderer<GWTJahiaNode>() {
    // public Object render(final GWTJahiaNode conditionNode, String property, ColumnData config, int rowIndex, int colIndex,
    // ListStore<GWTJahiaNode> store, Grid<GWTJahiaNode> grid) {
    // final GWTJahiaPublicationInfo info = conditionNode.getAggregatedPublicationInfo();
    // HorizontalPanel p = new HorizontalPanel();
    // p.setVerticalAlign(Style.VerticalAlignment.MIDDLE);
    // Integer infoStatus;
    // if (info != null) {
    // if (conditionNode.get("node-modified") != null) {
    // infoStatus = GWTJahiaPublicationInfo.MODIFIED;
    // } else {
    // infoStatus = info.getStatus();
    // }
    // } else {
    // infoStatus = GWTJahiaPublicationInfo.NOT_PUBLISHED;
    // }
    // PropertiesEditor pe = propertiesEditorMap.get(conditionNode.getPath());
    // if (pe != null) {
    // if (pe.getProperties(false, true, true).isEmpty()) {
    // infoStatus = GWTJahiaPublicationInfo.MODIFIED;
    // }
    // }
    // 
    // Image res = GWTJahiaPublicationInfo.renderPublicationStatusImage(infoStatus);
    // p.add(res);
    // final CheckBox checkbox = new CheckBox();
    // if (infoStatus == GWTJahiaPublicationInfo.PUBLISHED) {
    // checkbox.setEnabled(false);
    // }
    // checkbox.addListener(Events.Change, new Listener<ComponentEvent>() {
    // public void handleEvent(ComponentEvent event) {
    // conditionNode.set("node-published", checkbox.getValue());
    // }
    // });
    // p.add(checkbox);
    // return p;
    // }
    // });
    // configs.add(publicationInfo);
    ColumnModel cm = new ColumnModel(configs);
    final Grid<GWTJahiaNode> conditions = new Grid<GWTJahiaNode>(conditionsStore, cm);
    conditions.setAutoExpandColumn("name");
    tab.add(conditions, new RowData(1, 0.5));
    final LayoutContainer form = new LayoutContainer(new FitLayout());
    form.setEnabled(editable);
    tab.add(form, new RowData(1, 0.5));
    final GridSelectionModel<GWTJahiaNode> selectionModel = conditions.getSelectionModel();
    selectionModel.setSelectionMode(Style.SelectionMode.SINGLE);
    selectionModel.addSelectionChangedListener(new SelectionChangedListener<GWTJahiaNode>() {

        public void selectionChanged(SelectionChangedEvent<GWTJahiaNode> event) {
            form.removeAll();
            final GWTJahiaNode conditionNode = selectionModel.getSelectedItem();
            if (conditionNode != null) {
                PropertiesEditor pe = propertiesEditorMap.get(conditionNode.getPath());
                if (pe != null) {
                    form.add(pe);
                    form.layout();
                } else {
                    if (conditionNode.get("new-node") != null) {
                        final GWTJahiaNodeType type = types.getSelection().get(0);
                        JahiaContentManagementService.App.getInstance().initializeCreateEngine(type.getName(), node.getPath(), null, new BaseAsyncCallback<GWTJahiaCreateEngineInitBean>() {

                            public void onSuccess(GWTJahiaCreateEngineInitBean result) {
                                PropertiesEditor pe = new PropertiesEditor(Arrays.asList(type), new HashMap<String, GWTJahiaNodeProperty>(), Arrays.asList("content"));
                                pe.setChoiceListInitializersValues(result.getChoiceListInitializersValues());
                                pe.renderNewFormPanel();
                                propertiesEditorMap.put(conditionNode.getPath(), pe);
                                form.add(pe);
                                form.layout();
                                addFieldListener(pe, conditions, conditionNode);
                            }
                        });
                    } else {
                        JahiaContentManagementService.App.getInstance().initializeEditEngine(conditionNode.getPath(), false, new BaseAsyncCallback<GWTJahiaEditEngineInitBean>() {

                            public void onSuccess(GWTJahiaEditEngineInitBean result) {
                                if (result == null) {
                                    return;
                                }
                                PropertiesEditor pe = new PropertiesEditor(result.getNodeTypes(), result.getProperties(), Arrays.asList("content"));
                                pe.setChoiceListInitializersValues(result.getInitializersValues());
                                pe.renderNewFormPanel();
                                propertiesEditorMap.put(conditionNode.getPath(), pe);
                                form.add(pe);
                                form.layout();
                                addFieldListener(pe, conditions, conditionNode);
                            }
                        });
                    }
                }
            }
        }
    });
    add.addSelectionListener(new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            GWTJahiaNode newCondition = new GWTJahiaNode();
            List<GWTJahiaNodeType> nodeTypes = types.getSelection();
            String nodeTypeName = nodeTypes.get(0).getName();
            newCondition.setNodeTypes(Arrays.asList(nodeTypeName));
            String nodeName = nodeTypeName + new Date().getTime();
            newCondition.setName(nodeName);
            newCondition.setPath(node.getPath() + "/j:conditionalVisibility/" + nodeName);
            newCondition.set("new-node", Boolean.TRUE);
            conditionsStore.add(newCondition);
            selectionModel.select(Arrays.asList(newCondition), false);
            changed = true;
            refreshConditionsList();
            statusBar.update();
        }
    });
    if (editable) {
        types.addSelectionChangedListener(new SelectionChangedListener<GWTJahiaNodeType>() {

            @Override
            public void selectionChanged(SelectionChangedEvent<GWTJahiaNodeType> se) {
                add.enable();
            }
        });
    }
    JahiaContentManagementService.App.getInstance().getVisibilityInformation(node.getPath(), new BaseAsyncCallback<ModelData>() {

        public void onSuccess(ModelData result) {
            List<GWTJahiaNodeType> l = (List<GWTJahiaNodeType>) result.get("types");
            typesStore.add(l);
            types.setSelection(Arrays.asList(l.get(0)));
            for (GWTJahiaNodeType type : l) {
                typesMap.put(type.getName(), type);
                XTemplate tpl = XTemplate.create((String) type.get("xtemplate"));
                tpl.compile();
                type.set("compiledTemplate", tpl);
            }
            conditionsStore.add((List<GWTJahiaNode>) result.get("conditions"));
            refreshConditionsList();
            allConditionsMatch.setOriginalValue(result.<Boolean>get("j:forceMatchAllConditions"));
            allConditionsMatch.setValue(result.<Boolean>get("j:forceMatchAllConditions"));
            statusBar.initStatusBar((GWTJahiaPublicationInfo) result.get("publicationInfo"), (Boolean) result.get("liveStatus"));
        }
    });
    tab.layout();
}
Also used : GWTJahiaCreateEngineInitBean(org.jahia.ajax.gwt.client.data.GWTJahiaCreateEngineInitBean) HTML(com.google.gwt.user.client.ui.HTML) ListStore(com.extjs.gxt.ui.client.store.ListStore) Button(com.extjs.gxt.ui.client.widget.button.Button) GWTJahiaNodeProperty(org.jahia.ajax.gwt.client.data.definition.GWTJahiaNodeProperty) BaseAsyncCallback(org.jahia.ajax.gwt.client.core.BaseAsyncCallback) ComboBox(com.extjs.gxt.ui.client.widget.form.ComboBox) FillLayout(com.extjs.gxt.ui.client.widget.layout.FillLayout) LayoutContainer(com.extjs.gxt.ui.client.widget.LayoutContainer) CheckBox(com.extjs.gxt.ui.client.widget.form.CheckBox) AbstractImagePrototype(com.google.gwt.user.client.ui.AbstractImagePrototype) GWTJahiaEditEngineInitBean(org.jahia.ajax.gwt.client.data.GWTJahiaEditEngineInitBean) ModelData(com.extjs.gxt.ui.client.data.ModelData) RowData(com.extjs.gxt.ui.client.widget.layout.RowData) RowLayout(com.extjs.gxt.ui.client.widget.layout.RowLayout) HorizontalPanel(com.extjs.gxt.ui.client.widget.HorizontalPanel) Margins(com.extjs.gxt.ui.client.util.Margins) GWTJahiaNodeType(org.jahia.ajax.gwt.client.data.definition.GWTJahiaNodeType) FitLayout(com.extjs.gxt.ui.client.widget.layout.FitLayout) PropertiesEditor(org.jahia.ajax.gwt.client.widget.definition.PropertiesEditor) GWTJahiaNode(org.jahia.ajax.gwt.client.data.node.GWTJahiaNode) XTemplate(com.extjs.gxt.ui.client.core.XTemplate) com.extjs.gxt.ui.client.widget.grid(com.extjs.gxt.ui.client.widget.grid) GWTJahiaPublicationInfo(org.jahia.ajax.gwt.client.data.publication.GWTJahiaPublicationInfo)

Example 8 with FillLayout

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

the class StatusPanel method onRender.

protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    setLayout(new FitLayout());
    setBorders(false);
    setId("status-panel-wrapper");
    initToolBar();
    initStatusPanel();
    ContentPanel statusWrapperPanel = new ContentPanel();
    statusWrapperPanel.setBorders(false);
    statusWrapperPanel.setBodyBorder(false);
    statusWrapperPanel.setHeaderVisible(false);
    statusWrapperPanel.setLayout(new FillLayout());
    statusWrapperPanel.setTopComponent(m_toolBar);
    statusWrapperPanel.add(m_grid);
    add(statusWrapperPanel);
    m_initialized = true;
    refresh();
}
Also used : FillLayout(com.extjs.gxt.ui.client.widget.layout.FillLayout) FitLayout(com.extjs.gxt.ui.client.widget.layout.FitLayout) ContentPanel(com.extjs.gxt.ui.client.widget.ContentPanel)

Aggregations

FillLayout (com.extjs.gxt.ui.client.widget.layout.FillLayout)8 LayoutContainer (com.extjs.gxt.ui.client.widget.LayoutContainer)3 FitLayout (com.extjs.gxt.ui.client.widget.layout.FitLayout)3 Margins (com.extjs.gxt.ui.client.util.Margins)2 ContentPanel (com.extjs.gxt.ui.client.widget.ContentPanel)2 ComboBox (com.extjs.gxt.ui.client.widget.form.ComboBox)2 HTML (com.google.gwt.user.client.ui.HTML)2 HashMap (java.util.HashMap)2 List (java.util.List)2 BaseAsyncCallback (org.jahia.ajax.gwt.client.core.BaseAsyncCallback)2 GWTJahiaNodeType (org.jahia.ajax.gwt.client.data.definition.GWTJahiaNodeType)2 GWTJahiaNode (org.jahia.ajax.gwt.client.data.node.GWTJahiaNode)2 XTemplate (com.extjs.gxt.ui.client.core.XTemplate)1 ListLoadResult (com.extjs.gxt.ui.client.data.ListLoadResult)1 ModelData (com.extjs.gxt.ui.client.data.ModelData)1 RpcProxy (com.extjs.gxt.ui.client.data.RpcProxy)1 ComponentEvent (com.extjs.gxt.ui.client.event.ComponentEvent)1 Listener (com.extjs.gxt.ui.client.event.Listener)1 TreeGridEvent (com.extjs.gxt.ui.client.event.TreeGridEvent)1 ListStore (com.extjs.gxt.ui.client.store.ListStore)1