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

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

Introduction

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

Prototype

@Override
    public void add(Widget w) 

Source Link

Usage

From source file:com.google.appinventor.client.editor.blocks.BlocklyPanel.java

License:Open Source License

/**
 * Create a Dialog Box. We call this from Javascript (blockly) to
 * display a dialog box.  We do this here because we can get calls
 * from the blocklyframe when it is not visible.  Because we are in
 * the parent window, we can display dialogs that will be visible
 * even when the blocklyframe is not visible.
 *
 * @param title      Title for the Dialog Box
 * @param mess       The message to display
 * @param buttonName The string to display in the "OK" button.
 * @param size       0 or 1. 0 makes a smaller box 1 makes a larger box.
 * @param callback   an opague JavaScriptObject that contains the
 *                   callback function provided by the Javascript code.
 * @return The created dialog box./*  w w  w  .  ja va 2  s.  c o m*/
 */

public static DialogBox createDialog(String title, String mess, final String buttonName,
        final String cancelButtonName, int size, final JavaScriptObject callback) {
    final DialogBox dialogBox = new DialogBox();
    dialogBox.setStylePrimaryName("ode-DialogBox");
    dialogBox.setText(title);
    if (size == 0) {
        dialogBox.setHeight("150px");
    } else {
        dialogBox.setHeight("400px");
    }
    dialogBox.setWidth("400px");
    dialogBox.setGlassEnabled(true);
    dialogBox.setAnimationEnabled(true);
    dialogBox.center();
    VerticalPanel DialogBoxContents = new VerticalPanel();
    HTML message = new HTML(mess);
    HorizontalPanel holder = new HorizontalPanel();
    if (buttonName != null) { // If buttonName and cancelButtonName are null
        Button ok = new Button(buttonName); // We won't have any buttons and other
        ok.addClickHandler(new ClickHandler() { // code is needed to dismiss us
            @Override
            public void onClick(ClickEvent event) {
                doCallBack(callback, buttonName);
            }
        });
        holder.add(ok);
    }
    if (cancelButtonName != null) {
        Button cancel = new Button(cancelButtonName);
        cancel.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                doCallBack(callback, cancelButtonName);
            }
        });
        holder.add(cancel);
    }
    DialogBoxContents.add(message);
    DialogBoxContents.add(holder);
    dialogBox.setWidget(DialogBoxContents);
    terminateDrag(); // cancel a drag before showing the modal dialog
    dialogBox.show();
    return dialogBox;
}

From source file:com.google.appinventor.client.editor.simple.palette.SimplePaletteItem.java

License:Open Source License

/**
 * Creates a new palette item./*from  www.  java2 s. c  om*/
 *
 * @param scd  component descriptor for palette item
 * @param dropTargetProvider  provider of targets that palette items can be dropped on
 */
public SimplePaletteItem(SimpleComponentDescriptor scd, DropTargetProvider dropTargetProvider) {
    this.dropTargetProvider = dropTargetProvider;
    this.scd = scd;

    componentPrototype = null;

    // Initialize palette item UI
    HorizontalPanel panel = new HorizontalPanel();
    panel.setStylePrimaryName("ode-SimplePaletteItem");

    Image image = scd.getImage();
    image.setStylePrimaryName("ode-SimplePaletteItem-icon");
    panel.add(image);
    panel.setCellHorizontalAlignment(image, HorizontalPanel.ALIGN_LEFT);
    panel.setCellWidth(image, "30px");

    Label label = new Label(TranslationDesignerPallete.getCorrespondingString(scd.getName()));
    label.setHorizontalAlignment(Label.ALIGN_LEFT);
    label.addStyleName("ode-SimplePaletteItem-caption");
    panel.add(label);

    HorizontalPanel optPanel = new HorizontalPanel();

    ComponentHelpWidget helpImage = new ComponentHelpWidget(scd);
    helpImage.addStyleName("ode-SimplePalleteItem-button");
    optPanel.add(helpImage);
    optPanel.setCellHorizontalAlignment(helpImage, HorizontalPanel.ALIGN_LEFT);

    if (scd.getExternal()) {
        ComponentRemoveWidget deleteImage = new ComponentRemoveWidget(scd);
        deleteImage.addStyleName("ode-SimplePalleteItem-button");
        optPanel.add(deleteImage);
        optPanel.setCellHorizontalAlignment(deleteImage, HorizontalPanel.ALIGN_RIGHT);
    }

    panel.add(optPanel);
    panel.setCellHorizontalAlignment(optPanel, HorizontalPanel.ALIGN_RIGHT);

    panel.setWidth("100%");
    add(panel);
    setWidth("100%");
}

