Example usage for com.google.gwt.user.cellview.client Column Column

List of usage examples for com.google.gwt.user.cellview.client Column Column

Introduction

In this page you can find the example usage for com.google.gwt.user.cellview.client Column Column.

Prototype

public Column(Cell<C> cell) 

Source Link

Document

Construct a new Column with a given Cell .

Usage

From source file:org.jboss.as.console.client.shared.subsys.elytron.ui.factory.GenericAuthenticationMechanismFactoryEditor.java

License:Open Source License

@SuppressWarnings("unchecked")
public Widget asWidget() {
    VerticalPanel panel = new VerticalPanel();
    panel.addStyleName("fill-popupLayout-width");

    // table/*from   ww w.  j  a v  a  2 s .com*/
    table = new DefaultCellTable<>(5);
    dataProvider = new ListDataProvider<>();
    dataProvider.addDataDisplay(table);
    table.setSelectionModel(selectionModel);

    // columns
    Column<ModelNode, String> mechanismNameColumn = new TextColumn<ModelNode>() {
        @Override
        public String getValue(ModelNode node) {
            // as the mechanism-configuration  attribute is a list of attributes
            // none of them is required, so there is not a unique colum to show, so all defined attributes are
            // displayed, there is a "view" button that shows all attributes nicely formatted in a ModelNodeForm
            StringBuilder content = new StringBuilder();
            for (Property prop : node.asPropertyList()) {
                content.append(prop.getName()).append(": ").append(prop.getValue().asString()).append(", ");
            }
            return StringUtils.shortenStringIfNecessary(content.toString(), 120);
        }
    };

    Column<ModelNode, ModelNode> linkOpenDetailsColumn = new Column<ModelNode, ModelNode>(
            new ViewLinkCell<>(Console.CONSTANTS.common_label_view(), new ActionCell.Delegate<ModelNode>() {

                @Override
                public void execute(ModelNode selection) {
                    showMechanismConfigurationModal(selection);
                }
            })) {
        @Override
        public ModelNode getValue(ModelNode node) {
            return node;
        }
    };

    linkOpenDetailsColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    table.addColumn(mechanismNameColumn, "");
    table.addColumn(linkOpenDetailsColumn, "Option");
    table.setColumnWidth(linkOpenDetailsColumn, 8, Style.Unit.PCT);

    panel.add(mainTableTools());
    panel.add(table);

    DefaultPager pager = new DefaultPager();
    pager.setDisplay(table);
    panel.add(pager);

    // ===================== mechanism configuration form popup
    popupLayout.setStyleName("window-content");

    // read-only form to show details of mechanism-configuration attribute
    ModelNodeFormBuilder.FormAssets mechanismConfigurationFormView = new ModelNodeFormBuilder()
            .setResourceDescription(resourceDescription).setCreateMode(false).unsorted()
            .setCreateNameAttribute(false).setSecurityContext(securityContext)
            .exclude("mechanism-realm-configurations").build();
    mechanismConfigurationForm = mechanismConfigurationFormView.getForm();

    popupDialogOptions.showCancel(false);
    Widget formWidget = mechanismConfigurationFormView.getForm().asWidget();
    popupLayout.add(formWidget);

    return panel;
}

From source file:org.jboss.as.console.client.shared.subsys.jca.DatasourceTable.java

License:Open Source License

