Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editpolicies')
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editpolicies/DragAndDropEditPolicy.java45
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editpolicies/GraphNodeDragTracker.java33
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editpolicies/SelectionHandlesEditPolicyImpl.java237
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editpolicies/TopLevelComponentLabelCellEditorLocator.java49
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editpolicies/TopLevelNameDirectEditManager.java171
5 files changed, 0 insertions, 535 deletions
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editpolicies/DragAndDropEditPolicy.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editpolicies/DragAndDropEditPolicy.java
deleted file mode 100644
index e5bbbcc400..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editpolicies/DragAndDropEditPolicy.java
+++ /dev/null
@@ -1,45 +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.design.editpolicies;
-
-import org.eclipse.gef.EditPartViewer;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.requests.ChangeBoundsRequest;
-import org.eclipse.wst.xsd.ui.internal.commands.DragAndDropCommand;
-
-public class DragAndDropEditPolicy extends org.eclipse.gef.editpolicies.GraphicalEditPolicy
-{
- protected EditPartViewer viewer;
- protected SelectionHandlesEditPolicyImpl selectionHandlesEditPolicy;
-
- public DragAndDropEditPolicy(EditPartViewer viewer, SelectionHandlesEditPolicyImpl selectionHandlesEditPolicy)
- {
- this.viewer = viewer;
- this.selectionHandlesEditPolicy = selectionHandlesEditPolicy;
- }
-
- public boolean understandsRequest(Request req)
- {
- return true;
- }
-
-
- public org.eclipse.gef.commands.Command getCommand(Request request)
- {
- DragAndDropCommand command = null;
- if (request instanceof ChangeBoundsRequest)
- {
- command = new DragAndDropCommand(viewer, (ChangeBoundsRequest)request);
- selectionHandlesEditPolicy.setDragAndDropCommand(command);
- }
- return command;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editpolicies/GraphNodeDragTracker.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editpolicies/GraphNodeDragTracker.java
deleted file mode 100644
index 3a8b31801d..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editpolicies/GraphNodeDragTracker.java
+++ /dev/null
@@ -1,33 +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.design.editpolicies;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.tools.DragEditPartsTracker;
-
-
-public class GraphNodeDragTracker extends DragEditPartsTracker
-{
- protected EditPart editPart;
-
- public GraphNodeDragTracker(EditPart editPart)
- {
- super(editPart);
- this.editPart = editPart;
- }
-
- protected Command getCommand()
- {
- Request request = getTargetRequest();
- return editPart.getCommand(request);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editpolicies/SelectionHandlesEditPolicyImpl.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editpolicies/SelectionHandlesEditPolicyImpl.java
deleted file mode 100644
index 655916c00b..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editpolicies/SelectionHandlesEditPolicyImpl.java
+++ /dev/null
@@ -1,237 +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.design.editpolicies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.Figure;
-import org.eclipse.draw2d.FigureUtilities;
-import org.eclipse.draw2d.FreeformLayout;
-import org.eclipse.draw2d.Graphics;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Polyline;
-import org.eclipse.draw2d.RectangleFigure;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.PointList;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.handles.MoveHandle;
-import org.eclipse.gef.handles.MoveHandleLocator;
-import org.eclipse.gef.requests.ChangeBoundsRequest;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseEditPart;
-import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.ADTSelectionFeedbackEditPolicy;
-import org.eclipse.wst.xsd.ui.internal.commands.DragAndDropCommand;
-
-
-public class SelectionHandlesEditPolicyImpl extends ADTSelectionFeedbackEditPolicy
-{
- protected IFigure feedback;
- protected Rectangle originalLocation;
- protected DragAndDropCommand dragAndDropCommand;
- protected Polyline polyLine;
- protected RectangleFigure ghostShape;
-
- protected List createSelectionHandles()
- {
- List list = new ArrayList();
- EditPart editPart = getHost();
-
- if (editPart instanceof GraphicalEditPart)
- {
- GraphicalEditPart graphicalEditPart = (GraphicalEditPart)editPart;
- IFigure figure = (graphicalEditPart instanceof BaseEditPart) ?
- ((BaseEditPart)graphicalEditPart).getFigure() :
- graphicalEditPart.getFigure();
-
- Cursor cursorFigure = figure.getCursor();
- MoveHandleLocator loc = new MoveHandleLocator(figure);
- MoveHandle moveHandle = new MoveHandle(graphicalEditPart, loc);
- moveHandle.setCursor(cursorFigure);
- list.add(moveHandle);
- }
-
- return list;
- }
-
-
- public boolean understandsRequest(Request request)
- {
- boolean result = false;
-
- if (REQ_MOVE.equals(request.getType()))
- {
- result = false; // return false to disable move for now
- }
- else
- {
- result = super.understandsRequest(request);
- }
- return result;
- }
-
-
- public org.eclipse.gef.commands.Command getCommand(Request request)
- {
- return null;
- }
-
- public void setDragAndDropCommand(DragAndDropCommand dragAndDropCommand)
- {
- this.dragAndDropCommand = dragAndDropCommand;
- }
-
- protected org.eclipse.gef.commands.Command getMoveCommand(ChangeBoundsRequest request)
- {
- ChangeBoundsRequest req = new ChangeBoundsRequest(REQ_MOVE_CHILDREN);
- req.setEditParts(getHost());
-
- req.setMoveDelta(request.getMoveDelta());
- req.setSizeDelta(request.getSizeDelta());
- req.setLocation(request.getLocation());
-
- return getHost().getParent().getCommand(req);
- }
-
- public void showSourceFeedback(Request request)
- {
- if (REQ_MOVE.equals(request.getType()) ||
- REQ_ADD.equals(request.getType()))
- showChangeBoundsFeedback((ChangeBoundsRequest)request);
- }
-
- protected void showChangeBoundsFeedback(ChangeBoundsRequest request)
- {
- IFigure p = getDragSourceFeedbackFigure();
- Rectangle r = originalLocation.getTranslated(request.getMoveDelta());
- Dimension resize = request.getSizeDelta();
- r.width += resize.width;
- r.height+= resize.height;
-
- ((GraphicalEditPart)getHost()).getFigure().translateToAbsolute(r);
-
- p.translateToRelative(r);
- Rectangle pBounds = r.getCopy();
-
- if (dragAndDropCommand != null && dragAndDropCommand.canExecute())
- {
- int size = request.getEditParts().size();
- if (size > 0 && request.getEditParts().get(size - 1) == getHost())
- {
- PointList pointList = dragAndDropCommand.getConnectionPoints(r);
- if (pointList != null && pointList.size() > 0)
- {
- polyLine.setPoints(pointList);
-
- Point firstPoint = pointList.getFirstPoint();
- if (firstPoint != null)
- {
- pBounds = pBounds.getUnion(new Rectangle(firstPoint.x, firstPoint.y, 1, 1));
- }
- }
- }
- }
- p.setBounds(pBounds);
- ghostShape.setBounds(r);
- p.validate();
- }
-
-
-
-
- protected IFigure getDragSourceFeedbackFigure()
- {
- EditPart editPart = getHost();
- if (feedback == null && editPart instanceof BaseEditPart)
- {
- BaseEditPart baseEditPart = (BaseEditPart)editPart;
- originalLocation = new Rectangle(baseEditPart.getFigure().getBounds());
- feedback = createDragSourceFeedbackFigure(baseEditPart.getFigure());
- }
- return feedback;
- }
-
- protected IFigure createDragSourceFeedbackFigure(IFigure draggedFigure)
- {
- // Use a ghost rectangle for feedback
- Figure panel = new Figure();
- panel.setLayoutManager(new FreeformLayout());
-
- ghostShape = new RectangleFigure();
- FigureUtilities.makeGhostShape(ghostShape);
- ghostShape.setLineStyle(Graphics.LINE_DASHDOT);
- ghostShape.setForegroundColor(ColorConstants.white);
- ghostShape.setOpaque(false);
-
- Rectangle r = draggedFigure.getBounds();
- panel.setOpaque(false);
- panel.add(ghostShape);
-
- polyLine = new Polyline();
- //polyLine.setLineStyle(Graphics.LINE_DASHDOT);
- polyLine.setLineWidth(1);
- panel.add(polyLine);
-
- panel.setBounds(r);
- ghostShape.setBounds(r);
-
- addFeedback(panel);
-
- return panel;
- }
-
- public void deactivate()
- {
- if (feedback != null)
- {
- removeFeedback(feedback);
- feedback = null;
- }
- hideFocus();
- super.deactivate();
- }
-
- /**
- * Erase feedback indicating that the receiver object is
- * being dragged. This method is called when a drag is
- * completed or cancelled on the receiver object.
- * @param dragTracker org.eclipse.gef.tools.DragTracker The drag tracker of the tool performing the drag.
- */
- protected void eraseChangeBoundsFeedback(ChangeBoundsRequest request)
- {
- if (feedback != null)
- {
- removeFeedback(feedback);
- }
- feedback = null;
- originalLocation = null;
- }
-
- /**
- * Erase feedback indicating that the receiver object is
- * being dragged. This method is called when a drag is
- * completed or cancelled on the receiver object.
- * @param dragTracker org.eclipse.gef.tools.DragTracker The drag tracker of the tool performing the drag.
- */
- public void eraseSourceFeedback(Request request)
- {
- if (REQ_MOVE.equals(request.getType()) || REQ_ADD.equals(request.getType()))
- {
- eraseChangeBoundsFeedback((ChangeBoundsRequest)request);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editpolicies/TopLevelComponentLabelCellEditorLocator.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editpolicies/TopLevelComponentLabelCellEditorLocator.java
deleted file mode 100644
index a594a502f9..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editpolicies/TopLevelComponentLabelCellEditorLocator.java
+++ /dev/null
@@ -1,49 +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.design.editpolicies;
-
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.xsd.ui.internal.adt.design.directedit.LabelCellEditorLocator;
-import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.INamedEditPart;
-
-public class TopLevelComponentLabelCellEditorLocator extends LabelCellEditorLocator
-{
- public TopLevelComponentLabelCellEditorLocator(INamedEditPart namedEditPart, Point cursorLocation)
- {
- super(namedEditPart, cursorLocation);
- }
-
- public void relocate(CellEditor celleditor)
- {
- Text text = (Text) celleditor.getControl();
-
- Label label = namedEditPart.getNameLabelFigure();
-
- if (text.getBounds().x <= 0)
- {
- super.relocate(celleditor);
- }
- else
- {
- org.eclipse.swt.graphics.Point sel = text.getSelection();
- org.eclipse.swt.graphics.Point pref = text.computeSize(-1, -1);
- Rectangle rect = label.getTextBounds().getCopy();
- label.translateToAbsolute(rect);
- text.setBounds(rect.x, rect.y-1, rect.width, pref.y+1);
- text.setSelection(0);
- text.setSelection(sel);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editpolicies/TopLevelNameDirectEditManager.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editpolicies/TopLevelNameDirectEditManager.java
deleted file mode 100644
index e5b21c1bad..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editpolicies/TopLevelNameDirectEditManager.java
+++ /dev/null
@@ -1,171 +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.design.editpolicies;
-
-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.ISelectionProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-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.Display;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.part.CellEditorActionHandler;
-import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.INamedEditPart;
-import org.eclipse.wst.xsd.ui.internal.design.editparts.TopLevelComponentEditPart;
-import org.eclipse.xsd.XSDNamedComponent;
-
-public class TopLevelNameDirectEditManager extends DirectEditManager
-{
- protected XSDNamedComponent component;
- private IActionBars actionBars;
- private CellEditorActionHandler actionHandler;
- private IAction copy, cut, paste, undo, redo, find, selectAll, delete;
- private Font scaledFont;
-
- public TopLevelNameDirectEditManager(GraphicalEditPart source, CellEditorLocator locator, XSDNamedComponent component)
- {
- super(source, null, locator);
- this.component = component;
- }
-
- /**
- * @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();
-
- if (getEditPart() instanceof TopLevelComponentEditPart)
- {
- Runnable runnable = new Runnable()
- {
- public void run()
- {
- IWorkbench workbench = PlatformUI.getWorkbench();
- IEditorPart editor = workbench.getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- Object adapter = editor.getAdapter(ISelectionProvider.class);
- if (adapter instanceof ISelectionProvider)
- {
- ISelectionProvider sel = (ISelectionProvider) adapter;
- sel.setSelection(new StructuredSelection(getEditPart().getModel()));
- }
- }
- };
- Display.getCurrent().asyncExec(runnable);
- }
- }
-
- public void showFeedback()
- {
- super.showFeedback();
- }
-
- 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 = component.getName();
- 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);
- 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());
- delete = actionBars.getGlobalActionHandler(ActionFactory.DELETE.getId());
- 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());
- }
-
-} \ No newline at end of file

Back to the top