/**
   * @param filters
   * @return <code>true</code> if the transfer was succesful, and <code>false</code> otherwise
   */
  protected boolean transfer(IPreferenceFilter[] filters) {
    File importFile = new File(getDestinationValue());
    FileInputStream fis = null;
    try {
      if (filters.length > 0) {
        try {
          fis = new FileInputStream(importFile);
        } catch (FileNotFoundException e) {
          WorkbenchPlugin.log(e.getMessage(), e);
          MessageDialog.open(
              MessageDialog.ERROR,
              getControl().getShell(),
              new String(),
              e.getLocalizedMessage(),
              SWT.SHEET);
          return false;
        }
        IPreferencesService service = Platform.getPreferencesService();
        try {
          IExportedPreferences prefs = service.readPreferences(fis);

          service.applyPreferences(prefs, filters);
        } catch (CoreException e) {
          WorkbenchPlugin.log(e.getMessage(), e);
          MessageDialog.open(
              MessageDialog.ERROR,
              getControl().getShell(),
              new String(),
              e.getLocalizedMessage(),
              SWT.SHEET);
          return false;
        }
      }
    } finally {
      if (fis != null) {
        try {
          fis.close();
        } catch (IOException e) {
          WorkbenchPlugin.log(e.getMessage(), e);
          MessageDialog.open(
              MessageDialog.ERROR,
              getControl().getShell(),
              new String(),
              e.getLocalizedMessage(),
              SWT.SHEET);
        }
      }
    }
    return true;
  }
Example #2
0
 public static boolean saveDirtyFiles(String mask) {
   boolean result = true;
   // TODO (cs) add support for save automatically
   Shell shell = Display.getCurrent().getActiveShell();
   IEditorPart[] dirtyEditors = getDirtyEditors(mask);
   if (dirtyEditors.length > 0) {
     result = false;
     SaveDirtyFilesDialog saveDirtyFilesDialog = new SaveDirtyFilesDialog(shell);
     saveDirtyFilesDialog.setInput(Arrays.asList(dirtyEditors));
     // Save all open editors.
     if (saveDirtyFilesDialog.open() == Window.OK) {
       result = true;
       int numDirtyEditors = dirtyEditors.length;
       for (int i = 0; i < numDirtyEditors; i++) {
         dirtyEditors[i].doSave(null);
       }
     } else {
       MessageDialog dlg =
           new MessageDialog(
               shell,
               Messages.SaveDirtyFilesDialog_title_error,
               null,
               ALL_MODIFIED_RESOURCES_MUST_BE_SAVED_BEFORE_THIS_OPERATION,
               MessageDialog.ERROR,
               new String[] {IDialogConstants.OK_LABEL},
               0);
       dlg.open();
     }
   }
   return result;
 }
  private void populateTableWithTupleTemplate() {
    Table table = m_fieldsView.table;

    Set<String> existingRowAliases = new HashSet<String>();
    for (int i = 0; i < table.getItemCount(); i++) {
      TableItem tableItem = table.getItem(i);
      String alias = tableItem.getText(1);
      if (!Const.isEmpty(alias)) {
        existingRowAliases.add(alias);
      }
    }

    int choice = 0;
    if (existingRowAliases.size() > 0) {
      // Ask what we should do with existing mapping data
      MessageDialog md =
          new MessageDialog(
              m_shell,
              Messages.getString("MappingDialog.GetFieldsChoice.Title"),
              null,
              Messages.getString(
                  "MappingDialog.GetFieldsChoice.Message", "" + existingRowAliases.size(), "" + 5),
              MessageDialog.WARNING,
              new String[] {
                Messages.getString("MappingOutputDialog.ClearAndAdd"),
                Messages.getString("MappingOutputDialog.Cancel"),
              },
              0);
      MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
      int idx = md.open();
      choice = idx & 0xFF;
    }

    if (choice == 1 || choice == 255 /* 255 = escape pressed */) {
      return; // Cancel
    }

    m_fieldsView.clearAll();
    TableItem item = new TableItem(table, SWT.NONE);
    item.setText(1, "KEY");
    item.setText(2, "Y");
    item = new TableItem(table, SWT.NONE);
    item.setText(1, "Family");
    item.setText(2, "N");
    item.setText(5, "String");
    item = new TableItem(table, SWT.NONE);
    item.setText(1, "Column");
    item.setText(2, "N");
    item = new TableItem(table, SWT.NONE);
    item.setText(1, "Value");
    item.setText(2, "N");
    item = new TableItem(table, SWT.NONE);
    item.setText(1, "Timestamp");
    item.setText(2, "N");
    item.setText(5, "Long");

    m_fieldsView.removeEmptyRows();
    m_fieldsView.setRowNums();
    m_fieldsView.optWidth(true);
  }
