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

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.core/src/com/amazonaws/eclipse/core/.

Source file: BrowserUtils.java

  32 
vote

/** 
 * Opens the specified URL in an external browser window.
 * @param url The URL to open.
 */
public static void openExternalBrowser(String url){
  try {
    IWorkbenchBrowserSupport browserSupport=PlatformUI.getWorkbench().getBrowserSupport();
    browserSupport.createBrowser(BROWSER_STYLE,null,null,null).openURL(new URL(url));
  }
 catch (  Exception e) {
    Status status=new Status(Status.ERROR,AwsToolkitCore.PLUGIN_ID,"Unable to open external web browser to '" + url + "': "+ e.getMessage(),e);
    StatusManager.getManager().handle(status,StatusManager.SHOW);
  }
}
 

Example 2

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

Source file: SNSActionProvider.java

  32 
vote

@Override public void run(){
  AmazonSNS sns=AwsToolkitCore.getClientFactory().getSNSClient();
  CreateTopicDialog createTopicDialog=new CreateTopicDialog();
  if (createTopicDialog.open() == 0) {
    try {
      sns.createTopic(new CreateTopicRequest(createTopicDialog.getTopicName()));
      ContentProviderRegistry.refreshAllContentProviders();
    }
 catch (    Exception e) {
      Status status=new Status(Status.ERROR,AwsToolkitCore.PLUGIN_ID,"Unable to create SNS Topic",e);
      StatusManager.getManager().handle(status,StatusManager.SHOW | StatusManager.LOG);
    }
  }
}
 

Example 3

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

Source file: Activator.java

  32 
vote

public static void error(List<String> errors){
  final StringBuffer sb=new StringBuffer();
  for (  String msg : errors) {
    sb.append(msg);
    sb.append("\n");
  }
  async(new Runnable(){
    public void run(){
      Status s=new Status(Status.ERROR,PLUGIN_ID,0,"",null);
      ErrorDialog.openError(null,"Errors during bundle generation",sb.toString(),s);
    }
  }
);
}
 

Example 4

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

Source file: Activator.java

  32 
vote

public static void warning(List<String> errors){
  final StringBuffer sb=new StringBuffer();
  for (  String msg : errors) {
    sb.append(msg);
    sb.append("\n");
  }
  async(new Runnable(){
    public void run(){
      Status s=new Status(Status.WARNING,PLUGIN_ID,0,"",null);
      ErrorDialog.openError(null,"Warnings during bundle generation",sb.toString(),s);
    }
  }
);
}
 

Example 5

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

  31 
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 6

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

Source file: ImapHelper.java

  31 
vote

/** 
 * Synchronizes all folders of an IMAP  {@link Account} with a database usingthe  {@link EntityManager}. The current implementation is only able to add new messages, but NOT deleted or moved messages.
 * @param account the  {@link Account} to use to connect
 * @param debug enable/disable IMAP debugging
 * @param protocol the protocol to create the  {@link Store} from. See{@link Session#getStore(String)}
 * @param properties a key-value Map to override properties (i.e. for another port).
 * @throws SynchronizationException
 */
public static void syncAllFoldersToAccount(final Account account,IProgressMonitor monitor,Dictionary<String,String> properties,String protocol) throws SynchronizationException {
  try {
    Properties props=combineProperties(properties);
    Session session=Session.getInstance(props);
    Store store=session.getStore(protocol);
    try {
      store.connect(account.getHost(),account.getUsername(),account.getPassword());
      debug(store.toString());
      IMAPFolder imapFolder=(IMAPFolder)store.getDefaultFolder();
      int totalNumberOfFolders=caculateTotalNumberOfFolders(imapFolder);
      monitor.beginTask("Syncing " + totalNumberOfFolders + " IMAP Folders",totalNumberOfFolders);
      for (      javax.mail.Folder subFolder : imapFolder.list()) {
        if (monitor.isCanceled()) {
          break;
        }
        Folder syncedFolder=syncFolderInternal(account,monitor,(IMAPFolder)subFolder,null);
        if (!account.getFolders().contains(syncedFolder)) {
          account.getFolders().add(syncedFolder);
          syncedFolder.setAccount(account);
        }
      }
      merge(account);
    }
  finally {
      monitor.done();
      store.close();
    }
  }
 catch (  final Exception e) {
    Display.getDefault().syncExec(new Runnable(){
      @Override public void run(){
        Status status=new Status(Status.ERROR,Activator.PLUGIN_ID,"Synchronization of Account '" + account.getName() + "' failed",e.getCause());
        ExceptionDetailsErrorDialog.openError(Display.getDefault().getActiveShell(),status.getMessage(),null,status);
      }
    }
);
  }
}
 

