/** 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
  }
  /**
   * Insert a tab. Like add a tab only with an index.
   *
   * @param tab the tab.
   * @param index the index.
   */
  public void insertTab(final SimpleTab tab, final int index) {
    if (firstTab == null) {
      firstTab = tab.getIdentifier();
    }
    tabs.put(tab.getIdentifier(), tab);
    tabDropZone.insert(tab, index);

    if (draggable) {
      tab.makeTabDraggable(tabDragController);
    }

    tab.init(key);
  }
Esempio n. 3
0
  private void createButtonLine() {
    EnumSet<ButtonLineParam> buttonSet =
        EnumSet.of(ButtonLineParam.ADD_AT_END, ButtonLineParam.PLAY);
    EnumSet<ButtonType> buttonTypeSet = EnumSet.noneOf(ButtonType.class);
    if (artistId != null) {
      buttonTypeSet.add(ButtonType.PLAY_ARTIST);
    } else if (albumId != null) {
      buttonTypeSet.add(ButtonType.PLAY_ALBUM);
    } else {
      buttonTypeSet.add(ButtonType.PLAY_COLLECTION);
    }

    if (inCollection != null
        && artistId == null
        && albumId == null) { // We're in an album view of a collection
      buttonSet.add(ButtonLineParam.DELETE);
      buttonTypeSet.add(ButtonType.DELETE_COLLECTION);
    }
    ButtonLine b = new ButtonLine(buttonSet, buttonTypeSet);
    setDeleteButtonHandler(b);
    setAddAtEndButtonHandler(b);
    setPlayButtonHandler(b);
    titlePanel.insert(b, 2);
  }
Esempio n. 4
0
 /**
  * Inserts a tool.
  *
  * @param tool the tool to insert
  * @param index the insert location
  */
 public void insertTool(Widget tool, int index) {
   tools.add(index, tool);
   widgetPanel.setVisible(true);
   widgetPanel.insert(tool, index);
 }