示例#1
0
 /**
  * Show the preferences dialog
  *
  * @param shell The parent shell to use.
  */
 public void showPreferencesDialog(Shell shell) {
   PreferenceManager manager = new PreferenceManager();
   addPreferencePages(manager);
   PreferenceDialog dialog = new PreferenceDialog(shell, manager);
   dialog.setBlockOnOpen(true);
   dialog.open();
 }
 public Object execute(ExecutionEvent event) throws ExecutionException {
   Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
   PreferenceDialog preferenceDialog =
       PreferencesUtil.createPreferenceDialogOn(shell, getPreferenceId(), null, null);
   preferenceDialog.open();
   return null;
 }
示例#3
0
  public static IStatus connectWithPromptIfNeeded(IConnectionProfile profile, boolean reprompt) {
    String profileName = profile.getName();

    Shell shell = Display.getCurrent().getActiveShell();
    IStatus connectionStatus = null;
    ConnectionInfo info = null;
    if (profile != null) {
      if (shell == null) {
        connectionStatus = profile.connect();
      } else {
        connectionStatus = profile.connectWithoutJob();
        if (reprompt
            && profile.getConnectionState() != IConnectionProfile.CONNECTED_STATE
            && connectionStatus.getCode()
                != IStatus.OK) // could be marked OK if the profile can't be found for some reason
        {
          String title = NLS.bind(SQLNlsStrings.SQL_CONNECTION_FAILURE_MSG, profile.getName());
          MessageDialog.openInformation(
              shell, title, connectionStatus.getChildren()[0].getException().getLocalizedMessage());

          // Prompt to fix properties
          PropertyDialogAction propertyDialogAction =
              new PropertyDialogAction(
                  new SameShellProvider(shell),
                  new ConnectionPropertiesWizardSelectionProvider(profile));

          StructuredSelection selection = new StructuredSelection(profile);
          propertyDialogAction.selectionChanged(selection);
          if (!profile.arePropertiesComplete() && propertyDialogAction.isApplicableForSelection()) {
            // something in createDialog is failing to initialize the properties correctly the first
            // time
            // around. I can't debug it because it crashes the debugger when I set a breakpoint, so
            // I'll
            // call twice for now to get the initialization to happen until I figure it out.
            PreferenceDialog dialog = propertyDialogAction.createDialog();
            dialog = propertyDialogAction.createDialog();
            String shellText =
                NLS.bind(SQLNlsStrings.SQL_CONNECTION_PROPERTIES_FOR, profile.getName());
            dialog.getShell().setText(shellText);
            IConnectionProfileProvider provider = profile.getProvider();
            IPropertiesPersistenceHook hook =
                ((ConnectionProfileProvider) provider).getPropertiesPersistenceHook();
            String initialPage = hook.getConnectionPropertiesPageID();
            if (initialPage != null) {
              ((IWorkbenchPreferenceContainer) dialog).openPage(initialPage, null);
            }
            if (dialog.open() == Dialog.CANCEL) {
              reprompt = false;
            }
          }
          if (reprompt) {
            connectionStatus = profile.connectWithoutJob();
          }
        }
      }
    }

    return connectionStatus;
  }
