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

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

Introduction

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

Prototype

public void selectTab(int index) 

Source Link

Document

Programmatically selects the specified tab and fires events.

Usage

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. ja  v a2  s.c om
        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   w  ww .ja  va 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("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);/*from  w w  w. j a  v  a  2s  .c  o  m*/

    // 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;
}

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  w  w .j  a  v  a2 s .  c o  m*/
    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.web.WebSubsystemView.java

License:Open Source License

@Override
public Widget createWidget() {

    LayoutPanel layout = new RHSContentPanel("Servlet");

    layout.add(new ContentHeaderLabel("Servlet/HTTP Configuration"));
    layout.add(new ContentDescription(Console.CONSTANTS.subsys_web_desc()));
    // ----/*from w w w . j  a  v a 2s . co  m*/

    form = new Form(JSPContainerConfiguration.class);
    form.setNumColumns(2);

    FormToolStrip toolStrip = new FormToolStrip<JSPContainerConfiguration>(form,
            new FormToolStrip.FormCallback<JSPContainerConfiguration>() {
                @Override
                public void onSave(Map<String, Object> changeset) {
                    presenter.onSaveJSPConfig(changeset);
                }

                @Override
                public void onDelete(JSPContainerConfiguration entity) {

                }
            });

    toolStrip.providesDeleteOp(false);
    layout.add(toolStrip.asWidget());

    // ----

    CheckBoxItem disabled = new CheckBoxItem("disabled", "Disabled?");
    CheckBoxItem development = new CheckBoxItem("development", "Development?");
    TextBoxItem instanceId = new TextBoxItem("instanceId", "Instance ID", false);

    CheckBoxItem keepGenerated = new CheckBoxItem("keepGenerated", "Keep Generated?");
    NumberBoxItem checkInterval = new NumberBoxItem("checkInterval", "Check Interval");
    CheckBoxItem sourceFragment = new CheckBoxItem("displaySource", "Display Source?");

    form.setFields(disabled, development, instanceId);
    form.setFieldsInGroup(Console.CONSTANTS.common_label_advanced(), new DisclosureGroupRenderer(),
            keepGenerated, checkInterval, sourceFragment);

    FormHelpPanel helpPanel = new FormHelpPanel(new FormHelpPanel.AddressCallback() {
        @Override
        public ModelNode getAddress() {
            ModelNode address = Baseadress.get();
            address.add("subsystem", "web");
            address.add("configuration", "jsp-configuration");
            return address;
        }
    }, form);

    layout.add(helpPanel.asWidget());

    layout.add(form.asWidget());
    form.setEnabled(false); // TODO:

    // ----

    TabPanel bottomLayout = new TabPanel();
    bottomLayout.addStyleName("default-tabpanel");
    bottomLayout.getElement().setAttribute("style", "padding-top:20px;");

    connectorList = new ConnectorList(presenter);
    bottomLayout.add(connectorList.asWidget(), "Connectors");

    serverList = new VirtualServerList(presenter);
    bottomLayout.add(serverList.asWidget(), "Virtual Servers");

    bottomLayout.selectTab(0);

    layout.add(bottomLayout);

    return layout;
}

From source file:org.jboss.bpm.console.client.process.InstanceDetailView.java

License:Open Source License

private void createDiagramWindow(ProcessInstanceRef inst) {

    ScrollPanel layout = new ScrollPanel();
    layout.setStyleName("bpm-window-layout");

    Label header = new Label("Instance: " + inst.getId());
    header.setStyleName("bpm-label-header");
    layout.add(header);//from ww  w  . j a  v  a 2s  . c  o  m

    final TabPanel tabPanel = new TabPanel();

    HorizontalPanel diaViewLayout = new HorizontalPanel();
    diaViewLayout.add(diagramView);

    tabPanel.add(diagramView, "View");

    processEvents = new CustomizableListBox<String>(new CustomizableListBox.ItemFormatter<String>() {
        public String format(String item) {
            return new HTML(item).getHTML();
        }
    });

    processEvents.setFirstLine("Process Events");

    VerticalPanel sourcePanel = new VerticalPanel();
    sourcePanel.add(processEvents);
    tabPanel.add(sourcePanel, "Source");

    tabPanel.selectTab(0);

    layout.add(tabPanel);

    diagramWindowPanel = new WidgetWindowPanel("Process Instance Activity", layout, true);

    controller.handleEvent(new Event(GetProcessInstanceEventsAction.ID, inst.getId()));
}

From source file:org.jboss.gwt.circuit.sample.todo.client.App.java

License:Open Source License

