コード例 #1
0
  /** 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
  }
コード例 #2
0
 private static boolean showCategory(ComponentCategory category) {
   if (category == ComponentCategory.UNINITIALIZED) {
     return false;
   }
   if (category == ComponentCategory.INTERNAL
       && !AppInventorFeatures.showInternalComponentsCategory()) {
     return false;
   }
   return true;
 }
コード例 #3
0
  /** Enables and/or disables buttons based (mostly) on whether there is a current form. */
  private void updateButtons() {
    String screenName = (currentProject == null) ? null : currentProject.currentScreen;
    boolean enabled = (currentProject != null);
    setButtonEnabled(WIDGET_NAME_SAVE, enabled);
    setButtonEnabled(WIDGET_NAME_SAVE_AS, enabled);
    setButtonEnabled(WIDGET_NAME_CHECKPOINT, enabled);
    setDropItemEnabled(WIDGET_NAME_BUILD, WIDGET_NAME_BUILD_BARCODE, enabled);
    setDropItemEnabled(WIDGET_NAME_BUILD, WIDGET_NAME_BUILD_DOWNLOAD, enabled);

    if (AppInventorFeatures.allowMultiScreenApplications()) {
      setButtonEnabled(WIDGET_NAME_ADDFORM, enabled);
      enabled =
          (currentProject != null && !YoungAndroidSourceNode.SCREEN1_FORM_NAME.equals(screenName));
      setButtonEnabled(WIDGET_NAME_REMOVEFORM, enabled);
    }

    if (currentProject != null) {
      setDropDownButtonCaption(WIDGET_NAME_SCREENS_DROPDOWN, screenName);
    } else {
      setDropDownButtonCaption(WIDGET_NAME_SCREENS_DROPDOWN, MESSAGES.screensButton());
    }
  }