From source file:com.google.appinventor.client.editor.youngandroid.BlocklyPanel.java

License:Open Source License

/**
 * Create a Dialog Box. We call this from Javascript (blockly) to
 * display a dialog box.  We do this here because we can get calls
 * from the blocklyframe when it is not visible.  Because we are in
 * the parent window, we can display dialogs that will be visible
 * even when the blocklyframe is not visible.
 *
 * @param title      Title for the Dialog Box
 * @param mess       The message to display
 * @param buttonName The string to display in the "OK" button.
 * @param size       0 or 1. 0 makes a smaller box 1 makes a larger box.
 * @param callback   an opague JavaScriptObject that contains the
 *                   callback function provided by the Javascript code.
 * @return The created dialog box.//from  w w  w.j a v  a2  s. co m
 */

public static DialogBox createDialog(String title, String mess, final String buttonName,
        final String cancelButtonName, int size, final JavaScriptObject callback) {
    final DialogBox dialogBox = new DialogBox();
    dialogBox.setStylePrimaryName("ode-DialogBox");
    dialogBox.setText(title);
    if (size == 0) {
        dialogBox.setHeight("150px");
    } else {
        dialogBox.setHeight("400px");
    }
    dialogBox.setWidth("400px");
    dialogBox.setGlassEnabled(true);
    dialogBox.setAnimationEnabled(true);
    dialogBox.center();
    VerticalPanel DialogBoxContents = new VerticalPanel();
    HTML message = new HTML(mess);
    message.setStyleName("DialogBox-message");
    HorizontalPanel holder = new HorizontalPanel();
    if (buttonName != null) { // If buttonName and cancelButtonName are null
        Button ok = new Button(buttonName); // We won't have any buttons and other
        ok.addClickListener(new ClickListener() { // code is needed to dismiss us
            public void onClick(Widget sender) {
                doCallBack(callback, buttonName);
            }
        });
        holder.add(ok);
    }
    if (cancelButtonName != null) {
        Button cancel = new Button(cancelButtonName);
        cancel.addClickListener(new ClickListener() {
            public void onClick(Widget sender) {
                doCallBack(callback, cancelButtonName);
            }
        });
        holder.add(cancel);
    }
    DialogBoxContents.add(message);
    DialogBoxContents.add(holder);
    dialogBox.setWidget(DialogBoxContents);
    dialogBox.show();
    return dialogBox;
}

From source file:com.google.appinventor.client.explorer.SourceStructureExplorer.java

License:Open Source License

/**
 * Creates a new source structure explorer.
 *//* w ww. jav  a 2 s  .  co m*/