Example #4
0
 private boolean openSaveDialog() {
   if (getModel() != null && !getModel().exists()) {
     return true;
   }
   MessageDialog dialog =
       new MessageDialog(
           getShell(),
           Messages.ControlPanelWindow_SaveDialogTitle,
           null,
           Messages.ControlPanelWindow_SaveDialogMsg,
           MessageDialog.QUESTION_WITH_CANCEL,
           new String[] {
             IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL
           },
           0);
   int returnCode = dialog.open(); // Number of pressed button
   if (returnCode == 0) {
     if (getModel() != null) {
       save();
     } else {
       if (!saveAs()) {
         return false;
       }
     }
   }
   switch (returnCode) {
     case 2:
       return false; // User clicked Cancel button
     default:
       return true;
   }
 }
  @Before
  public void setUp() throws Exception {
    when(spoon.getActiveTransformation()).thenReturn(transMeta);
    when(spoon.getShell()).thenReturn(shell);
    when(uiFactory.getMessageBox(any(Shell.class), anyInt())).thenReturn(messageBox);
    when(uiFactory.getShell(shell)).thenReturn(shell);
    when(uiFactory.getDataServiceTestDialog(
            any(Shell.class), any(DataServiceMeta.class), any(DataServiceContext.class)))
        .thenReturn(dataServiceTestDialog);
    when(uiFactory.getMessageDialog(
            any(Shell.class),
            anyString(),
            any(Image.class),
            anyString(),
            anyInt(),
            any(String[].class),
            anyInt()))
        .thenReturn(messageDialog);
    when(messageDialog.open()).thenReturn(0);

    delegate = new DataServiceDelegate(context, spoon);

    when(uiFactory.getDataServiceDialogBuilder(transMeta)).thenReturn(dialogBuilder);
    when(dialogBuilder.serviceStep(STEP_NAME)).thenReturn(dialogBuilder);
    when(dialogBuilder.edit(dataService)).thenReturn(dialogBuilder);
    when(dialogBuilder.build(delegate)).thenReturn(dataServiceDialog);
  }
  @Inject
  public void setSelection(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) Contact contact) {
    if (contact != null) {
      if (dirtyable.isDirty()) {
        MessageDialog dialog =
            new MessageDialog(
                detailComposite.getShell(),
                "Save vCard",
                null,
                "The current vCard has been modified. Save changes?",
                MessageDialog.CONFIRM,
                new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL},
                0);
        dialog.create();
        ThemeUtil.applyDialogStyles(engine, dialog.getShell());
        if (dialog.open() == Window.OK) {
          ParameterizedCommand saveCommand =
              commandService.createCommand("contacts.save", Collections.EMPTY_MAP);
          handlerService.executeHandler(saveCommand);
        }
      }

      updatePartTitle(contact);
    } else {
      uiItem.setLabel("Details");
    }
    dirtyable.setDirty(false);
    if (!detailComposite.isDisposed()) {
      detailComposite.update(contact);
    }
  }
