Example usage for com.google.gwt.user.client.ui TabPanel TabPanel

List of usage examples for com.google.gwt.user.client.ui TabPanel TabPanel

Introduction

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

Prototype

public TabPanel() 

Source Link

Document

Creates an empty tab panel.

Usage

From source file:org.jboss.as.console.client.shared.deployment.DeploymentStep1.java

License:Open Source License

public Widget asWidget() {

    final TabPanel tabs = new TabPanel();
    tabs.setStyleName("default-tabpanel");

    // -------/*www. j av  a  2 s . c om*/

    VerticalPanel layout = new VerticalPanel();
    layout.setStyleName("window-content");

    // Create a FormPanel and point it at a service.
    final FormPanel form = new FormPanel();
    String url = Console.getBootstrapContext().getProperty(BootstrapContext.DEPLOYMENT_API);
    form.setAction(url);

    form.setEncoding(FormPanel.ENCODING_MULTIPART);
    form.setMethod(FormPanel.METHOD_POST);

    // Create a panel to hold all of the form widgets.
    VerticalPanel panel = new VerticalPanel();
    panel.getElement().setAttribute("style", "width:100%");
    form.setWidget(panel);

    // Create a FileUpload widget.
    final FileUpload upload = new FileUpload();
    upload.setName("uploadFormElement");
    panel.add(upload);

    final HTML errorMessages = new HTML("Please chose a file!");
    errorMessages.setStyleName("error-panel");
    errorMessages.setVisible(false);
    panel.add(errorMessages);

    // Add a 'submit' button.

    ClickHandler cancelHandler = new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            window.hide();
        }
    };

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

            errorMessages.setVisible(false);

            // verify form
            String filename = upload.getFilename();

            if (tabs.getTabBar().getSelectedTab() == 1) {
                // unmanaged content
                if (unmanagedForm.validate().hasErrors()) {
                    return;
                } else {
                    wizard.onCreateUnmanaged(unmanagedForm.getUpdatedEntity());
                }
            } else if (filename != null && !filename.equals("")) {
                loading = Feedback.loading(Console.CONSTANTS.common_label_plaseWait(),
                        Console.CONSTANTS.common_label_requestProcessed(), new Feedback.LoadingCallback() {
                            @Override
                            public void onCancel() {

                            }
                        });
                form.submit();
            } else {
                errorMessages.setVisible(true);
            }
        }
    };

    DialogueOptions options = new DialogueOptions(Console.CONSTANTS.common_label_next(), submitHandler,
            Console.CONSTANTS.common_label_cancel(), cancelHandler);

    // Add an event handler to the form.
    form.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {
        @Override
        public void onSubmitComplete(FormPanel.SubmitCompleteEvent event) {

            getLoading().hide();

            String html = event.getResults();

            // Step 1: upload content, retrieve hash value
            try {

                String json = html;

                try {
                    if (!GWT.isScript()) // TODO: Formpanel weirdness
                        json = html.substring(html.indexOf(">") + 1, html.lastIndexOf("<"));
                } catch (StringIndexOutOfBoundsException e) {
                    // if I get this exception it means I shouldn't strip out the html
                    // this issue still needs more research
                    Log.debug("Failed to strip out HTML.  This should be preferred?");
                }

                JSONObject response = JSONParser.parseLenient(json).isObject();
                JSONObject result = response.get("result").isObject();
                String hash = result.get("BYTES_VALUE").isString().stringValue();
                // step2: assign name and group
                wizard.onUploadComplete(upload.getFilename(), hash);

            } catch (Exception e) {
                Log.error(Console.CONSTANTS.common_error_failedToDecode() + ": " + html, e);
            }

            // Option 2: Unmanaged content

        }
    });

    String stepText = "<h3>" + Console.CONSTANTS.common_label_step() + "1/2: "
            + Console.CONSTANTS.common_label_deploymentSelection() + "</h3>";
    layout.add(new HTML(stepText));
    HTML description = new HTML();
    description.setHTML(Console.CONSTANTS.common_label_chooseFile());
    description.getElement().setAttribute("style", "padding-bottom:15px;");
    layout.add(description);
    layout.add(form);

    // Unmanaged form
    VerticalPanel unmanagedPanel = new VerticalPanel();
    unmanagedPanel.setStyleName("window-content");

    String unmanagedText = "<h3>" + Console.CONSTANTS.common_label_step() + "1/1: Specify Deployment</h3>";
    unmanagedPanel.add(new HTML(unmanagedText));

    unmanagedForm = new Form<DeploymentRecord>(DeploymentRecord.class);
    TextAreaItem path = new TextAreaItem("path", "Path");
    TextBoxItem relativeTo = new TextBoxItem("relativeTo", "Relative To", false);

    TextBoxItem name = new TextBoxItem("name", "Name");
    TextBoxItem runtimeName = new TextBoxItem("runtimeName", "Runtime Name");
    CheckBoxItem archive = new CheckBoxItem("archive", "Is Archive?");
    archive.setValue(true);
    unmanagedForm.setFields(path, relativeTo, archive, name, runtimeName);
    unmanagedPanel.add(unmanagedForm.asWidget());

    // Composite view

    tabs.add(layout, "Managed");
    tabs.add(unmanagedPanel, "Unmanaged");
    tabs.selectTab(0);

    return new WindowContentBuilder(tabs, options).build();
}

