/**
   * Permet de créer la région en 0,0 pour le diagramme
   *
   * @generated NOT
   */
  @Override
  public void activate() {
    super.activate();

    AbstractEMFOperation emfOp =
        new AbstractEMFOperation(getEditingDomain(), "Location setting") {

          @Override
          protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
              throws ExecutionException {
            // TODO Auto-generated method stub
            // Recupération du layout et mis a jour en (0,0)
            Location lc = (Location) ((Node) getModel()).getLayoutConstraint();
            lc.setX(0);
            lc.setY(0);

            return Status.OK_STATUS;
          }
        };

    IStatus status;

    try {
      status = OperationHistoryFactory.getOperationHistory().execute(emfOp, null, null);
    } catch (ExecutionException e) {
      status =
          new Status(IStatus.ERROR, ImaginDataDiagramEditorPlugin.ID, "Setting location failed", e);
    }

    if (status.getCode() == IStatus.WARNING || status.getCode() == IStatus.ERROR) {
      ImaginDataDiagramEditorPlugin.getInstance().getLog().log(status);
    }
  }
  private void swallowError(IPath file, Throwable e) throws CoreException {
    IStatus s;
    /*
     * If the thrown CoreException is for a STATUS_PDOM_TOO_LARGE, we don't want to
     * swallow this one.
     */
    if (e instanceof CoreException) {
      s = ((CoreException) e).getStatus();
      if (s.getCode() == CCorePlugin.STATUS_PDOM_TOO_LARGE) {
        if (CCorePlugin.PLUGIN_ID.equals(s.getPlugin())) throw (CoreException) e;
      }

      // mask errors in order to avoid dialog from platform
      Throwable exception = s.getException();
      if (exception != null) {
        Throwable masked = getMaskedException(exception);
        if (masked != exception) {
          e = masked;
          exception = null;
        }
      }
      if (exception == null) {
        s = new Status(s.getSeverity(), s.getPlugin(), s.getCode(), s.getMessage(), e);
      }
    } else {
      e = getMaskedException(e);
      s = createStatus(getMessage(MessageKind.errorWhileParsing, file), e);
    }
    logError(s);
    if (++fStatistics.fErrorCount > MAX_ERRORS) {
      throw new CoreException(createStatus(getMessage(MessageKind.tooManyIndexProblems)));
    }
  }
Ejemplo n.º 3
0
 public IBuffer getBuffer() throws JavaModelException {
   IStatus status = validateClassFile();
   if (status.isOK()) {
     return super.getBuffer();
   } else {
     // .class file not on classpath, create a new buffer to be nice (see
     // https://bugs.eclipse.org/bugs/show_bug.cgi?id=41444)
     Object info = ((ClassFile) getClassFile()).getBinaryTypeInfo((IFile) resource());
     IBuffer buffer = openBuffer(null, info);
     if (buffer != null && !(buffer instanceof NullBuffer)) return buffer;
     switch (status.getCode()) {
       case IJavaModelStatusConstants
           .ELEMENT_NOT_ON_CLASSPATH: // don't throw a JavaModelException to be able to open .class
         // file outside the classpath (see
         // https://bugs.eclipse.org/bugs/show_bug.cgi?id=138507 )
       case IJavaModelStatusConstants
           .INVALID_ELEMENT_TYPES: // don't throw a JavaModelException to be able to open .class
         // file in proj==src case without source (see
         // https://bugs.eclipse.org/bugs/show_bug.cgi?id=221904 )
         return null;
       default:
         throw new JavaModelException((IJavaModelStatus) status);
     }
   }
 }