Example #7
0
  /**
   * Handle game finished.
   *
   * @param player the player
   */
  private void handleGameFinished(IPlayer player) {
    TableViewerColumn column;
    column = this.playerColumn.get(player);
    column.getColumn().setImage(ProtoPlugin.getImage(ISharedImages.IMG_TICK_DECO));
    // remove edition
    for (Text inputTxt : this.playerScoreInput.values()) {
      inputTxt.setEnabled(false);

      inputTxt.setBackground(
          OpenDartsFormsToolkit.getToolkit()
              .getColors()
              .getColor(OpenDartsFormsToolkit.COLOR_INACTIVE));
    }
    for (TableViewerColumn col : this.playerColumn.values()) {
      col.setEditingSupport(null);
    }

    // End Game dialog
    if (!this.game.getParentSet().isFinished()) {
      String title = MessageFormat.format("{0} finished", this.game);
      String message = this.game.getWinningMessage();
      Shell shell = this.getSite().getShell();
      MessageDialog.open(MessageDialog.INFORMATION, shell, title, message, SWT.SHEET);
    }
    this.dirty = false;
    this.mForm.dirtyStateChanged();
  }
Example #8
0
 private boolean shouldVerify() {
   if (VerifyJob.isRunning()) {
     new MessageDialog(
             getShell(),
             "Program being verified.",
             null,
             "Only one program can be verified at a time.",
             MessageDialog.ERROR,
             new String[] {"OK"},
             0)
         .open();
     return false;
   }
   if (!editor.isDirty()) return true;
   MessageDialog dialog =
       new MessageDialog(
           getShell(),
           "Save Changes?",
           null,
           "Before the program can be verified changes made to the configuration must first be saved.",
           MessageDialog.ERROR,
           new String[] {
             "&Save New Properties and Verify", "&Revert to Old Properties and Verify", "&Cancel"
           },
           2);
   int option = dialog.open();
   if (option == 0) editor.saveProperties();
   else if (option == 1) editor.revertProperties();
   else return false;
   return true;
 }
