Java Code Examples for org.eclipse.core.runtime.IStatus

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project aws-toolkit-for-eclipse, under directory /com.amazonaws.eclipse.ec2/src/com/amazonaws/eclipse/explorer/ec2/.

Source file: OpenViewAction.java

  19 
vote

@Override public void run(){
  try {
    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(viewId);
  }
 catch (  PartInitException e) {
    IStatus status=new Status(IStatus.ERROR,Ec2Plugin.PLUGIN_ID,"Unable to open view " + viewId,e);
    StatusManager.getManager().handle(status,StatusManager.LOG);
  }
}
 

Example 2

From project aws-toolkit-for-eclipse, under directory /com.amazonaws.eclipse.elasticbeanstalk/src/com/amazonaws/eclipse/elasticbeanstalk/.

Source file: Environment.java

  18 
vote

@Override public IModule[] getRootModules(IModule module) throws CoreException {
  String moduleTypeId=module.getModuleType().getId().toLowerCase();
  if (moduleTypeId.equals("jst.web")) {
    IStatus status=canModifyModules(new IModule[]{module},null);
    if (status == null || !status.isOK()) {
      throw new CoreException(status);
    }
    return new IModule[]{module};
  }
  return J2EEUtil.getWebModules(module,null);
}
 

Example 3

From project Bio-PEPA, under directory /uk.ac.ed.inf.common.ui.plotting/src/uk/ac/ed/inf/common/ui/plotting/internal/.

Source file: PlottingTools.java

  18 
vote

public void write(IChart chart,String path) throws PlottingException {
  Serializer serialiser=SerializerImpl.instance();
  Chart birtChart=((CommonChart)chart).getBirtChart();
  try {
    serialiser.write(birtChart,new BufferedOutputStream(new FileOutputStream(path)));
  }
 catch (  Exception e) {
    IStatus status=new Status(IStatus.ERROR,Plotting.PLUGIN_ID,"Serialisation error",e);
    throw new PlottingException(status);
  }
}
 

Example 4

From project bndtools, under directory /bndtools.core/src/bndtools/builder/.

Source file: NewBuilder.java

  18 
vote

void validate(Builder builder,List<IValidator> validators){
  for (  IValidator validator : validators) {
    IStatus status=validator.validate(builder);
    if (!status.isOK())     validationResults.add(status);
  }
}
 

Example 5

From project bndtools, under directory /bndtools.core/src/bndtools/wizards/bndfile/.

Source file: ExecutableJarExportWizard.java

  18 
vote

@Override public boolean performFinish(){
  IStatus status=Status.OK_STATUS;
  if (destinationPage.isFolder())   status=generateFolder(destinationPage.getFolderPath());
 else   status=generateJar(destinationPage.getJarPath());
  if (!status.isOK())   ErrorDialog.openError(getShell(),"Error",null,status);
  return status.isOK();
}
 

Example 6

From project bpelunit, under directory /tycho/net.bpelunit.toolsupport/src/net/bpelunit/toolsupport/.

Source file: ToolSupportActivator.java

  18 
vote

public static void log(Throwable e){
  if (e instanceof InvocationTargetException) {
    e=((InvocationTargetException)e).getTargetException();
  }
  IStatus status=null;
  if (e instanceof CoreException) {
    status=((CoreException)e).getStatus();
  }
 else {
    status=getErrorStatus(e);
  }
  log(status);
}
 

Example 7

From project bpelunit, under directory /tycho/net.bpelunit.toolsupport/.

Source file: ToolSupportActivator.java

  18 
vote

public static void log(Throwable e){
  if (e instanceof InvocationTargetException) {
    e=((InvocationTargetException)e).getTargetException();
  }
  IStatus status=null;
  if (e instanceof CoreException) {
    status=((CoreException)e).getStatus();
  }
 else {
    status=getErrorStatus(e);
  }
  log(status);
}
 

Example 8

From project BPMN2-Editor-for-Eclipse, under directory /org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/validation/.