public SourceStructureExplorer() {
    // Initialize UI elements
    tree = new Tree(Ode.getImageBundle());
    tree.setAnimationEnabled(true);
    tree.addCloseHandler(new CloseHandler<TreeItem>() {
        @Override
        public void onClose(CloseEvent<TreeItem> event) {
            TreeItem treeItem = event.getTarget();
            if (treeItem != null) {
                Object userObject = treeItem.getUserObject();
                if (userObject instanceof SourceStructureExplorerItem) {
                    SourceStructureExplorerItem item = (SourceStructureExplorerItem) userObject;
                    item.onStateChange(false);
                }
            }
        }
    });
    tree.addOpenHandler(new OpenHandler<TreeItem>() {
        @Override
        public void onOpen(OpenEvent<TreeItem> event) {
            TreeItem treeItem = event.getTarget();
            if (treeItem != null) {
                Object userObject = treeItem.getUserObject();
                if (userObject instanceof SourceStructureExplorerItem) {
                    SourceStructureExplorerItem item = (SourceStructureExplorerItem) userObject;
                    item.onStateChange(true);
                }
            }
        }
    });
    tree.addSelectionHandler(new SelectionHandler<TreeItem>() {
        @Override
        public void onSelection(SelectionEvent<TreeItem> event) {
            TreeItem treeItem = event.getSelectedItem();
            if (treeItem != null) {
                Object userObject = treeItem.getUserObject();
                if (userObject instanceof SourceStructureExplorerItem) {
                    SourceStructureExplorerItem item = (SourceStructureExplorerItem) userObject;
                    enableButtons(item);
                    //showBlocks(item);
                    item.onSelected();
                } else {
                    disableButtons();
                    //hideComponent();
                }
            } else {
                disableButtons();
            }
        }
    });
    tree.addKeyDownHandler(new KeyDownHandler() {
        @Override
        public void onKeyDown(KeyDownEvent event) {
            int keyCode = event.getNativeKeyCode();
            if (keyCode == KeyCodes.KEY_DELETE || keyCode == KeyCodes.KEY_BACKSPACE) {
                event.preventDefault();
                deleteItemFromTree();
            }
        }
    });

    // Put a ScrollPanel around the tree.
    ScrollPanel scrollPanel = new ScrollPanel(tree);
    scrollPanel.setWidth("200px"); // wide enough to avoid a horizontal scrollbar most of the time
    scrollPanel.setHeight("480px"); // approximately the same height as the viewer

    HorizontalPanel buttonPanel = new HorizontalPanel();
    buttonPanel.setStyleName("ode-PanelButtons");
    buttonPanel.setSpacing(4);

    renameButton = new TextButton(MESSAGES.renameButton());
    renameButton.setEnabled(false);
    renameButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            TreeItem treeItem = tree.getSelectedItem();
            if (treeItem != null) {
                Object userObject = treeItem.getUserObject();
                if (userObject instanceof SourceStructureExplorerItem) {
                    SourceStructureExplorerItem item = (SourceStructureExplorerItem) userObject;
                    item.rename();
                }
            }
        }
    });
    buttonPanel.add(renameButton);
    buttonPanel.setCellHorizontalAlignment(renameButton, HorizontalPanel.ALIGN_RIGHT);

    deleteButton = new TextButton(MESSAGES.deleteButton());
    deleteButton.setEnabled(false);
    deleteButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            deleteItemFromTree();
        }
    });
    buttonPanel.add(deleteButton);
    buttonPanel.setCellHorizontalAlignment(deleteButton, HorizontalPanel.ALIGN_LEFT);

    VerticalPanel panel = new VerticalPanel();
    panel.add(scrollPanel);
    panel.add(new Label());
    panel.add(buttonPanel);
    panel.setCellHorizontalAlignment(buttonPanel, HorizontalPanel.ALIGN_CENTER);
    initWidget(panel);
}

From source file:com.google.appinventor.client.explorer.youngandroid.GalleryToolbar.java

License:Open Source License

/**
 * Initializes and assembles all commands into buttons in the toolbar.
 *//*from ww w.j  av a2s  .com*/
public GalleryToolbar() {
    allSearchToolbars.add(this);
    HorizontalPanel toolbar = new HorizontalPanel();
    toolbar.setWidth("100%");
    toolbar.setStylePrimaryName("ya-GalleryToolbar");

    FlowPanel searchPanel = new FlowPanel();
    searchText = new TextBox();
    searchText.addStyleName("gallery-search-textarea");
    searchButton = new Button("Search for apps");
    searchButton.addStyleName("search-compontent");
    searchPanel.add(searchText);
    searchPanel.add(searchButton);
    searchPanel.addStyleName("gallery");
    toolbar.add(searchPanel);
    searchButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            GalleryClient.getInstance().FindApps(searchText.getText(), 0, GalleryList.NUMAPPSTOSHOW, 0, true);
            searchText.setFocus(true);
            Ode.getInstance().switchToGalleryView();
            GalleryListBox.getGalleryListBox().getGalleryList().setSelectTabIndex(SEARCHTAB);
            for (GalleryToolbar toolbar : allSearchToolbars) {
                toolbar.getSearchText().setText(searchText.getText());
            }
            //TODO in gallerylist.java --> findapps: create a way to grab keyword from this toolbar
            //this is just a temp solution.
            GalleryListBox.getGalleryListBox().getGalleryList().getSearchText().setText(searchText.getText());
        }
    });
    searchText.addKeyDownHandler(new KeyDownHandler() {
        @Override
        public void onKeyDown(KeyDownEvent e) {
            if (e.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                GalleryClient.getInstance().FindApps(searchText.getText(), 0, GalleryList.NUMAPPSTOSHOW, 0,
                        true);
                searchText.setFocus(true);
                Ode.getInstance().switchToGalleryView();
                GalleryListBox.getGalleryListBox().getGalleryList().setSelectTabIndex(SEARCHTAB);
                for (GalleryToolbar toolbar : allSearchToolbars) {
                    toolbar.getSearchText().setText(searchText.getText());
                }
                //TODO in gallerylist.java --> findapps: create a way to grab keyword from this toolbar
                //this is just a temp solution.
                GalleryListBox.getGalleryListBox().getGalleryList().getSearchText()
                        .setText(searchText.getText());
            }
        }
    });
    initWidget(toolbar);
}