Widget asWidget() {

    VerticalPanel layout = new VerticalPanel();
    layout.setStyleName("fill-layout-width");

    dataSourceTable = new DefaultCellTable<DataSource>(PAGE_SIZE, new ProvidesKey<DataSource>() {
        @Override// ww w  .j  ava2s  .  c  o m
        public Object getKey(DataSource item) {
            return item.getJndiName();
        }
    });

    dataProvider = new ListDataProvider<DataSource>();
    dataProvider.addDataDisplay(dataSourceTable);

    TextColumn<DataSource> nameColumn = new TextColumn<DataSource>() {
        @Override
        public String getValue(DataSource record) {
            return record.getName();
        }
    };

    TextColumn<DataSource> jndiNameColumn = new TextColumn<DataSource>() {
        @Override
        public String getValue(DataSource record) {
            return record.getJndiName();
        }
    };

    Column<DataSource, ImageResource> statusColumn = new Column<DataSource, ImageResource>(
            new ImageResourceCell()) {
        @Override
        public ImageResource getValue(DataSource dataSource) {

            ImageResource res = null;

            if (dataSource.isEnabled())
                res = Icons.INSTANCE.status_good();
            else
                res = Icons.INSTANCE.status_bad();

            return res;
        }
    };

    dataSourceTable.addColumn(nameColumn, "Name");
    dataSourceTable.addColumn(jndiNameColumn, "JNDI");
    dataSourceTable.addColumn(statusColumn, "Enabled?");

    layout.add(dataSourceTable);

    // ---
    // http://code.google.com/p/google-web-toolkit/issues/detail?id=4988

    DefaultPager pager = new DefaultPager();
    pager.setDisplay(dataSourceTable);
    layout.add(pager);

    return layout;
}

From source file:org.jboss.as.console.client.shared.subsys.jca.XADataSourceEditor.java

License:Open Source License

