public void run(IProgressMonitor progressMonitor)
      throws InvocationTargetException, InterruptedException {
    try {
      boolean isFixedForm = getFortranEditor().isFixedForm();

      IDocument doc = getFortranEditor().getIDocument();
      Reader in = new StringReader(doc.get());
      Reader cppIn = new CPreprocessingReader(getFortranEditor().getIFile(), null, in);
      try {
        File tempFile =
            File.createTempFile(
                "tmp", //$NON-NLS-1$
                isFixedForm ? ".f" : ".f90"); // $NON-NLS-1$ //$NON-NLS-2$
        tempFile.deleteOnExit();
        PrintStream out = new PrintStream(new BufferedOutputStream(new FileOutputStream(tempFile)));
        try {
          for (int c = cppIn.read(); c != -1; c = cppIn.read()) out.print((char) c);
        } finally {
          out.close();
        }

        IDE.openEditor(
            Workbench.getInstance().getActiveWorkbenchWindow().getActivePage(),
            tempFile.toURI(),
            FortranEditor.EDITOR_ID,
            true);
      } finally {
        cppIn.close();
      }
    } catch (Exception e) {
      String message = e.getMessage();
      if (message == null) message = e.getClass().getName();
      MessageDialog.openError(getFortranEditor().getShell(), "Error", message); // $NON-NLS-1$
    }
  }
  public static boolean renameParameter(
      IContextModelManager manager,
      final String oldParamName,
      String sourceId,
      final String newParamName,
      boolean reposFlag) {
    if (!manager.getContextManager().checkValidParameterName(oldParamName, newParamName)) {
      MessageDialog.openError(
          new Shell(),
          Messages.getString("ContextProcessSection.errorTitle"),
          Messages.getString(
              "ContextProcessSection.ParameterNameIsNotValid")); //$NON-NLS-1$ //$NON-NLS-2$
      return false;
    }
    // fix 0017942: It is unlimited for total characters of context variable name
    if (null != newParamName && !"".equals(newParamName)) { // $NON-NLS-1$
      if (newParamName.length() > 255) {
        MessageDialog.openError(
            new Shell(),
            Messages.getString("ContextProcessSection.errorTitle"),
            Messages.getString(
                "ContextTemplateComposite.ParamterLengthInvilid")); //$NON-NLS-1$ //$NON-NLS-2$
        return false;
      }
    }

    manager.onContextRenameParameter(
        manager.getContextManager(), sourceId, oldParamName, newParamName);
    manager.refresh();
    return true;
  }
  public boolean downloadModel(String folderName, String modelName) {
    logger.debug("IN");
    boolean toReturn = true;

    SpagoBIServerObjectsFactory proxyServerObjects = null;

    try {
      proxyServerObjects = new SpagoBIServerObjectsFactory(projectName);

      Template template =
          proxyServerObjects.getServerDocuments().downloadDatamartFile(folderName, modelName);

      if (template == null) {
        logger.error("The download operation has returned a null object!");
        return false;
      }
      overwriteTemplate(template);
    } catch (NullPointerException e) {
      logger.error(
          "No comunication with server, check SpagoBi Server definition in preferences page", e);
      MessageDialog.openError(
          getShell(),
          "Error",
          "No comunication with server, check SpagoBi Server definition in preferences page");
      return false;
    } catch (Exception e) {
      logger.error("No comunication with SpagoBI server, could not retrieve template", e);
      MessageDialog.openError(
          getShell(), "Error", "Could not get the template from server for document");
      return false;
    }

    logger.debug("OUT");
    return toReturn;
  }
 /** @generated */
 private static boolean openEditor(IWorkbench workbench, URI fileURI) {
   IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
   IWorkbenchPage page = workbenchWindow.getActivePage();
   IEditorDescriptor editorDescriptor =
       workbench.getEditorRegistry().getDefaultEditor(fileURI.toFileString());
   if (editorDescriptor == null) {
     MessageDialog.openError(
         workbenchWindow.getShell(),
         Messages.DiagramEditorActionBarAdvisor_DefaultFileEditorTitle,
         NLS.bind(
             Messages.DiagramEditorActionBarAdvisor_DefaultFileEditorMessage,
             fileURI.toFileString()));
     return false;
   } else {
     try {
       page.openEditor(new URIEditorInput(fileURI), editorDescriptor.getId());
     } catch (PartInitException exception) {
       MessageDialog.openError(
           workbenchWindow.getShell(),
           Messages.DiagramEditorActionBarAdvisor_DefaultEditorOpenErrorTitle,
           exception.getMessage());
       return false;
     }
   }
   return true;
 }
  private void compileLoader(String id) {
    String param = "";
    param = "appId=" + id + "&" + "loader=1";
    String message = NetWorkService.getInstance().addUnpack(id, param, ip);
    JSONObject json;
    try {
      json = new JSONObject(message);
      String status = json.getString("status");
      if (status.equals("0")) {
        MessageDialog.openError(
            Display.getDefault().getActiveShell(), Messages.ERROR, Messages.SERVICEBUSY);
      } else if (status.equals("error")) {
        MessageDialog.openError(
            Display.getDefault().getActiveShell(), Messages.ERROR, Messages.COMPILEERROR);

      } else {
        String body;
        body = json.getString("body");
        JSONObject result = new JSONObject(body);
        pkgId = result.getString("pkgId");
        System.err.println(pkgId);
        compileAndDownloadAppLoader(id);
      }
    } catch (JSONException e) {
      e.printStackTrace();
    }
  }
  /*
   * @return <code>true</code> if compare result is OK to show, <code>false</code> otherwise
   */
  public boolean compareResultOK(CompareEditorInput input, IRunnableContext context) {
    final Shell shell = getShell();
    try {

      // run operation in separate thread and make it cancelable
      if (context == null) context = PlatformUI.getWorkbench().getProgressService();
      context.run(true, true, input);

      String message = input.getMessage();
      if (message != null) {
        MessageDialog.openError(
            shell, Utilities.getString("CompareUIPlugin.compareFailed"), message); // $NON-NLS-1$
        return false;
      }

      if (input.getCompareResult() == null) {
        MessageDialog.openInformation(
            shell,
            Utilities.getString("CompareUIPlugin.dialogTitle"),
            Utilities.getString("CompareUIPlugin.noDifferences")); // $NON-NLS-2$ //$NON-NLS-1$
        return false;
      }

      return true;

    } catch (InterruptedException x) {
      // canceled by user
    } catch (InvocationTargetException x) {
      MessageDialog.openError(
          shell,
          Utilities.getString("CompareUIPlugin.compareFailed"),
          x.getTargetException().getMessage()); // $NON-NLS-1$
    }
    return false;
  }
  /**
   * Determine if the supplied IFile has any outstanding problem markers. If markers are found,
   * dialogs are displayed.
   *
   * @param mxdFile the file containing the extension definition
   * @return <code>true</code> if problems were found
   */
  private static boolean checkProblemMarkers(IFile mxdFile) {
    IMarker[] markers = null;
    boolean errorOccurred = false;

    try {
      markers =
          mxdFile.findMarkers(
              UiConstants.ExtensionIds.PROBLEM_MARKER, false, IResource.DEPTH_INFINITE);
    } catch (CoreException ex) {
      Util.log(ex);
      errorOccurred = true;
    }

    // Notify user if error getting markers
    if (errorOccurred) {
      MessageDialog.openError(
          getShell(),
          Messages.checkMedProblemMarkersErrorTitle,
          Messages.checkMedProblemMarkersErrorMsg);
      return true;
    }

    if (markers.length > 0) {
      MessageDialog.openError(
          getShell(),
          Messages.checkMedProblemMarkersHasErrorsTitle,
          Messages.checkMedProblemMarkersHasErrorsMsg);
      return true;
    }

    return false;
  }
