コード例 #1
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();
 }
コード例 #2
0
 public static void popScreen() {
   DesignToolbar designToolbar = Ode.getInstance().getDesignToolbar();
   long projectId = Ode.getInstance().getCurrentYoungAndroidProjectId();
   String newScreen;
   if (pushedScreens.isEmpty()) {
     return; // Nothing to do really
   }
   newScreen = pushedScreens.removeFirst();
   designToolbar.doSwitchScreen(projectId, newScreen, View.BLOCKS);
 }
コード例 #3
0
 /*
  * PushScreen -- Static method called by Blockly when the Companion requests
  * That we switch to a new screen. We keep track of the Screen we were on
  * and push that onto a stack of Screens which we pop when requested by the
  * Companion.
  */
 public static boolean pushScreen(String screenName) {
   DesignToolbar designToolbar = Ode.getInstance().getDesignToolbar();
   long projectId = Ode.getInstance().getCurrentYoungAndroidProjectId();
   String currentScreen = designToolbar.currentProject.currentScreen;
   if (!designToolbar.currentProject.screens.containsKey(
       screenName)) // No such screen -- can happen
   return false; // because screen is user entered here.
   pushedScreens.addFirst(currentScreen);
   designToolbar.doSwitchScreen(projectId, screenName, View.BLOCKS);
   return true;
 }
コード例 #4
0
 @Override
 public void execute() {
   if (Ode.getInstance().okToConnect()) {
     startRepl(true, true, false); // true means we are the
     // emulator
   }
 }
コード例 #5
0
 @Override
 public void execute() {
   ProjectRootNode projectRootNode = Ode.getInstance().getCurrentYoungAndroidProjectRootNode();
   if (projectRootNode != null) {
     String target = YoungAndroidProjectNode.YOUNG_ANDROID_TARGET_ANDROID;
     ChainableCommand cmd =
         new SaveAllEditorsCommand(
             new GenerateYailCommand(
                 new BuildCommand(
                     target,
                     new ShowProgressBarCommand(
                         target,
                         new WaitForBuildResultCommand(
                             target, new DownloadProjectOutputCommand(target)),
                         "DownloadAction"))));
     //        updateBuildButton(true);
     cmd.startExecuteChain(
         Tracking.PROJECT_ACTION_BUILD_DOWNLOAD_YA,
         projectRootNode,
         new Command() {
           @Override
           public void execute() {
             //                updateBuildButton(false);
           }
         });
   }
 }
コード例 #6
0
 @Override
 public void execute() {
   Ode.getInstance()
       .getUserInfoService()
       .hasUserFile(
           StorageUtil.ANDROID_KEYSTORE_FILENAME,
           new OdeAsyncCallback<Boolean>(MESSAGES.uploadKeystoreError()) {
             @Override
             public void onSuccess(Boolean keystoreFileExists) {
               if (!keystoreFileExists || Window.confirm(MESSAGES.confirmOverwriteKeystore())) {
                 KeystoreUploadWizard wizard =
                     new KeystoreUploadWizard(
                         new Command() {
                           @Override
                           public void execute() {
                             Tracking.trackEvent(
                                 Tracking.USER_EVENT, Tracking.USER_ACTION_UPLOAD_KEYSTORE);
                             updateKeystoreFileMenuButtons();
                           }
                         });
                 wizard.center();
               }
             }
           });
 }
コード例 #7
0
 @Override
 public void execute() {
   final String errorMessage = MESSAGES.deleteKeystoreError();
   Ode.getInstance()
       .getUserInfoService()
       .hasUserFile(
           StorageUtil.ANDROID_KEYSTORE_FILENAME,
           new OdeAsyncCallback<Boolean>(errorMessage) {
             @Override
             public void onSuccess(Boolean keystoreFileExists) {
               if (keystoreFileExists && Window.confirm(MESSAGES.confirmDeleteKeystore())) {
                 Tracking.trackEvent(Tracking.USER_EVENT, Tracking.USER_ACTION_DELETE_KEYSTORE);
                 Ode.getInstance()
                     .getUserInfoService()
                     .deleteUserFile(
                         StorageUtil.ANDROID_KEYSTORE_FILENAME,
                         new OdeAsyncCallback<Void>(errorMessage) {
                           @Override
                           public void onSuccess(Void result) {
                             updateKeystoreFileMenuButtons();
                           }
                         });
               }
             }
           });
 }