Ejemplo n.º 4
0
 /**
  * @see org.teiid.designer.core.workspace.ModelWorkspace#createModelProject(java.lang.String,
  *     java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
  * @since 4.0
  */
 @Override
 public ModelProject createModelProject(
     final String name, final IPath path, final IProgressMonitor monitor) throws CoreException {
   CoreArgCheck.isNotNull(name);
   // Check if project already exists
   if (findModelProject(name) != null) {
     throw new ModelWorkspaceException(
         ModelerCore.Util.getString(
             "ModelWorkspaceImpl.cannotCreateModelProject", name)); // $NON-NLS-1$
   }
   // Validate name
   final IWorkspace workspace = ModelerCore.getWorkspace();
   final IStatus status = workspace.validateName(name, IResource.PROJECT);
   if (!status.isOK()) {
     throw new ModelWorkspaceException(
         new ModelStatusImpl(status.getSeverity(), status.getCode(), status.getMessage()));
   }
   // Create new model project
   final IProject project = workspace.getRoot().getProject(name);
   final IProjectDescription desc = workspace.newProjectDescription(project.getName());
   desc.setLocation(path);
   desc.setNatureIds(MODEL_NATURES);
   final IWorkspaceRunnable op =
       new IWorkspaceRunnable() {
         @Override
         public void run(final IProgressMonitor monitor) throws CoreException {
           project.create(desc, monitor);
           project.open(monitor);
         }
       };
   workspace.run(op, monitor);
   return new ModelProjectImpl(project, this);
 }
Ejemplo n.º 5
0
  /**
   * Checks if there was an error.
   *
   * @param caller The caller or <code>null</code>.
   * @param status The status. <code>null</code> if status should not be checked.
   * @param callback The callback to call on cancel or error.
   * @return <code>false</code> if everything is OK.
   */
  public static final boolean isError(Object caller, IStatus status, ICallback callback) {
    if (status == null) status = Status.OK_STATUS;

    if (!status.isOK() && status.getSeverity() != IStatus.CANCEL) {
      if (status.getSeverity() == IStatus.ERROR) {
        Throwable e = status.getException();
        try {
          throw e;
        } catch (Throwable thrown) {
          e = thrown;
        }
        CoreBundleActivator.getTraceHandler()
            .trace(
                status.getMessage(),
                1,
                ITraceIds.TRACE_CALLBACKS,
                status.getSeverity(),
                caller != null ? caller.getClass() : ProgressHelper.class);
        status =
            new Status(IStatus.ERROR, status.getPlugin(), status.getCode(), status.getMessage(), e);
      }

      if (callback != null) {
        if (caller instanceof ICallback) {
          Callback.copyProperties((ICallback) caller, callback);
        }
        callback.done(caller, status);
      }
      return true;
    }
    return false;
  }