From source file:org.jboss.as.console.client.shared.subsys.activemq.CoreQueueEditor.java

License:Open Source License

public Widget asWidget() {
    LayoutPanel layout = new LayoutPanel();

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

    ScrollPanel scroll = new ScrollPanel(panel);
    layout.add(scroll);//from   www  .  j a v a 2  s .  c  o m
    layout.setWidgetTopHeight(scroll, 0, Style.Unit.PX, 100, Style.Unit.PCT);

    serverName = new HTML("Replace me");
    serverName.setStyleName("content-header-label");

    panel.add(serverName);
    panel.add(new ContentDescription("Configuration for core queues."));

    TabPanel bottomLayout = new TabPanel();
    bottomLayout.addStyleName("default-tabpanel");
    bottomLayout.addStyleName("master_detail-detail");

    queueList = new CoreQueueList(presenter);
    bottomLayout.add(queueList.asWidget(), "Queues");

    bottomLayout.selectTab(0);

    panel.add(bottomLayout);

    return layout;
}

From source file:org.jboss.as.console.client.shared.subsys.activemq.JMSEditor.java

License:Open Source License

public Widget asWidget() {
    LayoutPanel layout = new LayoutPanel();

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

    ScrollPanel scroll = new ScrollPanel(panel);
    layout.add(scroll);//from  w w  w .  j a v  a2  s.  c o m
    layout.setWidgetTopHeight(scroll, 0, Style.Unit.PX, 100, Style.Unit.PCT);

    serverName = new HTML("Replace me");
    serverName.setStyleName("content-header-label");

    panel.add(serverName);
    panel.add(new ContentDescription("Configuration for JMS queues and topics."));

    TabPanel bottomLayout = new TabPanel();
    bottomLayout.addStyleName("default-tabpanel");
    bottomLayout.addStyleName("master_detail-detail");

    queueList = new JMSQueueList(presenter);
    bottomLayout.add(queueList.asWidget(), "Queues");

    topicList = new JMSTopicList(presenter);
    bottomLayout.add(topicList.asWidget(), "Topics");

    bottomLayout.selectTab(0);

    panel.add(bottomLayout);

    return layout;
}

From source file:org.jboss.as.console.client.shared.subsys.ejb3.ServicesView.java

License:Open Source License

@Override
public Widget createWidget() {

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

    vpanel.add(new ContentHeaderLabel(Console.CONSTANTS.subsys_ejb3_ejbServices()));
    vpanel.add(new ContentDescription(Console.CONSTANTS.subsys_ejb3_services_desc()));

    TabPanel bottomPanel = new TabPanel();
    bottomPanel.setStyleName("default-tabpanel");

    bottomPanel.add(timerServiceView.asWidget(), timerServiceView.getEntityDisplayName());
    bottomPanel.add(asyncServiceView.asWidget(), asyncServiceView.getEntityDisplayName());
    bottomPanel.add(remoteServiceView.asWidget(), remoteServiceView.getEntityDisplayName());
    bottomPanel.selectTab(0);//from  www  .j  a  va2s . c  o  m

    vpanel.add(bottomPanel);

    return new ScrollPanel(vpanel);
}

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

