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

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

Introduction

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

Prototype

public void add(Widget w, String tabText, boolean asHTML) 

Source Link

Document

Adds a widget to the tab panel.

Usage

From source file:org.apache.luke.client.LukeInspector.java

License:Apache License

public void onModuleLoad() {
    final RootPanel rootPanel = RootPanel.get();

    CaptionPanel cptnpnlNewPanel = new CaptionPanel("New panel");
    cptnpnlNewPanel.setCaptionHTML("Luke version 5.0");
    rootPanel.add(cptnpnlNewPanel, 10, 10);
    cptnpnlNewPanel.setSize("959px", "652px");

    TabPanel tabPanel = new TabPanel();
    cptnpnlNewPanel.setContentWidget(tabPanel);
    tabPanel.setSize("5cm", "636px");

    //LuceneIndexLoader.loadIndex(pName, this);

    SplitLayoutPanel splitLayoutPanel = new SplitLayoutPanel();
    tabPanel.add(splitLayoutPanel, "Index overview", false);
    tabPanel.setVisible(true);/*from   w  ww.  j a va 2 s  .  c  o m*/
    splitLayoutPanel.setSize("652px", "590px");

    SplitLayoutPanel splitLayoutPanel_1 = new SplitLayoutPanel();
    splitLayoutPanel.addNorth(splitLayoutPanel_1, 288.0);

    Label lblIndexStatistics = new Label("Index statistics");
    lblIndexStatistics.setDirectionEstimator(true);
    lblIndexStatistics.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    splitLayoutPanel_1.addNorth(lblIndexStatistics, 26.0);

    VerticalPanel verticalPanel = new VerticalPanel();
    splitLayoutPanel_1.addWest(verticalPanel, 125.0);

    Label lblTest = new Label("Index name:");
    verticalPanel.add(lblTest);
    lblTest.setWidth("109px");

    Label lblTest_1 = new Label("# fields:");
    verticalPanel.add(lblTest_1);

    Label lblNumber = new Label("# documents:");
    verticalPanel.add(lblNumber);
    lblNumber.setWidth("101px");

    Label lblTerms = new Label("# terms:");
    verticalPanel.add(lblTerms);

    Label lblHasDeletions = new Label("Has deletions?");
    verticalPanel.add(lblHasDeletions);

    Label lblNewLabel = new Label("Optimised?");
    verticalPanel.add(lblNewLabel);

    Label lblIndexVersion = new Label("Index version:");
    verticalPanel.add(lblIndexVersion);

    SplitLayoutPanel splitLayoutPanel_2 = new SplitLayoutPanel();
    splitLayoutPanel.addWest(splitLayoutPanel_2, 240.0);

    // Create name column.
    TextColumn<Field> nameColumn = new TextColumn<Field>() {
        @Override
        public String getValue(Field field) {
            return field.getName();
        }
    };

    // Make the name column sortable.
    nameColumn.setSortable(true);

    // Create termCount column.
    TextColumn<Field> termCountColumn = new TextColumn<Field>() {
        @Override
        public String getValue(Field contact) {
            return contact.getTermCount();
        }
    };

    // Create decoder column.
    TextColumn<Field> decoderColumn = new TextColumn<Field>() {
        @Override
        public String getValue(Field contact) {
            return contact.getDecoder();
        }
    };

    final CellTable<Field> cellTable = new CellTable<Field>();

    cellTable.addColumn(nameColumn, "Name");
    cellTable.addColumn(termCountColumn, "Term count");
    cellTable.addColumn(decoderColumn, "Decoder");

    cellTable.setRowCount(FieldsDummyData.Fields.size(), true);
    // Set the range to display. In this case, our visible range is smaller than
    // the data set.
    cellTable.setVisibleRange(0, 3);

    // Create a data provider.
    AsyncDataProvider<Field> dataProvider = new AsyncDataProvider<Field>() {
        @Override
        protected void onRangeChanged(HasData<Field> display) {
            final Range range = display.getVisibleRange();

            // Get the ColumnSortInfo from the table.
            final ColumnSortList sortList = cellTable.getColumnSortList();

            // This timer is here to illustrate the asynchronous nature of this data
            // provider. In practice, you would use an asynchronous RPC call to
            // request data in the specified range.
            new Timer() {
                @Override
                public void run() {
                    int start = range.getStart();
                    int end = start + range.getLength();
                    // This sorting code is here so the example works. In practice, you
                    // would sort on the server.
                    Collections.sort(FieldsDummyData.Fields, new Comparator<Field>() {
                        public int compare(Field o1, Field o2) {
                            if (o1 == o2) {
                                return 0;
                            }

                            // Compare the name columns.
                            int diff = -1;
                            if (o1 != null) {
                                diff = (o2 != null) ? o1.getName().compareTo(o2.getName()) : 1;
                            }
                            return sortList.get(0).isAscending() ? diff : -diff;
                        }
                    });
                    List<Field> dataInRange = FieldsDummyData.Fields.subList(start, end);

                    // Push the data back into the list.
                    cellTable.setRowData(start, dataInRange);
                }
            }.schedule(2000);
        }
    };

    // Connect the list to the data provider.
    dataProvider.addDataDisplay(cellTable);

    // Add a ColumnSortEvent.AsyncHandler to connect sorting to the
    // AsyncDataPRrovider.
    AsyncHandler columnSortHandler = new AsyncHandler(cellTable);
    cellTable.addColumnSortHandler(columnSortHandler);

    // We know that the data is sorted alphabetically by default.
    cellTable.getColumnSortList().push(nameColumn);

    splitLayoutPanel_2.add(cellTable);

    SplitLayoutPanel splitLayoutPanel_3 = new SplitLayoutPanel();
    splitLayoutPanel.addEast(splitLayoutPanel_3, 215.0);

    StackPanel stackPanel = new StackPanel();
    rootPanel.add(stackPanel, 714, 184);
    stackPanel.setSize("259px", "239px");

    FlowPanel flowPanel = new FlowPanel();
    stackPanel.add(flowPanel, "Open index", false);
    flowPanel.setSize("100%", "100%");

    TextBox textBox = new TextBox();
    flowPanel.add(textBox);

    Button btnNewButton = new Button("...");
    btnNewButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            DirectoryLister directoryLister = new DirectoryLister();
            directoryLister.setPopupPosition(rootPanel.getAbsoluteLeft() + rootPanel.getOffsetWidth() / 2,
                    rootPanel.getAbsoluteTop() + rootPanel.getOffsetHeight() / 2);
            directoryLister.show();

        }
    });
    flowPanel.add(btnNewButton);

    // exception handling
    // credits: http://code.google.com/p/mgwt/source/browse/src/main/java/com/googlecode/mgwt/examples/showcase/client/ShowCaseEntryPoint.java?repo=showcase
    GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {

        @Override
        public void onUncaughtException(Throwable e) {
            Window.alert("uncaught: " + e.getMessage());
            String s = buildStackTrace(e, "RuntimeExceotion:\n");
            Window.alert(s);
            e.printStackTrace();

        }
    });

}