From source file:com.google.appinventor.client.explorer.youngandroid.ProjectList.java

License:Open Source License

/**
 * Adds the header row to the table./*from w w w.  j  a  va 2 s . co m*/
 *
 */
private void setHeaderRow() {
    table.getRowFormatter().setStyleName(0, "ode-ProjectHeaderRow");

    HorizontalPanel nameHeader = new HorizontalPanel();
    final Label nameHeaderLabel = new Label(MESSAGES.projectNameHeader());
    nameHeaderLabel.addStyleName("ode-ProjectHeaderLabel");
    nameHeader.add(nameHeaderLabel);
    nameSortIndicator.addStyleName("ode-ProjectHeaderLabel");
    nameHeader.add(nameSortIndicator);
    table.setWidget(0, 1, nameHeader);

    HorizontalPanel dateCreatedHeader = new HorizontalPanel();
    final Label dateCreatedHeaderLabel = new Label(MESSAGES.projectDateCreatedHeader());
    dateCreatedHeaderLabel.addStyleName("ode-ProjectHeaderLabel");
    dateCreatedHeader.add(dateCreatedHeaderLabel);
    dateCreatedSortIndicator.addStyleName("ode-ProjectHeaderLabel");
    dateCreatedHeader.add(dateCreatedSortIndicator);
    table.setWidget(0, 2, dateCreatedHeader);

    HorizontalPanel dateModifiedHeader = new HorizontalPanel();
    final Label dateModifiedHeaderLabel = new Label(MESSAGES.projectDateModifiedHeader());
    dateModifiedHeaderLabel.addStyleName("ode-ProjectHeaderLabel");
    dateModifiedHeader.add(dateModifiedHeaderLabel);
    dateModifiedSortIndicator.addStyleName("ode-ProjectHeaderLabel");
    dateModifiedHeader.add(dateModifiedSortIndicator);
    table.setWidget(0, 3, dateModifiedHeader);

    HorizontalPanel publishedHeader = new HorizontalPanel();
    final Label publishedHeaderLabel = new Label(MESSAGES.projectPublishedHeader());
    publishedHeaderLabel.addStyleName("ode-ProjectHeaderLabel");
    publishedHeader.add(publishedHeaderLabel);
    publishedSortIndicator.addStyleName("ode-ProjectHeaderLabel");
    publishedHeader.add(publishedSortIndicator);
    table.setWidget(0, 4, publishedHeader);

    MouseDownHandler mouseDownHandler = new MouseDownHandler() {
        @Override
        public void onMouseDown(MouseDownEvent e) {
            SortField clickedSortField;
            if (e.getSource() == nameHeaderLabel || e.getSource() == nameSortIndicator) {
                clickedSortField = SortField.NAME;
            } else if (e.getSource() == dateCreatedHeaderLabel || e.getSource() == dateCreatedSortIndicator) {
                clickedSortField = SortField.DATE_CREATED;
            } else if (e.getSource() == dateModifiedHeaderLabel || e.getSource() == dateModifiedSortIndicator) {
                clickedSortField = SortField.DATE_MODIFIED;
            } else {
                clickedSortField = SortField.PUBLISHED;
            }
            changeSortOrder(clickedSortField);
        }
    };
    nameHeaderLabel.addMouseDownHandler(mouseDownHandler);
    nameSortIndicator.addMouseDownHandler(mouseDownHandler);
    dateCreatedHeaderLabel.addMouseDownHandler(mouseDownHandler);
    dateCreatedSortIndicator.addMouseDownHandler(mouseDownHandler);
    dateModifiedHeaderLabel.addMouseDownHandler(mouseDownHandler);
    dateModifiedSortIndicator.addMouseDownHandler(mouseDownHandler);
    publishedHeaderLabel.addMouseDownHandler(mouseDownHandler);
    publishedSortIndicator.addMouseDownHandler(mouseDownHandler);
}

From source file:com.google.appinventor.client.explorer.youngandroid.ReportList.java

License:Open Source License

/**
 * Creates a new ProjectList//from w  ww. j  a v a2  s .  co  m
 */