Example #9
0
 public final void unloadSelectedCustoms() {
   final IStructuredSelection selection =
       (IStructuredSelection)
           LoadCustomizationsDialog.this.selectedCustomizationsTreeViewer.getSelection();
   final List<Customization> toBeRemoved = new ArrayList<Customization>();
   boolean lockedCustomFound = false;
   for (Object object : selection.toList()) {
     if (this.lockedCustoms.contains(object)) {
       lockedCustomFound = true;
     } else if (object instanceof Customization) {
       final Customization element = (Customization) object;
       toBeRemoved.add(element);
     }
   }
   if (lockedCustomFound) {
     final MessageDialog dialog =
         new MessageDialog(
             null,
             Messages.LoadCustomizationsDialog_LoadCustomizationWarning,
             null,
             Messages.LoadCustomizationsDialog_Can_not_be_unload + this.lockMsg,
             MessageDialog.WARNING,
             new String[] {Messages.LoadCustomizationsDialog_OK},
             1);
     dialog.open();
   }
   removeFromSelection(toBeRemoved);
   refresh();
 }
 @Override
 public void run(TableLoadOption... tableLoadOptions) throws OseeCoreException {
   if (AtsUtil.isProductionDb()) {
     AWorkbench.popup("ERROR", "This should not to be run on production DB");
     return;
   }
   MessageDialog dialog =
       new MessageDialog(
           Displays.getActiveShell(),
           getName(),
           null,
           getName() + "\n\nSelect Source or Destination Client",
           MessageDialog.QUESTION,
           new String[] {
             "Source Client", "Destination Client - Start", "Destination Client - End", "Cancel"
           },
           2);
   int result = dialog.open();
   resultData = new XResultData();
   if (result == 0) {
     runClientTest();
   } else if (result == 1) {
     EntryDialog diag =
         new EntryDialog(getName(), "Enter tt number of Source Client created Action");
     if (diag.open() == 0) {
       runDestinationTestStart(diag.getEntry());
     }
   } else if (result == 2) {
     EntryDialog diag =
         new EntryDialog(getName(), "Enter tt number of Source Client created Action");
     if (diag.open() == 0) {
       runDestinationTestEnd(diag.getEntry());
     }
   }
 }
 private void handleNewIntro() {
   boolean needNewProduct = false;
   if (!productDefined()) {
     needNewProduct = true;
     MessageDialog mdiag =
         new MessageDialog(
             PDEPlugin.getActiveWorkbenchShell(),
             PDEUIMessages.IntroSection_undefinedProductId,
             null,
             PDEUIMessages.IntroSection_undefinedProductIdMessage,
             MessageDialog.QUESTION,
             new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL},
             0);
     if (mdiag.open() != Window.OK) return;
   }
   ProductIntroWizard wizard = new ProductIntroWizard(getProduct(), needNewProduct);
   WizardDialog dialog = new WizardDialog(PDEPlugin.getActiveWorkbenchShell(), wizard);
   dialog.create();
   if (dialog.open() == Window.OK) {
     String id = wizard.getIntroId();
     fIntroCombo.add(id, 0);
     fIntroCombo.setText(id);
     getIntroInfo().setId(id);
     addDependenciesAndPlugins();
   }
 }
  /**
   * Creates a new project resource with the selected name.
   *
   * <p>In normal usage, this method is invoked after the user has pressed Finish on the wizard; the
   * enablement of the Finish button implies that all controls on the pages currently contain valid
   * values.
   *
   * @return the created project resource, or <code>null</code> if the project was not created
   */
  IProject createExistingProject() {

    String projectName = projectNameField.getText();
    final IWorkspace workspace = ResourcesPlugin.getWorkspace();
    final IProject project = workspace.getRoot().getProject(projectName);
    if (this.description == null) {
      this.description = workspace.newProjectDescription(projectName);
      IPath locationPath = getLocationPath();
      // If it is under the root use the default location
      if (isPrefixOfRoot(locationPath)) {
        this.description.setLocation(null);
      } else {
        this.description.setLocation(locationPath);
      }
    } else {
      this.description.setName(projectName);
    }

    // create the new project operation
    WorkspaceModifyOperation op =
        new WorkspaceModifyOperation() {
          @Override
          protected void execute(IProgressMonitor monitor) throws CoreException {
            SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
            project.create(description, subMonitor.split(50));
            project.open(IResource.BACKGROUND_REFRESH, subMonitor.split(50));
          }
        };

    // run the new project creation operation
    try {
      getContainer().run(true, true, op);
    } catch (InterruptedException e) {
      return null;
    } catch (InvocationTargetException e) {
      // ie.- one of the steps resulted in a core exception
      Throwable t = e.getTargetException();
      if (t instanceof CoreException) {
        if (((CoreException) t).getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) {
          MessageDialog.open(
              MessageDialog.ERROR,
              getShell(),
              DataTransferMessages.WizardExternalProjectImportPage_errorMessage,
              NLS.bind(
                  DataTransferMessages.WizardExternalProjectImportPage_caseVariantExistsError,
                  projectName),
              SWT.SHEET);
        } else {
          ErrorDialog.openError(
              getShell(),
              DataTransferMessages.WizardExternalProjectImportPage_errorMessage,
              null,
              ((CoreException) t).getStatus());
        }
      }
      return null;
    }

    return project;
  }
 /** Shows the "Page Flipping abort" dialog. */
 void showPageFlippingAbortDialog() {
   MessageDialog.open(
       MessageDialog.ERROR,
       getShell(),
       JFaceResources.getString("AbortPageFlippingDialog.title"), // $NON-NLS-1$
       JFaceResources.getString("AbortPageFlippingDialog.message"),
       SWT.SHEET); //$NON-NLS-1$
 }
 /**
  * Anzeige eines Fehler durch einen MessageDialog.
  *
  * @param msg
  */
 public static void showError(String msg) {
   Shell shell = new Shell(Display.getDefault());
   MessageDialog messageDialog =
       new MessageDialog(
           shell, "Fehler", null, msg, MessageDialog.ERROR, new String[] {"Schließen"}, 1);
   int answer = messageDialog.open();
   if (answer == 0) messageDialog.close();
 }
 // This method must be run in the UI thread.
 private static boolean displayDialogAndGetAnswer(
     int type, String title, final String message, int defaultPosition) {
   Shell activeShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
   MessageDialog dialog =
       new MessageDialog(activeShell, title, null, message, type, LABELS, defaultPosition);
   int selection = dialog.open();
   return selection == YesOrNo.YES.ordinal();
 }
  private void informUserModal(CompletionProposalComputerDescriptor descriptor, IStatus status) {
    String title = DartTextMessages.CompletionProposalComputerRegistry_error_dialog_title;
    CompletionProposalCategory category = descriptor.getCategory();
    IContributor culprit = descriptor.getContributor();
    Set affectedPlugins = getAffectedContributors(category, culprit);

    final String avoidHint;
    final String culpritName = culprit == null ? null : culprit.getName();
    if (affectedPlugins.isEmpty()) {
      avoidHint =
          Messages.format(
              DartTextMessages.CompletionProposalComputerRegistry_messageAvoidanceHint,
              new Object[] {culpritName, category.getDisplayName()});
    } else {
      avoidHint =
          Messages.format(
              DartTextMessages.CompletionProposalComputerRegistry_messageAvoidanceHintWithWarning,
              new Object[] {culpritName, category.getDisplayName(), toString(affectedPlugins)});
    }

    String message = status.getMessage();
    // inlined from MessageDialog.openError
    MessageDialog dialog =
        new MessageDialog(
            DartToolsPlugin.getActiveWorkbenchShell(),
            title,
            null /* default image */,
            message,
            MessageDialog.ERROR,
            new String[] {IDialogConstants.OK_LABEL},
            0) {
          @Override
          protected Control createCustomArea(Composite parent) {
            Link link = new Link(parent, SWT.NONE);
            link.setText(avoidHint);
            link.addSelectionListener(
                new SelectionAdapter() {
                  @Override
                  public void widgetSelected(SelectionEvent e) {
                    PreferencesUtil.createPreferenceDialogOn(
                            getShell(),
                            "com.google.dart.tools.ui.internal.preferences.CodeAssistPreferenceAdvanced",
                            null,
                            null)
                        .open(); //$NON-NLS-1$
                  }
                });
            GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
            gridData.widthHint = this.getMinimumMessageWidth();
            link.setLayoutData(gridData);
            return link;
          }
        };
    dialog.open();
  }
 private void debugProxySettings() {
   MessageDialog dialog =
       new MessageDialog(
           PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
           "Architexa: Proxy Settings",
           null,
           CollabPlugin.getDebugStr(),
           MessageDialog.INFORMATION,
           new String[] {"OK"},
           1) {};
   dialog.open();
 }
