List of usage examples for com.google.gwt.user.client.ui HorizontalPanel HorizontalPanel
public HorizontalPanel()
From source file:com.google.appinventor.client.editor.youngandroid.properties.YoungAndroidLengthPropertyEditor.java
License:Open Source License
/** * Creates a new length property editor. * * @param includePercent whether to include percent of screen option *//*from w w w. j a v a 2 s. co m*/ public YoungAndroidLengthPropertyEditor(boolean includePercent) { // The radio button group cannot be shared across all instances, so we append a unique id. int uniqueId = ++uniqueIdSeed; String radioButtonGroup = "LengthType-" + uniqueId; automaticRadioButton = new RadioButton(radioButtonGroup, MESSAGES.automaticCaption()); fillParentRadioButton = new RadioButton(radioButtonGroup, MESSAGES.fillParentCaption()); percentfillRadioButton = new RadioButton(radioButtonGroup); customLengthRadioButton = new RadioButton(radioButtonGroup); customLengthField = new TextBox(); customLengthField.setVisibleLength(4); customLengthField.setMaxLength(4); percentLengthField = new TextBox(); percentLengthField.setVisibleLength(4); percentLengthField.setMaxLength(4); Panel customRow = new HorizontalPanel(); customRow.add(customLengthRadioButton); customRow.add(customLengthField); Label pixels = new Label(MESSAGES.pixelsCaption()); pixels.setStylePrimaryName("ode-PixelsLabel"); customRow.add(pixels); Panel percentRow = new HorizontalPanel(); percentRow.add(percentfillRadioButton); percentRow.add(percentLengthField); Label percent = new Label(MESSAGES.percentCaption()); percent.setStylePrimaryName("ode-PixelsLabel"); // recycle css definition percentRow.add(percent); Panel panel = new VerticalPanel(); panel.add(automaticRadioButton); panel.add(fillParentRadioButton); panel.add(customRow); if (includePercent) { panel.add(percentRow); } automaticRadioButton.addValueChangeHandler(new ValueChangeHandler() { @Override public void onValueChange(ValueChangeEvent event) { // Clear the custom and percent length fields. customLengthField.setText(""); percentLengthField.setText(""); } }); fillParentRadioButton.addValueChangeHandler(new ValueChangeHandler() { @Override public void onValueChange(ValueChangeEvent event) { // Clear the custom and percent length fields. customLengthField.setText(""); percentLengthField.setText(""); } }); customLengthField.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // If the user clicks on the custom length field, but the radio button for a custom length // is not checked, check it. if (!customLengthRadioButton.isChecked()) { customLengthRadioButton.setChecked(true); percentLengthField.setText(""); } } }); percentLengthField.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // If the user clicks on the percent length field, but the radio button for a custom length // is not checked, check it. if (!percentfillRadioButton.isChecked()) { percentfillRadioButton.setChecked(true); customLengthField.setText(""); } } }); initAdditionalChoicePanel(panel); }
From source file:com.google.appinventor.client.explorer.SourceStructureExplorer.java
License:Open Source License
/** * Creates a new source structure explorer. *//*from www. j av 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 w ww .j a v a2 s .c o m 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./* w w w. j a v a 2s .c o 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.ja v a 2s . c om*/ */ 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.// ww w. j a v a2 s. c o m * */ 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 ww w.j av a 2 s . co 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 w w w. ja v a2 s . com 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"); }
From source file:com.google.appinventor.client.TopPanel.java
License:Open Source License
/** * Initializes and assembles all UI elements shown in the top panel. *//*from w ww.j ava 2s . c o m*/ public TopPanel() { /* * The layout of the top panel is as follows: * * +-- topPanel ------------------------------------+ * |+-- logo --++-----tools-----++--links/account--+| * || || || || * |+----------++---------------++-----------------+| * +------------------------------------------------+ */ HorizontalPanel topPanel = new HorizontalPanel(); topPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); // Create the Tools TopToolbar tools = new TopToolbar(); ode.setTopToolbar(tools); // Create the Links HorizontalPanel links = new HorizontalPanel(); links.setStyleName("ode-TopPanelLinks"); links.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); if (Ode.getInstance().isReadOnly()) { Label readOnly = new Label(MESSAGES.readOnlyMode()); readOnly.setStyleName("ode-TopPanelWarningLabel"); links.add(readOnly); } // My Projects Link TextButton myProjects = new TextButton(MESSAGES.myProjectsTabName()); myProjects.setStyleName("ode-TopPanelButton"); myProjects.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { ode.switchToProjectsView(); } }); myProjects.setStyleName("ode-TopPanelButton"); links.add(myProjects); // Code on gallerydev branch // Gallery Link gallery = new TextButton(MESSAGES.tabNameGallery()); gallery.setStyleName("ode-TopPanelButton"); gallery.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { ode.switchToGalleryView(); } }); links.add(gallery); Config config = ode.getSystemConfig(); String guideUrl = config.getGuideUrl(); if (!Strings.isNullOrEmpty(guideUrl)) { TextButton guideLink = new TextButton(MESSAGES.guideTabName()); guideLink.addClickHandler(new WindowOpenClickHandler(guideUrl)); guideLink.setStyleName("ode-TopPanelButton"); links.add(guideLink); } // Feedback Link String feedbackUrl = config.getFeedbackUrl(); if (!Strings.isNullOrEmpty(feedbackUrl)) { TextButton feedbackLink = new TextButton(MESSAGES.feedbackTabName()); feedbackLink.addClickHandler(new WindowOpenClickHandler(feedbackUrl)); feedbackLink.setStyleName("ode-TopPanelButton"); links.add(feedbackLink); } /* // Code on master branch // Gallery Link if (Ode.getInstance().getUser().getIsAdmin()) { TextButton gallery = new TextButton(MESSAGES.galleryTabName()); gallery.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { Window.open("http://gallery.appinventor.mit.edu", "_blank", "scrollbars=1"); } }); gallery.setStyleName("ode-TopPanelButton"); links.add(gallery); } */ moderation = new TextButton(MESSAGES.tabNameModeration()); moderation.setStyleName("ode-TopPanelButton"); moderation.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { ode.switchToModerationPageView(); } }); moderation.setVisible(false); links.add(moderation); // Create the Account Information rightPanel = new VerticalPanel(); rightPanel.setHeight("100%"); rightPanel.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE); HorizontalPanel account = new HorizontalPanel(); account.setStyleName("ode-TopPanelAccount"); // Account Drop Down Button List<DropDownItem> userItems = Lists.newArrayList(); // Sign Out userItems.add(new DropDownItem(WIDGET_NAME_SIGN_OUT, MESSAGES.signOutLink(), new SignOutAction())); accountButton = new DropDownButton(WIDGET_NAME_USER, " ", userItems, true); accountButton.setItemEnabled(WIDGET_NAME_MESSAGES, false); accountButton.setStyleName("ode-TopPanelButton"); // Language List<DropDownItem> languageItems = Lists.newArrayList(); String[] localeNames = LocaleInfo.getAvailableLocaleNames(); String nativeName; for (String localeName : localeNames) { if (!localeName.equals("default")) { SelectLanguage lang = new SelectLanguage(); lang.setLocale(localeName); nativeName = getDisplayName(localeName); languageItems.add(new DropDownItem(WIDGET_NAME_LANGUAGE, nativeName, lang)); } } String currentLang = LocaleInfo.getCurrentLocale().getLocaleName(); String nativeDisplayName = getDisplayName(currentLang); languageDropDown = new DropDownButton(WIDGET_NAME_LANGUAGE, nativeDisplayName, languageItems, true); languageDropDown.setStyleName("ode-TopPanelButton"); account.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE); account.add(links); account.add(languageDropDown); account.add(accountButton); rightPanel.add(account); // Add the Logo, Tools, Links to the TopPanel addLogo(topPanel); topPanel.add(tools); topPanel.add(rightPanel); topPanel.setCellVerticalAlignment(rightPanel, HorizontalPanel.ALIGN_MIDDLE); rightPanel.setCellHorizontalAlignment(account, HorizontalPanel.ALIGN_RIGHT); topPanel.setCellHorizontalAlignment(rightPanel, HorizontalPanel.ALIGN_RIGHT); initWidget(topPanel); setStyleName("ode-TopPanel"); setWidth("100%"); }
From source file:com.google.appinventor.client.TopToolbar.java
License:Open Source License
public TopToolbar() { /*//from www . java 2s . co m * Layout is as follows: * +--------------------------------------------------+ * | Project | Connect | Build | Help | Admin | * +--------------------------------------------------+ */ HorizontalPanel toolbar = new HorizontalPanel(); toolbar.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); List<DropDownItem> fileItems = Lists.newArrayList(); List<DropDownItem> componentItems = Lists.newArrayList(); List<DropDownItem> connectItems = Lists.newArrayList(); List<DropDownItem> buildItems = Lists.newArrayList(); List<DropDownItem> helpItems = Lists.newArrayList(); // Should the UI be in read only mode? isReadOnly = Ode.getInstance().isReadOnly(); // File -> {New Project; Save; Save As; Checkpoint; |; Delete this Project; My Projects;} fileItems.add( new DropDownItem(WIDGET_NAME_MY_PROJECTS, MESSAGES.projectMenuItem(), new SwitchToProjectAction())); fileItems.add(null); if (!isReadOnly) { fileItems.add(new DropDownItem(WIDGET_NAME_NEW, MESSAGES.newProjectMenuItem(), new NewAction())); fileItems.add(new DropDownItem(WIDGET_NAME_IMPORTPROJECT, MESSAGES.importProjectMenuItem(), new ImportProjectAction())); fileItems.add(new DropDownItem(WIDGET_NAME_IMPORTTEMPLATE, MESSAGES.importTemplateButton(), new ImportTemplateAction())); fileItems.add(new DropDownItem(WIDGET_NAME_DELETE, MESSAGES.deleteProjectButton(), new DeleteAction())); fileItems.add(null); fileItems.add(new DropDownItem(WIDGET_NAME_SAVE, MESSAGES.saveMenuItem(), new SaveAction())); fileItems.add(new DropDownItem(WIDGET_NAME_SAVE_AS, MESSAGES.saveAsMenuItem(), new SaveAsAction())); fileItems.add(new DropDownItem(WIDGET_NAME_CHECKPOINT, MESSAGES.checkpointMenuItem(), new CheckpointAction())); fileItems.add(null); } fileItems.add(new DropDownItem(WIDGET_NAME_EXPORTPROJECT, MESSAGES.exportProjectMenuItem(), new ExportProjectAction())); fileItems.add(new DropDownItem(WIDGET_NAME_EXPORTALLPROJECTS, MESSAGES.exportAllProjectsMenuItem(), new ExportAllProjectsAction())); fileItems.add(null); if (!isReadOnly) { fileItems.add(new DropDownItem(WIDGET_NAME_UPLOAD_KEYSTORE, MESSAGES.uploadKeystoreMenuItem(), new UploadKeystoreAction())); } fileItems.add(new DropDownItem(WIDGET_NAME_DOWNLOAD_KEYSTORE, MESSAGES.downloadKeystoreMenuItem(), new DownloadKeystoreAction())); if (!isReadOnly) { fileItems.add(new DropDownItem(WIDGET_NAME_DELETE_KEYSTORE, MESSAGES.deleteKeystoreMenuItem(), new DeleteKeystoreAction())); } // Connect -> {Connect to Companion; Connect to Emulator; Connect to USB; Reset Connections} connectItems.add(new DropDownItem(WIDGET_NAME_WIRELESS_BUTTON, MESSAGES.AICompanionMenuItem(), new WirelessAction())); connectItems.add( new DropDownItem(WIDGET_NAME_EMULATOR_BUTTON, MESSAGES.emulatorMenuItem(), new EmulatorAction())); connectItems.add(new DropDownItem(WIDGET_NAME_USB_BUTTON, MESSAGES.usbMenuItem(), new UsbAction())); connectItems.add(null); connectItems.add( new DropDownItem(WIDGET_NAME_RESET_BUTTON, MESSAGES.resetConnectionsMenuItem(), new ResetAction())); connectItems.add(new DropDownItem(WIDGET_NAME_HARDRESET_BUTTON, MESSAGES.hardResetConnectionsMenuItem(), new HardResetAction())); // Build -> {Show Barcode; Download to Computer; Generate YAIL only when logged in as an admin} buildItems.add( new DropDownItem(WIDGET_NAME_BUILD_BARCODE, MESSAGES.showBarcodeMenuItem(), new BarcodeAction())); buildItems.add(new DropDownItem(WIDGET_NAME_BUILD_DOWNLOAD, MESSAGES.downloadToComputerMenuItem(), new DownloadAction())); if (AppInventorFeatures.hasYailGenerationOption() && Ode.getInstance().getUser().getIsAdmin()) { buildItems.add(null); buildItems.add(new DropDownItem(WIDGET_NAME_BUILD_YAIL, MESSAGES.generateYailMenuItem(), new GenerateYailAction())); } // Help -> {About, Library, Get Started, Tutorials, Troubleshooting, Forums, Report an Issue, // Companion Information, Show Splash Screen} helpItems.add(new DropDownItem(WIDGET_NAME_ABOUT, MESSAGES.aboutMenuItem(), new AboutAction())); helpItems.add(null); Config config = Ode.getInstance().getSystemConfig(); String libraryUrl = config.getLibraryUrl(); if (!Strings.isNullOrEmpty(libraryUrl)) { helpItems.add(new DropDownItem(WIDGET_NAME_LIBRARY, MESSAGES.libraryMenuItem(), new WindowOpenAction(libraryUrl))); } String getStartedUrl = config.getGetStartedUrl(); if (!Strings.isNullOrEmpty(getStartedUrl)) { helpItems.add(new DropDownItem(WIDGET_NAME_GETSTARTED, MESSAGES.getStartedMenuItem(), new WindowOpenAction(getStartedUrl))); } String extensionsUrl = config.getExtensionsUrl(); if (!Strings.isNullOrEmpty(extensionsUrl)) { helpItems.add(new DropDownItem(WIDGET_NAME_EXTENSIONS, MESSAGES.extensionsMenuItem(), new WindowOpenAction(extensionsUrl))); } String tutorialsUrl = config.getTutorialsUrl(); if (!Strings.isNullOrEmpty(tutorialsUrl)) { helpItems.add(new DropDownItem(WIDGET_NAME_TUTORIALS, MESSAGES.tutorialsMenuItem(), new WindowOpenAction(tutorialsUrl))); } String troubleshootingUrl = config.getTroubleshootingUrl(); if (!Strings.isNullOrEmpty(troubleshootingUrl)) { helpItems.add(new DropDownItem(WIDGET_NAME_TROUBLESHOOTING, MESSAGES.troubleshootingMenuItem(), new WindowOpenAction(troubleshootingUrl))); } String forumsUrl = config.getForumsUrl(); if (!Strings.isNullOrEmpty(forumsUrl)) { helpItems.add(new DropDownItem(WIDGET_NAME_FORUMS, MESSAGES.forumsMenuItem(), new WindowOpenAction(forumsUrl))); } helpItems.add(null); String feedbackUrl = config.getFeedbackUrl(); if (!Strings.isNullOrEmpty(feedbackUrl)) { helpItems.add(new DropDownItem(WIDGET_NAME_FEEDBACK, MESSAGES.feedbackMenuItem(), new WindowOpenAction(feedbackUrl))); helpItems.add(null); } helpItems.add(new DropDownItem(WIDGET_NAME_COMPANIONINFO, MESSAGES.companionInformation(), new AboutCompanionAction())); helpItems.add(new DropDownItem(WIDGET_NAME_COMPANIONUPDATE, MESSAGES.companionUpdate(), new CompanionUpdateAction())); helpItems.add( new DropDownItem(WIDGET_NAME_SHOWSPLASH, MESSAGES.showSplashMenuItem(), new ShowSplashAction())); // Create the TopToolbar drop down menus. fileDropDown = new DropDownButton(WIDGET_NAME_PROJECT, MESSAGES.projectsTabName(), fileItems, false); connectDropDown = new DropDownButton(WIDGET_NAME_CONNECT_TO, MESSAGES.connectTabName(), connectItems, false); buildDropDown = new DropDownButton(WIDGET_NAME_BUILD, MESSAGES.buildTabName(), buildItems, false); helpDropDown = new DropDownButton(WIDGET_NAME_HELP, MESSAGES.helpTabName(), helpItems, false); // Set the DropDown Styles fileDropDown.setStyleName("ode-TopPanelButton"); connectDropDown.setStyleName("ode-TopPanelButton"); buildDropDown.setStyleName("ode-TopPanelButton"); helpDropDown.setStyleName("ode-TopPanelButton"); // Add the Buttons to the Toolbar. toolbar.add(fileDropDown); toolbar.add(connectDropDown); toolbar.add(buildDropDown); // Commented out language switching until we have a clean Chinese translation. (AFM) toolbar.add(helpDropDown); //Only if logged in as an admin, add the Admin Button if (Ode.getInstance().getUser().getIsAdmin()) { List<DropDownItem> adminItems = Lists.newArrayList(); adminItems.add(new DropDownItem(WIDGET_NAME_DOWNLOAD_USER_SOURCE, MESSAGES.downloadUserSourceMenuItem(), new DownloadUserSourceAction())); adminItems.add(new DropDownItem(WIDGET_NAME_SWITCH_TO_DEBUG, MESSAGES.switchToDebugMenuItem(), new SwitchToDebugAction())); adminItems.add(new DropDownItem(WIDGET_NAME_USER_ADMIN, "User Admin", new SwitchToUserAdminAction())); adminDropDown = new DropDownButton(WIDGET_NAME_ADMIN, MESSAGES.adminTabName(), adminItems, false); adminDropDown.setStyleName("ode-TopPanelButton"); toolbar.add(adminDropDown); } initWidget(toolbar); }