Exemplo n.º 8
0
 /**
  * This method is called when 'Finish' button is pressed in the wizard. We will create an
  * operation and run it using wizard as execution context.
  */
 public boolean performFinish() {
   final String fileName = page.getProjectName();
   IRunnableWithProgress op =
       new IRunnableWithProgress() {
         public void run(IProgressMonitor monitor) throws InvocationTargetException {
           try {
             doFinish(fileName, monitor);
           } catch (CoreException e) {
             throw new InvocationTargetException(e);
           } finally {
             monitor.done();
           }
         }
       };
   try {
     getContainer().run(true, false, op);
     workbench.showPerspective(
         "edu.rosehulman.soar.perspective.SoarPerspectiveFactory",
         workbench.getWorkbenchWindows()[0]);
   } catch (InterruptedException e) {
     return false;
   } catch (InvocationTargetException e) {
     Throwable realException = e.getTargetException();
     MessageDialog.openError(getShell(), "Error", realException.getMessage());
     return false;
   } catch (WorkbenchException e) {
     MessageDialog.openError(getShell(), "Error", e.getMessage());
     return false;
   }
   return true;
 }
Exemplo n.º 9
0
  /**
   * ************************************************************************* The command has been
   * executed, so extract extract the needed information from the application context.
   * ************************************************************************
   */
  public CommandResult execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();

    IServerProxy proxy = (IServerProxy) ServiceManager.get(IServerProxy.class);
    ServerRole role = proxy.getCurrentServer().getRole();
    if (role != ServerRole.COMMANDING) {
      MessageDialog.openError(
          window.getShell(),
          "Cannot open",
          "Cannot schedule procedures on the current server,\n" + "the role is monitoring");
      return CommandResult.NO_EFFECT;
    }

    IRuntimeSettings runtime = (IRuntimeSettings) ServiceManager.get(IRuntimeSettings.class);
    String procId =
        (String) runtime.getRuntimeProperty(RuntimeProperty.ID_NAVIGATION_VIEW_SELECTION);
    if (procId != null) {
      ConditionDialog dlg = new ConditionDialog(window.getShell());
      dlg.open();
      String condition = dlg.getCondition();
      if (condition != null) {
        ScheduleProcedureJob job = new ScheduleProcedureJob(procId, condition);
        CommandHelper.executeInProgress(job, true, true);
        if (job.result != CommandResult.SUCCESS) {
          MessageDialog.openError(window.getShell(), "Schedule error", job.message);
        }
        return job.result;
      } else {
        return CommandResult.NO_EFFECT;
      }
    } else {
      return CommandResult.NO_EFFECT;
    }
  }