Example #18
0
 public static boolean WarningConfirm(String title, String body) {
   MessageDialog dialog =
       new MessageDialog(
           PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
           title,
           null,
           body,
           MessageDialog.WARNING,
           new String[] {"Yes", "No"},
           0);
   return dialog.open() == 0;
 }
 /** @return true if proceed is clicked, false if cancel is clicked */
 private boolean requestConfirmationForValidationErrorsWarnings() {
   String[] dialogButtons = {Messages.proceedButton, Messages.cancelButton};
   MessageDialog confirmationDialog =
       new MessageDialog(
           getShell(),
           Messages.validationTitle,
           null,
           StringUtils.format(Messages.validationMessage, errorMessage, errorComponents),
           MessageDialog.QUESTION,
           dialogButtons,
           1);
   return confirmationDialog.open() == 0;
 }
Example #20
0
  /**
   * Opens a dialog for a single non-user, non-password type item.
   *
   * @param shell the shell to use
   * @param uri the uri of the get request
   * @param item the item to handle
   * @return <code>true</code> if the request was successful and values were supplied; <code>false
   *     </code> if the user canceled the request and did not supply all requested values.
   */
  private boolean getSingleSpecial(Shell shell, URIish uri, CredentialItem item) {
    if (item instanceof CredentialItem.InformationalMessage) {
      MessageDialog.openInformation(
          shell, UIText.EGitCredentialsProvider_information, item.getPromptText());
      return true;
    } else if (item instanceof CredentialItem.YesNoType) {
      CredentialItem.YesNoType v = (CredentialItem.YesNoType) item;
      String[] labels =
          new String[] {
            IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL
          };
      int[] resultIDs =
          new int[] {IDialogConstants.YES_ID, IDialogConstants.NO_ID, IDialogConstants.CANCEL_ID};

      MessageDialog dialog =
          new MessageDialog(
              shell,
              UIText.EGitCredentialsProvider_question,
              null,
              item.getPromptText(),
              MessageDialog.QUESTION_WITH_CANCEL,
              labels,
              0);
      dialog.setBlockOnOpen(true);
      int r = dialog.open();
      if (r < 0) {
        return false;
      }

      switch (resultIDs[r]) {
        case IDialogConstants.YES_ID:
          {
            v.setValue(true);
            return true;
          }
        case IDialogConstants.NO_ID:
          {
            v.setValue(false);
            return true;
          }
        default:
          // abort
          return false;
      }
    } else {
      // generically handles all other types of items
      return getMultiSpecial(shell, uri, item);
    }
  }
  protected void ok() {
    if (Const.isEmpty(m_stepnameText.getText())) {
      return;
    }

    stepname = m_stepnameText.getText();

    m_currentMeta.setIncomingKeyField(m_incomingKeyCombo.getText());
    m_currentMeta.setIncomingResultField(m_incomingResultCombo.getText());
    List<String> problems = new ArrayList<String>();
    Mapping mapping = m_mappingEditor.getMapping(false, problems);
    if (problems.size() > 0) {
      StringBuffer p = new StringBuffer();
      for (String s : problems) {
        p.append(s).append("\n");
      }
      MessageDialog md =
          new MessageDialog(
              shell,
              BaseMessages.getString(PKG, "HBaseRowDecoderDialog.Error.IssuesWithMapping.Title"),
              null,
              BaseMessages.getString(PKG, "HBaseRowDecoderDialog.Error.IssuesWithMapping")
                  + ":\n\n"
                  + p.toString(),
              MessageDialog.WARNING,
              new String[] {
                BaseMessages.getString(
                    PKG, "HBaseRowDecoderDialog.Error.IssuesWithMapping.ButtonOK"),
                BaseMessages.getString(
                    PKG, "HBaseRowDecoderDialog.Error.IssuesWithMapping.ButtonCancel")
              },
              0);
      MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
      int idx = md.open() & 0xFF;
      if (idx == 1 || idx == 255 /* 255 = escape pressed */) {
        return; // Cancel
      }
    }
    if (mapping != null) {
      m_currentMeta.setMapping(mapping);
    }

    if (!m_originalMeta.equals(m_currentMeta)) {
      m_currentMeta.setChanged();
      changed = m_currentMeta.hasChanged();
    }

    dispose();
  }
  public static boolean confirm(String op) {
    if (Display.getCurrent() == null) {
      return true; // avoid dialog if running unit tests
    }
    String title = "<NOT YET IMPLEMENTED>";
    String msg =
        op
            + " is not yet fully implemented and/or tested. Running this operation may result in a corrupt database. Proceed only if you are testing/developing this function."
            + "\n\nRECOMMENDATION: DO NOT PROCEED!"
            + "\n\nDo you want to proceed despite the risk of destroying your database?";

    String[] buttons = {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL};
    MessageDialog dialog =
        new MessageDialog(null, title, null, msg, MessageDialog.WARNING, buttons, 1);
    return dialog.open() == 0;
  }
  private void processNonBBProjects(
      final List<IJavaProject> nonBBProjects,
      final List<IJavaProject> projectsWithProblem,
      final boolean fix) {
    for (IJavaProject javaProject : nonBBProjects) {
      if (fix && projectsWithProblem.contains(javaProject)) {
        ImportUtils.initializeProjectOptions(javaProject);
      }
    }
    if (fix) {
      Shell shell = ContextManager.getActiveWorkbenchWindow().getShell();
      String message = Messages.ClasspathChangeManager_rebuildProjectMsg1;
      StringBuffer projectList = new StringBuffer();
      for (IJavaProject javaProject : projectsWithProblem) {
        projectList.append(javaProject.getProject().getName() + "\n");
      }
      message += projectList.toString();
      message += Messages.ClasspathChangeManager_rebuildProjectMsg2;
      MessageDialog dialog =
          new MessageDialog(
              shell,
              Messages.ClasspathChangeManager_RebuildProjectDialogTitle,
              null,
              message,
              MessageDialog.INFORMATION,
              new String[] {
                Messages.IConstants_OK_BUTTON_TITLE, Messages.IConstants_CANCEL_BUTTON_TITLE
              },
              0);
      int buttonEventCode = dialog.open();

      switch (buttonEventCode) {
        case Window.OK:
          {
            buildProjects(projectsWithProblem);
            break;
          }
        case Window.CANCEL:
          {
            break;
          }
        default:
          throw new IllegalArgumentException("Unsupported dialog button event!");
      }
      dialog.close();
    }
  }