public Widget asWidget() {

    LayoutPanel layout = new LayoutPanel();

    ToolStrip topLevelTools = new ToolStrip();
    ToolButton commonLabelAddBtn = new ToolButton(Console.CONSTANTS.common_label_add(), new ClickHandler() {

        @Override//w ww . j  a  va 2 s  .  co m
        public void onClick(ClickEvent event) {
            presenter.launchNewXADatasourceWizard();
        }
    });
    commonLabelAddBtn.ensureDebugId(Console.DEBUG_CONSTANTS.debug_label_add_xADataSourceEditor());
    topLevelTools.addToolButtonRight(commonLabelAddBtn);

    ClickHandler clickHandler = new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {

            final XADataSource currentSelection = details.getCurrentSelection();
            if (currentSelection != null) {
                Feedback.confirm(Console.MESSAGES.deleteTitle("XA Datasource"),
                        Console.MESSAGES.deleteConfirm("XA Datasource " + currentSelection.getName()),
                        new Feedback.ConfirmationHandler() {
                            @Override
                            public void onConfirmation(boolean isConfirmed) {
                                if (isConfirmed) {
                                    presenter.onDeleteXA(currentSelection);
                                }
                            }
                        });
            }
        }
    };
    ToolButton deleteBtn = new ToolButton(Console.CONSTANTS.common_label_delete());
    deleteBtn.ensureDebugId(Console.DEBUG_CONSTANTS.debug_label_delete_xADataSourceEditor());
    deleteBtn.addClickHandler(clickHandler);
    topLevelTools.addToolButtonRight(deleteBtn);

    // ----

    VerticalPanel vpanel = new VerticalPanel();
    vpanel.setStyleName("rhs-content-panel");

    ScrollPanel scroll = new ScrollPanel(vpanel);
    layout.add(scroll);

    layout.setWidgetTopHeight(scroll, 0, Style.Unit.PX, 100, Style.Unit.PCT);

    // ---

    vpanel.add(new ContentHeaderLabel("JDBC XA Datasources"));

    vpanel.add(new ContentDescription(Console.CONSTANTS.subsys_jca_xadataSources_desc()));

    dataSourceTable = new DefaultCellTable<XADataSource>(8, new ProvidesKey<XADataSource>() {
        @Override
        public Object getKey(XADataSource item) {
            return item.getJndiName();
        }
    });

    dataSourceProvider = new ListDataProvider<XADataSource>();
    dataSourceProvider.addDataDisplay(dataSourceTable);

    TextColumn<DataSource> nameColumn = new TextColumn<DataSource>() {
        @Override
        public String getValue(DataSource record) {
            return record.getName();
        }
    };

    TextColumn<DataSource> jndiNameColumn = new TextColumn<DataSource>() {
        @Override
        public String getValue(DataSource record) {
            return record.getJndiName();
        }
    };

    Column<DataSource, ImageResource> statusColumn = new Column<DataSource, ImageResource>(
            new ImageResourceCell()) {
        @Override
        public ImageResource getValue(DataSource dataSource) {

            ImageResource res = null;

            if (dataSource.isEnabled())
                res = Icons.INSTANCE.status_good();
            else
                res = Icons.INSTANCE.status_bad();

            return res;
        }
    };

    dataSourceTable.addColumn(nameColumn, "Name");
    dataSourceTable.addColumn(jndiNameColumn, "JNDI");
    dataSourceTable.addColumn(statusColumn, "Enabled?");

    vpanel.add(new ContentGroupLabel(Console.MESSAGES.available("XA Datasources")));
    vpanel.add(topLevelTools.asWidget());
    vpanel.add(dataSourceTable);

    DefaultPager pager = new DefaultPager();
    pager.setDisplay(dataSourceTable);
    vpanel.add(pager);

    // -----------
    details = new XADataSourceDetails(presenter);

    propertyEditor = new PropertyEditor(this, true);
    propertyEditor.setHelpText(Console.CONSTANTS.subsys_jca_dataSource_xaprop_help());

    final SingleSelectionModel<XADataSource> selectionModel = new SingleSelectionModel<XADataSource>();
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            XADataSource dataSource = selectionModel.getSelectedObject();
            String nextState = dataSource.isEnabled() ? Console.CONSTANTS.common_label_disable()
                    : Console.CONSTANTS.common_label_enable();
            disableBtn.setText(nextState);

            presenter.loadXAProperties(dataSource.getName());
            presenter.loadPoolConfig(true, dataSource.getName());
        }
    });
    dataSourceTable.setSelectionModel(selectionModel);

    ClickHandler disableHandler = new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {

            final XADataSource selection = getCurrentSelection();
            final boolean doEnable = !selection.isEnabled();
            Feedback.confirm(Console.MESSAGES.modify("XA datasource"),
                    Console.MESSAGES.modifyConfirm("XA datasource " + selection.getName()),
                    new Feedback.ConfirmationHandler() {
                        @Override
                        public void onConfirmation(boolean isConfirmed) {
                            if (isConfirmed) {
                                presenter.onDisableXA(selection, doEnable);
                            }
                        }
                    });
        }
    };

    disableBtn = new ToolButton(Console.CONSTANTS.common_label_enOrDisable());
    disableBtn.ensureDebugId(Console.DEBUG_CONSTANTS.debug_label_enOrDisable_xADataSourceDetails());
    disableBtn.addClickHandler(disableHandler);
    topLevelTools.addToolButtonRight(disableBtn);

    // -----

    TabPanel bottomPanel = new TabPanel();
    bottomPanel.setStyleName("default-tabpanel");
    bottomPanel.add(details.asWidget(), "Attributes");
    details.getForm().bind(dataSourceTable);

    final FormToolStrip.FormCallback<XADataSource> xaCallback = new FormToolStrip.FormCallback<XADataSource>() {
        @Override
        public void onSave(Map<String, Object> changeset) {
            DataSource ds = getCurrentSelection();
            presenter.onSaveXADetails(ds.getName(), changeset);
        }

        @Override
        public void onDelete(XADataSource entity) {
            // n/a
        }
    };

    final FormToolStrip.FormCallback<DataSource> dsCallback = new FormToolStrip.FormCallback<DataSource>() {
        @Override
        public void onSave(Map<String, Object> changeset) {
            DataSource ds = getCurrentSelection();
            presenter.onSaveXADetails(ds.getName(), changeset);
        }

        @Override
        public void onDelete(DataSource entity) {
            // n/a
        }
    };

    connectionEditor = new XADataSourceConnection(presenter, xaCallback);
    connectionEditor.getForm().bind(dataSourceTable);
    bottomPanel.add(connectionEditor.asWidget(), "Connection");

    securityEditor = new DataSourceSecurityEditor(dsCallback);
    securityEditor.getForm().bind(dataSourceTable);
    bottomPanel.add(securityEditor.asWidget(), "Security");

    bottomPanel.add(propertyEditor.asWidget(), "Properties");
    propertyEditor.setAllowEditProps(false);

    poolConfig = new PoolConfigurationView(new PoolManagement() {
        @Override
        public void onSavePoolConfig(String parentName, Map<String, Object> changeset) {
            presenter.onSavePoolConfig(parentName, changeset, true);
        }

        @Override
        public void onResetPoolConfig(String parentName, PoolConfig entity) {
            presenter.onDeletePoolConfig(parentName, entity, true);
        }

        @Override
        public void onDoFlush(String editedName) {
            presenter.onDoFlush(true, editedName);
        }
    });
    bottomPanel.add(poolConfig.asWidget(), "Pool");
    poolConfig.getForm().bind(dataSourceTable);

    validationEditor = new DataSourceValidationEditor(dsCallback);
    validationEditor.getForm().bind(dataSourceTable);
    bottomPanel.add(validationEditor.asWidget(), "Validation");

    bottomPanel.selectTab(0);
    vpanel.add(new ContentGroupLabel(Console.CONSTANTS.common_label_selection()));
    vpanel.add(bottomPanel);
    return layout;
}

