Search in sources :

Example 16 with RpcProxy

use of com.extjs.gxt.ui.client.data.RpcProxy 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 17 with RpcProxy

use of com.extjs.gxt.ui.client.data.RpcProxy in project kura by eclipse.

the class PortForwardingConfigTab method initGrid.

private void initGrid() {
    // 
    // Column Configuration
    ColumnConfig column = null;
    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
    column = new ColumnConfig("inboundInterface", MSGS.firewallPortForwardInboundInterface(), 80);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("outboundInterface", MSGS.firewallPortForwardOutboundInterface(), 80);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("address", MSGS.firewallPortForwardAddress(), 120);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("protocol", MSGS.firewallPortForwardProtocol(), 60);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("inPort", MSGS.firewallPortForwardInPort(), 60);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("outPort", MSGS.firewallPortForwardOutPort(), 60);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("masquerade", MSGS.firewallPortForwardMasquerade(), 60);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("permittedNetwork", MSGS.firewallPortForwardPermittedNetwork(), 120);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("permittedMAC", MSGS.firewallPortForwardPermittedMac(), 120);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("sourcePortRange", MSGS.firewallPortForwardSourcePortRange(), 120);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    // rpc data proxy
    RpcProxy<ListLoadResult<GwtFirewallPortForwardEntry>> proxy = new RpcProxy<ListLoadResult<GwtFirewallPortForwardEntry>>() {

        @Override
        protected void load(Object loadConfig, final AsyncCallback<ListLoadResult<GwtFirewallPortForwardEntry>> callback) {
            gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {

                @Override
                public void onFailure(Throwable ex) {
                    FailureHandler.handle(ex);
                }

                @Override
                public void onSuccess(GwtXSRFToken token) {
                    gwtNetworkService.findDeviceFirewallPortForwards(token, callback);
                }
            });
        }
    };
    m_loader = new BaseListLoader<ListLoadResult<GwtFirewallPortForwardEntry>>(proxy);
    m_loader.setSortDir(SortDir.DESC);
    m_loader.setSortField("inPort");
    m_loader.setRemoteSort(true);
    SwappableListStore<GwtFirewallPortForwardEntry> m_store = new SwappableListStore<GwtFirewallPortForwardEntry>(m_loader);
    m_store.setKeyProvider(new ModelKeyProvider<GwtFirewallPortForwardEntry>() {

        public String getKey(GwtFirewallPortForwardEntry portForwardEntry) {
            return portForwardEntry.getInPort().toString();
        }
    });
    m_grid = new Grid<GwtFirewallPortForwardEntry>(m_store, new ColumnModel(configs));
    m_grid.setBorders(false);
    m_grid.setStateful(false);
    m_grid.setLoadMask(true);
    m_grid.setStripeRows(true);
    m_grid.setAutoExpandColumn("inPort");
    m_grid.getView().setAutoFill(true);
    // m_grid.getView().setEmptyText(MSGS.deviceTableNoDevices());
    m_loader.addLoadListener(new DataLoadListener(m_grid));
    GridSelectionModel<GwtFirewallPortForwardEntry> selectionModel = new GridSelectionModel<GwtFirewallPortForwardEntry>();
    selectionModel.setSelectionMode(SelectionMode.SINGLE);
    m_grid.setSelectionModel(selectionModel);
    m_grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GwtFirewallPortForwardEntry>() {

        @Override
        public void selectionChanged(SelectionChangedEvent<GwtFirewallPortForwardEntry> se) {
            m_selectedEntry = se.getSelectedItem();
            if (m_selectedEntry != null) {
                m_editButton.setEnabled(true);
                m_deleteButton.setEnabled(true);
            } else {
                m_editButton.setEnabled(false);
                m_deleteButton.setEnabled(false);
            }
        }
    });
}
Also used : ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) ArrayList(java.util.ArrayList) GwtXSRFToken(org.eclipse.kura.web.shared.model.GwtXSRFToken) RpcProxy(com.extjs.gxt.ui.client.data.RpcProxy) SwappableListStore(org.eclipse.kura.web.client.util.SwappableListStore) GwtFirewallPortForwardEntry(org.eclipse.kura.web.shared.model.GwtFirewallPortForwardEntry) GridSelectionModel(com.extjs.gxt.ui.client.widget.grid.GridSelectionModel) ListLoadResult(com.extjs.gxt.ui.client.data.ListLoadResult) ColumnModel(com.extjs.gxt.ui.client.widget.grid.ColumnModel)