Example #24
0
  private void save() {
    try {
      ITestCase model = getModel();
      NullProgressMonitor monitor = new NullProgressMonitor();
      if (model.exists()) {
        model = (ITestCase) model.getWorkingCopy(monitor);
        copyContent(scenario, (Scenario) model.getNamedElement());
        WriteAccessChecker writeAccessChecker = new WriteAccessChecker(getShell());

        try {
          if (!writeAccessChecker.makeResourceWritable(model)) {
            return;
          }
          model.commitWorkingCopy(true, monitor);
        } catch (CoreException e) {
          Q7UIPlugin.log(e);
        } finally {
          model.discardWorkingCopy();
        }
        contextsTable.setProject(getSavedProject());
        verificationsTable.setProject(getSavedProject());
        copyContent((Scenario) model.getNamedElement(), this.scenario);
      } else {
        MessageDialog dialog =
            new MessageDialog(
                getShell(),
                Messages.ControlPanelWindow_SaveDialogTitle,
                null,
                "Failed to save testcase because underlying resources is not exist.",
                MessageDialog.ERROR,
                new String[] {
                  IDialogConstants.YES_LABEL,
                  IDialogConstants.NO_LABEL,
                  IDialogConstants.CANCEL_LABEL
                },
                0);
        int value = dialog.open(); // Number of pressed button
        if (value == 0) {
          saveAs();
        }
      }
    } catch (ModelException e) {
      Q7UIPlugin.log(e);
    }
  }