Exemplo n.º 10
0
  @Override
  public boolean performFinish() {
    IFile resultFile = page.getResultFile();
    if (resultFile != null) {
      ABSEditor editor =
          UtilityFunctions.openABSEditorForFile(resultFile.getLocation(), resultFile.getProject());
      IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());

      // modules are always added the the end of the document
      final int off = document.getLength();

      try {
        document.replace(off, 0, insertType.getInsertionString(page.getResult()));
        final int insertOffset = insertType.getInsertOffset(page.getResult());

        WizardUtil.saveEditorAndGotoOffset(editor, insertOffset);

        return true;
      } catch (BadLocationException e) {
        MessageDialog.openError(
            getShell(),
            "Error",
            "Fatal error: The insertion position for the new module does not longer exist. Please save the target file and try again.");
        e.printStackTrace();
        return false;
      }
    } else {
      MessageDialog.openError(
          getShell(),
          "Error",
          "Fatal error: No file reference was passed by the wizard. Please try again to use the wizard and select a valid file.");
      return false;
    }
  }
Exemplo n.º 11
0
  protected void addSelection() {
    String key = keyText.getText();
    String val = valueText.getText();
    if (key != null && key.trim().length() > 0) {
      boolean isContained = false;
      for (int i = 0; i < globalLinkedProperties.size(); i++) {
        GlobalProperty property = (GlobalProperty) globalLinkedProperties.get(i);
        if (key.equals(property.key) && !property.isDeleted) {
          property.value = val;
          isContained = true;
          break;
        }
      }

      if (!isContained) {
        // if the file is read-only then change is not allowed.
        if (propFileName[0] == null) {
          return;
        } else {
          File f = new File(propFileName[0]);
          if (!(f.exists() && f.isFile())) {
            MessageDialog.openError(
                getShell(),
                Messages.getString("ResourceEditDialog.NotFile.Title"), // $NON-NLS-1$
                Messages.getFormattedString(
                    "ResourceEditDialog.NotFile.Message", //$NON-NLS-1$
                    new Object[] {propFileName}));
            return;
          } else if (!f.canWrite()) {
            MessageDialog.openError(
                getShell(),
                Messages.getString("ResourceEditDialog.ReadOnlyEncounter.Title"), // $NON-NLS-1$
                Messages.getFormattedString(
                    "ResourceEditDialog.ReadOnlyEncounter.Message", //$NON-NLS-1$
                    new Object[] {propFileName}));
            return;
          }

          GlobalProperty property = new GlobalProperty();
          property.key = key;
          property.value = val;
          property.holder = contents[0];
          property.isDeleted = false;
          property.holderFile = propFileName[0];

          globalLinkedProperties.add(property);
        }
      }

      viewer.refresh();
      listChanged = true;
      updateSelection();

    } else {
      MessageDialog.openWarning(
          getShell(),
          Messages.getString("ResourceEditDialog.text.AddWarningTitle"), // $NON-NLS-1$
          Messages.getString("ResourceEditDialog.text.AddWarningMsg")); // $NON-NLS-1$
    }
  }
Exemplo n.º 12
0
  /**
   * Simplified copy of IDEAplication processing that does not offer to choose a workspace location.
   */
  private boolean checkInstanceLocation(
      Location instanceLocation, Shell shell, IEclipseContext context) {

    // Eclipse has been run with -data @none or -data @noDefault options so
    // we don't need to validate the location
    if (instanceLocation == null && Boolean.FALSE.equals(context.get(IWorkbench.PERSIST_STATE))) {
      return true;
    }

    if (instanceLocation == null) {
      MessageDialog.openError(
          shell,
          WorkbenchSWTMessages.IDEApplication_workspaceMandatoryTitle,
          WorkbenchSWTMessages.IDEApplication_workspaceMandatoryMessage);
      return false;
    }

    // -data "/valid/path", workspace already set
    if (instanceLocation.isSet()) {
      // make sure the meta data version is compatible (or the user
      // has
      // chosen to overwrite it).
      if (!checkValidWorkspace(shell, instanceLocation.getURL())) {
        return false;
      }

      // at this point its valid, so try to lock it and update the
      // metadata version information if successful
      try {
        if (instanceLocation.lock()) {
          writeWorkspaceVersion();
          return true;
        }

        // we failed to create the directory.
        // Two possibilities:
        // 1. directory is already in use
        // 2. directory could not be created
        File workspaceDirectory = new File(instanceLocation.getURL().getFile());
        if (workspaceDirectory.exists()) {
          MessageDialog.openError(
              shell,
              WorkbenchSWTMessages.IDEApplication_workspaceCannotLockTitle,
              WorkbenchSWTMessages.IDEApplication_workspaceCannotLockMessage);
        } else {
          MessageDialog.openError(
              shell,
              WorkbenchSWTMessages.IDEApplication_workspaceCannotBeSetTitle,
              WorkbenchSWTMessages.IDEApplication_workspaceCannotBeSetMessage);
        }
      } catch (IOException e) {
        Logger logger = new WorkbenchLogger(PLUGIN_ID);
        logger.error(e);
        MessageDialog.openError(shell, WorkbenchSWTMessages.InternalError, e.getMessage());
      }
      return false;
    }
    return false;
  }