License:Open Source License

public Widget asWidget() {

    LayoutPanel layout = new LayoutPanel();

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

        @Override//from  w  ww.  ja  va 2s. c o  m
        public void onClick(ClickEvent event) {
            presenter.launchNewDatasourceWizard();
        }
    }));

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

            final DataSource currentSelection = details.getCurrentSelection();
            if (currentSelection != null) {
                Feedback.confirm(Console.MESSAGES.deleteTitle("Datasource"),
                        Console.MESSAGES.deleteConfirm("Datasource " + currentSelection.getName()),
                        new Feedback.ConfirmationHandler() {
                            @Override
                            public void onConfirmation(boolean isConfirmed) {
                                if (isConfirmed) {
                                    presenter.onDelete(currentSelection);
                                }
                            }
                        });
            }
        }
    };
    ToolButton deleteBtn = new ToolButton(Console.CONSTANTS.common_label_delete());
    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 Datasources"));
    vpanel.add(new ContentDescription(Console.CONSTANTS.subsys_jca_dataSources_desc()));

    dataSourceTable = new DatasourceTable();

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

    // -----------
    details = new DataSourceDetails(presenter);
    details.bind(dataSourceTable.getCellTable());

    SingleSelectionModel<DataSource> selectionModel = (SingleSelectionModel<DataSource>) dataSourceTable
            .getCellTable().getSelectionModel();

    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            DataSource selectedObject = ((SingleSelectionModel<DataSource>) dataSourceTable.getCellTable()
                    .getSelectionModel()).getSelectedObject();
            presenter.loadPoolConfig(false, selectedObject.getName());
            presenter.onLoadConnectionProperties(selectedObject.getName());

        }
    });

    // -----------------

    TabPanel bottomPanel = new TabPanel();
    bottomPanel.setStyleName("default-tabpanel");

    bottomPanel.add(details.asWidget(), "Attributes");

    // -----------------

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

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

    connectionEditor = new DataSourceConnectionEditor(presenter, formCallback);
    connectionEditor.getForm().bind(dataSourceTable.getCellTable());
    bottomPanel.add(connectionEditor.asWidget(), "Connection");

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

    // -----------------

    connectionProps = new ConnectionProperties(presenter);
    bottomPanel.add(connectionProps.asWidget(), "Properties");

    // -----------------

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

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

        @Override
        public void onDoFlush(String editedName) {
            if (getCurrentSelection().isEnabled())
                presenter.onDoFlush(false, editedName);
            else
                Console.error(Console.CONSTANTS.subsys_jca_error_datasource_notenabled());
        }
    });

    bottomPanel.add(poolConfig.asWidget(), "Pool");
    poolConfig.getForm().bind(dataSourceTable.getCellTable());

    // ----

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

    bottomPanel.selectTab(0);

    // -----------------

    vpanel.add(new ContentGroupLabel(Console.CONSTANTS.common_label_selection()));

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

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

    disableBtn = new ToolButton(Console.CONSTANTS.common_label_enOrDisable(), disableHandler);
    disableBtn.ensureDebugId(Console.DEBUG_CONSTANTS.debug_label_enOrDisable_dataSourceDetails());

    // -----
    // handle modifications to the model

    dataSourceTable.getCellTable().getSelectionModel()
            .addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
                @Override
                public void onSelectionChange(SelectionChangeEvent event) {
                    String nextState = getCurrentSelection().isEnabled()
                            ? Console.CONSTANTS.common_label_disable()
                            : Console.CONSTANTS.common_label_enable();
                    disableBtn.setText(nextState);
                }
            });

    topLevelTools.addToolButtonRight(disableBtn);

    // --

    vpanel.add(bottomPanel);

    return layout;
}

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

License:Open Source License