From source file:org.drools.brms.client.ruleeditor.EditorLauncher.java

License:Apache License

/**
 * This will actually show the viewer once everything is loaded and ready.
 * @param openedViewers/*from ww  w. j a v  a  2s.  c  o m*/
 * @param tab
 * @param uuid
 * @param readonly
 * @param asset
 */
private static void openRuleViewer(final Map openedViewers, final TabPanel tab, final String uuid,
        final boolean readonly, RuleAsset asset) {
    final RuleViewer view = new RuleViewer(asset, readonly);

    String displayName = asset.metaData.name;
    if (displayName.length() > 10) {
        displayName = displayName.substring(0, 7) + "...";
    }
    String icon = getAssetFormatIcon(asset.metaData.format);

    tab.add(view, "<img src='images/" + icon + "'>" + displayName, true);

    if (openedViewers != Collections.EMPTY_MAP) {
        openedViewers.put(uuid, view);
    }

    view.setCloseCommand(new Command() {
        public void execute() {
            tab.remove(tab.getWidgetIndex(view));
            tab.selectTab(0);
            if (openedViewers != Collections.EMPTY_MAP) {
                openedViewers.remove(uuid);
            }

        }
    });
    tab.selectTab(tab.getWidgetIndex(view));
}

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);
        }/*from www  .j  a  v a  2 s  . c  o  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:parceirosDaEstrada.web.client.ParceirosDaEstrada.java

License:Open Source License

public LayoutPanel carregaPainelCaronas() throws Exception {
    LayoutPanel painelDeCaronas = new LayoutPanel();
    painelDeCaronas.setSize("590px", "490px");
    final List<Carona> CONTACTS = SistemaWebMain.getSistema().localizarCarona("", "");

    DateCell dateCell = new DateCell();

    TabPanel tabPanel = new TabPanel();
    tabPanel.setSize("586px", "485px");
    CellTable<Carona> table = new CellTable<Carona>();
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);

    final SingleSelectionModel<Carona> selectionModel = new SingleSelectionModel<Carona>();
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        public void onSelectionChange(SelectionChangeEvent event) {
            Carona selected = selectionModel.getSelectedObject();
            if (selected != null) {
                Window.alert(selected.toString() + "\n  Cadastre agora mesmo e solicite uma vaga!");
            }/*ww w .jav  a2 s.co  m*/
        }
    });
    TextColumn<Carona> nameColumn = new TextColumn<Carona>() {
        @Override
        public String getValue(Carona object) {
            return object.getOrigem();
        }
    };
    table.addColumn(nameColumn, "Origem");
    Column<Carona, Date> dateColumn = new Column<Carona, Date>(dateCell) {
        @SuppressWarnings("deprecation")
        @Override
        public Date getValue(Carona object) {
            String[] data = object.getData().split("/");
            return new Date(Integer.parseInt(data[2]) - 1900, Integer.parseInt(data[1]) - 1,
                    Integer.parseInt(data[0]));

        }
    };
    table.addColumn(dateColumn, "Data");

    TextColumn<Carona> addressColumn = new TextColumn<Carona>() {
        @Override
        public String getValue(Carona object) {
            return object.getDestino();
        }
    };
    table.addColumn(addressColumn, "Destino");
    table.setSelectionModel(selectionModel);

    tabPanel.add(table, "Proximas Caronas", false);
    table.setRowCount(CONTACTS.size(), true);
    table.setRowData(0, CONTACTS);
    table.setSize("572px", "446px");

    tabPanel.add((new PainelOProjeto()).carregaPainel(), "O Projeto", false);
    tabPanel.selectTab(0);
    painelDeCaronas.add(tabPanel);
    return painelDeCaronas;
}