Exemplo n.º 13
0
  @Override
  public boolean performFinish() {
    try {
      final IDocument doc =
          createDocument(typePage.getDocumentType(), typePage.getRootElementName());

      final Style style =
          VexPlugin.getDefault().getPreferences().getPreferredStyle(typePage.getDocumentType());
      if (style == null) {
        MessageDialog.openError(
            getShell(),
            Messages.getString("NewDocumentWizard.noStyles.title"),
            Messages.getString("NewDocumentWizard.noStyles.message")); // $NON-NLS-1$ //$NON-NLS-2$
        return false;
        // TODO: don't allow selection of types with no stylesheets
      }

      final ByteArrayOutputStream baos = new ByteArrayOutputStream();
      final DocumentWriter writer = new DocumentWriter();
      writer.setWhitespacePolicy(new CssWhitespacePolicy(style.getStyleSheet()));
      writer.write(doc, baos);
      baos.close();
      final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());

      filePage.setInitialContents(bais);
      final IFile file = filePage.createNewFile();
      IDE.setDefaultEditor(file, VexEditor.ID);
      this.selectAndReveal(file);

      registerEditorForFilename("*." + file.getFileExtension(), VexEditor.ID); // $NON-NLS-1$

      // Open editor on new file.
      final IWorkbenchWindow dw = getWorkbench().getActiveWorkbenchWindow();
      if (dw != null) {
        final IWorkbenchPage page = dw.getActivePage();
        if (page != null) {
          IDE.openEditor(page, file, true);
        }
      }

      typePage.saveSettings();

      return true;

    } catch (final Exception ex) {
      final String message =
          MessageFormat.format(
              Messages.getString("NewDocumentWizard.errorLoading.message"),
              new Object[] {filePage.getFileName(), ex.getMessage()});
      VexPlugin.getDefault().log(IStatus.ERROR, message, ex);
      MessageDialog.openError(
          getShell(),
          Messages.getString("NewDocumentWizard.errorLoading.title"),
          "Unable to create " + filePage.getFileName()); // $NON-NLS-1$ //$NON-NLS-2$
      return false;
    }
  }
  /**
   * This method is called when 'Finish' button is pressed in the wizard. We will create an
   * operation and run it using wizard as execution context.
   */
  public boolean performFinish() {
    logger.debug("IN");
    TreeItem[] selectedItems = page.getTree().getSelection();
    if (selectedItems == null) {
      logger.warn("Error; no models selected");
    } else {
      // cycle on selected items
      for (int i = 0; i < selectedItems.length; i++) {
        TreeItem selectedItem = selectedItems[i];
        TreeItem folderItem = selectedItem;
        //	gets the folder and file name selected
        if (selectedItem.getData().toString().endsWith(".sbimodel")) {
          folderItem = selectedItem.getParentItem();
          if (folderItem == null) {
            logger.warn("Error; no models selected");
            MessageDialog.openError(
                getShell(), "Warning", "Choose a folder and a model file to continue.");
            return false;
          }
          String folderName = folderItem.getText();
          String modelName = selectedItem.getText();
          if (folderName != null
              && !folderName.equals("")
              && modelName != null
              && !modelName.equals("")
              && modelName.endsWith(".sbimodel")) {
            downloadModel(folderName, modelName);
          } else {
            logger.warn("Could not download model,not a right element was selected!");
            MessageDialog.openError(
                getShell(), "Warning", "Choose a folder and a model file to continue.");
            return false;
          }
        }
      }

      // print messages on file that could not be written
      if (messages.size() > 0) {
        String message =
            "Following models could not be added because already exist in project with the same name. You must delete firstly the existing ones: ";
        for (Iterator iterator = messages.iterator(); iterator.hasNext(); ) {
          String msg = (String) iterator.next();
          message += msg;
          if (iterator.hasNext()) {
            message += ", ";
          }
        }
        MessageDialog.openWarning(page.getShell(), "Warning", message);
        messages = new Vector<String>();
      }

      doFinish();
    }
    logger.debug("OUT");
    return true;
  }
  /** Handle browse package. */
  private void handleBrowsePackage() {

    IPackageFragment[] packages = null;
    IJavaProject javaProject = JavaCore.create(project);
    IJavaElement javaElementArray[] = null;
    ArrayList<IJavaElement> javaElementsList = new ArrayList<IJavaElement>();

    // Si el projecto no esta abierto se cancela el proceso
    if (javaProject.isOpen() == false) {
      MessageDialog.openError(
          getShell(),
          Messages.WizardPageChooseSourceFolderAndPackage_29,
          Messages.WizardPageChooseSourceFolderAndPackage_30);
      return;
    }

    // Lee los paquetes solo del proyecto
    try {
      packages = javaProject.getPackageFragments();

      for (IPackageFragment iPackageFragment : packages) {
        if (iPackageFragment.getKind() == IPackageFragmentRoot.K_SOURCE) {
          javaElementsList.add(iPackageFragment);
        }
      }
      if (javaElementsList.size() > 0) {
        javaElementArray = new IJavaElement[javaElementsList.size()];
        javaElementArray = javaElementsList.toArray(javaElementArray);
      }
    } catch (JavaModelException e) {
      MessageDialog.openError(
          getShell(), Messages.WizardPageChooseSourceFolderAndPackage_31, e.getMessage());
    }

    Shell shell = getShell();
    IJavaSearchScope iJavaSearchScope = SearchEngine.createJavaSearchScope(javaElementArray, false);
    PackageSelectionDialog packageSelectionDialog =
        new PackageSelectionDialog(
            shell,
            new ProgressMonitorDialog(shell),
            PackageSelectionDialog.F_REMOVE_DUPLICATES | PackageSelectionDialog.F_HIDE_EMPTY_INNER,
            iJavaSearchScope);

    packageSelectionDialog.setTitle(Messages.WizardPageChooseSourceFolderAndPackage_32);
    packageSelectionDialog.setMessage(Messages.WizardPageChooseSourceFolderAndPackage_33);

    if (packageSelectionDialog.open() == Window.OK) {
      Object results[] = packageSelectionDialog.getResult();
      if (results != null && results.length > 0) {
        PackageFragment packageFragment = (PackageFragment) results[0];
        txtPackage.setText(packageFragment.getElementName());
        EclipseGeneratorUtil.javaEntityPackage = packageFragment.getElementName();
      }
    }
  }
  /* (non-Javadoc)
   * @see org.eclipse.jface.wizard.Wizard#addPages()
   */
  public void addPages() {
    WizardElement templateWizardElement = getTemplateWizard();
    if (templateWizardElement == null) {
      MessageDialog.openError(
          getShell(),
          PDEUIMessages.NewPluginProjectFromTemplateWizard_1,
          NLS.bind(PDEUIMessages.NewPluginProjectFromTemplateWizard_0, getTemplateID()));
      return;
    }

    fProjectPage =
        new NewProjectCreationFromTemplatePage(
            "main", fPluginData, getSelection(), templateWizardElement); // $NON-NLS-1$
    fProjectPage.setTitle(PDEUIMessages.NewProjectWizard_MainPage_title);
    fProjectPage.setDescription(PDEUIMessages.NewProjectWizard_MainPage_desc);

    String projectName = getDefaultValue(DEF_PROJECT_NAME);
    if (projectName != null) fProjectPage.setInitialProjectName(projectName);
    addPage(fProjectPage);

    fProjectProvider =
        new IProjectProvider() {
          public String getProjectName() {
            return fProjectPage.getProjectName();
          }

          public IProject getProject() {
            return fProjectPage.getProjectHandle();
          }

          public IPath getLocationPath() {
            return fProjectPage.getLocationPath();
          }
        };

    fContentPage =
        new PluginContentPage("page2", fProjectProvider, fProjectPage, fPluginData); // $NON-NLS-1$
    addPage(fContentPage);

    try {
      fTemplateWizard = (IPluginContentWizard) templateWizardElement.createExecutableExtension();
      fTemplateWizard.init(fPluginData);
      fTemplateWizard.addPages();
      IWizardPage[] pages = fTemplateWizard.getPages();
      for (int i = 0; i < pages.length; i++) {
        addPage(pages[i]);
      }
    } catch (CoreException e) {
      MessageDialog.openError(
          getShell(),
          PDEUIMessages.NewPluginProjectFromTemplateWizard_1,
          NLS.bind(PDEUIMessages.NewPluginProjectFromTemplateWizard_0, getTemplateID()));
    }
  }
  /** The behaviour of the action. Checks if the name entered by the user is valid. */
  public void run() {
    ISelection selection = viewer.getSelection();
    if (selection.isEmpty()) {
      this.setEnabled(false);
    }
    TreeObject object = (TreeObject) ((IStructuredSelection) selection).getFirstElement();
    if (object instanceof DocumentTreeObject) {

      String oldValue = object.getValue().toString();

      IInputValidator validator = new TextValidator(oldValue);
      InputDialog dialog =
          new InputDialog(
              parent.getShell(),
              Properties.getProperty("rename"),
              Properties.getProperty("new_name"),
              oldValue,
              validator);
      dialog.setBlockOnOpen(true); // waits for user enter a name

      int res = dialog.open(); // opens the rename dialog

      if (res == InputDialog.OK) {
        String newValue = dialog.getValue();

        String newExtension = GUIUtil.getFileExtension(newValue);
        String oldExtension = GUIUtil.getFileExtension(oldValue);

        if (!newExtension.equalsIgnoreCase(oldExtension)) {
          newValue += oldExtension;
        }

        if (!newValue.equalsIgnoreCase(oldValue)) {
          if (!ProjectManagerController.getInstance().renameDocument(oldValue, newValue)) {
            MessageDialog.openError(
                parent.getShell(),
                Properties.getProperty("error_while_renaming"),
                Properties.getProperty("can_not_rename"));
          }
          try {
            GUIManager.getInstance().refreshViews();
          } catch (TargetException e) {
            MessageDialog.openError(
                this.parent.getShell(),
                Properties.getProperty("error_while_reloading_project"),
                e.getMessage());
            e.printStackTrace();
          }
        }
      }
    }
  }
  // 选择一个粒子效果作为绑定的预览效果
  private void onPreviewParticleEffect() {
    if (!glMode) {
      MessageDialog.openError(getShell(), "错误", "只有OpenGL模式才能使用此功能。");
      return;
    }

    if (hookPoint == null) {
      MessageDialog.openError(getShell(), "错误", "请先选择一个挂接点。");
      return;
    }

    ownerEditor.hookParticleEffect(hookPoint);
  }
  protected void okPressed() {

    if (key == null || key.equals("")) { // $NON-NLS-1$
      MessageDialog.openError(
          getShell(), INVALID_PROMPT.getText(keyPrompt), MUST_NOT_BE_BLANK.getText(keyPrompt));
      return;
    }
    if (value == null || value.equals("")) { // $NON-NLS-1$
      MessageDialog.openError(
          getShell(), INVALID_PROMPT.getText(valuePrompt), MUST_NOT_BE_BLANK.getText(valuePrompt));
      return;
    }
    super.okPressed();
  }
  private void openMoreInformaionInBrowser() {
    String moreInformationUrl = studyParameters.getMoreInformationUrl();
    try {
      if (WebBrowserPreference.getBrowserChoice() == WebBrowserPreference.EXTERNAL) {
        try {
          IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
          support.getExternalBrowser().openURL(new URL(moreInformationUrl));
        } catch (Exception e) {
          StatusHandler.fail(
              new Status(
                  IStatus.ERROR,
                  UiUsageMonitorPlugin.ID_PLUGIN,
                  "Could not open url",
                  e)); //$NON-NLS-1$
        }
      } else {
        IWebBrowser browser = null;
        int flags = 0;
        if (WorkbenchBrowserSupport.getInstance().isInternalWebBrowserAvailable()) {
          flags =
              IWorkbenchBrowserSupport.AS_EDITOR
                  | IWorkbenchBrowserSupport.LOCATION_BAR
                  | IWorkbenchBrowserSupport.NAVIGATION_BAR;

        } else {
          flags =
              IWorkbenchBrowserSupport.AS_EXTERNAL
                  | IWorkbenchBrowserSupport.LOCATION_BAR
                  | IWorkbenchBrowserSupport.NAVIGATION_BAR;
        }

        String generatedId =
            "org.eclipse.mylyn.web.browser-"
                + Calendar.getInstance().getTimeInMillis(); // $NON-NLS-1$
        browser =
            WorkbenchBrowserSupport.getInstance().createBrowser(flags, generatedId, null, null);
        browser.openURL(new URL(moreInformationUrl));
      }
    } catch (PartInitException e) {
      MessageDialog.openError(
          Display.getDefault().getActiveShell(),
          "Browser init error", //$NON-NLS-1$
          "Browser could not be initiated"); //$NON-NLS-1$
    } catch (MalformedURLException e) {
      MessageDialog.openError(
          Display.getDefault().getActiveShell(),
          Messages.UsageDataPreferencePage_Url_Not_Found,
          NLS.bind(Messages.UsageDataPreferencePage_Unable_To_Open_X, moreInformationUrl));
    }
  }