Widget asWidget() {
    VerticalPanel layout = new VerticalPanel();
    layout.getElement().setAttribute("style", "margin:10px; vertical-align:center;width:95%");

    HTML desc = new HTML("<h3>" + Console.CONSTANTS.subsys_jca_dataSource_step2() + "</h3>");
    desc.getElement().setAttribute("style", "padding-bottom:10px;");

    layout.add(desc);//from w w  w  .j a v  a 2s .co  m
    layout.add(new ContentDescription("Select one of the deployed JDBC driver."));

    // ---

    table = new DefaultCellTable<JDBCDriver>(5);

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

    TextColumn<JDBCDriver> groupColumn = new TextColumn<JDBCDriver>() {
        @Override
        public String getValue(JDBCDriver record) {
            return record.getGroup();
        }
    };

    table.addColumn(nameColumn, "Name");

    if (!isStandalone)
        table.addColumn(groupColumn, "Server Group");

    selectionModel = new SingleSelectionModel<JDBCDriver>();
    table.setSelectionModel(selectionModel);

    provisionTable(table);

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

    VerticalPanel driverPanel = new VerticalPanel();
    driverPanel.add(table);
    driverPanel.add(pager);

    // --

    final Form<JDBCDriver> form = new Form<JDBCDriver>(JDBCDriver.class);
    TextBoxItem name = new TextBoxItem("name", "Name");
    TextBoxItem driverClass = new TextBoxItem("driverClass", "Driver Class");
    NumberBoxItem major = new NumberBoxItem("majorVersion", "Major Version");
    NumberBoxItem minor = new NumberBoxItem("minorVersion", "Minor Version");

    form.setFields(name, driverClass, major, minor);

    // --

    TabPanel tabs = new TabPanel();
    tabs.setStyleName("default-tabpanel");
    tabs.addSelectionHandler(new SelectionHandler<Integer>() {
        @Override
        public void onSelection(SelectionEvent<Integer> event) {
            selectedTab = event.getSelectedItem();
        }
    });

    tabs.add(driverPanel, "Chose Driver");
    //tabs.add(form.asWidget(), "Specify Driver");

    layout.add(tabs);
    tabs.selectTab(0);

    // ----

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

            JDBCDriver driver = null;

            if (selectedTab == 0) {
                // reset state
                form.clearValues();

                SingleSelectionModel<JDBCDriver> selection = (SingleSelectionModel<JDBCDriver>) table
                        .getSelectionModel();
                driver = selection.getSelectedObject();
            } else {
                FormValidation formValidation = form.validate();
                if (!formValidation.hasErrors()) {
                    driver = form.getUpdatedEntity();
                }
            }

            if (driver != null) { // force selected driver
                editedEntity.setDriverName(driver.getName());
                editedEntity.setDriverClass(driver.getDriverClass());
                editedEntity.setMajorVersion(driver.getMajorVersion());
                editedEntity.setMinorVersion(driver.getMinorVersion());

                wizard.onConfigureDriver(editedEntity);
            } else {
                Console.warning(Console.CONSTANTS.subsys_jca_dataSource_select_driver(),
                        "If no driver is available you may need to deploy one!");
            }

        }
    };

    ClickHandler cancelHandler = new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            wizard.getPresenter().closeDialogue();
        }
    };

    DialogueOptions options = new DialogueOptions(Console.CONSTANTS.common_label_next(), submitHandler,
            Console.CONSTANTS.common_label_cancel(), cancelHandler);

    return new WindowContentBuilder(layout, options).build();
}

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

License:Open Source License