Example #25
0
  /**
   * This method is called from the <code>Viewer</code> method <code>inputChanged</code> to save any
   * unsaved changes of the old input.
   *
   * <p>The <code>ContentMergeViewer</code> implementation of this method calls <code>
   * saveContent(...)</code>. If confirmation has been turned on with <code>setConfirmSave(true)
   * </code>, a confirmation alert is posted before saving. Clients can override this method and are
   * free to decide whether they want to call the inherited method.
   *
   * @param newInput the new input of this viewer, or <code>null</code> if there is no new input
   * @param oldInput the old input element, or <code>null</code> if there was previously no input
   * @return <code>true</code> if saving was successful, or if the user didn't want to save (by
   *     pressing 'NO' in the confirmation dialog).
   * @since 2.0
   */
  protected boolean doSave(Object newInput, Object oldInput) {

    // before setting the new input we have to save the old
    if (isLeftDirty() || isRightDirty()) {

      if (Utilities.RUNNING_TESTS) {
        if (Utilities.TESTING_FLUSH_ON_COMPARE_INPUT_CHANGE) {
          flushContent(oldInput, null);
        }
      } else if (fConfirmSave) {
        // post alert
        Shell shell = fComposite.getShell();

        MessageDialog dialog =
            new MessageDialog(
                shell,
                Utilities.getString(getResourceBundle(), "saveDialog.title"), // $NON-NLS-1$
                null, // accept the default window icon
                Utilities.getString(getResourceBundle(), "saveDialog.message"), // $NON-NLS-1$
                MessageDialog.QUESTION,
                new String[] {
                  IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                },
                0); // default
        // button
        // index

        switch (dialog.open()) { // open returns index of pressed button
          case 0:
            flushContent(oldInput, null);
            break;
          case 1:
            setLeftDirty(false);
            setRightDirty(false);
            break;
          case 2:
            throw new ViewerSwitchingCancelled();
        }
      } else flushContent(oldInput, null);
      return true;
    }
    return false;
  }