public ReportList() {
    galleryClient = GalleryClient.getInstance();
    // Initialize UI
    panel = new VerticalPanel();
    panel.setWidth("100%");

    HorizontalPanel checkBoxPanel = new HorizontalPanel();
    checkBoxPanel.addStyleName("all-reports");
    checkBox = new CheckBox();
    checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            boolean isChecked = event.getValue(); // auto-unbox from Boolean to boolean
            //reset start position
            reportAllRecentCounter = 0;
            reportRecentCounter = 0;
            buttonNext.setVisible(true);
            if (isChecked) {
                initializeAllReports();
            } else {
                initializeReports();
            }
        }
    });
    checkBoxPanel.add(checkBox);
    Label checkBoxText = new Label(MESSAGES.moderationShowResolvedReports());
    checkBoxPanel.add(checkBoxText);
    panel.add(checkBoxPanel);

    selectedGalleryAppReports = new ArrayList<GalleryAppReport>();
    ReportWidgets = new HashMap<GalleryAppReport, ReportWidgets>();

    table = new Grid(1, 9); // The table initially contains just the header row.
    table.addStyleName("ode-ModerationTable");
    table.setWidth("100%");
    table.setCellSpacing(0);

    buttonNext = new Label();
    buttonNext.setText(MESSAGES.galleryMoreReports());

    buttonNext.addClickHandler(new ClickHandler() {
        //  @Override
        public void onClick(ClickEvent event) {
            final OdeAsyncCallback<GalleryReportListResult> callback = new OdeAsyncCallback<GalleryReportListResult>(
                    // failure message
                    MESSAGES.galleryError()) {
                @Override
                public void onSuccess(GalleryReportListResult reportListResult) {
                    List<GalleryAppReport> reportList = reportListResult.getReports();
                    reports.addAll(reportList);
                    for (GalleryAppReport report : reportList) {
                        ReportWidgets.put(report, new ReportWidgets(report));
                    }
                    refreshTable(reportListResult, false);
                }
            };
            if (checkBox.isChecked()) {
                reportAllRecentCounter += NUMREPORTSSHOW;
                Ode.getInstance().getGalleryService().getAllAppReports(reportAllRecentCounter, NUMREPORTSSHOW,
                        callback);
            } else {
                reportRecentCounter += NUMREPORTSSHOW;
                Ode.getInstance().getGalleryService().getRecentReports(reportRecentCounter, NUMREPORTSSHOW,
                        callback);
            }
        }
    });

    setHeaderRow();

    panel.add(table);
    FlowPanel next = new FlowPanel();
    buttonNext.addStyleName("active");
    next.add(buttonNext);
    next.addStyleName("gallery-report-next");
    panel.add(next);
    initWidget(panel);

    initializeReports();

}

From source file:com.google.appinventor.client.explorer.youngandroid.ReportList.java

License:Open Source License

/**
 * Adds the header row to the table.//from  ww w  .  j av a 2  s .c  om
 *
 */
private void setHeaderRow() {
    table.getRowFormatter().setStyleName(0, "ode-ProjectHeaderRow");

    HorizontalPanel reportHeader = new HorizontalPanel();
    final Label reportHeaderLabel = new Label(MESSAGES.moderationReportTextHeader());
    reportHeaderLabel.addStyleName("ode-ProjectHeaderLabel");
    reportHeader.add(reportHeaderLabel);
    table.setWidget(0, 0, reportHeader);

    HorizontalPanel appHeader = new HorizontalPanel();
    final Label appHeaderLabel = new Label(MESSAGES.moderationAppHeader());
    appHeaderLabel.addStyleName("ode-ProjectHeaderLabel");
    appHeader.add(appHeaderLabel);
    table.setWidget(0, 1, appHeader);

    HorizontalPanel dateCreatedHeader = new HorizontalPanel();
    final Label dateCreatedHeaderLabel = new Label(MESSAGES.moderationReportDateCreatedHeader());
    dateCreatedHeaderLabel.addStyleName("ode-ProjectHeaderLabel");
    dateCreatedHeader.add(dateCreatedHeaderLabel);
    table.setWidget(0, 2, dateCreatedHeader);

    HorizontalPanel appAuthorHeader = new HorizontalPanel();
    final Label appAuthorHeaderLabel = new Label(MESSAGES.moderationAppAuthorHeader());
    appAuthorHeaderLabel.addStyleName("ode-ProjectHeaderLabel");
    appAuthorHeader.add(appAuthorHeaderLabel);
    table.setWidget(0, 3, appAuthorHeader);

    HorizontalPanel reporterHeader = new HorizontalPanel();
    final Label reporterHeaderLabel = new Label(MESSAGES.moderationReporterHeader());
    reporterHeaderLabel.addStyleName("ode-ProjectHeaderLabel");
    reporterHeader.add(reporterHeaderLabel);
    table.setWidget(0, 4, reporterHeader);

}

