diff options
Diffstat (limited to 'bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design')
62 files changed, 0 insertions, 7506 deletions
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/ADTFloatingToolbar.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/ADTFloatingToolbar.java deleted file mode 100644 index b827ca52e7..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/ADTFloatingToolbar.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.design; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.ui.parts.GraphicalViewerImpl; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Canvas; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.ADTFloatingToolbarEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel; - -public class ADTFloatingToolbar extends GraphicalViewerImpl -{ - protected IModel model; - protected boolean isDrilledDown; - protected ADTFloatingToolbarEditPart editPart; - - public ADTFloatingToolbar(IModel model) - { - this.model = model; - } - - public void setModel(IModel model) - { - this.model = model; - editPart = (ADTFloatingToolbarEditPart)getEditPartFactory().createEditPart(null, new ADTFloatingToolbarModel(model)); - if (editPart == null) - { - editPart = new ADTFloatingToolbarEditPart(model); - } - editPart.setModel(model); - setContents(editPart); - } - - public Control createControl(Composite composite) - { - Canvas canvas = new Canvas(composite, SWT.NONE); - canvas.setBackground(ColorConstants.white); - setControl(canvas); - return getControl(); - } - - public void refresh(boolean isDrilledDown) - { - this.isDrilledDown = isDrilledDown; - if (editPart != null) { - editPart.setIsDrilledDown(isDrilledDown); - } - EditPart contents = getContents(); - if (contents != null) { - contents.refresh(); - } - } - - public class ADTFloatingToolbarModel - { - IModel model; - public ADTFloatingToolbarModel(IModel model) - { - this.model = model; - } - - public IModel getModel() - { - return model; - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/BaseGraphicalViewerKeyHandler.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/BaseGraphicalViewerKeyHandler.java deleted file mode 100644 index dfc4e82478..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/BaseGraphicalViewerKeyHandler.java +++ /dev/null @@ -1,168 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 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.design; - -import org.eclipse.draw2d.FigureCanvas; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.GraphicalViewer; -import org.eclipse.gef.ui.actions.ActionRegistry; -import org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler; -import org.eclipse.jface.action.IAction; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.KeyBoardAccessibilityEditPolicy; -import org.eclipse.wst.xsd.ui.internal.common.actions.OpenInNewEditor; - -/** - * This key handler is designed to be re-used by both the WSDL and XSD editor - */ -public class BaseGraphicalViewerKeyHandler extends GraphicalViewerKeyHandler -{ - public BaseGraphicalViewerKeyHandler(GraphicalViewer viewer) - { - super(viewer); - } - - public boolean keyPressed(KeyEvent event) - { - int direction = -1; - boolean isAltDown = (event.stateMask & SWT.ALT) != 0; - boolean isCtrlDown = (event.stateMask & SWT.CTRL) != 0; - switch (event.keyCode) - { - case SWT.ARROW_LEFT : { - direction = PositionConstants.WEST; - break; - } - case SWT.ARROW_RIGHT : { - direction = PositionConstants.EAST; - break; - } - case SWT.ARROW_UP : { - direction = isAltDown ? KeyBoardAccessibilityEditPolicy.OUT_TO_PARENT : PositionConstants.NORTH; - break; - } - case SWT.ARROW_DOWN : { - direction = isAltDown ? KeyBoardAccessibilityEditPolicy.IN_TO_FIRST_CHILD : PositionConstants.SOUTH; - break; - } - } - - if (direction != -1) - { - GraphicalEditPart focusEditPart = getFocusEditPart(); - KeyBoardAccessibilityEditPolicy policy = (KeyBoardAccessibilityEditPolicy)focusEditPart.getEditPolicy(KeyBoardAccessibilityEditPolicy.KEY); - - if (policy != null) - { - EditPart target = policy.getRelativeEditPart(focusEditPart, direction); - if (target != null) - { - if(isCtrlDown) { - - IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); - Object keyboardDrag = editor.getAdapter(IKeyboardDrag.class); - if (keyboardDrag instanceof IKeyboardDrag) { - ((IKeyboardDrag) keyboardDrag).performKeyboardDrag(focusEditPart, direction); - return true; - } - } - else { - navigateTo(target, event); - return true; - } - } - } - } - - switch (event.keyCode) - { - case SWT.PAGE_DOWN : - { - if (scrollPage(event, PositionConstants.SOUTH)) - return true; - } - case SWT.PAGE_UP : - { - if (scrollPage(event, PositionConstants.NORTH)) - return true; - } - case SWT.F3 : - case SWT.CR : - { - IWorkbench workbench = PlatformUI.getWorkbench(); - IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - IEditorPart editorPart = workbenchWindow.getActivePage().getActiveEditor(); - ActionRegistry registry = (ActionRegistry) editorPart.getAdapter(ActionRegistry.class); - if (registry != null) - { - IAction action = registry.getAction(OpenInNewEditor.ID); - if (action != null) - action.run(); - } - } - /* - case SWT.F5 : - { - IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); - if (part != null) - { - EditorModeManager manager = (EditorModeManager)part.getAdapter(EditorModeManager.class); - EditorMode[] modes = manager.getModes(); - EditorMode mode = manager.getCurrentMode(); - List list = Arrays.asList(modes); - int index = list.indexOf(mode); - int nextIndex = index + 1; - if (nextIndex < modes.length) - { - mode = (EditorMode)list.get(nextIndex); - } - else - { - mode = (EditorMode)list.get(0); - } - if (mode != manager.getCurrentMode()) - { - manager.setCurrentMode(mode); - } - } - return true; - }*/ - } - return super.keyPressed(event); - } - - private boolean scrollPage(KeyEvent event, int direction) - { - if (!(getViewer().getControl() instanceof FigureCanvas)) - return false; - FigureCanvas figCanvas = (FigureCanvas) getViewer().getControl(); - Point loc = figCanvas.getViewport().getViewLocation(); - Rectangle area = figCanvas.getViewport().getClientArea(Rectangle.SINGLETON).scale(.8); - if (direction == PositionConstants.NORTH) - { - figCanvas.scrollToY(loc.y - area.height); - } - else - { - figCanvas.scrollToY(loc.y + area.height); - } - return true; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/DesignViewContextMenuProvider.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/DesignViewContextMenuProvider.java deleted file mode 100644 index a13e440666..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/DesignViewContextMenuProvider.java +++ /dev/null @@ -1,161 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2010 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.design; - -import org.eclipse.gef.ContextMenuProvider; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPartViewer; -import org.eclipse.gef.commands.CommandStack; -import org.eclipse.gef.ui.actions.ActionRegistry; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IContributionItem; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchActionConstants; -import org.eclipse.wst.xsd.ui.internal.adt.actions.BaseSelectionAction; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IActionProvider; -import org.eclipse.wst.xsd.ui.internal.adt.editor.ContextMenuParticipant; -import org.eclipse.wst.xsd.ui.internal.adt.editor.EditorModeManager; -import org.eclipse.wst.xsd.ui.internal.adt.editor.Messages; -import org.eclipse.wst.xsd.ui.internal.refactor.IXSDRefactorConstants; - - -public class DesignViewContextMenuProvider extends ContextMenuProvider -{ - IEditorPart editor; - ISelectionProvider selectionProvider; - - /** - * Constructor for GraphContextMenuProvider. - * - * @param selectionProvider - * @param editor - */ - public DesignViewContextMenuProvider(IEditorPart editor, EditPartViewer viewer, ISelectionProvider selectionProvider) - { - super(viewer); - this.editor = editor; - this.selectionProvider = selectionProvider; - } - - /** - * @see org.eclipse.gef.ui.parts.ContextMenuProvider#buildContextMenu(org.eclipse.jface.action.IMenuManager, - * org.eclipse.gef.EditPartViewer) - */ - public void buildContextMenu(IMenuManager menu) - { - IMenuManager currentMenu = menu; - - EditorModeManager manager = (EditorModeManager)editor.getAdapter(EditorModeManager.class); - ContextMenuParticipant contextMenuParticipant = manager != null ? manager.getCurrentMode().getContextMenuParticipant() : null; - - menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); - ActionRegistry registry = getEditorActionRegistry(); - ISelection selection = selectionProvider.getSelection(); - - if (selection != null) - { - Object selectedObject = ((StructuredSelection) selection).getFirstElement(); - - // Convert editparts to model objects as selections - if (selectedObject instanceof EditPart) - { - selectedObject = ((EditPart)selectedObject).getModel(); - } - - if (selectedObject instanceof IActionProvider) - { - IActionProvider actionProvider = (IActionProvider) selectedObject; - - String[] actions = actionProvider.getActions(null); - for (int i = 0; i < actions.length; i++) - { - String id = actions[i]; - if (contextMenuParticipant == null || contextMenuParticipant.isApplicable(selectedObject, id)) - { - if (id.startsWith(BaseSelectionAction.SUBMENU_START_ID)) - { - String text = id.substring(BaseSelectionAction.SUBMENU_START_ID.length()); - IMenuManager subMenu = new MenuManager(text); - currentMenu.add(subMenu); - currentMenu = subMenu; - } - else if (id.startsWith(BaseSelectionAction.SUBMENU_END_ID)) - { - currentMenu = getParentMenu(menu, currentMenu); - } - else if (id.equals(BaseSelectionAction.SEPARATOR_ID)) - { - currentMenu.add(new Separator()); - } - else - { - IAction action = registry.getAction(id); - if (action != null) - { - action.isEnabled(); - currentMenu.add(action); - } - } - } - } - menu.add(new Separator()); - IMenuManager subMenu = new MenuManager(Messages._UI_REFACTOR_CONTEXT_MENU, IXSDRefactorConstants.REFACTOR_CONTEXT_MENU_ID); //$NON-NLS-1$ - menu.add(subMenu); - menu.add(new Separator()); - menu.add(new Separator("search-slot")); //$NON-NLS-1$ - menu.add(new Separator()); - menu.add(new Separator("endDesignMenu-slot")); // $NON-NLS-1$ - menu.add(new Separator()); - } - } - menu.add(new Separator()); - } - - protected IMenuManager getParentMenu(IMenuManager root, IMenuManager child) { - IMenuManager parent = null; - - IContributionItem[] kids = root.getItems(); - int index = 0; - while (index < kids.length && parent == null) { - IContributionItem item = kids[index]; - if (item.equals(child)) { - parent = root; - } - else { - if (item instanceof IMenuManager) { - parent = getParentMenu((IMenuManager) item, child); - } - } - index++; - } - - return parent; - } - - protected ActionRegistry getEditorActionRegistry() - { - return (ActionRegistry) editor.getAdapter(ActionRegistry.class); - } - protected CommandStack commandStack; - - protected CommandStack getCommandStack() - { - if (commandStack == null) - commandStack = getViewer().getEditDomain().getCommandStack(); - return commandStack; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/DesignViewGraphicalViewer.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/DesignViewGraphicalViewer.java deleted file mode 100644 index 381415ca8c..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/DesignViewGraphicalViewer.java +++ /dev/null @@ -1,449 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2009 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.design; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.gef.EditPart; -import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.INavigationHistory; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.xsd.ui.internal.adapters.RedefineCategoryAdapter; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDRedefineAdapter; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.IHolderEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.RootContentEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.StructureEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IGraphElement; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IModelProxy; -import org.eclipse.wst.xsd.ui.internal.adt.editor.CommonSelectionManager; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; -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.adt.outline.ADTContentOutlinePage; - -public class DesignViewGraphicalViewer extends ScrollingGraphicalViewer implements ISelectionChangedListener -{ - protected ADTSelectionChangedListener internalSelectionProvider = new ADTSelectionChangedListener(); - protected InputChangeManager inputChangeManager = new InputChangeManager(); - private IEditorPart editorPart; - - public DesignViewGraphicalViewer(IEditorPart editor, CommonSelectionManager manager) - { - super(); - this.editorPart = editor; - setContextMenu(new DesignViewContextMenuProvider(editor, this, this)); - editor.getEditorSite().registerContextMenu("org.eclipse.wst.xsd.ui.popup.graph", getContextMenu(), internalSelectionProvider, false); //$NON-NLS-1$ - - // make the internalSelectionProvider listen to graph view selection changes - addSelectionChangedListener(internalSelectionProvider); - internalSelectionProvider.addSelectionChangedListener(manager); - manager.addSelectionChangedListener(this); - - setKeyHandler(new BaseGraphicalViewerKeyHandler(this)); - } - - - // this method is called when something changes in the selection manager - // (e.g. a selection occured from another view) - public void selectionChanged(SelectionChangedEvent event) - { - Object selectedObject = null; - ISelection eventSelection = event.getSelection(); - if (eventSelection instanceof StructuredSelection) - { - selectedObject = ((StructuredSelection) eventSelection).getFirstElement(); - } - // TODO (cs) It seems like there's way more selection going on than there - // should - // be!! There's at least 2 selections getting fired when something is - // selected in the - // outline view. Are we listening to too many things? - // - // if (event.getSource() instanceof ADTContentOutlinePage) - if (selectedObject != null) - { - if (event.getSource() != internalSelectionProvider) - { - if (selectedObject instanceof IStructure) - { - if (((getInput() instanceof IModel) && (event.getSource() instanceof ADTContentOutlinePage)) || - (!(getInput() instanceof IModel))) - { - if ((selectedObject instanceof IGraphElement) && ((IGraphElement)selectedObject).isFocusAllowed()) - { - if (!(event.getSource() instanceof org.eclipse.jface.viewers.IPostSelectionProvider)) - { - setInputAndMarkLocation((IStructure)selectedObject); - } - } - } - } - else if (selectedObject instanceof IGraphElement) - { - if (((IGraphElement)selectedObject).isFocusAllowed() && ((event.getSource() instanceof ADTContentOutlinePage))) - { - setInputAndMarkLocation((IADTObject)selectedObject); - } - else if (!((IGraphElement)selectedObject).isFocusAllowed()) - { - // We encountered an object that is not a valid input to the graph viewer - // Now find the top container that can be a valid input - IADTObject obj = ((IGraphElement)selectedObject).getTopContainer(); - if (event.getSource() instanceof ADTContentOutlinePage) - { - // In this case, if the selection is originated from the outline, we should - // change the inputs - if (obj != null && getInput() != obj) // Don't change inputs if the obj is already the input - setInputAndMarkLocation(obj); - } - else if (event.getSource() instanceof CommonSelectionManager) - { - // In this case, if the selection is originated from some action, ie. adding - // a new element, we should change the input only if the current input is the model - // otherwise, inputs will change unexpectedly!! - if (getInput() instanceof IModel) - { - if (obj != null) - setInput (obj); - } - } - else if (event.getSource() instanceof org.eclipse.jface.viewers.IPostSelectionProvider ) - { - // In this case, if the selection is originated from the source viewer - // we should change the input regardless. Test is for multiple levels - // of anonymous types - if (obj != null) - setInput (obj); - } - else - { - if (obj != null && getInput() instanceof IModel) - setInputAndMarkLocation(obj); - } - } - if (selectedObject instanceof IField) - { - IField field = (IField)selectedObject; - if ( (!field.isGlobal() && getInput() instanceof IModel) || - (!field.isGlobal() && !(event.getSource() instanceof CommonSelectionManager))) - { - IADTObject obj = ((IGraphElement)selectedObject).getTopContainer(); - if (obj != null) - setInputAndMarkLocation(obj); - } - else if (field.isGlobal() && !(getInput() instanceof IModel)) - { - if (event.getSource() instanceof org.eclipse.jface.viewers.IPostSelectionProvider ) - setInput(field); - else - setInputAndMarkLocation(field); - } - } - } - else if (selectedObject instanceof IField) - { - IField field = (IField)selectedObject; - if ( (field.isGlobal() && (getInput() instanceof IModel) && (event.getSource() instanceof ADTContentOutlinePage)) || - ( (field.isGlobal() && !(getInput() instanceof IModel)))) - { - setInputAndMarkLocation(field); - } - } - else if (selectedObject instanceof IModelProxy) - { - IModelProxy adapter = (IModelProxy)selectedObject; - if (selectedObject instanceof RedefineCategoryAdapter) - { - RedefineCategoryAdapter selectionAdapter = (RedefineCategoryAdapter)selectedObject; - XSDRedefineAdapter selectionParentAdapter = selectionAdapter.getXsdRedefineAdapter(); - setInputAndMarkLocation(selectionParentAdapter); - } - else if (getInput() != adapter.getModel()) - setInput(adapter.getModel()); - } - else if (selectedObject instanceof IModel) - { - if (getInput() != selectedObject) - setInput((IModel)selectedObject); - } - - EditPart editPart = getEditPart(getRootEditPart(), selectedObject); - if (editPart != null) - { - setSelection(new StructuredSelection(editPart)); - setFocus(editPart); - } - } - } - } - - /* - * We need to convert from edit part selections to model object selections - */ - class ADTSelectionChangedListener implements ISelectionProvider, ISelectionChangedListener - { - protected List listenerList = new ArrayList(); - protected ISelection selection = new StructuredSelection(); - - public void addSelectionChangedListener(ISelectionChangedListener listener) - { - listenerList.add(listener); - } - - public void removeSelectionChangedListener(ISelectionChangedListener listener) - { - listenerList.remove(listener); - } - - public ISelection getSelection() - { - return selection; - } - - protected void notifyListeners(SelectionChangedEvent event) - { - for (Iterator i = listenerList.iterator(); i.hasNext();) - { - ISelectionChangedListener listener = (ISelectionChangedListener) i.next(); - listener.selectionChanged(event); - } - } - - public StructuredSelection convertSelectionFromEditPartToModel(ISelection editPartSelection) - { - List selectedModelObjectList = new ArrayList(); - if (editPartSelection instanceof IStructuredSelection) - { - for (Iterator i = ((IStructuredSelection) editPartSelection).iterator(); i.hasNext();) - { - Object obj = i.next(); - Object model = null; - if (obj instanceof EditPart) - { - EditPart editPart = (EditPart) obj; - model = editPart.getModel(); - } - if (model != null) - { - selectedModelObjectList.add(model); - } - } - } - return new StructuredSelection(selectedModelObjectList); - } - - public void setSelection(ISelection selection) - { - this.selection = selection; - } - - public void selectionChanged(SelectionChangedEvent event) - { - ISelection newSelection = convertSelectionFromEditPartToModel(event.getSelection()); - this.selection = newSelection; - SelectionChangedEvent newEvent = new SelectionChangedEvent(this, newSelection); - notifyListeners(newEvent); - } - } - - protected EditPart getEditPart(EditPart parent, Object object) - { - EditPart result = null; - for (Iterator i = parent.getChildren().iterator(); i.hasNext(); ) - { - EditPart editPart = (EditPart)i.next(); - if (editPart.getModel() == object && !(editPart instanceof IHolderEditPart) && !(editPart instanceof RootContentEditPart)) - { - result = editPart; - break; - } - } - - if (result == null) - { - for (Iterator i = parent.getChildren().iterator(); i.hasNext(); ) - { - EditPart editPart = getEditPart((EditPart)i.next(), object); - if (editPart != null) - { - // First check to see if there is a selection - ISelection currentSelection = getSelection(); - - // If there is a selection then we will try to select - // the target edit part that is one of its children - // This is handy when you add an element to a structured edit part - // then you want to select the element immediately and put it in - // direct edit mode - if (currentSelection != null) - { - if (currentSelection instanceof StructuredSelection) - { - EditPart targetStructureEditPart = (EditPart)((StructuredSelection)currentSelection).getFirstElement(); - if (targetStructureEditPart != null) - { - while (targetStructureEditPart != null) - { - if (targetStructureEditPart instanceof StructureEditPart) - { - break; - } - targetStructureEditPart = targetStructureEditPart.getParent(); - } - } - EditPart potentialEditPartToSelect = editPart; - - while (potentialEditPartToSelect != null) - { - if (potentialEditPartToSelect instanceof StructureEditPart) - { - break; - } - potentialEditPartToSelect = potentialEditPartToSelect.getParent(); - } - - // If we found a potential edit part to select then return it - // OR, if there is no target found, then we should just return - // the edit part we found - if (potentialEditPartToSelect == targetStructureEditPart || potentialEditPartToSelect == null || targetStructureEditPart == null) - { - result = editPart; - break; - } - } - } - else // Otherwise just find the first one and return - { - result = editPart; - break; - } - } - } - } - - return result; - } - - public void setInputAndMarkLocation(IADTObject object) - { - IADTObject oldInput = getInput(); - INavigationHistory navigationHistory = null; - IWorkbench workbench = PlatformUI.getWorkbench(); - if(workbench != null) - { - IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow(); - if(activeWorkbenchWindow != null) - { - IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage(); - if(activePage != null) - { - navigationHistory = activePage.getNavigationHistory(); - } - } - } - - setInput(object); - - if (editorPart != null && oldInput != object) - { - navigationHistory.markLocation(editorPart); - } - } - - public void setInput(IADTObject object) - { - RootContentEditPart rootContentEditPart = (RootContentEditPart)getRootEditPart().getContents(); - rootContentEditPart.setModel(object); - rootContentEditPart.refresh(); - - if (object != null) - { - inputChangeManager.setSelection(new StructuredSelection(object)); - } - // Select the editpart when it is set as input - EditPart editPart = getEditPart(rootContentEditPart, object); - if (editPart != null) - select(editPart); - } - - public IADTObject getInput() - { - RootContentEditPart rootContentEditPart = (RootContentEditPart)getRootEditPart().getContents(); - return (IADTObject)rootContentEditPart.getModel(); - } - - public EditPart getInputEditPart() - { - return getRootEditPart().getContents(); - } - - public void addInputChangdListener(ISelectionChangedListener listener) - { - inputChangeManager.addSelectionChangedListener(listener); - } - - public void removeInputChangdListener(ISelectionChangedListener listener) - { - inputChangeManager.removeSelectionChangedListener(listener); - } - - - private class InputChangeManager implements ISelectionProvider - { - List listeners = new ArrayList(); - - public void addSelectionChangedListener(ISelectionChangedListener listener) - { - if (!listeners.contains(listener)) - { - listeners.add(listener); - } - } - - public ISelection getSelection() - { - // no one should be calling this method - return null; - } - - public void removeSelectionChangedListener(ISelectionChangedListener listener) - { - listeners.remove(listener); - } - - public void setSelection(ISelection selection) - { - notifyListeners(selection); - } - - void notifyListeners(ISelection selection) - { - List list = new ArrayList(listeners); - for (Iterator i = list.iterator(); i.hasNext(); ) - { - ISelectionChangedListener listener = (ISelectionChangedListener)i.next(); - listener.selectionChanged(new SelectionChangedEvent(this, selection)); - } - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/DesignViewerGraphicConstants.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/DesignViewerGraphicConstants.java deleted file mode 100644 index 434e0d7f75..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/DesignViewerGraphicConstants.java +++ /dev/null @@ -1,21 +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.design; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.widgets.Display; - -public interface DesignViewerGraphicConstants -{ - public static final String SCALED_HANDLE_LAYER = "Scaled Handle Layer"; //$NON-NLS-1$ - public final static Font smallFont = new Font(Display.getCurrent(), "Tahoma", 6, SWT.NONE); //$NON-NLS-1$ -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/FlatCCombo.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/FlatCCombo.java deleted file mode 100644 index 4959363983..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/FlatCCombo.java +++ /dev/null @@ -1,1488 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2010 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.design; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.accessibility.ACC; -import org.eclipse.swt.accessibility.AccessibleAdapter; -import org.eclipse.swt.accessibility.AccessibleControlAdapter; -import org.eclipse.swt.accessibility.AccessibleControlEvent; -import org.eclipse.swt.accessibility.AccessibleEvent; -import org.eclipse.swt.accessibility.AccessibleTextAdapter; -import org.eclipse.swt.accessibility.AccessibleTextEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Layout; -import org.eclipse.swt.widgets.List; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.eclipse.swt.widgets.TypedListener; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; - -/** - * The CCombo class represents a selectable user interface object - * that combines a text field and a list and issues notification - * when an item is selected from the list. - * <p> - * Note that although this class is a subclass of <code>Composite</code>, - * it does not make sense to add children to it, or set a layout on it. - * </p> - * <dl> - * <dt><b>Styles:</b> - * <dd>BORDER, READ_ONLY, FLAT</dd> - * <dt><b>Events:</b> - * <dd>Selection</dd> - * </dl> - */ -public final class FlatCCombo extends Composite { - - Text text; - List list; - int visibleItemCount = 5; - Shell popup; - Label arrow; - boolean hasFocus; - Listener listener, filter; - Color foreground, background; - Font font; - -/** - * Constructs a new instance of this class given its parent - * and a style value describing its behavior and appearance. - * <p> - * The style value is either one of the style constants defined in - * class <code>SWT</code> which is applicable to instances of this - * class, or must be built by <em>bitwise OR</em>'ing together - * (that is, using the <code>int</code> "|" operator) two or more - * of those <code>SWT</code> style constants. The class description - * lists the style constants that are applicable to the class. - * Style bits are also inherited from superclasses. - * </p> - * - * @param parent a widget which will be the parent of the new instance (cannot be null) - * @param style the style of widget to construct - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> - * </ul> - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> - * </ul> - * - * @see SWT#BORDER - * @see SWT#READ_ONLY - * @see SWT#FLAT - * @see org.eclipse.swt.widgets.Widget#getStyle() - */ -public FlatCCombo (Composite parent, int style) { - super (parent, style = checkStyle (style)); - - int textStyle = SWT.SINGLE; - if ((style & SWT.READ_ONLY) != 0) textStyle |= SWT.READ_ONLY; - if ((style & SWT.FLAT) != 0) textStyle |= SWT.FLAT; - text = new Text (this, textStyle); - arrow = new Label(this, SWT.FLAT); - arrow.setImage(XSDEditorPlugin.getXSDImage("icons/TriangleToolBar.gif")); //$NON-NLS-1$ - - listener = new Listener () { - public void handleEvent (Event event) { - if (popup == event.widget) { - popupEvent (event); - return; - } - if (text == event.widget) { - textEvent (event); - return; - } - if (list == event.widget) { - listEvent (event); - return; - } - if (arrow == event.widget) { - arrowEvent (event); - return; - } - if (FlatCCombo.this == event.widget) { - comboEvent (event); - return; - } - if (getShell () == event.widget) { - handleFocus (SWT.FocusOut); - } - } - }; - filter = new Listener() { - public void handleEvent(Event event) { - Shell shell = ((Control)event.widget).getShell (); - if (shell == FlatCCombo.this.getShell ()) { - handleFocus (SWT.FocusOut); - } - } - }; - - int [] comboEvents = {SWT.Dispose, SWT.Move, SWT.Resize}; - for (int i=0; i<comboEvents.length; i++) this.addListener (comboEvents [i], listener); - - int [] textEvents = {SWT.KeyDown, SWT.KeyUp, SWT.MenuDetect, SWT.Modify, SWT.MouseDown, SWT.MouseUp, SWT.Traverse, SWT.FocusIn}; - for (int i=0; i<textEvents.length; i++) text.addListener (textEvents [i], listener); - - int [] arrowEvents = {SWT.MouseDown, SWT.Selection, SWT.FocusIn}; - for (int i=0; i<arrowEvents.length; i++) arrow.addListener (arrowEvents [i], listener); - - createPopup(null, -1); - initAccessible(); -} -static int checkStyle (int style) { - int mask = SWT.BORDER | SWT.READ_ONLY | SWT.FLAT | SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT; - return style & mask; -} -/** - * Adds the argument to the end of the receiver's list. - * - * @param string the new item - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the string is null</li> - * </ul> - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #add(String,int) - */ -public void add (String string) { - checkWidget(); - if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); - list.add (string); -} -/** - * Adds the argument to the receiver's list at the given - * zero-relative index. - * <p> - * Note: To add an item at the end of the list, use the - * result of calling <code>getItemCount()</code> as the - * index or use <code>add(String)</code>. - * </p> - * - * @param string the new item - * @param index the index for the item - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the string is null</li> - * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li> - * </ul> - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #add(String) - */ -public void add (String string, int index) { - checkWidget(); - if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); - list.add (string, index); -} -/** - * Adds the listener to the collection of listeners who will - * be notified when the receiver's text is modified, by sending - * it one of the messages defined in the <code>ModifyListener</code> - * interface. - * - * @param listener the listener which should be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see ModifyListener - * @see #removeModifyListener - */ -public void addModifyListener (ModifyListener listener) { - checkWidget(); - if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); - TypedListener typedListener = new TypedListener (listener); - addListener (SWT.Modify, typedListener); -} -/** - * Adds the listener to the collection of listeners who will - * be notified when the receiver's selection changes, by sending - * it one of the messages defined in the <code>SelectionListener</code> - * interface. - * <p> - * <code>widgetSelected</code> is called when the combo's list selection changes. - * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed the combo's text area. - * </p> - * - * @param listener the listener which should be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see SelectionListener - * @see #removeSelectionListener - * @see org.eclipse.swt.events.SelectionEvent - */ -public void addSelectionListener(SelectionListener listener) { - checkWidget(); - if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); - TypedListener typedListener = new TypedListener (listener); - addListener (SWT.Selection,typedListener); - addListener (SWT.DefaultSelection,typedListener); -} -void arrowEvent (Event event) { - switch (event.type) { - case SWT.FocusIn: { - handleFocus (SWT.FocusIn); - break; - } - case SWT.Selection: { - dropDown (!isDropped ()); - break; - } - case SWT.MouseDown: { - dropDown (!isDropped ()); - break; - } - } -} -/** - * Sets the selection in the receiver's text field to an empty - * selection starting just before the first character. If the - * text field is editable, this has the effect of placing the - * i-beam at the start of the text. - * <p> - * Note: To clear the selected items in the receiver's list, - * use <code>deselectAll()</code>. - * </p> - * - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #deselectAll - */ -public void clearSelection () { - checkWidget (); - text.clearSelection (); - list.deselectAll (); -} -void comboEvent (Event event) { - switch (event.type) { - case SWT.Dispose: - if (popup != null && !popup.isDisposed ()) { - list.removeListener (SWT.Dispose, listener); - popup.dispose (); - } - Shell shell = getShell (); - shell.removeListener (SWT.Deactivate, listener); - Display display = getDisplay (); - display.removeFilter (SWT.FocusIn, filter); - popup = null; - text = null; - list = null; - arrow = null; - break; - case SWT.Move: - dropDown (false); - break; - case SWT.Resize: - internalLayout (false); - break; - } -} - -public Point computeSize (int wHint, int hHint, boolean changed) { - checkWidget (); - int width = 0, height = 0; - String[] items = list.getItems (); - int textWidth = 0; - GC gc = new GC (text); - int spacer = gc.stringExtent (" ").x; //$NON-NLS-1$ - for (int i = 0; i < items.length; i++) { - textWidth = Math.max (gc.stringExtent (items[i]).x, textWidth); - } - gc.dispose(); - Point textSize = text.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed); - // Point arrowSize = arrow.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed); - Point arrowSize = new Point(16, 16); - Point listSize = list.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed); - int borderWidth = getBorderWidth (); - - height = Math.max (textSize.y, arrowSize.y); - width = Math.max (textWidth + 2*spacer + arrowSize.x + 2*borderWidth, listSize.x); - if (wHint != SWT.DEFAULT) width = wHint; - if (hHint != SWT.DEFAULT) height = hHint; - return new Point (width + 2*borderWidth, height + 2*borderWidth); -} -void createPopup(String[] items, int selectionIndex) { - // create shell and list - popup = new Shell (getShell (), SWT.NO_TRIM | SWT.ON_TOP); - int style = getStyle (); - int listStyle = SWT.SINGLE | SWT.V_SCROLL; - if ((style & SWT.FLAT) != 0) listStyle |= SWT.FLAT; - if ((style & SWT.RIGHT_TO_LEFT) != 0) listStyle |= SWT.RIGHT_TO_LEFT; - if ((style & SWT.LEFT_TO_RIGHT) != 0) listStyle |= SWT.LEFT_TO_RIGHT; - list = new List (popup, listStyle); - if (font != null) list.setFont (font); - if (foreground != null) list.setForeground (foreground); - if (background != null) list.setBackground (background); - - int [] popupEvents = {SWT.Close, SWT.Paint, SWT.Deactivate}; - for (int i=0; i<popupEvents.length; i++) popup.addListener (popupEvents [i], listener); - int [] listEvents = {SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose}; - for (int i=0; i<listEvents.length; i++) list.addListener (listEvents [i], listener); - - if (items != null) list.setItems (items); - if (selectionIndex != -1) list.setSelection (selectionIndex); -} -/** - * Deselects the item at the given zero-relative index in the receiver's - * list. If the item at the index was already deselected, it remains - * deselected. Indices that are out of range are ignored. - * - * @param index the index of the item to deselect - * - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public void deselect (int index) { - checkWidget (); - list.deselect (index); -} -/** - * Deselects all selected items in the receiver's list. - * <p> - * Note: To clear the selection in the receiver's text field, - * use <code>clearSelection()</code>. - * </p> - * - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #clearSelection - */ -public void deselectAll () { - checkWidget (); - list.deselectAll (); -} -void dropDown (boolean drop) { - if (drop == isDropped ()) return; - if (!drop) { - popup.setVisible (false); - if (!isDisposed ()&& arrow.isFocusControl()) { - text.setFocus(); - } - return; - } - - if (getShell() != popup.getParent ()) { - String[] items = list.getItems (); - int selectionIndex = list.getSelectionIndex (); - list.removeListener (SWT.Dispose, listener); - popup.dispose(); - popup = null; - list = null; - createPopup (items, selectionIndex); - } - - Point size = getSize (); - int itemCount = list.getItemCount (); - itemCount = (itemCount == 0) ? visibleItemCount : Math.min(visibleItemCount, itemCount); - int itemHeight = list.getItemHeight () * itemCount; - Point listSize = list.computeSize (SWT.DEFAULT, itemHeight, false); - list.setBounds (1, 1, Math.max (size.x - 2, listSize.x), listSize.y); - - int index = list.getSelectionIndex (); - if (index != -1) list.setTopIndex (index); - Display display = getDisplay (); - Rectangle listRect = list.getBounds (); - Rectangle parentRect = display.map (getParent (), null, getBounds ()); - Point comboSize = getSize (); - Rectangle displayRect = getMonitor ().getClientArea (); - int width = Math.max (comboSize.x, listRect.width + 2); - int height = listRect.height + 2; - int x = parentRect.x; - int y = parentRect.y + comboSize.y; - if (y + height > displayRect.y + displayRect.height) y = parentRect.y - height; - if (x + width > displayRect.x + displayRect.width) x = displayRect.x + displayRect.width - listRect.width; - popup.setBounds (x, y, width, height); - popup.setVisible (true); - list.setFocus (); -} -/* - * Return the lowercase of the first non-'&' character following - * an '&' character in the given string. If there are no '&' - * characters in the given string, return '\0'. - */ -char _findMnemonic (String string) { - if (string == null) return '\0'; - int index = 0; - int length = string.length (); - do { - while (index < length && string.charAt (index) != '&') index++; - if (++index >= length) return '\0'; - if (string.charAt (index) != '&') return Character.toLowerCase (string.charAt (index)); - index++; - } while (index < length); - return '\0'; -} -/* - * Return the Label immediately preceding the receiver in the z-order, - * or null if none. - */ -Label getAssociatedLabel () { - Control[] siblings = getParent ().getChildren (); - for (int i = 0; i < siblings.length; i++) { - if (siblings [i] == this) { - if (i > 0 && siblings [i-1] instanceof Label) { - return (Label) siblings [i-1]; - } - } - } - return null; -} -public Control [] getChildren () { - return super.getChildren(); -} -/** - * Gets the editable state. - * - * @return whether or not the receiver is editable - * - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @since 3.0 - */ -public boolean getEditable () { - checkWidget (); - return text.getEditable(); -} -/** - * Returns the item at the given, zero-relative index in the - * receiver's list. Throws an exception if the index is out - * of range. - * - * @param index the index of the item to return - * @return the item at the given index - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li> - * </ul> - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public String getItem (int index) { - checkWidget(); - return list.getItem (index); -} -/** - * Returns the number of items contained in the receiver's list. - * - * @return the number of items - * - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public int getItemCount () { - checkWidget (); - return list.getItemCount (); -} -/** - * Returns the height of the area which would be used to - * display <em>one</em> of the items in the receiver's list. - * - * @return the height of one item - * - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public int getItemHeight () { - checkWidget (); - return list.getItemHeight (); -} -/** - * Returns an array of <code>String</code>s which are the items - * in the receiver's list. - * <p> - * Note: This is not the actual structure used by the receiver - * to maintain its list of items, so modifying the array will - * not affect the receiver. - * </p> - * - * @return the items in the receiver's list - * - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public String [] getItems () { - checkWidget (); - return list.getItems (); -} -public Menu getMenu() { - return text.getMenu(); -} -/** - * Returns a <code>Point</code> whose x coordinate is the start - * of the selection in the receiver's text field, and whose y - * coordinate is the end of the selection. The returned values - * are zero-relative. An "empty" selection as indicated by - * the the x and y coordinates having the same value. - * - * @return a point representing the selection start and end - * - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public Point getSelection () { - checkWidget (); - return text.getSelection (); -} -/** - * Returns the zero-relative index of the item which is currently - * selected in the receiver's list, or -1 if no item is selected. - * - * @return the index of the selected item - * - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public int getSelectionIndex () { - checkWidget (); - return list.getSelectionIndex (); -} -public int getStyle () { - int style = super.getStyle (); - style &= ~SWT.READ_ONLY; - if (!text.getEditable()) style |= SWT.READ_ONLY; - return style; -} -/** - * Returns a string containing a copy of the contents of the - * receiver's text field. - * - * @return the receiver's text - * - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public String getText () { - checkWidget (); - return text.getText (); -} -/** - * Returns the height of the receivers's text field. - * - * @return the text height - * - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public int getTextHeight () { - checkWidget (); - return text.getLineHeight (); -} -/** - * Returns the maximum number of characters that the receiver's - * text field is capable of holding. If this has not been changed - * by <code>setTextLimit()</code>, it will be the constant - * <code>Combo.LIMIT</code>. - * - * @return the text limit - * - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public int getTextLimit () { - checkWidget (); - return text.getTextLimit (); -} -/** - * Gets the number of items that are visible in the drop - * down portion of the receiver's list. - * - * @return the number of items that are visible - * - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @since 3.0 - */ -public int getVisibleItemCount () { - checkWidget (); - return visibleItemCount; -} -void handleFocus (int type) { - if (isDisposed ()) return; - switch (type) { - case SWT.FocusIn: { - if (hasFocus) return; - if (getEditable ()) text.selectAll (); - hasFocus = true; - Shell shell = getShell (); - shell.removeListener (SWT.Deactivate, listener); - shell.addListener (SWT.Deactivate, listener); - Display display = getDisplay (); - display.removeFilter (SWT.FocusIn, filter); - display.addFilter (SWT.FocusIn, filter); - Event e = new Event (); - notifyListeners (SWT.FocusIn, e); - break; - } - case SWT.FocusOut: { - if (!hasFocus) return; - Control focusControl = getDisplay ().getFocusControl (); - if (focusControl == arrow || focusControl == list || focusControl == text) return; - hasFocus = false; - Shell shell = getShell (); - shell.removeListener(SWT.Deactivate, listener); - Display display = getDisplay (); - display.removeFilter (SWT.FocusIn, filter); - Event e = new Event (); - notifyListeners (SWT.FocusOut, e); - break; - } - } -} -/** - * Searches the receiver's list starting at the first item - * (index 0) until an item is found that is equal to the - * argument, and returns the index of that item. If no item - * is found, returns -1. - * - * @param string the search item - * @return the index of the item - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the string is null</li> - * </ul> - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public int indexOf (String string) { - checkWidget (); - if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); - return list.indexOf (string); -} -/** - * Searches the receiver's list starting at the given, - * zero-relative index until an item is found that is equal - * to the argument, and returns the index of that item. If - * no item is found or the starting index is out of range, - * returns -1. - * - * @param string the search item - * @param start the zero-relative index at which to begin the search - * @return the index of the item - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the string is null</li> - * </ul> - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public int indexOf (String string, int start) { - checkWidget (); - if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); - return list.indexOf (string, start); -} - -void initAccessible() { - AccessibleAdapter accessibleAdapter = new AccessibleAdapter () { - public void getName (AccessibleEvent e) { - String name = null; - Label label = getAssociatedLabel (); - if (label != null) { - name = stripMnemonic (label.getText()); - } - e.result = name; - } - public void getKeyboardShortcut(AccessibleEvent e) { - String shortcut = null; - Label label = getAssociatedLabel (); - if (label != null) { - String text = label.getText (); - if (text != null) { - char mnemonic = _findMnemonic (text); - if (mnemonic != '\0') { - shortcut = "Alt+"+mnemonic; //$NON-NLS-1$ - } - } - } - e.result = shortcut; - } - public void getHelp (AccessibleEvent e) { - e.result = getToolTipText (); - } - }; - getAccessible ().addAccessibleListener (accessibleAdapter); - text.getAccessible ().addAccessibleListener (accessibleAdapter); - list.getAccessible ().addAccessibleListener (accessibleAdapter); - - arrow.getAccessible ().addAccessibleListener (new AccessibleAdapter() { - public void getName (AccessibleEvent e) { - e.result = isDropped () ? SWT.getMessage ("SWT_Close") : SWT.getMessage ("SWT_Open"); //$NON-NLS-1$ //$NON-NLS-2$ - } - public void getKeyboardShortcut (AccessibleEvent e) { - e.result = "Alt+Down Arrow"; //$NON-NLS-1$ - } - public void getHelp (AccessibleEvent e) { - e.result = getToolTipText (); - } - }); - - getAccessible().addAccessibleTextListener (new AccessibleTextAdapter() { - public void getCaretOffset (AccessibleTextEvent e) { - e.offset = text.getCaretPosition (); - } - public void getSelectionRange(AccessibleTextEvent e) { - Point sel = text.getSelection(); - e.offset = sel.x; - e.length = sel.y - sel.x; - } - }); - - getAccessible().addAccessibleControlListener (new AccessibleControlAdapter() { - public void getChildAtPoint (AccessibleControlEvent e) { - Point testPoint = toControl (e.x, e.y); - if (getBounds ().contains (testPoint)) { - e.childID = ACC.CHILDID_SELF; - } - } - - public void getLocation (AccessibleControlEvent e) { - Rectangle location = getBounds (); - Point pt = toDisplay (location.x, location.y); - e.x = pt.x; - e.y = pt.y; - e.width = location.width; - e.height = location.height; - } - - public void getChildCount (AccessibleControlEvent e) { - e.detail = 0; - } - - public void getRole (AccessibleControlEvent e) { - e.detail = ACC.ROLE_COMBOBOX; - } - - public void getState (AccessibleControlEvent e) { - e.detail = ACC.STATE_NORMAL; - } - - public void getValue (AccessibleControlEvent e) { - e.result = getText (); - } - }); - - text.getAccessible ().addAccessibleControlListener (new AccessibleControlAdapter () { - public void getRole (AccessibleControlEvent e) { - e.detail = text.getEditable () ? ACC.ROLE_TEXT : ACC.ROLE_LABEL; - } - }); - - arrow.getAccessible ().addAccessibleControlListener (new AccessibleControlAdapter() { - public void getDefaultAction (AccessibleControlEvent e) { - e.result = isDropped () ? SWT.getMessage ("SWT_Close") : SWT.getMessage ("SWT_Open"); //$NON-NLS-1$ //$NON-NLS-2$ - } - }); -} -boolean isDropped () { - return popup.getVisible (); -} -public boolean isFocusControl () { - checkWidget(); - if (text.isFocusControl () || arrow.isFocusControl () || list.isFocusControl () || popup.isFocusControl ()) { - return true; - } - return super.isFocusControl (); -} -void internalLayout (boolean changed) { - if (isDropped ()) dropDown (false); - Rectangle rect = getClientArea (); - int width = rect.width; - int height = rect.height; - // Point arrowSize = arrow.computeSize (SWT.DEFAULT, height, changed); - // text.setBounds (0, 0, width - arrowSize.x, height); - text.setBounds (0, 0, width - 16, height); - // arrow.setBounds (width - arrowSize.x, 0, arrowSize.x, arrowSize.y); - arrow.setBounds (width - 16, 0, 16, 16); -} -void listEvent (Event event) { - switch (event.type) { - case SWT.Dispose: - if (getShell () != popup.getParent ()) { - String[] items = list.getItems (); - int selectionIndex = list.getSelectionIndex (); - popup = null; - list = null; - createPopup (items, selectionIndex); - } - break; - case SWT.FocusIn: { - handleFocus (SWT.FocusIn); - break; - } - case SWT.MouseUp: { - if (event.button != 1) return; - dropDown (false); - break; - } - case SWT.Selection: { - int index = list.getSelectionIndex (); - if (index == -1) return; - text.setText (list.getItem (index)); - text.selectAll (); - list.setSelection (index); - Event e = new Event (); - e.time = event.time; - e.stateMask = event.stateMask; - e.doit = event.doit; - notifyListeners (SWT.Selection, e); - event.doit = e.doit; - break; - } - case SWT.Traverse: { - switch (event.detail) { - case SWT.TRAVERSE_RETURN: - case SWT.TRAVERSE_ESCAPE: - case SWT.TRAVERSE_ARROW_PREVIOUS: - case SWT.TRAVERSE_ARROW_NEXT: - event.doit = false; - break; - } - Event e = new Event (); - e.time = event.time; - e.detail = event.detail; - e.doit = event.doit; - e.character = event.character; - e.keyCode = event.keyCode; - notifyListeners (SWT.Traverse, e); - event.doit = e.doit; - event.detail = e.detail; - break; - } - case SWT.KeyUp: { - Event e = new Event (); - e.time = event.time; - e.character = event.character; - e.keyCode = event.keyCode; - e.stateMask = event.stateMask; - notifyListeners (SWT.KeyUp, e); - break; - } - case SWT.KeyDown: { - if (event.character == SWT.ESC) { - // Escape key cancels popup list - dropDown (false); - } - if ((event.stateMask & SWT.ALT) != 0 && (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN)) { - dropDown (false); - } - if (event.character == SWT.CR) { - // Enter causes default selection - dropDown (false); - Event e = new Event (); - e.time = event.time; - e.stateMask = event.stateMask; - notifyListeners (SWT.DefaultSelection, e); - } - // At this point the widget may have been disposed. - // If so, do not continue. - if (isDisposed ()) break; - Event e = new Event(); - e.time = event.time; - e.character = event.character; - e.keyCode = event.keyCode; - e.stateMask = event.stateMask; - notifyListeners(SWT.KeyDown, e); - break; - - } - } -} - -void popupEvent(Event event) { - switch (event.type) { - case SWT.Paint: - // draw black rectangle around list - Rectangle listRect = list.getBounds(); - Color black = getDisplay().getSystemColor(SWT.COLOR_BLACK); - event.gc.setForeground(black); - event.gc.drawRectangle(0, 0, listRect.width + 1, listRect.height + 1); - break; - case SWT.Close: - event.doit = false; - dropDown (false); - break; - case SWT.Deactivate: - dropDown (false); - break; - } -} -public void redraw () { - super.redraw(); - text.redraw(); - arrow.redraw(); - if (popup.isVisible()) list.redraw(); -} -public void redraw (int x, int y, int width, int height, boolean all) { - super.redraw(x, y, width, height, true); -} - -/** - * Removes the item from the receiver's list at the given - * zero-relative index. - * - * @param index the index for the item - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li> - * </ul> - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public void remove (int index) { - checkWidget(); - list.remove (index); -} -/** - * Removes the items from the receiver's list which are - * between the given zero-relative start and end - * indices (inclusive). - * - * @param start the start of the range - * @param end the end of the range - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</li> - * </ul> - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public void remove (int start, int end) { - checkWidget(); - list.remove (start, end); -} -/** - * Searches the receiver's list starting at the first item - * until an item is found that is equal to the argument, - * and removes that item from the list. - * - * @param string the item to remove - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the string is null</li> - * <li>ERROR_INVALID_ARGUMENT - if the string is not found in the list</li> - * </ul> - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public void remove (String string) { - checkWidget(); - if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); - list.remove (string); -} -/** - * Removes all of the items from the receiver's list and clear the - * contents of receiver's text field. - * <p> - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public void removeAll () { - checkWidget(); - text.setText (""); //$NON-NLS-1$ - list.removeAll (); -} -/** - * Removes the listener from the collection of listeners who will - * be notified when the receiver's text is modified. - * - * @param listener the listener which should no longer be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see ModifyListener - * @see #addModifyListener - */ -public void removeModifyListener (ModifyListener listener) { - checkWidget(); - if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); - removeListener(SWT.Modify, listener); -} -/** - * Removes the listener from the collection of listeners who will - * be notified when the receiver's selection changes. - * - * @param listener the listener which should no longer be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see SelectionListener - * @see #addSelectionListener - */ -public void removeSelectionListener (SelectionListener listener) { - checkWidget(); - if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); - removeListener(SWT.Selection, listener); - removeListener(SWT.DefaultSelection,listener); -} -/** - * Selects the item at the given zero-relative index in the receiver's - * list. If the item at the index was already selected, it remains - * selected. Indices that are out of range are ignored. - * - * @param index the index of the item to select - * - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public void select (int index) { - checkWidget(); - if (index == -1) { - list.deselectAll (); - text.setText (""); //$NON-NLS-1$ - return; - } - if (0 <= index && index < list.getItemCount()) { - if (index != getSelectionIndex()) { - text.setText (list.getItem (index)); - text.selectAll (); - list.select (index); - list.showSelection (); - } - } -} -public void setBackground (Color color) { - super.setBackground(color); - background = color; - if (text != null) text.setBackground(color); - if (list != null) list.setBackground(color); - if (arrow != null) arrow.setBackground(color); -} -/** - * Sets the editable state. - * - * @param editable the new editable state - * - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @since 3.0 - */ -public void setEditable (boolean editable) { - checkWidget (); - text.setEditable(editable); -} -public void setEnabled (boolean enabled) { - super.setEnabled(enabled); - if (popup != null) popup.setVisible (false); - if (text != null) text.setEnabled(enabled); - if (arrow != null) arrow.setEnabled(enabled); -} -public boolean setFocus () { - checkWidget(); - return text.setFocus (); -} -public void setFont (Font font) { - super.setFont (font); - this.font = font; - text.setFont (font); - list.setFont (font); - internalLayout (true); -} -public void setForeground (Color color) { - super.setForeground(color); - foreground = color; - if (text != null) text.setForeground(color); - if (list != null) list.setForeground(color); - if (arrow != null) arrow.setForeground(color); -} -/** - * Sets the text of the item in the receiver's list at the given - * zero-relative index to the string argument. This is equivalent - * to <code>remove</code>'ing the old item at the index, and then - * <code>add</code>'ing the new item at that index. - * - * @param index the index for the item - * @param string the new text for the item - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li> - * <li>ERROR_NULL_ARGUMENT - if the string is null</li> - * </ul> - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public void setItem (int index, String string) { - checkWidget(); - list.setItem (index, string); -} -/** - * Sets the receiver's list to be the given array of items. - * - * @param items the array of items - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the items array is null</li> - * <li>ERROR_INVALID_ARGUMENT - if an item in the items array is null</li> - * </ul> - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public void setItems (String [] items) { - checkWidget (); - list.setItems (items); - if (!text.getEditable ()) text.setText (""); //$NON-NLS-1$ -} -/** - * Sets the layout which is associated with the receiver to be - * the argument which may be null. - * <p> - * Note: No Layout can be set on this Control because it already - * manages the size and position of its children. - * </p> - * - * @param layout the receiver's new layout or null - * - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public void setLayout (Layout layout) { - checkWidget (); - return; -} -public void setMenu(Menu menu) { - text.setMenu(menu); -} -/** - * Sets the selection in the receiver's text field to the - * range specified by the argument whose x coordinate is the - * start of the selection and whose y coordinate is the end - * of the selection. - * - * @param selection a point representing the new selection start and end - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the point is null</li> - * </ul> - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public void setSelection (Point selection) { - checkWidget(); - if (selection == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); - text.setSelection (selection.x, selection.y); -} - -/** - * Sets the contents of the receiver's text field to the - * given string. - * <p> - * Note: The text field in a <code>Combo</code> is typically - * only capable of displaying a single line of text. Thus, - * setting the text to a string containing line breaks or - * other special characters will probably cause it to - * display incorrectly. - * </p> - * - * @param string the new text - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the string is null</li> - * </ul> - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public void setText (String string) { - checkWidget(); - if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); - int index = list.indexOf (string); - if (index == -1) { - list.deselectAll (); - text.setText (string); - return; - } - text.setText (string); - text.selectAll (); - list.setSelection (index); - list.showSelection (); -} -/** - * Sets the maximum number of characters that the receiver's - * text field is capable of holding to be the argument. - * - * @param limit new text limit - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_CANNOT_BE_ZERO - if the limit is zero</li> - * </ul> - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public void setTextLimit (int limit) { - checkWidget(); - text.setTextLimit (limit); -} - -public void setToolTipText (String string) { - checkWidget(); - super.setToolTipText(string); - arrow.setToolTipText (string); - text.setToolTipText (string); -} - -public void setVisible (boolean visible) { - super.setVisible(visible); - if (!visible) popup.setVisible(false); -} -/** - * Sets the number of items that are visible in the drop - * down portion of the receiver's list. - * - * @param count the new number of items to be visible - * - * @exception org.eclipse.swt.SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @since 3.0 - */ -public void setVisibleItemCount (int count) { - checkWidget (); - if (count < 0) return; - visibleItemCount = count; -} -String stripMnemonic (String string) { - int index = 0; - int length = string.length (); - do { - while ((index < length) && (string.charAt (index) != '&')) index++; - if (++index >= length) return string; - if (string.charAt (index) != '&') { - return string.substring(0, index-1) + string.substring(index, length); - } - index++; - } while (index < length); - return string; -} -void textEvent (Event event) { - switch (event.type) { - case SWT.FocusIn: { - handleFocus (SWT.FocusIn); - break; - } - case SWT.KeyDown: { - if (event.character == SWT.CR) { - dropDown (false); - Event e = new Event (); - e.time = event.time; - e.stateMask = event.stateMask; - notifyListeners (SWT.DefaultSelection, e); - } - //At this point the widget may have been disposed. - // If so, do not continue. - if (isDisposed ()) break; - - if (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN) { - event.doit = false; - if ((event.stateMask & SWT.ALT) != 0) { - boolean dropped = isDropped (); - text.selectAll (); - if (!dropped) setFocus (); - dropDown (!dropped); - break; - } - - int oldIndex = getSelectionIndex (); - if (event.keyCode == SWT.ARROW_UP) { - select (Math.max (oldIndex - 1, 0)); - } else { - select (Math.min (oldIndex + 1, getItemCount () - 1)); - } - if (oldIndex != getSelectionIndex ()) { - Event e = new Event(); - e.time = event.time; - e.stateMask = event.stateMask; - notifyListeners (SWT.Selection, e); - } - //At this point the widget may have been disposed. - // If so, do not continue. - if (isDisposed ()) break; - } - - // Further work : Need to add support for incremental search in - // pop up list as characters typed in text widget - - Event e = new Event (); - e.time = event.time; - e.character = event.character; - e.keyCode = event.keyCode; - e.stateMask = event.stateMask; - notifyListeners (SWT.KeyDown, e); - break; - } - case SWT.KeyUp: { - Event e = new Event (); - e.time = event.time; - e.character = event.character; - e.keyCode = event.keyCode; - e.stateMask = event.stateMask; - notifyListeners (SWT.KeyUp, e); - break; - } - case SWT.MenuDetect: { - Event e = new Event (); - e.time = event.time; - notifyListeners (SWT.MenuDetect, e); - break; - } - case SWT.Modify: { - list.deselectAll (); - Event e = new Event (); - e.time = event.time; - notifyListeners (SWT.Modify, e); - break; - } - case SWT.MouseDown: { - if (event.button != 1) return; - if (text.getEditable ()) return; - boolean dropped = isDropped (); - text.selectAll (); - if (!dropped) setFocus (); - dropDown (!dropped); - break; - } - case SWT.MouseUp: { - if (event.button != 1) return; - if (text.getEditable ()) return; - text.selectAll (); - break; - } - case SWT.Traverse: { - switch (event.detail) { - case SWT.TRAVERSE_RETURN: - case SWT.TRAVERSE_ARROW_PREVIOUS: - case SWT.TRAVERSE_ARROW_NEXT: - // The enter causes default selection and - // the arrow keys are used to manipulate the list contents so - // do not use them for traversal. - event.doit = false; - break; - } - - Event e = new Event (); - e.time = event.time; - e.detail = event.detail; - e.doit = event.doit; - e.character = event.character; - e.keyCode = event.keyCode; - notifyListeners (SWT.Traverse, e); - event.doit = e.doit; - event.detail = e.detail; - break; - } - } -} -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/IAnnotationProvider.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/IAnnotationProvider.java deleted file mode 100644 index 226d4357d8..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/IAnnotationProvider.java +++ /dev/null @@ -1,17 +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.design; - -public interface IAnnotationProvider -{ - String getNameAnnotationString(); - String getNameAnnotationToolTipString(); -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/IKeyboardDrag.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/IKeyboardDrag.java deleted file mode 100644 index fe069207d2..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/IKeyboardDrag.java +++ /dev/null @@ -1,19 +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.design; - -import org.eclipse.gef.GraphicalEditPart; - -public interface IKeyboardDrag { - - public void performKeyboardDrag (GraphicalEditPart source, int direction); - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/ImageOverlayDescriptor.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/ImageOverlayDescriptor.java deleted file mode 100644 index 0f2a674073..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/ImageOverlayDescriptor.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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.design; - -import org.eclipse.jface.resource.CompositeImageDescriptor; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.ImageData; -import org.eclipse.swt.graphics.Point; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; - -public class ImageOverlayDescriptor extends CompositeImageDescriptor -{ - protected Image baseImage; - protected Image extensionOverlay, disabledExtensionOverlay; - protected Point imageSize; - protected boolean isReadOnly; - - public ImageOverlayDescriptor(Image baseImage, boolean isReadOnly) - { - super(); - this.baseImage = baseImage; - this.isReadOnly = isReadOnly; - imageSize = new Point(baseImage.getBounds().width, baseImage.getBounds().height); - extensionOverlay = XSDEditorPlugin.getPlugin().getIcon("ovr16/extnsn_ovr.gif"); //$NON-NLS-1$ - disabledExtensionOverlay = XSDEditorPlugin.getPlugin().getIcon("ovr16/extnsndis_ovr.gif"); //$NON-NLS-1$ - } - - public Image getImage() - { - return createImage(); - } - - protected void drawCompositeImage(int width, int height) - { - drawImage(baseImage.getImageData(), 0, 0); - ImageData extensionImageData; - if (isReadOnly) - { - extensionImageData = disabledExtensionOverlay.getImageData(); - } - else - { - extensionImageData = extensionOverlay.getImageData(); - } - drawImage (extensionImageData, imageSize.x - extensionImageData.width, 0); // Top Right corner - } - - protected Point getSize() - { - return imageSize; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/directedit/ADTComboBoxCellEditor.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/directedit/ADTComboBoxCellEditor.java deleted file mode 100644 index 717c7aec22..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/directedit/ADTComboBoxCellEditor.java +++ /dev/null @@ -1,268 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2010 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.design.directedit; - -import java.text.MessageFormat; - -import org.eclipse.jface.viewers.ComboBoxCellEditor; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.events.FocusAdapter; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.TraverseEvent; -import org.eclipse.swt.events.TraverseListener; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.TypedListener; -import org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager; -import org.eclipse.wst.xsd.ui.internal.adt.edit.IComponentDialog; -import org.eclipse.wst.xsd.ui.internal.editor.Messages; - -/* - * This wraps the ComboBoxCellEditor. - * We need to apply and deactivate the combo on a single click (not on a double click like - * the ComboBoxCellEditor). - */ -public class ADTComboBoxCellEditor extends ComboBoxCellEditor -{ - private static final int adtDefaultStyle = SWT.NONE; - - /** - * Used to determine if the value should be applied to the cell. - */ - private boolean continueApply; - private boolean isTraversing = false; - private Object selectedValue; - private ComponentReferenceEditManager componentReferenceEditManager; - - // This prevents the cell editor from being deactivated while handling the New or Browse selection. - private boolean isHandlingSelection = false; - - /** - * Creates a new cell editor with a combo containing the given list of choices - * and parented under the given control. The cell editor value is the - * zero-based index of the selected item. Initially, the cell editor has no - * cell validator and the first item in the list is selected. - * - * @param parent - * the parent control - * @param items - * the list of strings for the combo box - */ - public ADTComboBoxCellEditor(Composite parent, String[] items, ComponentReferenceEditManager editManager) - { - super(parent, items, adtDefaultStyle | SWT.READ_ONLY); - setItems(items); - componentReferenceEditManager = editManager; - } - - private void removeListeners(CCombo comboBox, int event) - { - Listener [] listeners = comboBox.getListeners(event); - int length = listeners.length; - for (int i = 0; i < length; i++) - { - Listener l = listeners[i]; - if (l instanceof TypedListener) - { - TypedListener typedListener = (TypedListener)l; - String className = typedListener.getEventListener().getClass().getCanonicalName(); - // It's possible that there are other typed listeners added to the CCombo. - // Currently there are none, but as an extra check, I want to ensure - // I'm removing the ones added from the inherited class. - // I've tested this and I know it removes the following: - // org.eclipse.jface.viewers.ComboBoxCellEditor$2 - // org.eclipse.jface.viewers.ComboBoxCellEditor$4 - // which are indeed the ones I'm customizing - if (className != null && className.contains("org.eclipse.jface.viewers.ComboBoxCellEditor")) - { - comboBox.removeListener(event, l); - } - } - } - } - - /* - * (non-Javadoc) Method declared on CellEditor. - */ - protected Control createControl(Composite parent) - { - CCombo comboBox = (CCombo)super.createControl(parent); - - comboBox.setFont(parent.getFont()); - - // Need to remove the listeners added from ComboBoxCellEditor - removeListeners(comboBox, SWT.Selection); - removeListeners(comboBox, SWT.DefaultSelection); - removeListeners(comboBox, SWT.FocusIn); - removeListeners(comboBox, SWT.FocusOut); - - // Now add our custom listeners - comboBox.addSelectionListener(new SelectionAdapter() - { - public void widgetDefaultSelected(SelectionEvent event) - { - // Want the same behaviour since hitting return on Browse or New should launch the dialogs, - // and not immediately apply the value -// applyEditorValueAndDeactivate(); - widgetSelected(event); - } - - public void widgetSelected(SelectionEvent event) - { - continueApply = true; - CCombo comboBox = getCCombo(); - isHandlingSelection = true; - Object newValue = null; - - try - { - int selection = comboBox.getSelectionIndex(); - if (isTraversing) - { - isTraversing = false; - return; - } - - String[] items = getItems(); - String stringSelection = items[selection]; - - if (stringSelection.equals(Messages._UI_COMBO_BROWSE)) - { - continueApply = true; - newValue = invokeDialog(componentReferenceEditManager.getBrowseDialog()); - } - else if (stringSelection.equals(Messages._UI_COMBO_NEW)) - { - continueApply = true; - newValue = invokeDialog(componentReferenceEditManager.getNewDialog()); - } - } - finally - { - isHandlingSelection = false; - } - - if (continueApply) - { - if (newValue == null) - { - int index = comboBox.getSelectionIndex(); - if (index != -1) - { - selectedValue = comboBox.getItem(index); - } - } - else - { - selectedValue = newValue; - } - - applyEditorValueAndDeactivate(); - focusLost(); - } - } - }); - - comboBox.addTraverseListener(new TraverseListener() - { - public void keyTraversed(TraverseEvent e) - { - if (e.detail == SWT.TRAVERSE_ARROW_NEXT || e.detail == SWT.TRAVERSE_ARROW_PREVIOUS) - { - isTraversing = true; - } - } - }); - - comboBox.addFocusListener(new FocusAdapter() - { - public void focusLost(FocusEvent e) - { - if (!isHandlingSelection) - ADTComboBoxCellEditor.this.focusLost(); - } - }); - return comboBox; - } - - private Object invokeDialog(IComponentDialog dialog) - { - Object newValue = null; - - if (dialog == null) - { - return null; - } - - //dialog.setInitialComponent(setObject); - if (dialog.createAndOpen() == Window.OK) - { - newValue = dialog.getSelectedComponent(); - } - else - { - continueApply = false; - focusLost(); - } - - return newValue; - } - - public Object getSelectedValue() - { - return selectedValue; - } - - protected CCombo getCCombo() - { - return (CCombo)getControl(); - } - -///////// ComboBox cell editor - - void applyEditorValueAndDeactivate() - { - // must set the selection before getting value - CCombo comboBox = getCCombo(); - String[] items = getItems(); - - int selection = comboBox.getSelectionIndex(); - Object newValue = doGetValue(); - markDirty(); - boolean isValid = isCorrect(newValue); - setValueValid(isValid); - - if (!isValid) - { - // Only format if the 'index' is valid - if (items.length > 0 && selection >= 0 && selection < items.length) - { - // try to insert the current value into the error message. - setErrorMessage(MessageFormat.format(getErrorMessage(), new Object[] { items[selection] })); - } - else - { - // Since we don't have a valid index, assume we're using an - // 'edit' - // combo so format using its text value - setErrorMessage(MessageFormat.format(getErrorMessage(), new Object[] { comboBox.getText() })); - } - } - - fireApplyEditorValue(); - deactivate(); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/directedit/AttributeReferenceDirectEditManager.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/directedit/AttributeReferenceDirectEditManager.java deleted file mode 100644 index 2b5e2722b3..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/directedit/AttributeReferenceDirectEditManager.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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.design.directedit; - -import org.eclipse.draw2d.Label; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IField; -import org.eclipse.wst.xsd.ui.internal.editor.XSDAttributeReferenceEditManager; - -public class AttributeReferenceDirectEditManager extends ReferenceDirectEditManager -{ - public AttributeReferenceDirectEditManager(IField parameter, AbstractGraphicalEditPart source, Label label) - { - super(parameter, source, label); - } - - protected ComponentReferenceEditManager getComponentReferenceEditManager() - { - ComponentReferenceEditManager result = null; - IEditorPart editor = getActiveEditor(); - if (editor != null) - { - result = (ComponentReferenceEditManager)editor.getAdapter(XSDAttributeReferenceEditManager.class); - } - return result; - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/directedit/ComboBoxCellEditorManager.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/directedit/ComboBoxCellEditorManager.java deleted file mode 100644 index c840f2199e..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/directedit/ComboBoxCellEditorManager.java +++ /dev/null @@ -1,224 +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.design.directedit; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.tools.CellEditorLocator; -import org.eclipse.gef.tools.DirectEditManager; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ComboBoxCellEditor; -import org.eclipse.jface.viewers.ICellEditorListener; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; - -public abstract class ComboBoxCellEditorManager extends DirectEditManager// implements - // DirectEditPolicyDelegate -{ - protected Label label; - - public ComboBoxCellEditorManager(GraphicalEditPart source, Label label) - { - super(source, ComboBoxCellEditor.class, new InternalCellEditorLocator(label)); - this.label = label; - } - - protected void initCellEditor() - { - String initialLabelText = label.getText(); - - CCombo combo = (CCombo) getCellEditor().getControl(); - combo.setFont(label.getFont()); - combo.setForeground(label.getForegroundColor()); - combo.setBackground(label.getBackgroundColor()); - combo.setVisibleItemCount(20); - - /* - * combo.addKeyListener(new KeyAdapter() { // hook key pressed - see PR - * 14201 public void keyPressed(KeyEvent keyEvent) { if (keyEvent.character == - * 'z') { getCellEditor().applyEditorValue(); } } }); - */ - ICellEditorListener cellEditorListener = new ICellEditorListener() - { - public void cancelEditor() - { - } - - public void applyEditorValue() - { - } - - public void editorValueChanged(boolean old, boolean newState) - { - } - }; - getCellEditor().addListener(cellEditorListener); - - String[] item = combo.getItems(); - for (int i = 0; i < item.length; i++) - { - if (item[i].equals(initialLabelText)) - { - getCellEditor().setValue(new Integer(i)); - break; - } - } - } - - // hack... for some reason the ComboBoxCellEditor does't fire an - // editorValueChanged to set the dirty flag - // unless we overide this method to return true, the manager is not notified - // of changes made in the cell editor - protected boolean isDirty() - { - return true; - } - - protected CellEditor createCellEditorOn(Composite composite) - { - boolean isLabelTextInList = false; - List list = computeComboContent(); - for (Iterator i = list.iterator(); i.hasNext();) - { - String string = (String) i.next(); - if (string.equals(label.getText())) - { - isLabelTextInList = true; - break; - } - } - - if (!isLabelTextInList) - { - list.add(label.getText()); - } - - List sortedList = computeSortedList(list); - String[] stringArray = new String[sortedList.size()]; - for (int i = 0; i < stringArray.length; i++) - { - stringArray[i] = (String) sortedList.get(i); - } - return createCellEditor(composite, stringArray); - } - - protected CellEditor createCellEditor(Composite composite, String[] stringArray) - { - return new ComboBoxCellEditor(composite, stringArray); - } - - protected List computeSortedList(List list) - { - return list; - } - - protected abstract List computeComboContent(); - - protected abstract void performModify(Object value); - - public static class InternalCellEditorLocator implements CellEditorLocator - { - protected Label label; - - public InternalCellEditorLocator(Label label) - { - this.label = label; - } - - public void relocate(CellEditor celleditor) - { - CCombo combo = (CCombo) celleditor.getControl(); - - // TODO: We're pulling a fast one here..... This is assuming we're using a - // CCombo as our widget - // Our eventual 'Combo' may not even use CCombo so this will most likely - // get replaced. - // int dropDownButtonSizeX = 16; - - Rectangle labelParentBounds = label.getBounds().getCopy(); - label.translateToAbsolute(labelParentBounds); - - int x = labelParentBounds.x; - int y = labelParentBounds.y; - int widthK = labelParentBounds.width; - int height = labelParentBounds.height; - combo.setBounds(x, y + 1, widthK, height - 2); - } - } - - // implements DirectEditPolicyDelegate - // - public void performEdit(CellEditor cellEditor) - { - ADTComboBoxCellEditor comboCellEditor = (ADTComboBoxCellEditor) cellEditor; - CCombo combo = (CCombo) getCellEditor().getControl(); - int index = combo.getSelectionIndex(); - if (index != -1) - { - Object value = combo.getItem(index); - if (comboCellEditor.getSelectedValue() != null) - { - value = comboCellEditor.getSelectedValue(); - } - - performModify(value); - } - else - { - String typedValue = combo.getText(); - if (combo.indexOf(typedValue) != -1) - { - performModify(typedValue); - } - else - { - String closeMatch = getCloseMatch(typedValue, combo.getItems()); - if (closeMatch != null) - { - performModify(closeMatch); - } - else - { - Display.getCurrent().beep(); - } - } - } - } - - protected String getCloseMatch(String value, String[] items) - { - int matchIndex = -1; - - for (int i = 0; i < items.length; i++) - { - String item = items[i]; - String a = getLocalName(value); - String b = getLocalName(item); - if (a.equalsIgnoreCase(b)) - { - matchIndex = i; - break; - } - } - return matchIndex != -1 ? items[matchIndex] : null; - } - - protected String getLocalName(String string) - { - int index = string.indexOf(":"); //$NON-NLS-1$ - return (index != -1) ? string.substring(index + 1) : string; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/directedit/ElementReferenceDirectEditManager.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/directedit/ElementReferenceDirectEditManager.java deleted file mode 100644 index 54117a2b10..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/directedit/ElementReferenceDirectEditManager.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 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.design.directedit; - -import org.eclipse.draw2d.Label; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IField; -import org.eclipse.wst.xsd.ui.internal.editor.XSDElementReferenceEditManager; - -public class ElementReferenceDirectEditManager extends ReferenceDirectEditManager -{ - public ElementReferenceDirectEditManager(IField parameter, AbstractGraphicalEditPart source, Label label) - { - super(parameter, source, label); - } - - protected ComponentReferenceEditManager getComponentReferenceEditManager() - { - ComponentReferenceEditManager result = null; - IEditorPart editor = getActiveEditor(); - if (editor != null) - { - result = (ComponentReferenceEditManager)editor.getAdapter(XSDElementReferenceEditManager.class); - } - return result; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/directedit/LabelCellEditorLocator.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/directedit/LabelCellEditorLocator.java deleted file mode 100644 index 0b34f8e404..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/directedit/LabelCellEditorLocator.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.design.directedit; - -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.tools.CellEditorLocator; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.swt.widgets.Text; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.INamedEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.design.figures.IFieldFigure; - -public class LabelCellEditorLocator implements CellEditorLocator -{ - protected INamedEditPart namedEditPart; - protected Point cursorLocation; - - public LabelCellEditorLocator(INamedEditPart namedEditPart, Point cursorLocation) - { - this.namedEditPart = namedEditPart; - this.cursorLocation = cursorLocation; - } - - public void relocate(CellEditor celleditor) - { - Text text = (Text) celleditor.getControl(); - - Label label = namedEditPart.getNameLabelFigure(); - if (text.getBounds().x <= 0) - { - int widthToRemove = 0; - // HACK - if (namedEditPart instanceof BaseFieldEditPart) - { - BaseFieldEditPart field = (BaseFieldEditPart)namedEditPart; - IFieldFigure fieldFigure = field.getFieldFigure(); - widthToRemove = fieldFigure.getTypeLabel().getBounds().width; - //TODO: !! perhaps the IFieldFigure should just have a method to compute this? - //Label typeAnnotationLabel = ((FieldFigure) field.getFigure()).getTypeAnnotationLabel(); - //Label nameAnnotationLabel = ((FieldFigure) field.getFigure()).getNameAnnotationLabel(); - //widthToRemove = typeLabel.getBounds().width + typeAnnotationLabel.getBounds().width + nameAnnotationLabel.getBounds().width; - } - - Rectangle boundingRect = label.getTextBounds(); - - // Reduce the width by the amount we shifted along the x-axis - int delta = Math.abs(boundingRect.x - label.getParent().getBounds().x); - - label.getParent().translateToAbsolute(boundingRect); - org.eclipse.swt.graphics.Rectangle trim = text.computeTrim(0, 0, 0, 0); - boundingRect.translate(trim.x, trim.y); - boundingRect.height = boundingRect.height - trim.y; - - boundingRect.width = label.getParent().getBounds().width - delta - widthToRemove; - text.setBounds(boundingRect.x, boundingRect.y, boundingRect.width, boundingRect.height); - - // Translate point - if (cursorLocation != null) { - Point translatedPoint = new Point(cursorLocation.x - boundingRect.x, cursorLocation.y - boundingRect.y); - - // Calculate text offset corresponding to the translated point - text.setSelection(0, 0); - int xCaret = text.getCaretLocation().x; - int offset = text.getCaretPosition(); - while (xCaret < translatedPoint.x) - { - text.setSelection(offset + 1, offset + 1); - xCaret = text.getCaretLocation().x; - int newOffset = text.getCaretPosition(); - if (newOffset == offset) - { - break; - } - offset++; - } - text.setSelection(offset, offset); - } - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/directedit/LabelEditManager.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/directedit/LabelEditManager.java deleted file mode 100644 index 884341acae..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/directedit/LabelEditManager.java +++ /dev/null @@ -1,150 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 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.design.directedit; - -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.tools.CellEditorLocator; -import org.eclipse.gef.tools.DirectEditManager; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.TextCellEditor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.part.CellEditorActionHandler; -import org.eclipse.wst.xsd.ui.internal.adt.actions.BaseSelectionAction; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.INamedEditPart; - -public class LabelEditManager extends DirectEditManager { - - private IActionBars actionBars; - private CellEditorActionHandler actionHandler; - private IAction copy, cut, paste, undo, redo, find, selectAll, delete; - private Font scaledFont; - - public LabelEditManager(GraphicalEditPart source, CellEditorLocator locator) { - super(source, null, locator); - } - - /** - * @see org.eclipse.gef.tools.DirectEditManager#bringDown() - */ - protected void bringDown() { - if (actionHandler != null) { - actionHandler.dispose(); - actionHandler = null; - } - if (actionBars != null) { - restoreSavedActions(actionBars); - actionBars.updateActionBars(); - actionBars = null; - } - - Font disposeFont = scaledFont; - scaledFont = null; - super.bringDown(); - if (disposeFont != null) - disposeFont.dispose(); - } - - public void showFeedback() { -// super.showFeedback(); - getEditPart().showSourceFeedback(getDirectEditRequest()); - } - - protected CellEditor createCellEditorOn(Composite composite) { - return new TextCellEditor(composite, SWT.SINGLE | SWT.WRAP); - } - - protected void initCellEditor() { - Text text = (Text)getCellEditor().getControl(); - Label label = ((INamedEditPart) getEditPart()).getNameLabelFigure(); - - if (label != null) { - scaledFont = label.getFont(); - - Color color = label.getBackgroundColor(); - text.setBackground(color); - - String initialLabelText = label.getText(); - getCellEditor().setValue(initialLabelText); - } - else { - scaledFont = label.getParent().getFont(); - text.setBackground(label.getParent().getBackgroundColor()); - } - - FontData data = scaledFont.getFontData()[0]; - Dimension fontSize = new Dimension(0, data.getHeight()); - label.getParent().translateToAbsolute(fontSize); - data.setHeight(fontSize.height); - scaledFont = new Font(null, data); - - text.setFont(scaledFont); -// text.selectAll(); - - // Hook the cell editor's copy/paste actions to the actionBars so that they can - // be invoked via keyboard shortcuts. - actionBars = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() - .getActiveEditor().getEditorSite().getActionBars(); - saveCurrentActions(actionBars); - actionHandler = new CellEditorActionHandler(actionBars); - actionHandler.addCellEditor(getCellEditor()); - actionBars.updateActionBars(); - } - - private void restoreSavedActions(IActionBars actionBars){ - actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copy); - actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), paste); - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=252509 - // Delete action (key) doesn't always work. The saved action could be the - // CellEditorActionHandler's DeleteActionHandler...due to timing issues. - // We'll only restore the delete action if it is indeed the one for the Design view. - // We should update the other actions too, but currently, none are applicable. - if (delete instanceof BaseSelectionAction) - { - actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), delete); - } - actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), selectAll); - actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), cut); - actionBars.setGlobalActionHandler(ActionFactory.FIND.getId(), find); - actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), undo); - actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), redo); - } - - private void saveCurrentActions(IActionBars actionBars) { - copy = actionBars.getGlobalActionHandler(ActionFactory.COPY.getId()); - paste = actionBars.getGlobalActionHandler(ActionFactory.PASTE.getId()); - IAction currentDeleteAction = actionBars.getGlobalActionHandler(ActionFactory.DELETE.getId()); - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=252509 - // Delete action (key) doesn't always work. The saved action could be the - // CellEditorActionHandler's DeleteActionHandler...due to timing issues. - // We'll only restore the delete action if it is indeed the one for the Design view. - // We should update the other actions too, but currently, none are applicable. - if (currentDeleteAction instanceof BaseSelectionAction) - { - delete = currentDeleteAction; - } - selectAll = actionBars.getGlobalActionHandler(ActionFactory.SELECT_ALL.getId()); - cut = actionBars.getGlobalActionHandler(ActionFactory.CUT.getId()); - find = actionBars.getGlobalActionHandler(ActionFactory.FIND.getId()); - undo = actionBars.getGlobalActionHandler(ActionFactory.UNDO.getId()); - redo = actionBars.getGlobalActionHandler(ActionFactory.REDO.getId()); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/directedit/ReferenceDirectEditManager.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/directedit/ReferenceDirectEditManager.java deleted file mode 100644 index 7ced90db3c..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/directedit/ReferenceDirectEditManager.java +++ /dev/null @@ -1,180 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.design.directedit; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.draw2d.Label; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification; -import org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager; -import org.eclipse.wst.xsd.ui.internal.editor.Messages; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IField; - -public abstract class ReferenceDirectEditManager extends ComboBoxCellEditorManager -{ - protected AbstractGraphicalEditPart editPart; - protected IField setObject; - - public ReferenceDirectEditManager(IField parameter, AbstractGraphicalEditPart source, Label label) - { - super(source, label); - editPart = source; - setObject = parameter; - } - - protected CellEditor createCellEditorOn(Composite composite) - { - return super.createCellEditorOn(composite); - } - - protected List computeComboContent() - { - List list = new ArrayList(); - ComponentReferenceEditManager editManager = getComponentReferenceEditManager(); - if (editManager != null) - { - list.add(Messages._UI_COMBO_BROWSE); - list.add(Messages._UI_COMBO_NEW); - ComponentSpecification[] quickPicks = editManager.getQuickPicks(); - if (quickPicks != null) - { - for (int i=0; i < quickPicks.length; i++) - { - ComponentSpecification componentSpecification = quickPicks[i]; - list.add(componentSpecification.getName()); - } - } - ComponentSpecification[] history = editManager.getHistory(); - if (history != null) - { - for (int i=0; i < history.length; i++) - { - ComponentSpecification componentSpecification = history[i]; - list.add(componentSpecification.getName()); - } - } - } - return list; - } - - protected ComponentSpecification getComponentSpecificationForValue(String value) - { - ComponentReferenceEditManager editManager = getComponentReferenceEditManager(); - if (editManager != null) - { - ComponentSpecification[] quickPicks = editManager.getQuickPicks(); - if (quickPicks != null) - { - for (int i=0; i < quickPicks.length; i++) - { - ComponentSpecification componentSpecification = quickPicks[i]; - if (value.equals(componentSpecification.getName())) - { - return componentSpecification; - } - } - } - ComponentSpecification[] history = editManager.getHistory(); - if (history != null) - { - for (int i=0; i < history.length; i++) - { - ComponentSpecification componentSpecification = history[i]; - if (value.equals(componentSpecification.getName())) - { - return componentSpecification; - } - } - } - } - return null; - } - - public void performModify(Object value) - { - ComponentReferenceEditManager editManager = getComponentReferenceEditManager(); - if (editManager == null) - { - return; - } - - // our crude combo box can only work with 'String' objects - // if we get a String back we need to do some clever mapping to get the ComponentSpecification - // - if (value instanceof String) - { - value = getComponentSpecificationForValue((String)value); - } - // we assume the selected value is always of the form of a ComponentSpecification - // - if (value instanceof ComponentSpecification) - { - // we need to perform an asyncExec here since the 'host' editpart may be - // removed as a side effect of performing the action - DelayedSetReferenceRunnable runnable = new DelayedSetReferenceRunnable(editManager, setObject, (ComponentSpecification)value); - //runnable.run(); - Display.getCurrent().asyncExec(runnable); - } - } - - protected List computeSortedList(List list) - { - // return TypesHelper.sortList(list); - return list; - } - - protected CellEditor createCellEditor(Composite composite, String[] stringArray) - { - ADTComboBoxCellEditor cellEditor = new ADTComboBoxCellEditor(composite, stringArray, getComponentReferenceEditManager()); - //((ADTComboBoxCellEditor) cellEditor).setObjectToModify(setObject); - return cellEditor; - } - - protected abstract ComponentReferenceEditManager getComponentReferenceEditManager(); - - protected IEditorPart getActiveEditor() - { - IWorkbench workbench = PlatformUI.getWorkbench(); - IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - IEditorPart editorPart = workbenchWindow.getActivePage().getActiveEditor(); - return editorPart; - } - - protected class DelayedSetReferenceRunnable implements Runnable - { - protected ComponentReferenceEditManager componentReferenceEditManager; - protected ComponentSpecification newValue; - protected IField field; - - public DelayedSetReferenceRunnable(ComponentReferenceEditManager componentReferenceEditManager, - IField setObject, ComponentSpecification selectedValue) - { - this.componentReferenceEditManager = componentReferenceEditManager; - newValue = selectedValue; - field = setObject; - } - - public void run() - { - componentReferenceEditManager.modifyComponentReference(field, newValue); - } - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/directedit/TypeReferenceDirectEditManager.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/directedit/TypeReferenceDirectEditManager.java deleted file mode 100644 index dbebae1ddb..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/directedit/TypeReferenceDirectEditManager.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 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.design.directedit; - -import org.eclipse.draw2d.Label; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager; -import org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager2; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IField; -import org.eclipse.wst.xsd.ui.internal.editor.XSDTypeReferenceEditManager; - -public class TypeReferenceDirectEditManager extends ReferenceDirectEditManager //ComboBoxCellEditorManager -{ - public TypeReferenceDirectEditManager(IField parameter, AbstractGraphicalEditPart source, Label label) - { - super(parameter, source, label); - } - - protected ComponentReferenceEditManager getComponentReferenceEditManager() - { - ComponentReferenceEditManager result = null; - IEditorPart editor = getActiveEditor(); - if (editor != null) - { - result = (ComponentReferenceEditManager)editor.getAdapter(XSDTypeReferenceEditManager.class); - if (result instanceof ComponentReferenceEditManager2) - { - ComponentReferenceEditManager2 manager = (ComponentReferenceEditManager2)result; - manager.setReferencer(setObject); - } - } - return result; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/ADTEditPartFactory.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/ADTEditPartFactory.java deleted file mode 100644 index 26426048ab..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/ADTEditPartFactory.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 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.design.editparts; - -import org.eclipse.draw2d.ToolbarLayout; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPartFactory; -import org.eclipse.jface.util.Assert; -import org.eclipse.wst.xsd.ui.internal.adt.design.ADTFloatingToolbar.ADTFloatingToolbarModel; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.AbstractModelCollection; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.Compartment; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.FocusTypeColumn; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.RootHolder; -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; - -public class ADTEditPartFactory implements EditPartFactory -{ - public EditPart createEditPart(EditPart context, Object model) - { - EditPart child = doCreateEditPart(context, model); - checkChild(child, model); - return child; - } - - protected EditPart doCreateEditPart(EditPart context, Object model) - { - EditPart child = null; - if (model instanceof Compartment) - { - child = new CompartmentEditPart(); - } - else if (model instanceof RootHolder) - { - child = new RootHolderEditPart(); - } - else if (model instanceof ADTFloatingToolbarModel) - { - child = new ADTFloatingToolbarEditPart(((ADTFloatingToolbarModel)model).getModel()); - } - else if (model instanceof AbstractModelCollection) - { - child = new ColumnEditPart(); - if (model instanceof FocusTypeColumn) - { - ColumnEditPart columnEditPart = (ColumnEditPart)child; - columnEditPart.setSpacing(60); - columnEditPart.setMinorAlignment(ToolbarLayout.ALIGN_CENTER); - } - } - else if (model instanceof IComplexType) - { - child = new ComplexTypeEditPart(); - } - else if (model instanceof IStructure) - { - child = new StructureEditPart(); - } - else if (model instanceof IField) - { - if (context instanceof CompartmentEditPart) - { - child = new FieldEditPart(); - } - else - { - child = new TopLevelFieldEditPart(); - } - } - else if (model instanceof IModel) - { - child = new RootContentEditPart(); - } - return child; - } - - /** - * Subclasses can override and not check for null - * - * @param child - * @param model - */ - protected void checkChild(EditPart child, Object model) - { - if (child == null) - { - // Thread.dumpStack(); - } - Assert.isNotNull(child); - child.setModel(model); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/ADTFloatingToolbarEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/ADTFloatingToolbarEditPart.java deleted file mode 100644 index 46b8be98cd..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/ADTFloatingToolbarEditPart.java +++ /dev/null @@ -1,227 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.design.editparts; - -import java.awt.event.KeyEvent; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.Figure; -import org.eclipse.draw2d.FocusEvent; -import org.eclipse.draw2d.FocusListener; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.KeyListener; -import org.eclipse.draw2d.MouseEvent; -import org.eclipse.draw2d.MouseListener; -import org.eclipse.draw2d.MouseMotionListener; -import org.eclipse.draw2d.ToolbarLayout; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.xsd.ui.internal.adt.actions.SetInputToGraphView; -import org.eclipse.wst.xsd.ui.internal.adt.editor.Messages; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel; -import org.eclipse.wst.xsd.ui.internal.design.figures.CenteredIconFigure; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; - -public class ADTFloatingToolbarEditPart extends BaseEditPart -{ - protected IModel model; - protected boolean isDrilledDown; - protected ADTToolbarButton backToSchema; - - public ADTFloatingToolbarEditPart(IModel model) - { - this.model = model; - } - - protected IFigure createFigure() - { - Figure figure = new Figure(); - ToolbarLayout tb = new ToolbarLayout(true); - tb.setStretchMinorAxis(false); - tb.setSpacing(3); - figure.setLayoutManager(tb); - - backToSchema = new ADTToolbarButton(XSDEditorPlugin.getPlugin().getIcon("elcl16/schemaview_co.gif")); - backToSchema.setToolTipText(Messages._UI_HOVER_BACK_TO_SCHEMA); - backToSchema.setBackgroundColor(ColorConstants.white); - backToSchema.setFocusTraversable(true); - figure.add(backToSchema); - figure.setBounds(new Rectangle(0,0,24,24)); - addToToolbar(figure); - return figure; - } - - protected void addToToolbar(IFigure figure) - { - - } - - public void setIsDrilledDown(boolean isDrilledDown) - { - this.isDrilledDown = isDrilledDown; - } - - protected void refreshVisuals() - { - super.refreshVisuals(); - backToSchema.isEnabled = isDrilledDown; - if (isDrilledDown) - { - backToSchema.image = XSDEditorPlugin.getPlugin().getIcon("elcl16/schemaview_co.gif"); - } - else - { - backToSchema.image = XSDEditorPlugin.getPlugin().getIcon("dlcl16/schemaview_co.gif"); - } - backToSchema.refresh(); - } - - protected void doAction(MouseEvent me) - { - IEditorPart editorPart = getActionEditorPart(); - - if (backToSchema.getBounds().contains(me.getLocation())) - { - SetInputToGraphView action = new SetInputToGraphView(editorPart, model); - action.run(); - } - } - - protected void doAction(org.eclipse.draw2d.KeyEvent ke) - { - IEditorPart editorPart = getActionEditorPart(); - SetInputToGraphView action = new SetInputToGraphView(editorPart, model); - action.run(); - } - - private IEditorPart getActionEditorPart() - { - IWorkbench workbench = PlatformUI.getWorkbench(); - IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - IEditorPart editorPart = workbenchWindow.getActivePage().getActiveEditor(); - return editorPart; - } - - - protected class ADTToolbarButton extends CenteredIconFigure - { - protected MouseListener mouseListener; - protected org.eclipse.draw2d.KeyListener keyListener; - protected FocusListener focusListener; - public boolean isEnabled; - - public ADTToolbarButton(Image img) - { - super(); - this.image = img; - - mouseListener = new MouseListener.Stub() - { - public void mousePressed(org.eclipse.draw2d.MouseEvent me) - { - if (isEnabled) - { - addFeedback(); - } - } - - public void mouseReleased(org.eclipse.draw2d.MouseEvent me) - { - if (isEnabled) - { - removeFeedback(); - doAction(me); - } - } - }; - addMouseListener(mouseListener); - addMouseMotionListener(new MouseMotionListener.Stub() - { - public void mouseExited(MouseEvent me) - { - removeFeedback(); - } - }); - - keyListener = new KeyListener.Stub() - { - public void keyPressed(org.eclipse.draw2d.KeyEvent ke) - { - boolean isValidKey = (ke.keycode == KeyEvent.VK_SPACE); - isValidKey = isValidKey || (ke.character == SWT.CR || ke.character == SWT.LF); - if (isEnabled && isValidKey) - { - addFeedback(); - } - } - - public void keyReleased(org.eclipse.draw2d.KeyEvent ke) - { - boolean isValidKey = (ke.keycode == KeyEvent.VK_SPACE); - isValidKey = isValidKey || (ke.character == SWT.CR || ke.character == SWT.LF); - if (isEnabled && isValidKey) - { - removeFeedback(); - doAction(ke); - } - } - }; - addKeyListener(keyListener); - - focusListener = new FocusListener(){ - - public void focusGained(FocusEvent fe) { - setMode(CenteredIconFigure.HOVER); - refresh(); - } - - public void focusLost(FocusEvent fe) { - setMode(CenteredIconFigure.NORMAL); - refresh(); - } - }; - - addFocusListener(focusListener); - } - - public void addFeedback() - { - setMode(CenteredIconFigure.SELECTED); - refresh(); - } - - public void removeFeedback() - { - setMode(CenteredIconFigure.NORMAL); - refresh(); - } - - public Rectangle getBounds() - { - Rectangle r = super.getBounds(); - org.eclipse.swt.graphics.Rectangle rect = image.getBounds(); - return new Rectangle(r.x, r.y, rect.width + 8, rect.height + 8); - } - - public Dimension getPreferredSize(int hint, int hint2) - { - org.eclipse.swt.graphics.Rectangle rect = image.getBounds(); - return new Dimension(rect.width + 8, rect.height + 8); - } - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/BackToSchemaEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/BackToSchemaEditPart.java deleted file mode 100644 index f79ed6ce9a..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/BackToSchemaEditPart.java +++ /dev/null @@ -1,134 +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.design.editparts; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.MouseListener; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.Request; -import org.eclipse.gef.RequestConstants; -import org.eclipse.ui.part.MultiPageEditorPart; -import org.eclipse.wst.xsd.ui.internal.adt.actions.SetInputToGraphView; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IFeedbackHandler; -import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.ADTDirectEditPolicy; -import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.ADTSelectionFeedbackEditPolicy; -import org.eclipse.wst.xsd.ui.internal.adt.editor.ADTMultiPageEditor; -import org.eclipse.wst.xsd.ui.internal.design.figures.CenteredIconFigure; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; - -public class BackToSchemaEditPart extends BaseEditPart implements IFeedbackHandler -{ - protected MultiPageEditorPart multipageEditor; - protected ADTDirectEditPolicy adtDirectEditPolicy = new ADTDirectEditPolicy(); - protected boolean isEnabled; - protected CenteredIconFigure backToSchema; - protected MouseListener mouseListener; - - public BackToSchemaEditPart(ADTMultiPageEditor multipageEditor) - { - super(); - this.multipageEditor = multipageEditor; - } - - protected IFigure createFigure() - { - backToSchema = new CenteredIconFigure(); - backToSchema.setBackgroundColor(ColorConstants.white); - backToSchema.image = XSDEditorPlugin.getPlugin().getIcon("elcl16/schemaview_co.gif"); - // TODO, look at why the editpolicy doesn't work - mouseListener = new MouseListener() - { - public void mouseDoubleClicked(org.eclipse.draw2d.MouseEvent me) - { - - } - - public void mousePressed(org.eclipse.draw2d.MouseEvent me) - { - if (isEnabled) - { - addFeedback(); - } - } - - public void mouseReleased(org.eclipse.draw2d.MouseEvent me) - { - if (isEnabled) - { - removeFeedback(); - SetInputToGraphView action = new SetInputToGraphView(multipageEditor, getModel()); - action.run(); - } - } - }; - backToSchema.addMouseListener(mouseListener); - return backToSchema; - } - - - public void setEnabled(boolean isEnabled) - { - this.isEnabled = isEnabled; - refreshVisuals(); - } - - protected void createEditPolicies() - { - installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, adtDirectEditPolicy); - installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new ADTSelectionFeedbackEditPolicy()); - } - - public void performRequest(Request request) - { - if (request.getType() == RequestConstants.REQ_DIRECT_EDIT || request.getType() == RequestConstants.REQ_OPEN) - { - SetInputToGraphView action = new SetInputToGraphView(multipageEditor, getModel()); - action.run(); - } - } - - protected void refreshVisuals() - { - super.refreshVisuals(); - CenteredIconFigure figure = (CenteredIconFigure) getFigure(); - if (isEnabled) - { - backToSchema.image = XSDEditorPlugin.getPlugin().getIcon("elcl16/schemaview_co.gif"); - } - else - { - backToSchema.image = XSDEditorPlugin.getPlugin().getIcon("dlcl16/schemaview_co.gif"); - } - figure.refresh(); - } - - public void addFeedback() - { - CenteredIconFigure figure = (CenteredIconFigure) getFigure(); - figure.setMode(CenteredIconFigure.SELECTED); - figure.refresh(); - } - - public void removeFeedback() - { - CenteredIconFigure figure = (CenteredIconFigure) getFigure(); - figure.setMode(CenteredIconFigure.NORMAL); - figure.refresh(); - } - - public void deactivate() - { - backToSchema.removeMouseListener(mouseListener); - super.deactivate(); - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/BaseEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/BaseEditPart.java deleted file mode 100644 index 357e63489f..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/BaseEditPart.java +++ /dev/null @@ -1,300 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2010 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.design.editparts; - -import java.util.List; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.AccessibleEditPart; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPartFactory; -import org.eclipse.gef.GraphicalViewer; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; -import org.eclipse.gef.editparts.ScalableRootEditPart; -import org.eclipse.gef.editparts.ZoomListener; -import org.eclipse.gef.editparts.ZoomManager; -import org.eclipse.jface.action.IAction; -import org.eclipse.swt.SWT; -import org.eclipse.swt.accessibility.AccessibleEvent; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.ide.FileStoreEditorInput; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IActionProvider; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IFeedbackHandler; -import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.KeyBoardAccessibilityEditPolicy; -import org.eclipse.wst.xsd.ui.internal.adt.design.figures.IFigureFactory; -import org.eclipse.wst.xsd.ui.internal.adt.editor.CommonMultiPageEditor; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObjectListener; - -public abstract class BaseEditPart extends AbstractGraphicalEditPart implements IActionProvider, IADTObjectListener, IFeedbackHandler -{ - protected static final String[] EMPTY_ACTION_ARRAY = {}; - protected boolean isSelected = false; - protected boolean hasFocus = false; - protected static boolean isHighContrast = Display.getDefault().getHighContrast(); - protected AccessibleEditPart accessiblePart; - - public IFigureFactory getFigureFactory() - { - EditPartFactory factory = getViewer().getEditPartFactory(); - Assert.isTrue(factory instanceof IFigureFactory, "EditPartFactory must be an instanceof of IFigureFactory"); //$NON-NLS-1$ - return (IFigureFactory)factory; - } - - public String[] getActions(Object object) - { - Object model = getModel(); - if (model instanceof IActionProvider) - { - return ((IActionProvider)model).getActions(object); - } - return EMPTY_ACTION_ARRAY; - } - - protected void addActionsToList(List list, IAction[] actions) - { - for (int i = 0; i < actions.length; i++) - { - list.add(actions[i]); - } - } - - public void activate() - { - super.activate(); - Object model = getModel(); - if (model instanceof IADTObject) - { - IADTObject object = (IADTObject)model; - object.registerListener(this); - } - - if (getZoomManager() != null) - getZoomManager().addZoomListener(zoomListener); - - } - - public void deactivate() - { - try - { - Object model = getModel(); - if (model instanceof IADTObject) - { - IADTObject object = (IADTObject)model; - object.unregisterListener(this); - } - - if (getZoomManager() != null) - getZoomManager().removeZoomListener(zoomListener); - } - finally - { - super.deactivate(); - } - } - - public void propertyChanged(Object object, String property) - { - refresh(); - } - - public void refresh() { - - boolean doUpdateDesign = doUpdateDesign(); - if (doUpdateDesign) - { - super.refresh(); - } - } - - public void addFeedback() - { - isSelected = true; - refreshVisuals(); - } - - public void removeFeedback() - { - isSelected = false; - refreshVisuals(); - } - - public ZoomManager getZoomManager() - { - return ((ScalableRootEditPart)getRoot()).getZoomManager(); - } - - public Rectangle getZoomedBounds(Rectangle r) - { - double factor = getZoomManager().getZoom(); - int x = (int)Math.round(r.x * factor); - int y = (int)Math.round(r.y * factor); - int width = (int)Math.round(r.width * factor); - int height = (int)Math.round(r.height * factor); - - return new Rectangle(x, y, width, height); - } - - private ZoomListener zoomListener = new ZoomListener() - { - public void zoomChanged(double zoom) - { - handleZoomChanged(); - } - }; - - protected void handleZoomChanged() - { - refreshVisuals(); - } - - public IEditorPart getEditorPart() - { - IEditorPart editorPart = null; - IWorkbench workbench = PlatformUI.getWorkbench(); - if (workbench != null) - { - IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - if (workbenchWindow != null) - { - if (workbenchWindow.getActivePage() != null) - { - editorPart = workbenchWindow.getActivePage().getActiveEditor(); - } - } - } -// Assert.isNotNull(editorPart); - return editorPart; - } - - protected void createEditPolicies() - { - installEditPolicy(KeyBoardAccessibilityEditPolicy.KEY, new KeyBoardAccessibilityEditPolicy() - { - public EditPart getRelativeEditPart(EditPart editPart, int direction) - { - return doGetRelativeEditPart(editPart, direction); - } - }); - } - - - public EditPart doGetRelativeEditPart(EditPart editPart, int direction) - { - return null; - } - - protected boolean isFileReadOnly() - { - IWorkbench workbench = PlatformUI.getWorkbench(); - if (workbench != null) - { - IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - if (workbenchWindow != null) - { - IWorkbenchPage page = workbenchWindow.getActivePage(); - if (page != null) - { - IEditorPart editor = page.getActiveEditor(); - if (editor != null) - { - IEditorInput editorInput = editor.getEditorInput(); - if (!(editorInput instanceof IFileEditorInput || editorInput instanceof FileStoreEditorInput)) - { - return true; - } - } - } - } - } - return false; - } - - // For https://bugs.eclipse.org/bugs/show_bug.cgi?id=218281 - // Don't want to refresh the design when changes are made in the source view. - protected boolean doUpdateDesign() - { - IWorkbench workbench = PlatformUI.getWorkbench(); - if (workbench != null) - { - IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - if (workbenchWindow != null) - { - IWorkbenchPage page = workbenchWindow.getActivePage(); - if (page != null) - { - IEditorPart editorPart = page.getActiveEditor(); - if (editorPart instanceof CommonMultiPageEditor) - { - CommonMultiPageEditor editor = (CommonMultiPageEditor) editorPart; - GraphicalViewer viewer = (GraphicalViewer)editor.getAdapter(GraphicalViewer.class); - // Need to ensure this is the same editor we are working with since the active editor may not be - // the current, eg. at startup, there can be another XSD Editor open on the source page, so we could end - // up not populating the design view initally - if (getViewer() == viewer) - { - // If source page is active, don't update the design - return !editor.isSourcePageActive(); - } - } - } - } - } - return true; - } - - /** - * Try to get the italic font for the current font - * @param font - * @return - */ - protected Font getItalicFont(Font font) - { - if (font != null && !font.isDisposed()) - { - FontData[] fd = font.getFontData(); - if (fd.length > 0) - { - fd[0].setStyle(fd[0].getStyle() | SWT.ITALIC); - return new Font(font.getDevice(), fd); - } - } - return font; - } - protected AccessibleEditPart getAccessibleEditPart() { - - if (accessiblePart ==null) - { - accessiblePart = new AccessibleGraphicalEditPart(){ - - public void getName(AccessibleEvent e) { - e.result = getReaderText(); - } - }; - } - return accessiblePart; - } -public String getReaderText() -{ - return ""; -} -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/BaseFieldEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/BaseFieldEditPart.java deleted file mode 100644 index e40978037d..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/BaseFieldEditPart.java +++ /dev/null @@ -1,535 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2009 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.design.editparts; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.gef.DragTracker; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.LayerConstants; -import org.eclipse.gef.Request; -import org.eclipse.gef.RequestConstants; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; -import org.eclipse.gef.requests.DirectEditRequest; -import org.eclipse.gef.requests.LocationRequest; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.widgets.Display; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; -import org.eclipse.wst.xsd.ui.internal.adt.design.directedit.ComboBoxCellEditorManager; -import org.eclipse.wst.xsd.ui.internal.adt.design.directedit.ElementReferenceDirectEditManager; -import org.eclipse.wst.xsd.ui.internal.adt.design.directedit.LabelCellEditorLocator; -import org.eclipse.wst.xsd.ui.internal.adt.design.directedit.LabelEditManager; -import org.eclipse.wst.xsd.ui.internal.adt.design.directedit.TypeReferenceDirectEditManager; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.FocusTypeColumn; -import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.ADTDirectEditPolicy; -import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.ADTSelectionFeedbackEditPolicy; -import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.IADTUpdateCommand; -import org.eclipse.wst.xsd.ui.internal.adt.design.figures.IFieldFigure; -import org.eclipse.wst.xsd.ui.internal.adt.editor.Messages; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IField; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IType; -import org.eclipse.wst.xsd.ui.internal.design.editparts.ConnectableEditPart; -import org.eclipse.wst.xsd.ui.internal.design.editparts.TargetConnectionSpacingFigureEditPart; -import org.eclipse.wst.xsd.ui.internal.design.editparts.model.TargetConnectionSpaceFiller; -import org.eclipse.wst.xsd.ui.internal.design.editpolicies.GraphNodeDragTracker; -import org.eclipse.xsd.XSDNamedComponent; - -public class BaseFieldEditPart extends BaseTypeConnectingEditPart implements INamedEditPart, IAutoDirectEdit -{ - protected TypeReferenceConnection connectionFigure; - protected ADTDirectEditPolicy adtDirectEditPolicy = new ADTDirectEditPolicy(); - protected TypeReferenceConnection connectionFeedbackFigure; - - protected IFigure createFigure() - { - IFieldFigure figure = getFigureFactory().createFieldFigure(getModel()); - figure.setForegroundColor(ColorConstants.black); - return figure; - } - - public IFieldFigure getFieldFigure() - { - return (IFieldFigure)figure; - } - - - protected boolean shouldDrawConnection() - { - boolean result = false; - - // For now we only want to produce outbound lines from a Field to a Type - // when the field in contained in the 'focus' edit part - for (EditPart parent = getParent(); parent != null; parent = parent.getParent()) - { - if (parent.getModel() instanceof FocusTypeColumn) - { - result = true; - break; - } - } - return result; - } - - private EditPart getTargetEditPart(IType type) - { - ColumnEditPart columnEditPart = null; - for (EditPart editPart = this; editPart != null; editPart = editPart.getParent()) - { - if (editPart instanceof ColumnEditPart) - { - columnEditPart = (ColumnEditPart)editPart; - break; - } - } - if (columnEditPart != null) - { - // get the next column - EditPart parent = columnEditPart.getParent(); - List columns = parent.getChildren(); - int index = columns.indexOf(columnEditPart); - if (index + 1 < columns.size()) - { - EditPart nextColumn = (EditPart)columns.get(index + 1); - for (Iterator i = nextColumn.getChildren().iterator(); i.hasNext(); ) - { - EditPart child = (EditPart)i.next(); - if (child.getModel() == type) - { - return child; - } - } - } - } - return null; - } - - private EditPart getTargetConnectionEditPart() - { - EditPart result = null; - IField field = (IField)getModel(); - IType type = field.getType(); - if (type != null) - { - result = getTargetEP(type); //getTargetEditPart(type); - } - return result; - } - - /** - * Do not override - * @param type - * @return - */ - protected EditPart getTargetEP(IType type) - { - return getTargetEditPart(type); - } - - public TypeReferenceConnection createConnectionFigure() - { - connectionFigure = null; - AbstractGraphicalEditPart referenceTypePart = (AbstractGraphicalEditPart)getTargetConnectionEditPart(); - if (referenceTypePart != null) - { - connectionFigure = new TypeReferenceConnection(); - - if (getFigure().getParent() == referenceTypePart.getFigure()) - { - connectionFigure.setSourceAnchor(new CenteredConnectionAnchor(getFigure(), CenteredConnectionAnchor.LEFT, 1)); - } - else - { - connectionFigure.setSourceAnchor(new CenteredConnectionAnchor(getFigure(), CenteredConnectionAnchor.RIGHT, 5)); - } - int targetAnchorYOffset = 8; - - connectionFigure.setTargetAnchor(new CenteredConnectionAnchor(referenceTypePart.getFigure(), CenteredConnectionAnchor.HEADER_LEFT, 0, targetAnchorYOffset)); - connectionFigure.setHighlight(false); - } - - return connectionFigure; - } - - protected void createEditPolicies() - { - super.createEditPolicies(); - installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, adtDirectEditPolicy); - installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new ADTSelectionFeedbackEditPolicy()); - } - - public EditPart doGetRelativeEditPart(EditPart editPart, int direction) - { - EditPart result = null; - if (direction == PositionConstants.EAST) - { - result = getTargetConnectionEditPart(); - } - else if (direction == PositionConstants.WEST) - { - for (Iterator iter = getParent().getChildren().iterator(); iter.hasNext(); ) - { - Object child = iter.next(); - if (child instanceof SectionEditPart) - { - SectionEditPart groups = (SectionEditPart) child; - for (Iterator i = groups.getChildren().iterator(); i.hasNext(); ) - { - Object groupChild = i.next(); - EditPart connectable = getParentConnectableEditPart((EditPart)groupChild); - if (connectable != null) - { - result = connectable; - } - } - } - } - if (result == null) - { - result = this; - } - } - else - { - result = super.doGetRelativeEditPart(editPart, direction); - if (result == null) - { - result = ((BaseEditPart)getParent()).doGetRelativeEditPart(editPart, direction); - } - } - return result; - } - - protected ConnectableEditPart getParentConnectableEditPart(EditPart connectable) - { - if (connectable instanceof TargetConnectionSpacingFigureEditPart) - { - TargetConnectionSpaceFiller space = (TargetConnectionSpaceFiller) ((TargetConnectionSpacingFigureEditPart)connectable).getModel(); - if (space.getAdapter() == this.getModel()) - { - return (ConnectableEditPart)connectable; - } - } - - for (Iterator i = connectable.getChildren().iterator(); i.hasNext(); ) - { - Object child = i.next(); - if (child instanceof ConnectableEditPart) - { - ConnectableEditPart r = getParentConnectableEditPart((EditPart)child); - if (r != null) return r; - } - else if (child instanceof TargetConnectionSpacingFigureEditPart) - { - TargetConnectionSpaceFiller space = (TargetConnectionSpaceFiller) ((TargetConnectionSpacingFigureEditPart)child).getModel(); - if (space.getAdapter() == this.getModel() && connectable instanceof ConnectableEditPart) - { - return (ConnectableEditPart)connectable; - } - } - } - return null; - } - - protected void refreshVisuals() - { - super.refreshVisuals(); - IFieldFigure figure = getFieldFigure(); - IField field = (IField) getModel(); - - figure.getNameLabel().setText(field.getName()); - figure.getTypeLabel().setText(field.getTypeName()); - figure.refreshVisuals(getModel()); - - figure.recomputeLayout(); - - ((GraphicalEditPart)getRoot()).getFigure().invalidateTree(); - } - - public DragTracker getDragTracker(Request request) - { - return new GraphNodeDragTracker(this); - } - - /* - public IAction[] getActions(Object object) - { - // when a FieldEditPart is selected it provides it's own actions - // as well as those of it's parent 'type' edit part - List list = new ArrayList(); - EditPart compartment = getParent(); - if (compartment != null) - { - EditPart type = compartment.getParent(); - if (type != null && type instanceof IActionProvider) - { - IActionProvider provider = (IActionProvider)type; - addActionsToList(list, provider.getActions(object)); - } - } - addActionsToList(list, super.getActions(object)); - IAction[] result = new IAction[list.size()]; - list.toArray(result); - return result; - }*/ - - public Label getNameLabelFigure() - { - return getFieldFigure().getNameLabel(); - } - - public void performDirectEdit(Point cursorLocation) - { - - } - - public void performRequest(Request request) - { - if (((IADTObject)getModel()).isReadOnly() || isFileReadOnly()) - { - return; - } - if (request.getType() == RequestConstants.REQ_DIRECT_EDIT|| - request.getType() == RequestConstants.REQ_OPEN) - { - IFieldFigure fieldFigure = getFieldFigure(); - Object model = getModel(); - if (request instanceof LocationRequest) - { - LocationRequest locationRequest = (LocationRequest)request; - Point p = locationRequest.getLocation(); - - if (hitTest(fieldFigure.getTypeLabel(), p)) - { - TypeReferenceDirectEditManager manager = new TypeReferenceDirectEditManager((IField)model, this, fieldFigure.getTypeLabel()); - TypeUpdateCommand typeUpdateCommand = new TypeUpdateCommand(); - typeUpdateCommand.setDelegate(manager); - adtDirectEditPolicy.setUpdateCommand(typeUpdateCommand); - manager.show(); - } - else if (hitTest(fieldFigure.getNameLabel(), p)) - { - directEditNameField(); - } - } - else { - directEditNameField(); - } - } - } - - protected void directEditNameField() - { - if (isFileReadOnly()) return; - Object model = getModel(); - IFieldFigure fieldFigure = getFieldFigure(); - if ( model instanceof IField) - { - IField field = (IField) model; - if (field.isReference()) - { - ElementReferenceDirectEditManager manager = new ElementReferenceDirectEditManager((IField) model, this, fieldFigure.getNameLabel()); - ReferenceUpdateCommand elementUpdateCommand = new ReferenceUpdateCommand(); - elementUpdateCommand.setDelegate(manager); - adtDirectEditPolicy.setUpdateCommand(elementUpdateCommand); - manager.show(); - } - else - { - LabelEditManager manager = new LabelEditManager(this, new LabelCellEditorLocator(this, null)); - NameUpdateCommandWrapper wrapper = new NameUpdateCommandWrapper(); - adtDirectEditPolicy.setUpdateCommand(wrapper); - manager.show(); - } - } - } - - public void doEditName(boolean addFromDesign) - { - if (!addFromDesign) return; - -// removeFeedback(); - - Runnable runnable = new Runnable() - { - public void run() - { - Object object = ((XSDBaseAdapter)getModel()).getTarget(); - if (object instanceof XSDNamedComponent) - { - Point p = getNameLabelFigure().getLocation(); - LabelEditManager manager = new LabelEditManager(BaseFieldEditPart.this, new LabelCellEditorLocator(BaseFieldEditPart.this, p)); - NameUpdateCommandWrapper wrapper = new NameUpdateCommandWrapper(); - adtDirectEditPolicy.setUpdateCommand(wrapper); - manager.show(); - } - } - }; - Display.getCurrent().asyncExec(runnable); - - } - - protected class NameUpdateCommandWrapper extends Command implements IADTUpdateCommand - { - Command command; - protected DirectEditRequest request; - - public NameUpdateCommandWrapper() - { - super(Messages._UI_ACTION_UPDATE_NAME); - } - - public void setRequest(DirectEditRequest request) - { - this.request = request; - } - - public void execute() - { - IField field = (IField)getModel(); - Object newValue = request.getCellEditor().getValue(); - if (newValue instanceof String) - { - command = field.getUpdateNameCommand((String)newValue); - } - if (command != null) - command.execute(); - } - } - - class TypeUpdateCommand extends Command implements IADTUpdateCommand - { - protected ComboBoxCellEditorManager delegate; - protected DirectEditRequest request; - - public TypeUpdateCommand() - { - super(Messages._UI_ACTION_UPDATE_TYPE); - } - - public void setDelegate(ComboBoxCellEditorManager delegate) - { - this.delegate = delegate; - } - - public void setRequest(DirectEditRequest request) - { - this.request = request; - } - - public void execute() - { - if (delegate != null) - { - delegate.performEdit(request.getCellEditor()); - } - } - - public boolean canExecute() - { - IField field = (IField)getModel(); - Object newValue = ((CCombo)request.getCellEditor().getControl()).getText(); - if (newValue instanceof String) - { - return !newValue.equals(field.getTypeName()); - } - return true; - } - } - - protected class ReferenceUpdateCommand extends Command implements IADTUpdateCommand - { - protected ComboBoxCellEditorManager delegate; - protected DirectEditRequest request; - - public ReferenceUpdateCommand() - { - super(Messages._UI_ACTION_UPDATE_ELEMENT_REFERENCE); - } - - public void setDelegate(ComboBoxCellEditorManager delegate) - { - this.delegate = delegate; - } - - public void setRequest(DirectEditRequest request) - { - this.request = request; - } - - public void execute() - { - if (delegate != null) - { - delegate.performEdit(request.getCellEditor()); - } - } - - public boolean canExecute() - { - return true; - } - } - - - public void addFeedback() - { - // Put back connection figure so it won't get overlayed by other non highlighted connections - if (connectionFigure != null && !isSelected) - { - connectionFeedbackFigure = new TypeReferenceConnection(); - connectionFeedbackFigure.setSourceAnchor(connectionFigure.getSourceAnchor()); - connectionFeedbackFigure.setTargetAnchor(connectionFigure.getTargetAnchor()); - connectionFeedbackFigure.setHighlight(true); - getLayer(LayerConstants.FEEDBACK_LAYER).add(connectionFeedbackFigure); - } - super.addFeedback(); - getFieldFigure().addSelectionFeedback(); - } - - public void removeFeedback() - { - if (connectionFeedbackFigure != null) - { - connectionFeedbackFigure.setHighlight(false); - getLayer(LayerConstants.FEEDBACK_LAYER).remove(connectionFeedbackFigure); - } - connectionFeedbackFigure = null; - super.removeFeedback(); - getFieldFigure().removeSelectionFeedback(); - } - public String getReaderText() - { - IFieldFigure fieldFigure = getFieldFigure(); - - String name=""; - if (fieldFigure.getNameLabel() !=null&& fieldFigure.getNameLabel().getText().trim().length() > 0) - name +=fieldFigure.getNameLabel().getText(); - if (fieldFigure.getNameAnnotationLabel() !=null && fieldFigure.getNameAnnotationLabel().getText().trim().length() > 0) - name += " "+fieldFigure.getNameAnnotationLabel().getText(); - if (fieldFigure.getTypeLabel() !=null && fieldFigure.getTypeLabel().getText().trim().length() > 0) - name += " type "+fieldFigure.getTypeLabel().getText(); - if (fieldFigure.getTypeAnnotationLabel() !=null && fieldFigure.getTypeAnnotationLabel().getText().trim().length() >0) - name += " "+fieldFigure.getTypeAnnotationLabel().getText(); - return name; - - } -} - diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/BaseTypeConnectingEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/BaseTypeConnectingEditPart.java deleted file mode 100644 index eebb8e6036..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/BaseTypeConnectingEditPart.java +++ /dev/null @@ -1,207 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2009 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.design.editparts; - -import java.util.Iterator; -import org.eclipse.draw2d.ConnectionAnchor; -import org.eclipse.draw2d.Figure; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.LayerConstants; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.requests.DirectEditRequest; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IFeedbackHandler; -import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.IADTUpdateCommand; -import org.eclipse.wst.xsd.ui.internal.adt.editor.Messages; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IType; - -/** - * This class provides some base function to enable drawing connections to a referenced type - * - */ -public abstract class BaseTypeConnectingEditPart extends BaseEditPart implements IFeedbackHandler, IConnectionContainer -{ - private TypeReferenceConnection connectionFigure; - - public void activate() - { - super.activate(); - } - - public void deactivate() - { - deactivateConnection(); - super.deactivate(); - } - - public void refreshConnections() - { - deactivateConnection(); - activateConnection(); - } - - protected void activateConnection() - { - // If appropriate, create our connectionFigure and add it to the appropriate layer - if (connectionFigure == null && shouldDrawConnection()) - { - //System.out.println("activateeConnection()-pre:" + getClass().getName()); - connectionFigure = createConnectionFigure(); - if (connectionFigure != null) - { - // Add our editpolicy as a listener on the connection, so it can stay in synch - //connectionFigure.addPropertyChangeListener((AttributeSelectionFeedbackPolicy) getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE)); - //connectionFigure.addMouseListener(this); - getLayer(LayerConstants.CONNECTION_LAYER).add(connectionFigure); - } - } - } - - protected void deactivateConnection() - { - // if we have a connection, remove it - if (connectionFigure != null) - { - getLayer(LayerConstants.CONNECTION_LAYER).remove(connectionFigure); - // Remove our editpolicy listener(s) - //connectionFigure.removePropertyChangeListener((AttributeSelectionFeedbackPolicy) getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE)); - //connectionFigure.removeMouseListener(this); - connectionFigure = null; - } - } - - protected boolean shouldDrawConnection() - { - return true; - } - - public abstract TypeReferenceConnection createConnectionFigure(); - - public void addFeedback() - { - if (connectionFigure != null) - { - connectionFigure.setHighlight(true); - } - super.addFeedback(); - } - - public void removeFeedback() - { - if (connectionFigure != null) - { - connectionFigure.setHighlight(false); - } - super.removeFeedback(); - } - - protected class NameUpdateCommandWrapper extends Command implements IADTUpdateCommand - { - Command command; - protected DirectEditRequest request; - - public NameUpdateCommandWrapper() - { - super(Messages._UI_ACTION_UPDATE_NAME); - } - - public void setRequest(DirectEditRequest request) - { - this.request = request; - } - - public void execute() - { - IType iType = (IType)getModel(); - Object newValue = request.getCellEditor().getValue(); - if (newValue instanceof String) - { - command = iType.getUpdateNameCommand((String)newValue); - } - if (command != null) - command.execute(); - } - } - - public boolean hitTest(IFigure target, Point location) - { - Rectangle b = target.getBounds().getCopy(); - target.translateToAbsolute(b); - return b.contains(location); - } - - public EditPart doGetRelativeEditPart(EditPart editPart, int direction) - { - EditPart result = null; - if (direction == PositionConstants.WEST) - { - result = getConnectionEditPart(PositionConstants.WEST); - } - else if (direction == PositionConstants.EAST) - { - result = getConnectionEditPart(PositionConstants.EAST); - } - return result; - } - - private EditPart getConnectionEditPart(int direction) - { - // find the first connection that targets this editPart - // navigate backward along the connection (to the left) to find the source edit part - EditPart result = null; - for (Iterator i = getLayer(LayerConstants.CONNECTION_LAYER).getChildren().iterator(); i.hasNext(); ) - { - Figure figure = (Figure)i.next(); - if (figure instanceof TypeReferenceConnection) - { - TypeReferenceConnection typeReferenceConnection = (TypeReferenceConnection)figure; - ConnectionAnchor thisAnchor = null; - if (direction == PositionConstants.EAST) - { - thisAnchor = typeReferenceConnection.getSourceAnchor(); - } - else if (direction == PositionConstants.WEST) - { - thisAnchor = typeReferenceConnection.getTargetAnchor(); - } - if (thisAnchor != null && thisAnchor.getOwner() == getFigure()) - { - ConnectionAnchor outAnchor = null; - if (direction == PositionConstants.EAST) - { - outAnchor = typeReferenceConnection.getTargetAnchor(); - } - else if (direction == PositionConstants.WEST) - { - outAnchor = typeReferenceConnection.getSourceAnchor(); - } - - if (outAnchor != null) - { - IFigure sourceFigure = outAnchor.getOwner(); - EditPart part = null; - while (part == null && sourceFigure != null) - { - part = (EditPart)getViewer().getVisualPartMap().get(sourceFigure); - sourceFigure = sourceFigure.getParent(); - } - result = part; - break; - } - } - } - } - return result; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/BoxEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/BoxEditPart.java deleted file mode 100644 index 89a85deaae..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/BoxEditPart.java +++ /dev/null @@ -1,92 +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.design.editparts; - -import java.util.List; -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.LineBorder; -import org.eclipse.draw2d.ToolbarLayout; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.ui.actions.ActionRegistry; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.Compartment; -import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.ADTSelectionFeedbackEditPolicy; -import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.SimpleDirectEditPolicy; -import org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement; -import org.eclipse.wst.xsd.ui.internal.adt.typeviz.design.figures.BoxFigure; - -public abstract class BoxEditPart extends BaseTypeConnectingEditPart //IFeedbackHandler -{ - protected List compartmentList = null; - protected SimpleDirectEditPolicy simpleDirectEditPolicy = new SimpleDirectEditPolicy(); - - protected Compartment[] getCompartments() - { - return null; - } - - protected IFigure createFigure() - { - BoxFigure figure = new BoxFigure(); - LineBorder boxLineBorder = new LineBorder(1); - figure.setBorder(boxLineBorder); - ToolbarLayout toolbarLayout = new ToolbarLayout(); - toolbarLayout.setStretchMinorAxis(true); - figure.setLayoutManager(toolbarLayout); - // we should organize ITreeElement and integrate it with the facade - if (getModel() instanceof ITreeElement) - { - figure.getNameLabel().setIcon(((ITreeElement)getModel()).getImage()); - } - return figure; - } - - public IFigure getContentPane() - { - return ((BoxFigure)getFigure()).getContentPane(); - } - - protected void createEditPolicies() - { - super.createEditPolicies(); - installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new ADTSelectionFeedbackEditPolicy()); - installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, simpleDirectEditPolicy); - } - - - public void addFeedback() - { - BoxFigure boxFigure = (BoxFigure)figure; - LineBorder boxFigureLineBorder = (LineBorder)boxFigure.getBorder(); - boxFigureLineBorder.setWidth(2); - boxFigureLineBorder.setColor(ColorConstants.darkBlue); - boxFigure.getHeadingFigure().setSelected(true); - figure.repaint(); - super.addFeedback(); - } - - public void removeFeedback() - { - BoxFigure boxFigure = (BoxFigure)figure; - LineBorder boxFigureLineBorder = (LineBorder)boxFigure.getBorder(); - boxFigureLineBorder.setWidth(1); - boxFigureLineBorder.setColor(ColorConstants.black); - boxFigure.getHeadingFigure().setSelected(false); - figure.repaint(); - super.removeFeedback(); - } - - protected ActionRegistry getEditorActionRegistry(IEditorPart editor) - { - return (ActionRegistry) editor.getAdapter(ActionRegistry.class); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/CenteredConnectionAnchor.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/CenteredConnectionAnchor.java deleted file mode 100644 index 0c93b9d691..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/CenteredConnectionAnchor.java +++ /dev/null @@ -1,115 +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.design.editparts; - -import org.eclipse.draw2d.AbstractConnectionAnchor; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.wst.xsd.ui.internal.design.figures.CenteredIconFigure; - -public class CenteredConnectionAnchor extends AbstractConnectionAnchor -{ - public static final int TOP = 0; - public static final int BOTTOM = 1; - public static final int LEFT = 2; - public static final int RIGHT = 3; - - public static final int HEADER_LEFT = 4; - public static final int HEADER_RIGHT = 5; - - private int location; - private int inset; - private int offset = 0; - private CenteredConnectionAnchor other; - - public CenteredConnectionAnchor(IFigure owner, int location, int inset) - { - super(owner); - this.location = location; - this.inset = inset; - } - - public CenteredConnectionAnchor(IFigure owner, int location, int inset, int offset) - { - this(owner, location, inset); - this.offset = offset; - } - - public Point getLocation(Point reference) - { - Rectangle r = getOwner().getBounds(); - int x, y; - switch (location) - { - case TOP: - x = r.right() - r.width / 2 + offset; - y = r.y + inset; - break; - case BOTTOM: - x = r.right() - r.width / 2 + offset; - y = r.bottom() - inset; - break; - case LEFT: - x = r.x + inset; - y = r.bottom() - r.height / 2 + offset; - break; - case RIGHT: - x = r.right() - inset; - y = r.bottom() - r.height / 2 + offset; - break; - case HEADER_LEFT: - x = r.x + inset; - y = r.y + offset; - break; - case HEADER_RIGHT: - x = r.right() - inset; - y = r.y + offset; - break; - - default: - x = r.right() - r.width / 2; - y = r.bottom() - r.height / 2; - } - Point p = new Point(x, y); - - if (!(getOwner() instanceof CenteredIconFigure)) - { - getOwner().translateToAbsolute(p); - } - else - { - getOwner().translateToAbsolute(p); - } - - if (other != null) - { - // if within only one pixel of being vertical, we straighten up the line - Point p2 = other.getLocation(null); - if (Math.abs(p2.x - p.x) <= 1) - { - p.x = p2.x; - } - } - return p; - } - - public Point getReferencePoint() - { - return getLocation(null); - } - - public void setOther(CenteredConnectionAnchor other) - { - this.other = other; - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/ColumnEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/ColumnEditPart.java deleted file mode 100644 index 8eb4090fbc..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/ColumnEditPart.java +++ /dev/null @@ -1,127 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 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.design.editparts; - -import java.util.Iterator; -import java.util.List; -import org.eclipse.draw2d.Figure; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.ToolbarLayout; -import org.eclipse.gef.EditPart; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.AbstractModelCollection; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.ReferencedTypeColumn; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IComplexType; - -public class ColumnEditPart extends BaseEditPart -{ - protected int spacing = 20; - protected int minorAlignment = -1; - protected boolean isHorizontal = false; - - public ColumnEditPart() - { - } - - public ColumnEditPart(boolean isHorizontal) - { - this.isHorizontal = isHorizontal; - } - - protected IFigure createFigure() - { - Figure figure = new Figure(); - ToolbarLayout layout = new ToolbarLayout(isHorizontal); - - if (minorAlignment != -1) - { - layout.setMinorAlignment(minorAlignment); - } - layout.setStretchMinorAxis(false); - layout.setSpacing(spacing); - figure.setLayoutManager(layout); - return figure; - } - - public void setSpacing(int spacing) - { - this.spacing = spacing; - if (figure != null) - { - ((ToolbarLayout)figure.getLayoutManager()).setSpacing(spacing); - } - } - - public IComplexType getComplexType() - { - return (IComplexType)getModel(); - } - - protected void createEditPolicies() - { - // TODO Auto-generated method stub - } - - protected List getModelChildren() - { - AbstractModelCollection collection = (AbstractModelCollection)getModel(); - return collection.getChildren(); - } - - public int getMinorAlignment() - { - return minorAlignment; - } - - public void setMinorAlignment(int minorAlignment) - { - this.minorAlignment = minorAlignment; - } - - protected void refreshChildren() - { - super.refreshChildren(); - if (getModel() instanceof ReferencedTypeColumn) - { - if (getParent().getChildren().size() > 0) - { - EditPart editPart = (EditPart)getParent().getChildren().get(0); - refreshConnections(editPart); - } - } - else - { - refreshConnections(this); - } - } - - - public void refreshConnections(EditPart parent) - { - for (Iterator i = parent.getChildren().iterator(); i.hasNext(); ) - { - EditPart editPart = (EditPart)i.next(); - if (editPart instanceof BaseTypeConnectingEditPart) - { - BaseTypeConnectingEditPart connectingEditPart = (BaseTypeConnectingEditPart)editPart; - connectingEditPart.refreshConnections(); - } - refreshConnections(editPart); - } - } - - public boolean isSelectable() - { - return false; - } -} - - - diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/CompartmentEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/CompartmentEditPart.java deleted file mode 100644 index 15f56e892e..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/CompartmentEditPart.java +++ /dev/null @@ -1,217 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 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.design.editparts; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.Annotation; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.Compartment; -import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.KeyBoardAccessibilityEditPolicy; -import org.eclipse.wst.xsd.ui.internal.adt.design.figures.ICompartmentFigure; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IField; - -// TODO (cs) common-up with BoxEditPart (?) -public class CompartmentEditPart extends BaseEditPart // implements - // IFeedbackHandler -{ - protected Annotation annotation = new Annotation(); - - protected IFigure createFigure() - { - ICompartmentFigure figure = getFigureFactory().createCompartmentFigure(getModel()); - return figure; - } - - public IFigure getContentPane() - { - return getCompartmentFigure().getContentPane(); - } - - public boolean hasContent() - { - // since the annotation always takes up 1 child, here's a convenience method to figure out if - return getChildren().size() > 1; - } - - List getChildrenSansAnnotation() - { - List children = new ArrayList(); - children.addAll(getChildren()); - for (Iterator i = children.iterator(); i.hasNext(); ) - { - EditPart child = (EditPart)i.next(); - if (child.getModel() == annotation) - { - i.remove(); - break; - } - } - return children; - } - - public EditPart doGetRelativeEditPart(EditPart editPart, int direction) - { - EditPart result = null; - - // we compute the children sans the annotation EditPart - // since the annotation EditPart confuses our up/down key handling - List children = getChildrenSansAnnotation(); - if (children.contains(editPart)) - { - if (direction == KeyBoardAccessibilityEditPolicy.OUT_TO_PARENT) - { - Compartment compartment = (Compartment)getModel(); - for (EditPart parent = editPart.getParent(); parent != null; parent = parent.getParent()) - { - if (parent.getModel() == compartment.getOwner()) - { - result = parent; - break; - } - } - } - else if (direction == PositionConstants.SOUTH) - { - int size = children.size(); - if (size > 0) - { - if (children.get(size - 1) == editPart) - { - CompartmentEditPart nextCompartment = (CompartmentEditPart)EditPartNavigationHandlerUtil.getNextSibling(CompartmentEditPart.this); - if (nextCompartment != null && nextCompartment.getChildrenSansAnnotation().size() > 0) - { - result = EditPartNavigationHandlerUtil.getFirstChild(nextCompartment); - } - else - { - result = editPart; - } - } - } - if (result == null) result = EditPartNavigationHandlerUtil.getNextSibling(editPart); - } - else if (direction == PositionConstants.NORTH) - { - if (EditPartNavigationHandlerUtil.getFirstChild(CompartmentEditPart.this) == editPart) - { - EditPart prevCompartment = EditPartNavigationHandlerUtil.getPrevSibling(CompartmentEditPart.this); - if (prevCompartment instanceof CompartmentEditPart) - { - List prevCompListChildren = ((CompartmentEditPart)prevCompartment).getChildrenSansAnnotation(); - int size = prevCompListChildren.size(); - if (size > 0) - { - result = (EditPart)prevCompartment.getChildren().get(size - 1); - } - } - } - if (result == null) result = EditPartNavigationHandlerUtil.getPrevSibling(editPart); - } - } - return result; - } - - protected void addChildVisual(EditPart childEditPart, int index) - { - Object model = childEditPart.getModel(); - - IFigure child = ((GraphicalEditPart) childEditPart).getFigure(); - - if (model instanceof IField) - { - getCompartmentFigure().getContentPane().add(child, index); - return; - } - else if (model instanceof Annotation) - { - getCompartmentFigure().getAnnotationPane().add(child); - return; - } - super.addChildVisual(childEditPart, index); - } - - protected void removeChildVisual(EditPart childEditPart) - { - Object model = childEditPart.getModel(); - IFigure child = ((GraphicalEditPart) childEditPart).getFigure(); - - if (model instanceof IField) - { - getCompartmentFigure().getContentPane().remove(child); - return; - } - else if (model instanceof Annotation) - { - getCompartmentFigure().getAnnotationPane().remove(child); - return; - } - super.removeChildVisual(childEditPart); - } - - protected Compartment getCompartment() - { - return (Compartment) getModel(); - } - - protected List getModelChildren() - { - List children = getCompartment().getChildren(); - children.add(annotation); - return children; - } - - public void setModel(Object model) - { - super.setModel(model); - annotation.setCompartment(getCompartment()); - } - - protected void refreshChildren() - { - super.refreshChildren(); - // ((AbstractGraphicalEditPart)getParent()).getContentPane().invalidate(); - } - - protected void refreshVisuals() - { - super.refreshVisuals(); - } - - public void addFeedback() - { - // getFigure().setBackgroundColor(ColorConstants.blue); - // ((CompartmentFigure)getFigure()).setBorderColor(ColorConstants.black); - getFigure().repaint(); - } - - public void removeFeedback() - { - // getFigure().setBackgroundColor(ColorConstants.lightBlue); - // ((CompartmentFigure)getFigure()).setBorderColor(ColorConstants.lightGray); - getFigure().repaint(); - } - - public ICompartmentFigure getCompartmentFigure() - { - return (ICompartmentFigure)figure; - } - - public void addNotify() - { - super.addNotify(); - getCompartmentFigure().editPartAttached(this); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/ComplexTypeEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/ComplexTypeEditPart.java deleted file mode 100644 index 0eceb08ac1..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/ComplexTypeEditPart.java +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2009 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.design.editparts; - -import java.util.Iterator; - -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.ManhattanConnectionRouter; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; -import org.eclipse.swt.graphics.Font; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.FocusTypeColumn; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IComplexType; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IType; - -public class ComplexTypeEditPart extends StructureEditPart -{ - private Font italicFont; - - protected boolean shouldDrawConnection() - { - if (getParent().getModel() instanceof FocusTypeColumn) - { - IComplexType complexType = (IComplexType)getModel(); - return complexType.getSuperType() != null; - } - return false; - } - - - private EditPart getTargetEditPart(IType type) - { - ColumnEditPart columnEditPart = null; - for (EditPart editPart = this; editPart != null; editPart = editPart.getParent()) - { - if (editPart instanceof ColumnEditPart) - { - columnEditPart = (ColumnEditPart)editPart; - break; - } - } - if (columnEditPart != null) - { - for (Iterator i = columnEditPart.getChildren().iterator(); i.hasNext(); ) - { - EditPart child = (EditPart)i.next(); - if (child.getModel() == type) - { - return child; - } - } - } - return null; - } - - public TypeReferenceConnection createConnectionFigure() - { - connectionFigure = null; - IComplexType complexType = (IComplexType)getModel(); - IType type = complexType.getSuperType(); - if (type != null) - { - AbstractGraphicalEditPart referenceTypePart = (AbstractGraphicalEditPart)getTargetEditPart(type); - if (referenceTypePart != null) - { - connectionFigure = new TypeReferenceConnection(true); - // draw a line out from the top - connectionFigure.setSourceAnchor(new CenteredConnectionAnchor(getFigure(), CenteredConnectionAnchor.TOP, 1)); - - // TODO (cs) need to draw the target anchor to look like a UML inheritance relationship - // adding a label to the connection would help to - connectionFigure.setTargetAnchor(new CenteredConnectionAnchor(referenceTypePart.getFigure(), CenteredConnectionAnchor.BOTTOM, 0, 0)); - connectionFigure.setConnectionRouter(new ManhattanConnectionRouter()); - ((CenteredConnectionAnchor)connectionFigure.getSourceAnchor()).setOther((CenteredConnectionAnchor)connectionFigure.getTargetAnchor()); - connectionFigure.setHighlight(false); - } - } - return connectionFigure; - } - - protected void refreshVisuals() - { - super.refreshVisuals(); - Label label = getNameLabelFigure(); - IComplexType complexType = (IComplexType)getModel(); - if (complexType.isAbstract()) - { - if (italicFont == null) - { - Font font = label.getFont(); - italicFont = getItalicFont(font); - } - if (italicFont != null) - { - label.setFont(italicFont); - } - } - else - { - label.setFont(label.getParent().getFont()); - } - } - - public void deactivate() - { - if (italicFont != null) - { - italicFont.dispose(); - italicFont = null; - } - super.deactivate(); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/EditPartNavigationHandlerUtil.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/EditPartNavigationHandlerUtil.java deleted file mode 100644 index c234b65f5c..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/EditPartNavigationHandlerUtil.java +++ /dev/null @@ -1,72 +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.design.editparts; -import java.util.List; -import org.eclipse.gef.EditPart; - - -public class EditPartNavigationHandlerUtil -{ - public static EditPart getFirstChild(EditPart editPart) - { - EditPart result = null; - if (editPart.getChildren().size() > 0) - { - result = (EditPart)editPart.getChildren().get(0); - } - return result; - } - - public static EditPart getLastChild(EditPart editPart) - { - EditPart result = null; - int size = editPart.getChildren().size(); - if (size > 0) - { - result = (EditPart)editPart.getChildren().get(size - 1); - } - return result; - } - - public static EditPart getNextSibling(EditPart editPart) - { - EditPart result = null; - EditPart parent = editPart.getParent(); - if (parent != null) - { - List children = parent.getChildren(); - int index = children.indexOf(editPart); - if (index + 1 < children.size()) - { - result = (EditPart)children.get(index + 1); - } - } - return result; - } - - public static EditPart getPrevSibling(EditPart editPart) - { - EditPart result = null; - EditPart parent = editPart.getParent(); - if (parent != null) - { - List children = parent.getChildren(); - int index = children.indexOf(editPart); - if (index - 1 >= 0) - { - // if this is the first child - // - result = (EditPart)children.get(index - 1); - } - } - return result; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/FieldEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/FieldEditPart.java deleted file mode 100644 index f17dd39853..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/FieldEditPart.java +++ /dev/null @@ -1,21 +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.design.editparts; - - -public class FieldEditPart extends BaseFieldEditPart -{ - public void addNotify() - { - super.addNotify(); - getFieldFigure().editPartAttached(this); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/IAutoDirectEdit.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/IAutoDirectEdit.java deleted file mode 100644 index bcd3186980..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/IAutoDirectEdit.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.design.editparts; - -/** - * Edit parts that can be direct editable - * - */ -public interface IAutoDirectEdit -{ - public void doEditName(boolean addFromDesign); -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/IConnectionContainer.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/IConnectionContainer.java deleted file mode 100644 index 176125351a..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/IConnectionContainer.java +++ /dev/null @@ -1,16 +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.design.editparts; - -public interface IConnectionContainer -{ - public void refreshConnections(); -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/IHolderEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/IHolderEditPart.java deleted file mode 100644 index 7f7a5ae74c..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/IHolderEditPart.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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.design.editparts; - -public interface IHolderEditPart -{ - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/INamedEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/INamedEditPart.java deleted file mode 100644 index b186c28124..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/INamedEditPart.java +++ /dev/null @@ -1,21 +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.design.editparts; - -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.geometry.Point; - -public interface INamedEditPart -{ - public Label getNameLabelFigure(); - - public void performDirectEdit(Point cursorLocation); -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/RootContentEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/RootContentEditPart.java deleted file mode 100644 index d2677d4a12..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/RootContentEditPart.java +++ /dev/null @@ -1,165 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2010 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.design.editparts; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.draw2d.Figure; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.MarginBorder; -import org.eclipse.draw2d.Panel; -import org.eclipse.draw2d.ToolbarLayout; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IGraphElement; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.RootHolder; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; -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.adt.facade.IType; - -public class RootContentEditPart extends BaseEditPart -{ - List collections = null; - Figure contentPane; - - protected IFigure createFigure() - { - Panel panel = new Panel(); - panel.setBorder(new MarginBorder(60)); - - ToolbarLayout panelLayout = new ToolbarLayout(false); - panelLayout.setStretchMinorAxis(true); - panel.setLayoutManager(panelLayout); - - contentPane = new Figure(); - panel.add(contentPane); - - ToolbarLayout tb = new ToolbarLayout(false); - tb.setMinorAlignment(ToolbarLayout.ALIGN_CENTER); - tb.setStretchMinorAxis(true); - tb.setSpacing(40); - contentPane.setLayoutManager(tb); - - return panel; - } - - public IFigure getContentPane() - { - return contentPane; - } - - - public IComplexType getSelectedComplexType() - { - IComplexType result = null; - IModel model = (IModel)getModel(); - List types = model.getTypes(); - if (types.size() > 0) - { - if (types.get(0) instanceof IComplexType) - result = (IComplexType)types.get(0); - } - return result; - } - - protected void createEditPolicies() - { - // TODO Auto-generated method stub - } - - protected List getModelChildren() - { - collections = new ArrayList(); - if (getModel() != null) - { - Object obj = getModel(); - IADTObject focusObject = null; - if (obj instanceof IStructure) - { - if (obj instanceof IGraphElement) - { - if (((IGraphElement)obj).isFocusAllowed()) - focusObject = (IStructure)obj; - } - } - else if (obj instanceof IField) - { - focusObject = (IField)obj; - } - else if (obj instanceof IModel) - { - focusObject = (IModel)obj; - collections.add(focusObject); - return collections; - } - else if (obj instanceof IType) - { - if (obj instanceof IGraphElement) - { - if (((IGraphElement)obj).isFocusAllowed()) - { - focusObject = (IType)obj; - } - } - } - else if (obj instanceof IGraphElement) - { - if (((IGraphElement)obj).isFocusAllowed()) - { - focusObject = (IADTObject)obj; - collections.add(focusObject); - return collections; - } - } - if (focusObject != null) - { - RootHolder holder = new RootHolder(focusObject); - collections.add(holder); - return collections; - } - } - return collections; - } - - - /** - * @deprecated Don't call this method. Use DesignViewGraphicalViewer.setInput() instead. - */ - public void setInput(Object component) - { - setModel(component); - refresh(); - } - - /** - * @deprecated Don't call this method. Use DesignViewGraphicalViewer.getInput() instead. - */ - public Object getInput() - { - return getModel(); - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=252589 - public void activate() - { - super.activate(); - Object model = getModel(); - // The schema adapter doesn't have to notify the RootContentEditPart of it changes - if (model instanceof IADTObject) - { - IADTObject object = (IADTObject)model; - object.unregisterListener(this); - } - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/RootEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/RootEditPart.java deleted file mode 100644 index fd8758129f..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/RootEditPart.java +++ /dev/null @@ -1,115 +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.design.editparts; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import org.eclipse.draw2d.BendpointConnectionRouter; -import org.eclipse.draw2d.ConnectionLayer; -import org.eclipse.draw2d.Figure; -import org.eclipse.draw2d.FigureCanvas; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Layer; -import org.eclipse.draw2d.LayeredPane; -import org.eclipse.draw2d.RectangleFigure; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.LayerConstants; -import org.eclipse.gef.editparts.ScalableRootEditPart; -import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; -import org.eclipse.wst.xsd.ui.internal.adt.design.DesignViewerGraphicConstants; - -public class RootEditPart extends ScalableRootEditPart implements org.eclipse.gef.RootEditPart -{ - public void activate() - { - super.activate(); - // Set up Connection layer with a router, if it doesn't already have one - ConnectionLayer connectionLayer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER); - if (connectionLayer != null) - { - connectionLayer.setConnectionRouter(new BendpointConnectionRouter()); - } - - Figure figure = (Figure)getLayer(LayerConstants.FEEDBACK_LAYER); - if (figure != null) - { - if (getViewer() instanceof ScrollingGraphicalViewer) - { - //ScrollingGraphicalViewer sgv = (ScrollingGraphicalViewer)getViewer(); - //IndexFigure indexFigure = new IndexFigure(sgv); - //figure.add(indexFigure); - //getViewer().addPropertyChangeListener(indexFigure); - } - } - refresh(); - } - - protected LayeredPane createPrintableLayers() - { - LayeredPane pane = super.createPrintableLayers(); - Layer layer = new ScaledHandleLayer(); - layer.setPreferredSize(new Dimension(5, 5)); - pane.add(layer, DesignViewerGraphicConstants.SCALED_HANDLE_LAYER); - return pane; - } - - - class ScaledHandleLayer extends Layer - { - ScaledHandleLayer() - { - setEnabled(true); - } - /** - * @see org.eclipse.draw2d.Figure#getPreferredSize(int, int) - */ - public Dimension getPreferredSize(int wHint, int hHint) - { - Rectangle rect = new Rectangle(); - for (int i = 0; i < getChildren().size(); i++) - rect.union(((IFigure)getChildren().get(i)).getBounds()); - return rect.getSize(); - } - } - - class IndexFigure extends RectangleFigure implements PropertyChangeListener - { - EditPart editPart; - ScrollingGraphicalViewer sgv; - public IndexFigure(ScrollingGraphicalViewer sgv) - { - this.sgv = sgv; - ((FigureCanvas)sgv.getControl()).getViewport().getHorizontalRangeModel().addPropertyChangeListener(this); - ((FigureCanvas)sgv.getControl()).getViewport().getVerticalRangeModel().addPropertyChangeListener(this); - Rectangle bounds = new Rectangle(0, 0, 40, 40); - translateToAbsolute(bounds); - setBounds(bounds); - } - public void propertyChange(PropertyChangeEvent evt) - { - System.out.println("scroll-change"); - Rectangle bounds = new Rectangle(0, 0, 40, 40); - Point p = ((FigureCanvas)sgv.getControl()).getViewport().getViewLocation(); - bounds.translate(p); - setBounds(bounds); - } - - public Rectangle getBounds() - { - Point p = ((FigureCanvas)sgv.getControl()).getViewport().getViewLocation(); - bounds.translate(p); - return super.getBounds().getCopy().translate(p); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/RootHolderEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/RootHolderEditPart.java deleted file mode 100644 index a4ad059af0..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/RootHolderEditPart.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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.design.editparts; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Panel; -import org.eclipse.draw2d.ToolbarLayout; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.FocusTypeColumn; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.ReferencedTypeColumn; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.RootHolder; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; - -public class RootHolderEditPart extends BaseEditPart implements IHolderEditPart -{ - protected Panel panel; - - public RootHolderEditPart() - { - } - - protected IFigure createFigure() - { - panel = new Panel(); - ToolbarLayout layout = new ToolbarLayout(true); - layout.setStretchMinorAxis(false); - layout.setSpacing(100); - panel.setLayoutManager(layout); - - return panel; - } - - protected List getModelChildren() - { - List collections = new ArrayList(); - RootHolder holder = (RootHolder)getModel(); - IADTObject focusObject = holder.getModel(); - collections.add(new FocusTypeColumn(focusObject)); - collections.add(new ReferencedTypeColumn(focusObject)); - return collections; - } - - protected void createEditPolicies() - { - super.createEditPolicies(); - } - - public boolean isSelectable() - { - return false; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/SectionEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/SectionEditPart.java deleted file mode 100644 index a25af476be..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/SectionEditPart.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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.design.editparts; - -import org.eclipse.draw2d.Figure; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.ToolbarLayout; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IComplexType; - -public class SectionEditPart extends BaseEditPart -{ - protected IComplexType complexType; - - protected IFigure createFigure() - { - Figure fig = new Figure(); - fig.setLayoutManager(new ToolbarLayout()); - return fig; - } - - protected void createEditPolicies() - { - - } - - public boolean isSelectable() - { - return false; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/StructureEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/StructureEditPart.java deleted file mode 100644 index 167bfcfc8a..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/StructureEditPart.java +++ /dev/null @@ -1,249 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2009 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.design.editparts; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.Request; -import org.eclipse.gef.RequestConstants; -import org.eclipse.gef.requests.LocationRequest; -import org.eclipse.gef.ui.actions.ActionRegistry; -import org.eclipse.jface.action.IAction; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDComplexTypeDefinitionAdapter; -import org.eclipse.wst.xsd.ui.internal.adt.actions.SetInputToGraphView; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.Compartment; -import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.ADTDirectEditPolicy; -import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.ADTSelectionFeedbackEditPolicy; -import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.KeyBoardAccessibilityEditPolicy; -import org.eclipse.wst.xsd.ui.internal.adt.design.figures.IStructureFigure; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IStructure; -import org.eclipse.wst.xsd.ui.internal.common.actions.OpenInNewEditor; -import org.eclipse.wst.xsd.ui.internal.design.editparts.SpaceFillerForFieldEditPart; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDSchema; - -public class StructureEditPart extends BaseTypeConnectingEditPart implements INamedEditPart -{ - protected List compartmentList = null; - protected ADTDirectEditPolicy adtDirectEditPolicy = new ADTDirectEditPolicy(); - protected TypeReferenceConnection connectionFigure; - protected TypeReferenceConnection connectionFeedbackFigure; - - /** - * TODO cs... I'm sure this has something to do with the way we wanted to rework compartment creation - * I suppose we could have subclasses override this method instead of getModelChildren() - * - * @deprecated - */ - protected Compartment[] getCompartments() - { - return null; - } - - protected IFigure createFigure() - { - IStructureFigure figure = getFigureFactory().createStructureFigure(getModel()); - return figure; - } - - public IStructureFigure getStructureFigure() - { - return (IStructureFigure)getFigure(); - } - - public IFigure getContentPane() - { - return getStructureFigure().getContentPane(); - } - - - public EditPart doGetRelativeEditPart(EditPart editPart, int direction) - { - EditPart result = null; - if (direction == KeyBoardAccessibilityEditPolicy.IN_TO_FIRST_CHILD) - { - for (Iterator i = getChildren().iterator(); i.hasNext();) - { - CompartmentEditPart compartment = (CompartmentEditPart)i.next(); - if (compartment.hasContent()) - { - for (Iterator contentChildren = compartment.getChildren().iterator(); contentChildren.hasNext(); ) - { - Object child = contentChildren.next(); - if (child instanceof SectionEditPart) - { - SectionEditPart part = (SectionEditPart) child; - result = (EditPart)part.getChildren().get(0); - return result; - } - else if (child instanceof BaseFieldEditPart && (!(child instanceof SpaceFillerForFieldEditPart))) - { - result = (EditPart)child; - return result; - } - } - } - } - } - else - { - return super.doGetRelativeEditPart(editPart, direction); - } - return result; - } - - protected void createEditPolicies() - { - super.createEditPolicies(); - installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new ADTSelectionFeedbackEditPolicy()); - installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, adtDirectEditPolicy); - } - - protected IStructure getStructure() - { - return (IStructure)getModel(); - } - - protected List getModelChildren() - { - if (compartmentList == null) - { - compartmentList = new ArrayList(); - - // TODO.. this needs to be moved to the xsd specific version of this class - compartmentList.add(new Compartment(getStructure(), "attribute")); //$NON-NLS-1$ - compartmentList.add(new Compartment(getStructure(), "element")); //$NON-NLS-1$ - } - return compartmentList; - } - - protected void refreshChildren() - { - super.refreshChildren(); - //getFigure().invalidateTree(); - } - - protected void refreshVisuals() - { - super.refreshVisuals(); - getStructureFigure().refreshVisuals(getModel()); - } - - public void addFeedback() - { - getStructureFigure().addSelectionFeedback(); - super.addFeedback(); - } - - public void removeFeedback() - { - getStructureFigure().removeSelectionFeedback(); - super.removeFeedback(); - } - - public Label getNameLabelFigure() - { - return getStructureFigure().getNameLabel(); - } - - public void performDirectEdit(Point cursorLocation) - { - - } - - public void performRequest(Request request) - { - if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) - { - if (request instanceof LocationRequest) - { - // uncomment for direct edit of name (add else) -// LocationRequest locationRequest = (LocationRequest)request; -// Point p = locationRequest.getLocation(); -// if (hitTest(getNameLabelFigure(), p)) -// { -// LabelEditManager manager = new LabelEditManager(this, new LabelCellEditorLocator(this, p)); -// NameUpdateCommandWrapper wrapper = new NameUpdateCommandWrapper(); -// adtDirectEditPolicy.setUpdateCommand(wrapper); -// manager.show(); -// } - } - } - else if (request.getType() == RequestConstants.REQ_OPEN) - { - Object model = getModel(); - if (request instanceof LocationRequest) - { - LocationRequest locationRequest = (LocationRequest)request; - Point p = locationRequest.getLocation(); - - if (getStructureFigure().hitTestHeader(p)) - { - // TODO: !!! This should be moved to the adt-xsd package - // - if (model instanceof XSDComplexTypeDefinitionAdapter) - { - XSDComplexTypeDefinitionAdapter adapter = (XSDComplexTypeDefinitionAdapter)model; - XSDComplexTypeDefinition ct = (XSDComplexTypeDefinition)adapter.getTarget(); - IWorkbench workbench = PlatformUI.getWorkbench(); - IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - IEditorPart editorPart = workbenchWindow.getActivePage().getActiveEditor(); - Object schema = editorPart.getAdapter(XSDSchema.class); - ActionRegistry registry = getEditorActionRegistry(editorPart); - if (registry != null) - { - if (schema == ct.getSchema()) - { - IAction action = registry.getAction(SetInputToGraphView.ID); - action.run(); - } - else - { - IAction action = registry.getAction(OpenInNewEditor.ID); - action.run(); - } - } - } - } - } - } - } - - protected ActionRegistry getEditorActionRegistry(IEditorPart editor) - { - return (ActionRegistry) editor.getAdapter(ActionRegistry.class); - } - - protected boolean shouldDrawConnection() - { - return false; - } - - public TypeReferenceConnection createConnectionFigure() - { - return null; - } - public String getReaderText() - { - // return getStructureFigure().getNameLabel().getText(); - return getNameLabelFigure().getText(); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/TopLevelFieldEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/TopLevelFieldEditPart.java deleted file mode 100644 index 1ad0195f3f..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/TopLevelFieldEditPart.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2009 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.design.editparts; - -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.Request; -import org.eclipse.gef.RequestConstants; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; -import org.eclipse.swt.graphics.Font; -import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.ADTDirectEditPolicy; -import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.ADTSelectionFeedbackEditPolicy; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IField; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IType; -import org.eclipse.wst.xsd.ui.internal.adt.typeviz.design.figures.BoxFigure; - -public class TopLevelFieldEditPart extends BoxEditPart implements INamedEditPart -{ - protected ADTDirectEditPolicy adtDirectEditPolicy = new ADTDirectEditPolicy(); - private Font italicFont; - - protected boolean shouldDrawConnection() - { - IField field = (IField)getModel(); - IType type = field.getType(); - return (type != null); - } - - public TypeReferenceConnection createConnectionFigure() - { - TypeReferenceConnection connectionFigure = null; - IField field = (IField)getModel(); - IType type = field.getType(); - if (type != null) - { - AbstractGraphicalEditPart referenceTypePart = (AbstractGraphicalEditPart)getViewer().getEditPartRegistry().get(type); - if (referenceTypePart != null) - { - connectionFigure = new TypeReferenceConnection(); - connectionFigure.setSourceAnchor(new CenteredConnectionAnchor(getFigure(), CenteredConnectionAnchor.RIGHT, 0)); - int targetAnchorYOffset = 12; - connectionFigure.setTargetAnchor(new CenteredConnectionAnchor(referenceTypePart.getFigure(), CenteredConnectionAnchor.HEADER_LEFT, 0, targetAnchorYOffset)); - connectionFigure.setHighlight(false); - } - } - return connectionFigure; - } - - protected void createEditPolicies() - { - super.createEditPolicies(); - installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, adtDirectEditPolicy); - installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new ADTSelectionFeedbackEditPolicy()); - } - - protected void refreshVisuals() - { - IField field = (IField)getModel(); - BoxFigure boxFigure = (BoxFigure)getFigure(); - Label label = boxFigure.getNameLabel(); - label.setText(field.getName()); - if (field.isAbstract()) - { - if (italicFont == null) - { - Font font = label.getFont(); - italicFont = getItalicFont(font); - } - if (italicFont != null) - { - label.setFont(italicFont); - } - } - else - { - label.setFont(label.getParent().getFont()); - } - super.refreshVisuals(); - } - - public void deactivate() - { - if (italicFont != null) - { - italicFont.dispose(); - italicFont = null; - } - super.deactivate(); - } - - public Label getNameLabelFigure() - { - BoxFigure boxFigure = (BoxFigure)getFigure(); - return boxFigure.getNameLabel(); - } - - public void performDirectEdit(Point cursorLocation) - { - - } - public String getReaderText() - { - return getNameLabelFigure().getText(); - } - - public void performRequest(Request request) - { - if (request.getType() == RequestConstants.REQ_DIRECT_EDIT|| - request.getType() == RequestConstants.REQ_OPEN) - { -// if (request instanceof LocationRequest) -// { -// LocationRequest locationRequest = (LocationRequest)request; -// Point p = locationRequest.getLocation(); -// -// if (hitTest(getNameLabelFigure(), p)) -// { -// LabelEditManager manager = new LabelEditManager(this, new LabelCellEditorLocator(this, p)); -// NameUpdateCommandWrapper wrapper = new NameUpdateCommandWrapper(); -// adtDirectEditPolicy.setUpdateCommand(wrapper); -// manager.show(); -// } -// } - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/TypeReferenceConnection.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/TypeReferenceConnection.java deleted file mode 100644 index 0d7da4aba0..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/TypeReferenceConnection.java +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 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.design.editparts; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.ConnectionRouter; -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.ManhattanConnectionRouter; -import org.eclipse.draw2d.PolygonDecoration; -import org.eclipse.draw2d.PolylineConnection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.widgets.Display; - -public class TypeReferenceConnection extends PolylineConnection -{ - protected boolean highlight = false; - protected static final Color activeConnection = ColorConstants.black; - protected static final Color inactiveConnection = new Color(null, 198, 195, 198); - - /** - * Default constructor - */ - public TypeReferenceConnection() - { - super(); - setTargetDecoration(new PolygonDecoration()); - } - - public TypeReferenceConnection(boolean fill) - { - super(); - PolygonDecoration dec = new PolygonDecoration() - { - protected void fillShape(Graphics g) - { - try - { - g.pushState(); - g.setBackgroundColor(ColorConstants.white); - super.fillShape(g); - } - finally - { - g.popState(); - } - } - - }; - dec.setFill(fill); - dec.setTemplate(PolygonDecoration.TRIANGLE_TIP); - dec.setScale(14,6); - setTargetDecoration(dec); - } - - - public void setConnectionRouter(ConnectionRouter cr) - { - if (cr != null && getConnectionRouter() != null && !(getConnectionRouter() instanceof ManhattanConnectionRouter)) - super.setConnectionRouter(cr); - } - - /** - * @return Returns the current highlight status. - */ - public boolean isHighlighted() - { - return highlight; - } - - /** - * @param highlight - * The highlight to set. - */ - public void setHighlight(boolean highlight) - { - this.highlight = highlight; - // Update our connection to use the correct colouring - boolean highContrast = false; - try - { - highContrast = Display.getDefault().getHighContrast(); - } - catch (Exception e) - { - } - if (highContrast) - { - setForegroundColor(highlight ? Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND) : ColorConstants.lightGray); - } - else - { - setForegroundColor(highlight ? activeConnection : inactiveConnection); - } - setOpaque(highlight); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/AbstractModelCollection.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/AbstractModelCollection.java deleted file mode 100644 index dbeb88e177..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/AbstractModelCollection.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 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.design.editparts.model; - -import java.util.List; - -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObjectListener; - -public abstract class AbstractModelCollection implements IADTObject -{ - protected IADTObject model; - protected String kind; - - public AbstractModelCollection(IADTObject model, String kind) - { - this.model = model; - this.kind = kind; - } - - public Object getModel() - { - return model; - } - - public void setModel(IADTObject model) - { - this.model = model; - } - - public String getKind() - { - return kind; - } - - public void setKind(String kind) - { - this.kind = kind; - } - - public abstract List getChildren(); - - public void registerListener(IADTObjectListener listener) - { - model.registerListener(listener); - } - - public void unregisterListener(IADTObjectListener listener) - { - model.unregisterListener(listener); - } - - public boolean isReadOnly() - { - return false; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/Annotation.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/Annotation.java deleted file mode 100644 index 1f67a7fdd8..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/Annotation.java +++ /dev/null @@ -1,37 +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.design.editparts.model; - -import org.eclipse.wst.xsd.ui.internal.adt.facade.IStructure; - -public class Annotation -{ - Compartment compartment; - public Annotation() - { - super(); - } - - public void setCompartment(Compartment compartment) - { - this.compartment = compartment; - } - - public Compartment getCompartment() - { - return compartment; - } - - public IStructure getOwner() - { - return compartment.getOwner(); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/Compartment.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/Compartment.java deleted file mode 100644 index 628cd4f8ef..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/Compartment.java +++ /dev/null @@ -1,73 +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.design.editparts.model; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObjectListener; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IField; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IStructure; - -public class Compartment implements IADTObject -{ - String kind; - IStructure owner; - - public Compartment(IStructure owner, String kind) - { - this.kind = kind; - this.owner = owner; - } - - public List getChildren() - { - List list = new ArrayList(); - for (Iterator i = owner.getFields().iterator(); i.hasNext();) - { - IField field = (IField) i.next(); - if (kind == null || kind.equals(field.getKind())) - { - list.add(field); - } - } - return list; - } - - public String getKind() - { - return kind; - } - - public IStructure getOwner() - { - return owner; - } - - public void registerListener(IADTObjectListener listener) - { - // really we want to listen to the owner - owner.registerListener(listener); - } - - public void unregisterListener(IADTObjectListener listener) - { - // really we want to listen to the owner - owner.unregisterListener(listener); - } - - public boolean isReadOnly() - { - return false; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/FocusTypeColumn.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/FocusTypeColumn.java deleted file mode 100644 index 60a6fc19c2..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/FocusTypeColumn.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 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.design.editparts.model; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IField; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IStructure; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IType; - -public class FocusTypeColumn extends AbstractModelCollection -{ - protected boolean isFocusObject = false; - - public FocusTypeColumn(IADTObject model) - { - super(model, "FocusTypeColumn"); //$NON-NLS-1$ - } - - public FocusTypeColumn(IADTObject model, boolean isFocusObject) - { - super(model, "FocusTypeColumn"); //$NON-NLS-1$ - this.isFocusObject = isFocusObject; - } - - public List getChildren() - { - List result = new ArrayList(); - if (model instanceof IType) - { - IType type = (IType)model; - if (type.getSuperType() != null) - { - result.add(type.getSuperType()); - } - result.add(type); - } - else if (model instanceof IField || - model instanceof IStructure) - { - result.add(model); - } - return result; - } - - public boolean isFocusObject() - { - return isFocusObject; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/IActionProvider.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/IActionProvider.java deleted file mode 100644 index d8443fa552..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/IActionProvider.java +++ /dev/null @@ -1,18 +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.design.editparts.model; - - - -public interface IActionProvider -{ - public String[] getActions(Object object); -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/IFeedbackHandler.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/IFeedbackHandler.java deleted file mode 100644 index 18e860b330..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/IFeedbackHandler.java +++ /dev/null @@ -1,17 +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.design.editparts.model; - -public interface IFeedbackHandler -{ - public void addFeedback(); - public void removeFeedback(); -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/IGraphElement.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/IGraphElement.java deleted file mode 100644 index 9b2f5cba55..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/IGraphElement.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2009 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.design.editparts.model; - -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel; -import org.eclipse.gef.commands.Command; - -public interface IGraphElement -{ - boolean isFocusAllowed(); - IADTObject getTopContainer(); - Command getDeleteCommand(); - IModel getModel(); - boolean isReadOnly(); -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/IModelProxy.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/IModelProxy.java deleted file mode 100644 index f263c38dd6..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/IModelProxy.java +++ /dev/null @@ -1,18 +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.design.editparts.model; - -import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel; - -public interface IModelProxy -{ - IModel getModel(); -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/ReferencedTypeColumn.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/ReferencedTypeColumn.java deleted file mode 100644 index 95f8970e0a..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/ReferencedTypeColumn.java +++ /dev/null @@ -1,138 +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.design.editparts.model; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObjectListener; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IField; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IStructure; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IType; - -public class ReferencedTypeColumn extends AbstractModelCollection -{ - List listenerList = new ArrayList(); - InternalListener internalListener = new InternalListener(); - - // todo... really this this model object should listen - // to the parent of the IType - // - public ReferencedTypeColumn(IADTObject model) - { - super(model, "ReferencedTypeColumn"); //$NON-NLS-1$ - model.registerListener(internalListener); - internalListener.recomputeSubListeners(); - } - - public List getChildren() - { - List result = new ArrayList(); - if (model instanceof IStructure) - { - IStructure structure = (IStructure)model; - for (Iterator i = structure.getFields().iterator(); i.hasNext(); ) - { - IField field = (IField)i.next(); - IType type = field.getType(); - if (type != null) // && type.isComplexType()) - { - if (!result.contains(type)) - { - if (type instanceof IGraphElement) - { - if (((IGraphElement)type).isFocusAllowed()) - result.add(type); - } - } - } - } - } - else if (model instanceof IField) - { - IField field = (IField)model; - IType type = field.getType(); - if (type != null) // && type.isComplexType()) - { - if (type instanceof IGraphElement) - { - if (((IGraphElement)type).isFocusAllowed()) - result.add(type); - } - } - } - return result; - } - - public void registerListener(IADTObjectListener listener) - { - listenerList.add(listener); - } - - public void unregisterListener(IADTObjectListener listener) - { - listenerList.remove(listener); - } - - protected void notifyListeners(Object changedObject, String property) - { - List clonedListenerList = new ArrayList(); - clonedListenerList.addAll(listenerList); - for (Iterator i = clonedListenerList.iterator(); i.hasNext(); ) - { - IADTObjectListener listener = (IADTObjectListener)i.next(); - listener.propertyChanged(this, null); - } - } - - protected class InternalListener implements IADTObjectListener - { - List fields = new ArrayList(); - - void recomputeSubListeners() - { - if (model instanceof IStructure) - { - // remove old ones - for (Iterator i = fields.iterator(); i.hasNext();) - { - IField field = (IField) i.next(); - field.unregisterListener(this); - } - // add new ones - fields.clear(); - IStructure complexType = (IStructure) model; - for (Iterator i = complexType.getFields().iterator(); i.hasNext();) - { - IField field = (IField) i.next(); - fields.add(field); - field.registerListener(this); - } - } - } - - public void propertyChanged(Object object, String property) - { - if (object == model) - { - // we need to update the fields we're listening too - // since these may have changed - recomputeSubListeners(); - } - else if (object instanceof IField) - { - } - notifyListeners(object, property); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/RootHolder.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/RootHolder.java deleted file mode 100644 index ca7b3a6225..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/model/RootHolder.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 22007 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.design.editparts.model; - -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; - -public class RootHolder -{ - IADTObject model; - - public RootHolder(IADTObject model) - { - this.model = model; - } - - public IADTObject getModel() - { - return model; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editpolicies/ADTDirectEditPolicy.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editpolicies/ADTDirectEditPolicy.java deleted file mode 100644 index b7f22b30a5..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editpolicies/ADTDirectEditPolicy.java +++ /dev/null @@ -1,46 +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.design.editpolicies; - -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.editpolicies.DirectEditPolicy; -import org.eclipse.gef.requests.DirectEditRequest; -import org.eclipse.wst.xsd.ui.internal.adt.design.directedit.ComboBoxCellEditorManager; - -public class ADTDirectEditPolicy extends DirectEditPolicy -{ - protected ComboBoxCellEditorManager delegate; - protected IADTUpdateCommand command; - - public ADTDirectEditPolicy() - { - super(); - } - - - public void setUpdateCommand(IADTUpdateCommand command) - { - this.command = command; - } - - protected void showCurrentEditValue(DirectEditRequest request) - { - getHostFigure().getUpdateManager().performUpdate(); - } - - protected Command getDirectEditCommand(DirectEditRequest request) - { - command.setRequest(request); - return (Command)command; - } - - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editpolicies/ADTSelectionFeedbackEditPolicy.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editpolicies/ADTSelectionFeedbackEditPolicy.java deleted file mode 100644 index 0747165e75..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editpolicies/ADTSelectionFeedbackEditPolicy.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 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.design.editpolicies; - -import org.eclipse.gef.editpolicies.SelectionEditPolicy; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IFeedbackHandler; - -public class ADTSelectionFeedbackEditPolicy extends SelectionEditPolicy -{ - - public ADTSelectionFeedbackEditPolicy() - { - super(); - } - - protected void hideSelection() - { - if (getHost() instanceof IFeedbackHandler) - { - ((IFeedbackHandler) getHost()).removeFeedback(); - } - } - - protected void showSelection() - { - if (getHost() instanceof IFeedbackHandler) - { - ((IFeedbackHandler) getHost()).addFeedback(); - } - } - - protected void showFocus() - { - super.showFocus(); - getHost().setFocus(true); - } - - protected void hideFocus() - { - super.hideFocus(); - getHost().setFocus(false); - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editpolicies/DirectEditPolicyDelegate.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editpolicies/DirectEditPolicyDelegate.java deleted file mode 100644 index 151b493512..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editpolicies/DirectEditPolicyDelegate.java +++ /dev/null @@ -1,18 +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.design.editpolicies; - -import org.eclipse.jface.viewers.CellEditor; - -public interface DirectEditPolicyDelegate -{ - public void performEdit(CellEditor cellEditor); -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editpolicies/IADTUpdateCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editpolicies/IADTUpdateCommand.java deleted file mode 100644 index a4c4eb50bb..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editpolicies/IADTUpdateCommand.java +++ /dev/null @@ -1,18 +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.design.editpolicies; - -import org.eclipse.gef.requests.DirectEditRequest; - -public interface IADTUpdateCommand -{ - void setRequest(DirectEditRequest request); -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editpolicies/KeyBoardAccessibilityEditPolicy.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editpolicies/KeyBoardAccessibilityEditPolicy.java deleted file mode 100644 index dd0ee63e22..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editpolicies/KeyBoardAccessibilityEditPolicy.java +++ /dev/null @@ -1,28 +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.design.editpolicies; - -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.editpolicies.GraphicalEditPolicy; - -public class KeyBoardAccessibilityEditPolicy extends GraphicalEditPolicy -{ - public static String KEY = "KeyBoardAccessibilityEditPolicy"; - - public static int OUT_TO_PARENT = PositionConstants.ALWAYS_LEFT; - public static int IN_TO_FIRST_CHILD = PositionConstants.ALWAYS_RIGHT; - - public EditPart getRelativeEditPart(EditPart editPart, int direction) - { - return null; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editpolicies/SimpleDirectEditPolicy.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editpolicies/SimpleDirectEditPolicy.java deleted file mode 100644 index 4e38e39f6e..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editpolicies/SimpleDirectEditPolicy.java +++ /dev/null @@ -1,58 +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.design.editpolicies; - -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.editpolicies.DirectEditPolicy; -import org.eclipse.gef.requests.DirectEditRequest; - -public class SimpleDirectEditPolicy extends DirectEditPolicy -{ - protected DirectEditPolicyDelegate delegate; - - public void setDelegate(DirectEditPolicyDelegate delegate) - { - this.delegate = delegate; - } - - protected org.eclipse.gef.commands.Command getDirectEditCommand(final DirectEditRequest request) - { - return new Command() //AbstractCommand() - { - public void execute() - { - if (delegate != null) - { - delegate.performEdit(request.getCellEditor()); - } - } - - public void redo() - { - } - - public void undo() - { - } - - public boolean canExecute() - { - return true; - } - }; - } - - protected void showCurrentEditValue(DirectEditRequest request) - { - //hack to prevent async layout from placing the cell editor twice. - getHostFigure().getUpdateManager().performUpdate(); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/figures/IADTFigure.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/figures/IADTFigure.java deleted file mode 100644 index 284a26043b..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/figures/IADTFigure.java +++ /dev/null @@ -1,22 +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.design.figures; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.gef.EditPart; - -public interface IADTFigure extends IFigure -{ - void editPartAttached(EditPart owner); - void addSelectionFeedback(); - void removeSelectionFeedback(); - void refreshVisuals(Object model); -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/figures/ICompartmentFigure.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/figures/ICompartmentFigure.java deleted file mode 100644 index 3e25deff34..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/figures/ICompartmentFigure.java +++ /dev/null @@ -1,19 +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.design.figures; - -import org.eclipse.draw2d.IFigure; - -public interface ICompartmentFigure extends IADTFigure -{ - IFigure getContentPane(); - IFigure getAnnotationPane(); -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/figures/IFieldFigure.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/figures/IFieldFigure.java deleted file mode 100644 index efabeb0e68..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/figures/IFieldFigure.java +++ /dev/null @@ -1,23 +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.design.figures; - -import org.eclipse.draw2d.Label; - - -public interface IFieldFigure extends IADTFigure -{ - Label getTypeLabel(); - Label getNameLabel(); - Label getNameAnnotationLabel(); - Label getTypeAnnotationLabel(); - void recomputeLayout(); -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/figures/IFigureFactory.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/figures/IFigureFactory.java deleted file mode 100644 index d6efe614c4..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/figures/IFigureFactory.java +++ /dev/null @@ -1,18 +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.design.figures; - -public interface IFigureFactory -{ - IFieldFigure createFieldFigure(Object model); - IStructureFigure createStructureFigure(Object model); - ICompartmentFigure createCompartmentFigure(Object model); -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/figures/IStructureFigure.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/figures/IStructureFigure.java deleted file mode 100644 index 5a96af2019..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/figures/IStructureFigure.java +++ /dev/null @@ -1,22 +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.design.figures; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.geometry.Point; - -public interface IStructureFigure extends IADTFigure -{ - IFigure getContentPane(); - Label getNameLabel(); - boolean hitTestHeader(Point point); -} |