コード例 #8
0
  /** Creates a new ProjectList */
  public ProjectList() {
    projects = new ArrayList<Project>();
    selectedProjects = new ArrayList<Project>();
    projectWidgets = new HashMap<Project, ProjectWidgets>();

    sortField = SortField.DATE_MODIFIED;
    sortOrder = SortOrder.DESCENDING;

    // Initialize UI
    table = new Grid(1, 4); // The table initially contains just the header row.
    table.addStyleName("ode-ProjectTable");
    table.setWidth("100%");
    table.setCellSpacing(0);
    nameSortIndicator = new Label("");
    dateCreatedSortIndicator = new Label("");
    dateModifiedSortIndicator = new Label("");
    refreshSortIndicators();
    setHeaderRow();

    VerticalPanel panel = new VerticalPanel();
    panel.setWidth("100%");

    panel.add(table);
    initWidget(panel);

    // It is important to listen to project manager events as soon as possible.
    Ode.getInstance().getProjectManager().addProjectManagerEventListener(this);
  }
コード例 #9
0
 @Override
 public void saveSettings(final Command command) {
   if (loading) {
     // If we are in the process of loading, we must defer saving.
     DeferredCommand.addCommand(
         new Command() {
           @Override
           public void execute() {
             saveSettings(command);
           }
         });
   } else {
     String s = encodeSettings();
     OdeLog.log("Saving global settings: " + s);
     Ode.getInstance()
         .getUserInfoService()
         .storeUserSettings(
             s,
             new OdeAsyncCallback<Void>(
                 // failure message
                 MESSAGES.settingsSaveError()) {
               @Override
               public void onSuccess(Void result) {
                 if (command != null) {
                   command.execute();
                 }
               }
             });
   }
 }
コード例 #10
0
 @Override
 public void execute() {
   ProjectRootNode projectRootNode = Ode.getInstance().getCurrentYoungAndroidProjectRootNode();
   if (projectRootNode != null) {
     ChainableCommand cmd = new SaveAllEditorsCommand(new CopyYoungAndroidProjectCommand(true));
     cmd.startExecuteChain(Tracking.PROJECT_ACTION_CHECKPOINT_YA, projectRootNode);
   }
 }
コード例 #11
0
 @Override
 public void execute() {
   ProjectRootNode projectRootNode = Ode.getInstance().getCurrentYoungAndroidProjectRootNode();
   if (projectRootNode != null) {
     ChainableCommand cmd = new AddFormCommand();
     cmd.startExecuteChain(Tracking.PROJECT_ACTION_ADDFORM_YA, projectRootNode);
   }
 }
コード例 #12
0
 @Override
 public void execute() {
   if (Ode.getInstance().screensLocked()) {
     return; // Refuse to switch if locked (save file happening)
   }
   new NewYoungAndroidProjectWizard().center();
   // The wizard will switch to the design view when the new
   // project is created.
 }
コード例 #13
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
  }
コード例 #14
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 updateButtons() {
   ProjectList projectList = ProjectListBox.getProjectListBox().getProjectList();
   int numProjects = projectList.getNumProjects();
   int numSelectedProjects = projectList.getNumSelectedProjects();
   setButtonEnabled(WIDGET_NAME_DELETE, numSelectedProjects > 0);
   Ode.getInstance()
       .getTopToolbar()
       .fileDropDown
       .setItemEnabled(MESSAGES.deleteProjectMenuItem(), numSelectedProjects > 0);
   Ode.getInstance()
       .getTopToolbar()
       .fileDropDown
       .setItemEnabled(MESSAGES.exportProjectMenuItem(), numSelectedProjects > 0);
   Ode.getInstance()
       .getTopToolbar()
       .fileDropDown
       .setItemEnabled(MESSAGES.exportAllProjectsMenuItem(), numSelectedProjects > 0);
 }