From source file:com.google.appinventor.client.Ode.java

License:Open Source License

private void initializeUi() {
    BlocklyPanel.initUi();//from   www . j  a  v a 2  s .  c  o m

    rpcStatusPopup = new RpcStatusPopup();

    // Register services with RPC status popup
    rpcStatusPopup.register((ExtendedServiceProxy<?>) helpService);
    rpcStatusPopup.register((ExtendedServiceProxy<?>) projectService);
    rpcStatusPopup.register((ExtendedServiceProxy<?>) galleryService);
    rpcStatusPopup.register((ExtendedServiceProxy<?>) userInfoService);

    Window.setTitle(MESSAGES.titleYoungAndroid());
    Window.enableScrolling(true);

    topPanel = new TopPanel();
    statusPanel = new StatusPanel();

    DockPanel mainPanel = new DockPanel();
    mainPanel.add(topPanel, DockPanel.NORTH);

    // Create tab panel for subsequent tabs
    deckPanel = new DeckPanel() {
        @Override
        public final void onBrowserEvent(Event event) {
            switch (event.getTypeInt()) {
            case Event.ONCONTEXTMENU:
                event.preventDefault();
                break;
            }
        }
    };

    deckPanel.setAnimationEnabled(true);
    deckPanel.sinkEvents(Event.ONCONTEXTMENU);
    deckPanel.setStyleName("ode-DeckPanel");

    // Projects tab
    VerticalPanel pVertPanel = new VerticalPanel();
    pVertPanel.setWidth("100%");
    pVertPanel.setSpacing(0);
    HorizontalPanel projectListPanel = new HorizontalPanel();
    projectListPanel.setWidth("100%");
    projectToolbar = new ProjectToolbar();
    projectListPanel.add(ProjectListBox.getProjectListBox());
    pVertPanel.add(projectToolbar);
    pVertPanel.add(projectListPanel);
    projectsTabIndex = deckPanel.getWidgetCount();
    deckPanel.add(pVertPanel);

    // Design tab
    VerticalPanel dVertPanel = new VerticalPanel();
    dVertPanel.setWidth("100%");
    dVertPanel.setHeight("100%");

    // Add the Code Navigation arrow
    //    switchToBlocksButton = new VerticalPanel();
    //    switchToBlocksButton.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE);
    //    switchToBlocksButton.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    //    switchToBlocksButton.setStyleName("ode-NavArrow");
    //    switchToBlocksButton.add(new Image(RIGHT_ARROW_IMAGE_URL));
    //    switchToBlocksButton.setWidth("25px");
    //    switchToBlocksButton.setHeight("100%");

    // Add the Code Navigation arrow
    //    switchToDesignerButton = new VerticalPanel();
    //    switchToDesignerButton.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE);
    //    switchToDesignerButton.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    //    switchToDesignerButton.setStyleName("ode-NavArrow");
    //    switchToDesignerButton.add(new Image(LEFT_ARROW_IMAGE_URL));
    //    switchToDesignerButton.setWidth("25px");
    //    switchToDesignerButton.setHeight("100%");

    designToolbar = new DesignToolbar();
    dVertPanel.add(designToolbar);

    workColumns = new HorizontalPanel();
    workColumns.setWidth("100%");

    //workColumns.add(switchToDesignerButton);

    Box palletebox = PaletteBox.getPaletteBox();
    palletebox.setWidth("222px");
    workColumns.add(palletebox);

    Box viewerbox = ViewerBox.getViewerBox();
    workColumns.add(viewerbox);
    workColumns.setCellWidth(viewerbox, "97%");
    workColumns.setCellHeight(viewerbox, "97%");

    structureAndAssets = new VerticalPanel();
    structureAndAssets.setVerticalAlignment(VerticalPanel.ALIGN_TOP);
    // Only one of the SourceStructureBox and the BlockSelectorBox is visible
    // at any given time, according to whether we are showing the form editor
    // or the blocks editor. They share the same screen real estate.
    structureAndAssets.add(SourceStructureBox.getSourceStructureBox());
    structureAndAssets.add(BlockSelectorBox.getBlockSelectorBox()); // initially not visible
    structureAndAssets.add(AssetListBox.getAssetListBox());
    workColumns.add(structureAndAssets);

    Box propertiesbox = PropertiesBox.getPropertiesBox();
    propertiesbox.setWidth("222px");
    workColumns.add(propertiesbox);
    //switchToBlocksButton.setHeight("650px");
    //workColumns.add(switchToBlocksButton);
    dVertPanel.add(workColumns);
    designTabIndex = deckPanel.getWidgetCount();
    deckPanel.add(dVertPanel);

    // Gallery list tab
    VerticalPanel gVertPanel = new VerticalPanel();
    gVertPanel.setWidth("100%");
    gVertPanel.setSpacing(0);
    galleryListToolbar = new GalleryToolbar();
    gVertPanel.add(galleryListToolbar);
    HorizontalPanel appListPanel = new HorizontalPanel();
    appListPanel.setWidth("100%");
    appListPanel.add(GalleryListBox.getGalleryListBox());

    gVertPanel.add(appListPanel);
    galleryTabIndex = deckPanel.getWidgetCount();
    deckPanel.add(gVertPanel);

    // Gallery app tab
    VerticalPanel aVertPanel = new VerticalPanel();
    aVertPanel.setWidth("100%");
    aVertPanel.setSpacing(0);
    galleryPageToolbar = new GalleryToolbar();
    aVertPanel.add(galleryPageToolbar);
    HorizontalPanel appPanel = new HorizontalPanel();
    appPanel.setWidth("100%");
    appPanel.add(GalleryAppBox.getGalleryAppBox());

    aVertPanel.add(appPanel);
    galleryAppTabIndex = deckPanel.getWidgetCount();
    deckPanel.add(aVertPanel);

    // User Admin Panel
    VerticalPanel uaVertPanel = new VerticalPanel();
    uaVertPanel.setWidth("100%");
    uaVertPanel.setSpacing(0);
    HorizontalPanel adminUserListPanel = new HorizontalPanel();
    adminUserListPanel.setWidth("100%");
    adminUserListPanel.add(AdminUserListBox.getAdminUserListBox());
    uaVertPanel.add(adminUserListPanel);
    userAdminTabIndex = deckPanel.getWidgetCount();
    deckPanel.add(uaVertPanel);

    // KM: DEBUGGING BEGIN
    // User profile tab
    VerticalPanel uVertPanel = new VerticalPanel();
    uVertPanel.setWidth("100%");
    uVertPanel.setSpacing(0);
    HorizontalPanel userProfilePanel = new HorizontalPanel();
    userProfilePanel.setWidth("100%");
    userProfilePanel.add(ProfileBox.getUserProfileBox());

    uVertPanel.add(userProfilePanel);
    userProfileTabIndex = deckPanel.getWidgetCount();
    deckPanel.add(uVertPanel);
    // KM: DEBUGGING END

    // Private User Profile TabPanel
    VerticalPanel ppVertPanel = new VerticalPanel();
    ppVertPanel.setWidth("100%");
    ppVertPanel.setSpacing(0);
    HorizontalPanel privateUserProfileTabPanel = new HorizontalPanel();
    privateUserProfileTabPanel.setWidth("100%");
    privateUserProfileTabPanel.add(PrivateUserProfileTabPanel.getPrivateUserProfileTabPanel());
    ppVertPanel.add(privateUserProfileTabPanel);
    privateUserProfileIndex = deckPanel.getWidgetCount();
    deckPanel.add(ppVertPanel);

    // Moderation Page tab
    VerticalPanel mPVertPanel = new VerticalPanel();
    mPVertPanel.setWidth("100%");
    mPVertPanel.setSpacing(0);
    HorizontalPanel moderationPagePanel = new HorizontalPanel();
    moderationPagePanel.setWidth("100%");

    moderationPagePanel.add(ModerationPageBox.getModerationPageBox());

    mPVertPanel.add(moderationPagePanel);
    moderationPageTabIndex = deckPanel.getWidgetCount();
    deckPanel.add(mPVertPanel);

    // Debugging tab
    if (AppInventorFeatures.hasDebuggingView()) {

        Button dismissButton = new Button(MESSAGES.dismissButton());
        dismissButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                if (currentView == DESIGNER)
                    switchToDesignView();
                else
                    switchToProjectsView();
            }
        });

        ColumnLayout defaultLayout = new ColumnLayout("Default");
        Column column = defaultLayout.addColumn(100);
        column.add(MessagesOutputBox.class, 300, false);
        column.add(OdeLogBox.class, 300, false);
        final WorkAreaPanel debuggingTab = new WorkAreaPanel(new OdeBoxRegistry(), defaultLayout);

        debuggingTab.add(dismissButton);

        debuggingTabIndex = deckPanel.getWidgetCount();
        deckPanel.add(debuggingTab);

        // Hook the window resize event, so that we can adjust the UI.
        Window.addResizeHandler(new ResizeHandler() {
            @Override
            public void onResize(ResizeEvent event) {
                resizeWorkArea(debuggingTab);
            }
        });

        // Call the window resized handler to get the initial sizes setup. Doing this in a deferred
        // command causes it to occur after all widgets' sizes have been computed by the browser.
        DeferredCommand.addCommand(new Command() {
            @Override
            public void execute() {
                resizeWorkArea(debuggingTab);
            }
        });

        resizeWorkArea(debuggingTab);
    }

    // We do not select the designer tab here because at this point there is no current project.
    // Instead, we select the projects tab. If the user has a previously opened project, we will
    // open it and switch to the designer after the user settings are loaded.
    // Remember, the user may not have any projects at all yet.
    // Or, the user may have deleted their previously opened project.
    // ***** THE DESIGNER TAB DOES NOT DISPLAY CORRECTLY IF THERE IS NO CURRENT PROJECT. *****
    deckPanel.showWidget(projectsTabIndex);

    mainPanel.add(deckPanel, DockPanel.CENTER);
    mainPanel.setCellHeight(deckPanel, "100%");
    mainPanel.setCellWidth(deckPanel, "100%");

    //    mainPanel.add(switchToDesignerButton, DockPanel.WEST);
    //    mainPanel.add(switchToBlocksButton, DockPanel.EAST);

    //Commenting out for now to gain more space for the blocks editor
    mainPanel.add(statusPanel, DockPanel.SOUTH);
    mainPanel.setSize("100%", "100%");
    RootPanel.get().add(mainPanel);

    // Add a handler to the RootPanel to keep track of Google Chrome Pinch Zooming and
    // handle relevant bugs. Chrome maps a Pinch Zoom to a MouseWheelEvent with the
    // control key pressed.
    RootPanel.get().addDomHandler(new MouseWheelHandler() {
        @Override
        public void onMouseWheel(MouseWheelEvent event) {
            if (event.isControlKeyDown()) {
                // Trip the appropriate flag in PZAwarePositionCallback when the page
                // is Pinch Zoomed. Note that this flag does not need to be removed when
                // the browser is un-zoomed because the patched function for determining
                // absolute position works in all circumstances.
                PZAwarePositionCallback.setPinchZoomed(true);
            }
        }
    }, MouseWheelEvent.getType());

    // There is no sure-fire way of preventing people from accidentally navigating away from ODE
    // (e.g. by hitting the Backspace key). What we do need though is to make sure that people will
    // not lose any work because of this. We hook into the window closing  event to detect the
    // situation.
    Window.addWindowClosingHandler(new Window.ClosingHandler() {
        @Override
        public void onWindowClosing(Window.ClosingEvent event) {
            onClosing();
        }
    });

    setupMotd();
}

From source file:com.google.appinventor.client.StatusPanel.java

License:Open Source License

/**
 * Initializes and assembles all UI elements shown in the status panel.
 *//*from ww w  . j a  v a2 s.c o m*/
public StatusPanel() {
    HorizontalPanel hpanel = new HorizontalPanel();
    hpanel.setWidth("100%");
    hpanel.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
    String tosUrl = Ode.getInstance().getSystemConfig().getTosUrl();
    if (!Strings.isNullOrEmpty(tosUrl)) {
        String appInventorFooter = "<a href=\"" + tosUrl + "\" target=\"_blank\">" + MESSAGES.privacyTermsLink()
                + "</a>";
        hpanel.add(new HTML(appInventorFooter));
    }

    // This shows the git version and the date of the build
    //    String version = GitBuildId.getVersion();
    //    String date = GitBuildId.getDate();
    //    if (version != null && date != null) {
    //      Label buildId = new Label(MESSAGES.gitBuildId(date, version));
    //      hpanel.add(buildId);
    //      hpanel.setCellHorizontalAlignment(buildId, HorizontalPanel.ALIGN_RIGHT);
    //    }

    initWidget(hpanel);
    setStyleName("ode-StatusPanel");
}