Ejemplo n.º 6
0
 private IIndexFragmentName createPDOMName(PDOMLinkage linkage, IASTName name, PDOMName caller)
     throws CoreException {
   final IBinding binding = name.getBinding();
   if (binding instanceof IParameter) {
     return null;
   }
   try {
     if (binding instanceof IMacroBinding
         || (binding == null
             && name.getPropertyInParent() == IASTPreprocessorStatement.MACRO_NAME)) {
       return createPDOMMacroReferenceName(linkage, name);
     }
     PDOMBinding pdomBinding = linkage.addBinding(name);
     if (pdomBinding != null) {
       final PDOMName result = new PDOMName(fLinkage, name, this, pdomBinding, caller);
       linkage.onCreateName(this, name, result);
       return result;
     }
   } catch (CoreException e) {
     final IStatus status = e.getStatus();
     if (status != null && status.getCode() == CCorePlugin.STATUS_PDOM_TOO_LARGE) {
       if (CCorePlugin.PLUGIN_ID.equals(status.getPlugin())) throw e;
     }
     CCorePlugin.log(e);
   }
   return null;
 }
 public void helpIsValidJdbcSource(
     final JdbcSource source, final int expectedCode, final int expectedSeverity) {
   final IStatus status = mgr.isValid(source);
   assertNotNull(status);
   assertEquals(expectedCode, status.getCode());
   assertEquals(expectedSeverity, status.getSeverity());
 }
 public void helpIsValidJdbcDriver(
     final JdbcDriver driver, final int expectedCode, final int expectedSeverity) {
   final IStatus status = mgr.isValid(driver);
   assertNotNull(status);
   assertEquals(expectedCode, status.getCode());
   assertEquals(expectedSeverity, status.getSeverity());
 }
  // Code copied from PlatformLogWriter.getLog(). Why is logging an IStatus so
  // hard?
  FrameworkLogEntry createLogEntry(IStatus status) {
    Throwable t = status.getException();
    ArrayList childlist = new ArrayList();

    int stackCode = t instanceof CoreException ? 1 : 0;
    // ensure a substatus inside a CoreException is properly logged
    if (stackCode == 1) {
      IStatus coreStatus = ((CoreException) t).getStatus();
      if (coreStatus != null) {
        childlist.add(createLogEntry(coreStatus));
      }
    }

    if (status.isMultiStatus()) {
      IStatus[] children = status.getChildren();
      for (int i = 0; i < children.length; i++) {
        childlist.add(createLogEntry(children[i]));
      }
    }

    FrameworkLogEntry[] children =
        (FrameworkLogEntry[])
            (childlist.size() == 0
                ? null
                : childlist.toArray(new FrameworkLogEntry[childlist.size()]));

    return new FrameworkLogEntry(
        status.getPlugin(),
        status.getSeverity(),
        status.getCode(),
        status.getMessage(),
        stackCode,
        t,
        children);
  }
  /**
   * Shows the specified <code>status</code>'s children in the "Details" area of an information
   * dialog.
   *
   * @param event the live validation occurred event
   */
  private void showLiveValidationDialog(final ValidationEvent event) {
    IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (workbenchWindow != null) {
      IStatus[] details = toStatusArray(event);

      String message =
          event.getSeverity() >= IStatus.ERROR
              ? ValidationUIMessages.Validation_liveError
              : null; // show the constraint message as the primary message

      // the dialog should show INFO severity for errors because
      //   the corrective action has already been taken by the
      //   system; the user is just being informed that everything
      //   is still OK.  Warnings, however, require corrective
      //   action by the user.
      final int dialogSeverity = event.matches(IStatus.WARNING) ? IStatus.WARNING : IStatus.INFO;

      // get the first of the most severe error messages and use
      //   it in the summary message presented to the user
      IStatus primary = getFirstStatus(details, event.getSeverity());

      IStatus toDisplay;

      if (details.length > 1) {
        toDisplay =
            new MultiStatus(
                ValidationUIPlugin.getPlugin().getBundle().getSymbolicName(),
                0,
                details,
                primary.getMessage(),
                null) {

              /**
               * Redefines the inherited method to always return the more appropriate severity for
               * the dialog.
               */
              @Override
              public int getSeverity() {
                return dialogSeverity;
              }
            };
      } else {
        toDisplay =
            new Status(
                dialogSeverity,
                primary.getPlugin(),
                primary.getCode(),
                primary.getMessage(),
                primary.getException());
      }

      new LiveValidationDialog(
              Display.getCurrent().getActiveShell(),
              ValidationUIMessages.Validation_liveDialogTitle,
              message,
              toDisplay)
          .open();
    }
  }
Ejemplo n.º 11
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;
  }
Ejemplo n.º 12
0
 public void helpCheckClassNameForError(
     final int expectedCode, final int expectedSeverity, final String className) {
   final IStatus status = mgr.checkClassNameForError(className);
   if (expectedCode != VALID_CLASS_NAME) {
     assertEquals(expectedCode, status.getCode());
     assertEquals(expectedSeverity, status.getSeverity());
   }
 }
