예제 #1
0
 private void updateConnectToDropDownButton(
     boolean isEmulatorRunning, boolean isCompanionRunning, boolean isUsbRunning) {
   if (!isEmulatorRunning && !isCompanionRunning && !isUsbRunning) {
     connectDropDown.setItemEnabled(MESSAGES.wirelessButton(), true);
     connectDropDown.setItemEnabled(MESSAGES.emulatorButton(), true);
     connectDropDown.setItemEnabled(MESSAGES.usbButton(), true);
   } else {
     connectDropDown.setItemEnabled(MESSAGES.wirelessButton(), false);
     connectDropDown.setItemEnabled(MESSAGES.emulatorButton(), false);
     connectDropDown.setItemEnabled(MESSAGES.usbButton(), false);
   }
 }
예제 #2
0
 /**
  * Enables and/or disables buttons based on how many projects exist (in the case of "Download All
  * Projects") or are selected (in the case of "Delete" and "Download Source").
  */
 public void updateFileMenuButtons(int view) {
   if (view == 0) { // We are in the Projects view
     fileDropDown.setItemEnabled(
         MESSAGES.deleteMenuItemButton(),
         Ode.getInstance().getProjectManager().getProjects() == null);
     fileDropDown.setItemEnabled(
         MESSAGES.exportAllProjectsButton(),
         Ode.getInstance().getProjectManager().getProjects().size() > 0);
     fileDropDown.setItemEnabled(MESSAGES.exportProjectButton(), false);
     fileDropDown.setItemEnabled(MESSAGES.saveMenuItem(), false);
     fileDropDown.setItemEnabled(MESSAGES.saveAsMenuItem(), false);
     fileDropDown.setItemEnabled(MESSAGES.checkpointButton(), false);
     buildDropDown.setItemEnabled(MESSAGES.showBarcodeButton(), false);
     buildDropDown.setItemEnabled(MESSAGES.downloadToComputerButton(), false);
   } else { // We have to be in the Designer/Blocks view
     fileDropDown.setItemEnabled(MESSAGES.deleteMenuItemButton(), false);
     fileDropDown.setItemEnabled(MESSAGES.exportAllProjectsButton(), false);
     fileDropDown.setItemEnabled(MESSAGES.exportProjectButton(), false);
     fileDropDown.setItemEnabled(MESSAGES.saveMenuItem(), true);
     fileDropDown.setItemEnabled(MESSAGES.saveAsMenuItem(), true);
     fileDropDown.setItemEnabled(MESSAGES.checkpointButton(), true);
     buildDropDown.setItemEnabled(MESSAGES.showBarcodeButton(), true);
     buildDropDown.setItemEnabled(MESSAGES.downloadToComputerButton(), true);
   }
   updateKeystoreFileMenuButtons();
 }
예제 #3
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);
  }