Example 18 with RpcProxy

use of com.extjs.gxt.ui.client.data.RpcProxy in project kura by eclipse.

the class OpenPortsConfigTab method initOpenPortsGrid.

private void initOpenPortsGrid() {
    // 
    // Column Configuration
    ColumnConfig column = null;
    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
    column = new ColumnConfig("portRange", MSGS.firewallOpenPort(), 100);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("protocol", MSGS.firewallOpenPortProtocol(), 100);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("permittedNetwork", MSGS.firewallOpenPortPermittedNetwork(), 130);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("permittedInterfaceName", MSGS.firewallOpenPortPermittedInterfaceName(), 130);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("unpermittedInterfaceName", MSGS.firewallOpenPortUnpermittedInterfaceName(), 130);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("permittedMAC", MSGS.firewallOpenPortPermittedMac(), 130);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("sourcePortRange", MSGS.firewallOpenPortSourcePortRange(), 130);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    // rpc data proxy
    RpcProxy<ListLoadResult<GwtFirewallOpenPortEntry>> proxy = new RpcProxy<ListLoadResult<GwtFirewallOpenPortEntry>>() {

        @Override
        protected void load(Object loadConfig, final AsyncCallback<ListLoadResult<GwtFirewallOpenPortEntry>> callback) {
            gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {

                @Override
                public void onFailure(Throwable ex) {
                    FailureHandler.handle(ex);
                }

                @Override
                public void onSuccess(GwtXSRFToken token) {
                    gwtNetworkService.findDeviceFirewallOpenPorts(token, callback);
                }
            });
        }
    };
    m_openPortsLoader = new BaseListLoader<ListLoadResult<GwtFirewallOpenPortEntry>>(proxy);
    m_openPortsLoader.setSortDir(SortDir.DESC);
    m_openPortsLoader.setSortField("port");
    m_openPortsLoader.setRemoteSort(true);
    SwappableListStore<GwtFirewallOpenPortEntry> m_store = new SwappableListStore<GwtFirewallOpenPortEntry>(m_openPortsLoader);
    m_store.setKeyProvider(new ModelKeyProvider<GwtFirewallOpenPortEntry>() {

        public String getKey(GwtFirewallOpenPortEntry openPortEntry) {
            return openPortEntry.getPortRange();
        }
    });
    m_grid = new Grid<GwtFirewallOpenPortEntry>(m_store, new ColumnModel(configs));
    m_grid.setBorders(false);
    m_grid.setStateful(false);
    m_grid.setLoadMask(true);
    m_grid.setStripeRows(true);
    m_grid.setAutoExpandColumn("portRange");
    m_grid.getView().setAutoFill(true);
    // m_grid.getView().setEmptyText(MSGS.deviceTableNoDevices());
    m_openPortsLoader.addLoadListener(new DataLoadListener(m_grid));
    GridSelectionModel<GwtFirewallOpenPortEntry> selectionModel = new GridSelectionModel<GwtFirewallOpenPortEntry>();
    selectionModel.setSelectionMode(SelectionMode.SINGLE);
    m_grid.setSelectionModel(selectionModel);
    m_grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GwtFirewallOpenPortEntry>() {

        @Override
        public void selectionChanged(SelectionChangedEvent<GwtFirewallOpenPortEntry> se) {
            m_selectedEntry = se.getSelectedItem();
            if (m_selectedEntry != null) {
                m_editButton.setEnabled(true);
                m_deleteButton.setEnabled(true);
            } else {
                m_editButton.setEnabled(false);
                m_deleteButton.setEnabled(false);
            }
        }
    });
}
Also used : ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) ArrayList(java.util.ArrayList) GwtXSRFToken(org.eclipse.kura.web.shared.model.GwtXSRFToken) RpcProxy(com.extjs.gxt.ui.client.data.RpcProxy) SwappableListStore(org.eclipse.kura.web.client.util.SwappableListStore) GwtFirewallOpenPortEntry(org.eclipse.kura.web.shared.model.GwtFirewallOpenPortEntry) GridSelectionModel(com.extjs.gxt.ui.client.widget.grid.GridSelectionModel) ListLoadResult(com.extjs.gxt.ui.client.data.ListLoadResult) ColumnModel(com.extjs.gxt.ui.client.widget.grid.ColumnModel)