Ejemplo n.º 13
0
  /**
   * Finds available WSO2 features in current profile and search for updates to them in WSO2 p2
   * repository for updates.
   *
   * @param monitor
   * @throws Exception
   */
  public void checkForAvailableUpdates(IProgressMonitor monitor) throws Exception {
    if (monitor == null) {
      monitor = new NullProgressMonitor();
    }
    SubMonitor progress = SubMonitor.convert(monitor, Messages.UpdateManager_18, 6);

    // get all available IUs in update repository
    IMetadataRepository metadataRepo =
        metadataRepoManager.loadRepository(getDevStudioUpdateSite(), progress.newChild(1));
    IQuery<IInstallableUnit> allIUQuery = QueryUtil.createIUAnyQuery();
    IQueryResult<IInstallableUnit> allIUQueryResult =
        metadataRepo.query(allIUQuery, progress.newChild(1));

    // read artifact repository for updates
    IArtifactRepository artifactRepo =
        artifactRepoManager.loadRepository(getDevStudioUpdateSite(), progress.newChild(1));

    // read meta-data of all available features
    Map<String, EnhancedFeature> allFeaturesInUpdateRepo =
        loadWSO2FeaturesInRepo(artifactRepo, allIUQueryResult, progress.newChild(1));

    // get all installed wso2 features
    Collection<IInstallableUnit> installedWSO2Features =
        getInstalledWSO2Features(progress.newChild(1));

    installedWSO2FeaturesMap = new HashMap<String, IInstallableUnit>();
    for (IInstallableUnit iInstallableUnit : installedWSO2Features) {
      installedWSO2FeaturesMap.put(iInstallableUnit.getId(), iInstallableUnit);
    }

    if (progress.isCanceled()) {
      throw new OperationCanceledException();
    }

    URI[] repos = new URI[] {getDevStudioUpdateSite()};
    updateOperation = new UpdateOperation(session, installedWSO2Features);
    updateOperation.getProvisioningContext().setArtifactRepositories(repos);
    updateOperation.getProvisioningContext().setMetadataRepositories(repos);

    // resolve update operation
    IStatus status = updateOperation.resolveModal(progress.newChild(1));
    // user cancelled the job while resolving
    if (status.getSeverity() == IStatus.CANCEL || progress.isCanceled()) {
      throw new OperationCanceledException();
    }
    // there is nothing to update
    if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) {
      featuresWithPossibleUpdates = new HashMap<String, EnhancedFeature>();
      log.info(Messages.UpdateManager_19);
    } else if (status.getSeverity() == IStatus.ERROR) { // resolution errors
      // something wrong with the updates
      log.info(Messages.UpdateManager_20);
    } else {
      // good to proceed installing updates
      setPossibleUpdates(updateOperation.getPossibleUpdates(), allFeaturesInUpdateRepo);
    }
  }
Ejemplo n.º 14
0
 public ServerStatus(IStatus status, int httpCode) {
   super(
       status.getSeverity(),
       status.getPlugin(),
       status.getCode(),
       status.getMessage(),
       status.getException());
   this.httpCode = httpCode;
 }
Ejemplo n.º 15
0
 public ServerStatus(IStatus status, int httpCode, JSONObject jsonData) {
   super(
       status.getSeverity(),
       status.getPlugin(),
       status.getCode(),
       status.getMessage(),
       status.getException());
   this.httpCode = httpCode;
   this.jsonData = jsonData;
 }
  /**
   * Tests a JDT feature bundle container contains the appropriate bundles for a specific OS.
   *
   * @throws Exception
   */
  public void testMacOSFeatureBundleContainer() throws Exception {
    // extract the feature
    IPath location = extractModifiedFeatures();

    ITargetDefinition definition = getNewTarget();
    definition.setOS(Platform.OS_MACOSX);
    ITargetLocation container =
        getTargetService().newFeatureLocation(location.toOSString(), "org.eclipse.jdt", null);
    container.resolve(definition, null);
    TargetBundle[] bundles = container.getBundles();

    List expected = new ArrayList();
    expected.add("org.eclipse.jdt");
    expected.add("org.eclipse.jdt.launching");
    // 2 versions of JUnit
    expected.add("org.junit");
    expected.add("org.junit");
    expected.add("org.junit4");
    expected.add("org.eclipse.jdt.launching.macosx");

    assertEquals("Wrong number of bundles in JDT feature", expected.size(), bundles.length);
    for (int i = 0; i < bundles.length; i++) {
      String symbolicName = bundles[i].getBundleInfo().getSymbolicName();
      expected.remove(symbolicName);
      if (symbolicName.equals("org.eclipse.jdt.launching.macosx")) {
        // the bundle should be missing unless on Mac
        IStatus status = bundles[i].getStatus();
        if (Platform.getOS().equals(Platform.OS_MACOSX)) {
          assertTrue("Mac bundle should be present", status.isOK());
        } else {
          assertFalse("Mac bundle should be missing", status.isOK());
          assertEquals(
              "Mac bundle should be mssing",
              TargetBundle.STATUS_PLUGIN_DOES_NOT_EXIST,
              status.getCode());
        }
      }
    }
    Iterator iterator = expected.iterator();
    while (iterator.hasNext()) {
      String name = (String) iterator.next();
      System.err.println("Missing: " + name);
    }
    assertTrue("Wrong bundles in JDT feature", expected.isEmpty());

    // should be no source bundles
    for (int i = 0; i < bundles.length; i++) {
      TargetBundle bundle = bundles[i];
      assertFalse("Should be no source bundles", bundle.isSourceBundle());
    }
  }