Exemplo n.º 21
0
 @Override
 public void run() {
   try {
     IType type = TypeUtil.findType(element.getJavaProject(), element.getClazz());
     if (type != null) {
       IMethod iMethod;
       iMethod = findMethod(type, element.getMethod());
       if (iMethod == null)
         MessageDialog.openError(null, "Java Element not found", "Java Element not found");
       else JavaUI.openInEditor(iMethod);
     } else MessageDialog.openError(null, "Java Element not found", "Java Element not found");
   } catch (JavaModelException e) {
   } catch (PartInitException e) {
   }
 }
Exemplo n.º 22
0
  @Override
  public boolean performFinish() {
    try {
      // TODO Auto-generated method stub
      // See http://www.programcreek.com/2011/05/eclipse-jdt-tutorial-java-model/
      //

      IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
      // Crea un nuevo projecto
      final IProject project = root.getProject(page.getProjectName());
      project.create(null);
      project.open(null);

      // Map props = project.getPersistentProperties();

      /*			//Crear el proyecto Java
      			IProjectDescription description = project.getDescription();
      			//description.setLocation(page.getLocationPath());
      			//Associate nature
      			description.setNatureIds(new String[]{JavaCore.NATURE_ID});
      			project.setDescription(description, null);
      			IJavaProject javaProject = JavaCore.create(project);
      */
      IFolder folder = project.getFolder("models");
      folder.create(true, true, null);
      folder = project.getFolder("src-gen");
      folder.create(true, true, null);

      return true;
    } catch (CoreException e) {
      // TODO Auto-generated catch block
      MessageDialog.openError(getShell(), "Error", e.getMessage());
      return false;
    }
  }
  protected void okPressed() {
    boolean hasErrors = popupValidationErrorDialogIfNecessary();

    if (!hasErrors) {
      try {
        conceptUtil.setId(wId.getText());
      } catch (ObjectAlreadyExistsException e) {
        if (logger.isErrorEnabled()) {
          logger.error("an exception occurred", e);
        }
        MessageDialog.openError(
            getShell(),
            Messages.getString("General.USER_TITLE_ERROR"),
            Messages.getString(
                "PhysicalTableDialog.USER_ERROR_PHYSICAL_TABLE_ID_EXISTS", wId.getText()));
        return;
      }

      // attempt to set the connection
      IStructuredSelection selection = (IStructuredSelection) comboViewer.getSelection();
      DatabaseMeta con = (DatabaseMeta) selection.getFirstElement();
      BusinessModel busModel = (BusinessModel) conceptUtil;
      if (!DUMMY_CON_NAME.equals(con.getName())) {
        busModel.setConnection((DatabaseMeta) con);
      } else {
        busModel.clearConnection();
      }

      super.okPressed();
    }
  }
 @Override
 public void postExecuteFailure(String commandId, ExecutionException exception) {
   if (commandId.equals(CreateNewWriterHandler.commandId)) {
     MessageDialog.openError(
         getItem().getParent().getShell(), "Creating Stock item failed", exception.getMessage());
   }
 }