Example 19 with RpcProxy

use of com.extjs.gxt.ui.client.data.RpcProxy in project kura by eclipse.

the class ThreadsTab method onRender.

protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    setLayout(new FitLayout());
    setId("device-threads");
    RpcProxy<ListLoadResult<GwtGroupedNVPair>> proxy = new RpcProxy<ListLoadResult<GwtGroupedNVPair>>() {

        @Override
        protected void load(Object loadConfig, final AsyncCallback<ListLoadResult<GwtGroupedNVPair>> callback) {
            gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {

                @Override
                public void onFailure(Throwable ex) {
                    FailureHandler.handle(ex);
                }

                @Override
                public void onSuccess(GwtXSRFToken token) {
                    gwtDeviceService.findThreads(token, new AsyncCallback<ListLoadResult<GwtGroupedNVPair>>() {

                        public void onSuccess(ListLoadResult<GwtGroupedNVPair> pairs) {
                            callback.onSuccess(pairs);
                        }

                        public void onFailure(Throwable caught) {
                            FailureHandler.handle(caught);
                        }
                    });
                }
            });
        }
    };
    m_loader = new BaseListLoader<ListLoadResult<GwtGroupedNVPair>>(proxy);
    m_store = new GroupingStore<GwtGroupedNVPair>(m_loader);
    m_store.groupBy("group");
    ColumnConfig name = new ColumnConfig("name", MSGS.deviceThreadName(), 50);
    ColumnConfig value = new ColumnConfig("value", MSGS.deviceThreadInfo(), 50);
    List<ColumnConfig> config = new ArrayList<ColumnConfig>();
    config.add(name);
    config.add(value);
    ColumnModel cm = new ColumnModel(config);
    GroupingView view = new GroupingView();
    view.setShowGroupedColumn(false);
    view.setForceFit(true);
    m_grid = new Grid<GwtGroupedNVPair>(m_store, cm);
    m_grid.setView(view);
    m_grid.setBorders(false);
    m_grid.setLoadMask(true);
    m_grid.setStripeRows(true);
    add(m_grid);
    m_initialized = true;
}
Also used : ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) ArrayList(java.util.ArrayList) GwtGroupedNVPair(org.eclipse.kura.web.shared.model.GwtGroupedNVPair) GwtXSRFToken(org.eclipse.kura.web.shared.model.GwtXSRFToken) RpcProxy(com.extjs.gxt.ui.client.data.RpcProxy) ListLoadResult(com.extjs.gxt.ui.client.data.ListLoadResult) ColumnModel(com.extjs.gxt.ui.client.widget.grid.ColumnModel) GroupingView(com.extjs.gxt.ui.client.widget.grid.GroupingView) FitLayout(com.extjs.gxt.ui.client.widget.layout.FitLayout)

Example 20 with RpcProxy

use of com.extjs.gxt.ui.client.data.RpcProxy in project kura by eclipse.

the class SnapshotsTab method initGrid.

