diff options
Diffstat (limited to 'plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions')
23 files changed, 0 insertions, 2970 deletions
diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractActionDelegate.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractActionDelegate.java deleted file mode 100644 index 9d9a71ef2..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractActionDelegate.java +++ /dev/null @@ -1,225 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.actions; - - - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchWindow; - - -public abstract class AbstractActionDelegate implements org.eclipse.ui.IActionDelegate { - protected ISelection selection; - protected boolean allowsMultiSelect = false; - public static final Class IPROJECT_CLASS = IProject.class; - private final static String ERROR_OCCURRED_TITLE = J2EEUIMessages.getResourceString("ERROR_OCCURRED_TITLE"); //$NON-NLS-1$ - private final static String ERROR_OCCURRED_MESSAGE = J2EEUIMessages.getResourceString("ERROR_OCCURRED_MESSAGE"); //$NON-NLS-1$ - - /** - * EditModuleDependencyAction constructor comment. - */ - public AbstractActionDelegate() { - super(); - } - - /** - * Applicable only when this action does not allow multi select - */ - protected IProject getProject() { - return getProject(getSelectedElement()); - } - - protected List getProjects() { - if ((selection == null) || !(selection instanceof IStructuredSelection)) - return Collections.EMPTY_LIST; - - List result = new ArrayList(); - IStructuredSelection struct = (IStructuredSelection) selection; - Iterator it = struct.iterator(); - while (it.hasNext()) { - IProject p = getProject(it.next()); - if (p != null) - result.add(p); - } - return result; - } - - protected IProject getProject(Object element) { - - if (isSupportedAction(element)) - return ProjectUtilities.getProject((EObject) element); - else if (element instanceof IAdaptable) - return (IProject) ((IAdaptable) element).getAdapter(IPROJECT_CLASS); - else - return null; - } - - protected IStructuredSelection getStructuredSelection() { - if ((selection == null) || !(selection instanceof IStructuredSelection)) - return null; - else if (selection.isEmpty()) { - selection = J2EEUIPlugin.getCurrentSelection(); - } - return (IStructuredSelection) selection; - } - - /* - * Only return if there is exactly one item selected - */ - protected Object getSelectedElement() { - IStructuredSelection sel = getStructuredSelection(); - return sel == null ? null : sel.getFirstElement(); - } - - protected IWorkbenchWindow getWorkbenchWindow() { - return J2EEUIPlugin.getActiveWorkbenchWindow(); - } - - /** - * Can the receiver be executed for - * - * @element - */ - protected abstract boolean isSupportedAction(Object element); - - /** - * @deprecated use {@link #primRun(Shell)} - */ - protected void primRun(IProject project, Shell shell) { - //Deprecated - } - - /** - * Subclasses should override this instead of {@link #run(org.eclipse.jface.action.IAction)} - */ - protected void primRun(Shell shell) { - primRun(getProject(), shell); - } - - /** - * Performs this action. - * <p> - * This method is called when the delegating action has been triggered. Implement this method to - * do the actual work. - * </p> - * - * @param action - * the action proxy that handles the presentation portion of the action - */ - public void run(org.eclipse.jface.action.IAction action) { - - Shell shell = getWorkbenchWindow().getShell(); - setActionStateFromProjects(action); - if (!action.isEnabled()) - MessageDialog.openInformation(shell, J2EEUIMessages.getResourceString("INFORMATION_UI_"), J2EEUIMessages.getResourceString("CHOSEN_OP_NOT_AVAILABLE")); //$NON-NLS-2$ = "The chosen operation is not currently available." //$NON-NLS-1$ = "Information" - else { - try { - primRun(shell); - } catch (Throwable t) { - org.eclipse.jst.j2ee.internal.plugin.ErrorDialog.openError(shell, ERROR_OCCURRED_TITLE, ERROR_OCCURRED_MESSAGE, t, 0, false); - } - } - - - } - - /** - * Notifies this action delegate that the selection in the workbench has changed. - * <p> - * Implementers can use this opportunity to change the availability of the action or to modify - * other presentation properties. - * </p> - * - * @param action - * the action proxy that handles presentation portion of the action - * @param aSelection - * the current selection in the workbench - */ - public void selectionChanged(org.eclipse.jface.action.IAction action, org.eclipse.jface.viewers.ISelection aSelection) { - this.selection = aSelection; - setActionState(action); - } - - protected void setActionState(IAction action) { - if (allowsMultiSelect) - setActionStateForMultiSelect(action); - else - setActionStateForSingleSelect(action); - } - - protected void setActionStateForSingleSelect(IAction action) { - IStructuredSelection sel = getStructuredSelection(); - if (sel == null || sel.size() != 1) { - action.setEnabled(false); - return; - } - setActionStateFromProjects(action); - } - - protected void setActionStateForMultiSelect(IAction action) { - setActionStateFromProjects(action); - } - - protected void setActionStateFromProjects(IAction action) { - IStructuredSelection sel = getStructuredSelection(); - boolean allOk = false; - if (sel != null && !sel.isEmpty()) { - allOk = true; - Iterator it = sel.iterator(); - while (it.hasNext()) { - Object o = it.next(); - IProject project = getProject(o); - if (project == null || !project.isOpen()) { - allOk = false; - break; - } - } - } - action.setEnabled(allOk); - } - - /** - * Returns the allowsMultiSelect. - * - * @return boolean - */ - public boolean allowsMultiSelect() { - return allowsMultiSelect; - } - - - /** - * Sets the allowsMultiSelect. - * - * @param allowsMultiSelect - * The allowsMultiSelect to set - */ - public void setAllowsMultiSelect(boolean allowsMultiSelect) { - this.allowsMultiSelect = allowsMultiSelect; - } - - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractActionWithDelegate.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractActionWithDelegate.java deleted file mode 100644 index 1dbce3ddc..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractActionWithDelegate.java +++ /dev/null @@ -1,69 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2003, 2004 IBM Corporation and others. 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: IBM Corporation - initial API and implementation - **************************************************************************************************/ -package org.eclipse.jst.j2ee.internal.actions; - - - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IActionDelegate; - - -public abstract class AbstractActionWithDelegate extends org.eclipse.ui.actions.SelectionListenerAction { - protected IActionDelegate delegate; - - /** - * EditModuleDependencyAction constructor comment. - * - * @param text - * java.lang.String - */ - public AbstractActionWithDelegate() { - super("");//$NON-NLS-1$ - initLabel(); - initDelegate(); - } - - protected abstract IActionDelegate createDelegate(); - - protected abstract String getLabel(); - - protected void initDelegate() { - delegate = createDelegate(); - } - - protected void initLabel() { - setText(getLabel()); - } - - /** - * Implementation of method defined on <code>IAction</code>. - */ - public void run() { - delegate.run(this); - } - - /** - * Updates this action in response to the given selection. - * <p> - * The <code>SelectionListenerAction</code> implementation of this method returns - * <code>true</code>. Subclasses may extend to react to selection changes; however, if the - * super method returns <code>false</code>, the overriding method must also return - * <code>false</code>. - * </p> - * - * @param selection - * the new selection - * @return <code>true</code> if the action should be enabled for this selection, and - * <code>false</code> otherwise - */ - protected boolean updateSelection(IStructuredSelection selection) { - delegate.selectionChanged(this, selection); - return this.isEnabled(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractOpenAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractOpenAction.java deleted file mode 100644 index f40852177..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractOpenAction.java +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.actions; - - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Event; -import org.eclipse.ui.IActionDelegate2; -import org.eclipse.ui.IEditorDescriptor; -import org.eclipse.ui.IEditorRegistry; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.SelectionListenerAction; - -/** - * Action for opening a J2EE resource from the J2EE navigator. - */ -public abstract class AbstractOpenAction extends SelectionListenerAction implements IActionDelegate2 { - // //$NON-NLS-1$ - protected IEditorDescriptor currentDescriptor; - protected Object srcObject; - - protected AbstractOpenAction(String text) { - super(text); - } - - protected static IEditorDescriptor findEditorDescriptor(String id) { - IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); - return registry.findEditor(id); - } - - protected void setAttributesFromDescriptor() { - if (currentDescriptor == null) - return; - //setText(currentDescriptor.getLabel()); - setToolTipText(currentDescriptor.getLabel()); - //setImageDescriptor(currentDescriptor.getImageDescriptor()); - } - - /** - * The structured selection has changed in the workbench. Subclasses should override this method - * to react to the change. Returns true if the action should be enabled for this selection, and - * false otherwise. - * - * When this method is overridden, the super method must always be invoked. If the super method - * returns false, this method must also return false. - * - * @param sel - * the new structured selection - */ - public boolean updateSelection(IStructuredSelection s) { - srcObject = null; - if (!super.updateSelection(s)) - return false; - - if (s.size() != 1) - return false; - - return true; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate2#dispose() - */ - public void dispose() { - //Dispose - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction) - */ - public void init(IAction action) { - //init - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, - * org.eclipse.swt.widgets.Event) - */ - public void runWithEvent(IAction action, Event event) { - runWithEvent(event); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction action) { - // TODO Auto-generated method stub - run(); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, - * org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - // TODO HACK! - updateSelection((IStructuredSelection) selection); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractOpenWizardAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractOpenWizardAction.java deleted file mode 100644 index d652982bd..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractOpenWizardAction.java +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.actions; - - -import java.util.Iterator; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWizard; -import org.eclipse.ui.activities.WorkbenchActivityHelper; - - -public abstract class AbstractOpenWizardAction extends org.eclipse.jface.action.Action { - // //$NON-NLS-1$ - - private IWorkbench fWorkbench; - - private Class[] fActivatedOnTypes; - - private boolean fAcceptEmptySelection; - - protected AbstractOpenWizardAction() { - //Default constructor - } - - public AbstractOpenWizardAction(IWorkbench workbench, String label, Class[] activatedOnTypes, boolean acceptEmptySelection) { - super(label); - fWorkbench = workbench; - fActivatedOnTypes = activatedOnTypes; - fAcceptEmptySelection = acceptEmptySelection; - } - - public AbstractOpenWizardAction(IWorkbench workbench, String label, boolean acceptEmptySelection) { - this(workbench, label, null, acceptEmptySelection); - } - - public boolean canActionBeAdded() { - ISelection selection = getCurrentSelection(); - if (selection == null || selection.isEmpty()) { - return fAcceptEmptySelection; - } - if (fActivatedOnTypes != null) { - if (selection instanceof IStructuredSelection) { - return isEnabled(((IStructuredSelection) selection).iterator()); - } - return false; - } - return true; - } - - /** - * Create the specific Wizard (to be implemented by a subclass) - */ - abstract protected Wizard createWizard(); - - protected IStructuredSelection getCurrentSelection() { - IWorkbenchWindow window = J2EEUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow(); - if (window != null) { - ISelection selection = window.getSelectionService().getSelection(); - if (selection instanceof IStructuredSelection) { - return (IStructuredSelection) selection; - } - - } - return null; - } - - protected IWorkbench getWorkbench() { - return fWorkbench; - } - - private boolean isEnabled(Iterator iter) { - while (iter.hasNext()) { - Object obj = iter.next(); - if (!isOfAcceptedType(obj) || !shouldAcceptElement(obj)) { - return false; - } - } - return true; - } - - private boolean isOfAcceptedType(Object obj) { - for (int i = 0; i < fActivatedOnTypes.length; i++) { - if (fActivatedOnTypes[i].isInstance(obj)) { - return true; - } - } - return false; - } - - protected String getDialogText() { - return J2EEUIMessages.getResourceString(J2EEUIMessages.NEW_LBL); - } - - /** - * The user has invoked this action. - */ - public void run() { - Wizard wizard = createWizard(); - if (wizard instanceof IWorkbenchWizard) { - IStructuredSelection sel = null; - if (null != getCurrentSelection()) - sel = getCurrentSelection(); - else - sel = new StructuredSelection(); - ((IWorkbenchWizard) wizard).init(J2EEUIPlugin.getDefault().getWorkbench(), sel); - } - if (WorkbenchActivityHelper.allowUseOf(null,wizard)) { - IWorkbenchWindow window = J2EEUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow(); - WizardDialog dialog = new WizardDialog(window.getShell(), wizard); - dialog.create(); - String text = getDialogText(); - if (null != text) { - dialog.getShell().setText(text); - } - dialog.open(); - } - } - - protected void setWorkbench(IWorkbench workbench) { - fWorkbench = workbench; - } - - /** - * can be overridden to add more checks obj is guaranteed to be instance of one of the accepted - * types - */ - protected boolean shouldAcceptElement(Object obj) { - return true; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractOpenWizardWorkbenchAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractOpenWizardWorkbenchAction.java deleted file mode 100644 index 5c7093697..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractOpenWizardWorkbenchAction.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.actions; - - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchWindow; - - -public abstract class AbstractOpenWizardWorkbenchAction extends AbstractOpenWizardAction implements org.eclipse.ui.IWorkbenchWindowActionDelegate { - protected AbstractOpenWizardWorkbenchAction() { - //Default - } - - public AbstractOpenWizardWorkbenchAction(IWorkbench workbench, String label, Class[] activatedOnTypes, boolean acceptEmptySelection) { - super(workbench, label, null, acceptEmptySelection); - } - - public AbstractOpenWizardWorkbenchAction(IWorkbench workbench, String label, boolean acceptEmptySelection) { - super(workbench, label, null, acceptEmptySelection); - } - - /** - * @see AbstractOpenWizardAction#dispose - */ - public void dispose() { - // do nothing. - setWorkbench(null); - } - - /** - * @see AbstractOpenWizardAction#init - */ - public void init(IWorkbenchWindow window) { - setWorkbench(window.getWorkbench()); - } - - /** - * @see IActionDelegate#run - */ - public void run(IAction action) { - run(); - } - - /** - * @see IActionDelegate#selectionChanged - */ - public void selectionChanged(IAction action, ISelection selection) { - // do nothing. Action doesn't depend on selection. - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/BaseAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/BaseAction.java deleted file mode 100644 index 635f84058..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/BaseAction.java +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Mar 27, 2003 - * - * To change this generated comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.jst.j2ee.internal.actions; - -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jst.j2ee.internal.plugin.ErrorDialog; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IActionDelegate; -import org.eclipse.ui.IWorkbenchWindow; - - -/** - * @author jsholl - * - * To change this generated comment go to Window>Preferences>Java>Code Generation>Code and Comments - */ -public abstract class BaseAction extends Action implements IActionDelegate { - - protected IStructuredSelection selection = null; - - protected IWorkbenchWindow getWorkbenchWindow() { - return J2EEUIPlugin.getPluginWorkbench().getActiveWorkbenchWindow(); - } - - public void setSelection(IStructuredSelection selection) { - this.selection = selection; - } - - public void run() { - Shell shell = getWorkbenchWindow().getShell(); - if (null == selection) { - ISelection autoselection = getWorkbenchWindow().getSelectionService().getSelection(); - if (autoselection instanceof IStructuredSelection) - this.selection = (IStructuredSelection) autoselection; - } - - try { - primRun(shell); - this.selection = null; - } catch (Throwable t) { - Logger.getLogger().logError(t); - String ERROR_OCCURRED_TITLE = J2EEUIMessages.getResourceString("ERROR_OCCURRED_TITLE"); //$NON-NLS-1$ - String ERROR_OCCURRED_MESSAGE = J2EEUIMessages.getResourceString("ERROR_OCCURRED_MESSAGE"); //$NON-NLS-1$ - ErrorDialog.openError(shell, ERROR_OCCURRED_TITLE, ERROR_OCCURRED_MESSAGE, t, 0, false); - } - - } - - protected abstract void primRun(Shell shell); - - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate2#dispose() - */ - public void dispose() { - //dispose - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction) - */ - public void init(IAction action) { - //init - } - - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, - * org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IAction action, ISelection aSelection) { - setSelection((IStructuredSelection) aSelection); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, - * org.eclipse.swt.widgets.Event) - */ - public void runWithEvent(IAction action, Event event) { - run(); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction action) { - run(); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/ComponentEditorInput.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/ComponentEditorInput.java deleted file mode 100644 index 61d93f458..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/ComponentEditorInput.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.actions; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IPersistableElement; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; - -public class ComponentEditorInput implements IEditorInput { - - private IVirtualComponent component; - - public ComponentEditorInput(IVirtualComponent component){ - this.component = component; - } - - public boolean exists() { - return component.exists(); - } - - public ImageDescriptor getImageDescriptor() { - return null; - } - - public String getName() { - return component.getName(); - } - - public IPersistableElement getPersistable() { - return null; - } - - public String getToolTipText() { - return ""; //$NON-NLS-1$ - } - - public Object getAdapter(Class adapter) { - return null; - } - - public IVirtualComponent getComponent(){ - return component; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/ForceClasspathUpdateAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/ForceClasspathUpdateAction.java deleted file mode 100644 index 0122ba5e5..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/ForceClasspathUpdateAction.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c)2006 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.actions; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathUpdater; -import org.eclipse.ui.IActionDelegate; - -public class ForceClasspathUpdateAction extends Action implements IActionDelegate{ - - private List projectsList = new ArrayList(); - - public void run() { - J2EEComponentClasspathUpdater.getInstance().forceUpdate(projectsList); - } - - public void run(IAction action) { - J2EEComponentClasspathUpdater.getInstance().forceUpdate(projectsList); - } - - public void selectionChanged(IAction action, ISelection selection) { - action.setEnabled(setSelection(selection)); - } - - private boolean setSelection(ISelection selection){ - projectsList.clear(); - if(selection != null && selection instanceof IStructuredSelection) { - IStructuredSelection structuredSelection = (IStructuredSelection)selection; - if (structuredSelection.size() > 0) { - Iterator iterator = structuredSelection.iterator(); - while(iterator.hasNext()){ - Object next = iterator.next(); - if (next instanceof IProject) { - projectsList.add(next); - } else { - projectsList.clear(); - return false; - } - } - } else { // empty selection - return false; - } - return true; - } - return false; - } - - - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/IJ2EEUIContextIds.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/IJ2EEUIContextIds.java deleted file mode 100644 index dcf94e928..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/IJ2EEUIContextIds.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.actions; - -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; - - -/** - * Insert the type's description here. Creation date: (9/6/2001 12:23:02 PM) - * - * @author: Administrator - */ -public interface IJ2EEUIContextIds { - // New creation wizards - public static final String NEW_EAR_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".EAR_NEW_EAR_WIZARD_PAGE1"; //$NON-NLS-1$ - public static final String NEW_EAR_ADD_MODULES_PAGE = J2EEUIPlugin.PLUGIN_ID + ".NEW_EAR_ADD_MODULES_PAGE"; //$NON-NLS-1$ - public static final String NEW_EAR_COMP_PAGE = J2EEUIPlugin.PLUGIN_ID + ".NEW_EAR_COMP_PAGE"; //$NON-NLS-1$ - public static final String EAR_NEW_MODULE_PROJECTS_PAGE = J2EEUIPlugin.PLUGIN_ID + ".EAR_NEW_MODULE_PROJECTS_PAGE"; //$NON-NLS-1$ - public static final String NEW_APPCLIENT_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".APPCLIENT_NEW_APPCLIENT_WIZARD_PAGE1"; //$NON-NLS-1$ - public static final String NEW_APPCLIENT_WIZARD_P3 = J2EEUIPlugin.PLUGIN_ID + ".APPCLIENT_NEW_APPCLIENT_WIZARD_PAGE3"; //$NON-NLS-1$ - public static final String NEW_EJB_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".EJB_NEW_EJB_WIZARD_PAGE1"; //$NON-NLS-1$ - public static final String NEW_EJB_WIZARD_P2 = J2EEUIPlugin.PLUGIN_ID + ".EJB_NEW_EJB_WIZARD_PAGE2"; //$NON-NLS-1$ - public static final String NEW_EJB_WIZARD_P3 = J2EEUIPlugin.PLUGIN_ID + ".EJB_NEW_EJB_WIZARD_PAGE3"; //$NON-NLS-1$ - public static final String NEW_CONNECTOR_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".JCA_NEWIZARD_PAGE1"; //$NON-NLS-1$ - public static final String NEW_CONNECTOR_WIZARD_P3 = J2EEUIPlugin.PLUGIN_ID + ".JCA_NEWIZARD_PAGE3"; //$NON-NLS-1$ - public static final String NEW_JAVA_COMPONENT_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".NEW_JAVA_COMPONENT_WIZARD_PAGE1"; //$NON-NLS-1$ - public static final String NEW_JAVA_CLASS_OPTION_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".NEW_JAVA_CLASS_OPTION_WIZARD_PAGE1"; //$NON-NLS-1$ - public static final String NEW_UTILITY_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".NEW_UTILITY_WIZARD_P1"; //$NON-NLS-1$ - public static final String NEW_UTILITY_WIZARD_P3 = J2EEUIPlugin.PLUGIN_ID + ".NEW_UTILITY_WIZARD_P3"; //$NON-NLS-1$ - - // Import, export wizards - public static final String IMPORT_EAR_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".EAR_IMPORT_EAR_WIZARD_PAGE1"; //$NON-NLS-1$ - public static final String IMPORT_EAR_WIZARD_P2 = J2EEUIPlugin.PLUGIN_ID + ".EAR_IMPORT_EAR_WIZARD_PAGE2"; //$NON-NLS-1$ - public static final String IMPORT_EAR_WIZARD_P3 = J2EEUIPlugin.PLUGIN_ID + ".EAR_IMPORT_EAR_WIZARD_PAGE3"; //$NON-NLS-1$ - public static final String IMPORT_APPCLIENT_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".APPCLIENT_IMPORT_APPCLIENT_WIZARD_PAGE1"; //$NON-NLS-1$ - public static final String IMPORT_EJB_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".EJB_IMPORT_EJB_WIZARD_PAGE1"; //$NON-NLS-1$ - public static final String IMPORT_RAR_WIZARD_PAGE = J2EEUIPlugin.PLUGIN_ID + ".IMPORT_RAR_WIZARD_PAGE"; //$NON-NLS-1$ - public static final String IMPORT_UTILITY_JAR_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".IMPORT_UTILITY_JAR_WIZARD_PAGE1"; //$NON-NLS-1$ - public static final String IMPORT_UTILITY_JAR_WIZARD_P2 = J2EEUIPlugin.PLUGIN_ID + ".IMPORT_UTILITY_JAR_WIZARD_PAGE2"; //$NON-NLS-1$ - public static final String IMPORT_CLASS_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".IMPORT_CLASS_WIZARD_PAGE1"; //$NON-NLS-1$ - public static final String IMPORT_CLASS_WIZARD_P2 = J2EEUIPlugin.PLUGIN_ID + ".IMPORT_CLASS_WIZARD_PAGE2"; //$NON-NLS-1$ - - public static final String EXPORT_EAR_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".EAR_EXPORT_PAGE1"; //$NON-NLS-1$ - public static final String EXPORT_APPCLIENT_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".APPCLIENT_EXPORT_APPCLIENT_WIZARD_PAGE1"; //$NON-NLS-1$ - public static final String EXPORT_EJB_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".EJB_EXPORT_PAGE1"; //$NON-NLS-1$ - public static final String EXPORT_RAR_WIZARD_PAGE = J2EEUIPlugin.PLUGIN_ID + ".EXPORT_RAR_WIZARD_PAGE"; //$NON-NLS-1$ - - // dialogs - public static final String DELEATE_EAR_DIALOG_1 = J2EEUIPlugin.PLUGIN_ID + ".navm2000"; //$NON-NLS-1$ - public static final String DELEATE_MODULE_DIALOG_1 = J2EEUIPlugin.PLUGIN_ID + ".navm2010"; //$NON-NLS-1$ - public static final String RENAME_EAR_DIALOG_1 = J2EEUIPlugin.PLUGIN_ID + ".navm3000"; //$NON-NLS-1$ - public static final String RENAME_MODULE_DIALOG_1 = J2EEUIPlugin.PLUGIN_ID + ".navm3010"; //$NON-NLS-1$ - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/ImportClassesAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/ImportClassesAction.java deleted file mode 100644 index abff48694..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/ImportClassesAction.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Mar 31, 2003 - * - * To change this generated comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.jst.j2ee.internal.actions; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.wizard.ClassesImportWizard; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; - -/** - * @author jsholl - * - * To change this generated comment go to Window>Preferences>Java>Code Generation>Code and Comments - */ -public class ImportClassesAction extends WTPBaseAction { - - public static String LABEL = J2EEUIMessages.getResourceString("Import_Classes"); //$NON-NLS-1$ - - public ImportClassesAction() { - super(); - setText(LABEL); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.common.actions.BaseAction#primRun(org.eclipse.swt.widgets.Shell) - */ - protected void primRun(Shell shell) { - IProject project = ProjectUtilities.getProject(getSelection().getFirstElement()); - ClassesImportWizard wizard = new ClassesImportWizard(project); - - - wizard.init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY); - wizard.setDialogSettings(J2EEUIPlugin.getDefault().getDialogSettings()); - - WizardDialog dialog = new WizardDialog(shell, wizard); - - dialog.create(); - dialog.getShell().setSize(550, 550); - dialog.open(); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEDeleteAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEDeleteAction.java deleted file mode 100644 index 6697cf6d0..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEDeleteAction.java +++ /dev/null @@ -1,421 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.actions; - - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.ui.actions.SelectionDispatchAction; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.window.Window; -import org.eclipse.jst.j2ee.application.Application; -import org.eclipse.jst.j2ee.common.internal.util.CommonUtil; -import org.eclipse.jst.j2ee.ejb.componentcore.util.EJBArtifactEdit; -import org.eclipse.jst.j2ee.internal.delete.DeleteOptions; -import org.eclipse.jst.j2ee.internal.dialogs.DeleteEARDialog; -import org.eclipse.jst.j2ee.internal.dialogs.DeleteModuleDialog; -import org.eclipse.jst.j2ee.internal.dialogs.J2EEDeleteDialog; -import org.eclipse.jst.j2ee.internal.dialogs.J2EEDeleteUIConstants; -import org.eclipse.jst.j2ee.internal.plugin.CommonEditorUtility; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchSite; -import org.eclipse.ui.actions.DeleteResourceAction; -import org.eclipse.ui.actions.SelectionListenerAction; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; - -public class J2EEDeleteAction extends SelectionDispatchAction implements J2EEDeleteUIConstants { - - protected Shell shell; - //Used for EAR delete - protected Set referencedProjects; - protected List projects; - protected DeleteOptions options; - // added for IRefactoringAction behavior - protected ISelectionProvider provider = null; - - - - /** - * Constructor for DeleteModuleAction. - * - * @param text - */ - public J2EEDeleteAction(IWorkbenchSite site, Shell parent) { - super(site); - setText(DELETE); - shell = parent; - } - - public J2EEDeleteAction(IWorkbenchSite site, ISelectionProvider newProvider) { - super(site); - setText(DELETE); - shell = J2EEUIPlugin.getActiveWorkbenchWindow().getShell(); - provider = newProvider; - } - - protected void reset() { - referencedProjects = null; - projects = null; - options = null; - } - - protected boolean getEnableStateBasedOnSelection(IStructuredSelection selection) { - if (selection.isEmpty()) - return false; - return isSelectionApplicable() && isSelectionSomeJ2EE(); - } - - /** - * @see SelectionListenerAction#updateSelection(IStructuredSelection) - */ - protected void updateSelection(IStructuredSelection selection) { - update(selection); - } - - protected boolean isSelectionApplicable() { - IStructuredSelection sel = (StructuredSelection) getSelection(); - Iterator it = sel.iterator(); - while (it.hasNext()) { - Object o = it.next(); - if (!isJ2EEModule(o) && !isApplication(o) && !isProjectOrJavaProject(o)) - return false; - } - return true; - } - - protected boolean isSelectionSomeJ2EE() { - IStructuredSelection sel = (StructuredSelection) getSelection(); - Iterator it = sel.iterator(); - while (it.hasNext()) { - Object o = it.next(); - if (isJ2EEModule(o) || isApplication(o)) - return true; - } - return false; - } - - - protected boolean isSelectionAllDDRoots() { - IStructuredSelection sel = (StructuredSelection) getSelection(); - Iterator it = sel.iterator(); - while (it.hasNext()) { - Object o = it.next(); - if (!isJ2EEModule(o)) - return false; - } - return true; - } - - protected boolean isSelectionAllApplications() { - IStructuredSelection sel = (StructuredSelection) getSelection(); - Iterator it = sel.iterator(); - while (it.hasNext()) { - Object o = it.next(); - if (!isApplication(o)) - return false; - } - return true; - } - - protected boolean isJ2EEModule(Object o) { - //TODO switch to virtual comp -// if (o instanceof WorkbenchComponent) { -// WorkbenchComponent module = (WorkbenchComponent) o; -// String moduleType = module.getComponentType().getComponentTypeId(); -// //TODO need to add connector, app client, ear, ejb client -// return moduleType.equals(IModuleConstants.JST_WEB_MODULE) || moduleType.equals(IModuleConstants.JST_EJB_MODULE); -// } - return CommonUtil.isDeploymentDescriptorRoot(o, false); - } - - protected boolean isApplication(Object o) { - return (o instanceof Application) || isJ2EEApplicationProject(o); - } - - protected boolean isProjectOrJavaProject(Object o) { - return (o instanceof IProject) || (o instanceof IJavaProject); - } - - protected List getProjects() { - if (projects == null) { - projects = new ArrayList(); - IStructuredSelection sel = (StructuredSelection) getSelection(); - Iterator iterator = sel.iterator(); - IProject project = null; - Object o = null; - while (iterator.hasNext()) { - o = iterator.next(); - if (o instanceof IJavaProject) - o = ((IJavaProject) o).getProject(); - if (o instanceof IProject) { - projects.add(o); - addEJBClientProjectIfNecessary((IProject) o, projects); - } else if (o instanceof EObject) { - EObject obj = (EObject) o; - project = ProjectUtilities.getProject(obj); - if (project == null) - throw new RuntimeException(J2EEUIMessages.getResourceString("Project_should_not_be_null_1_EXC_")); //$NON-NLS-1$ - projects.add(project); - addEJBClientProjectIfNecessary(project, projects); - } else { - throw new RuntimeException(J2EEUIMessages.getResourceString("Non-project_in_selection_2_EXC_")); //$NON-NLS-1$ - } - } - } - return projects; - } - - /** - * @param project - * @param localProjects - */ - private void addEJBClientProjectIfNecessary(IProject project, List localProjects) { - IVirtualComponent comp = ComponentCore.createComponent(project); - EJBArtifactEdit edit = EJBArtifactEdit.getEJBArtifactEditForRead(comp); - if (edit != null && edit.hasEJBClientJARProject()) - localProjects.add(edit.getEJBClientJarModule().getProject()); - } - - /** - * @see IAction#run() - */ - public void run() { - try { - J2EEDeleteDialog dlg = null; - if (isSelectionAllApplications()) - dlg = new DeleteEARDialog(shell, getReferencedProjects()); - else if (isSelectionAllDDRoots()) - dlg = new DeleteModuleDialog(shell); - else { - if (confirmStandardDelete()) - runResourceDeleteAction(); - return; - } - - dlg.open(); - if (dlg.getReturnCode() == Window.CANCEL) - return; - options = dlg.getDeleteOptions(); - if (options != null) - options.setSelectedProjects(getProjects()); - else - return; - if (!(ensureEditorsSaved() && validateState())) - return; - deleteProjectsIfNecessary(); - deleteMetadataIfNecessary(); - presentStatusIfNeccessary(); - } finally { - reset(); - } - } - - private boolean ensureEditorsSaved() { - return CommonEditorUtility.promptToSaveAllDirtyEditors(); - } - - protected boolean confirmStandardDelete() { - return MessageDialog.openConfirm(shell, DELETE_PROJECTS, CUSTOM_DELETE_MIX_MATCH); - } - - protected Set getReferencedProjects() { - if (referencedProjects == null) - computeReferencedProjects(); - return referencedProjects; - } - - protected void computeReferencedProjects() { - //TODO fix up to use components -// getProjects(); -// referencedProjects = new HashSet(); -// for (int i = 0; i < projects.size(); i++) { -// IProject project = (IProject) projects.get(i); -// EARNatureRuntime runtime = EARNatureRuntime.getRuntime(project); -// if (runtime == null) -// continue; -// EAREditModel editModel = runtime.getEarEditModelForRead(this); -// try { -// referencedProjects.addAll(editModel.getModuleMappedProjects()); -// } finally { -// editModel.releaseAccess(this); -// } -// } - } - -// protected DeleteModuleOperation getDeleteModuleOperation() { -// if (deleteModuleOperation == null) -// deleteModuleOperation = new DeleteModuleOperation(options); -// return deleteModuleOperation; -// } - - protected void deleteMetadataIfNecessary() { - if (!shouldDeleteMetaData()) - return; - -// IRunnableWithProgress runnable = WTPUIPlugin.getRunnableWithProgress(getDeleteModuleOperation()); -// ProgressMonitorDialog monitorDialog = new ProgressMonitorDialog(shell); -// -// try { -// monitorDialog.run(false, false, runnable); -// } catch (InvocationTargetException e) { -// handleException(e); -// } catch (InterruptedException e) { -// //Ignore -// } - } - - protected boolean shouldDeleteMetaData() { - if (deleteProjectsFailedOrCancelled()) - return false; - return primShouldDeleteMetaData(); - } - - protected boolean primShouldDeleteMetaData() { - return options != null && (options.shouldDeleteModules() || options.shouldDeleteModuleDependencies()); - } - - protected boolean deleteProjectsFailedOrCancelled() { - if (options == null || !options.shouldDeleteProjects()) - return false; - return deletedProjectsExist(); - } - - protected boolean deletedProjectsExist() { - List deletedProjects = options.getAllProjectsToDelete(); - for (int i = 0; i < deletedProjects.size(); i++) { - IProject project = (IProject) deletedProjects.get(i); - if (project.exists()) - return true; - } - return false; - } - - protected void deleteProjectsIfNecessary() { - if (options.shouldDeleteProjects()) - runResourceDeleteAction(); - } - - protected void runResourceDeleteAction() { - DeleteResourceAction action = new DeleteResourceAction(shell); - List localProjects = null; - if (options == null) - localProjects = getProjects(); - else - localProjects = options.getAllProjectsToDelete(); - Iterator it = localProjects.iterator(); - while (it.hasNext()) { - IProject p = (IProject) it.next(); - if (!p.exists()) - it.remove(); - } - IStructuredSelection sel = new StructuredSelection(localProjects); - action.selectionChanged(sel); - action.run(); - } - - public void handleException(InvocationTargetException e) { - Logger.getLogger().logError(e); - IStatus status = J2EEPlugin.newErrorStatus(IStatus.ERROR, DELETE_ERROR, e); - ErrorDialog.openError(shell, DELETE_ERROR, DELETE_NOT_COMPLETED, status); - } - - /** - * Update the action's enable state according to the current selection of the used selection - * provider. - */ - public void update() { - IStructuredSelection selection = null; - - if (provider != null) { - selection = (IStructuredSelection) provider.getSelection(); - selectionChanged((ISelection) selection); - } else { - selection = (IStructuredSelection) getSelection(); - - if (selection == null) { - setEnabled(false); - } else { - updateSelection(selection); - } - } - } - - protected boolean isJ2EEApplicationProject(Object o) { - if (o instanceof IProject) { - IProject project = (IProject) o; - if (J2EEProjectUtilities.isEARProject(project)) - return true; - } - return false; - } - - protected void setEnabledFromSelection(IStructuredSelection selection) { - if (selection == null) { - setEnabled(false); - } else { - setEnabled(getEnableStateBasedOnSelection(selection)); - } - } - - /** - * @see SelectionDispatchAction#selectionChanged(ISelection) - */ - public void selectionChanged(ISelection selection) { - if (selection instanceof IStructuredSelection) - setEnabledFromSelection((IStructuredSelection) selection); - else - super.selectionChanged(selection); - } - - protected boolean validateState() { - // TODO Fix validateState - // if (!primShouldDeleteMetaData()) - // return true; - // - // IValidateEditListener listener = new ValidateEditListener(null, - // getDeleteModuleOperation().getDeleteEditModel()); - // listener.setShell(shell); - // return listener.validateState().isOK(); - return true; - } - - protected void presentStatusIfNeccessary() { - IStatus status = null; -// if (deleteModuleOperation != null) -// status = deleteModuleOperation.getStatus(); - - if (status == null || status.isOK()) - return; - - ErrorDialog.openError(shell, null, null, status, IStatus.ERROR); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEDeleteModuleActionPopulator.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEDeleteModuleActionPopulator.java deleted file mode 100644 index 97d00f3d1..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEDeleteModuleActionPopulator.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Jun 16, 2004 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package org.eclipse.jst.j2ee.internal.actions; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IWorkbenchSite; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -/** - * @author mdelder - * - * TODO To change the template for this generated type comment go to Window - Preferences - Java - - * Code Style - Code Templates - */ -public class J2EEDeleteModuleActionPopulator {//implements WTPOperationDataModelUICreator { - - - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.operation.extension.ui.WTPOperationDataModelUICreator#createDataModel(java.lang.String, - * java.lang.String, org.eclipse.jface.viewers.IStructuredSelection, - * org.eclipse.ui.IWorkbenchSite) - */ - public IDataModel createDataModel(String extendedOperationId, String operationClass, IStructuredSelection selection, IWorkbenchSite site) { - //TODO fix up -// J2EEDeleteAction deleteAction = new J2EEDeleteAction(site, (ISelectionProvider) null); -// WTPOperationDataModel dataModel = IActionWTPOperationDataModel.createDataModel(deleteAction, selection, site.getSelectionProvider(), site.getShell()); -// return dataModel; - return null; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEDeployAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEDeployAction.java deleted file mode 100644 index 2814cd35e..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEDeployAction.java +++ /dev/null @@ -1,182 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Mar 30, 2004 - * - * To change the template for this generated file go to - * Window - Preferences - Java - Code Generation - Code and Comments - */ -package org.eclipse.jst.j2ee.internal.actions; - -import java.text.MessageFormat; -import java.util.List; - -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.emf.ecore.EObject; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jst.j2ee.componentcore.EnterpriseArtifactEdit; -import org.eclipse.jst.j2ee.internal.deploy.DeployerRegistry; -import org.eclipse.jst.j2ee.internal.deploy.J2EEDeployOperation; -import org.eclipse.jst.j2ee.internal.dialogs.RuntimeSelectionDialog; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.frameworks.internal.WTPResourceHandler; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; -import org.eclipse.wst.server.core.IRuntime; - -/** - * @author cbridgha - * - * To change the template for this generated type comment go to Window - Preferences - Java - Code - * Generation - Code and Comments - */ -public class J2EEDeployAction extends BaseAction { - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.ui.actions.BaseAction#primRun(org.eclipse.swt.widgets.Shell) - */ - protected void primRun(Shell shell) { - - if (checkEnabled(shell)) { - final IStructuredSelection deploySelection = selection; - Job deployJob = new Job("Deploy") { - protected IStatus run(IProgressMonitor monitor) { - IStatus result = null; - J2EEDeployOperation op = new J2EEDeployOperation(deploySelection.toArray()); - try { - result = op.execute(monitor, null); - } catch (Exception e) { - result = new Status(IStatus.ERROR, WTPCommonPlugin.PLUGIN_ID, IStatus.ERROR, WTPResourceHandler.getString("27"), e); //$NON-NLS-1$ - Logger.getLogger().logError(e); - } finally { - - } - return result; - } - }; - - - try { - deployJob.setUser(true); - deployJob.schedule(); - } catch (Exception e) { - //Ignore - } - - } - - } - - /* - * - */ - public J2EEDeployAction() { - super(); - // TODO Auto-generated constructor stub - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, - * org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IAction action, ISelection aSelection) { - super.selectionChanged(action, aSelection); - action.setEnabled(true); - } - - - public boolean checkEnabled(Shell shell) { - try { - DeployerRegistry reg = DeployerRegistry.instance(); - Object[] modules = selection.toArray(); - for (int i = 0; i < modules.length; i++) { - Object object = modules[i]; - if (object instanceof EObject) { - object = ProjectUtilities.getProject(object); - } - if (!(object instanceof IProject)) { - continue; - } - IVirtualComponent component = ComponentCore.createComponent((IProject) object); - EnterpriseArtifactEdit edit = null; - try { - edit = (EnterpriseArtifactEdit) ComponentUtilities.getArtifactEditForRead(component); - if (edit == null) - continue; - EObject module = edit.getDeploymentDescriptorRoot(); - IProject proj = (IProject) object; - if (proj == null) { - displayMessageDialog(J2EEUIMessages.getResourceString("DEPLOY_PROJECT_NOT_FOUND"), shell); - return false; - } - IRuntime runtime = J2EEProjectUtilities.getServerRuntime(proj); - if (runtime == null) { - String message = MessageFormat.format(J2EEUIMessages.getResourceString("DEPLOY_RUNTIME_NOT_FOUND"), new String[] { proj.getName() }); - RuntimeSelectionDialog selectionDialog = new RuntimeSelectionDialog( shell, - J2EEUIMessages.getResourceString("DEPLOY_DIALOG_TITLE"), - null /* default image */, message, - MessageDialog.ERROR, - new String[] { IDialogConstants.OK_LABEL }, 0, proj); - selectionDialog.open(); - runtime = J2EEProjectUtilities.getServerRuntime(proj); - if (runtime == null) - return false; - } - List visitors = reg.getDeployModuleExtensions(module, runtime); - if (visitors.isEmpty()) { - displayMessageDialog( MessageFormat.format( J2EEUIMessages.getResourceString("DEPLOY_PROJECT_NOT_SUPPORTED"), - new String[] { proj.getName() }), shell); - return false; - } - } finally { - if (edit != null) - edit.dispose(); - } - } - return true; - } catch (CoreException e) { - J2EEPlugin.log(4, -1, "Deploy Action recovering from problem verifying enablement.", e); //$NON-NLS-1$ - e.printStackTrace(); - } - return false; - } - - private void displayMessageDialog(String message, Shell shell) { - String title = J2EEUIMessages.getResourceString("DEPLOY_DIALOG_TITLE"); - MessageDialog dialog = new MessageDialog(shell, - title, - null /* default image */, - message, - MessageDialog.ERROR, - new String[] { IDialogConstants.OK_LABEL }, 0) ; - dialog.open(); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEModuleRenameChange.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEModuleRenameChange.java deleted file mode 100644 index da682a432..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEModuleRenameChange.java +++ /dev/null @@ -1,150 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Sep 26, 2004 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package org.eclipse.jst.j2ee.internal.actions; - - -import java.util.Collections; - -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.OperationCanceledException; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.j2ee.internal.dialogs.J2EERenameUIConstants; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.rename.RenameOptions; -import org.eclipse.jst.j2ee.web.componentcore.util.WebArtifactEdit; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; - - -/** - * - * TODO To change the template for this generated type comment go to Window - Preferences - Java - - * Code Style - Code Templates - */ -public class J2EEModuleRenameChange extends Change { - - private String newName; - private IProject target; - private boolean renameDependencies; - - public J2EEModuleRenameChange(IProject target, String newName, boolean renameDependencies) { - this.target = target; - this.newName = newName; - this.renameDependencies = renameDependencies; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ltk.core.refactoring.Change#getName() - */ - public String getName() { - return J2EERenameUIConstants.RENAME_MODULES; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ltk.core.refactoring.Change#initializeValidationData(org.eclipse.core.runtime.IProgressMonitor) - */ - public void initializeValidationData(IProgressMonitor pm) { - //Do nothing - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ltk.core.refactoring.Change#isValid(org.eclipse.core.runtime.IProgressMonitor) - */ - public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException { - if (target != null) - return RefactoringStatus.create(Status.OK_STATUS); - return RefactoringStatus.create(new Status(IStatus.ERROR, J2EEUIPlugin.PLUGIN_ID, 0, "", null)); //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ltk.core.refactoring.Change#perform(org.eclipse.core.runtime.IProgressMonitor) - */ - public Change perform(IProgressMonitor pm) throws CoreException { -// try { - -// RenameModuleOperation renameOp = new RenameModuleOperation(getRenameOptions()); -// renameOp.run(pm); - - //String contextRoot = getServerContextRoot(); - // TODO fix up rename and context root operations - //if (webNature != null) { - //new UpdateWebContextRootMetadataOperation(newTarget, webNature.getContextRoot()).run(pm); -// if(contextRoot.equals("") == false){ //$NON-NLS-1$ -// new UpdateWebContextRootMetadataOperation(target, contextRoot).run(pm); -// } else if (J2EENature.getRegisteredRuntime(target) == null) -// new RenameUtilityJarMetadataOperation(target, newTarget).run(pm); -// } catch (InvocationTargetException e) { -// //Ignore -// } catch (InterruptedException e) { -// //Ignore -// } - return null; - } - - protected String getServerContextRoot() { - WebArtifactEdit webEdit = null; - try{ - webEdit = WebArtifactEdit.getWebArtifactEditForRead(target); - if (webEdit != null) - return webEdit.getServerContextRoot(); - } finally { - if (webEdit != null ) - webEdit.dispose(); - } - return ""; //$NON-NLS-1$ - } - - /** - * @return - */ - /**@deprecated - * If this method is not used it should be removed at a later time, marking as deprecated - * Warning cleanup 12/07/2005 - */ - private RenameOptions getRenameOptions() { - RenameOptions options = new RenameOptions(); - options.setNewName(this.newName); - options.setSelectedProjects(Collections.singletonList(this.target)); - // TODO check module type for EAR type - //options.setIsEARRename(EARNatureRuntime.getRuntime(this.target) != null); - options.setRenameModuleDependencies(this.renameDependencies); - options.setRenameModules(true); - options.setRenameProjects(false); - return options; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ltk.core.refactoring.Change#getModifiedElement() - */ - public Object getModifiedElement() { - return null; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EERenameAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EERenameAction.java deleted file mode 100644 index b5f6df41b..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EERenameAction.java +++ /dev/null @@ -1,393 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.actions; - - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jdt.ui.actions.SelectionDispatchAction; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.window.Window; -import org.eclipse.jst.j2ee.application.Application; -import org.eclipse.jst.j2ee.common.internal.util.CommonUtil; -import org.eclipse.jst.j2ee.internal.dialogs.J2EERenameDialog; -import org.eclipse.jst.j2ee.internal.dialogs.J2EERenameUIConstants; -import org.eclipse.jst.j2ee.internal.dialogs.RenameModuleDialog; -import org.eclipse.jst.j2ee.internal.plugin.CommonEditorUtility; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.internal.rename.RenameOptions; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchSite; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.RenameResourceAction; -import org.eclipse.ui.actions.SelectionListenerAction; -import org.eclipse.wst.common.componentcore.UnresolveableURIException; -import org.eclipse.wst.common.componentcore.internal.ComponentResource; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; - -public class J2EERenameAction extends SelectionDispatchAction implements J2EERenameUIConstants { - - protected Shell shell; - //Used for EAR rename - protected Set referencedProjects; - protected List modules; - protected RenameOptions options; - // added for IRefactoringAction behavior - protected ISelectionProvider provider = null; -// protected RenameModuleOperation renameModuleOperation = null; - - /** - * Constructor for RenameModuleAction. - * - * @param text - */ - public J2EERenameAction(IWorkbenchSite site, Shell parent) { - super(site); - setText(RENAME); - shell = parent; - } - - public J2EERenameAction(IWorkbenchSite site, ISelectionProvider newProvider) { - super(site); - setText(RENAME); - shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); - provider = newProvider; - } - - protected void reset() { -// if (renameModuleOperation != null) { -// renameModuleOperation.release(); -// renameModuleOperation = null; -// } - referencedProjects = null; - modules = null; - options = null; - } - - /** - * @see SelectionListenerAction#updateSelection(IStructuredSelection) - */ - protected void updateSelection(IStructuredSelection selection) { - super.update(selection); - } - - /** - * @see SelectionDispatchAction#selectionChanged(ISelection) - */ - public void selectionChanged(ISelection selection) { - if (selection instanceof IStructuredSelection) - setEnabledFromSelection((IStructuredSelection) selection); - else - super.selectionChanged(selection); - } - - protected void setEnabledFromSelection(IStructuredSelection selection) { - if (selection == null) { - setEnabled(false); - } else { - if (selection.toList().size() != 1) { - setEnabled(false); - } else { - setEnabled(getEnableStateBasedOnSelection(selection)); - } - } - } - - protected boolean getEnableStateBasedOnSelection(IStructuredSelection selection) { - if (selection.isEmpty()) - return false; - return isSelectionAllDDRoots() || isSelectionAllApplications(); - } - - protected boolean isSelectionAllDDRoots() { - IStructuredSelection sel = (StructuredSelection) getSelection(); - Iterator it = sel.iterator(); - while (it.hasNext()) { - Object o = it.next(); - //TODO check for j2ee workbench module selection - if (!CommonUtil.isDeploymentDescriptorRoot(o, false) /*&& !isJ2EEProject(o)*/) - return false; - } - return true; - } - - protected boolean isSelectionAllApplications() { - IStructuredSelection sel = (StructuredSelection) getSelection(); - Iterator it = sel.iterator(); - while (it.hasNext()) { - Object o = it.next(); - if (!(o instanceof Application) && !isJ2EEApplicationProject(o)) - return false; - } - return true; - } - - - protected List getModules() { - if (modules == null) { - modules = new ArrayList(); - IStructuredSelection sel = (StructuredSelection) getSelection(); - Iterator iterator = sel.iterator(); - WorkbenchComponent module = null; - Object o = null; - while (iterator.hasNext()) { - o = iterator.next(); - if (o instanceof WorkbenchComponent) { - modules.add(o); - } else if (o instanceof EObject) { - EObject obj = (EObject) o; - IProject project = ProjectUtilities.getProject(obj); - StructureEdit moduleCore = null; - try { - moduleCore = StructureEdit.getStructureEditForRead(project); - URI uri = obj.eResource().getURI(); - ComponentResource[] resources = moduleCore.findResourcesBySourcePath(uri); - for (int i=0; i<resources.length; i++) { - module = resources[i].getComponent(); - if (module !=null) - break; - } - if (module == null) - throw new RuntimeException(J2EEUIMessages.getResourceString("Project_should_not_be_null_1_ERROR_")); //$NON-NLS-1$ - modules.add(module); - } catch (UnresolveableURIException e) { - //Ignore - } finally { - if (moduleCore !=null) - moduleCore.dispose(); - } - } else { - throw new RuntimeException(J2EEUIMessages.getResourceString("Non-project_in_selection_2_ERROR_")); //$NON-NLS-1$ - } - } - } - return modules; - } - - /** - * @see IAction#run() - */ - public void run() { - try { - List localModules = getModules(); - if (localModules.size() != 1) - return; - WorkbenchComponent module = (WorkbenchComponent) localModules.get(0); - J2EERenameDialog dlg = null; - - // if all we are doing is renaming an EAR, let the base platform do it - if (isSelectionAllApplications()) { - RenameResourceAction action = new RenameResourceAction(shell); - action.selectionChanged(new StructuredSelection(module)); - action.run(); - } else { - String contextRoot = ""; //$NON-NLS-1$ - //TODO add context root to the module model - //contextRoot = module.getServerContextRoot(); - dlg = new RenameModuleDialog(shell, module.getName(), contextRoot); - dlg.open(); - if (dlg.getReturnCode() == Window.CANCEL) - return; - - options = dlg.getRenameOptions(); - if (options != null) - options.setSelectedProjects(localModules); - - if (!(ensureEditorsSaved() && validateState())) - return; - renameProjectsIfNecessary(); - renameMetadataIfNecessary(); - presentStatusIfNeccessary(); - } - } finally { - reset(); - } - } - - - private boolean ensureEditorsSaved() { - return CommonEditorUtility.promptToSaveAllDirtyEditors(); - } - - protected Set getReferencedProjects() { - if (referencedProjects == null) - computeReferencedProjects(); - return referencedProjects; - } - - protected void computeReferencedProjects() { - getModules(); - referencedProjects = new HashSet(); - for (int i = 0; i < modules.size(); i++) { - //WorkbenchComponent module = (WorkbenchComponent) modules.get(i); - //TODO fix up code here for modules instead of projects -// EARNatureRuntime runtime = EARNatureRuntime.getRuntime(project); -// if (runtime == null) -// continue; -// EAREditModel editModel = runtime.getEarEditModelForRead(this); -// try { -// referencedProjects.addAll(editModel.getModuleMappedProjects()); -// } finally { -// editModel.releaseAccess(this); -// } - } - } - - protected void renameMetadataIfNecessary() { - if (!shouldRenameMetaData()) - return; -// RenameModuleOperation op = getRenameModuleOperation(); -// IRunnableWithProgress runnable = WTPUIPlugin.getRunnableWithProgress(op); -// ProgressMonitorDialog monitorDialog = new ProgressMonitorDialog(shell); -// -// try { -// monitorDialog.run(false, false, runnable); -// } catch (InvocationTargetException e) { -// handleException(e); -// } catch (InterruptedException e) { -// //Ignore -// } - } - - protected boolean shouldRenameMetaData() { - if (renameProjectsFailedOrCancelled()) - return false; - - return primShouldRenameMetaData(); - } - - protected boolean renameProjectsFailedOrCancelled() { - if (options == null || !options.shouldRenameProjects()) - return false; - return renamedProjectsExist(); - } - - protected boolean renamedProjectsExist() { - List renamedProjects = options.getAllProjectsToRename(); - for (int i = 0; i < renamedProjects.size(); i++) { - IProject project = (IProject) renamedProjects.get(i); - if (project.exists()) - return true; - } - return false; - } - - protected void renameProjectsIfNecessary() { - if (options == null || !options.shouldRenameProjects()) - return; - J2EERenameResourceAction action = new J2EERenameResourceAction(shell); - action.setNewName(options.getNewName()); - IStructuredSelection sel = new StructuredSelection(options.getAllProjectsToRename()); - action.selectionChanged(sel); - action.run(); - - // only web projects should have a context root - String newContextRoot = options.getNewContextRoot(); - if (newContextRoot != null && options.shouldRenameProjects()) { - //WorkbenchComponent module = (WorkbenchComponent) getModules().get(0); - try { - // TODO add server context root to the module model - //module.setServerContextRoot(newContextRoot); - } catch (Throwable t) { - //Ignore - } - } - } - - public void handleException(InvocationTargetException e) { - Logger.getLogger().logError(e); - IStatus status = J2EEPlugin.newErrorStatus(IStatus.ERROR, RENAME_ERROR, e); - ErrorDialog.openError(shell, RENAME_ERROR, RENAME_NOT_COMPLETED, status); - } - - /** - * Update the action's enable state according to the current selection of the used selection - * provider. - */ - public void update() { - IStructuredSelection selection = null; - - if (provider != null) { - selection = (IStructuredSelection) provider.getSelection(); - super.update(selection); - } else { - selection = (IStructuredSelection) getSelection(); - - if (selection == null) { - setEnabled(false); - } else { - updateSelection(selection); - } - } - } - - protected boolean isJ2EEApplicationProject(Object o) { - if (o instanceof IProject) { - IProject project = (IProject) o; - if (J2EEProjectUtilities.isEARProject(project)) - return true; - } - return false; - } - - protected boolean validateState() { - if (!primShouldRenameMetaData()) - return true; - -// IValidateEditListener listener = new ValidateEditListener(null, getRenameModuleOperation().getRenameEditModel()); -// listener.setShell(shell); -// return listener.validateState().isOK(); - return false; - } - - protected boolean primShouldRenameMetaData() { - return options != null && (options.shouldRenameModules() || options.shouldRenameModuleDependencies()); - } - -// protected RenameModuleOperation getRenameModuleOperation() { -// if (renameModuleOperation == null) { -// renameModuleOperation = new RenameModuleOperation(options); -// } -// return renameModuleOperation; -// } - - protected void presentStatusIfNeccessary() { - IStatus status = null; - -// if (renameModuleOperation != null) { -// status = renameModuleOperation.getStatus(); -// } - - if (status == null || status.isOK()) - return; - - ErrorDialog.openError(shell, null, null, status, IStatus.ERROR); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EERenameParticipant.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EERenameParticipant.java deleted file mode 100644 index e52b7c605..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EERenameParticipant.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Sep 26, 2004 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package org.eclipse.jst.j2ee.internal.actions; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.j2ee.internal.dialogs.J2EERenameUIConstants; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; -import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext; -import org.eclipse.ltk.core.refactoring.participants.RenameParticipant; -import org.eclipse.wst.common.frameworks.internal.AdaptabilityUtility; - - -/** - * TODO To change the template for this generated type comment go to Window - Preferences - Java - - * Code Style - Code Templates - */ -public class J2EERenameParticipant extends RenameParticipant { - - private static final Class IPROJECT_CLASS = IProject.class; - - public J2EERenameParticipant() { - super(); - // TODO Auto-generated constructor stub - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#initialize(java.lang.Object) - */ - protected boolean initialize(Object element) { - if (element == null) - return false; - - IProject project = (IProject) AdaptabilityUtility.getAdapter(element, IPROJECT_CLASS); - if (project.isAccessible()) { - return true; - } - return false; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor) - */ - public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException { - Object[] targetElements = getProcessor().getElements(); - if (targetElements == null || targetElements.length != 1) - return null; - IProject project = (IProject) AdaptabilityUtility.getAdapter(targetElements[0], IPROJECT_CLASS); - - if (project != null) - return new J2EEModuleRenameChange(project, getArguments().getNewName(), getArguments().getUpdateReferences()); - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#getName() - */ - public String getName() { - return J2EERenameUIConstants.RENAME; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#checkConditions(org.eclipse.core.runtime.IProgressMonitor, - * org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext) - */ - public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) throws OperationCanceledException { - return RefactoringStatus.create(Status.OK_STATUS); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EERenameResourceAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EERenameResourceAction.java deleted file mode 100644 index f927e1cac..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EERenameResourceAction.java +++ /dev/null @@ -1,67 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2003, 2004 IBM Corporation and others. 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: IBM Corporation - initial API and implementation - **************************************************************************************************/ -package org.eclipse.jst.j2ee.internal.actions; - - -import org.eclipse.core.resources.IResource; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.actions.RenameResourceAction; - -public class J2EERenameResourceAction extends RenameResourceAction { - String newName = null; - - /** - * Creates a new action. Using this constructor directly will rename using a dialog (if - * necessary) rather than the inline editor of a ResourceNavigator. Note that a rename happens - * on one and only one resource at a time. - * - * @param shell - * the shell for any dialogs - */ - public J2EERenameResourceAction(Shell shell) { - super(shell); - } - - /** - * Return the new name to be given to the target resource. - * - * @return java.lang.String - */ - protected String queryNewResourceName(final IResource resource) { - String retVal = null; - - if (newName == null || newName.length() < 1) { - retVal = super.queryNewResourceName(resource); - } else { - retVal = newName; - } - - return retVal; - } - - /** - * Gets the newName. - * - * @return Returns a String - */ - public String getNewName() { - return newName; - } - - /** - * Sets the newName. - * - * @param newName - * The newName to set - */ - public void setNewName(String newName) { - this.newName = newName; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEResourceOpenListener.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEResourceOpenListener.java deleted file mode 100644 index 2d0657e3b..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEResourceOpenListener.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Feb 2, 2005 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package org.eclipse.jst.j2ee.internal.actions; - -import org.eclipse.jface.viewers.IOpenListener; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.OpenEvent; - -/** - * @author Admin - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates - */ -public class J2EEResourceOpenListener implements IOpenListener{ - - private OpenJ2EEResourceAction action; - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IOpenListener#open(org.eclipse.jface.viewers.OpenEvent) - */ - - public void open(OpenEvent anEvent) { - ISelection selection = anEvent.getSelection(); - if (selection instanceof IStructuredSelection) { - - if (getAction().updateSelection((IStructuredSelection)selection)) - action.run(); - } - - } - - /** - * @return - */ - private OpenJ2EEResourceAction getAction() { - if (action == null) - action = new OpenJ2EEResourceAction(); - return action; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/NewAppClientComponentAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/NewAppClientComponentAction.java deleted file mode 100644 index b8a2f7e0e..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/NewAppClientComponentAction.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.actions; - - -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.ui.project.facet.appclient.AppClientProjectWizard; -import org.eclipse.ui.IWorkbench; - - -public class NewAppClientComponentAction extends AbstractOpenWizardWorkbenchAction { - - // TODO MDE 02-28 Find correct label - public static String LABEL = J2EEUIMessages.getResourceString("NewApplClientModuleAction_UI_0"); //$NON-NLS-1$ - private static final String ICON = "new_appclientproject_wiz"; //$NON-NLS-1$ - - public NewAppClientComponentAction() { - setText(LABEL); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(ICON)); - } - - public NewAppClientComponentAction(IWorkbench workbench, String label, Class[] acceptedTypes) { - super(workbench, label, acceptedTypes, false); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(ICON)); - } - - protected Wizard createWizard() { - return new AppClientProjectWizard(); - } - - protected boolean shouldAcceptElement(Object obj) { - return true; /* NewGroup.isOnBuildPath(obj) && !NewGroup.isInArchive(obj); */ - } - - protected String getDialogText() { - return null; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/NewEARComponentAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/NewEARComponentAction.java deleted file mode 100644 index 3c96cb23b..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/NewEARComponentAction.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.actions; - - - -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.ui.project.facet.EarProjectWizard; -import org.eclipse.ui.IWorkbench; - - -public class NewEARComponentAction extends AbstractOpenWizardWorkbenchAction { - // TODO MDE 02-28 Find correct label - public static String LABEL = J2EEUIMessages.getResourceString("NewEARModuleAction_UI_0"); //$NON-NLS-1$ - private static final String ICON = "newear_wiz"; //$NON-NLS-1$ - - public NewEARComponentAction() { - setText(LABEL); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(ICON)); - } - - public NewEARComponentAction(IWorkbench workbench, String label, Class[] acceptedTypes) { - super(workbench, label, acceptedTypes, false); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(ICON)); - } - - protected Wizard createWizard() { - return new EarProjectWizard(); - } - - protected boolean shouldAcceptElement(Object obj) { - return true; /* NewGroup.isOnBuildPath(obj) && !NewGroup.isInArchive(obj); */ - } - - protected String getDialogText() { - return null; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/OpenJ2EEResourceAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/OpenJ2EEResourceAction.java deleted file mode 100644 index e496a977d..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/OpenJ2EEResourceAction.java +++ /dev/null @@ -1,268 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.j2ee.internal.actions; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.jem.java.JavaClass; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jst.j2ee.commonarchivecore.internal.ModuleFile; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveOptions; -import org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil; -import org.eclipse.jst.j2ee.ejb.EJBJar; -import org.eclipse.jst.j2ee.ejb.EnterpriseBean; -import org.eclipse.jst.j2ee.ejb.componentcore.util.EJBArtifactEdit; -import org.eclipse.jst.j2ee.internal.componentcore.ComponentArchiveOptions; -import org.eclipse.jst.j2ee.internal.ejb.provider.J2EEJavaClassProviderHelper; -import org.eclipse.jst.j2ee.internal.plugin.J2EEEditorUtility; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.web.componentcore.util.WebArtifactEdit; -import org.eclipse.jst.j2ee.webapplication.Servlet; -import org.eclipse.jst.j2ee.webapplication.WebApp; -import org.eclipse.jst.j2ee.webservice.wsdd.BeanLink; -import org.eclipse.jst.j2ee.webservice.wsdd.EJBLink; -import org.eclipse.jst.j2ee.webservice.wsdd.ServletLink; -import org.eclipse.ui.IEditorDescriptor; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorRegistry; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.ide.IDE; -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.part.ISetSelectionTarget; -import org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.internal.emfworkbench.WorkbenchResourceHelper; - -/** - * Action for opening a J2EE resource from the J2EE navigator. - */ -public class OpenJ2EEResourceAction extends AbstractOpenAction { - - public static final String ID = "org.eclipse.jst.j2ee.internal.internal.ui.actions.OpenJ2EEResourceAction"; //$NON-NLS-1$ - public static final String JAVA_EDITOR_ID = "org.eclipse.jst.j2ee.internal.internal.ejb.ui.java.EnterpriseBeanJavaEditor"; //$NON-NLS-1$ - public static final String BASE_JAVA_EDITOR_ID = "org.eclipse.jdt.ui.CompilationUnitEditor"; //$NON-NLS-1$ - - protected static IEditorDescriptor javaEditorDescriptor; - protected static IEditorDescriptor baseJavaEditorDescriptor; - - /** - * Create an instance of this class - */ - public OpenJ2EEResourceAction() { - super("Open"); //$NON-NLS-1$ - } - - /** - * Returns the action ID. - */ - public String getID() { - return ID; - } - - public static IEditorDescriptor getJavaEditorDescriptor() { - if (javaEditorDescriptor == null) - javaEditorDescriptor = findEditorDescriptor(JAVA_EDITOR_ID); - return javaEditorDescriptor; - } - - public static IEditorDescriptor getBaseJavaEditorDescriptor() { - if (baseJavaEditorDescriptor == null) - baseJavaEditorDescriptor = findEditorDescriptor(BASE_JAVA_EDITOR_ID); - return baseJavaEditorDescriptor; - } - - protected void openAppropriateEditor(IVirtualComponent c){ - if (c == null){ - return; - } - IWorkbenchPage page = null; - IEditorPart editor = null; - try { - page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - editor = page.openEditor(new ComponentEditorInput(c), currentDescriptor.getId()); - if (editor instanceof ISetSelectionTarget) - ((ISetSelectionTarget) editor).selectReveal(getStructuredSelection()); - } catch (Exception e) { - MessageDialog.openError(page.getWorkbenchWindow().getShell(), J2EEUIMessages.getResourceString("Problems_Opening_Editor_ERROR_"), e.getMessage()); //$NON-NLS-1$ = "Problems Opening Editor" - } - } - - - /** - * open the appropriate editor - */ - protected void openAppropriateEditor(IResource r) { - if (r == null) - return; - IWorkbenchPage page = null; - IEditorPart editor = null; - try { - page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - editor = page.openEditor(new FileEditorInput((IFile) r), currentDescriptor.getId()); - if (editor instanceof ISetSelectionTarget) - ((ISetSelectionTarget) editor).selectReveal(getStructuredSelection()); - } catch (Exception e) { - MessageDialog.openError(page.getWorkbenchWindow().getShell(), J2EEUIMessages.getResourceString("Problems_Opening_Editor_ERROR_"), e.getMessage()); //$NON-NLS-1$ = "Problems Opening Editor" - } - } - - /** - * The user has invoked this action - */ - public void run() { - if (!isEnabled()) - return; - - if (srcObject instanceof J2EEJavaClassProviderHelper) { - ((J2EEJavaClassProviderHelper) srcObject).openInEditor(); - return; - } - if (srcObject instanceof EObject) { - EObject ro = (EObject) srcObject; - IProject p = ProjectUtilities.getProject(ro); - if (ro instanceof BeanLink) { - openBeanLinkInJavaEditor((BeanLink) ro, p); - return; - } - IResource resource = WorkbenchResourceHelper.getFile((EObject)srcObject); - if(resource != null){ - openAppropriateEditor(resource); - } else { - ModuleFile moduleFile = ArchiveUtil.getModuleFile(ro); - ArchiveOptions options = moduleFile.getOptions(); - if(options instanceof ComponentArchiveOptions) { - IVirtualComponent component = ((ComponentArchiveOptions)options).getComponent(); - openAppropriateEditor(component); - } - } - } - else if (srcObject instanceof Resource) - openAppropriateEditor(WorkbenchResourceHelper.getFile((Resource)srcObject)); - } - - /** - * The structured selection has changed in the workbench. Subclasses should override this method - * to react to the change. Returns true if the action should be enabled for this selection, and - * false otherwise. - * - * When this method is overridden, the super method must always be invoked. If the super method - * returns false, this method must also return false. - * - * @param sel the new structured selection - */ - public boolean updateSelection(IStructuredSelection s) { - if (!super.updateSelection(s)) - return false; - - // Make sure this is one of the selections we can handle, - // then set the source object as is. The run() will do the hard stuff. - Object obj = s.getFirstElement(); - - if (obj instanceof J2EEJavaClassProviderHelper) - currentDescriptor = getJavaEditorDescriptor(); - else if (obj instanceof BeanLink) - currentDescriptor = getBaseJavaEditorDescriptor(); - else if (obj instanceof EObject) { - IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); - IFile file = WorkbenchResourceHelper.getFile((EObject)obj); - if(file != null) { - IContentType contentType = IDE.getContentType(file); - currentDescriptor = registry.getDefaultEditor(file.getName(), contentType); - } else { - String name = (new Path(((EObject)obj).eResource().getURI().toString())).lastSegment(); - currentDescriptor = registry.getDefaultEditor(name, null); - } - } - else if (obj instanceof Resource) { - IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); - IFile file = WorkbenchResourceHelper.getFile((Resource)obj); - IContentType contentType = IDE.getContentType(file); - currentDescriptor = registry.getDefaultEditor(file.getName(), contentType); - } - else { - currentDescriptor = null; - return false; - } - setAttributesFromDescriptor(); - srcObject = obj; - return true; - } - - /** - * @param link - */ - private void openBeanLinkInJavaEditor(BeanLink link, IProject p) { - String linkName = null; - JavaClass javaClass = null; - IVirtualComponent comp = ComponentUtilities.findComponent(link); - // Handle EJB Link case - if (link instanceof EJBLink) { - linkName = ((EJBLink) link).getEjbLink(); - EJBArtifactEdit artifactEdit = null; - try { - artifactEdit = EJBArtifactEdit.getEJBArtifactEditForRead(comp); - EJBJar ejbJar = artifactEdit.getEJBJar(); - if (ejbJar == null) - return; - EnterpriseBean bean = ejbJar.getEnterpriseBeanNamed(linkName); - if (bean == null) - return; - javaClass = bean.getEjbClass(); - } finally { - if (artifactEdit!=null) - artifactEdit.dispose(); - } - } - // Handle Servlet Link case - else { - linkName = ((ServletLink) link).getServletLink(); - WebArtifactEdit artifactEdit = null; - try { - artifactEdit = WebArtifactEdit.getWebArtifactEditForRead(comp); - WebApp webApp = artifactEdit.getWebApp(); - if (webApp == null) - return; - Servlet servlet = webApp.getServletNamed(linkName); - if (servlet == null) - return; - javaClass = servlet.getServletClass(); - } finally { - if (artifactEdit!=null) - artifactEdit.dispose(); - } - } - // Open java editor on the selected objects associated java file - try { - J2EEEditorUtility.openInEditor(javaClass, p); - } catch (Exception cantOpen) { - cantOpen.printStackTrace(); - } - } - - protected EObject getRootObject(Object obj) { - if (obj instanceof EObject) { - EObject refObj = (EObject) obj; - while (refObj != null && refObj.eContainer() != null) - refObj = refObj.eContainer(); - return refObj; - } - return null; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/WTPBaseAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/WTPBaseAction.java deleted file mode 100644 index 5433410e9..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/WTPBaseAction.java +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Jul 7, 2004 - * - * TODO To change the template for this generated file go to Window - Preferences - Java - Code - * Style - Code Templates - */ -package org.eclipse.jst.j2ee.internal.actions; - - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jst.j2ee.internal.plugin.ErrorDialog; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IActionDelegate2; -import org.eclipse.ui.IWorkbenchWindow; - - - -public abstract class WTPBaseAction extends Action implements IActionDelegate2 { - private final static String ERROR_OCCURRED_TITLE = J2EEUIMessages.getResourceString("ERROR_OCCURRED_TITLE"); //$NON-NLS-1$ - private final static String ERROR_OCCURRED_MESSAGE = J2EEUIMessages.getResourceString("ERROR_OCCURRED_MESSAGE"); //$NON-NLS-1$ - - protected IStructuredSelection selection = null; - - protected IWorkbenchWindow getWorkbenchWindow() { - return J2EEUIPlugin.getPluginWorkbench().getActiveWorkbenchWindow(); - } - - public void setSelection(IStructuredSelection selection) { - this.selection = selection; - } - - public void run() { - Shell shell = getWorkbenchWindow().getShell(); - if (null == selection) { - ISelection autoselection = getWorkbenchWindow().getSelectionService().getSelection(); - if (autoselection instanceof IStructuredSelection) - this.selection = (IStructuredSelection) autoselection; - } - - try { - primRun(shell); - this.selection = null; - } catch (Throwable t) { - ErrorDialog.openError(shell, ERROR_OCCURRED_TITLE, ERROR_OCCURRED_MESSAGE, t, 0, false); - } - - } - - protected abstract void primRun(Shell shell); - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate2#dispose() - */ - public void dispose() { - //dispose - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction) - */ - public void init(IAction action) { - //init - } - - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, - * org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IAction action, ISelection aSelection) { - setSelection((IStructuredSelection) aSelection); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, - * org.eclipse.swt.widgets.Event) - */ - public void runWithEvent(IAction action, Event event) { - run(); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction action) { - run(); - } - - /** - * @return Returns the selection. - */ - protected IStructuredSelection getSelection() { - return selection; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/WorkspaceModifyComposedOperation.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/WorkspaceModifyComposedOperation.java deleted file mode 100644 index 021b9315a..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/WorkspaceModifyComposedOperation.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.actions; - - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.jface.operation.IRunnableWithProgress; - -/** - * An operation which delegates its work to a runnable that modifies the workspace. - * <p> - * This class may be instantiated; it is not intended to be subclassed. - * </p> - */ -public class WorkspaceModifyComposedOperation extends org.eclipse.ui.actions.WorkspaceModifyOperation { - protected List fRunnables; - - public WorkspaceModifyComposedOperation(ISchedulingRule rule) { - super(rule); - } - - /** - * Creates a new operation which will delegate its work to the given runnable. - */ - public WorkspaceModifyComposedOperation() { - super(); - } - - public WorkspaceModifyComposedOperation(ISchedulingRule rule, List nestedRunnablesWithProgress) { - super(rule); - fRunnables = nestedRunnablesWithProgress; - } - - public WorkspaceModifyComposedOperation(List nestedRunnablesWithProgress) { - super(); - fRunnables = nestedRunnablesWithProgress; - } - - /** - * Creates a new operation which will delegate its work to the given runnable. - * - * @param content - * the runnable to delegate to when this operation is executed - */ - public WorkspaceModifyComposedOperation(IRunnableWithProgress nestedOp) { - super(); - getRunnables().add(nestedOp); - } - - public boolean addRunnable(IRunnableWithProgress nestedOp) { - return getRunnables().add(nestedOp); - } - - protected void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - int size = fRunnables.size(); - monitor.beginTask("", size);//$NON-NLS-1$ - for (int i = 0; i < fRunnables.size(); i++) { - IRunnableWithProgress op = (IRunnableWithProgress) fRunnables.get(i); - op.run(new SubProgressMonitor(monitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); - } - } - - protected List getRunnables() { - if (fRunnables == null) - fRunnables = new ArrayList(3); - return fRunnables; - } -}
\ No newline at end of file |