diff options
Diffstat (limited to 'bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/actions')
6 files changed, 0 insertions, 509 deletions
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/actions/AddFieldAction.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/actions/AddFieldAction.java deleted file mode 100644 index d41124077a..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/actions/AddFieldAction.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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.wst.xsd.ui.internal.adt.actions; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.gef.commands.Command; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.views.contentoutline.ContentOutline; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDAdapterFactory; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.editor.Messages; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IComplexType; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IField; -import org.eclipse.wst.xsd.ui.internal.common.commands.BaseCommand; - - -public class AddFieldAction extends BaseSelectionAction -{ - public static String ID = "AddFieldAction"; //$NON-NLS-1$ - - public AddFieldAction(IWorkbenchPart part) - { - super(part); - setId(ID); - setText(Messages._UI_ACTION_ADD_FIELD); - } - - public void run() - { - if (getSelectedObjects().size() > 0) - { - Object o = getSelectedObjects().get(0); - IComplexType type = null; - - if (o instanceof IComplexType) - { - type = (IComplexType)o; - } - else if (o instanceof IField) - { - IField field = (IField)o; - type = field.getContainerType(); - } - if (type != null) - { - Command command = type.getAddNewFieldCommand(""); //$NON-NLS-1$ - if (command != null) - { - getCommandStack().execute(command); - Adapter adapter = XSDAdapterFactory.getInstance().adapt(((BaseCommand)command).getAddedComponent()); - selectAddedComponent(adapter); - } - else - { - //TODO ... pop up a command not implemented message - } - } - } - } - - protected void doEdit(Object obj, IWorkbenchPart part) - { - if (obj instanceof BaseFieldEditPart) - { - BaseFieldEditPart editPart = (BaseFieldEditPart)obj; - editPart.doEditName(!(part instanceof ContentOutline)); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/actions/BaseDirectEditAction.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/actions/BaseDirectEditAction.java deleted file mode 100644 index 70141bec15..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/actions/BaseDirectEditAction.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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.wst.xsd.ui.internal.adt.actions; - -import org.eclipse.gef.EditPart; -import org.eclipse.gef.GraphicalViewer; -import org.eclipse.gef.ui.actions.DirectEditAction; -import org.eclipse.gef.ui.parts.AbstractEditPartViewer; -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.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; - - -public class BaseDirectEditAction extends DirectEditAction { - protected ISelectionProvider provider; - - /** - * Same as {@link #DirectEditAction(IWorkbenchPart)}. - * @param editor the editor - */ - public BaseDirectEditAction(IEditorPart editor) { - super((IWorkbenchPart)editor); - } - - /** - * Constructs a DirectEditAction using the specified part. - * @param part the workbench part - */ - public BaseDirectEditAction(IWorkbenchPart part) { - super(part); - } - - /* (non-Javadoc) - * @see org.eclipse.gef.ui.actions.SelectionAction#getSelection() - */ - protected ISelection getSelection() - { - // always get selection from selection provider first - if (provider!=null) { - Object selection = provider.getSelection(); - if (selection instanceof StructuredSelection) { - Object object = ((StructuredSelection) selection).getFirstElement(); - if (object instanceof XSDBaseAdapter) { - // We need to return an EditPart as the selection. - IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); - Object graphicalViewer = editor.getAdapter(GraphicalViewer.class); - if (graphicalViewer instanceof AbstractEditPartViewer) { - AbstractEditPartViewer viewer = (AbstractEditPartViewer) graphicalViewer; - EditPart editPart = (EditPart)viewer.getEditPartRegistry().get(object); - return new StructuredSelection(editPart); - } - } - } - } - - return super.getSelection(); - } - - protected boolean calculateEnabled() { - Object selection = ((IStructuredSelection) getSelection()).getFirstElement(); - - if (selection instanceof XSDBaseAdapter) { - return !((XSDBaseAdapter) selection).isReadOnly(); - } - - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.gef.ui.actions.SelectionAction#setSelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) - */ - public void setSelectionProvider(ISelectionProvider provider) - { - super.setSelectionProvider(provider); - this.provider = provider; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/actions/BaseSelectionAction.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/actions/BaseSelectionAction.java deleted file mode 100644 index 53b7f5122a..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/actions/BaseSelectionAction.java +++ /dev/null @@ -1,125 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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.wst.xsd.ui.internal.adt.actions; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.gef.GraphicalViewer; -import org.eclipse.gef.ui.actions.SelectionAction; -import org.eclipse.gef.ui.parts.AbstractEditPartViewer; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.internal.Workbench; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IComplexType; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IField; - -public abstract class BaseSelectionAction extends SelectionAction -{ - public static final String SEPARATOR_ID = "org.eclipse.jface.action.Separator"; //$NON-NLS-1$ - public static final String SUBMENU_START_ID = "SUBMENU_START_ID: "; //$NON-NLS-1$ - public static final String SUBMENU_END_ID = "SUBMENU_END_ID: "; //$NON-NLS-1$ - - protected ISelectionProvider provider; - protected boolean doDirectEdit = true; - - public BaseSelectionAction(IWorkbenchPart part) - { - super(part); - } - - /* (non-Javadoc) - * @see org.eclipse.gef.ui.actions.SelectionAction#getSelection() - */ - protected ISelection getSelection() - { - // always get selection from selection provider first - if (provider!=null) - return provider.getSelection(); - - return super.getSelection(); - } - /* (non-Javadoc) - * @see org.eclipse.gef.ui.actions.SelectionAction#setSelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) - */ - public void setSelectionProvider(ISelectionProvider provider) - { - super.setSelectionProvider(provider); - this.provider = provider; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.xsd.ui.internal.adt.actions.BaseSelectionAction#calculateEnabled() - */ - protected boolean calculateEnabled() - { - if (getSelectedObjects().size() > 0) - { - Object o = getSelectedObjects().get(0); - if (o instanceof IComplexType) - { - return !((IComplexType)o).isReadOnly(); - } - else if (o instanceof IField) - { - return !((IField)o).isReadOnly(); - } - } - return true; - } - - protected void selectAddedComponent(final Adapter adapter) - { - Runnable runnable = new Runnable() - { - public void run() - { - if (adapter != null) - { - provider.setSelection(new StructuredSelection(adapter)); - if (doDirectEdit) - activateDirectEdit(); - } - } - }; - Display.getCurrent().asyncExec(runnable); - } - - protected void activateDirectEdit() - { - if (getWorkbenchPart() instanceof IEditorPart) - { - try - { - IEditorPart owningEditor = (IEditorPart)getWorkbenchPart(); - IWorkbenchPart part = Workbench.getInstance().getActiveWorkbenchWindow().getActivePage().getActivePart(); - Object object = owningEditor.getAdapter(GraphicalViewer.class); - if (object instanceof AbstractEditPartViewer) - { - AbstractEditPartViewer viewer = (AbstractEditPartViewer)object; - Object obj = viewer.getSelectedEditParts().get(0); - doEdit(obj, part); - } - } - catch (Exception e) - { - - } - } - } - - protected void doEdit(Object obj, IWorkbenchPart part) - { - - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/actions/DeleteAction.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/actions/DeleteAction.java deleted file mode 100644 index d654e323a7..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/actions/DeleteAction.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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.wst.xsd.ui.internal.adt.actions; - -import java.util.Iterator; - -import org.eclipse.gef.commands.Command; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.xsd.ui.internal.adt.editor.Messages; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IComplexType; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IField; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IStructure; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; - -public class DeleteAction extends BaseSelectionAction -{ - public final static String ID = "org.eclipse.wst.xsd.ui.internal.editor.DeleteAction"; //$NON-NLS-1$ - public DeleteAction(IWorkbenchPart part) - { - super(part); - setText(Messages._UI_ACTION_DELETE); - setId(ID); - setImageDescriptor(XSDEditorPlugin.getImageDescriptor("icons/delete_obj.gif") ); //$NON-NLS-1$ - } - - public void run() - { - for (Iterator i = ((IStructuredSelection) getSelection()).iterator(); i.hasNext(); ) - { - Object selection = i.next(); - Command command = null; - boolean doReselect = false; - IModel model = null; - if (selection instanceof IComplexType) - { - command = ((IComplexType)selection).getDeleteCommand(); - model = ((IComplexType)selection).getModel(); - doReselect = true; - } - else if (selection instanceof IField) - { - model = ((IField)selection).getModel(); - if ( ((IField)selection).isGlobal()) - { - doReselect = true; - } - command = ((IField)selection).getDeleteCommand(); - } - else if (selection instanceof IStructure) - { - // Fallback for model groups and attribute groups. - IStructure structure = (IStructure)selection; - model = structure.getModel(); - command = structure.getDeleteCommand(); - } - - if (command != null) - { - command.execute(); - if (model != null && doReselect) - provider.setSelection(new StructuredSelection(model)); - } - } - - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/actions/SetInputToGraphView.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/actions/SetInputToGraphView.java deleted file mode 100644 index 60b4e69618..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/actions/SetInputToGraphView.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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.wst.xsd.ui.internal.adt.actions; - -import org.eclipse.gef.EditPart; -import org.eclipse.gef.GraphicalViewer; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.xsd.ui.internal.adt.design.DesignViewGraphicalViewer; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.RootContentEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.editor.Messages; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; - -public class SetInputToGraphView extends BaseSelectionAction -{ - public static String ID = "SetAsFocus"; //$NON-NLS-1$ - IEditorPart editorPart; - Object input; - - public SetInputToGraphView(IWorkbenchPart part) - { - this(part, null); - } - - public SetInputToGraphView(IWorkbenchPart part, Object input) - { - super(part); - this.input = input; - setId(ID); - setText(Messages._UI_ACTION_SET_AS_FOCUS); - if (part instanceof IEditorPart) - { - editorPart = (IEditorPart)part; - } - } - - protected boolean calculateEnabled() - { - return true; - } - - public void run() - { - Object selection = input; - if (selection == null) - { - selection = ((IStructuredSelection) getSelection()).getFirstElement(); - } - Object adapter = getWorkbenchPart().getAdapter(GraphicalViewer.class); - - if (selection instanceof IADTObject) - { - IADTObject obj = (IADTObject) selection; - if (adapter instanceof DesignViewGraphicalViewer) - { - DesignViewGraphicalViewer graphicalViewer = (DesignViewGraphicalViewer) adapter; - EditPart editPart = graphicalViewer.getInputEditPart(); - if (editPart instanceof RootContentEditPart) - { - if (editorPart != null) - { - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getNavigationHistory().markLocation(editorPart); - } - graphicalViewer.setInput(obj); - //((RootContentEditPart) editPart).refresh(); - if (editorPart != null) - { - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getNavigationHistory().markLocation(editorPart); - } - } - } - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/actions/ShowPropertiesViewAction.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/actions/ShowPropertiesViewAction.java deleted file mode 100644 index e3d232f072..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/actions/ShowPropertiesViewAction.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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.wst.xsd.ui.internal.adt.actions; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PartInitException; -import org.eclipse.wst.xsd.ui.internal.adt.editor.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; - - -/** - * Show the properties view in the current perspective. - */ -public class ShowPropertiesViewAction extends BaseSelectionAction -{ - public static final String ID = "org.eclipse.wst.xsd.ui.internal.adt.actions.ShowPropertiesViewAction"; //$NON-NLS-1$ - public static final String PROPERTIES_VIEW_ID = "org.eclipse.ui.views.PropertySheet"; //$NON-NLS-1$ - - protected static ImageDescriptor enabledImage, disabledImage; - - public ShowPropertiesViewAction(IWorkbenchPart part) - { - super(part); - setId(ID); - setText(Messages._UI_ACTION_SHOW_PROPERTIES); - setToolTipText(getText()); - setImageDescriptor(XSDEditorPlugin.getImageDescriptor("icons/elcl16/showproperties_obj.gif") ); //$NON-NLS-1$ - setDisabledImageDescriptor(XSDEditorPlugin.getImageDescriptor("icons/dlcl16/showproperties_obj.gif") ); //$NON-NLS-1$ - } - - protected boolean calculateEnabled() - { - return true; - } - - public void run() - { - try - { - getWorkbenchPart().getSite().getPage().showView(PROPERTIES_VIEW_ID); - } - catch (PartInitException pie) - { - - } - } -} |