Source file: LiveValidationContentAdapter.java

  18 
vote

public void notifyChanged(final Notification notification){
  super.notifyChanged(notification);
  if (validator == null) {
    validator=(ILiveValidator)ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
  }
  IStatus status=validator.validate(notification);
  if (!status.isOK()) {
    if (status.isMultiStatus()) {
      status=status.getChildren()[0];
    }
  }
}
 

Example 9

From project bundlemaker, under directory /main/org.bundlemaker.core.ui/src/org/bundlemaker/core/ui/wizards/.

Source file: NewBundleMakerProjectWizardCreationPage.java

  18 
vote

@Override protected boolean validatePage(){
  if (!super.validatePage()) {
    return false;
  }
  IStatus status=_jreComboBlock.getStatus();
  setErrorMessageFromStatus(status);
  return status.isOK();
}
 

Example 10

From project bel-editor, under directory /org.openbel.editor.core/src/org/openbel/editor/core/.

Source file: CoreFunctions.java

  17 
vote

/** 
 * Returns a compiler exception  {@link CoreException}, deriving from the supplied exception as a result of executing the BEL compiler. <p> This method either returns the  {@code e} supplied or provides somethingmore informative if  {@code e} is has BEL compiler information.</p>
 * @param e {@link CoreException}
 * @return {@link CoreException}
 */
public static CoreException compilerException(CoreException e){
  String msg=e.getMessage();
  if (!msg.contains("exec returned:"))   return e;
  String[] split=msg.split(" ");
  String strcode=split[split.length - 1];
  ExitCode ec=getExitCode(parseInt(strcode));
  if (ec == null)   return e;
  String fmt="BEL Compiler failure (%d): %s";
  msg=format(fmt,ec.getValue(),ec.getErrorMessage());
  IStatus oldStatus=e.getStatus();
  IStatus newStatus=new Status(IStatus.ERROR,oldStatus.getPlugin(),msg);
  CoreException ce=new CoreException(newStatus);
  ce.initCause(e);
  return ce;
}
 

Example 11

From project BPMN2-Editor-for-Eclipse, under directory /org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/wizards/.

Source file: BPMN2DiagramCreator.java

  17 
vote

private void openEditor(final DiagramEditorInput editorInput){
  PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable(){
    @Override public void run(){
      try {
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(editorInput,BPMN2Editor.EDITOR_ID);
      }
 catch (      PartInitException e) {
        String error="Error while opening diagram editor";
        IStatus status=new Status(IStatus.ERROR,Activator.PLUGIN_ID,error,e);
        ErrorUtils.showErrorWithLogging(status);
      }
    }
  }
);
}
 

Example 12

From project acceleo-modules, under directory /psm-gen-scala/plugins/com.github.sbegaudeau.acceleo.modules.psm.gen.scala/src/com/github/sbegaudeau/acceleo/modules/psm/gen/scala/.

Source file: ScalaGeneratorPlugin.java

  15 
vote

/** 
 * Trace an Exception in the error log.
 * @param e Exception to log.
 * @param blocker <code>True</code> if the exception must be logged as error, <code>False</code> to log it as a warning.
 */
public static void log(Exception e,boolean blocker){
  if (e == null) {
    throw new NullPointerException("Logging null exception");
  }
  if (getDefault() == null) {
    e.printStackTrace();
  }
 else   if (e instanceof CoreException) {
    log(((CoreException)e).getStatus());
  }
 else   if (e instanceof NullPointerException) {
    int severity=IStatus.WARNING;
    if (blocker) {
      severity=IStatus.ERROR;
    }
    log(new Status(severity,PLUGIN_ID,severity,"Required element not found",e));
  }
 else {
    int severity=IStatus.WARNING;
    if (blocker) {
      severity=IStatus.ERROR;
    }
    log(new Status(severity,PLUGIN_ID,severity,e.getMessage(),e));
  }
}
 

Example 13

