diff options
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions')
6 files changed, 0 insertions, 443 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/GenerateDDLAction.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/GenerateDDLAction.java deleted file mode 100644 index f6aca3be2b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/GenerateDDLAction.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.actions; - -import org.eclipse.jpt.jpa.core.JpaProject; - -/** - * GenerateDDLAction - */ -public class GenerateDDLAction extends ProjectAction { - - public GenerateDDLAction() { - super(); - } - - @Override - protected void execute(JpaProject project) { - this.getJpaPlatformUi(project).generateDDL(project, this.getCurrentSelection()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/GenerateEntitiesAction.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/GenerateEntitiesAction.java deleted file mode 100644 index 383633831a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/GenerateEntitiesAction.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2007, 2009 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. -* -* Contributors: -* Oracle - initial API and implementation -*******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.actions; - -import org.eclipse.jpt.jpa.core.JpaProject; - -/** - * GenerateEntitiesAction - */ -public class GenerateEntitiesAction extends ProjectAction { - public GenerateEntitiesAction() { - super(); - } - - @Override - protected void execute(JpaProject project) { - this.getJpaPlatformUi(project).generateEntities(project, this.getCurrentSelection()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/MakePersistentAction.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/MakePersistentAction.java deleted file mode 100644 index 4fcf0b4caf..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/MakePersistentAction.java +++ /dev/null @@ -1,145 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2010 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. -* -* Contributors: -* Oracle - initial API and implementation -*******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.actions; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.eclipse.core.resources.IProject; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.wizards.JpaMakePersistentWizard; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; - - -public class MakePersistentAction implements IObjectActionDelegate { - - - private Map<IProject, List<IType>> selectedTypes; - - public MakePersistentAction() { - super(); - } - - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - // do nothing - } - - public void selectionChanged(IAction action, ISelection selection) { - // Action is contributed for IType, ICompilationUnit, IPackageFragment, and IPackageFragmentRoot that is a source folder - this.selectedTypes = this.buildSelectedTypes((StructuredSelection) selection); - } - - protected Map<IProject, List<IType>> buildSelectedTypes(StructuredSelection structuredSelection) { - Map<IProject, List<IType>> types = new HashMap<IProject, List<IType>>(); - - for (Object selection : structuredSelection.toList()) { - switch (((IJavaElement) selection).getElementType()) { - case IJavaElement.TYPE : - addSelectedType((IType) selection, types); - break; - case IJavaElement.COMPILATION_UNIT : - addSelectedType((ICompilationUnit) selection, types); - break; - case IJavaElement.PACKAGE_FRAGMENT : - addSelectedType((IPackageFragment) selection, types); - break; - case IJavaElement.PACKAGE_FRAGMENT_ROOT : - addSelectedType((IPackageFragmentRoot) selection, types); - break; - default : - break; - } - } - return types; - } - - private void addSelectedType(IPackageFragmentRoot packageFragmentRoot, Map<IProject, List<IType>> types) { - for (IJavaElement pkgFragment : getPackageFragments(packageFragmentRoot)) { - addSelectedType((IPackageFragment) pkgFragment, types); - } - } - - private void addSelectedType(IPackageFragment packageFragment, Map<IProject, List<IType>> types) { - for (ICompilationUnit compUnit : getCompilationUnits(packageFragment)) { - addSelectedType(compUnit, types); - } - } - - private void addSelectedType(ICompilationUnit compilationUnit, Map<IProject, List<IType>> types) { - IType primaryType = this.getPrimaryType(compilationUnit); - if (primaryType != null) { - this.addSelectedType(primaryType, types); - } - } - - private void addSelectedType(IType primaryType, Map<IProject, List<IType>> typesMap) { - IProject project = primaryType.getJavaProject().getProject(); - List<IType> types = typesMap.get(project); - if (types == null) { - types = new ArrayList<IType>(); - typesMap.put(project, types); - } - if (!types.contains(primaryType)) { - types.add(primaryType); - } - } - - private ICompilationUnit[] getCompilationUnits(IPackageFragment packageFragment) { - try { - return packageFragment.getCompilationUnits(); - } - catch (JavaModelException e) { - JptJpaUiPlugin.log(e); - } - return new ICompilationUnit[0]; - } - - private IJavaElement[] getPackageFragments(IPackageFragmentRoot packageFragmentRoot) { - try { - return packageFragmentRoot.getChildren(); - } - catch (JavaModelException e) { - JptJpaUiPlugin.log(e); - } - return new IJavaElement[0]; - } - - private IType getPrimaryType(ICompilationUnit compilationUnit) { - return compilationUnit.findPrimaryType(); - } - - public void run(IAction action) { - for (List<IType> types : this.selectedTypes.values()) { - //open the wizard once for each selected project - JpaMakePersistentWizard wizard = new JpaMakePersistentWizard(types); - WizardDialog dialog = new WizardDialog(this.getCurrentShell(), wizard); - dialog.create(); - dialog.open(); - } - } - - private Shell getCurrentShell() { - return Display.getCurrent().getActiveShell(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/OpenJpaResourceAction.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/OpenJpaResourceAction.java deleted file mode 100644 index d1e156202a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/OpenJpaResourceAction.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2011 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 - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.actions; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jpt.jpa.core.JpaStructureNode; -import org.eclipse.jpt.jpa.core.context.JpaContextNode; -import org.eclipse.jpt.jpa.core.context.JpaRootContextNode; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -import org.eclipse.jpt.jpa.ui.internal.selection.DefaultJpaSelection; -import org.eclipse.jpt.jpa.ui.internal.selection.JpaSelectionManager; -import org.eclipse.jpt.jpa.ui.internal.selection.SelectionManagerFactory; -import org.eclipse.ui.IEditorDescriptor; -import org.eclipse.ui.IEditorRegistry; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.BaseSelectionListenerAction; -import org.eclipse.ui.ide.IDE; -import org.eclipse.ui.part.FileEditorInput; - -public class OpenJpaResourceAction - extends BaseSelectionListenerAction { - - private JpaContextNode selectedNode; - - - public OpenJpaResourceAction() { - super("Open"); //$NON-NLS-1$ - } - - - @Override - public boolean updateSelection(IStructuredSelection s) { - selectedNode = null; - - if (! super.updateSelection(s)) { - return false; - } - - if (s.size() != 1) { - return false; - } - - if (s.getFirstElement() instanceof JpaRootContextNode) { - return false; - } - - selectedNode = (JpaContextNode) s.getFirstElement(); - - return true; - } - - @Override - public void run() { - if (! isEnabled()) { - return; - } - - IResource resource = selectedNode.getResource(); - - if (resource != null && resource.exists() && resource.getType() == IResource.FILE) { - openEditor((IFile) resource); - - - if (selectedNode instanceof JpaStructureNode) { - JpaSelectionManager selectionManager = - SelectionManagerFactory.getSelectionManager(PlatformUI.getWorkbench().getActiveWorkbenchWindow()); - selectionManager.select(new DefaultJpaSelection((JpaStructureNode) selectedNode), null); - } - } - } - - protected void openEditor(IFile file) { - IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); - IContentType contentType = IDE.getContentType(file); - IEditorDescriptor editorDescriptor = registry.getDefaultEditor(file.getName(), contentType); - if (editorDescriptor == null) { - return; // no editor associated... - } - - IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - - try { - page.openEditor(new FileEditorInput(file), editorDescriptor.getId()); - } - catch (Exception e) { - MessageDialog.openError(page.getWorkbenchWindow().getShell(), JptUiMessages.Error_openingEditor, e.getMessage()); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/ProjectAction.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/ProjectAction.java deleted file mode 100644 index a91b6381f2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/ProjectAction.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.actions; - -import java.util.Iterator; -import org.eclipse.core.resources.IProject; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.ui.JpaPlatformUi; -import org.eclipse.jpt.jpa.ui.internal.platform.JpaPlatformUiRegistry; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; - -/** - * Override any of the #execute() methods. - */ -public abstract class ProjectAction implements IObjectActionDelegate { - - private ISelection currentSelection; - - - public ProjectAction() { - super(); - } - - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - // do nothing - } - - public void selectionChanged(IAction action, ISelection selection) { - this.currentSelection = selection; - } - - protected IStructuredSelection getCurrentSelection() { - if (this.currentSelection instanceof IStructuredSelection) { - return (IStructuredSelection) this.currentSelection; - } - return null; - } - - public void run(IAction action) { - if (this.currentSelection instanceof IStructuredSelection) { - for (Iterator stream = ((IStructuredSelection) this.currentSelection).iterator(); stream.hasNext(); ) { - this.execute(stream.next()); - } - } - } - - protected void execute(Object selection) { - IProject project = this.projectFromSelection(selection); - if (project != null) { - this.execute(project); - } - } - - protected IProject projectFromSelection(Object selection) { - if (selection instanceof IProject) { - return (IProject) selection; - } - if (selection instanceof IJavaProject) { - return ((IJavaProject) selection).getProject(); - } - return null; - } - - protected JpaPlatformUi getJpaPlatformUi(JpaProject project) { - String coreJpaPlatformId = project.getJpaPlatform().getId(); - return JpaPlatformUiRegistry.instance().getJpaPlatformUi(coreJpaPlatformId); - } - - protected void execute(IProject project) { - JpaProject jpaProject = JptJpaCorePlugin.getJpaProject(project); - if (jpaProject == null) { - return; - } - this.execute(jpaProject); - } - - protected void execute(JpaProject project) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/SynchronizeClassesAction.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/SynchronizeClassesAction.java deleted file mode 100644 index 9f16d7a440..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/SynchronizeClassesAction.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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 - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.actions; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml; -import org.eclipse.jpt.jpa.core.internal.synch.SynchronizeClassesJob; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; - -public class SynchronizeClassesAction - implements IObjectActionDelegate -{ - private IFile file; - - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - // no-op for now - } - - public void run(IAction action) { - SynchronizeClassesJob job = new SynchronizeClassesJob(file); - job.schedule(); - } - - public void selectionChanged(IAction action, ISelection selection) { - // Action is contributed for IFile's named "persistence.xml" and - // for PeristenceXml objects. - // There is always only one element in actual selection. - Object selectedObject = ((StructuredSelection) selection).getFirstElement(); - - if (selectedObject instanceof IFile) { - file = (IFile) selectedObject; - } - else if (selectedObject instanceof PersistenceXml) { - file = (IFile) ((PersistenceXml) selectedObject).getResource(); - } - } -} |