Ejemplo n.º 17
0
 /**
  * Handles the exception thrown from JDT Core when the attached Javadoc cannot be retrieved due to
  * accessibility issues or location URL issue. This exception is not logged but the exceptions
  * occurred due to other reasons are logged.
  *
  * @param e the exception thrown when retrieving the Javadoc fails
  * @return the String message for why the Javadoc could not be retrieved
  * @since 3.9
  */
 public static String handleFailedJavadocFetch(CoreException e) {
   IStatus status = e.getStatus();
   if (JavaCore.PLUGIN_ID.equals(status.getPlugin())) {
     Throwable cause = e.getCause();
     int code = status.getCode();
     // See bug 120559, bug 400060 and bug 400062
     if (code == IJavaModelStatusConstants.CANNOT_RETRIEVE_ATTACHED_JAVADOC_TIMEOUT
         || (code == IJavaModelStatusConstants.CANNOT_RETRIEVE_ATTACHED_JAVADOC
             && (cause instanceof FileNotFoundException
                 || cause instanceof SocketException
                 || cause instanceof UnknownHostException
                 || cause instanceof ProtocolException)))
       return CorextMessages.JavaDocLocations_error_gettingAttachedJavadoc;
   }
   JavaPlugin.log(e);
   return CorextMessages.JavaDocLocations_error_gettingJavadoc;
 }
Ejemplo n.º 18
0
  /** As per Bug 289458 */
  public void testShowErrorAfterValidationOnUpdateWithBlock() {
    final ValidRange rule = new ValidRange(18, 80);
    valueBindingSupport.addValidationRule(rule, ValidationTime.ON_UPDATE_TO_MODEL);
    final IStatus errorStatus = rule.validate("81"); // $NON-NLS-1$
    assertEquals(ValidationRuleStatus.ERROR_BLOCK_WITH_FLASH, errorStatus.getCode());

    assertEquals(0, markable.getMarkersOfType(ErrorMarker.class).size());

    valueBindingSupport.updateValidationStatus(rule, errorStatus);

    assertEquals(1, markable.getMarkersOfType(ErrorMarker.class).size());

    final IStatus okStatus = rule.validate("80"); // $NON-NLS-1$
    valueBindingSupport.updateValidationStatus(rule, okStatus);

    assertEquals(0, markable.getMarkersOfType(ErrorMarker.class).size());
  }
Ejemplo n.º 19
0
  public void testDeleteUnMergedBranch() throws Throwable {
    testAddBranch();

    assertSwitchBranch("my_new_branch");

    // Now we need to make changes, commit and then switch back to master
    GitIndex index = getRepo().index();

    // TODO Refactor out common code with testAddFileStageUnstageCommit
    // Actually add a file to the location
    String txtFile = getRepo().workingDirectory() + File.separator + "file_on_branch.txt";
    FileWriter writer = new FileWriter(txtFile);
    writer.write("Hello Branched World!");
    writer.close();
    // refresh the index
    index.refresh(new NullProgressMonitor());

    // Now there should be a single file that's been changed!
    List<ChangedFile> changedFiles = index.changedFiles();
    assertEquals(
        "repository changed file listing should contain one entry for a new file_on_branch.txt file, but does not",
        1,
        changedFiles.size());

    // Make sure it's shown as having unstaged changes only and is NEW
    assertNewUnstagedFile(changedFiles.get(0));

    // Stage the new file
    assertStageFiles(index, changedFiles);
    assertNewStagedFile(changedFiles.get(0));

    assertCommit(index, "Initial commit");

    // Now switch to master
    assertSwitchBranch("master");

    IStatus status = getRepo().deleteBranch("my_new_branch");
    assertFalse(
        "Deleting an umerged branch didn't return an error status (as it should)", status.isOK());
    assertEquals(1, status.getCode());
    // Can't rely on the unmerged failure message from git to remain the same across versions.
    // assertEquals(
    // "error: The branch 'my_new_branch' is not an ancestor of your current HEAD.\nIf you are sure
    // you want to delete it, run 'git branch -D my_new_branch'.",
    // status.getMessage());
  }
  /**
   * @see org.teiid.designer.core.query.QueryValidationResult#getUpdateStatusList(int cmdType)
   * @since 7.3
   */
  @Override
  public Collection<IStatus> getUpdateStatusList(int cmdType) {
    if (getUpdateStatusList() == null || getUpdateStatusList().isEmpty())
      return getUpdateStatusList();

    LinkedList<IStatus> cmdStatusList = new LinkedList<IStatus>();
    for (IStatus status : getUpdateStatusList()) {
      int code = status.getCode();

      if (code != QueryValidator.ALL_UPDATE_SQL_PROBLEM) {
        switch (cmdType) {
          case QueryValidator.INSERT_TRNS:
            {
              if (code != QueryValidator.INSERT_SQL_PROBLEM) {
                continue;
              }
            }
            break;
          case QueryValidator.UPDATE_TRNS:
            {
              if (code != QueryValidator.UPDATE_SQL_PROBLEM) {
                continue;
              }
            }
            break;
          case QueryValidator.DELETE_TRNS:
            {
              if (code != QueryValidator.DELETE_SQL_PROBLEM) {
                continue;
              }
            }
            break;
        }
      }

      if (status.getSeverity() > IStatus.WARNING) {
        cmdStatusList.addFirst(status);
      } else {
        cmdStatusList.add(status);
      }
    }

    return cmdStatusList;
  }
