/** Updates this dialog's controls to reflect the current page. */
 protected void update() {
   // Update the title bar
   updateTitle();
   // Update the message line
   updateMessage();
   // Update the buttons
   updateButtons();
   // Saved the selected node in the preferences
   setSelectedNode();
   firePageChanged(new PageChangedEvent(this, getCurrentPage()));
 }
예제 #2
0
  public boolean openConfigDialog(Shell parentShell, String pageId) {
    PreferenceManager manager = new PreferenceManager();

    PreferenceNode profile =
        new PreferenceNode(UserProfilePage.PAGE_ID, new UserProfilePage(iniUserProfile));
    manager.addToRoot(profile);
    PreferenceNode setting =
        new PreferenceNode(MiscSettingPage.PAGE_ID, new MiscSettingPage(iniSettings));
    manager.addToRoot(setting);
    PreferenceNode appearance =
        new PreferenceNode(AppearancePage.PAGE_ID, new AppearancePage(this));
    manager.addToRoot(appearance);

    for (IPreferenceNodeProvider p : preferenceNodeProviders)
      manager.addToRoot(p.createPreferenceNode());

    PreferenceDialog dialog =
        new PreferenceDialog(parentShell, manager) {
          @Override
          protected void configureShell(Shell newShell) {
            super.configureShell(newShell);
            newShell.setText("設定");
            newShell.setImage(imageRegistry.get(ICON_TOOLBAR_CONFIG));
          }

          @Override
          protected Composite createTitleArea(Composite parent) {
            Composite composite = super.createTitleArea(parent);
            FormLayout layout = (FormLayout) composite.getLayout();
            layout.marginTop = 4;
            return composite;
          }
        };

    if (pageId != null) dialog.setSelectedNode(pageId);

    switch (dialog.open()) {
      case IDialogConstants.OK_ID:
        try {
          iniSettingFile.saveToIni();

          wlanLibrary = iniSettings.getWlanLibrary();
          updateWlanLibraryStatus();
          return true;
        } catch (IOException e) {
          arenaWindow.appendToSystemLog(Utility.stackTraceToString(e), true);
          e.printStackTrace();
        }
    }
    return false;
  }
  /**
   * Method creates tree structure of windows azure property pages. and opens property dialog with
   * desired property page selected & active.
   *
   * @param windowsAzureRole : worker role
   * @param pageToDisplay : property page Id which should be active after opening dialog
   * @return integer
   */
  public static int openRolePropertyDialog(
      WindowsAzureRole windowsAzureRole, String pageToDisplay) {
    int retVal = Window.CANCEL; // value corresponding to cancel
    try {
      // Node creation
      PreferenceNode nodeGeneral =
          new PreferenceNode(
              Messages.cmhIdGeneral, Messages.cmhLblGeneral, null, WARGeneral.class.toString());
      nodeGeneral.setPage(new WARGeneral());
      nodeGeneral.getPage().setTitle(Messages.cmhLblGeneral);

      PreferenceNode nodeCache =
          new PreferenceNode(
              Messages.cmhIdCach, Messages.cmhLblCach, null, WARCaching.class.toString());
      nodeCache.setPage(new WARCaching());
      nodeCache.getPage().setTitle(Messages.cmhLblCach);

      PreferenceNode nodeCmpnts =
          new PreferenceNode(
              Messages.cmhIdCmpnts, Messages.cmhLblCmpnts, null, WARComponents.class.toString());
      nodeCmpnts.setPage(new WARComponents());
      nodeCmpnts.getPage().setTitle(Messages.cmhLblCmpnts);

      PreferenceNode nodeDebugging =
          new PreferenceNode(
              Messages.cmhIdDbg, Messages.cmhLblDbg, null, WARDebugging.class.toString());
      nodeDebugging.setPage(new WARDebugging());
      nodeDebugging.getPage().setTitle(Messages.cmhLblDbg);

      PreferenceNode nodeEndPts =
          new PreferenceNode(
              Messages.cmhIdEndPts, Messages.cmhLblEndPts, null, WAREndpoints.class.toString());
      nodeEndPts.setPage(new WAREndpoints());
      nodeEndPts.getPage().setTitle(Messages.cmhLblEndPts);

      PreferenceNode nodeEnvVars =
          new PreferenceNode(
              Messages.cmhIdEnvVars, Messages.cmhLblEnvVars, null, WAREnvVars.class.toString());
      nodeEnvVars.setPage(new WAREnvVars());
      nodeEnvVars.getPage().setTitle(Messages.cmhLblEnvVars);

      PreferenceNode nodeLdBlnc =
          new PreferenceNode(
              Messages.cmhIdLdBlnc, Messages.cmhLblLdBlnc, null, WARLoadBalance.class.toString());
      nodeLdBlnc.setPage(new WARLoadBalance());
      nodeLdBlnc.getPage().setTitle(Messages.cmhLblLdBlnc);

      PreferenceNode nodeLclStg =
          new PreferenceNode(
              Messages.cmhIdLclStg, Messages.cmhLblLclStg, null, WARLocalStorage.class.toString());
      nodeLclStg.setPage(new WARLocalStorage());
      nodeLclStg.getPage().setTitle(Messages.cmhLblLclStg);

      PreferenceNode nodeSrvCnfg =
          new PreferenceNode(
              Messages.cmhIdSrvCnfg,
              Messages.cmhLblSrvCnfg,
              null,
              WAServerConfiguration.class.toString());
      nodeSrvCnfg.setPage(new WAServerConfiguration());
      nodeSrvCnfg.getPage().setTitle(Messages.cmhLblSrvCnfg);

      /*
       * Tree structure creation.
       * Don't change order while adding nodes.
       * Its the default alphabetical order given by eclipse.
       */
      nodeGeneral.add(nodeCache);
      nodeGeneral.add(nodeCmpnts);
      nodeGeneral.add(nodeDebugging);
      nodeGeneral.add(nodeEndPts);
      nodeGeneral.add(nodeEnvVars);
      nodeGeneral.add(nodeLdBlnc);
      nodeGeneral.add(nodeLclStg);
      nodeGeneral.add(nodeSrvCnfg);

      PreferenceManager mgr = new PreferenceManager();
      mgr.addToRoot(nodeGeneral);
      // Dialog creation
      PreferenceDialog dialog =
          new PreferenceDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), mgr);
      // make desired property page active.
      dialog.setSelectedNode(pageToDisplay);
      dialog.create();
      String dlgTitle = String.format(Messages.cmhPropFor, windowsAzureRole.getName());
      dialog.getShell().setText(dlgTitle);
      dialog.open();
      // return whether user has pressed OK or Cancel button
      retVal = dialog.getReturnCode();
    } catch (Exception ex) {
      PluginUtil.displayErrorDialogAndLog(
          new Shell(), Messages.rolsDlgErr, Messages.rolsDlgErrMsg, ex);
    }
    return retVal;
  }