From project acceleo-modules, under directory /psm-gen-scala/plugins/com.github.sbegaudeau.acceleo.modules.psm.gen.scala/src/com/github/sbegaudeau/acceleo/modules/psm/gen/scala/.

Source file: ScalaGeneratorPlugin.java

  15 
vote

/** 
 * Puts the given status in the error log view.
 * @param status Error Status.
 */
public static void log(IStatus status){
  if (status == null) {
    throw new NullPointerException("Logging null status");
  }
  if (getDefault() != null) {
    getDefault().getLog().log(status);
  }
 else {
    System.err.println(status.getMessage());
    status.getException().printStackTrace();
  }
}
 

Example 14

From project Archimedes, under directory /br.org.archimedes.orto/src/br/org/archimedes/orto/.

Source file: Activator.java

  15 
vote

public void earlyStartup(){
  UIJob job=new UIJob("InitCommandsWorkaround"){
    public IStatus runInUIThread(    IProgressMonitor monitor){
      ICommandService commandService=(ICommandService)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(ICommandService.class);
      Command command=commandService.getCommand(ORTO_COMMAND_ID);
      State state=command.getState(ORTO_STATE);
      state.setValue(false);
      if (command.getHandler().isEnabled()) {
        commandService.refreshElements(ORTO_COMMAND_ID,null);
      }
      return new Status(IStatus.OK,PLUGIN_ID,"Init commands workaround performed succesfully");
    }
  }
;
  job.schedule();
}
 

Example 15

From project Archimedes, under directory /br.org.archimedes.snap/src/br/org/archimedes/snap/.

Source file: Activator.java

  15 
vote

private void earlyStartup(){
  UIJob job=new UIJob("InitCommandsWorkaround"){
    public IStatus runInUIThread(    IProgressMonitor monitor){
      ICommandService commandService=(ICommandService)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(ICommandService.class);
      Command command=commandService.getCommand(SNAP_COMMAND_ID);
      State state=command.getState(SNAP_STATE);
      state.setValue(true);
      if (command.getHandler().isEnabled()) {
        commandService.refreshElements(SNAP_COMMAND_ID,null);
      }
      return new Status(IStatus.OK,PLUGIN_ID,"Init commands workaround performed succesfully");
    }
  }
;
  job.schedule();
}
 

Example 16

From project bel-editor, under directory /org.openbel.editor.ui/src/org/openbel/editor/ui/.

Source file: ResourceLoader.java

  15 
vote

/** 
 * {@inheritDoc}
 */
@Override protected IStatus run(IProgressMonitor m){
  m.beginTask("Loading Resources",100);
  m.subTask("Loading resource index.");
  final ResourceIndex resourceIndex=readResourceIndex();
  if (resourceIndex == null) {
    m.setCanceled(true);
    return Status.CANCEL_STATUS;
  }
  m.worked(50);
  getDefault().setResourceIndex(resourceIndex);
  Display.getDefault().asyncExec(new UpdateViewResources());
  m.subTask("Building namespace and resources.");
  final ResourceIndex index=getDefault().getResourceIndex();
  if (index == null) {
    logError("resource index is null at " + callerFrame());
    m.setCanceled(true);
    return Status.CANCEL_STATUS;
  }
  final String rloc=getPluginLocation().append("resources").makeAbsolute().toString();
  createDirectory(rloc);
  final File rlocFile=new File(rloc);
  try {
    final Records records=new Records(rlocFile,resourceIndex);
    records.build(index);
  }
 catch (  IOException e) {
    logError(e);
  }
  return Status.OK_STATUS;
}
 

Example 17

From project BHT-FPA, under directory /mailer-common/de.bht.fpa.mail.common/src/de/bht/fpa/mail/s000000/common/internal/.

Source file: Activator.java

  15 
vote

/** 
 * Logs an  {@link Exception} to the eclipse workbench.
 * @param e the  {@link Exception} to log
 */