From source file:org.jboss.as.console.client.shared.subsys.messaging.AddressingDetails.java

License:Open Source License

Widget asWidget() {

    addrTable = new DefaultCellTable<AddressingPattern>(8, new ProvidesKey<AddressingPattern>() {
        @Override// w  w  w .  j ava  2 s  .c  o  m
        public Object getKey(AddressingPattern item) {
            return item.getPattern();
        }
    });
    addrProvider = new ListDataProvider<AddressingPattern>();
    addrProvider.addDataDisplay(addrTable);

    Column<AddressingPattern, String> patternColumn = new Column<AddressingPattern, String>(new TextCell()) {
        @Override
        public String getValue(AddressingPattern object) {
            return object.getPattern();
        }
    };

    addrTable.addColumn(patternColumn, "Pattern");

    // ---

    form = new Form<AddressingPattern>(AddressingPattern.class);
    form.setNumColumns(2);
    form.bind(addrTable);

    TextBoxItem dlQ = new TextBoxItem("deadLetterQueue", "Dead Letter Address");
    TextBoxItem expQ = new TextBoxItem("expiryQueue", "Expiry Address");
    NumberBoxItem redelivery = new NumberBoxItem("redeliveryDelay", "Redelivery Delay");
    NumberBoxItem maxDelivery = new NumberBoxItem("maxDelivery", "Max Delivery Attepmts");

    form.setFields(dlQ, expQ, redelivery, maxDelivery);

    FormHelpPanel helpPanel = new FormHelpPanel(new FormHelpPanel.AddressCallback() {
        @Override
        public ModelNode getAddress() {
            ModelNode address = Baseadress.get();
            address.add("subsystem", "messaging");
            address.add("hornetq-server", "*");
            address.add("address-setting", "*");
            return address;
        }
    }, form);

    FormToolStrip<AddressingPattern> formTools = new FormToolStrip<AddressingPattern>(form,
            new FormToolStrip.FormCallback<AddressingPattern>() {
                @Override
                public void onSave(Map<String, Object> changeset) {
                    presenter.onSaveAddressDetails(form.getEditedEntity(), changeset);
                }

                @Override
                public void onDelete(AddressingPattern entity) {

                }
            });
    ToolStrip tableTools = new ToolStrip();
    ToolButton addBtn = new ToolButton(Console.CONSTANTS.common_label_add(), new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            presenter.launchNewAddrDialogue();
        }
    });
    addBtn.ensureDebugId(Console.DEBUG_CONSTANTS.debug_label_add_addressingDetails());
    tableTools.addToolButtonRight(addBtn);

    ToolButton removeBtn = new ToolButton(Console.CONSTANTS.common_label_delete(), new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {

            Feedback.confirm(Console.MESSAGES.deleteTitle("Addressing Config"),
                    Console.MESSAGES.deleteConfirm("Addressing Config"), new Feedback.ConfirmationHandler() {
                        @Override
                        public void onConfirmation(boolean isConfirmed) {
                            if (isConfirmed)
                                presenter.onDeleteAddressDetails(form.getEditedEntity());
                        }
                    });

        }
    });

    tableTools.addToolButtonRight(removeBtn);

    VerticalPanel formPanel = new VerticalPanel();
    formPanel.addStyleName("fill-layout-width");

    formPanel.add(helpPanel.asWidget());
    formPanel.add(formTools.asWidget());
    formPanel.add(form.asWidget());

    serverName = new ContentHeaderLabel();

    MultipleToOneLayout layout = new MultipleToOneLayout().setPlain(true).setHeadlineWidget(serverName)
            .setDescription(
                    "An address setting defines some attributes that are defined against an address wildcard rather than a specific queue.")
            .setMaster("TODO", addrTable).setMasterTools(tableTools.asWidget()).setDetail("Details", formPanel);

    return layout.build();

}

