Search in sources :

Example 16 with Window

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

the class ContentBrowseTabItem method create.

@Override
public TabItem create(final GWTSidePanelTab config) {
    super.create(config);
    contentContainer = new LayoutContainer();
    contentContainer.setBorders(true);
    contentContainer.setScrollMode(Style.Scroll.AUTO);
    contentContainer.setLayout(new FitLayout());
    // data proxy
    final List<String> loadedNodeTypes = new ArrayList<String>();
    loadedNodeTypes.addAll(JCRClientUtils.FILE_NODETYPES);
    loadedNodeTypes.addAll(JCRClientUtils.CONTENT_NODETYPES);
    RpcProxy<PagingLoadResult<GWTJahiaNode>> listProxy = getPagingLoadResultRpcProxy(config, loadedNodeTypes);
    listLoader = new BaseListLoader<>(listProxy);
    listLoader.addLoadListener(new LoadListener() {

        @Override
        public void loaderLoad(LoadEvent le) {
            if (!le.isCancelled()) {
                contentContainer.unmask();
            }
        }
    });
    contentStore = new ListStore<GWTJahiaNode>(listLoader);
    contentStore.setStoreSorter(new StoreSorter<GWTJahiaNode>(new Comparator<Object>() {

        @Override
        public int compare(Object o1, Object o2) {
            if (o1 instanceof String && o2 instanceof String) {
                String s1 = (String) o1;
                String s2 = (String) o2;
                return Collator.getInstance().localeCompare(s1, s2);
            } else if (o1 instanceof Comparable && o2 instanceof Comparable) {
                return ((Comparable) o1).compareTo(o2);
            }
            return 0;
        }
    }));
    addSelectionChangedListener();
    tree.setContextMenu(createContextMenu(config.getTreeContextMenu(), tree.getSelectionModel()));
    VBoxLayoutData contentVBoxData = new VBoxLayoutData();
    contentVBoxData.setFlex(2);
    if (config.getTableColumns().size() == 1) {
        listView = new ThumbsListView(true);
        listView.setStyleAttribute("overflow-x", "hidden");
        listView.setStore(contentStore);
        contentStore.setSortField("display");
        listView.addListener(Events.DoubleClick, new Listener<ListViewEvent<GWTJahiaNode>>() {

            @Override
            public void handleEvent(ListViewEvent<GWTJahiaNode> be) {
                Window w = new Window();
                w.addStyleName("content-browse-preview");
                GWTJahiaNode node = listView.getSelectionModel().getSelectedItem();
                final String text = "Preview of " + node.getDisplayName();
                w.setHeadingHtml(text);
                w.setScrollMode(Style.Scroll.AUTO);
                w.setModal(true);
                w.setClosable(true);
                w.setMaximizable(true);
                w.setSize(Math.max(Integer.parseInt((String) node.get("j:width")) + 60, 400), Math.max(Integer.parseInt((String) node.get("j:height")) + 80, 50));
                w.setBlinkModal(true);
                w.setPlain(true);
                w.setToolTip(text);
                w.setLayout(new CenterLayout());
                w.add(new Image(listView.getSelectionModel().getSelectedItem().getUrl()));
                w.show();
            }
        });
        listView.setContextMenu(createContextMenu(config.getTableContextMenu(), listView.getSelectionModel()));
        contentContainer.add(listView);
    } else {
        NodeColumnConfigList displayColumns = new NodeColumnConfigList(config.getTableColumns(), true);
        grid = new Grid<GWTJahiaNode>(contentStore, new ColumnModel(displayColumns));
        grid.setAutoExpandColumn(displayColumns.getAutoExpand());
        contentContainer.add(grid);
        grid.setContextMenu(createContextMenu(config.getTableContextMenu(), grid.getSelectionModel()));
    }
    contentVBoxData = new VBoxLayoutData();
    contentVBoxData.setFlex(2);
    tab.add(contentContainer, contentVBoxData);
    tab.setId("JahiaGxtContentBrowseTab");
    return tab;
}
Also used : VBoxLayoutData(com.extjs.gxt.ui.client.widget.layout.VBoxLayoutData) NodeColumnConfigList(org.jahia.ajax.gwt.client.widget.NodeColumnConfigList) Image(com.google.gwt.user.client.ui.Image) CenterLayout(com.extjs.gxt.ui.client.widget.layout.CenterLayout) FitLayout(com.extjs.gxt.ui.client.widget.layout.FitLayout) Window(com.extjs.gxt.ui.client.widget.Window) GWTJahiaNode(org.jahia.ajax.gwt.client.data.node.GWTJahiaNode) LayoutContainer(com.extjs.gxt.ui.client.widget.LayoutContainer) ThumbsListView(org.jahia.ajax.gwt.client.widget.content.ThumbsListView)