public static void logException(Exception e){
  if (getInstance() == null) {
    final Writer result=new StringWriter();
    e.printStackTrace(new PrintWriter(result));
    System.err.println(result.toString());
  }
 else {
    getInstance().getLog().log(new Status(IStatus.ERROR,Activator.PLUGIN_ID,-1,e.getMessage(),e));
  }
}
 

Example 18

From project BHT-FPA, under directory /mailer-common/de.bht.fpa.mail.common/src/de/bht/fpa/mail/s000000/common/rcp/exception/.

Source file: ExceptionDetailsErrorDialog.java

  15 
vote

/** 
 * Creates an error dialog. Note that the dialog will have no visual representation (no widgets) until it is told to open. <p> Normally one should use <code>openError</code> to create and open one of these. This constructor is useful only if the error object being displayed contains child items <it>and </it> you need to specify a mask which will be used to filter the displaying of these children. </p>
 * @param parentShell the shell under which to create this dialog
 * @param dialogTitle the title to use for this dialog, or <code>null</code> to indicate that the default title should be used
 * @param message the message to show in this dialog, or <code>null</code> to indicate that the error's message should be shown as the primary message
 * @param status the error to show to the user
 * @param displayMask the mask to use to filter the displaying of child items, as per <code>IStatus.matches</code>
 * @see org.eclipse.core.runtime.IStatus#matches(int)
 */
public ExceptionDetailsErrorDialog(Shell parentShell,String dialogTitle,String message,IStatus status,int displayMask){
  super(parentShell);
  this.title=dialogTitle == null ? JFaceResources.getString("Problem_Occurred") : dialogTitle;
  this.message=message == null ? status.getMessage() : JFaceResources.format("Reason",new Object[]{message,status.getMessage()});
  this.status=status;
  this.displayMask=displayMask;
  setShellStyle(getShellStyle() | SWT.RESIZE);
}
 

Example 19

From project Bio-PEPA, under directory /uk.ac.ed.inf.biopepa.ui/src/uk/ac/ed/inf/biopepa/ui/wizards/export/.

Source file: CompRelationsWizard.java

  15 
vote

@Override protected IStatus run(IProgressMonitor monitor){
  inferer.computeComponentRelations();
  Runnable runnable=new Runnable(){
    public void run(){
      BioPEPACompRelationsView invview=BioPEPACompRelationsView.getDefault();
      invview.setRelationsTree(inferer.getRelationsTree());
      invview.refreshTree();
    }
  }
;
  Display.getDefault().syncExec(runnable);
  return Status.OK_STATUS;
}
 

Example 20

From project bioclipse.speclipse, under directory /plugins/net.bioclipse.spectrum/src/net/bioclipse/spectrum/contenttypes/.

Source file: CmlSpectrumFileDescriber.java

  15 
vote

/** 
 * Store parameters
 */
@SuppressWarnings("unchecked") public void setInitializationData(final IConfigurationElement config,final String propertyName,final Object data) throws CoreException {
  if (data instanceof String)   count=(String)data;
 else   if (data instanceof Hashtable) {
    Hashtable parameters=(Hashtable)data;
    type=(String)parameters.get(TYPE_TO_FIND);
    count=(String)parameters.get(COUNT_TO_FIND);
  }
  if (count == null) {
    String message=NLS.bind(ContentMessages.content_badInitializationData,CmlSpectrumFileDescriber.class.getName());
    throw new CoreException(new Status(IStatus.ERROR,ContentMessages.OWNER_NAME,0,message,null));
  }
}
 

Example 21

From project bundlemaker, under directory /integrationtest/org.bundlemaker.itest.spring/src/org/bundlemaker/itest/spring/experimental/.

Source file: SpecialComponent.java

  15 
vote

@Override protected List createApiTypeContainers() throws CoreException {
  try {
    List<IApiTypeContainer> containers=new LinkedList<IApiTypeContainer>();
    containers.add(createApiTypeContainer(_file));
    return containers;
  }
 catch (  IOException e) {
    e.printStackTrace();
    throw new CoreException(new Status(IStatus.ERROR,"asdads","Fehler"));
  }
}
 