Ejemplo n.º 21
0
  public IStatus service(Command command, IProcess context)
      throws InterruptedException, CoreException {
    UpdateFeature updateFeature = (UpdateFeature) command;
    String featureId = updateFeature.getId();

    ProvisioningSession session = PlatformPlugin.createProvisioningSession();

    IProfile profile = PlatformPlugin.getProfileRegistry().getProfile(IProfileRegistry.SELF);
    IQuery<IInstallableUnit> query =
        QueryUtil.createLatestQuery(QueryUtil.createIUQuery(featureId));
    IQueryResult<IInstallableUnit> result = profile.query(query, new NullProgressMonitor());

    if (result.isEmpty()) {
      return Status.OK_STATUS;
    }

    UpdateOperation op = new UpdateOperation(session, result.toSet());
    IStatus status = op.resolveModal(new NullProgressMonitor());

    if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) {
      return Status.OK_STATUS;
    }
    if (status.getSeverity() == IStatus.CANCEL) {
      // should not happen,
      throw new CoreException(status);
    }

    if (status.getSeverity() == IStatus.ERROR) {
      throw new CoreException(status);
    }

    ProvisioningJob job = op.getProvisioningJob(null);
    if (job == null) {
      return Status.OK_STATUS;
    }

    status = job.runModal(new NullProgressMonitor());
    if (status.getSeverity() == IStatus.CANCEL) throw new CoreException(status);

    return Status.OK_STATUS;
  }
 /**
  * Add this exception to the collector. If a log was specified in the constructor then the
  * exception will be output to the log. You can retreive exceptions using <code>getStatus</code>.
  *
  * @param exception the exception to collect
  */
 public void handleException(CoreException exception) {
   // log the exception if we have a log
   if (log != null) {
     log.log(new Status(severity, pluginId, 0, message, exception));
   }
   // Record each status individually to flatten the resulting multi-status
   IStatus exceptionStatus = exception.getStatus();
   // Wrap the exception so the stack trace is not lost.
   IStatus status =
       new Status(
           exceptionStatus.getSeverity(),
           exceptionStatus.getPlugin(),
           exceptionStatus.getCode(),
           exceptionStatus.getMessage(),
           exception);
   recordStatus(status);
   IStatus[] children = status.getChildren();
   for (int i = 0; i < children.length; i++) {
     IStatus status2 = children[i];
     recordStatus(status2);
   }
 }