From source file:org.jboss.as.console.client.shared.subsys.messaging.SecurityDetails.java

License:Open Source License

Widget asWidget() {

    secTable = new DefaultCellTable<SecurityPattern>(8, new ProvidesKey<SecurityPattern>() {
        @Override//from www.j a va  2s  .c  o m
        public Object getKey(SecurityPattern item) {
            return item.getPattern() + "_" + item.getRole();
        }
    });
    secProvider = new ListDataProvider<SecurityPattern>();
    secProvider.addDataDisplay(secTable);

    Column<SecurityPattern, String> roleColumn = new Column<SecurityPattern, String>(new TextCell()) {
        @Override
        public String getValue(SecurityPattern object) {
            return object.getRole();
        }
    };

    Column<SecurityPattern, String> patternColumn = new Column<SecurityPattern, String>(new TextCell()) {
        @Override
        public String getValue(SecurityPattern object) {
            return object.getPattern();
        }
    };

    secTable.addColumn(patternColumn, "Pattern");
    secTable.addColumn(roleColumn, "Role");

    // ---

    form = new Form<SecurityPattern>(SecurityPattern.class);
    form.setNumColumns(2);
    form.bind(secTable);

    CheckBoxItem send = new CheckBoxItem("send", "Send?");
    CheckBoxItem consume = new CheckBoxItem("consume", "Consume?");
    CheckBoxItem manage = new CheckBoxItem("manage", "Manage?");

    CheckBoxItem createDQ = new CheckBoxItem("createDurableQueue", "CreateDurable?");
    CheckBoxItem deleteDQ = new CheckBoxItem("deleteDurableQueue", "DeleteDurable?");

    CheckBoxItem createNDQ = new CheckBoxItem("createNonDurableQueue", "CreateNonDurable?");
    CheckBoxItem deleteNDQ = new CheckBoxItem("deleteNonDurableQueue", "DeleteNonDurable?");

    form.setFields(send, consume, manage);
    form.setFieldsInGroup(Console.CONSTANTS.common_label_advanced(), new DisclosureGroupRenderer(), createDQ,
            deleteDQ, createNDQ, deleteNDQ);

    FormHelpPanel helpPanel = new FormHelpPanel(new FormHelpPanel.AddressCallback() {
        @Override
        public ModelNode getAddress() {
            ModelNode address = Baseadress.get();
            address.add("subsystem", "messaging");
            address.add("hornetq-server", "*");
            address.add("security-setting", "*");
            address.add("role", "*");
            return address;
        }
    }, form);

    FormToolStrip<SecurityPattern> formTools = new FormToolStrip<SecurityPattern>(form,
            new FormToolStrip.FormCallback<SecurityPattern>() {
                @Override
                public void onSave(Map<String, Object> changeset) {
                    presenter.onSaveSecDetails(form.getEditedEntity(), changeset);
                }

                @Override
                public void onDelete(SecurityPattern entity) {

                }
            });

    ToolStrip tableTools = new ToolStrip();

    ToolButton addBtn = new ToolButton(Console.CONSTANTS.common_label_add(), new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            presenter.launchNewSecDialogue();
        }
    });
    addBtn.ensureDebugId(Console.DEBUG_CONSTANTS.debug_label_add_securityDetails());
    tableTools.addToolButtonRight(addBtn);

    ToolButton removeBtn = new ToolButton(Console.CONSTANTS.common_label_delete(), new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {

            Feedback.confirm(Console.MESSAGES.deleteTitle("Security Config"),
                    Console.MESSAGES.deleteConfirm("Security Config"), new Feedback.ConfirmationHandler() {
                        @Override
                        public void onConfirmation(boolean isConfirmed) {
                            if (isConfirmed)
                                presenter.onDeleteSecDetails(form.getEditedEntity());
                        }
                    });

        }
    });

    tableTools.addToolButtonRight(removeBtn);

    //  ----

    VerticalPanel formPanel = new VerticalPanel();
    formPanel.addStyleName("fill-layout-width");

    formPanel.add(helpPanel.asWidget());
    formPanel.add(formTools.asWidget());
    formPanel.add(form.asWidget());

    serverName = new ContentHeaderLabel();

    MultipleToOneLayout layout = new MultipleToOneLayout().setPlain(true).setHeadlineWidget(serverName)
            .setDescription(
                    "A security setting allows sets of permissions to be defined against queues based on their address.")
            .setMaster("Available security settings", secTable).setMasterTools(tableTools.asWidget())
            .setDetail("Details", formPanel);

    return layout.build();
}