コード例 #15
0
  @Override
  public void onProjectRemoved(Project project) {
    projects.remove(project);
    projectWidgets.remove(project);

    refreshTable(false);

    selectedProjects.remove(project);
    Ode.getInstance().getProjectToolbar().updateButtons();
  }
コード例 #16
0
    private void deleteProject(Project project) {
      Tracking.trackEvent(
          Tracking.PROJECT_EVENT,
          Tracking.PROJECT_ACTION_DELETE_PROJECT_YA,
          project.getProjectName());

      final long projectId = project.getProjectId();

      Ode ode = Ode.getInstance();
      boolean isCurrentProject = (projectId == ode.getCurrentYoungAndroidProjectId());
      ode.getEditorManager().closeProjectEditor(projectId);
      if (isCurrentProject) {
        // If we're deleting the project that is currently open in the Designer we
        // need to clear the ViewerBox first.
        ViewerBox.getViewerBox().clear();
      }
      // Make sure that we delete projects even if they are not open.
      doDeleteProject(projectId);
    }
コード例 #17
0
  @Override
  public void saveSettings(final Command command) {
    if (Ode.getInstance().isReadOnly()) {
      return; // Don't save when in read-only mode
    }
    if (loading) {
      // If we are in the process of loading, we must defer saving.
      DeferredCommand.addCommand(
          new Command() {
            @Override
            public void execute() {
              saveSettings(command);
            }
          });
    } else if (!loaded) {
      // Do not save settings that have not been loaded. We should
      // only wind up in this state if we are in the early phases of
      // loading the App Inventor client code. If saveSettings is
      // called in this state, it is from the onWindowClosing
      // handler. We do *not* want to over-write a persons valid
      // settings with this empty version, so we just return.
      return;

    } else {
      String s = encodeSettings();
      OdeLog.log("Saving global settings: " + s);
      Ode.getInstance()
          .getUserInfoService()
          .storeUserSettings(
              s,
              new OdeAsyncCallback<Void>(
                  // failure message
                  MESSAGES.settingsSaveError()) {
                @Override
                public void onSuccess(Void result) {
                  if (command != null) {
                    command.execute();
                  }
                }
              });
    }
  }
コード例 #18
0
 private void replHardReset() {
   DesignToolbar.DesignProject currentProject =
       Ode.getInstance().getDesignToolbar().getCurrentProject();
   if (currentProject == null) {
     OdeLog.wlog("DesignToolbar.currentProject is null. " + "Ignoring attempt to do hard reset.");
     return;
   }
   DesignToolbar.Screen screen = currentProject.screens.get(currentProject.currentScreen);
   ((YaBlocksEditor) screen.blocksEditor).hardReset();
   updateConnectToDropDownButton(false, false, false);
 }
コード例 #19
0
  private void refreshTable(boolean needToSort) {
    if (needToSort) {
      // Sort the projects.
      Comparator<Project> comparator;
      switch (sortField) {
        default:
        case NAME:
          comparator =
              (sortOrder == SortOrder.ASCENDING)
                  ? ProjectComparators.COMPARE_BY_NAME_ASCENDING
                  : ProjectComparators.COMPARE_BY_NAME_DESCENDING;
          break;
        case DATE_CREATED:
          comparator =
              (sortOrder == SortOrder.ASCENDING)
                  ? ProjectComparators.COMPARE_BY_DATE_CREATED_ASCENDING
                  : ProjectComparators.COMPARE_BY_DATE_CREATED_DESCENDING;
          break;
        case DATE_MODIFIED:
          comparator =
              (sortOrder == SortOrder.ASCENDING)
                  ? ProjectComparators.COMPARE_BY_DATE_MODIFIED_ASCENDING
                  : ProjectComparators.COMPARE_BY_DATE_MODIFIED_DESCENDING;
          break;
      }
      Collections.sort(projects, comparator);
    }

    refreshSortIndicators();

    // Refill the table.
    table.resize(1 + projects.size(), 5);
    int row = 1;
    for (Project project : projects) {
      ProjectWidgets pw = projectWidgets.get(project);
      if (selectedProjects.contains(project)) {
        table.getRowFormatter().setStyleName(row, "ode-ProjectRowHighlighted");
        pw.checkBox.setValue(true);
      } else {
        table.getRowFormatter().setStyleName(row, "ode-ProjectRowUnHighlighted");
        pw.checkBox.setValue(false);
      }
      table.setWidget(row, 0, pw.checkBox);
      table.setWidget(row, 1, pw.nameLabel);
      table.setWidget(row, 2, pw.dateCreatedLabel);
      table.setWidget(row, 3, pw.dateModifiedLabel);
      table.setWidget(row, 4, pw.editButton);
      preparePublishApp(project, pw);
      row++;
    }

    Ode.getInstance().getProjectToolbar().updateButtons();
  }
