Java Code Examples for org.eclipse.core.runtime.Status#ERROR
The following examples show how to use
org.eclipse.core.runtime.Status#ERROR .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractSimulationEngine.java From statecharts with Eclipse Public License 1.0 | 6 votes |
protected void handleException(Throwable t) { if (t instanceof WrappedException) { t = ((WrappedException) t).getCause(); } String statusMessage = t.getMessage() == null ? ERROR_MSG : t.getMessage(); Status errorStatus = new Status(Status.ERROR, SimulationCoreActivator.PLUGIN_ID, ERROR_DURING_SIMULATION, statusMessage, t); SimulationCoreActivator.getDefault().getLog().log(errorStatus); IStatusHandler statusHandler = DebugPlugin.getDefault().getStatusHandler(errorStatus); try { statusHandler.handleStatus(errorStatus, getDebugTarget()); } catch (CoreException e) { e.printStackTrace(); } finally { terminate(); } }
Example 2
Source File: DataflowMavenModel.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
private DataflowMavenModel fromIFile(IFile file) throws CoreException { try { IStructuredModel structuredModel = StructuredModelManager.getModelManager().getModelForEdit(file); if (structuredModel instanceof IDOMModel) { XPath xpath = XPathFactory.newInstance().newXPath(); xpath.setNamespaceContext(pomNamespaceContext); return new DataflowMavenModel( dependencyManager, xpath, file.getProject(), (IDOMModel) structuredModel); } else { throw new CoreException(new Status(Status.ERROR, DataflowCorePlugin.PLUGIN_ID, String.format("File %s wasn't a DOM model", file))); } } catch (IOException e) { throw new CoreException(new Status(Status.ERROR, DataflowCorePlugin.PLUGIN_ID, String.format("Couldn't get a DOM Model for file %s", file), e)); } }
Example 3
Source File: SaveProjectPreferencesJob.java From typescript.java with MIT License | 6 votes |
@Override public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } monitor.beginTask(NLS.bind(TypeScriptCoreMessages.SaveProjectPreferencesJob_taskName, project.getName()), 1); try { preferences.flush(); } catch (BackingStoreException e) { IStatus status = new Status(Status.ERROR, TypeScriptCorePlugin.PLUGIN_ID, "Error while saving project preferences", e); throw new CoreException(status); } monitor.worked(1); monitor.done(); return Status.OK_STATUS; }
Example 4
Source File: GSWorker.java From slr-toolkit with Eclipse Public License 1.0 | 6 votes |
protected IStatus waitForJs(HtmlPage page) { JavaScriptJobManager manager = page.getEnclosingWindow().getJobManager(); while (manager.getJobCount() > 0) { try { Thread.sleep(100); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return new Status(Status.ERROR, "de.tudresden.slr.googlescholar", "Failed to wait for Javascript processes", e); } if (this.monitor != null && monitor.isCanceled()) { return Status.CANCEL_STATUS; } } return Status.OK_STATUS; }
Example 5
Source File: DFSFile.java From RDFS with Apache License 2.0 | 5 votes |
public InputStream getContents() throws CoreException { try { return DFSFile.this.open(); } catch (IOException ioe) { throw new CoreException(new Status(Status.ERROR, Activator.PLUGIN_ID, 0, "Unable to open file \"" + DFSFile.this.path + "\"", ioe)); } }
Example 6
Source File: JReFrameworker.java From JReFrameworker with MIT License | 5 votes |
public static IStatus deleteProject(IProject project) { if (project != null && project.exists()) try { project.delete(true, true, new NullProgressMonitor()); } catch (CoreException e) { Log.error("Could not delete project", e); return new Status(Status.ERROR, Activator.PLUGIN_ID, "Could not delete project", e); } return Status.OK_STATUS; }
Example 7
Source File: PersistentObject.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
/** * Eine Hashtable speichern. Diese wird zunächst in ein byte[] geplättet, und so gespeichert. * * @param field * @param map * @return 0 bei Fehler */ @SuppressWarnings("rawtypes") public void setMap(final String field, final Map<Object, Object> map){ if (map == null) { throw new PersistenceException(new ElexisStatus(Status.ERROR, CoreHub.PLUGIN_ID, ElexisStatus.CODE_NONE, "Attempt to store Null map", null)); } byte[] bin = flatten((Hashtable) map); getDBConnection().getCache().put(getKey(field), map, getCacheTime()); setBinary(field, bin); }
Example 8
Source File: PacketNetCloudTLCInstanceParameters.java From tlaplus with MIT License | 5 votes |
@Override public IStatus validateCredentials() { final String credential = System.getenv("PACKET_NET_PROJECT_ID"); final String identity = System.getenv("PACKET_NET_APIKEY"); if (credential == null || identity == null) { return new Status(Status.ERROR, "org.lamport.tla.toolbox.jcloud", "Invalid credentials, please check the environment variables " + "(PACKET_NET_PROJECT_ID " + "and PACKET_NET_APIKEY) are correctly " + "set up and picked up by the Toolbox." + "\n\nPlease visit the Toolbox help and read section 4 " + "of \"Cloud based distributed TLC\" on how to setup authentication."); } return Status.OK_STATUS; }
Example 9
Source File: Verrechnet.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
/** * Change the count for this service or article, considering the rules given by the resp. * optifiers. * * @param neuAnzahl * @return */ public IStatus changeAnzahlValidated(int neuAnzahl){ int vorher = getZahl(); if (neuAnzahl == vorher) { return Status.OK_STATUS; } Konsultation kons = getKons(); if (neuAnzahl == 0) { kons.removeLeistung(this); return Status.OK_STATUS; } int difference = neuAnzahl - vorher; if (difference > 0) { IVerrechenbar verrechenbar = getVerrechenbar(); for (int i = 0; i < difference; i++) { Result<IVerrechenbar> result = kons.addLeistung(verrechenbar); if (!result.isOK()) { String message = result.getMessages().stream().map(m -> m.getText()) .collect(Collectors.joining(", ")); return new Status(Status.ERROR, CoreHub.PLUGIN_ID, message); } } } else if (difference < 0) { changeAnzahl(neuAnzahl); } return Status.OK_STATUS; }
Example 10
Source File: NodeJS.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public IStatus validate() { if (path == null) { return new Status(Status.ERROR, JSCorePlugin.PLUGIN_ID, Messages.NodeJSService_NullPathError); } if (!exists()) { return new Status(Status.ERROR, JSCorePlugin.PLUGIN_ID, ERR_DOES_NOT_EXIST, MessageFormat.format( Messages.NodeJSService_FileDoesntExistError, path), null); } String version = getVersion(); if (version == null) { return new Status(Status.ERROR, JSCorePlugin.PLUGIN_ID, ERR_NOT_EXECUTABLE, MessageFormat.format( Messages.NodeJSService_CouldntGetVersionError, path), null); } int index = version.indexOf('v'); if (index != -1) { version = version.substring(index + 1); // eliminate 'v' } if (VersionUtil.compareVersions(version, MIN_NODE_VERSION) >= 0) { return Status.OK_STATUS; } return new Status(Status.ERROR, JSCorePlugin.PLUGIN_ID, ERR_INVALID_VERSION, MessageFormat.format( Messages.NodeJSService_InvalidVersionError, path, version, MIN_NODE_VERSION), null); }
Example 11
Source File: DisassemblerContentProvider.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private String getContent(byte[] bytes, IProgressMonitor monitor) throws CoreException { ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); String disassembledByteCode = null; try { disassembledByteCode = disassembler.disassemble(bytes, LF, ClassFileBytesDisassembler.WORKING_COPY); if (disassembledByteCode != null) { disassembledByteCode = DISASSEMBLED_HEADER + disassembledByteCode; } } catch (ClassFormatException e) { throw new CoreException(new Status(Status.ERROR, "", "Error disassembling", e)); } return disassembledByteCode; }
Example 12
Source File: DisassemblerContentProvider.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public String getContent(URI uri, IProgressMonitor monitor) throws CoreException { IClassFile classFile = JDTUtils.resolveClassFile(uri); if (classFile != null) { return getSource(classFile, monitor); } try { return getContent(Files.readAllBytes(Paths.get(uri)), monitor); } catch (IOException e) { throw new CoreException(new Status(Status.ERROR, "", "Error opening " + uri, e)); } }
Example 13
Source File: StockCommissioningSystemService.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
@Override public IStatus performArticleOutlay(IStockEntry stockEntry, int quantity, Map<String, Object> data){ if (stockEntry == null) { return new Status(Status.ERROR, Bundle.ID, "stock entry is null"); } ElexisEvent performOutlayEvent = new ElexisEvent(); performOutlayEvent.setTopic(ElexisEventTopics.STOCK_COMMISSIONING_OUTLAY); performOutlayEvent.getProperties() .put(ElexisEventTopics.STOCK_COMMISSIONING_PROPKEY_STOCKENTRY_ID, stockEntry.getId()); performOutlayEvent.getProperties().put( ElexisEventTopics.STOCK_COMMISSIONING_PROPKEY_QUANTITY, Integer.toString(quantity)); return elexisServerService.postEvent(performOutlayEvent); }
Example 14
Source File: StockService.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
@Override public IStatus performSingleReturn(IArticle article, int count, String mandatorId){ if (article == null) { return new Status(Status.ERROR, "ch.elexis.core.services", "Article is null"); } IStockEntry se = findPreferredStockEntryForArticle(StoreToStringServiceHolder.getStoreToString(article), null); if (se == null) { return new Status(Status.WARNING, "ch.elexis.core.services", "No stock entry for article found"); } if (se.getStock().isCommissioningSystem()) { // updates must happen via manual inputs in the machine return Status.OK_STATUS; } LockResponse lr = LocalLockServiceHolder.get().acquireLockBlocking(se, 1, new NullProgressMonitor()); if (lr.isOk()) { int fractionUnits = se.getFractionUnits(); int ve = article.getSellingSize(); int vk = article.getPackageSize(); if (vk == 0) { if (ve != 0) { vk = ve; } } if (ve == 0) { if (vk != 0) { ve = vk; } } int num = count * ve; int cs = se.getCurrentStock(); if (vk == ve) { se.setCurrentStock(cs + count); } else { int rest = fractionUnits + num; while (rest > vk) { rest = rest - vk; se.setCurrentStock(cs + 1); } se.setFractionUnits(rest); } coreModelService.save(se); LocalLockServiceHolder.get().releaseLock(se); return Status.OK_STATUS; } return new Status(Status.WARNING, "ch.elexis.core.services", "Could not acquire lock"); }
Example 15
Source File: StatusUtil.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
/** * Log a status to the corresponding log-level; does nothing if * {@link Status#isOK()} * * @param prependMessage an optional message to prepend the status * message * @param log * @param status * @param includeExceptionIfAvailable * @param logDebugIfOk log to level debug if the status is ok */ public static void logStatus(String prependMessage, @NonNull Logger log, @NonNull IStatus status, boolean includeExceptionIfAvailable, boolean logDebugIfOk) { if (status.isOK() && !logDebugIfOk) { return; } StringBuilder sb = new StringBuilder(); if (status.isMultiStatus()) { sb.append("[MULTISTATUS] "); } if (prependMessage != null) { sb.append(prependMessage + " "); } sb.append("(c" + status.getCode() + "/s" + status.getSeverity() + ") "); sb.append(status.getMessage()); String message = sb.toString(); boolean includeException = (includeExceptionIfAvailable && status.getException() != null); int severity = status.getSeverity(); switch (severity) { case Status.ERROR: if (includeException) { log.error(message, status.getException()); } else { log.error(message); } break; case Status.WARNING: if (includeException) { log.warn(message, status.getException()); } else { log.warn(message); } break; case Status.INFO: case Status.CANCEL: if (includeException) { log.info(message, status.getException()); } else { log.info(message); } break; case Status.OK: log.debug(message); break; default: break; } if (status.isMultiStatus()) { Arrays.asList(status.getChildren()).stream().forEach(c -> logStatus(prependMessage, log, c, true, false)); } }
Example 16
Source File: PythonNatureStore.java From Pydev with Eclipse Public License 1.0 | 4 votes |
/** * This is the function that actually stores the contents of the xml into the file with the configurations. */ private synchronized IStatus doStore() { try { if (this.project == null) { return Status.OK_STATUS; } traceFunc("doStore"); if (inInit) { traceFunc("END doStore (inInit)"); return Status.OK_STATUS; } synchronized (this) { if (document == null) { traceFunc("END doStore (document == null)"); return new Status(Status.ERROR, "PythonNatureStore.doStore", -2, "document == null", new RuntimeException("document == null")); } File file = getRawXmlFileLocation(); try { //Ok, we may receive multiple requests at once (e.g.: when updating the version and the pythonpath together), but //as the file is pretty small, there should be no problems in writing it directly (if that proves a problem later on, we //could have a *very* simple mechanism for saving it after some millis) String str = new String(serializeDocument(document)); lastLoadedContents = str; if (file == null) { if (!ProjectModulesManager.IN_TESTS) { //if we're not in tests, let's log this, as it'd be an error. Log.log("Error: xml file should only be null in tests (when no workspace is available)"); } return Status.OK_STATUS; } if (TRACE_PYTHON_NATURE_STORE) { System.out.println("Writing to file: " + file + " " + str); } FileUtils.writeStrToFile(str, file); } catch (Exception e) { Log.log("Unable to write contents of file: " + file, e); } traceFunc("END doStore"); return Status.OK_STATUS; } } finally { clearCache(); } }
Example 17
Source File: StockService.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
@Override public IStatus performSingleDisposal(IArticle article, int count, String mandatorId){ if (article == null) { return new Status(Status.ERROR, "ch.elexis.core.services", "Article is null"); } IStockEntry se = findPreferredStockEntryForArticle( StoreToStringServiceHolder.getStoreToString(article), mandatorId); if (se == null) { return new Status(Status.WARNING, "ch.elexis.core.services", "No stock entry for article found"); } if (se.getStock().isCommissioningSystem()) { boolean suspendOutlay = configService.getLocal(Preferences.INVENTORY_MACHINE_SUSPEND_OUTLAY, Preferences.INVENTORY_MACHINE_SUSPEND_OUTLAY_DEFAULT); if(suspendOutlay) { return Status.OK_STATUS; } int sellingUnit = article.getSellingSize(); boolean isPartialUnitOutput = (sellingUnit > 0 && sellingUnit < article.getPackageSize()); if (isPartialUnitOutput) { boolean performPartialOutlay = configService.get(Preferences.INVENTORY_MACHINE_OUTLAY_PARTIAL_PACKAGES, Preferences.INVENTORY_MACHINE_OUTLAY_PARTIAL_PACKAGES_DEFAULT); if (!performPartialOutlay) { return Status.OK_STATUS; } } return StockCommissioningServiceHolder.get().performArticleOutlay(se, count, null); } else { LockResponse lr = LocalLockServiceHolder.get().acquireLockBlocking(se, 1, new NullProgressMonitor()); if (lr.isOk()) { int fractionUnits = se.getFractionUnits(); int ve = article.getSellingSize(); int vk = article.getPackageSize(); if (vk == 0) { if (ve != 0) { vk = ve; } } if (ve == 0) { if (vk != 0) { ve = vk; } } int num = count * ve; int cs = se.getCurrentStock(); if (vk == ve) { se.setCurrentStock(cs - count); } else { int rest = fractionUnits - num; while (rest < 0) { rest = rest + vk; se.setCurrentStock(cs - 1); } se.setFractionUnits(rest); } coreModelService.save(se); LocalLockServiceHolder.get().releaseLock(se); return Status.OK_STATUS; } } return new Status(Status.WARNING, "ch.elexis.core.services", "Could not acquire lock"); }
Example 18
Source File: PersistenceException.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
public PersistenceException(String message){ super(message); errCode = NOT_DEFINED; status = new Status(Status.ERROR, "Persistence", message); }
Example 19
Source File: AppraiseRepositoryConnector.java From git-appraise-eclipse with Eclipse Public License 1.0 | 4 votes |
@Override public IStatus performQuery(TaskRepository repository, IRepositoryQuery query, TaskDataCollector collector, ISynchronizationSession session, IProgressMonitor monitor) { AppraisePluginReviewClient client; try { client = getReviewClient(repository); } catch (GitClientException e) { AppraiseConnectorPlugin.logError("Failed to initialize git client", e); return Status.CANCEL_STATUS; } boolean reviewer = Boolean.parseBoolean(query.getAttribute(AppraiseConnectorPlugin.QUERY_REVIEWER)); boolean requester = Boolean.parseBoolean(query.getAttribute(AppraiseConnectorPlugin.QUERY_REQUESTER)); String reviewCommitPrefix = query.getAttribute(AppraiseConnectorPlugin.QUERY_REVIEW_COMMIT_PREFIX); List<ReviewResult> reviews = client.listReviews(); if (reviews == null) { return new Status(Status.ERROR, AppraiseConnectorPlugin.PLUGIN_ID, "Error running review list query"); } for (ReviewResult review : reviews) { TaskData taskData = taskDataHandler.createPartialTaskData(repository, review); boolean shouldAccept = false; if (!reviewer && !requester) { // Accept everything if no filters are set. shouldAccept = true; } else if (reviewer && review.isCurrentUserReviewer()) { shouldAccept = true; } else if (requester && review.isCurrentUserRequester()) { shouldAccept = true; } if (reviewCommitPrefix != null && !reviewCommitPrefix.isEmpty()) { shouldAccept = shouldAccept && review.getHash().startsWith(reviewCommitPrefix); } if (shouldAccept) { collector.accept(taskData); } } return Status.OK_STATUS; }
Example 20
Source File: CreateRegionCommand.java From statecharts with Eclipse Public License 1.0 | 4 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) protected EObject doDefaultElementCreation(int index) { EObject result = null; EReference reference = getContainmentFeature(); EClass eClass = getElementType().getEClass(); if (reference != null) { EObject container = getElementToEdit(); if (container != null) { IResourceHelper helper = Util.getHelper(container.eResource()); if (helper != null) { result = helper.create(eClass); } else { result = eClass.getEPackage().getEFactoryInstance() .create(eClass); } if (FeatureMapUtil.isMany(container, reference)) { ((List) container.eGet(reference)).add(index, result); } else { container.eSet(reference, result); } return result; } } IStatus status = (result != null) ? Status.OK_STATUS : new Status( Status.ERROR, DiagramActivator.PLUGIN_ID, "CreateRegionCommand: No Region created: " + getElementType().getDisplayName()); setDefaultElementCreationStatus(status); return result; }