diff options
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/handlers/AddPersistentAttributeToXmlHandler.java')
-rw-r--r-- | jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/handlers/AddPersistentAttributeToXmlHandler.java | 38 |
1 files changed, 10 insertions, 28 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/handlers/AddPersistentAttributeToXmlHandler.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/handlers/AddPersistentAttributeToXmlHandler.java index ca1edad755..1e0a986ca4 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/handlers/AddPersistentAttributeToXmlHandler.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/handlers/AddPersistentAttributeToXmlHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2012 Oracle. All rights reserved. + * Copyright (c) 2006, 2013 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -9,16 +9,9 @@ ******************************************************************************/ package org.eclipse.jpt.jpa.ui.internal.handlers; -import java.util.ArrayList; -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jpt.common.core.internal.utility.PlatformTools; +import java.util.Map; import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.jpa.ui.selection.JpaSelectionManager; import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.handlers.HandlerUtil; /** * Convert a list of <code>orm.xml</code> <em>virtual</em> attributes to @@ -30,25 +23,14 @@ import org.eclipse.ui.handlers.HandlerUtil; * See <code>org.eclipse.jpt.jpa.ui/plugin.xml</code>. */ public class AddPersistentAttributeToXmlHandler - extends AbstractHandler -{ - public Object execute(ExecutionEvent event) throws ExecutionException { - this.execute_(event); - return null; - } - - private void execute_(ExecutionEvent event) throws ExecutionException { - ArrayList<OrmPersistentAttribute> specifiedAttributes = new ArrayList<OrmPersistentAttribute>(); - IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event); - for (Object each : selection.toList()) { - OrmPersistentAttribute attribute = (OrmPersistentAttribute) each; - specifiedAttributes.add(attribute.addToXml()); - } - - if (specifiedAttributes.size() == 1) { - IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); - JpaSelectionManager selectionManager = PlatformTools.getAdapter(window, JpaSelectionManager.class); - selectionManager.setSelection(specifiedAttributes.get(0)); + extends JpaStructureViewHandler +{ + @Override + protected void execute_(Object[] items, Map<String, String> parameters, IWorkbenchWindow window) { + for (int i = 0; i < items.length; i++) { + OrmPersistentAttribute attribute = (OrmPersistentAttribute) items[i]; + // a little hacky... :-) + items[i] = attribute.addToXml(); } } } |