コード例 #20
0
 private void doDeleteGalleryApp(final long galleryId) {
   Ode.getInstance()
       .getGalleryService()
       .deleteApp(
           galleryId,
           new OdeAsyncCallback<Void>(
               // failure message
               MESSAGES.galleryDeleteError()) {
             @Override
             public void onSuccess(Void result) {
               // need to update gallery list
             }
           });
 }
コード例 #21
0
 @Override
 public void execute() {
   if (currentProject == null) {
     OdeLog.wlog(
         "DesignToolbar.currentProject is null. "
             + "Ignoring SwitchToFormEditorAction.execute().");
     return;
   }
   if (currentView != View.FORM) {
     long projectId = Ode.getInstance().getCurrentYoungAndroidProjectRootNode().getProjectId();
     switchToScreen(projectId, currentProject.currentScreen, View.FORM);
     toggleEditor(false); // Gray out the Designer button and enable the blocks button
   }
 }
コード例 #22
0
ファイル: ProjectToolbar.java プロジェクト: JDub20/CodeBlocks
  /** Initializes and assembles all commands into buttons in the toolbar. */
  public ProjectToolbar() {
    super();

    addButton(new ToolbarItem(WIDGET_NAME_NEW, MESSAGES.newButton(), new NewAction()));

    addButton(new ToolbarItem(WIDGET_NAME_DELETE, MESSAGES.deleteButton(), new DeleteAction()));

    addButton(
        new ToolbarItem(
            WIDGET_NAME_DOWNLOAD_ALL, MESSAGES.downloadAllButton(), new DownloadAllAction()));

    List<ToolbarItem> otherItems = Lists.newArrayList();
    otherItems.add(
        new ToolbarItem(
            WIDGET_NAME_DOWNLOAD_SOURCE,
            MESSAGES.downloadSourceButton(),
            new DownloadSourceAction()));
    otherItems.add(
        new ToolbarItem(
            WIDGET_NAME_UPLOAD_SOURCE, MESSAGES.uploadSourceButton(), new UploadSourceAction()));
    otherItems.add(null);
    otherItems.add(
        new ToolbarItem(
            WIDGET_NAME_DOWNLOAD_KEYSTORE,
            MESSAGES.downloadKeystoreButton(),
            new DownloadKeystoreAction()));
    otherItems.add(
        new ToolbarItem(
            WIDGET_NAME_UPLOAD_KEYSTORE,
            MESSAGES.uploadKeystoreButton(),
            new UploadKeystoreAction()));
    otherItems.add(
        new ToolbarItem(
            WIDGET_NAME_DELETE_KEYSTORE,
            MESSAGES.deleteKeystoreButton(),
            new DeleteKeystoreAction()));
    addDropDownButton(WIDGET_NAME_MORE_ACTIONS, MESSAGES.moreActionsButton(), otherItems);
    if (Ode.getInstance().getUser().getIsAdmin()) {
      List<ToolbarItem> adminItems = Lists.newArrayList();
      adminItems.add(
          new ToolbarItem(
              WIDGET_NAME_DOWNLOAD_USER_SOURCE,
              MESSAGES.downloadUserSourceButton(),
              new DownloadUserSourceAction()));
      addDropDownButton(WIDGET_NAME_ADMIN, MESSAGES.adminButton(), adminItems);
    }
    updateKeystoreButtons();
    updateButtons();
  }