Exemplo n.º 25
0
  @Override
  public void doRun(
      IStructuredSelection selection, Event event, UIInstrumentationBuilder instrumentation) {

    instrumentation.metric("command", command);

    if (!selection.isEmpty() && selection.getFirstElement() instanceof IResource) {
      Object object = selection.getFirstElement();
      if (object instanceof IFile) {
        object = ((IFile) object).getParent();
      }
      while (object != null
          && ((IContainer) object).findMember(DartCore.PUBSPEC_FILE_NAME) == null) {
        object = ((IContainer) object).getParent();
      }
      if (object instanceof IContainer) {
        IContainer container = (IContainer) object;
        instrumentation.data("name", container.getName());
        savePubspecFile(container);
        runPubJob(container);
        return;
      } else {
        instrumentation.metric("Problem", "Object was null").log();
      }
    }

    instrumentation.metric("Problem", "pubspec.yaml file not selected, showing dialog");

    MessageDialog.openError(
        getShell(), ActionMessages.RunPubAction_fail, ActionMessages.RunPubAction_fileNotFound);

    instrumentation.log();
  }
Exemplo n.º 26
0
  public void run() {
    if (main.getBioPAXModel() == null) {
      MessageDialog.openError(main.getShell(), "Error!", "Load or query a BioPAX model first!");

      return;
    }

    // open dialog
    CompartmentQueryParamWithEntitiesDialog dialog =
        new CompartmentQueryParamWithEntitiesDialog(main);
    options = dialog.open(options);

    if (!options.isCancel()) {
      options.setCancel(true);
    } else {
      return;
    }

    // Source and target node sets

    Set<String> source = new HashSet<String>(dialog.getSourceAddedCompartments());
    Set<String> target = new HashSet<String>(dialog.getTargetAddedCompartments());

    Set<BioPAXElement> result =
        QueryExecuter.runPathsFromTo(
            BioPAXUtil.getElementsAtLocations(main.getBioPAXModel(), source),
            BioPAXUtil.getElementsAtLocations(main.getBioPAXModel(), target),
            main.getBioPAXModel(),
            options.getLimitType() ? LimitType.NORMAL : LimitType.SHORTEST_PLUS_K,
            options.getLengthLimit());

    viewAndHighlightResult(result, options.isCurrentView(), "Query Result");
  }