@Override
@SuppressWarnings("unchecked")
protected Widget asWidget(final Context<T> context) {
    // first tab: driver form
    form = new Form<>(JDBCDriver.class);
    TextBoxItem driverName = new TextBoxItem("name", "Name", true);
    TextBoxItem moduleName = new TextBoxItem("driverModuleName", "Module Name", true);
    TextBoxItem driverClass = new TextBoxItem("driverClass", "Driver Class", false);
    TextBoxItem xaDataSource = new TextBoxItem("xaDataSourceClass", "XA DataSource Class", false);
    if (context.xa) {
        form.setFields(driverName, moduleName, driverClass, xaDataSource);
    } else {/*from   w ww  .j  a  v a2  s . com*/
        form.setFields(driverName, moduleName, driverClass);
    }

    FlowPanel formPanel = new FlowPanel();
    formPanel.add(new FormHelpPanel(context.jdbcDriverHelp, form).asWidget());
    formPanel.add(form);

    // second tab: existing drivers
    table = new DefaultCellTable<>(5);
    TextColumn<JDBCDriver> nameColumn = new TextColumn<JDBCDriver>() {
        @Override
        public String getValue(JDBCDriver record) {
            return record.getName();
        }
    };
    TextColumn<JDBCDriver> moduleColumn = new TextColumn<JDBCDriver>() {
        @Override
        public String getValue(JDBCDriver record) {
            return record.getDriverModuleName();
        }
    };
    table.addColumn(nameColumn, "Name");
    if (!context.standalone) {
        table.addColumn(moduleColumn, "Module");
    }
    selectionModel = new SingleSelectionModel<>();
    table.setSelectionModel(selectionModel);
    provisionTable(table);

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

    FlowPanel driverPanel = new FlowPanel();
    driverPanel.add(table);
    driverPanel.add(pager);

    // tabs
    TabPanel tabs = new TabPanel();
    tabs.setStyleName("default-tabpanel");
    tabs.addSelectionHandler(event -> selectedTab = event.getSelectedItem());
    tabs.add(formPanel, "Specify Driver");
    tabs.add(driverPanel, "Detected Driver");

    // body
    FlowPanel body = new FlowPanel();
    body.add(new ContentDescription(
            "Select one of the installed JDBC drivers. If you do not see your driver, make sure that it is deployed as a module and properly registered."));
    body.add(tabs);
    tabs.selectTab(0);

    return body;
}

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/*from  w  w  w.  j a  v a  2s.  c o 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.JMSEditor.java

License:Open Source License

public Widget asWidget() {

    LayoutPanel layout = new LayoutPanel();

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

    ScrollPanel scroll = new ScrollPanel(panel);
    layout.add(scroll);//from  ww  w  .j a  v  a 2  s.  c  om

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

    // ---

    serverName = new HTML("Replace me");
    serverName.setStyleName("content-header-label");

    panel.add(serverName);
    panel.add(new ContentDescription("Queue and Topic destinations."));

    // ----

    TabPanel bottomLayout = new TabPanel();
    bottomLayout.addStyleName("default-tabpanel");

    queueList = new QueueList(presenter);
    bottomLayout.add(queueList.asWidget(), "Queues");

    topicList = new TopicList(presenter);
    bottomLayout.add(topicList.asWidget(), "Topics");

    bottomLayout.selectTab(0);

    panel.add(bottomLayout);

    return layout;
}

From source file:org.jboss.as.console.client.shared.subsys.osgi.config.FrameworkEditor.java

License:Open Source License

Widget asWidget() {
    LayoutPanel layout = new LayoutPanel();
    ScrollPanel scroll = new ScrollPanel();
    VerticalPanel vpanel = new VerticalPanel();
    vpanel.setStyleName("rhs-content-panel");
    scroll.add(vpanel);//w w  w  .ja v  a2s  . c om

    // Add an empty toolstrip to make this panel look similar to others
    ToolStrip toolStrip = new ToolStrip();
    layout.add(toolStrip);

    vpanel.add(new ContentHeaderLabel(Console.CONSTANTS.subsys_osgi_frameworkHeader()));
    vpanel.add(new ContentGroupLabel(Console.CONSTANTS.common_label_settings()));

    form = new Form<OSGiSubsystem>(OSGiSubsystem.class);
    form.setNumColumns(1);

    CheckBoxItem activationMode = new CheckBoxItem("lazyActivation",
            Console.CONSTANTS.common_label_lazyActivation());
    activationMode.asWidget().addHandler(new ValueChangeHandler<Boolean>() {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            presenter.onActivationChange(event.getValue());
        }
    }, ValueChangeEvent.getType());
    form.setFields(activationMode);
    vpanel.add(form.asWidget());

    vpanel.add(new ContentGroupLabel(Console.CONSTANTS.subsys_osgi_frameworkConfiguration()));
    TabPanel bottomPanel = new TabPanel();
    bottomPanel.setStyleName("default-tabpanel");

    propertiesTable = new FrameworkPropertiesTable(presenter);
    bottomPanel.add(propertiesTable.asWidget(), Console.CONSTANTS.subsys_osgi_properties());

    VerticalPanel panel = new VerticalPanel();
    addCapabilities(panel);
    bottomPanel.add(panel, Console.CONSTANTS.subsys_osgi_capabilities());

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

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

    return layout;
}