From source file:org.jboss.as.console.client.shared.subsys.osgi.runtime.BundleRuntimeView.java

License:Open Source License

@Override
protected DefaultCellTable<OSGiBundle> makeEntityTable() {
    bundleTable = new DefaultCellTable<OSGiBundle>(8);
    sortHandler = new MyListHandler<OSGiBundle>();

    TextColumn<OSGiBundle> idColumn = new TextColumn<OSGiBundle>() {
        @Override/*  ww  w . ja  v  a  2  s. co m*/
        public String getValue(OSGiBundle record) {
            return record.getName();
        }
    };
    idColumn.setSortable(true);
    sortHandler.setComparator(idColumn, new Comparator<OSGiBundle>() {
        @Override
        public int compare(OSGiBundle o1, OSGiBundle o2) {
            return new Long(o1.getName()).compareTo(new Long(o2.getName()));
        }
    });
    bundleTable.addColumn(idColumn, Console.CONSTANTS.subsys_osgi_bundleID());

    TextColumn<OSGiBundle> symbolicNameColumn = new TextColumn<OSGiBundle>() {
        @Override
        public String getValue(OSGiBundle record) {
            return record.getSymbolicName();
        }
    };
    symbolicNameColumn.setSortable(true);
    sortHandler.setComparator(symbolicNameColumn, new Comparator<OSGiBundle>() {
        @Override
        public int compare(OSGiBundle o1, OSGiBundle o2) {
            return o1.getSymbolicName().compareTo(o2.getSymbolicName());
        }
    });
    bundleTable.addColumn(symbolicNameColumn, Console.CONSTANTS.subsys_osgi_bundleSymbolicName());

    TextColumn<OSGiBundle> versionColumn = new TextColumn<OSGiBundle>() {
        @Override
        public String getValue(OSGiBundle record) {
            return record.getVersion();
        }
    };
    bundleTable.addColumn(versionColumn, Console.CONSTANTS.subsys_osgi_bundleVersion());

    Column<OSGiBundle, ImageResource> stateColumn = new Column<OSGiBundle, ImageResource>(
            new ImageResourceCell()) {
        @Override
        public ImageResource getValue(OSGiBundle bundle) {
            if ("ACTIVE".equals(bundle.getState()))
                return Icons.INSTANCE.status_good();
            if ("STARTING".equals(bundle.getState()))
                return Icons.INSTANCE.status_warn();
            if ("RESOLVED".equals(bundle.getState()))
                return Icons.INSTANCE.status_none();

            // default
            return Icons.INSTANCE.status_none();
        }
    };
    stateColumn.setSortable(true);
    sortHandler.setComparator(stateColumn, new Comparator<OSGiBundle>() {
        @Override
        public int compare(OSGiBundle o1, OSGiBundle o2) {
            List<String> order = Arrays.asList("RESOLVED", "STARTING", "ACTIVE");
            Integer i1 = order.indexOf(o1.getState());
            Integer i2 = order.indexOf(o2.getState());

            return i1.compareTo(i2);
        }
    });
    bundleTable.addColumn(stateColumn, Console.CONSTANTS.subsys_osgi_bundleState());

    class BundleColumn extends Column<OSGiBundle, OSGiBundle> {
        public BundleColumn(Cell<OSGiBundle> cell) {
            super(cell);
        }

        @Override
        public OSGiBundle getValue(OSGiBundle record) {
            return record;
        }
    }
    ;
    TextLinkCell<OSGiBundle> startCell = new TextLinkCell<OSGiBundle>(
            Console.CONSTANTS.common_label_start() + "&nbsp;&nbsp;", new ActionCell.Delegate<OSGiBundle>() {
                @Override
                public void execute(OSGiBundle bundle) {
                    if ("fragment".equals(bundle.getType())) {
                        Feedback.alert(Console.CONSTANTS.subsys_osgi(),
                                Console.MESSAGES.subsys_osgi_cant_start_fragment(bundle.getSymbolicName()));
                    } else {
                        presenter.startBundle(bundle);
                    }
                }
            });

    final TextLinkCell<OSGiBundle> stopCell = new TextLinkCell<OSGiBundle>(
            Console.CONSTANTS.common_label_stop(), new ActionCell.Delegate<OSGiBundle>() {
                @Override
                public void execute(OSGiBundle bundle) {
                    if ("fragment".equals(bundle.getType())) {
                        Feedback.alert(Console.CONSTANTS.subsys_osgi(),
                                Console.MESSAGES.subsys_osgi_cant_stop_fragment(bundle.getSymbolicName()));
                    } else {
                        presenter.stopBundle(bundle);
                    }
                }
            });
    List<HasCell<OSGiBundle, OSGiBundle>> buttonCells = new ArrayList<HasCell<OSGiBundle, OSGiBundle>>();
    buttonCells.add(new BundleColumn(startCell));
    buttonCells.add(new BundleColumn(stopCell));
    BundleColumn myColumn = new BundleColumn(new CompositeCell(buttonCells));

    bundleTable.addColumn(myColumn, Console.CONSTANTS.common_label_action());

    bundleTable.addColumnSortHandler(sortHandler);
    bundleTable.getColumnSortList().push(idColumn); // initial sort is on bundle ID

    return bundleTable;
}

