Exemplo n.º 1
0
  /**
   * Create a new instance of the receiver on a status.
   *
   * @param status The status to display.
   */
  SafeRunnableDialog(IStatus status) {

    super(
        null,
        JFaceResources.getString("error"),
        status.getMessage(), // $NON-NLS-1$
        status,
        IStatus.ERROR);

    setShellStyle(
        SWT.DIALOG_TRIM | SWT.MODELESS | SWT.RESIZE | SWT.MIN | SWT.MAX | getDefaultOrientation());

    setStatus(status);
    statuses.add(status);

    setBlockOnOpen(false);

    String reason =
        JFaceResources.getString("SafeRunnableDialog_checkDetailsMessage"); // $NON-NLS-1$
    if (status.getException() != null) {
      reason =
          status.getException().getMessage() == null
              ? status.getException().toString()
              : status.getException().getMessage();
    }
    this.message =
        JFaceResources.format(
            "SafeRunnableDialog_reason",
            new Object[] { // $NON-NLS-1$
              status.getMessage(), reason
            });
  }
 /**
  * Save the values specified in the pages.
  *
  * <p>The default implementation of this framework method saves all pages of type <code>
  * PreferencePage</code> (if their store needs saving and is a <code>PreferenceStore</code>).
  *
  * <p>Subclasses may override.
  */
 protected void handleSave() {
   Iterator<IPreferenceNode> nodes =
       preferenceManager.getElements(PreferenceManager.PRE_ORDER).iterator();
   while (nodes.hasNext()) {
     IPreferenceNode node = nodes.next();
     IPreferencePage page = node.getPage();
     if (page instanceof PreferencePage) {
       // Save now in case tbe workbench does not shutdown cleanly
       IPreferenceStore store = ((PreferencePage) page).getPreferenceStore();
       if (store != null && store.needsSaving() && store instanceof IPersistentPreferenceStore) {
         try {
           ((IPersistentPreferenceStore) store).save();
         } catch (IOException e) {
           String message =
               JFaceResources.format(
                   "PreferenceDialog.saveErrorMessage",
                   page.getTitle(), // $NON-NLS-1$
                   e.getMessage());
           Policy.getStatusHandler()
               .show(
                   new Status(IStatus.ERROR, Policy.JFACE, message, e),
                   JFaceResources.getString("PreferenceDialog.saveErrorTitle")); // $NON-NLS-1$
         }
       }
     }
   }
 }
Exemplo n.º 3
0
  /**
   * Return the label for showing tasks
   *
   * @return String
   */
  private String taskLabel() {
    boolean hasTask = fTaskName != null && fTaskName.length() > 0;
    boolean hasSubtask = fSubTaskName != null && fSubTaskName.length() > 0;

    if (hasTask) {
      if (hasSubtask)
        return escapeMetaCharacters(
            JFaceResources.format(
                "Set_SubTask", new Object[] {fTaskName, fSubTaskName})); // $NON-NLS-1$
      return escapeMetaCharacters(fTaskName);

    } else if (hasSubtask) {
      return escapeMetaCharacters(fSubTaskName);

    } else {
      return ""; //$NON-NLS-1$
    }
  }
Exemplo n.º 4
0
 @Override
 public boolean performOk() {
   boolean isOk = super.performOk();
   if (isOk && corePreferences.needsSaving()) {
     try {
       corePreferences.save();
     } catch (IOException e) {
       String message =
           JFaceResources.format(
               "PreferenceDialog.saveErrorMessage",
               getTitle(), //$NON-NLS-1$
               e.getMessage());
       Policy.getStatusHandler()
           .show(
               new Status(IStatus.ERROR, Policy.JFACE, message, e),
               JFaceResources.getString("PreferenceDialog.saveErrorTitle")); // $NON-NLS-1$
     }
   }
   return isOk;
 }