diff --git a/kieker.tools.eclipse.parent/kieker.tools.eclipse.monitoring/src/kieker/tools/eclipse/monitoring/Activator.java b/kieker.tools.eclipse.parent/kieker.tools.eclipse.monitoring/src/kieker/tools/eclipse/monitoring/Activator.java index a79a94aeda9f4e1fab952493356e164de1abc7f3..0981261259e10d695b14035e5ccfd312621fac90 100644 --- a/kieker.tools.eclipse.parent/kieker.tools.eclipse.monitoring/src/kieker/tools/eclipse/monitoring/Activator.java +++ b/kieker.tools.eclipse.parent/kieker.tools.eclipse.monitoring/src/kieker/tools/eclipse/monitoring/Activator.java @@ -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)); + } + } diff --git a/kieker.tools.eclipse.parent/kieker.tools.eclipse.monitoring/src/kieker/tools/eclipse/monitoring/handlers/ProjectNatureHandler.java b/kieker.tools.eclipse.parent/kieker.tools.eclipse.monitoring/src/kieker/tools/eclipse/monitoring/handlers/ProjectNatureHandler.java index 3be1b1ca1317d45aa8cbdf9d95706df39c2ef9be..c32f975ddb8fd41db06b0f6e1a92f42b920fc06d 100644 --- a/kieker.tools.eclipse.parent/kieker.tools.eclipse.monitoring/src/kieker/tools/eclipse/monitoring/handlers/ProjectNatureHandler.java +++ b/kieker.tools.eclipse.parent/kieker.tools.eclipse.monitoring/src/kieker/tools/eclipse/monitoring/handlers/ProjectNatureHandler.java @@ -12,56 +12,67 @@ 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(); + + // Get an IResource as an adapter from the current selection + IAdapterManager adapterManager = Platform.getAdapterManager(); + IResource resourceAdapter = adapterManager.getAdapter(firstElement, IResource.class); - Object firstElement = ((IStructuredSelection) currentSelection).getFirstElement(); + if (resourceAdapter == null) { + String message = String.format("Cannot find an adapter for '%s'", firstElement); + Activator.getDefault().logErrorMsgToErrorLog(message); + return null; + } - // Get an IResource as an adapter from the current selection - IAdapterManager adapterManager = Platform.getAdapterManager(); - IResource resourceAdapter = adapterManager.getAdapter(firstElement, IResource.class); + addNature(resourceAdapter); - if (resourceAdapter != null) { - IResource resource = resourceAdapter; - IProject project = resource.getProject(); - try { - IProjectDescription description = project.getDescription(); - String[] natures = description.getNatureIds(); - String[] newNatures = new String[natures.length + 1]; - System.arraycopy(natures, 0, newNatures, 0, natures.length); + return null; + } - // add our new "com.example.project.examplenature" id - newNatures[natures.length] = KiekerMonitoringNature.NATURE_ID; + private void addNature(IResource resourceAdapter) throws ExecutionException { + IResource resource = resourceAdapter; + IProject project = resource.getProject(); + try { + IProjectDescription description = project.getDescription(); + String[] natures = description.getNatureIds(); + String[] newNatures = new String[natures.length + 1]; + System.arraycopy(natures, 0, newNatures, 0, natures.length); - // validate the natures - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IStatus status = workspace.validateNatureSet(newNatures); + // add our new "com.example.project.examplenature" id + newNatures[natures.length] = KiekerMonitoringNature.NATURE_ID; - // only apply new nature, if the status is ok - if (status.getCode() == IStatus.OK) { - description.setNatureIds(newNatures); - project.setDescription(description, null); - } + // validate the natures + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + IStatus status = workspace.validateNatureSet(newNatures); - return status; - } catch (CoreException e) { - throw new ExecutionException(e.getMessage(), e); - } + // only apply new nature, if the status is ok + 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); } + } catch (CoreException e) { + throw new ExecutionException(e.getMessage(), e); } - - return Status.OK_STATUS; } } diff --git a/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/artifacts.jar b/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/artifacts.jar index a44cfef7028c24348de4a9a75345dde627e09fc4..51865ad27afae3f2176fd847eb38216ae276fc40 100644 Binary files a/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/artifacts.jar and b/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/artifacts.jar differ diff --git a/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/artifacts.xml.xz b/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/artifacts.xml.xz index 5699d4f7cdc4225bb14963f51b2dcead751844c0..15e1acc98d1d7b92360f964381e292e23660de7c 100644 Binary files a/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/artifacts.xml.xz and b/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/artifacts.xml.xz differ diff --git a/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/content.jar b/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/content.jar index 282dd68d0508ea509c35679b682ae0491f74f9a6..1958a7556fa1cd4d2c8ba043d39e9d7d1d2109ab 100644 Binary files a/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/content.jar and b/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/content.jar differ diff --git a/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/content.xml.xz b/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/content.xml.xz index 0d79455467169138ed78eb5fb40a4332cef94fcb..cf69a473f84970f13d7eafc44beca14182c760c8 100644 Binary files a/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/content.xml.xz and b/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/content.xml.xz differ diff --git a/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/features/kieker.tools.eclipse.feature_1.0.0.201801101605.jar b/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/features/kieker.tools.eclipse.feature_1.0.0.201801101605.jar deleted file mode 100644 index 33e59c49b7e60e79ad4fec2e309f3e42bd40a479..0000000000000000000000000000000000000000 Binary files a/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/features/kieker.tools.eclipse.feature_1.0.0.201801101605.jar and /dev/null differ diff --git a/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/features/kieker.tools.eclipse.feature_1.0.0.201801101649.jar b/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/features/kieker.tools.eclipse.feature_1.0.0.201801101649.jar new file mode 100644 index 0000000000000000000000000000000000000000..58f77e70bc7f6264c89d476f5d0320fe943f870c Binary files /dev/null and b/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/features/kieker.tools.eclipse.feature_1.0.0.201801101649.jar differ diff --git a/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/p2.index b/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/p2.index index 216888428f3fe818e89ca1866350142e16c4bbdb..d2869e0a4deb51d016a8f34bfe806bf7120e72f7 100644 --- a/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/p2.index +++ b/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/p2.index @@ -1,4 +1,4 @@ -#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,\! diff --git a/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/plugins/kieker.tools.eclipse.analysis_1.0.0.201801101605.jar b/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/plugins/kieker.tools.eclipse.analysis_1.0.0.201801101649.jar similarity index 99% rename from kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/plugins/kieker.tools.eclipse.analysis_1.0.0.201801101605.jar rename to kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/plugins/kieker.tools.eclipse.analysis_1.0.0.201801101649.jar index dbb51fd21ccdf5b676810433be3231de8a64d3e5..4324e5ce0d95776a35489954018f4fd94a274277 100644 Binary files a/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/plugins/kieker.tools.eclipse.analysis_1.0.0.201801101605.jar and b/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/plugins/kieker.tools.eclipse.analysis_1.0.0.201801101649.jar differ diff --git a/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/plugins/kieker.tools.eclipse.monitoring_1.0.0.201801101605.jar b/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/plugins/kieker.tools.eclipse.monitoring_1.0.0.201801101649.jar similarity index 79% rename from kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/plugins/kieker.tools.eclipse.monitoring_1.0.0.201801101605.jar rename to kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/plugins/kieker.tools.eclipse.monitoring_1.0.0.201801101649.jar index 1b074c5410f9b5ae571cc9139b9d3f06b6896c27..51bfe61576975725ae582362dd66bae30118a32f 100644 Binary files a/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/plugins/kieker.tools.eclipse.monitoring_1.0.0.201801101605.jar and b/kieker.tools.eclipse.parent/kieker.tools.eclipse.repository/target/repository/plugins/kieker.tools.eclipse.monitoring_1.0.0.201801101649.jar differ