コード例 #23
0
    BarcodeDialogBox(String projectName, String appInstallUrl) {
      super(false, true);
      setStylePrimaryName("ode-DialogBox");
      setText(MESSAGES.barcodeTitle(projectName));

      ClickHandler buttonHandler =
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              hide();
            }
          };

      Button cancelButton = new Button(MESSAGES.cancelButton());
      cancelButton.addClickHandler(buttonHandler);
      Button okButton = new Button(MESSAGES.okButton());
      okButton.addClickHandler(buttonHandler);
      Image barcodeImage = new Image(appInstallUrl);
      HorizontalPanel buttonPanel = new HorizontalPanel();
      buttonPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
      HTML warningLabel =
          new HTML(
              MESSAGES.barcodeWarning(
                  Ode.getInstance().getUser().getUserEmail(),
                  "<a href=\""
                      + Ode.APP_INVENTOR_DOCS_URL
                      + "/learn/userfaq.html\" target=\"_blank\">",
                  "</a>"));
      warningLabel.setWordWrap(true);
      warningLabel.setWidth("200px"); // set width to get the text to wrap
      HorizontalPanel warningPanel = new HorizontalPanel();
      warningPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT);
      warningPanel.add(warningLabel);

      // The cancel button is removed from the panel since it has no meaning in this
      // context.  But the logic is still here in case we want to restore it, and as
      // an example of how to code this stuff in GWT.
      // buttonPanel.add(cancelButton);
      buttonPanel.add(okButton);
      buttonPanel.setSize("100%", "24px");
      VerticalPanel contentPanel = new VerticalPanel();
      contentPanel.add(barcodeImage);
      contentPanel.add(buttonPanel);
      contentPanel.add(warningPanel);
      //      contentPanel.setSize("320px", "100%");
      add(contentPanel);
    }
コード例 #24
0
  @Override
  public void execute(final ProjectNode node) {
    final MessagesOutput messagesOutput = MessagesOutput.getMessagesOutput();
    messagesOutput.addMessages(MESSAGES.downloadingToPhoneMessage());

    final RpcStatusPopup rpcStatusPopup = Ode.getInstance().getRpcStatusPopup();

    AsyncCallback<Void> callback =
        new AsyncCallback<Void>() {
          @Override
          public void onFailure(Throwable caught) {
            rpcStatusPopup.onFailure(FAKE_RPC_NAME, caught);
            ErrorReporter.reportError(MESSAGES.downloadToPhoneFailedMessage());
            executionFailedOrCanceled();
          }

          @Override
          public void onSuccess(Void result) {
            rpcStatusPopup.onSuccess(FAKE_RPC_NAME, result);
            Window.alert(MESSAGES.downloadToPhoneSucceededMessage());
            executeNextCommand(node);
          }
        };

    String packageName;
    if (node instanceof YoungAndroidProjectNode) {
      YoungAndroidProjectNode yaNode = (YoungAndroidProjectNode) node;
      packageName = yaNode.getPackageNode().getPackageName();
    } else {
      ErrorReporter.reportError(MESSAGES.downloadToPhoneFailedMessage());
      executionFailedOrCanceled();
      return;
    }

    rpcStatusPopup.onStart(FAKE_RPC_NAME);
    String apkFilePath =
        BUILD_FOLDER
            + "/"
            + YoungAndroidProjectNode.YOUNG_ANDROID_TARGET_ANDROID
            + "/"
            + node.getName()
            + ".apk";
    CodeblocksManager.getCodeblocksManager()
        .installApplication(apkFilePath, node.getName(), packageName, callback);
  }
