private void startRepl(String screenName, boolean forEmulator, boolean forUsb) { Screen screen = currentProject.screens.get(screenName); screen.blocksEditor.startRepl(replStarted, forEmulator, forUsb); if (!replStarted) { replStarted = true; if (forEmulator) { // We are starting the emulator... updateConnectToDropDownButton(true, false, false); } else if (forUsb) { // We are starting the usb connection updateConnectToDropDownButton(false, false, true); } else { // We are connecting via wifi to a Companion updateConnectToDropDownButton(false, true, false); } } else { replStarted = false; updateConnectToDropDownButton(false, false, false); } }
/** Initializes and assembles all commands into buttons in the toolbar. */ public DesignToolbar() { super(); projectNameLabel = new Label(); projectNameLabel.setStyleName("ya-ProjectName"); HorizontalPanel toolbar = (HorizontalPanel) getWidget(); toolbar.insert(projectNameLabel, 0); toolbar.setCellWidth(projectNameLabel, "222px"); // width of palette minus // cellspacing/border of buttons addButton(new ToolbarItem(WIDGET_NAME_SAVE, MESSAGES.saveButton(), new SaveAction())); addButton(new ToolbarItem(WIDGET_NAME_SAVE_AS, MESSAGES.saveAsButton(), new SaveAsAction())); addButton( new ToolbarItem( WIDGET_NAME_CHECKPOINT, MESSAGES.checkpointButton(), new CheckpointAction())); if (AppInventorFeatures.allowMultiScreenApplications()) { addButton( new ToolbarItem(WIDGET_NAME_ADDFORM, MESSAGES.addFormButton(), new AddFormAction())); addButton( new ToolbarItem( WIDGET_NAME_REMOVEFORM, MESSAGES.removeFormButton(), new RemoveFormAction())); } List<ToolbarItem> connectToItems = Lists.newArrayList(); addDropDownButton(WIDGET_NAME_CONNECT_TO, MESSAGES.connectToButton(), connectToItems, true); updateConnectToDropDownButton(false, false, false); List<ToolbarItem> screenItems = Lists.newArrayList(); addDropDownButton(WIDGET_NAME_SCREENS_DROPDOWN, MESSAGES.screensButton(), screenItems, true); addButton( new ToolbarItem( WIDGET_NAME_SWITCH_TO_FORM_EDITOR, MESSAGES.switchToFormEditorButton(), new SwitchToFormEditorAction()), true); addButton( new ToolbarItem( WIDGET_NAME_SWITCH_TO_BLOCKS_EDITOR, MESSAGES.switchToBlocksEditorButton(), new SwitchToBlocksEditorAction()), true); List<ToolbarItem> buildItems = Lists.newArrayList(); buildItems.add( new ToolbarItem( WIDGET_NAME_BUILD_BARCODE, MESSAGES.showBarcodeButton(), new BarcodeAction())); buildItems.add( new ToolbarItem( WIDGET_NAME_BUILD_DOWNLOAD, MESSAGES.downloadToComputerButton(), new DownloadAction())); if (AppInventorFeatures.hasYailGenerationOption() && Ode.getInstance().getUser().getIsAdmin()) { buildItems.add( new ToolbarItem( WIDGET_NAME_BUILD_YAIL, MESSAGES.generateYailButton(), new GenerateYailAction())); } addDropDownButton(WIDGET_NAME_BUILD, MESSAGES.buildButton(), buildItems, true); toggleEditor(false); // Gray out the Designer button and enable the blocks button }
/** * Indicate that we are no longer connected to the Companion, adjust buttons accordingly. Called * from BlocklyPanel */ public static void indicateDisconnect() { DesignToolbar instance = Ode.getInstance().getDesignToolbar(); instance.updateConnectToDropDownButton(false, false, false); instance.replStarted = false; // This is ugly, I should really define a method to do this // but that would just take space and time... }