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

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

Introduction

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

Prototype

public void add(Widget w, @IsSafeHtml String stackText, boolean asHTML) 

Source Link

Document

Adds a new child with the given widget and header, optionally interpreting the header as HTML.

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);/*  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.packages.PackageExplorerWidget.java

License:Apache License

/**
 * Load up the package config data and display it.
 *//*from  w  w w. ja  v a  2  s .  co  m*/
private void loadPackageConfig(String uuid) {

    LoadingPopup.showMessage("Loading package information ...");

    RepositoryServiceFactory.getService().loadPackageConfig(uuid, new GenericCallback() {

        public void onSuccess(Object data) {
            final PackageConfigData conf = (PackageConfigData) data;

            StackPanel sp = new StackPanel();
            currentlySelectedPackage = conf.name;

            FormStyleLayout infoLayout = new FormStyleLayout("images/package_large.png", conf.name);
            infoLayout.setStyleName("package-Editor");
            infoLayout.setWidth("100%");
            infoLayout.addAttribute("Description:", new Label(conf.description));
            infoLayout.addAttribute("Date created:", new Label(conf.dateCreated.toLocaleString()));

            if (conf.isSnapshot) {
                infoLayout.addAttribute("Snapshot created on:", new Label(conf.lastModified.toLocaleString()));
                infoLayout.addAttribute("Snapshot comment:", new Label(conf.checkinComment));
                final String uri = PackageBuilderWidget.getDownloadLink(conf);
                // Button download = new Button("Download package");
                // download.addClickListener( new ClickListener() {
                // public void onClick(Widget arg0) {
                // Window.open( uri, "downloading...",
                // "resizable=no,scrollbars=yes,status=no" );
                // }
                // });

                HTML html = new HTML("<a href='" + uri + "' target='_blank'>Download binary package</a>");
                infoLayout.addAttribute("Download package:", html);
                infoLayout.addAttribute("Package URI:", new Label(uri));
                Button viewSource = new Button("View package source");
                viewSource.addClickListener(new ClickListener() {
                    public void onClick(Widget w) {
                        PackageBuilderWidget.doBuildSource(conf.uuid, conf.name);
                    }
                });
                infoLayout.addAttribute("Show package source:", viewSource);
            }

            if (!conf.isSnapshot) {
                infoLayout.addRow(new HTML("<i>Choose one of the options below</i>"));
            }

            Command makeDirtyCommand = new Command() {
                public void execute() {
                    makeDirty();
                }

            };

            Command cleanDirtyCommand = new Command() {
                public void execute() {
                    resetDirty();
                }

            };

            sp.add(infoLayout, "<img src='images/information.gif'/>Info", true);
            if (!conf.isSnapshot) {
                sp.add(new PackageEditor(conf, makeDirtyCommand, cleanDirtyCommand, refreshCommand),
                        "<img src='images/package.gif'/>Edit Package configuration", true);
                sp.add(new PackageBuilderWidget(conf, editEvent),
                        "<img src='images/package_build.gif'/>Build, validate and deploy", true);
            } else {
                sp.add(new PackageEditor(conf, makeDirtyCommand, cleanDirtyCommand, refreshCommand),
                        "<img src='images/package.gif'/>View Package configuration", true);

            }
            sp.setWidth("100%");
            layout.setWidget(0, 1, sp);
            LoadingPopup.close();
        }
    });

}