Example 17 with Window

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

the class FileImagesBrowseTabItem method create.

@Override
public TabItem create(GWTSidePanelTab config) {
    super.create(config);
    contentContainer = new LayoutContainer();
    contentContainer.setId("images-view");
    contentContainer.setBorders(true);
    contentContainer.setScrollMode(Style.Scroll.AUTOY);
    contentContainer.setLayout(new FitLayout());
    // data proxy
    RpcProxy<PagingLoadResult<GWTJahiaNode>> listProxy = new RpcProxy<PagingLoadResult<GWTJahiaNode>>() {

        @Override
        protected void load(Object gwtJahiaFolder, AsyncCallback<PagingLoadResult<GWTJahiaNode>> listAsyncCallback) {
            if (gwtJahiaFolder != null) {
                String path = ((GWTJahiaNode) gwtJahiaFolder).getPath();
                Log.debug("retrieving children of " + path);
                JahiaContentManagementService.App.getInstance().lsLoad(path, JCRClientUtils.FILE_NODETYPES, null, null, Arrays.asList(GWTJahiaNode.PERMISSIONS, GWTJahiaNode.ICON, GWTJahiaNode.PUBLICATION_INFO, GWTJahiaNode.THUMBNAILS, GWTJahiaNode.TAGS, "j:width", "j:height"), false, -1, -1, false, null, null, false, false, listAsyncCallback);
            } else {
                contentContainer.unmask();
            }
        }
    };
    listLoader = new BaseListLoader<ListLoadResult<GWTJahiaNode>>(listProxy);
    listLoader.addLoadListener(new LoadListener() {

        @Override
        public void loaderLoad(LoadEvent le) {
            if (!le.isCancelled()) {
                contentContainer.unmask();
            }
        }
    });
    contentStore = new ListStore<GWTJahiaNode>(listLoader);
    contentStore.setStoreSorter(new StoreSorter<GWTJahiaNode>(new Comparator<Object>() {

        @Override
        public int compare(Object o1, Object o2) {
            if (o1 instanceof String && o2 instanceof String) {
                String s1 = (String) o1;
                String s2 = (String) o2;
                return Collator.getInstance().localeCompare(s1, s2);
            } else if (o1 instanceof Comparable && o2 instanceof Comparable) {
                return ((Comparable) o1).compareTo(o2);
            }
            return 0;
        }
    }));
    tree.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GWTJahiaNode>() {

        @Override
        public void selectionChanged(SelectionChangedEvent<GWTJahiaNode> event) {
            contentContainer.mask(Messages.get("label.loading", "Loading..."), "x-mask-loading");
            listLoader.load(event.getSelectedItem());
        }
    });
    tree.setContextMenu(createContextMenu(config.getTreeContextMenu(), tree.getSelectionModel()));
    listView = new ThumbsListView(true);
    listView.setStyleAttribute("overflow-x", "hidden");
    listView.setStore(contentStore);
    contentStore.setSortField("display");
    contentContainer.add(listView);
    VBoxLayoutData contentVBoxData = new VBoxLayoutData();
    contentVBoxData.setFlex(2);
    tab.add(contentContainer, contentVBoxData);
    listView.addListener(Events.DoubleClick, new Listener<ListViewEvent<GWTJahiaNode>>() {

        @Override
        public void handleEvent(ListViewEvent<GWTJahiaNode> be) {
            Window w = new Window();
            w.addStyleName("fileimage-browse-preview");
            GWTJahiaNode node = listView.getSelectionModel().getSelectedItem();
            final String text = "Preview of " + node.getDisplayName();
            w.setHeadingHtml(text);
            w.setScrollMode(Style.Scroll.AUTO);
            w.setModal(true);
            w.setClosable(true);
            w.setMaximizable(true);
            w.setSize(Math.max(Integer.parseInt((String) node.get("j:width")) + 60, 400), Math.max(Integer.parseInt((String) node.get("j:height")) + 80, 50));
            w.setBlinkModal(true);
            w.setPlain(true);
            w.setToolTip(text);
            w.setLayout(new CenterLayout());
            w.add(new Image(listView.getSelectionModel().getSelectedItem().getUrl()));
            w.show();
        }
    });
    listView.setContextMenu(createContextMenu(config.getTableContextMenu(), listView.getSelectionModel()));
    tab.setId("JahiaGxtFileImagesBrowseTab");
    return tab;
}
Also used : VBoxLayoutData(com.extjs.gxt.ui.client.widget.layout.VBoxLayoutData) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) Image(com.google.gwt.user.client.ui.Image) CenterLayout(com.extjs.gxt.ui.client.widget.layout.CenterLayout) FitLayout(com.extjs.gxt.ui.client.widget.layout.FitLayout) Window(com.extjs.gxt.ui.client.widget.Window) GWTJahiaNode(org.jahia.ajax.gwt.client.data.node.GWTJahiaNode) LayoutContainer(com.extjs.gxt.ui.client.widget.LayoutContainer) ThumbsListView(org.jahia.ajax.gwt.client.widget.content.ThumbsListView)