Exemplo n.º 27
0
  @Override
  public void generate(Shell parentShell, IType objectClass, CommandIdentifier commandIdentifier) {
    LinkedHashSet<MethodSkeleton<U>> methodSkeletons =
        methodSkeletonManager.getMethodSkeletons(commandIdentifier);
    LinkedHashSet<StrategyIdentifier> strategyIdentifiers =
        methodContentManager.getStrategiesIntersection(methodSkeletons);

    try {
      Set<IMethod> excludedMethods = getExcludedMethods(objectClass, methodSkeletons);
      FieldDialog<U> dialog =
          dialogFactory.createDialog(
              parentShell, objectClass, excludedMethods, strategyIdentifiers);
      int returnCode = dialog.getDialog().open();
      if (returnCode == Window.OK) {

        for (IMethod excludedMethod : excludedMethods) {
          excludedMethod.delete(true, null);
        }

        U data = dialog.getData();
        StrategyIdentifier selectedContentStrategy = data.getSelectedStrategyIdentifier();
        LinkedHashSet<Method<T, U>> methods =
            methodContentManager.getAllMethods(methodSkeletons, selectedContentStrategy);
        generateCode(parentShell, objectClass, data, methods);
      }

    } catch (Exception exception) {
      MessageDialog.openError(parentShell, "Method Generation Failed", exception.getMessage());
    }
  }
