Commit 583c22a7 authored by Christian Wulf's avatar Christian Wulf

added error messages when the Kieker nature could not be added;

updated repository
parent da479c31
......@@ -54,4 +54,8 @@ public class Activator extends AbstractUIPlugin {
getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
}
public void logErrorMsgToErrorLog(final String message) {
getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message));
}
}
......@@ -12,19 +12,22 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.handlers.HandlerUtil;
import kieker.tools.eclipse.monitoring.KiekerMonitoringNature;
import kieker.tools.eclipse.monitoring.*;
public class ProjectNatureHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
if (currentSelection instanceof IStructuredSelection) {
if (!(currentSelection instanceof IStructuredSelection)) {
String message = String.format("Invalid selection type '%s'", currentSelection);
Activator.getDefault().logErrorMsgToErrorLog(message);
return null;
}
Object firstElement = ((IStructuredSelection) currentSelection).getFirstElement();
......@@ -32,7 +35,18 @@ public class ProjectNatureHandler extends AbstractHandler {
IAdapterManager adapterManager = Platform.getAdapterManager();
IResource resourceAdapter = adapterManager.getAdapter(firstElement, IResource.class);
if (resourceAdapter != null) {
if (resourceAdapter == null) {
String message = String.format("Cannot find an adapter for '%s'", firstElement);
Activator.getDefault().logErrorMsgToErrorLog(message);
return null;
}
addNature(resourceAdapter);
return null;
}
private void addNature(IResource resourceAdapter) throws ExecutionException {
IResource resource = resourceAdapter;
IProject project = resource.getProject();
try {
......@@ -52,16 +66,13 @@ public class ProjectNatureHandler extends AbstractHandler {
if (status.getCode() == IStatus.OK) {
description.setNatureIds(newNatures);
project.setDescription(description, null);
} else {
String message = String.format("Invalid nature status '%s'", status);
Activator.getDefault().logErrorMsgToErrorLog(message);
}
return status;
} catch (CoreException e) {
throw new ExecutionException(e.getMessage(), e);
}
}
}
return Status.OK_STATUS;
}
}
#Wed Jan 10 17:06:06 CET 2018
#Wed Jan 10 17:49:22 CET 2018
version=1
metadata.repository.factory.order=content.xml.xz,content.xml,\!
artifact.repository.factory.order=artifacts.xml.xz,artifacts.xml,\!
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment