You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by pk...@apache.org on 2013/07/01 14:25:21 UTC
svn commit: r1498408 - in /uima/sandbox/ruta/trunk/ruta-ep-addons: plugin.xml
src/main/java/org/apache/uima/ruta/utils/update/ConvertProjectHandler.java
src/main/java/org/apache/uima/ruta/utils/update/UpdateProjectHandler.java
Author: pkluegl
Date: Mon Jul 1 12:25:21 2013
New Revision: 1498408
URL: http://svn.apache.org/r1498408
Log:
UIMA-3027
- added command to convert projects
Added:
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/utils/update/ConvertProjectHandler.java
Modified:
uima/sandbox/ruta/trunk/ruta-ep-addons/plugin.xml
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/utils/update/UpdateProjectHandler.java
Modified: uima/sandbox/ruta/trunk/ruta-ep-addons/plugin.xml
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/plugin.xml?rev=1498408&r1=1498407&r2=1498408&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-addons/plugin.xml (original)
+++ uima/sandbox/ruta/trunk/ruta-ep-addons/plugin.xml Mon Jul 1 12:25:21 2013
@@ -305,6 +305,11 @@ under the License.
id="org.apache.uima.ruta.utils.update"
name="Update Project">
</command>
+ <command
+ defaultHandler="org.apache.uima.ruta.utils.update.ConvertProjectHandler"
+ id="org.apache.uima.ruta.utils.convert"
+ name="Convert to UIMA Ruta project">
+ </command>
</extension> <extension
point="org.eclipse.ui.menus">
<menuContribution
@@ -444,6 +449,25 @@ under the License.
</visibleWhen>
</command>
</menuContribution>
+ <menuContribution
+ locationURI="popup:org.apache.uima.ruta.utils.popup.submenu">
+ <command
+ commandId="org.apache.uima.ruta.utils.convert"
+ disabledIcon="icons/ruta_obj.png"
+ hoverIcon="icons/ruta_obj.png"
+ icon="icons/ruta_obj.png"
+ id="org.apache.uima.ruta.utils.convert.popup"
+ label="Convert to UIMA Ruta project"
+ style="push"
+ tooltip="Convert to UIMA Ruta project">
+ <visibleWhen
+ checkEnabled="true">
+ <reference
+ definitionId="org.apache.uima.ruta.utils.convert.definition">
+ </reference>
+ </visibleWhen>
+ </command>
+ </menuContribution>
</extension> <extension
point="org.eclipse.core.expressions.definitions">
<definition
@@ -502,6 +526,23 @@ under the License.
</iterate>
</with>
</definition>
+ <definition
+ id="org.apache.uima.ruta.utils.convert.definition">
+ <with
+ variable="selection">
+ <iterate
+ ifEmpty="true">
+ <or>
+ <instanceof
+ value="org.eclipse.dltk.core.IScriptProject ">
+ </instanceof>
+ <instanceof
+ value="org.eclipse.core.resources.IProject ">
+ </instanceof>
+ </or>
+ </iterate>
+ </with>
+ </definition>
</extension> <extension
point="org.eclipse.ui.bindings">
<key
Added: uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/utils/update/ConvertProjectHandler.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/utils/update/ConvertProjectHandler.java?rev=1498408&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/utils/update/ConvertProjectHandler.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/utils/update/ConvertProjectHandler.java Mon Jul 1 12:25:21 2013
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.utils.update;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.uima.ruta.addons.RutaAddonsPlugin;
+import org.apache.uima.ruta.ide.core.RutaNature;
+import org.apache.uima.ruta.ide.ui.wizards.RutaProjectCreationWizard;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.commands.IHandlerListener;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.dltk.core.DLTKCore;
+import org.eclipse.dltk.core.IScriptProject;
+import org.eclipse.dltk.utils.ResourceUtil;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public class ConvertProjectHandler implements IHandler {
+
+ private class ConvertProjectHandlerJob extends Job {
+ ExecutionEvent event;
+
+ ConvertProjectHandlerJob(ExecutionEvent event) {
+ super("Converting...");
+ this.event = event;
+ setUser(true);
+ }
+
+ @Override
+ public IStatus run(IProgressMonitor monitor) {
+ List<IProject> projects = new ArrayList<IProject>();
+ final ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
+ if (currentSelection instanceof IStructuredSelection) {
+ StructuredSelection selection = (StructuredSelection) currentSelection;
+ Iterator<?> iter = selection.iterator();
+ while (iter.hasNext()) {
+ Object object = iter.next();
+ if (object instanceof IScriptProject) {
+ IScriptProject p = (IScriptProject) object;
+ projects.add(p.getProject());
+ } else if (object instanceof IProject) {
+ projects.add((IProject) object);
+ }
+ }
+ }
+ monitor.beginTask("Converting to UIMA Ruta project...", projects.size());
+ for (IProject each : projects) {
+ try {
+ IScriptProject scriptProject = DLTKCore.create(each);
+ ResourceUtil.addNature(each, monitor, RutaNature.NATURE_ID);
+ RutaProjectCreationWizard.createRutaProject(scriptProject, null, monitor);
+ } catch (CoreException e) {
+ RutaAddonsPlugin.error(e);
+ }
+ }
+ monitor.done();
+ return Status.OK_STATUS;
+ }
+ }
+
+ public void addHandlerListener(IHandlerListener arg0) {
+
+ }
+
+ public void dispose() {
+
+ }
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ new ConvertProjectHandlerJob(event).schedule();
+ return Status.OK_STATUS;
+ }
+
+ public boolean isEnabled() {
+ return true;
+ }
+
+ public boolean isHandled() {
+ return true;
+ }
+
+ public void removeHandlerListener(IHandlerListener arg0) {
+
+ }
+
+}
Modified: uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/utils/update/UpdateProjectHandler.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/utils/update/UpdateProjectHandler.java?rev=1498408&r1=1498407&r2=1498408&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/utils/update/UpdateProjectHandler.java (original)
+++ uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/utils/update/UpdateProjectHandler.java Mon Jul 1 12:25:21 2013
@@ -143,7 +143,7 @@ public class UpdateProjectHandler implem
public Object execute(ExecutionEvent event) throws ExecutionException {
new ConverterHandlerJob(event).schedule();
- return null;
+ return Status.OK_STATUS;
}
public boolean isEnabled() {