Author: dazarov
Date: 2008-07-10 08:52:26 -0400 (Thu, 10 Jul 2008)
New Revision: 9114
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ViewIDDirectEditPolicy.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ViewIDEditManager.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ViewIDEditorLocator.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/commands/AddExceptionOnDiagramHandler.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/commands/AddPageOnDiagramHandler.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ExceptionEditPart.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/GraphicalPartFactory.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PageEditPart.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesDiagramEditPart.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ExceptionFigure.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/PageFigure.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-2309
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/commands/AddExceptionOnDiagramHandler.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/commands/AddExceptionOnDiagramHandler.java 2008-07-09
19:47:26 UTC (rev 9113)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/commands/AddExceptionOnDiagramHandler.java 2008-07-10
12:52:26 UTC (rev 9114)
@@ -1,8 +1,8 @@
package org.jboss.tools.seam.ui.pages.editor.commands;
import java.util.Properties;
-import java.util.Random;
+import org.eclipse.draw2d.geometry.Point;
import org.jboss.tools.common.meta.XChild;
import org.jboss.tools.common.meta.XModelEntity;
import org.jboss.tools.common.meta.action.impl.AbstractHandler;
@@ -12,6 +12,8 @@
import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
import org.jboss.tools.seam.pages.xml.model.SeamPagesConstants;
import org.jboss.tools.seam.pages.xml.model.handlers.AddExceptionHandler;
+import org.jboss.tools.seam.ui.pages.editor.ecore.pages.PageException;
+import org.jboss.tools.seam.ui.pages.editor.ecore.pages.impl.PagesFactoryImpl;
import org.jboss.tools.seam.ui.pages.editor.edit.PagesDiagramEditPart;
public class AddExceptionOnDiagramHandler extends AbstractHandler {
@@ -27,12 +29,11 @@
PagesDiagramEditPart part = (PagesDiagramEditPart)p.get("diagramEditPart");
int x = Integer.parseInt(p.getProperty("mouse.x"));
int y = Integer.parseInt(p.getProperty("mouse.y"));
- System.out.println("x=" + x + " y=" + y + " part=" +
part);
- String className = "/test" + (new Random()).nextInt(10000);
- AddExceptionOnDiagramHandler.createException(object, className, p);
-
-// XActionInvoker.invoke("CreateActions.AddExceptionWizard", object, p);
+ PageException newException = PagesFactoryImpl.eINSTANCE.createPgException();
+ newException.setName("");
+ newException.setLocation(new Point(x,y));
+ part.getPagesModel().getChildren().add(newException);
}
/**
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/commands/AddPageOnDiagramHandler.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/commands/AddPageOnDiagramHandler.java 2008-07-09
19:47:26 UTC (rev 9113)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/commands/AddPageOnDiagramHandler.java 2008-07-10
12:52:26 UTC (rev 9114)
@@ -1,8 +1,8 @@
package org.jboss.tools.seam.ui.pages.editor.commands;
import java.util.Properties;
-import java.util.Random;
+import org.eclipse.draw2d.geometry.Point;
import org.jboss.tools.common.meta.action.impl.AbstractHandler;
import org.jboss.tools.common.model.XModelException;
import org.jboss.tools.common.model.XModelObject;
@@ -11,6 +11,8 @@
import org.jboss.tools.seam.pages.xml.model.handlers.AddExceptionHandler;
import org.jboss.tools.seam.pages.xml.model.handlers.AddViewSupport;
import org.jboss.tools.seam.pages.xml.model.helpers.SeamPagesDiagramHelper;
+import org.jboss.tools.seam.ui.pages.editor.ecore.pages.Page;
+import org.jboss.tools.seam.ui.pages.editor.ecore.pages.impl.PagesFactoryImpl;
import org.jboss.tools.seam.ui.pages.editor.edit.PagesDiagramEditPart;
public class AddPageOnDiagramHandler extends AbstractHandler {
@@ -26,13 +28,11 @@
PagesDiagramEditPart part = (PagesDiagramEditPart)p.get("diagramEditPart");
int x = Integer.parseInt(p.getProperty("mouse.x"));
int y = Integer.parseInt(p.getProperty("mouse.y"));
- System.out.println("x=" + x + " y=" + y + " part=" +
part);
-//
- String viewId = "/test" + (new Random()).nextInt(10000);
- AddPageOnDiagramHandler.createPage(object, viewId, p);
-
-// XActionInvoker.invoke("CreateActions.AddPageWizard", object, p);
+ Page newPage = PagesFactoryImpl.eINSTANCE.createPage();
+ newPage.setName("");
+ newPage.setLocation(new Point(x,y));
+ part.getPagesModel().getChildren().add(newPage);
}
/**
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ExceptionEditPart.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ExceptionEditPart.java 2008-07-09
19:47:26 UTC (rev 9113)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ExceptionEditPart.java 2008-07-10
12:52:26 UTC (rev 9114)
@@ -29,6 +29,7 @@
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.DirectEditRequest;
import org.eclipse.gef.requests.DropRequest;
import org.eclipse.swt.accessibility.AccessibleControlEvent;
import org.eclipse.swt.accessibility.AccessibleEvent;
@@ -113,15 +114,20 @@
protected List getModelSourceConnections() {
return getExceptionModel().getOutputLinks();
}
+
+ public void performRequest(Request req) {
+ if (req.getType() == GraphicalPartFactory.REQ_INIT_EDIT) {
+ new ViewIDEditManager(this, new ViewIDEditorLocator(
+ (ExceptionFigure) getFigure())).show();
+ }
+ }
protected void createEditPolicies() {
super.createEditPolicies();
installEditPolicy(EditPolicy.NODE_ROLE, null);
installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, null);
- //installEditPolicy(EditPolicy.COMPONENT_ROLE, new PageEditPolicy());
- //installEditPolicy(EditPolicy.LAYOUT_ROLE, new JSFFlowEditPolicy());
- //installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE,
- // new PageEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE,
+ new ViewIDDirectEditPolicy());
}
/**
@@ -162,7 +168,10 @@
protected void refreshVisuals() {
Point loc = getExceptionModel().getLocation();
String text = getExceptionReadOnlyLabel();
- int width = getIconWidth()+FigureUtilities.getTextExtents(text,
NodeFigure.nodeLabelFont).width;
+ int width = getIconWidth()+FigureUtilities.getTextExtents(text,
NodeFigure.nodeLabelFont).width;
+
+ if(width < getMinimumWidth()) width = getMinimumWidth();
+
size = new Dimension(width, getVisualHeight());
adjustForGrid(loc);
@@ -171,8 +180,10 @@
((GraphicalEditPart) getParent()).setLayoutConstraint(this,
getFigure(), r);
}
-
+ private int getMinimumWidth() {
+ return 130;
+ }
private int getVisualHeight() {
return 21;
@@ -231,6 +242,11 @@
return;
((Notifier) getModel()).eAdapters().add(this);
super.activate();
+ if("".equals(getExceptionModel().getName())){
+ DirectEditRequest req = new DirectEditRequest();
+ req.setType(GraphicalPartFactory.REQ_INIT_EDIT);
+ performRequest(req);
+ }
}
public void deactivate(){
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/GraphicalPartFactory.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/GraphicalPartFactory.java 2008-07-09
19:47:26 UTC (rev 9113)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/GraphicalPartFactory.java 2008-07-10
12:52:26 UTC (rev 9114)
@@ -20,6 +20,7 @@
public class GraphicalPartFactory implements EditPartFactory {
+ public static final String REQ_INIT_EDIT = "init edit"; //$NON-NLS-1$
public EditPart createEditPart(EditPart context, Object model) {
EditPart child = null;
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PageEditPart.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PageEditPart.java 2008-07-09
19:47:26 UTC (rev 9113)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PageEditPart.java 2008-07-10
12:52:26 UTC (rev 9114)
@@ -30,6 +30,7 @@
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.Request;
import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.requests.DirectEditRequest;
import org.eclipse.gef.requests.DropRequest;
import org.eclipse.gef.requests.SelectionRequest;
import org.eclipse.swt.accessibility.AccessibleControlEvent;
@@ -134,6 +135,9 @@
SeamUiPagesPlugin.log(e);
}
}
+ }else if (req.getType() == GraphicalPartFactory.REQ_INIT_EDIT) {
+ new ViewIDEditManager(this, new ViewIDEditorLocator(
+ (PageFigure) getFigure())).show();
}
}
@@ -143,6 +147,8 @@
installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, null);
installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE,
new PageEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE,
+ new ViewIDDirectEditPolicy());
}
/**
@@ -182,6 +188,8 @@
int width = getIconWidth()+FigureUtilities.getTextExtents(getPageModel().getName(),
NodeFigure.nodeLabelFont).width;
+ if(width < getMinimumWidth()) width = getMinimumWidth();
+
size = new Dimension(width, height);
adjustForGrid(loc);
@@ -198,8 +206,11 @@
private int getIconWidth() {
return 30;
}
+
+ private int getMinimumWidth() {
+ return 130;
+ }
-
public ConnectionAnchor getTargetConnectionAnchor(
ConnectionEditPart connEditPart) {
ConnectionAnchor anc = getNodeFigure().getConnectionAnchor("1_IN");
@@ -239,6 +250,11 @@
return;
((Notifier) getModel()).eAdapters().add(this);
super.activate();
+ if("".equals(getPageModel().getName())){
+ DirectEditRequest req = new DirectEditRequest();
+ req.setType(GraphicalPartFactory.REQ_INIT_EDIT);
+ performRequest(req);
+ }
}
public void deactivate() {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesDiagramEditPart.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesDiagramEditPart.java 2008-07-09
19:47:26 UTC (rev 9113)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesDiagramEditPart.java 2008-07-10
12:52:26 UTC (rev 9114)
@@ -38,6 +38,7 @@
import org.eclipse.gef.tools.MarqueeDragTracker;
import org.eclipse.swt.accessibility.AccessibleEvent;
import org.jboss.tools.seam.ui.pages.editor.ecore.pages.Page;
+import org.jboss.tools.seam.ui.pages.editor.ecore.pages.PagesElement;
import org.jboss.tools.seam.ui.pages.editor.ecore.pages.PagesModel;
import org.jboss.tools.seam.ui.pages.editor.ecore.pages.PagesModelListener;
import org.jboss.tools.seam.ui.pages.editor.figures.DiagramFigure;
@@ -295,10 +296,20 @@
super.deactivate();
}
+ private static PagesElement toDelete = null;
+
+ public static void deleteChild(PagesElement element){
+ toDelete = element;
+ }
+
/**
* @see
org.eclipse.emf.common.notify.Adapter#notifyChanged(org.eclipse.emf.common.notify.Notification)
*/
public void notifyChanged(Notification notification) {
+ if(toDelete != null){
+ toDelete.setParent(null);
+ toDelete = null;
+ }
refresh();
refreshVisuals();
}
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ViewIDDirectEditPolicy.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ViewIDDirectEditPolicy.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ViewIDDirectEditPolicy.java 2008-07-10
12:52:26 UTC (rev 9114)
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.ui.pages.editor.edit;
+
+import java.util.Properties;
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.DirectEditPolicy;
+import org.eclipse.gef.requests.DirectEditRequest;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.seam.ui.pages.editor.commands.AddExceptionOnDiagramHandler;
+import org.jboss.tools.seam.ui.pages.editor.commands.AddPageOnDiagramHandler;
+import org.jboss.tools.seam.ui.pages.editor.ecore.pages.Page;
+import org.jboss.tools.seam.ui.pages.editor.ecore.pages.PageException;
+import org.jboss.tools.seam.ui.pages.editor.ecore.pages.PagesElement;
+
+public class ViewIDDirectEditPolicy extends DirectEditPolicy {
+
+ /**
+ * @see DirectEditPolicy#getDirectEditCommand(DirectEditRequest)
+ */
+ protected Command getDirectEditCommand(DirectEditRequest edit) {
+ String labelText = (String) edit.getCellEditor().getValue();
+ PagesEditPart node = (PagesEditPart) getHost();
+ PagesElement element = node.getElementModel();
+ if (element != null) {
+ return new FlowNameCommand(element, labelText);
+ }
+ return null;
+ }
+
+ /**
+ * @see DirectEditPolicy#showCurrentEditValue(DirectEditRequest)
+ */
+ protected void showCurrentEditValue(DirectEditRequest request) {
+ }
+
+ public class FlowNameCommand extends Command {
+
+ PagesElement node;
+ String value;
+
+ public FlowNameCommand(PagesElement node, String value) {
+ this.node = node;
+ this.value = value;
+ }
+
+ public boolean canExecute() {
+ if (value == null)
+ return false;
+ return true;
+ }
+
+ public boolean canUndo() {
+ return false;
+ }
+
+ public void execute() {
+ Properties props = new Properties();
+ props.setProperty("mouse.x", ""+node.getLocation().x);
+ props.setProperty("mouse.y", ""+node.getLocation().y);
+ XModelObject object = (XModelObject)node.getPagesModel().getData();
+
+ PagesDiagramEditPart.deleteChild(node);
+
+ if(node instanceof Page)
+ AddPageOnDiagramHandler.createPage(object, value, props);
+ else if(node instanceof PageException)
+ AddExceptionOnDiagramHandler.createException(object, value, props);
+ }
+ }
+
+}
Property changes on:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ViewIDDirectEditPolicy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ViewIDEditManager.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ViewIDEditManager.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ViewIDEditManager.java 2008-07-10
12:52:26 UTC (rev 9114)
@@ -0,0 +1,207 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.ui.pages.editor.edit;
+
+import java.text.MessageFormat;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.gef.EditPartViewer;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.editparts.ZoomListener;
+import org.eclipse.gef.editparts.ZoomManager;
+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.events.ModifyEvent;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+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.internal.Workbench;
+import org.eclipse.ui.internal.WorkbenchWindow;
+import org.eclipse.ui.part.CellEditorActionHandler;
+import org.jboss.tools.seam.ui.pages.editor.figures.ExceptionFigure;
+import org.jboss.tools.seam.ui.pages.editor.figures.NodeFigure;
+import org.jboss.tools.seam.ui.pages.editor.figures.PageFigure;
+
+public class ViewIDEditManager extends DirectEditManager {
+
+ private IActionBars actionBars;
+ private CellEditorActionHandler actionHandler;
+ private IAction copy, cut, paste, undo, redo, find, selectAll, delete;
+ private double cachedZoom = -1.0;
+ private Font scaledFont;
+ private EditPartViewer viewer = null;
+ private ZoomListener zoomListener = new ZoomListener() {
+ public void zoomChanged(double newZoom) {
+ updateScaledFont(newZoom);
+ }
+ };
+
+ public ViewIDEditManager(GraphicalEditPart source, CellEditorLocator locator) {
+ super(source, null, locator);
+ }
+
+ /**
+ * @see org.eclipse.gef.tools.DirectEditManager#bringDown()
+ */
+ protected void bringDown() {
+ ZoomManager zoomMgr = (ZoomManager) viewer
+ .getProperty(ZoomManager.class.toString());
+ if (zoomMgr != null)
+ zoomMgr.removeZoomListener(zoomListener);
+
+ if (actionHandler != null) {
+ actionHandler.dispose();
+ actionHandler = null;
+ }
+ if (actionBars != null) {
+ restoreSavedActions(actionBars);
+ actionBars.updateActionBars();
+ actionBars = null;
+ }
+
+ super.bringDown();
+ // dispose any scaled fonts that might have been created
+ disposeScaledFont();
+ }
+
+ protected CellEditor createCellEditorOn(Composite composite) {
+ return new TextCellEditor(composite, SWT.SINGLE | SWT.WRAP);// {
+// protected void setErrorMessage(String message) {
+// super.setErrorMessage(message);
+// ((WorkbenchWindow) Workbench.getInstance()
+// .getActiveWorkbenchWindow()).getStatusLineManager()
+// .setErrorMessage(message);
+// }
+//
+// protected void editOccured(ModifyEvent e) {
+// String value = text.getText();
+// if (value == null) {
+// value = "";//$NON-NLS-1$
+// }
+// Object typedValue = value;
+// boolean oldValidState = isValueValid();
+// boolean newValidState = isCorrect(typedValue);
+// if (typedValue == null && newValidState) {
+// Assert
+// .isTrue(false,
+// "Validator isn't limiting the cell editor's type
range");//$NON-NLS-1$
+// }
+// if (!newValidState) {
+// // try to insert the current value into the error message.
+// setErrorMessage(MessageFormat.format(getErrorMessage(),
+// new Object[] { value }));
+// } else {
+// setErrorMessage("");
+// }
+// valueChanged(oldValidState, newValidState);
+// }
+//
+// protected Control createControl(Composite parent) {
+// Control control = super.createControl(parent);
+// setErrorMessage("");
+// return control;
+// }
+// };
+ }
+
+ private void disposeScaledFont() {
+ if (scaledFont != null) {
+ scaledFont.dispose();
+ scaledFont = null;
+ }
+ }
+
+ protected void initCellEditor() {
+ // update text
+ viewer = getEditPart().getViewer();
+ NodeFigure stickyNote = (NodeFigure) getEditPart().getFigure();
+ if(stickyNote instanceof PageFigure)
+ getCellEditor().setValue(((PageFigure)stickyNote).page.getName());
+ else if(stickyNote instanceof ExceptionFigure)
+ getCellEditor().setValue(((ExceptionFigure)stickyNote).exc.getName());
+
+ // update font
+ ZoomManager zoomMgr = (ZoomManager) getEditPart().getViewer()
+ .getProperty(ZoomManager.class.toString());
+ if (zoomMgr != null) {
+ // this will force the font to be set
+ cachedZoom = -1.0;
+ updateScaledFont(zoomMgr.getZoom());
+ zoomMgr.addZoomListener(zoomListener);
+ } else
+ getCellEditor().getControl().setFont(stickyNote.getFont());
+
+ // 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();
+ // getCellEditor().setValidator(NameValidator.instance);
+ }
+
+ 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());
+ }
+
+ private void updateScaledFont(double zoom) {
+ if (cachedZoom == zoom)
+ return;
+
+ Text text = (Text) getCellEditor().getControl();
+ Font font = getEditPart().getFigure().getFont();
+
+ disposeScaledFont();
+ cachedZoom = zoom;
+ if (zoom == 1.0)
+ text.setFont(font);
+ else {
+ FontData fd = font.getFontData()[0];
+ fd.setHeight((int) (fd.getHeight() * zoom));
+ text.setFont(scaledFont = new Font(null, fd));
+ }
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ViewIDEditManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ViewIDEditorLocator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ViewIDEditorLocator.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ViewIDEditorLocator.java 2008-07-10
12:52:26 UTC (rev 9114)
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.ui.pages.editor.edit;
+
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.jface.viewers.CellEditor;
+
+import org.eclipse.draw2d.geometry.Rectangle;
+
+import org.eclipse.gef.tools.CellEditorLocator;
+import org.jboss.tools.seam.ui.pages.editor.figures.NodeFigure;
+import org.jboss.tools.seam.ui.pages.editor.figures.PageFigure;
+
+final public class ViewIDEditorLocator implements CellEditorLocator {
+
+ private NodeFigure nodeFigure;
+
+ public ViewIDEditorLocator(NodeFigure nodeFigure) {
+ setFigure(nodeFigure);
+ }
+
+ public void relocate(CellEditor celleditor) {
+ Text text = (Text) celleditor.getControl();
+ Rectangle rect = nodeFigure.getClientArea();
+ nodeFigure.translateToAbsolute(rect);
+ org.eclipse.swt.graphics.Rectangle trim = text.computeTrim(0, 0, 0, 0);
+ rect.translate(trim.x, trim.y);
+ rect.width += trim.width;
+ rect.height = 14;
+ text.setBounds(rect.x+25, rect.y+2, rect.width-27, rect.height);
+ }
+
+ /**
+ * Returns the node figure.
+ */
+ protected NodeFigure getFigure() {
+ return nodeFigure;
+ }
+
+ /**
+ * Sets the node figure.
+ *
+ */
+ protected void setFigure(NodeFigure nodeFigure) {
+ this.nodeFigure = nodeFigure;
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ViewIDEditorLocator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ExceptionFigure.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ExceptionFigure.java 2008-07-09
19:47:26 UTC (rev 9113)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ExceptionFigure.java 2008-07-10
12:52:26 UTC (rev 9114)
@@ -52,7 +52,7 @@
public ExceptionFigure(PageException group) {
this.exc = group;
- if (group != null) {
+ if (group != null && group.getData() != null) {
setIcon(group.getImage());
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/PageFigure.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/PageFigure.java 2008-07-09
19:47:26 UTC (rev 9113)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/PageFigure.java 2008-07-10
12:52:26 UTC (rev 9114)
@@ -59,7 +59,7 @@
public PageFigure(Page group) {
this.page = group;
- if (group != null) {
+ if (group != null && group.getData() != null) {
setIcon(group.getImage());
initConnectionAnchors(group.getOutputLinks().size());
}