Exemplo n.º 28
0
 public PatchWizard(IStorage patch, IResource target, CompareConfiguration configuration) {
   Assert.isNotNull(configuration);
   this.fConfiguration = configuration;
   setDefaultPageImageDescriptor(
       CompareUIPlugin.getImageDescriptor("wizban/applypatch_wizban.png")); // $NON-NLS-1$
   setWindowTitle(PatchMessages.PatchWizard_title);
   initializeDialogSettings();
   fPatcher = new WorkspacePatcher(target);
   if (patch != null) {
     try {
       fPatcher.parse(patch);
       this.patch = patch;
       patchReadIn = true;
     } catch (IOException e) {
       MessageDialog.openError(
           null,
           PatchMessages.InputPatchPage_PatchErrorDialog_title,
           PatchMessages.InputPatchPage_ParseError_message);
     } catch (CoreException e) {
       ErrorDialog.openError(
           getShell(),
           PatchMessages.InputPatchPage_PatchErrorDialog_title,
           PatchMessages.InputPatchPage_PatchFileNotFound_message,
           e.getStatus());
     }
   }
 }
Exemplo n.º 29
0
  protected void testQuery() {
    try {
      // ClassArrayShell whether model is null
      if (sqlPredicate == null) {
        MessageDialog.openWarning(top.getShell(), "Warning!", "The predicate is null");
        //		return;
      }
      // ClassArrayShell whether there is a name
      if (textName.getText() == null || textName.getText().trim().length() == 0) {
        MessageDialog.openWarning(top.getShell(), "Warning!", "The predicate should have a name");
        //		return;
      }
      // ClassArrayShell whether there is a data source
      if (sqlPredicate.getDataSource() == null) {
        MessageDialog.openWarning(top.getShell(), "Warning!", "There is no datasource set");
        //		return;
      }

      // ClassArrayShell SQL
      DataSource ds = sqlPredicate.getDataSource();
      Connection con = ds.getConnection();
      java.sql.Statement stmt = con.createStatement();
      final ResultSet rs = stmt.executeQuery(sqlPredicate.getQuery());

      QueryResultsDialog dialog = new QueryResultsDialog(getSite().getShell(), sqlPredicate, rs);
      dialog.create();
      if (dialog.open() != InputDialog.OK) return;
    } catch (Exception x) {
      MessageDialog.openError(top.getShell(), "Error!", "Test has failed");
    }
  }
Exemplo n.º 30
0
  /**
   * Check if any error occurred during initialization. If it did, display an error message.
   *
   * @return True if an error occurred, false if we should continue.
   */
  public boolean checkIfInitFailed() {
    if (mAvdManagerInitError != null) {
      String example;
      if (SdkConstants.currentPlatform() == SdkConstants.PLATFORM_WINDOWS) {
        example = "%USERPROFILE%"; // $NON-NLS-1$
      } else {
        example = "~"; // $NON-NLS-1$
      }

      String error =
          String.format(
              "The AVD manager normally uses the user's profile directory to store "
                  + "AVD files. However it failed to find the default profile directory. "
                  + "\n"
                  + "To fix this, please set the environment variable ANDROID_SDK_HOME to "
                  + "a valid path such as \"%s\".",
              example);

      // We may not have any UI. Only display a dialog if there's a window shell available.
      if (mWindowShell != null && !mWindowShell.isDisposed()) {
        MessageDialog.openError(mWindowShell, "Android Virtual Devices Manager", error);
      } else {
        mSdkLog.error(null /* Throwable */, "%s", error); // $NON-NLS-1$
      }

      return true;
    }
    return false;
  }