コード例 #1
0
 private void ok() {
   if (Const.isEmpty(wStepname.getText())) {
     return;
   }
   getMeta(joinMeta);
   // Show a warning (optional)
   if ("Y".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y"))) {
     MessageDialogWithToggle md =
         new MessageDialogWithToggle(
             shell,
             BaseMessages.getString(PKG, "MultiMergeJoinDialog.InputNeedSort.DialogTitle"),
             null,
             BaseMessages.getString(
                     PKG, "MultiMergeJoinDialog.InputNeedSort.DialogMessage", Const.CR)
                 + Const.CR,
             MessageDialog.WARNING,
             new String[] {
               BaseMessages.getString(PKG, "MultiMergeJoinDialog.InputNeedSort.Option1")
             },
             0,
             BaseMessages.getString(PKG, "MultiMergeJoinDialog.InputNeedSort.Option2"),
             "N".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y")));
     MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
     md.open();
     props.setCustomParameter(STRING_SORT_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y");
     props.saveProps();
   }
   stepname = wStepname.getText(); // return value
   dispose();
 }
コード例 #2
0
  public Object execute(ExecutionEvent event) throws ExecutionException {

    DBSelection dbSel = new DBSelection(HandlerUtil.getCurrentSelection(event));

    ElementDBNode sel = dbSel.getSel();
    if (sel == null) {
      Logger.warn("nothing selected in the design browser, nothing to report");
      return null;
    }
    String selName = (sel instanceof ModelDBNode) ? "/" : ((InstanceDBNode) sel).getInstPath();

    MessageDialogWithToggle dialog =
        new MessageDialogWithToggle(
            HandlerUtil.getActiveShell(event),
            "Report type",
            null,
            "After clicking OK, the states of the current model are applied successively; "
                + "the currents found in each state are stored in a PowerPoint document ",
            MessageDialog.INFORMATION,
            new String[] {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL},
            0,
            "generate a power report instead",
            false);

    if (dialog.open() == Window.OK) {

      IScriptService interpreter = ScriptRegistry.instance.interpreter(SCRIPT_LANGAGE.TCL);

      try {
        interpreter.eval(
            "package require ms_report; ms_report::ppa_report "
                + selName
                + " "
                + (dialog.getToggleState() ? "power" : "current"),
            SCR_LOG_TYPE.PRINT_TRANSCRIPT);
      } catch (ScriptServiceException e) {
        ViewUtils.setErrorMessage("report generation failed", true);
      }
    }

    return null;
  }
コード例 #3
0
ファイル: Utils.java プロジェクト: eclipse/jubula.core
 /**
  * Opens a perspective with the given ID.
  *
  * @param perspectiveID The ID of the perspective to open.
  * @return True, if the user wants to change the perspective, false otherwise.
  */
 public static boolean openPerspective(String perspectiveID) {
   IWorkbench worbench = PlatformUI.getWorkbench();
   IWorkbenchWindow activeWindow = worbench.getActiveWorkbenchWindow();
   try {
     IPerspectiveDescriptor activePerspective = getActivePerspective(activeWindow.getActivePage());
     if (activePerspective != null && activePerspective.getId().equals(perspectiveID)) {
       return true;
     }
     final IPreferenceStore preferenceStore = Plugin.getDefault().getPreferenceStore();
     int value = preferenceStore.getInt(Constants.PERSP_CHANGE_KEY);
     if (value == Constants.PERSPECTIVE_CHANGE_YES) {
       worbench.showPerspective(perspectiveID, activeWindow);
       return true;
     } else if (value == Constants.PERSPECTIVE_CHANGE_NO) {
       return true;
     }
     // if --> value = Constants.PERSPECTIVE_CHANGE_PROMPT:
     String perspectiveName = StringConstants.EMPTY;
     if (perspectiveID.equals(Constants.SPEC_PERSPECTIVE)) {
       perspectiveName = Messages.UtilsSpecPerspective;
     } else {
       perspectiveName = Messages.UtilsExecPerspective;
     }
     final int returnCodeYES = 256; // since Eclipse3.2 (not 0)
     final int returnCodeNO = 257; // since Eclipse3.2 (not 1)
     final int returnCodeCANCEL = -1;
     MessageDialogWithToggle dialog =
         new MessageDialogWithToggle(
             activeWindow.getShell(),
             Messages.UtilsTitle,
             null,
             NLS.bind(Messages.UtilsQuestion, perspectiveName),
             MessageDialog.QUESTION,
             new String[] {Messages.UtilsYes, Messages.UtilsNo},
             0,
             Messages.UtilsRemember,
             false) {
           /** {@inheritDoc} */
           protected void buttonPressed(int buttonId) {
             super.buttonPressed(buttonId);
             preferenceStore.setValue(Constants.REMEMBER_KEY, getToggleState());
             int val = Constants.PERSPECTIVE_CHANGE_PROMPT;
             if (getToggleState() && getReturnCode() == returnCodeNO) {
               val = Constants.PERSPECTIVE_CHANGE_NO;
             } else if (getToggleState() && getReturnCode() == returnCodeYES) {
               val = Constants.PERSPECTIVE_CHANGE_YES;
             }
             preferenceStore.setValue(Constants.PERSP_CHANGE_KEY, val);
           }
         };
     dialog.create();
     DialogUtils.setWidgetNameForModalDialog(dialog);
     dialog.open();
     if (dialog.getReturnCode() == returnCodeNO) {
       return true;
     } else if (dialog.getReturnCode() == returnCodeCANCEL) {
       return false;
     }
     worbench.showPerspective(perspectiveID, activeWindow);
   } catch (WorkbenchException e) {
     StringBuilder msg = new StringBuilder();
     msg.append(Messages.CannotOpenThePerspective)
         .append(StringConstants.COLON)
         .append(StringConstants.SPACE)
         .append(perspectiveID)
         .append(StringConstants.LEFT_PARENTHESES)
         .append(e)
         .append(StringConstants.RIGHT_PARENTHESES)
         .append(StringConstants.DOT);
     log.error(msg.toString());
     ErrorHandlingUtil.createMessageDialog(MessageIDs.E_NO_PERSPECTIVE);
     return false;
   }
   return true;
 }
コード例 #4
0
ファイル: MakeTargetDndUtil.java プロジェクト: PARAG00991/cdt
  /**
   * Overwrite Make Target dialog.
   *
   * @param name - name of make target to display to a user.
   * @param shell - shell where to display the dialog.
   * @return user's answer.
   */
  private static int overwriteMakeTargetDialog(String name, Shell shell) {

    if (lastUserAnswer == IDialogConstants.YES_TO_ALL_ID
        || lastUserAnswer == IDialogConstants.NO_TO_ALL_ID
        || lastUserAnswer == RENAME_TO_ALL_ID) {

      return lastUserAnswer;
    }

    String labels[] =
        new String[] {
          IDialogConstants.YES_LABEL,
          IDialogConstants.NO_LABEL,
          MakeUIPlugin.getResourceString("MakeTargetDnD.button.rename"), // $NON-NLS-1$
          IDialogConstants.CANCEL_LABEL,
        };

    String title =
        MakeUIPlugin.getResourceString("MakeTargetDnD.title.overwriteTargetConfirm"); // $NON-NLS-1$
    String question =
        MessageFormat.format(
            MakeUIPlugin.getResourceString(
                "MakeTargetDnD.message.overwriteTargetConfirm"), //$NON-NLS-1$
            new Object[] {name});
    String toggleApplyToAll =
        MakeUIPlugin.getResourceString("MakeTargetDnD.toggle.applyToAll"); // $NON-NLS-1$

    MessageDialogWithToggle dialog =
        new MessageDialogWithToggle(
            shell,
            title,
            null,
            question,
            MessageDialog.QUESTION,
            labels,
            0,
            toggleApplyToAll,
            false);

    try {
      dialog.open();
      lastUserAnswer = dialog.getReturnCode();
      boolean toAll = dialog.getToggleState();
      if (toAll && lastUserAnswer == IDialogConstants.YES_ID) {
        lastUserAnswer = IDialogConstants.YES_TO_ALL_ID;
      } else if (toAll && lastUserAnswer == IDialogConstants.NO_ID) {
        lastUserAnswer = IDialogConstants.NO_TO_ALL_ID;
      } else if (toAll && lastUserAnswer == RENAME_ID) {
        lastUserAnswer = RENAME_TO_ALL_ID;
      }
    } catch (SWTException e) {
      MakeUIPlugin.log(e);
      lastUserAnswer = IDialogConstants.CANCEL_ID;
    }

    if (lastUserAnswer == SWT.DEFAULT) {
      // A window close returns SWT.DEFAULT, which has to be
      // mapped to a cancel
      lastUserAnswer = IDialogConstants.CANCEL_ID;
    }
    return lastUserAnswer;
  }
コード例 #5
0
    /**
     * @see
     *     org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
     */
    public void widgetSelected(SelectionEvent e) {

      Object source = e.getSource();
      // edit filter
      if (source == mBtnEditFilter) {

        ISelection selection = mFilterList.getSelection();
        openFilterEditor(selection);
        getContainer().updateButtons();
      }
      if (source == mMainTab) {
        mFileSetsEditor.refresh();
        getContainer().updateButtons();

      } else if (source == mChkSyncFormatter) {
        mProjectConfig.setSyncFormatter(mChkSyncFormatter.getSelection());
      } else if (source == mChkSimpleConfig) {
        try {

          mProjectConfig.setUseSimpleConfig(mChkSimpleConfig.getSelection());

          boolean showWarning =
              CheckstyleUIPluginPrefs.getBoolean(CheckstyleUIPluginPrefs.PREF_FILESET_WARNING);
          if (mProjectConfig.isUseSimpleConfig() && showWarning) {
            MessageDialogWithToggle dialog =
                new MessageDialogWithToggle(
                    getShell(),
                    Messages.CheckstylePropertyPage_titleWarnFilesets,
                    null,
                    Messages.CheckstylePropertyPage_msgWarnFilesets,
                    MessageDialogWithToggle.WARNING,
                    new String[] {IDialogConstants.OK_LABEL},
                    0,
                    Messages.CheckstylePropertyPage_mgsWarnFileSetNagOption,
                    showWarning) {
                  /**
                   * Overwritten because we don't want to store which button the user pressed but
                   * the state of the toggle.
                   *
                   * @see MessageDialogWithToggle#buttonPressed(int)
                   */
                  protected void buttonPressed(int buttonId) {
                    getPrefStore().setValue(getPrefKey(), getToggleState());
                    setReturnCode(buttonId);
                    close();
                  }
                };
            dialog.setPrefStore(CheckstyleUIPlugin.getDefault().getPreferenceStore());
            dialog.setPrefKey(CheckstyleUIPluginPrefs.PREF_FILESET_WARNING);
            dialog.open();
          }

          createFileSetsArea(mFileSetsContainer);
          mFileSetsContainer.redraw();
          mFileSetsContainer.update();
          mFileSetsContainer.layout();
        } catch (CheckstylePluginException ex) {
          CheckstyleUIPlugin.errorDialog(getShell(), Messages.errorChangingFilesetEditor, ex, true);
        }
      }
    }