From source file:org.jboss.as.console.client.shared.subsys.security.AbstractDomainDetailEditor.java

License:Open Source License

Widget asWidget() {

    VerticalPanel vpanel = new VerticalPanel();
    vpanel.setStyleName("rhs-content-panel");

    // TODO: in order for the selection to retain we need a distinct key per module.

    // attributesTable = new DefaultCellTable<T>(4, getKeyProvider());
    attributesTable = new DefaultCellTable<T>(4);

    attributesTable.getElement().setAttribute("style", "margin-top:5px;");
    attributesProvider = new ListDataProvider<T>();
    attributesProvider.addDataDisplay(attributesTable);

    headerLabel = new ContentHeaderLabel("TITLE HERE");
    vpanel.add(headerLabel);/* w ww.ja  v a2s .c  om*/
    vpanel.add(new ContentDescription(description));

    vpanel.add(new ContentGroupLabel(getStackName()));

    ToolStrip tableTools = new ToolStrip();

    addModule = new ToolButton(Console.CONSTANTS.common_label_add());
    addModule.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            openWizard(null);
        }
    });
    addModule.ensureDebugId(Console.DEBUG_CONSTANTS.debug_label_add_abstractDomainDetailEditor());
    tableTools.addToolButtonRight(addModule);
    tableTools.addToolButtonRight(new ToolButton(Console.CONSTANTS.common_label_remove(), new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {

            final T policy = getCurrentSelection();
            Feedback.confirm(Console.MESSAGES.deleteTitle(getEntityName()),
                    Console.MESSAGES.deleteConfirm(policy.getCode()), new Feedback.ConfirmationHandler() {
                        @Override
                        public void onConfirmation(boolean isConfirmed) {
                            if (isConfirmed) {
                                attributesProvider.getList().remove(policy);
                                if (attributesProvider.getList().size() > 0) {
                                    saveData();
                                }
                                // call remove() on last provider-module instead of save()
                                else {
                                    removeData();
                                }
                            }
                        }
                    });
        }
    }));
    vpanel.add(tableTools);

    // -------

    Column<T, String> codeColumn = new Column<T, String>(new TextCell()) {
        @Override
        public String getValue(T record) {
            return record.getCode();
        }
    };
    attributesTable.addColumn(codeColumn, Console.CONSTANTS.subsys_security_codeField());

    addCustomColumns(attributesTable);

    List<HasCell<T, T>> actionCells = new ArrayList<HasCell<T, T>>();
    IdentityColumn<T> actionColumn = new IdentityColumn<T>(new CompositeCell(actionCells));
    attributesTable.addColumn(actionColumn, "");

    vpanel.add(attributesTable);

    // -------

    DefaultPager pager = new DefaultPager();
    pager.setDisplay(attributesTable);
    vpanel.add(pager);

    // -------

    propertyEditor = new PropertyEditor(this, true);
    propertyEditor.setHideButtons(false);

    final SingleSelectionModel<T> ssm = new SingleSelectionModel<T>();
    ssm.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            T policy = ssm.getSelectedObject();
            if (policy == null) // Can this actually happen?
            {
                return;
            }

            List<PropertyRecord> props = policy.getProperties();
            if (props == null) {
                props = new ArrayList<PropertyRecord>();
                policy.setProperties(props);
            }

            propertyEditor.setProperties("", policy.getProperties());

            wizard.edit(policy);

        }
    });
    attributesTable.setSelectionModel(ssm);

    wizard = getWizard();

    TabPanel bottomTabs = new TabPanel();
    bottomTabs.setStyleName("default-tabpanel");
    bottomTabs.add(wizard.asWidget(), "Attributes");
    bottomTabs.add(propertyEditor.asWidget(), "Module Options");

    propertyEditor.setAllowEditProps(false);

    vpanel.add(new ContentGroupLabel("Details"));

    vpanel.add(bottomTabs);
    bottomTabs.selectTab(0);

    // -------

    ScrollPanel scroll = new ScrollPanel(vpanel);

    LayoutPanel layout = new LayoutPanel();
    layout.add(scroll);
    layout.setWidgetTopHeight(scroll, 0, Style.Unit.PX, 100, Style.Unit.PCT);

    return layout;
}