コード例 #4
0
  public TopToolbar() {
    /*
     * 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> connectItems = Lists.newArrayList();
    List<DropDownItem> buildItems = Lists.newArrayList();
    List<DropDownItem> helpItems = Lists.newArrayList();

    // File -> {New Project; Save; Save As; Checkpoint; |; Delete this Project; My Projects;}
    fileItems.add(
        new DropDownItem(
            WIDGET_NAME_MY_PROJECTS, MESSAGES.tabNameProjects(), new SwitchToProjectAction()));
    fileItems.add(null);
    fileItems.add(new DropDownItem(WIDGET_NAME_NEW, MESSAGES.newMenuItemButton(), new NewAction()));
    fileItems.add(
        new DropDownItem(
            WIDGET_NAME_IMPORTPROJECT, MESSAGES.importProjectButton(), new ImportProjectAction()));
    fileItems.add(
        new DropDownItem(
            WIDGET_NAME_IMPORTTEMPLATE,
            MESSAGES.importTemplateButton(),
            new ImportTemplateAction()));
    fileItems.add(
        new DropDownItem(WIDGET_NAME_DELETE, MESSAGES.deleteMenuItemButton(), 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.checkpointButton(), new CheckpointAction()));
    fileItems.add(null);
    fileItems.add(
        new DropDownItem(
            WIDGET_NAME_EXPORTPROJECT, MESSAGES.exportProjectButton(), new ExportProjectAction()));
    fileItems.add(
        new DropDownItem(
            WIDGET_NAME_EXPORTALLPROJECTS,
            MESSAGES.exportAllProjectsButton(),
            new ExportAllProjectsAction()));
    fileItems.add(null);
    fileItems.add(
        new DropDownItem(
            WIDGET_NAME_UPLOAD_KEYSTORE,
            MESSAGES.uploadKeystoreButton(),
            new UploadKeystoreAction()));
    fileItems.add(
        new DropDownItem(
            WIDGET_NAME_DOWNLOAD_KEYSTORE,
            MESSAGES.downloadKeystoreButton(),
            new DownloadKeystoreAction()));
    fileItems.add(
        new DropDownItem(
            WIDGET_NAME_DELETE_KEYSTORE,
            MESSAGES.deleteKeystoreButton(),
            new DeleteKeystoreAction()));

    // Connect -> {Connect to Companion; Connect to Emulator; Connect to USB; Reset Connections}
    connectItems.add(
        new DropDownItem(
            WIDGET_NAME_WIRELESS_BUTTON, MESSAGES.wirelessButton(), new WirelessAction()));
    connectItems.add(
        new DropDownItem(
            WIDGET_NAME_EMULATOR_BUTTON, MESSAGES.emulatorButton(), new EmulatorAction()));
    connectItems.add(
        new DropDownItem(WIDGET_NAME_USB_BUTTON, MESSAGES.usbButton(), new UsbAction()));
    connectItems.add(null);
    connectItems.add(
        new DropDownItem(WIDGET_NAME_RESET_BUTTON, MESSAGES.resetConnections(), new ResetAction()));
    connectItems.add(
        new DropDownItem(
            WIDGET_NAME_HARDRESET_BUTTON, MESSAGES.hardResetConnections(), 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.showBarcodeButton(), new BarcodeAction()));
    buildItems.add(
        new DropDownItem(
            WIDGET_NAME_BUILD_DOWNLOAD, MESSAGES.downloadToComputerButton(), new DownloadAction()));
    if (AppInventorFeatures.hasYailGenerationOption() && Ode.getInstance().getUser().getIsAdmin()) {
      buildItems.add(null);
      buildItems.add(
          new DropDownItem(
              WIDGET_NAME_BUILD_YAIL, MESSAGES.generateYailButton(), new GenerateYailAction()));
    }

    // Help -> {About, Library, Get Started, Tutorials, Troubleshooting, Forums, Report an Issue}
    helpItems.add(new DropDownItem(WIDGET_NAME_ABOUT, MESSAGES.aboutLink(), new AboutAction()));
    helpItems.add(null);
    helpItems.add(
        new DropDownItem(WIDGET_NAME_LIBRARY, MESSAGES.libraryLink(), new LibraryAction()));
    helpItems.add(
        new DropDownItem(
            WIDGET_NAME_GETSTARTED, MESSAGES.getStartedLink(), new GetStartedAction()));
    helpItems.add(
        new DropDownItem(WIDGET_NAME_TUTORIALS, MESSAGES.tutorialsLink(), new TutorialsAction()));
    helpItems.add(
        new DropDownItem(
            WIDGET_NAME_TROUBLESHOOTING,
            MESSAGES.troubleshootingLink(),
            new TroubleShootingAction()));
    helpItems.add(new DropDownItem(WIDGET_NAME_FORUMS, MESSAGES.forumsLink(), new ForumsAction()));
    helpItems.add(null);
    helpItems.add(
        new DropDownItem(WIDGET_NAME_FEEDBACK, MESSAGES.feedbackLink(), new FeedbackAction()));

    // Create the TopToolbar drop down menus.
    fileDropDown =
        new DropDownButton(WIDGET_NAME_PROJECT, MESSAGES.projectButton(), fileItems, false);
    connectDropDown =
        new DropDownButton(WIDGET_NAME_CONNECT_TO, MESSAGES.connectButton(), connectItems, false);
    buildDropDown =
        new DropDownButton(WIDGET_NAME_BUILD, MESSAGES.buildButton(), buildItems, false);
    helpDropDown = new DropDownButton(WIDGET_NAME_HELP, MESSAGES.helpLink(), 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);
    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.downloadUserSourceButton(),
              new DownloadUserSourceAction()));
      adminItems.add(
          new DropDownItem(
              WIDGET_NAME_SWITCH_TO_DEBUG,
              MESSAGES.switchToDebugButton(),
              new SwitchToDebugAction()));
      adminDropDown =
          new DropDownButton(WIDGET_NAME_ADMIN, MESSAGES.adminButton(), adminItems, false);
      adminDropDown.setStyleName("ode-TopPanelButton");
      toolbar.add(adminDropDown);
    }

    initWidget(toolbar);
  }