private void initGrid() {
    List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
    ColumnConfig column = new ColumnConfig("snapshotId", MSGS.deviceSnapshotId(), 25);
    column.setSortable(false);
    column.setAlignment(HorizontalAlignment.CENTER);
    columns.add(column);
    column = new ColumnConfig("createdOnFormatted", MSGS.deviceSnapshotCreatedOn(), 75);
    column.setSortable(false);
    column.setAlignment(HorizontalAlignment.LEFT);
    columns.add(column);
    // loader and store
    RpcProxy<ListLoadResult<GwtSnapshot>> proxy = new RpcProxy<ListLoadResult<GwtSnapshot>>() {

        @Override
        public void load(Object loadConfig, final AsyncCallback<ListLoadResult<GwtSnapshot>> callback) {
            gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {

                @Override
                public void onFailure(Throwable ex) {
                    FailureHandler.handle(ex);
                }

                @Override
                public void onSuccess(GwtXSRFToken token) {
                    gwtSnapshotService.findDeviceSnapshots(token, callback);
                }
            });
        }
    };
    m_loader = new BaseListLoader<ListLoadResult<GwtSnapshot>>(proxy);
    m_loader.setSortDir(SortDir.DESC);
    m_loader.setSortField("createdOnFormatted");
    m_loader.addLoadListener(new DataLoadListener());
    m_store = new ListStore<GwtSnapshot>(m_loader);
    m_grid = new Grid<GwtSnapshot>(m_store, new ColumnModel(columns));
    m_grid.setBorders(false);
    m_grid.setStateful(false);
    m_grid.setLoadMask(true);
    m_grid.setStripeRows(true);
    m_grid.setTrackMouseOver(false);
    m_grid.getView().setAutoFill(true);
    m_grid.getView().setEmptyText(MSGS.deviceSnapshotsNone());
    GridSelectionModel<GwtSnapshot> selectionModel = new GridSelectionModel<GwtSnapshot>();
    selectionModel.setSelectionMode(SelectionMode.SINGLE);
    m_grid.setSelectionModel(selectionModel);
    m_grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GwtSnapshot>() {

        @Override
        public void selectionChanged(SelectionChangedEvent<GwtSnapshot> se) {
            if (se.getSelectedItem() != null) {
                m_downloadButton.setEnabled(true);
                m_rollbackButton.setEnabled(true);
            } else {
                m_downloadButton.setEnabled(false);
                m_rollbackButton.setEnabled(false);
            }
        }
    });
}
Also used : GwtSnapshot(org.eclipse.kura.web.shared.model.GwtSnapshot) ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) ArrayList(java.util.ArrayList) GridSelectionModel(com.extjs.gxt.ui.client.widget.grid.GridSelectionModel) GwtXSRFToken(org.eclipse.kura.web.shared.model.GwtXSRFToken) RpcProxy(com.extjs.gxt.ui.client.data.RpcProxy) ListLoadResult(com.extjs.gxt.ui.client.data.ListLoadResult) ColumnModel(com.extjs.gxt.ui.client.widget.grid.ColumnModel)

Aggregations

RpcProxy (com.extjs.gxt.ui.client.data.RpcProxy)28 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)28 ArrayList (java.util.ArrayList)26 ColumnModel (com.extjs.gxt.ui.client.widget.grid.ColumnModel)24 ColumnConfig (com.extjs.gxt.ui.client.widget.grid.ColumnConfig)22 ListLoadResult (com.extjs.gxt.ui.client.data.ListLoadResult)19 GridSelectionModel (com.extjs.gxt.ui.client.widget.grid.GridSelectionModel)13 GwtXSRFToken (org.eclipse.kura.web.shared.model.GwtXSRFToken)11 ListStore (com.extjs.gxt.ui.client.store.ListStore)9 FitLayout (com.extjs.gxt.ui.client.widget.layout.FitLayout)8 ContentPanel (com.extjs.gxt.ui.client.widget.ContentPanel)7 ColumnData (com.extjs.gxt.ui.client.widget.grid.ColumnData)7 List (java.util.List)7 Grid (com.extjs.gxt.ui.client.widget.grid.Grid)6 GroupingView (com.extjs.gxt.ui.client.widget.grid.GroupingView)6 ModelData (com.extjs.gxt.ui.client.data.ModelData)5 GridCellRenderer (com.extjs.gxt.ui.client.widget.grid.GridCellRenderer)5 GWTJahiaNode (org.jahia.ajax.gwt.client.data.node.GWTJahiaNode)5 PagingLoadResult (com.extjs.gxt.ui.client.data.PagingLoadResult)4 Window (com.extjs.gxt.ui.client.widget.Window)4