示例#4
0
 /* (non-Javadoc)
  * Method declared on Action.
  */
 public void run() {
   if (workbenchWindow == null) {
     // action has been dispose
     return;
   }
   PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(null, null, null, null);
   dialog.open();
 }
 @Override
 public void handle() {
   PreferenceDialog propertyDialog =
       PreferencesUtil.createPropertyDialogOn(
           getShell(), requireSelection(ProjectSpace.class).getProject(), null, null, null);
   if (propertyDialog != null) {
     propertyDialog.open();
   }
 }
 /**
  * Opens the network preferences page
  *
  * @return true if the user has confirmed the network configurations or false otherwise
  */
 private boolean openNetworkPreferencesPage() {
   // Creates the dialog every time, because it is disposed when it is
   // closed.
   networkPreferencesDialog = new WorkbenchPreferenceDialog(this.getShell(), prefMan);
   networkPreferencesDialog.create();
   centralizeShell(networkPreferencesDialog.getShell());
   networkPreferencesDialog.open();
   return networkPreferencesDialog.getReturnCode() == WorkbenchPreferenceDialog.OK;
 }
    protected void openPreferencePage() {
      PreferenceDialog pref =
          PreferencesUtil.createPreferenceDialogOn(
              getShell(), LangUIPlugin_Actual.ROOT_PREF_PAGE_ID, null, null);

      if (pref != null) {
        pref.open();
        updateComponentFromInput();
      }
    }
 public static void bowerLocationNotDefined() {
   boolean define =
       MessageDialog.openQuestion(
           Display.getDefault().getActiveShell(),
           Messages.BowerErrorHandler_BowerNotDefinedTitle,
           Messages.BowerErrorHandler_BowerNotDefinedMessage);
   if (define) {
     PreferenceDialog dialog =
         PreferencesUtil.createPreferenceDialogOn(
             Display.getDefault().getActiveShell(), BowerPreferencePage.PAGE_ID, null, null);
     dialog.open();
   }
 }
示例#9
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;
  }
  protected void configureSDKsLinkSelected(SelectionEvent e) {
    // boolean noSDKs = SDKManager.getAllSDKs().length == 0;

    String[] id = new String[] {SDKsPreferencePage.ID};

    PreferenceDialog dialog =
        PreferencesUtil.createPreferenceDialogOn(this.getShell(), SDKsPreferencePage.ID, id, null);

    int retval = dialog.open();

    if (retval == Window.OK) {
      getContainer().updateButtons();
    }
  }
  /**
   * Opens the properties dialog for the given breakpoint. This method can be used on an existing
   * breakpoint or on a blank breakpoint which doesn't have an associated marker yet.
   *
   * @param bp The breakpoint to edit. This breakpoint may not have an associated marker yet.
   * @param part Workbench part where the action was invoked.
   * @param resource Workbench resource to create the breakpoint on.
   * @param attributes Breakpoint attributes to show in properties dialog. If the breakpoint already
   *     exists, this attribute map can be used to override the attributes currently in the
   *     breakpoint. Can be <code>null</code>.
   */
  protected void openBreakpointPropertiesDialog(
      ICBreakpoint bp, IWorkbenchPart part, IResource resource, Map<String, Object> attributes) {
    ISelection debugContext =
        DebugUITools.getDebugContextManager()
            .getContextService(part.getSite().getWorkbenchWindow())
            .getActiveContext(part.getSite().getId());
    CBreakpointContext bpContext = new CBreakpointContext(bp, debugContext, resource, attributes);

    PreferenceDialog dialog =
        PreferencesUtil.createPropertyDialogOn(
            part.getSite().getShell(), bpContext, null, null, null);
    if (dialog != null) {
      dialog.open();
    }
  }
示例#12
0
 public static void showPreferencesFor(Shell shell, Object element, String defPageID) {
   PreferenceDialog propDialog;
   if (element == null) {
     propDialog =
         PreferencesUtil.createPreferenceDialogOn(
             shell, defPageID, new String[] {defPageID}, null, PreferencesUtil.OPTION_NONE);
   } else {
     propDialog =
         PreferencesUtil.createPropertyDialogOn(
             shell, element, defPageID, null, null, PreferencesUtil.OPTION_NONE);
   }
   if (propDialog != null) {
     propDialog.open();
   }
 }
示例#13
0
  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {

    IEditorPart iworkbench =
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    if (iworkbench != null) {
      IEditorInput input = iworkbench.getEditorInput();
      IFile res = ((IFileEditorInput) input).getFile();
      Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
      PreferenceDialog x =
          PreferencesUtil.createPropertyDialogOn(
              shell,
              res.getProject(),
              ProjectModelsPage.ID,
              new String[] {ProjectModelsPage.ID},
              Collections.EMPTY_MAP);
      x.open();
    }
    return null;
  }
 @Execute
 public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell) {
   PreferenceManager pm = createPreferenceManager();
   PreferenceDialog dialog = new PreferenceDialog(shell, pm);
   dialog.open();
 }
  /**
   * 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;
  }