Example 22

From project CBCJVM, under directory /eclipse/src/cbclipse/builder/.

Source file: CBCBuilder.java

  15 
vote

public boolean visit(IResourceDelta delta) throws CoreException {
  IResource resource=delta.getResource();
  try {
switch (delta.getKind()) {
case IResourceDelta.ADDED:
      handleAdd(resource);
    break;
case IResourceDelta.REMOVED:
  handleRemove(resource);
break;
case IResourceDelta.CHANGED:
handleChange(resource);
break;
}
}
 catch (CommunicationException e) {
throw new CoreException(new Status(IStatus.ERROR,BUILDER_ID,"Communication with CBC failed, not downloaded",new RuntimeException()));
}
return true;
}
 

Example 23

From project CBCJVM, under directory /eclipse/src/cbclipse/builder/.

Source file: CBCBuilder.java

  15 
vote

protected void fullBuild(final IProgressMonitor monitor) throws CoreException {
  IJavaProject jP=JavaCore.create(getProject());
  Connection c=ConnectionInfo.getConnection(getProject());
  if (c == null || !c.isDownloaderSet()) {
    System.out.println("Downloader not set, skipping CBC Builder..");
    throw new CoreException(new Status(IStatus.WARNING,BUILDER_ID,"Downloader not set in project properties.",new RuntimeException()));
  }
  try {
    ProjectDownloadTask task=new CleanProjectDownloadTask(jP);
    getProject().accept(new CBCResourceVisitor(task));
    task.end();
  }
 catch (  CommunicationException e) {
    e.printStackTrace();
  }
}
 

Example 24

From project ccw, under directory /ccw.core/src/java/ccw/editors/outline/.

Source file: ClojureOutlinePage.java

  15 
vote

private void refreshInput(){
  Job job=new Job("Outline browser tree refresh"){
    @Override protected IStatus run(    IProgressMonitor monitor){
      String string=document.get();
      LineNumberingPushbackReader pushbackReader=new LineNumberingPushbackReader(new StringReader(string));
      Object EOF=new Object();
      ArrayList<List> input=new ArrayList<List>();
      Object result=null;
      while (true) {
        try {
          result=LispReader.read(pushbackReader,false,EOF,false);
          if (result == EOF)           break;
          if (result instanceof List)           input.add((List)result);
        }
 catch (        ReaderException e) {
          CCWPlugin.logWarning(String.format("Failed to read file %s (%s)",editor.getEditorInput().getName(),e.getMessage()));
          break;
        }
catch (        Exception e) {
          throw new RuntimeException(e);
        }
      }
      ClojureOutlinePage.this.forms=input;
      setInputInUiThread(input);
      return Status.OK_STATUS;
    }
    @Override public boolean belongsTo(    Object family){
      return REFRESH_OUTLINE_JOB_FAMILY.equals(family);
    }
  }
;
  job.setSystem(true);
  Job.getJobManager().cancel(REFRESH_OUTLINE_JOB_FAMILY);
  job.schedule(500);
}
 

Example 25

From project ccw, under directory /ccw.core/src/java/ccw/launching/.

Source file: SourcePathComputerDelegate.java

  15 
vote

private List<ISourceContainer> getSrcFoldersAsISourceContainers(ILaunchConfiguration configuration) throws CoreException {
  String projectName=configuration.getAttribute(LaunchUtils.ATTR_PROJECT_NAME,(String)null);
  if (projectName == null) {
    throw new CoreException(new Status(IStatus.ERROR,CCWPlugin.PLUGIN_ID,"Clojure SourcePathComputerDelegate unable to correctly set the clojure sources in the class because the considered launch configuration does not have an associated project"));
  }
 else {
    return Arrays.asList(new ISourceContainer[]{new FolderSourceContainer(ResourcesPlugin.getWorkspace().getRoot().getProject(projectName).getFolder("src"),true)});
  }
}