use of org.eclipse.core.runtime.MultiStatus in project liferay-ide by liferay.
the class LiferayPublishOperation method throwException.
/**
* Utility method to throw a CoreException based on the contents of a list of
* error and warning status.
*
* @param status a List containing error and warning IStatus
* @throws CoreException
*/
protected static void throwException(List status) throws CoreException {
if (status == null || status.size() == 0)
return;
if (status.size() == 1) {
IStatus status2 = (IStatus) status.get(0);
throw new CoreException(status2);
}
IStatus[] children = new IStatus[status.size()];
status.toArray(children);
String message = Msgs.errorPublish;
MultiStatus status2 = new MultiStatus(TomcatPlugin.PLUGIN_ID, 0, children, message, null);
throw new CoreException(status2);
}
use of org.eclipse.core.runtime.MultiStatus in project liferay-ide by liferay.
the class SDK method validate.
public IStatus validate(boolean reload) {
MultiStatus status = new MultiStatus(SDKCorePlugin.PLUGIN_ID, IStatus.OK, "", null);
boolean validLocation = SDKUtil.isValidSDKLocation(getLocation().toOSString());
IPath buildXmlLocation = getLocation().append("build.xml");
if (!validLocation) {
status.add(SDKCorePlugin.createErrorStatus(Msgs.sdkLocationInvalid));
return status;
}
if (!buildXmlLocation.toFile().exists()) {
status.add(SDKCorePlugin.createErrorStatus(Msgs.buildXmlFileNotExist));
return status;
}
Map<String, Object> sdkProperties = null;
try {
sdkProperties = getBuildProperties(reload);
if (sdkProperties == null) {
status.add(SDKCorePlugin.createErrorStatus("Could not find any sdk settings."));
return status;
}
} catch (Exception e) {
status.add(SDKCorePlugin.createErrorStatus(e.getMessage()));
return status;
}
for (String propertyKey : appServerPropertiesKeys) {
if (!status.isOK()) {
break;
}
String propertyValue = (String) sdkProperties.get(propertyKey);
if (propertyValue == null) {
status.add(SDKCorePlugin.createErrorStatus(propertyKey + " is null."));
} else {
switch(propertyKey) {
case "app.server.type":
if (!supportedServerTypes.contains(propertyValue)) {
status.add(SDKCorePlugin.createErrorStatus("The " + propertyKey + "(" + propertyValue + ") server is not supported by Liferay IDE."));
}
break;
case "app.server.dir":
case "app.server.deploy.dir":
case "app.server.lib.global.dir":
case "app.server.parent.dir":
case "app.server.portal.dir":
IPath propertyPath = new Path(propertyValue);
if (!propertyPath.toFile().exists()) {
String errorMessage = new String(propertyKey + " is invalid. Please reconfigure Plugins SDK setting: " + propertyKey + "=" + propertyValue);
status.add(SDKCorePlugin.createErrorStatus(SDKCorePlugin.PLUGIN_ID, errorMessage));
}
break;
default:
}
}
}
return status;
}
use of org.eclipse.core.runtime.MultiStatus in project jbosstools-hibernate by jbosstools.
the class HibernatePlugin method throwableToStatus.
public static IStatus throwableToStatus(Throwable t, int code) {
List<IStatus> causes = new ArrayList<IStatus>();
Throwable temp = t;
while (temp != null && temp.getCause() != temp) {
causes.add(new Status(IStatus.ERROR, getId(), code, temp.getMessage() == null ? temp.toString() + HibernateConsoleMessages.HibernateConsolePlugin_no_message_1 : temp.toString(), temp));
temp = temp.getCause();
}
String msg = HibernateConsoleMessages.HibernateConsolePlugin_no_message_2;
if (t != null && t.getMessage() != null) {
msg = t.toString();
}
if (causes.isEmpty()) {
return new Status(IStatus.ERROR, getId(), code, msg, t);
} else {
return new MultiStatus(getId(), code, causes.toArray(new IStatus[causes.size()]), msg, t);
}
}
use of org.eclipse.core.runtime.MultiStatus in project jbosstools-hibernate by jbosstools.
the class HibernateConsolePlugin method openError.
/*public ConsoleConfiguration getLastUsedConfiguration() {
String lastUsedName = getDefault().getPreferenceStore().getString(HibernateConsolePlugin.LAST_USED_CONFIGURATION_PREFERENCE);
ConsoleConfiguration lastUsed = (lastUsedName == null || lastUsedName.trim().length()==0)
? null
: KnownConfigurations.getInstance().find(lastUsedName);
if(lastUsed==null && KnownConfigurations.getInstance().getConfigurations().length==1) {
lastUsed = KnownConfigurations.getInstance().getConfigurations()[0];
}
return lastUsed;
}*/
/*public void setLastUsedConfiguration(ConsoleConfiguration lastUsed) {
String name;
if(lastUsed==null) {
name = "";
} else {
name = lastUsed.getName();
}
HibernateConsolePlugin.getDefault().getPreferenceStore().setValue(
LAST_USED_CONFIGURATION_PREFERENCE, name );
}*/
/**
* Convenience method for showing an error dialog
* @param shell a valid shell or null
* @param exception the exception to be report
* @param title the title to be displayed
* @param flags customizing attributes for the error handling
* @return IStatus the status that was displayed to the user
*/
public static IStatus openError(Shell providedShell, String title, String message, Throwable exception, int flags) {
// Unwrap InvocationTargetExceptions
if (exception instanceof InvocationTargetException) {
Throwable target = ((InvocationTargetException) exception).getTargetException();
// re-throw any runtime exceptions or errors so they can be handled by the workbench
if (target instanceof RuntimeException) {
throw (RuntimeException) target;
}
if (target instanceof Error) {
throw (Error) target;
}
return openError(providedShell, title, message, target, flags);
}
// Determine the status to be displayed (and possibly logged)
IStatus status = null;
if (exception instanceof CoreException) {
status = ((CoreException) exception).getStatus();
} else if (exception != null) {
status = new MultiStatus(ID, IStatus.ERROR, new IStatus[] { throwableToStatus(exception.getCause()) }, exception.toString(), exception);
}
if (status.isOK()) {
return status;
}
// Create a runnable that will display the error status
final String displayTitle = title;
final String displayMessage = message;
final IStatus displayStatus = status;
final IOpenableInShell openable = new IOpenableInShell() {
public void open(Shell shell) {
if (displayStatus.getSeverity() == IStatus.INFO && !displayStatus.isMultiStatus()) {
// $NON-NLS-1$
MessageDialog.openInformation(shell, "Information", displayStatus.getMessage());
} else {
ErrorDialog.openError(shell, displayTitle, displayMessage, displayStatus);
}
}
};
openDialog(providedShell, openable, flags);
// return the status we display
return status;
}
use of org.eclipse.core.runtime.MultiStatus in project jbosstools-hibernate by jbosstools.
the class HibernateConsolePlugin method logErrorMessage.
public void logErrorMessage(String message, Throwable[] t) {
IStatus[] children = new IStatus[t.length];
for (int i = 0; i < t.length; i++) {
Throwable throwable = t[i];
children[i] = throwableToStatus(throwable);
}
IStatus s = new MultiStatus(ID, 150, children, message, null);
log(s);
}
Aggregations