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

The following examples show how to use org.eclipse.core.runtime.Status#WARNING . 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: JStructPlugin.java    From junion with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static void log(int status, String msg, Exception e) {
		if(instance != null) {
			Status st = new Status(status, PLUGIN_ID, Status.OK, msg, e);
			instance.getLog().log(st);
			if(status == Status.ERROR || status == Status.WARNING) {
//				StatusManager sm = StatusManager.getManager();
//				log("SM handle" + sm);
//		    	if(sm != null) {
//		    		
//		    		sm.handle(st, StatusManager.SHOW);
//		    	}
			}
		}
		else {
			if(e != null) System.out.println(msg + ", " + e.toString());
			else System.out.println(msg);
		}
	}
 
Example 2
Source File: WizardNewHybridProjectCreationPage.java    From thym with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected IStatus run(IProgressMonitor monitor) {
	try {
		ErrorDetectingCLIResult result = new CordovaCLI().version(monitor).convertTo(ErrorDetectingCLIResult.class);
		if(result.asStatus().getCode() == CordovaCLIErrors.ERROR_COMMAND_MISSING){
			return Status.OK_STATUS;
		}
		if(result.asStatus().isOK()){
			cordovaVersion = Version.parseVersion(result.getMessage()).toString();
			return Status.OK_STATUS;
		}
	} catch (Exception e) {
		HybridUI.log(WARNING, "Unable to determine if cordova is available", e);
	}
	return new Status(Status.WARNING, HybridUI.PLUGIN_ID, "");
	
}
 
Example 3
Source File: StatusUtil.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
private static String getSeverityString(int severity) {
	switch (severity) {
	case Status.OK:
		return "OK";
	case Status.WARNING:
		return "WARNING";
	case Status.ERROR:
		return "ERROR";
	case Status.INFO:
		return "INFO";
	case Status.CANCEL:
		return "CANCEL";
	default:
		return "? " + severity + " ?";
	}
}
 
Example 4
Source File: DataflowJavaProjectNature.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Adds the Dataflow Nature ID to the {@code IProjectDescription} of the provided project.
 */
public static void addDataflowJavaNatureToProject(IProject project, IProgressMonitor monitor)
    throws CoreException {
  Preconditions.checkNotNull(project);
  if (!project.isAccessible()) {
    throw new CoreException(new Status(Status.WARNING, DataflowCorePlugin.PLUGIN_ID,
        "Can't add the Dataflow nature to closed project " + project.getName()));
  }
  NatureUtils.addNature(project, DATAFLOW_NATURE_ID, monitor);
}
 
Example 5
Source File: DataflowJavaProjectNature.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Removes the Dataflow Nature ID from the {@code IProjectDescription} of the provided project.
 */
public static void removeDataflowJavaNatureFromProject(IProject project, IProgressMonitor monitor)
    throws CoreException {
  Preconditions.checkNotNull(project);
  if (!project.isAccessible()) {
    throw new CoreException(new Status(Status.WARNING, DataflowCorePlugin.PLUGIN_ID,
        "Can't remove the Dataflow nature from closed project " + project.getName()));
  }
  NatureUtils.removeNature(project, DATAFLOW_NATURE_ID, monitor);
}
 
Example 6
Source File: StockService.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public IStatus performSingleDisposal(String articleStoreToString, int count, String mandatorId){
	Optional<Identifiable> article =
		StoreToStringServiceHolder.get().loadFromString(articleStoreToString);
	if (article.isPresent()) {
		return performSingleDisposal((IArticle) article.get(), count, mandatorId);
	}
	return new Status(Status.WARNING, "ch.elexis.core.services",
		"No article found [" + articleStoreToString + "]");
}
 
Example 7
Source File: StockService.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public IStatus performSingleReturn(String articleStoreToString, int count, String mandatorId){
	Optional<Identifiable> article =
		StoreToStringServiceHolder.get().loadFromString(articleStoreToString);
	if (article.isPresent()) {
		return performSingleReturn((IArticle) article.get(), count, mandatorId);
	}
	return new Status(Status.WARNING, "ch.elexis.core.services",
		"No article found [" + articleStoreToString + "]");
}
 
Example 8
Source File: PluginLogger.java    From SparkBuilderGenerator with MIT License 4 votes vote down vote up
public void warn(String message) {
    Status messageToLog = new Status(Status.WARNING, Activator.PLUGIN_ID, message);
    logMessage(messageToLog);
}
 
Example 9
Source File: PluginLogger.java    From SparkBuilderGenerator with MIT License 4 votes vote down vote up
public void warn(String message, Throwable exception) {
    Status messageToLog = new Status(Status.WARNING, Activator.PLUGIN_ID, message, exception);
    logMessage(messageToLog);
}
 
Example 10
Source File: SCTBuilder.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
protected void logGenmodelError(String resource) {
	Status status = new Status(Status.WARNING, BUILDER_ID,
			String.format("Cannot execute Genmodel %s. The file contains errors.", resource));
	Platform.getLog(BuilderActivator.getDefault().getBundle()).log(status);
}
 
Example 11
Source File: SCTBuilder.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
protected void logStatechartError(final String resource) {
	Status status = new Status(Status.WARNING, BUILDER_ID,
			String.format("Cannot generate Code for Statechart %s. The file contains errors.", resource));
	Platform.getLog(BuilderActivator.getDefault().getBundle()).log(status);
}
 
Example 12
Source File: StatusUtil.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * 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 13
Source File: StockService.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
@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 14
Source File: StockService.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
@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: ResultStatusAdapter.java    From elexis-3-core with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Adapt the result of an {@link IIdentifiedRunnable} to an {@link IStatus}
 * 
 * @param run
 * @return
 */
public static IStatus adapt(Map<String, Serializable> result){
	String resultData = (String) result.get(IIdentifiedRunnable.ReturnParameter.RESULT_DATA);
	boolean isWarning = result.containsKey(IIdentifiedRunnable.ReturnParameter.MARKER_WARN);
	return new Status(isWarning ? Status.WARNING : Status.OK, "unknown", resultData);
}