Example 18 with Window

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

the class NodeUsagesGrid method createUsageGrid.

public static Grid<GWTJahiaNodeUsage> createUsageGrid(final List<GWTJahiaNode> nodes, final String baseUsageUrl) {
    List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
    ColumnConfig col = new ColumnConfig("pagePath", Messages.get("label.pageUrl", "Page URL"), 200);
    col.setRenderer(new GridCellRenderer<GWTJahiaNodeUsage>() {

        @Override
        public Object render(GWTJahiaNodeUsage gwtJahiaNodeUsage, String s, ColumnData columnData, int i, int i1, ListStore<GWTJahiaNodeUsage> gwtJahiaNodeUsageListStore, com.extjs.gxt.ui.client.widget.grid.Grid<GWTJahiaNodeUsage> gwtJahiaNodeUsageGrid) {
            if (gwtJahiaNodeUsage.getLanguage() == null) {
                return "<a href=\"" + baseUsageUrl + gwtJahiaNodeUsage.getPagePath() + ".html\" target=\"_blank\">" + gwtJahiaNodeUsage.getPageTitle() + "<a>";
            } else {
                return "<a href=\"" + baseUsageUrl + "/../" + gwtJahiaNodeUsage.getLanguage() + gwtJahiaNodeUsage.getPagePath() + ".html\" target=\"_blank\">" + gwtJahiaNodeUsage.getPageTitle() + " (" + gwtJahiaNodeUsage.getLanguage() + ")<a>";
            }
        }
    });
    columns.add(col);
    col = new ColumnConfig("path", Messages.get("label.path", "URL"), 600);
    columns.add(col);
    ColumnModel cm = new ColumnModel(columns);
    final ListStore<GWTJahiaNodeUsage> usageStore = new ListStore<GWTJahiaNodeUsage>(new BaseListLoader(new RpcProxy<List<GWTJahiaNodeUsage>>() {

        @Override
        protected void load(Object loadConfig, final AsyncCallback<List<GWTJahiaNodeUsage>> asyncCallback) {
            List<String> paths = new ArrayList<String>();
            for (GWTJahiaNode selectedNode : nodes) {
                paths.add(selectedNode.getPath());
            }
            instance.getUsages(paths, new BaseAsyncCallback<List<GWTJahiaNodeUsage>>() {

                @Override
                public void onApplicationFailure(Throwable throwable) {
                    Log.debug("Cannot retrieve usages", throwable);
                }

                @Override
                public void onSuccess(List<GWTJahiaNodeUsage> gwtJahiaNodeUsages) {
                    asyncCallback.onSuccess(gwtJahiaNodeUsages);
                }
            });
        }
    }));
    final Grid<GWTJahiaNodeUsage> tbl = new Grid<GWTJahiaNodeUsage>(usageStore, cm);
    tbl.addListener(Events.RowDoubleClick, new Listener<GridEvent<?>>() {

        @Override
        public void handleEvent(GridEvent<?> tableEvent) {
            Object url = tableEvent.getModel().get("path");
            if (url != null && url instanceof String) {
                instance.getRenderedContent((String) url, null, JahiaGWTParameters.getUILanguage(), null, "module", null, false, null, null, null, new BaseAsyncCallback<GWTRenderResult>() {

                    @Override
                    public void onSuccess(GWTRenderResult result) {
                        HTML html = new HTML(result.getResult());
                        Window w = new Window();
                        w.addStyleName("node-usage-dblclick-preview");
                        w.setScrollMode(Style.Scroll.AUTO);
                        w.setModal(true);
                        w.setClosable(true);
                        w.setMaximizable(true);
                        w.setSize(800, 600);
                        w.setBlinkModal(true);
                        w.setPlain(true);
                        w.setLayout(new CenterLayout());
                        w.add(html);
                        w.show();
                    }
                });
            }
        }
    });
    usageStore.getLoader().load();
    return tbl;
}
Also used : GridEvent(com.extjs.gxt.ui.client.event.GridEvent) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) BaseAsyncCallback(org.jahia.ajax.gwt.client.core.BaseAsyncCallback) ArrayList(java.util.ArrayList) HTML(com.google.gwt.user.client.ui.HTML) BaseListLoader(com.extjs.gxt.ui.client.data.BaseListLoader) RpcProxy(com.extjs.gxt.ui.client.data.RpcProxy) ListStore(com.extjs.gxt.ui.client.store.ListStore) BaseAsyncCallback(org.jahia.ajax.gwt.client.core.BaseAsyncCallback) CenterLayout(com.extjs.gxt.ui.client.widget.layout.CenterLayout) ArrayList(java.util.ArrayList) List(java.util.List) Window(com.extjs.gxt.ui.client.widget.Window) GWTRenderResult(org.jahia.ajax.gwt.client.data.GWTRenderResult) GWTJahiaNode(org.jahia.ajax.gwt.client.data.node.GWTJahiaNode) com.extjs.gxt.ui.client.widget.grid(com.extjs.gxt.ui.client.widget.grid) GWTJahiaNodeUsage(org.jahia.ajax.gwt.client.data.node.GWTJahiaNodeUsage)