コード例 #25
0
  public ComponentHelpWidget(final SimpleComponentDescriptor scd) {
    if (imageResource == null) {
      Images images = Ode.getImageBundle();
      imageResource = images.help();
    }
    AbstractImagePrototype.create(imageResource).applyTo(this);
    addClickListener(
        new ClickListener() {
          @Override
          public void onClick(Widget sender) {
            final long MINIMUM_MS_BETWEEN_SHOWS = 250; // .25 seconds

            if (System.currentTimeMillis() - lastClosureTime >= MINIMUM_MS_BETWEEN_SHOWS) {
              new ComponentHelpPopup(scd, sender);
            }
          }
        });
  }
コード例 #26
0
 @Override
 public void execute() {
   ProjectRootNode projectRootNode = Ode.getInstance().getCurrentYoungAndroidProjectRootNode();
   if (projectRootNode != null) {
     String target = YoungAndroidProjectNode.YOUNG_ANDROID_TARGET_ANDROID;
     ChainableCommand cmd = new SaveAllEditorsCommand(new GenerateYailCommand(null));
     // updateBuildButton(true);
     cmd.startExecuteChain(
         Tracking.PROJECT_ACTION_BUILD_YAIL_YA,
         projectRootNode,
         new Command() {
           @Override
           public void execute() {
             // updateBuildButton(false);
           }
         });
   }
 }
コード例 #27
0
 @Override
 protected void execute(final ProjectNode node) {
   Ode.getInstance()
       .getEditorManager()
       .generateYailForBlocksEditors(
           new Command() {
             @Override
             public void execute() {
               executeNextCommand(node);
             }
           },
           new Command() {
             @Override
             public void execute() {
               executionFailedOrCanceled();
             }
           });
 }
コード例 #28
0
 private void doDeleteProject(final long projectId) {
   Ode.getInstance()
       .getProjectService()
       .deleteProject(
           projectId,
           new OdeAsyncCallback<Void>(
               // failure message
               MESSAGES.deleteProjectError()) {
             @Override
             public void onSuccess(Void result) {
               Ode.getInstance().getProjectManager().removeProject(projectId);
               // Show a welcome dialog in case there are no
               // projects saved.
               if (Ode.getInstance().getProjectManager().getProjects().size() == 0) {
                 Ode.getInstance().createNoProjectsDialog(true);
               }
             }
           });
 }
コード例 #29
0
  /** Enables or disables buttons based on whether the user has an android.keystore file. */
  public void updateKeystoreFileMenuButtons() {
    Ode.getInstance()
        .getUserInfoService()
        .hasUserFile(
            StorageUtil.ANDROID_KEYSTORE_FILENAME,
            new AsyncCallback<Boolean>() {
              @Override
              public void onSuccess(Boolean keystoreFileExists) {
                fileDropDown.setItemEnabled(MESSAGES.deleteKeystoreButton(), keystoreFileExists);
                fileDropDown.setItemEnabled(MESSAGES.downloadKeystoreButton(), keystoreFileExists);
              }

              @Override
              public void onFailure(Throwable caught) {
                // Enable the buttons. If they are clicked, we'll check again if the keystore
                // exists.
                fileDropDown.setItemEnabled(MESSAGES.deleteKeystoreButton(), true);
                fileDropDown.setItemEnabled(MESSAGES.downloadKeystoreButton(), true);
              }
            });
  }
コード例 #30
0
 /**
  * startRepl -- Start/Stop the connection to the companion.
  *
  * @param start -- true to start the repl, false to stop it.
  * @param forEmulator -- true if we are connecting to the emulator.
  * @param forUsb -- true if this is a USB connection.
  *     <p>If both forEmulator and forUsb are false, then we are connecting via Wireless.
  */
 private void startRepl(boolean start, boolean forEmulator, boolean forUsb) {
   DesignToolbar.DesignProject currentProject =
       Ode.getInstance().getDesignToolbar().getCurrentProject();
   if (currentProject == null) {
     OdeLog.wlog("DesignToolbar.currentProject is null. " + "Ignoring attempt to start the repl.");
     return;
   }
   DesignToolbar.Screen screen = currentProject.screens.get(currentProject.currentScreen);
   screen.blocksEditor.startRepl(!start, forEmulator, forUsb);
   if (start) {
     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 {
     updateConnectToDropDownButton(false, false, false);
   }
 }