Example 7

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

  31 
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 8

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

Source file: BPMN2Editor.java

  31 
vote

@Override protected void setInput(IEditorInput input){
  super.setInput(input);
  getEditingDomainListener();
  BasicCommandStack basicCommandStack=(BasicCommandStack)getEditingDomain().getCommandStack();
  if (input instanceof DiagramEditorInput) {
    ResourceSet resourceSet=getEditingDomain().getResourceSet();
    Bpmn2ResourceImpl bpmnResource=(Bpmn2ResourceImpl)resourceSet.createResource(modelUri,"org.eclipse.bpmn2.content-type.xml");
    resourceSet.setURIConverter(new ProxyURIConverterImplExtension());
    modelHandler=ModelHandlerLocator.createModelHandler(modelUri,bpmnResource);
    ModelHandlerLocator.put(diagramUri,modelHandler);
    try {
      if (modelFile.exists()) {
        bpmnResource.load(null);
      }
 else {
        doSave(null);
      }
    }
 catch (    IOException e) {
      Status status=new Status(IStatus.ERROR,Activator.PLUGIN_ID,e.getMessage(),e);
      ErrorUtils.showErrorWithLogging(status);
    }
    basicCommandStack.execute(new RecordingCommand(getEditingDomain()){
      @Override protected void doExecute(){
        importDiagram();
      }
    }
);
  }
  basicCommandStack.saveIsDone();
}
 

Example 9

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

  30 
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 10

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

Source file: CoreFunctions.java

  30 
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 bpelunit, under directory /tycho/net.bpelunit.toolsupport/src/net/bpelunit/toolsupport/util/.

Source file: WSDLFileValidator.java

  30 
vote

public IStatus validate(Object[] selection){
  if (!required && selection.length == 0) {
    return new Status(IStatus.OK,ToolSupportActivator.getPluginId(),0,"",null);
  }
  if ((selection.length != 1) || (!(selection[0] instanceof IFile))) {
    return new Status(IStatus.ERROR,ToolSupportActivator.getPluginId(),0,"Please select a WSDL file",null);
  }
  try {
    IFile file=(IFile)selection[0];
    editor.getWsdlForFile(file.getProjectRelativePath().toString());
  }
 catch (  WSDLReadingException e) {
    String msg=e.getMessage() + ((e.getCause() != null) ? ": " + e.getCause() : "");
    return new Status(IStatus.ERROR,ToolSupportActivator.getPluginId(),0,msg,null);
  }
  return new Status(IStatus.OK,ToolSupportActivator.getPluginId(),0,"",null);
}
 

Example 12

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

Source file: WSDLFileValidator.java

  30 
vote

public IStatus validate(Object[] selection){
  if (!required && selection.length == 0) {
    return new Status(IStatus.OK,ToolSupportActivator.getPluginId(),0,"",null);
  }
  if ((selection.length != 1) || (!(selection[0] instanceof IFile))) {
    return new Status(IStatus.ERROR,ToolSupportActivator.getPluginId(),0,"Please select a WSDL file",null);
  }
  try {
    IFile file=(IFile)selection[0];
    editor.getWsdlForFile(file.getProjectRelativePath().toString());
  }
 catch (  WSDLReadingException e) {
    String msg=e.getMessage() + ((e.getCause() != null) ? ": " + e.getCause() : "");
    return new Status(IStatus.ERROR,ToolSupportActivator.getPluginId(),0,msg,null);
  }
  return new Status(IStatus.OK,ToolSupportActivator.getPluginId(),0,"",null);
}
 