From source file:org.jboss.as.console.client.shared.subsys.security.AuthEditor.java

License:Open Source License

@Override
void addCustomColumns(DefaultCellTable<T> table) {
    Column<T, String> flagColumn = new Column<T, String>(new TextCell()) {
        @Override/*from w w  w  .  j av a 2s. c o m*/
        public String getValue(T record) {
            return record.getFlag();
        }
    };
    table.addColumn(flagColumn, Console.CONSTANTS.subsys_security_flagField());
}

From source file:org.jboss.as.console.client.shared.subsys.security.MappingEditor.java

License:Open Source License

@Override
void addCustomColumns(DefaultCellTable<MappingModule> table) {
    Column<MappingModule, String> typeColumn = new Column<MappingModule, String>(new TextCell()) {
        @Override/* w ww.  ja va 2 s . co  m*/
        public String getValue(MappingModule record) {
            return record.getType();
        }
    };
    table.addColumn(typeColumn, Console.CONSTANTS.subsys_security_flagField());
}

From source file:org.jboss.as.console.client.shared.subsys.security.SecurityDomainsView.java

License:Open Source License

@Override
protected DefaultCellTable<SecurityDomain> makeEntityTable() {
    table = new DefaultCellTable<SecurityDomain>(5);

    Column<SecurityDomain, SecurityDomain> option = new Column<SecurityDomain, SecurityDomain>(
            new ViewLinkCell<SecurityDomain>(Console.CONSTANTS.common_label_view() + "&nbsp;",
                    new ActionCell.Delegate<SecurityDomain>() {
                        @Override
                        public void execute(SecurityDomain selection) {
                            presenter.getPlaceManager()
                                    .revealPlace(new PlaceRequest(NameTokens.SecurityDomainsPresenter)
                                            .with("name", selection.getName()));
                        }//from ww  w  . ja v  a  2  s  . c om
                    })) {
        @Override
        public SecurityDomain getValue(SecurityDomain domain) {
            return domain;
        }
    };

    table.addColumn(new Columns.NameColumn(), Columns.NameColumn.LABEL);
    table.addColumn(option, "Option");

    return table;
}