Author: scabanovich
Date: 2008-05-30 11:24:41 -0400 (Fri, 30 May 2008)
New Revision: 8482
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/ExceptionTemplate.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/PageTemplate.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/TemplateConstants.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesDiagramEditPolicy.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/SeamUIPagesMessages.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/PagesEditor.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/messages.properties
Log:
JBIDE-1189
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/SeamUIPagesMessages.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/SeamUIPagesMessages.java 2008-05-30
15:08:10 UTC (rev 8481)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/SeamUIPagesMessages.java 2008-05-30
15:24:41 UTC (rev 8482)
@@ -19,6 +19,9 @@
public static String PAGESDIAGRAM_MARQUEE;
public static String PAGESDIAGRAM_CREATE_NEW_CONNECTION;
public static String SEAM_UI_PAGES_PLUGIN_NO_MESSAGES;
+
+ public static String PAGES_DIAGRAM_VIEW_TEMPLATE;
+ public static String PAGES_DIAGRAM_EXCEPTION_TEMPLATE;
public static ResourceBundle getResourceBundle() {
try {
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/ExceptionTemplate.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/ExceptionTemplate.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/ExceptionTemplate.java 2008-05-30
15:24:41 UTC (rev 8482)
@@ -0,0 +1,5 @@
+package org.jboss.tools.seam.ui.pages.editor;
+
+public class ExceptionTemplate {
+
+}
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/PageTemplate.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/PageTemplate.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/PageTemplate.java 2008-05-30
15:24:41 UTC (rev 8482)
@@ -0,0 +1,5 @@
+package org.jboss.tools.seam.ui.pages.editor;
+
+public class PageTemplate {
+
+}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/PagesEditor.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/PagesEditor.java 2008-05-30
15:08:10 UTC (rev 8481)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/PagesEditor.java 2008-05-30
15:24:41 UTC (rev 8482)
@@ -48,6 +48,7 @@
import org.eclipse.gef.editparts.ScalableFreeformRootEditPart;
import org.eclipse.gef.editparts.ZoomListener;
import org.eclipse.gef.editparts.ZoomManager;
+import org.eclipse.gef.palette.CombinedTemplateCreationEntry;
import org.eclipse.gef.palette.MarqueeToolEntry;
import org.eclipse.gef.palette.PaletteContainer;
import org.eclipse.gef.palette.PaletteEntry;
@@ -394,19 +395,30 @@
entries.add(sep);
-// CombinedTemplateCreationEntry combined = new CombinedTemplateCreationEntry(
-// FacesConfigEditorMessages.JSFDIAGRAM_VIEW_TEMPLATE,
-// FacesConfigEditorMessages.JSFDIAGRAM_VIEW_TEMPLATE,
-// TemplateConstants.TEMPLATE_VIEW,
-// new SimpleFactory(String.class), ImageDescriptor
-// .createFromFile(PagesEditor.class, "icons/view.gif"),
-// null//$NON-NLS-1$
-// );
-// entries.add(combined);
-//
+ CombinedTemplateCreationEntry combined = new CombinedTemplateCreationEntry(
+ SeamUIPagesMessages.PAGES_DIAGRAM_VIEW_TEMPLATE,
+ SeamUIPagesMessages.PAGES_DIAGRAM_VIEW_TEMPLATE,
+ TemplateConstants.TEMPLATE_PAGE,
+ new SimpleFactory(PageTemplate.class), ImageDescriptor
+ .createFromFile(PagesEditor.class, "icons/view.gif"),
+ null//$NON-NLS-1$
+ );
+ entries.add(combined);
+
+ combined = new CombinedTemplateCreationEntry(
+ SeamUIPagesMessages.PAGES_DIAGRAM_EXCEPTION_TEMPLATE,
+ SeamUIPagesMessages.PAGES_DIAGRAM_EXCEPTION_TEMPLATE,
+ TemplateConstants.TEMPLATE_EXCEPTION,
+ new SimpleFactory(ExceptionTemplate.class), ImageDescriptor
+ .createFromFile(PagesEditor.class, "icons/exception.gif"),
+ null//$NON-NLS-1$
+ );
+ entries.add(combined);
+
controlGroup.addAll(entries);
return controlGroup;
}
+
public void gotoMarker(IMarker marker) {
}
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/TemplateConstants.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/TemplateConstants.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/TemplateConstants.java 2008-05-30
15:24:41 UTC (rev 8482)
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * 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;
+
+/**
+ * @author hudsonr
+ * @since 2.1
+ */
+public class TemplateConstants {
+
+ public static final String TEMPLATE_PAGE = "page template";
+ public static final String TEMPLATE_EXCEPTION = "exception template";
+
+}
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-05-30
15:08:10 UTC (rev 8481)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesDiagramEditPart.java 2008-05-30
15:24:41 UTC (rev 8482)
@@ -129,7 +129,7 @@
installEditPolicy(EditPolicy.NODE_ROLE, null);
installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, null);
installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, null);
- //installEditPolicy(EditPolicy.COMPONENT_ROLE, new JSFDiagramEditPolicy());
+ installEditPolicy(EditPolicy.COMPONENT_ROLE, new PagesDiagramEditPolicy());
}
/**
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesDiagramEditPolicy.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesDiagramEditPolicy.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesDiagramEditPolicy.java 2008-05-30
15:24:41 UTC (rev 8482)
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * 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.draw2d.geometry.Point;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.RootComponentEditPolicy;
+import org.eclipse.gef.requests.CreateRequest;
+
+import org.jboss.tools.common.meta.action.XActionInvoker;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.seam.ui.pages.editor.ExceptionTemplate;
+import org.jboss.tools.seam.ui.pages.editor.PageTemplate;
+import org.jboss.tools.seam.ui.pages.editor.ecore.pages.PagesModel;
+
+public class PagesDiagramEditPolicy extends RootComponentEditPolicy{
+
+ public PagesDiagramEditPolicy() {
+ super();
+ }
+
+ public PagesDiagramEditPart getDiagramEditPart(){
+ return (PagesDiagramEditPart)getHost();
+ }
+
+ public Command getCommand(Request request) {
+ if (RequestConstants.REQ_CREATE.equals(request.getType())){
+ CreateRequest req = (CreateRequest)request;
+ if(req.getNewObjectType().equals(ExceptionTemplate.class))
+ return getCreateExceptionCommand((CreateRequest)request);
+ else if(req.getNewObjectType().equals(PageTemplate.class))
+ return getCreatePageCommand((CreateRequest)request);
+ }
+ return super.getCommand(request);
+ }
+
+ public Command getCreateExceptionCommand(CreateRequest request){
+ CreateExceptionCommand comm = new CreateExceptionCommand();
+ comm.setLocation(request.getLocation());
+ return comm;
+ }
+
+ public Command getCreatePageCommand(CreateRequest request){
+ CreatePageCommand comm = new CreatePageCommand();
+ comm.setLocation(request.getLocation());
+ return comm;
+ }
+
+ class CreateExceptionCommand extends org.eclipse.gef.commands.Command{
+ Point location;
+
+ public void setLocation(Point point){
+ PagesDiagramEditPolicy.this.getDiagramEditPart().getFigure().translateToRelative(point);
+ location = point;
+ }
+
+
+ public CreateExceptionCommand(){
+ super("CreateExceptionCommand");
+ }
+
+ public boolean canExecute(){
+ return true;
+ }
+
+ public void execute(){
+ Properties properties = new Properties();
+ if(location != null){
+ properties.put("process.mouse.x","" + location.x);
+ properties.put("process.mouse.y","" + location.y);
+ }
+
+ XActionInvoker.invoke("CreateActions.AddException",
(XModelObject)((PagesModel)getDiagramEditPart().getModel()).getData(),properties);
+ }
+
+ public boolean canUndo() {
+ return false;
+ }
+ }
+
+ class CreatePageCommand extends org.eclipse.gef.commands.Command{
+ Point location;
+
+ public void setLocation(Point point){
+ PagesDiagramEditPolicy.this.getDiagramEditPart().getFigure().translateToRelative(point);
+ location = point;
+ }
+
+
+ public CreatePageCommand(){
+ super("CreatePageCommand");
+ }
+
+ public boolean canExecute(){
+ return true;
+ }
+
+ public void execute(){
+ Properties properties = new Properties();
+ if(location != null) {
+ properties.put("process.mouse.x","" + location.x);
+ properties.put("process.mouse.y","" + location.y);
+ }
+
+ XActionInvoker.invoke("CreateActions.AddPage",
(XModelObject)((PagesModel)getDiagramEditPart().getModel()).getData(),properties);
+ }
+
+ public boolean canUndo() {
+ return false;
+ }
+ }
+}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/messages.properties
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/messages.properties 2008-05-30
15:08:10 UTC (rev 8481)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/messages.properties 2008-05-30
15:24:41 UTC (rev 8482)
@@ -1,2 +1,4 @@
SEAM_PAGES_EDITOR_SOURCE_TAB=Source
SEAM_PAGES_EDITOR_DIAGRAM_TAB=Graphical
+PAGES_DIAGRAM_VIEW_TEMPLATE=Add Page
+PAGES_DIAGRAM_EXCEPTION_TEMPLATE=Add Exception
\ No newline at end of file