Example #26
0
  public static boolean canCloseTerminal(
      IShellProvider shellProvider, LocalTerminalConnector terminalConnector) {
    List<String> processes = terminalConnector.getRunningProcesses();
    if (processes.size() < 2) {
      return true;
    }

    int closeId = 1;
    MessageDialog dialog =
        new MessageDialog(
            shellProvider.getShell(),
            Messages.TerminalCloseHelper_DialogTitle,
            null,
            Messages.TerminalCloseHelper_DialogMessage + processes.toString(),
            MessageDialog.QUESTION,
            new String[] {IDialogConstants.CANCEL_LABEL, IDialogConstants.CLOSE_LABEL},
            closeId);
    return dialog.open() == closeId;
  }
 private boolean upToDateCheck(Element notationInfo) {
   if ("process-diagram".equals(notationInfo.getNodeName())
       || "pageflow-diagram".equals(notationInfo.getNodeName())) {
     MessageDialog dialog =
         new MessageDialog(
             null,
             "GPD 3.0.x Format Detected",
             null,
             "The file you are trying to save contains GPD 3.0.x information."
                 + "Saving the file will result in an automatic conversion into the 3.1.x format."
                 + "It will be impossible to open it with the old GPD.\n"
                 + "Do you want to continue?",
             MessageDialog.QUESTION,
             new String[] {"Save And Convert", "Cancel"},
             0);
     return dialog.open() == 0;
   }
   return true;
 }
Example #28
0
  @Override
  public boolean performFinish() {

    EnrollService service = Activator.getDefault().getEnrollService();

    try {
      service.createCourse(page.getTitleText(), page.getFreeSlots());
    } catch (Exception e) {
      MessageDialog.open(
          MessageDialog.ERROR,
          PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
          "Error",
          e.getMessage(),
          SWT.NONE);
      return false;
    }

    EnrollViewPart.refreshCurrentInstance(2);
    return true;
  }
Example #29
0
 private void activateExtensionPages(String activePageId) {
   MessageDialog mdiag =
       new MessageDialog(
           PDEPlugin.getActiveWorkbenchShell(),
           PDEUIMessages.OverviewPage_extensionPageMessageTitle,
           null,
           PDEUIMessages.OverviewPage_extensionPageMessageBody,
           MessageDialog.QUESTION,
           new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL},
           0);
   if (mdiag.open() != Window.OK) return;
   try {
     MonitorEditor manifestEditor = (MonitorEditor) getEditor();
     manifestEditor.addExtensionTabs();
     manifestEditor.setShowExtensions(true);
     manifestEditor.setActivePage(activePageId);
   } catch (PartInitException e) {
   } catch (BackingStoreException e) {
   }
 }
 private Element convertCheck(Element notationInfo) {
   if ("process-diagram".equals(notationInfo.getNodeName())
       || "pageflow-diagram".equals(notationInfo.getNodeName())) {
     MessageDialog dialog =
         new MessageDialog(
             null,
             "Convert To 3.1.x Format",
             null,
             "A file created with an older GPD version was detected. "
                 + "If you open this file it will be converted to the 3.1.x "
                 + "format and overwritten.\n"
                 + "Do you want to continue?",
             MessageDialog.QUESTION,
             new String[] {"Convert And Open", "Continue Without Converting"},
             0);
     if (dialog.open() == 0) {
       return convertToRootContainer(notationInfo);
     }
   }
   return null;
 }