Author: dazarov
Date: 2008-08-01 08:14:29 -0400 (Fri, 01 Aug 2008)
New Revision: 9467
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/ecore/pages/impl/PagesModelImpl.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/ViewIDDirectEditPolicy.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ViewIDEditManager.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2589
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/ecore/pages/impl/PagesModelImpl.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/ecore/pages/impl/PagesModelImpl.java 2008-08-01
10:44:13 UTC (rev 9466)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/ecore/pages/impl/PagesModelImpl.java 2008-08-01
12:14:29 UTC (rev 9467)
@@ -16,6 +16,7 @@
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
+import org.eclipse.swt.widgets.Display;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.event.XModelTreeEvent;
@@ -288,7 +289,23 @@
* <!-- end-user-doc -->
* @generated NOT
*/
- public void nodeChanged(XModelTreeEvent event) {
+ public void nodeChanged(final XModelTreeEvent event) {
+ if(Display.getCurrent() != null){
+ nodeChangedInternal(event);
+ }else{
+ Display.getDefault().asyncExec(new Runnable(){
+ public void run(){
+ nodeChangedInternal(event);
+ }
+ });
+ }
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated NOT
+ */
+ private void nodeChangedInternal(XModelTreeEvent event) {
if(getData() == null) return;
XModelObject diagramXML = (XModelObject)getData();
String newPath = event.getModelObject().getPath();
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-08-01
10:44:13 UTC (rev 9466)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PageEditPart.java 2008-08-01
12:14:29 UTC (rev 9467)
@@ -138,6 +138,9 @@
}else if (req.getType() == GraphicalPartFactory.REQ_INIT_EDIT) {
new ViewIDEditManager(this, new ViewIDEditorLocator(
(PageFigure) getFigure())).show();
+ }else if (req.getType() == RequestConstants.REQ_DIRECT_EDIT) {
+ new ViewIDEditManager(this, new ViewIDEditorLocator(
+ (PageFigure) getFigure()), true).show();
}
}
Modified:
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 2008-08-01
10:44:13 UTC (rev 9466)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ViewIDDirectEditPolicy.java 2008-08-01
12:14:29 UTC (rev 9467)
@@ -12,10 +12,18 @@
import java.util.Properties;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.DirectEditPolicy;
import org.eclipse.gef.requests.DirectEditRequest;
+import org.jboss.tools.common.model.XModelException;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.jst.web.model.ReferenceObject;
+import org.jboss.tools.seam.pages.xml.model.SeamPagesConstants;
+import org.jboss.tools.seam.pages.xml.model.handlers.RenameViewSupport;
+import org.jboss.tools.seam.pages.xml.model.helpers.SeamPagesDiagramHelper;
+import org.jboss.tools.seam.pages.xml.model.helpers.SeamPagesDiagramStructureHelper;
+import org.jboss.tools.seam.ui.pages.SeamUiPagesPlugin;
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;
@@ -27,12 +35,16 @@
/**
* @see DirectEditPolicy#getDirectEditCommand(DirectEditRequest)
*/
- protected Command getDirectEditCommand(DirectEditRequest edit) {
- String labelText = (String) edit.getCellEditor().getValue();
+ protected Command getDirectEditCommand(DirectEditRequest request) {
+ String labelText = (String) request.getCellEditor().getValue();
PagesEditPart node = (PagesEditPart) getHost();
PagesElement element = node.getElementModel();
if (element != null) {
- return new FlowNameCommand(element, labelText);
+ Object rename = request.getExtendedData().get("rename");
+ if(rename != null && rename instanceof Boolean &&
((Boolean)rename).booleanValue())
+ return new RenameViewCommand(element, labelText);
+ else
+ return new InitViewCommand(element, labelText);
}
return null;
}
@@ -43,13 +55,13 @@
protected void showCurrentEditValue(DirectEditRequest request) {
}
- public class FlowNameCommand extends Command {
+ public class InitViewCommand extends Command {
PagesElement node;
String value;
XModelObject object;
- public FlowNameCommand(PagesElement node, String value) {
+ public InitViewCommand(PagesElement node, String value) {
this.node = node;
this.value = value;
object = (XModelObject)node.getPagesModel().getData();
@@ -80,5 +92,48 @@
AddExceptionOnDiagramHandler.createException(object, value, props);
}
}
+
+ public class RenameViewCommand extends Command {
+ PagesElement node;
+ String value;
+ XModelObject object;
+ String oldValue;
+
+ public RenameViewCommand(PagesElement node, String value) {
+ this.node = node;
+ this.value = value;
+ object = (XModelObject)node.getData();
+ oldValue = object.getAttributeValue(SeamPagesConstants.ATTR_PATH);
+ }
+
+ public boolean canExecute() {
+ ViewIDValidator val = new ViewIDValidator(object);
+ String message = val.isValid(value);
+
+ if (message == null || "".equals(message))
+ return true;
+ return false;
+ }
+
+ public boolean canUndo() {
+ return false;
+ }
+
+ public void execute() {
+ if(node instanceof Page && object instanceof ReferenceObject){
+ SeamPagesDiagramHelper h =
SeamPagesDiagramHelper.getHelper(SeamPagesDiagramStructureHelper.instance.getDiagram(object));
+ h.addUpdateLock(this);
+ try{
+ RenameViewSupport.replace((ReferenceObject)object, oldValue, value);
+ }catch(XModelException ex){
+ SeamUiPagesPlugin.log(ex);
+ } finally {
+ h.removeUpdateLock(this);
+ h.updateDiagram();
+ }
+ }
+
+ }
+ }
}
Modified:
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 2008-08-01
10:44:13 UTC (rev 9466)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ViewIDEditManager.java 2008-08-01
12:14:29 UTC (rev 9467)
@@ -13,9 +13,11 @@
import java.text.MessageFormat;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.draw2d.ColorConstants;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.editparts.ZoomListener;
import org.eclipse.gef.editparts.ZoomManager;
+import org.eclipse.gef.requests.DirectEditRequest;
import org.eclipse.gef.tools.CellEditorLocator;
import org.eclipse.gef.tools.DirectEditManager;
import org.eclipse.jface.action.IAction;
@@ -57,18 +59,38 @@
}
};
- XModelObject target;
+ private XModelObject target;
+
+ private boolean rename = false;
public ViewIDEditManager(GraphicalEditPart source, CellEditorLocator locator) {
super(source, null, locator);
target = (XModelObject) ((PagesDiagramEditPart) source.getParent())
.getPagesModel().getData();
}
+
+ public ViewIDEditManager(GraphicalEditPart source, CellEditorLocator locator, boolean
rename) {
+ this(source, locator);
+ this.rename = rename;
+ }
+
+ /**
+ * Creates and returns the DirectEditRequest.
+ * @return the direct edit request
+ */
+ protected DirectEditRequest createDirectEditRequest() {
+ DirectEditRequest req = super.createDirectEditRequest();
+ if(rename){
+ req.getExtendedData().put("rename", new Boolean(true));
+ }
+ return req;
+ }
/**
* @see org.eclipse.gef.tools.DirectEditManager#bringDown()
*/
protected void bringDown() {
+ if(getEditPart().getParent() == null)return;
ZoomManager zoomMgr = (ZoomManager) getEditPart().getViewer()
.getProperty(ZoomManager.class.toString());
if (zoomMgr != null)
@@ -89,7 +111,8 @@
PagesElement element = ((PagesEditPart) getEditPart())
.getElementModel();
- element.setParent(null);
+ if(!rename)
+ element.setParent(null);
}
protected CellEditor createCellEditorOn(Composite composite) {
@@ -127,6 +150,7 @@
protected Control createControl(Composite parent) {
Control control = super.createControl(parent);
+ control.setBackground(ColorConstants.white);
setErrorMessage("");
return control;
}