Ejemplo n.º 23
0
  public boolean execute(IProgressMonitor pm, IOperationListener listener) throws CoreException {

    IStatus status = OperationsManager.getValidator().validatePendingConfig(feature);
    if (status != null && status.getCode() == IStatus.ERROR) {
      throw new CoreException(status);
    }
    try {
      targetSite.configure(feature);
      // ensureUnique();

      // Restart not needed
      boolean restartNeeded = false;

      // Check if this operation is cancelling one that's already pending
      IOperation pendingOperation = OperationsManager.findPendingOperation(feature);

      if (pendingOperation instanceof IUnconfigFeatureOperation) {
        // no need to do either pending change
        OperationsManager.removePendingOperation(pendingOperation);
      } else {
        OperationsManager.addPendingOperation(this);
      }

      markProcessed();
      if (listener != null) listener.afterExecute(this, null);

      restartNeeded = SiteManager.getLocalSite().save() && restartNeeded;

      // notify the model
      OperationsManager.fireObjectChanged(feature, null);

      return restartNeeded;
    } catch (CoreException e) {
      undo();
      UpdateUtils.logException(e);
      throw e;
    }
  }
Ejemplo n.º 24
0
  /**
   * Checks if the operation was canceled.
   *
   * @param caller The caller or <code>null</code>.
   * @param status The status. <code>null</code> if status should not be checked.
   * @param progress The progress monitor. <code>null</code> if cancel should not be checked.
   * @param callback The callback to call on cancel or error.
   * @return <code>false</code> if everything is OK.
   */
  public static final boolean isCancel(
      Object caller, IStatus status, IProgressMonitor progress, ICallback callback) {
    if (status == null) status = Status.OK_STATUS;

    if (status.getSeverity() == IStatus.CANCEL || (progress != null && progress.isCanceled())) {
      status =
          new Status(
              IStatus.CANCEL,
              status.getPlugin(),
              status.getCode(),
              status.getMessage(),
              new OperationCanceledException());

      if (callback != null) {
        if (caller instanceof ICallback) {
          Callback.copyProperties((ICallback) caller, callback);
        }
        callback.done(caller, status);
      }
      return true;
    }
    return false;
  }
  @Test
  public void test() {

    Path path = new Path("/Users/danielbfranco/temp/ranking.db");
    DbModel model = null;
    try {
      model = new DbModel(path);
    } catch (MotodevDbException e) {
      e.printStackTrace();
    }
    IStatus s = model.connect();
    assertTrue(s.getCode() == IStatus.OK);

    Table table = model.getTable("mablinhos3");

    TableNode node = new TableNode(table, model, null);
    node.browseTableContents();

    try {
      Thread.sleep(5000);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
 /*
  * (non-Javadoc)
  *
  * @see
  * org.eclipse.ui.internal.e4.compatibility.WorkbenchPartReference#createPart
  * ()
  */
 @Override
 public IWorkbenchPart createPart() throws PartInitException {
   try {
     if (descriptor == null) {
       return createErrorPart();
     } else if (descriptor.getId().equals(IEditorRegistry.SYSTEM_INPLACE_EDITOR_ID)) {
       IEditorPart part = ComponentSupport.getSystemInPlaceEditor();
       if (part == null) {
         throw new PartInitException(WorkbenchMessages.EditorManager_no_in_place_support);
       }
       return part;
     }
     return descriptor.createEditor();
   } catch (CoreException e) {
     IStatus status = e.getStatus();
     throw new PartInitException(
         new Status(
             IStatus.ERROR,
             WorkbenchPlugin.PI_WORKBENCH,
             status.getCode(),
             status.getMessage(),
             e));
   }
 }
Ejemplo n.º 27
0
 private void processStatus(IStatus status) {
   pluginId = status.getPlugin();
   severity = status.getSeverity();
   code = status.getCode();
   fDate = new Date();
   message = status.getMessage();
   Throwable throwable = status.getException();
   if (throwable != null) {
     StringWriter swriter = new StringWriter();
     PrintWriter pwriter = new PrintWriter(swriter);
     throwable.printStackTrace(pwriter);
     pwriter.flush();
     pwriter.close();
     stack = swriter.toString();
   }
   IStatus[] schildren = status.getChildren();
   if (schildren.length > 0) {
     children = new ArrayList();
     for (int i = 0; i < schildren.length; i++) {
       LogEntry child = new LogEntry(schildren[i]);
       addChild(child);
     }
   }
 }
 /**
  * @return Returns <code>true</code> if the attribute a on a container child and is not supported
  */
 public boolean isNotSupported() {
   return fStatus != null
       && fStatus.getCode() == ClasspathContainerInitializer.ATTRIBUTE_NOT_SUPPORTED;
 }