@AfterInitialization
public void init() {
    resources.css().ensureInjected();/*from   w w w  .  j a  v  a 2s .c  o m*/
    dispatcher.addDiagnostics(diagnosticsView);

    DockLayoutPanel layout = new DockLayoutPanel(Style.Unit.PX);
    layout.getElement().setAttribute("style", "width:100%; height:100%");

    TabPanel tabs = new TabPanel();
    tabs.getElement().setId("app-container");
    tabs.getElement().setAttribute("style", "margin:30px;width:100%; height:100%");

    tabs.add(todoView, "Todo List");
    tabs.add(userView, "User Management");

    tabs.selectTab(0);

    layout.addSouth(diagnosticsView, 50);
    layout.add(tabs);

    RootPanel.get().add(layout);

    // application init
    dispatcher.dispatch(new LoadUsers());
    dispatcher.dispatch(new ListTodos());
}

From source file:org.metawidget.gwt.client.ui.layout.TabPanelLayoutDecorator.java

License:LGPL

@Override
protected Panel createSectionWidget(Panel previousSectionWidget, String section, Map<String, String> attributes,
        Panel container, GwtMetawidget metawidget) {

    // Whole new tab panel?

    TabPanel tabPanel;

    if (previousSectionWidget == null) {
        tabPanel = new TabPanel();

        // Add to parent container

        Map<String, String> tabPanelAttributes = new HashMap<String, String>();
        tabPanelAttributes.put(LABEL, "");
        tabPanelAttributes.put(LARGE, TRUE);
        getDelegate().layoutWidget(tabPanel, PROPERTY, tabPanelAttributes, container, metawidget);
    } else {//from w  w  w  .jav  a  2  s  . c  o m
        tabPanel = (TabPanel) previousSectionWidget.getParent().getParent().getParent();
    }

    // New tab

    final Panel newPanel = new FlowPanel();

    // Section name (possibly localized)

    String localizedSection = metawidget.getLocalizedKey(StringUtils.camelCase(section));

    if (localizedSection == null) {
        localizedSection = section;
    }

    tabPanel.add(newPanel, localizedSection);

    if (previousSectionWidget == null) {
        tabPanel.selectTab(0);
    }

    return newPanel;
}

From source file:org.quartz.GWTQuartzManager.client.QuartzManager.java

License:Open Source License