Example 13

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

Source file: DIImport.java

  30 
vote

/** 
 * Find a Graphiti feature for given shape and generate necessary diagram elements.
 * @param shape
 */
private void createShape(BPMNShape shape){
  BaseElement bpmnElement=shape.getBpmnElement();
  if (shape.getChoreographyActivityShape() != null) {
    return;
  }
  IAddFeature addFeature=featureProvider.getAddFeature(new AddContext(new AreaContext(),bpmnElement));
  if (addFeature == null) {
    Activator.logStatus(new Status(IStatus.WARNING,Activator.PLUGIN_ID,"Element not supported: " + bpmnElement.eClass().getName()));
    return;
  }
  AddContext context=new AddContext();
  context.putProperty(IMPORT_PROPERTY,true);
  context.setNewObject(bpmnElement);
  context.setSize((int)shape.getBounds().getWidth(),(int)shape.getBounds().getHeight());
  if (bpmnElement instanceof Lane) {
    handleLane(bpmnElement,context,shape);
  }
 else   if (bpmnElement instanceof FlowNode) {
    handleFlowNode((FlowNode)bpmnElement,context,shape);
  }
 else {
    context.setTargetContainer(diagram);
    context.setLocation((int)shape.getBounds().getX(),(int)shape.getBounds().getY());
  }
  if (addFeature.canAdd(context)) {
    PictogramElement newContainer=addFeature.add(context);
    featureProvider.link(newContainer,new Object[]{bpmnElement,shape});
    if (bpmnElement instanceof Participant) {
      elements.put(((Participant)bpmnElement).getProcessRef(),newContainer);
    }
    elements.put(bpmnElement,newContainer);
    handleEvents(bpmnElement,newContainer);
  }
  ModelUtil.addID(bpmnElement);
  String id=bpmnElement.getId();
  if (shape.getId() == null)   shape.setId(id);
  if (!bpmnElement.eAdapters().contains(liveValidationContentAdapter)) {
    bpmnElement.eAdapters().add(liveValidationContentAdapter);
  }
}
 

Example 14

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

Source file: Activator.java

  29 
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

  29 
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

  29 
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 Bio-PEPA, under directory /uk.ac.ed.inf.biopepa.ui/src/uk/ac/ed/inf/biopepa/ui/wizards/export/.

Source file: CompRelationsWizard.java

  29 
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 18

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

Source file: CmlSpectrumFileDescriber.java

  29 
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 19

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

Source file: SpecialComponent.java

  29 
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 20

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

Source file: BundleMakerCore.java

  29 
vote

/** 
 * <p> Creates a bundle maker project for the given  {@link IProject}. The specified project must have the bundle maker nature. </p> <p> You can use  {@link #isBundleMakerProject(IProject)} to check if the project is BundleMaker project
 * @param project
 * @return
 * @throws CoreException
 */
public static IBundleMakerProject getBundleMakerProject(IProject project,IProgressMonitor progressMonitor) throws CoreException {
  Assert.isNotNull(project);
  if (!project.exists()) {
    throw new CoreException(new Status(IStatus.ERROR,BundleMakerCore.BUNDLE_ID,"Project '" + project.getName() + "' has to exist."));
  }
  if (!project.hasNature(NATURE_ID)) {
    throw new CoreException(new Status(IStatus.ERROR,BundleMakerCore.BUNDLE_ID,"Project '" + project.getName() + "' must have nature '"+ NATURE_ID+ "'."));
  }
  IBundleMakerProject bundleMakerProject=(IBundleMakerProject)Activator.getDefault().getBundleMakerProject(project);
  if (bundleMakerProject == null) {
    bundleMakerProject=new BundleMakerProject(project);
    Activator.getDefault().cacheBundleMakerProject(project,bundleMakerProject);
  }
  return bundleMakerProject;
}