Example 19 with Window

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

the class PortletDefinitionField method onTriggerClick.

@Override
protected void onTriggerClick(ComponentEvent componentEvent) {
    super.onTriggerClick(componentEvent);
    if (disabled || isReadOnly()) {
        return;
    }
    final Window w = new Window();
    w.addStyleName("portlet-definition-window");
    w.setLayout(new FitLayout());
    final PortletDefinitionCard card = new PortletDefinitionCard();
    w.setModal(true);
    w.setSize(600, 400);
    ButtonBar bar = new ButtonBar();
    Button ok = new Button(Messages.get("org.jahia.engines.PortletsManager.wizard.ok.label", "OK"), new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent event) {
            GWTJahiaPortletDefinition def = card.getSelectedPortletDefinition();
            setRawValue(def.getDefinitionName());
            w.hide();
        }
    });
    ok.addStyleName("button-ok");
    bar.add(ok);
    w.setTopComponent(bar);
    w.add(card);
    w.show();
}
Also used : Window(com.extjs.gxt.ui.client.widget.Window) GWTJahiaPortletDefinition(org.jahia.ajax.gwt.client.data.node.GWTJahiaPortletDefinition) ButtonBar(com.extjs.gxt.ui.client.widget.button.ButtonBar) Button(com.extjs.gxt.ui.client.widget.button.Button) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent) FitLayout(com.extjs.gxt.ui.client.widget.layout.FitLayout)

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