public void onModuleLoad() {
    //catch exception
    GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
        public void onUncaughtException(Throwable e) {
            log.log(Level.SEVERE, e.getMessage(), e);
        }//w ww.j  a  v  a 2s  . co  m
    });
    Logger.getLogger("").addHandler(new ErrorDialog().getHandler());

    eventBus.addHandler(TriggerJobEvent.TYPE, new TriggerJobEvent.Handler() {
        @Override
        public void fireTrigger(GWTJobDetail jobDetail) {
            scheduler.triggerJob(jobDetail.getKey(), new GWTQuartzScheduler.nopAsynCallback<Void>());
        }
    });

    eventBus.addHandler(DeleteJobEvent.TYPE, new DeleteJobEvent.Handler() {

        @Override
        public void deleteJob(GWTJobDetail jobDetail) {
            scheduler.deleteJob(jobDetail.getKey(), new AsyncCallback<Boolean>() {

                @Override
                public void onFailure(Throwable caught) {
                    // TODO Auto-generated method stub

                }

                @Override
                public void onSuccess(Boolean result) {
                    updateJobs();
                }
            });
        }
    });

    eventBus.addHandler(EditTriggerEvent.TYPE, new EditTriggerEvent.Handler() {

        @Override
        public void startEdit(GWTTrigger trigger) {
            //TODO in the future, there may be some subclasses of GWTTrigger other than WGTCronTrigger.
            //do instanceof check
            EditCronTriggerWorkflow newTriggerWorkflow = new EditCronTriggerWorkflow(scheduler);
            newTriggerWorkflow.edit((GWTCronTrigger) trigger);
        }
    });

    eventBus.addHandler(ToggleTriggerStateEvent.TYPE, new ToggleTriggerStateEvent.Handler() {

        @Override
        public void resume(GWTTrigger trigger) {
            scheduler.resumeTrigger(trigger.getKey(), new GWTQuartzScheduler.nopAsynCallback<Void>());
        }

        @Override
        public void pause(GWTTrigger trigger) {
            scheduler.pauseTrigger(trigger.getKey(), new GWTQuartzScheduler.nopAsynCallback<Void>());
        }
    });

    eventBus.addHandler(EditJobEvent.TYPE, new EditJobEvent.Handler() {

        @Override
        public void editJob(GWTJobDetail jobDetail, boolean create) {
            new EditJobDetailWorkflow(scheduler, create).edit(jobDetail);
        }
    });

    RootPanel rootPanel = RootPanel.get();
    rootPanel.setSize("100%", "100%");

    DockPanel dockPanel = new DockPanel();
    rootPanel.add(dockPanel);
    dockPanel.setSize("", "100%");

    SimplePanel simplePanel = new SimplePanel();
    simplePanel.add(new SchedulerAdminButtonsWidget(scheduler));
    dockPanel.add(simplePanel, DockPanel.NORTH);

    SimplePanel simplePanel_1 = new SimplePanel();
    dockPanel.add(simplePanel_1, DockPanel.EAST);
    dockPanel.setCellWidth(simplePanel_1, "20%");
    simplePanel_1.setWidth("");

    executedJobsTable = new CellTable<GWTQuartzJobExecutionContext>();
    simplePanel_1.setWidget(executedJobsTable);
    executedJobsTable.setSize("100%", "100%");
    executedJobsTable.setTableLayoutFixed(false);

    TextColumn<GWTQuartzJobExecutionContext> ejJobName = new TextColumn<GWTQuartzJobExecutionContext>() {
        @Override
        public String getValue(GWTQuartzJobExecutionContext object) {
            return object.getJobKey().getName();
        }
    };
    executedJobsTable.addColumn(ejJobName, "job name");

    TextColumn<GWTQuartzJobExecutionContext> ejTriggerName = new TextColumn<GWTQuartzJobExecutionContext>() {
        @Override
        public String getValue(GWTQuartzJobExecutionContext object) {
            return object.getTriggerKey().getName();
        }
    };
    executedJobsTable.addColumn(ejTriggerName, "trigger name");

    Column<GWTQuartzJobExecutionContext, Number> ejRunTime = new Column<GWTQuartzJobExecutionContext, Number>(
            new NumberCell()) {
        @Override
        public Number getValue(GWTQuartzJobExecutionContext object) {
            return new Long(object.getJobRunTime());
        }
    };
    executedJobsTable.addColumn(ejRunTime, "run time");
    jobExecuationContextsProvider.addDataDisplay(executedJobsTable);

    final TabPanel tabPanel = new TabPanel();
    dockPanel.add(tabPanel, DockPanel.CENTER);
    dockPanel.setCellHeight(tabPanel, "100%");
    tabPanel.setSize("100%", "100%");
    VerticalPanel verticalPanel = new VerticalPanel();
    tabPanel.add(verticalPanel, "Jobs", false);
    verticalPanel.setSize("100%", "100%");
    tabPanel.selectTab(0);

    HorizontalPanel horizontalPanel_1 = new HorizontalPanel();
    verticalPanel.add(horizontalPanel_1);
    verticalPanel.setCellHeight(horizontalPanel_1, "22");
    verticalPanel.setCellWidth(horizontalPanel_1, "100%");

    Label lblNewLabel = new Label("Job Group");
    horizontalPanel_1.add(lblNewLabel);
    lblNewLabel.setWidth("67px");

    cbGroupName = new ListBox();
    horizontalPanel_1.add(cbGroupName);

    cbGroupName.addItem(ALL_GROUPS);
    cbGroupName.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            updateJobs();
        }
    });

    final SimplePanel jobPanel = new SimplePanel();
    verticalPanel.add(jobPanel);
    verticalPanel.setCellHeight(jobPanel, "100%");
    verticalPanel.setCellWidth(jobPanel, "100%");
    jobPanel.setSize("100%", "");
    jobPanel.setStyleName("boxed");
    final JobsTable jobsTable = new JobsTable(jobsProvider, eventBus);
    jobPanel.add(jobsTable);
    jobsTable.setSize("100%", "397px");

    VerticalPanel verticalPanel_1 = new VerticalPanel();
    tabPanel.add(verticalPanel_1, "triggers", false);
    verticalPanel_1.setSize("100%", "100%");

    HorizontalPanel horizontalPanel_2 = new HorizontalPanel();
    verticalPanel_1.add(horizontalPanel_2);
    verticalPanel_1.setCellWidth(horizontalPanel_2, "100%");
    verticalPanel_1.setCellHeight(horizontalPanel_2, "22");

    Label lblGroup = new Label("Trigger Group");
    horizontalPanel_2.add(lblGroup);

    cbTriggerGroup = new ListBox();
    cbTriggerGroup.addItem(ALL_GROUPS);
    cbTriggerGroup.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            updateTriggers();
        }
    });

    horizontalPanel_2.add(cbTriggerGroup);

    Button btnPauseAll = new Button("Pause All");
    btnPauseAll.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            scheduler.pauseAll(new AsyncCallback<Void>() {

                @Override
                public void onFailure(Throwable caught) {
                    // TODO Auto-generated method stub

                }

                @Override
                public void onSuccess(Void result) {
                    // TODO Auto-generated method stub

                }
            });
        }
    });
    horizontalPanel_2.add(btnPauseAll);
    horizontalPanel_2.setCellHorizontalAlignment(btnPauseAll, HasHorizontalAlignment.ALIGN_RIGHT);

    Button btnResumeAll = new Button("Resume All");
    btnResumeAll.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            scheduler.resumeAll(new AsyncCallback<Void>() {

                @Override
                public void onFailure(Throwable caught) {
                    // TODO Auto-generated method stub

                }

                @Override
                public void onSuccess(Void result) {
                    // TODO Auto-generated method stub

                }
            });
        }
    });
    horizontalPanel_2.add(btnResumeAll);

    Button btnPauseGroup = new Button("Pause Group");
    btnPauseGroup.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            String selectedGroup = cbTriggerGroup.getItemText(cbTriggerGroup.getSelectedIndex());
            scheduler.pauseTriggers(selectedGroup, new AsyncCallback<Void>() {

                @Override
                public void onFailure(Throwable caught) {
                    // TODO Auto-generated method stub

                }

                @Override
                public void onSuccess(Void result) {
                    // TODO Auto-generated method stub

                }
            });
        }
    });
    horizontalPanel_2.add(btnPauseGroup);

    Button btnResumeGroup = new Button("Resume Group");
    btnResumeGroup.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            String selectedGroup = cbTriggerGroup.getItemText(cbTriggerGroup.getSelectedIndex());
            scheduler.resumeTriggers(selectedGroup, new AsyncCallback<Void>() {

                @Override
                public void onFailure(Throwable caught) {
                    // TODO Auto-generated method stub

                }

                @Override
                public void onSuccess(Void result) {
                    // TODO Auto-generated method stub

                }
            });
        }
    });
    horizontalPanel_2.add(btnResumeGroup);

    SimplePanel triggerPanel = new SimplePanel();
    verticalPanel_1.add(triggerPanel);
    triggerPanel.setSize("100%", "390px");
    TriggersTable triggersTable = new TriggersTable(eventBus, triggersProvider);
    triggerPanel.add(triggersTable);
    triggersTable.setSize("100%", "100%");

    scheduler.getJobGroupNames(new AsyncCallback<ArrayList<String>>() {

        @Override
        public void onSuccess(ArrayList<String> result) {
            for (String name : result) {
                cbGroupName.addItem(name);
            }
            updateJobs();
        }

        @Override
        public void onFailure(Throwable caught) {
            // TODO Auto-generated method stub

        }
    });

    //polling jobs, triggers and job executions status
    new com.google.gwt.user.client.Timer() {
        @Override
        public void run() {

            updateJobs();

            updateTriggers();

            updateJobExecutionContexts();
            this.schedule(2000);
        }
    }.schedule(2000);

    scheduler.getTriggerGroupNames(new AsyncCallback<List<String>>() {

        @Override
        public void onFailure(Throwable caught) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onSuccess(List<String> result) {
            for (String group : result) {
                cbTriggerGroup.addItem(group);
            }
            updateTriggers();
        }
    });

    //update trigger group combo box

}

From source file:org.sonar.plugins.core.ui.pageselector.client.PageSelector.java

License:Open Source License

private void displayResource(final Resource resource) {
    List<PageDef> pages = selectPages(resource);

    PageDef selectedPage = selectPage(pages);

    Title title = new Title(resource);
    final TabPanel tabs = new TabPanel();
    tabs.setWidth("100%");

    int selectedTabIndex = -1;
    for (int tabIndex = 0; tabIndex < pages.size(); tabIndex++) {
        PageDef page = pages.get(tabIndex);
        tabs.add(new PagePanel(page), page.getName());
        if (page == selectedPage) {
            selectedTabIndex = tabIndex;
        }// w  w  w.java 2s.  c  o  m
    }

    container.clear(); // remove the loading icon
    container.add(title);
    container.add(tabs);

    tabs.addSelectionHandler(new SelectionHandler<Integer>() {
        public void onSelection(SelectionEvent<Integer> tabId) {
            ((PagePanel) tabs.getWidget(tabId.getSelectedItem())).display();
        }
    });

    if (selectedTabIndex > -1) {
        tabs.selectTab(selectedTabIndex);
    }
}