[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[List Home]
|
[stp-commits] r3315 - in org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram: . META-INF customsrc/org/eclipse/stp/sca/diagram/customactions customsrc/org/eclipse/stp/sca/diagram/dnd
|
- From: genie@xxxxxxxxxxx
- Date: Tue, 15 Sep 2009 06:38:08 -0400 (EDT)
- Delivered-to: stp-commits@eclipse.org
Author: sdrapeau
Date: 2009-09-15 06:38:07 -0400 (Tue, 15 Sep 2009)
New Revision: 3315
Added:
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram/customsrc/org/eclipse/stp/sca/diagram/dnd/AbstractFileDD.java
Removed:
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram/customsrc/org/eclipse/stp/sca/diagram/dnd/client/
Modified:
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram/META-INF/MANIFEST.MF
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram/customsrc/org/eclipse/stp/sca/diagram/customactions/OpenDiagramAction.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram/customsrc/org/eclipse/stp/sca/diagram/customactions/OpenEditorAction.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram/customsrc/org/eclipse/stp/sca/diagram/dnd/MyScaDropTargetListener.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram/plugin.xml
Log:
Fix for OpenDiagramAction, OpenEditorAction, DnD
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram/META-INF/MANIFEST.MF
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram/META-INF/MANIFEST.MF 2009-09-15 10:35:25 UTC (rev 3314)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram/META-INF/MANIFEST.MF 2009-09-15 10:38:07 UTC (rev 3315)
@@ -42,6 +42,7 @@
org.eclipse.draw2d,
org.eclipse.core.expressions,
org.eclipse.ui.navigator.resources,
- com.ibm.icu
+ com.ibm.icu,
+ org.eclipse.stp.sca.common
Bundle-ActivationPolicy: lazy
Eclipse-LazyStart: true
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram/customsrc/org/eclipse/stp/sca/diagram/customactions/OpenDiagramAction.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram/customsrc/org/eclipse/stp/sca/diagram/customactions/OpenDiagramAction.java 2009-09-15 10:35:25 UTC (rev 3314)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram/customsrc/org/eclipse/stp/sca/diagram/customactions/OpenDiagramAction.java 2009-09-15 10:38:07 UTC (rev 3315)
@@ -26,12 +26,15 @@
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.stp.sca.SCAImplementation;
+import org.eclipse.stp.sca.common.utils.ResourceUtils;
import org.eclipse.stp.sca.diagram.part.ScaDiagramEditorPlugin;
import org.eclipse.ui.IActionDelegate;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.FileEditorInput;
/**
*
@@ -67,8 +70,13 @@
Messages.OpenDiagramAction_0));
return;
}
- path = new Path(p.getNamespaceURI() + "/" + p.getLocalPart() //$NON-NLS-1$
- + "_diagram"); //$NON-NLS-1$
+ IFile compositeFile = ResourceUtils.getCompositeFile(p
+ .getLocalPart()
+ + ".composite");
+ if (compositeFile != null) {
+ path = new Path(compositeFile.getFullPath().toString()
+ + "_diagram");
+ }
} else {
ScaDiagramEditorPlugin.getInstance().getLog().log(
new Status(IStatus.ERROR, ScaDiagramEditorPlugin.ID,
@@ -95,13 +103,17 @@
IEditorDescriptor editorDescriptor = PlatformUI.getWorkbench()
.getEditorRegistry().getDefaultEditor(fileToBeOpened.getName());
// FIXME open the diagram
- /*
- * try { page.openEditor(new FileEditorInput(fileToBeOpened),
- * editorDescriptor.getId(), true); } catch (PartInitException e) {
- * ScaDiagramEditorPlugin.getInstance().getLog().log( new
- * Status(IStatus.ERROR, ScaDiagramEditorPlugin.ID,
- * Messages.OpenDiagramAction_3 + e)); return; }
- */
+
+ try {
+ page.openEditor(new FileEditorInput(fileToBeOpened),
+ editorDescriptor.getId(), true);
+ } catch (PartInitException e) {
+ ScaDiagramEditorPlugin.getInstance().getLog().log(
+ new Status(IStatus.ERROR, ScaDiagramEditorPlugin.ID,
+ Messages.OpenDiagramAction_3 + e));
+ return;
+ }
+
}
/*
@@ -116,8 +128,9 @@
/*
* (non-Javadoc)
*
- * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
- * org.eclipse.jface.viewers.ISelection)
+ * @see
+ * org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action
+ * .IAction, org.eclipse.jface.viewers.ISelection)
*/
public void selectionChanged(IAction action, ISelection selection) {
if (selection != null && selection instanceof IStructuredSelection) {
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram/customsrc/org/eclipse/stp/sca/diagram/customactions/OpenEditorAction.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram/customsrc/org/eclipse/stp/sca/diagram/customactions/OpenEditorAction.java 2009-09-15 10:35:25 UTC (rev 3314)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram/customsrc/org/eclipse/stp/sca/diagram/customactions/OpenEditorAction.java 2009-09-15 10:38:07 UTC (rev 3315)
@@ -29,6 +29,7 @@
import org.eclipse.stp.sca.SCAImplementation;
import org.eclipse.stp.sca.WSDLPortType;
import org.eclipse.stp.sca.WebServiceBinding;
+import org.eclipse.stp.sca.common.utils.ResourceUtils;
import org.eclipse.stp.sca.diagram.part.ScaDiagramEditorPlugin;
import org.eclipse.ui.IActionDelegate;
import org.eclipse.ui.IEditorDescriptor;
@@ -70,11 +71,13 @@
Messages.OpenEditorAction_2));
return;
}
- // FIXME Open the sca model
- /*
- * path = new Path(getFilePathSCA(p.getNamespaceURI() + "/" +
- * p.getLocalPart() + ".composite")); //$NON-NLS-1$//$NON-NLS-2$
- */
+ IFile compositeFile = ResourceUtils.getCompositeFile(p
+ .getLocalPart()
+ + ".composite");
+ if (compositeFile != null) {
+ path = new Path(compositeFile.getFullPath().toString());
+ }
+
} else if (myPart.resolveSemanticElement() instanceof WSDLPortType) {
String p = ((WSDLPortType) myPart.resolveSemanticElement())
.getInterface();
@@ -156,8 +159,9 @@
/*
* (non-Javadoc)
*
- * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
- * org.eclipse.jface.viewers.ISelection)
+ * @see
+ * org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action
+ * .IAction, org.eclipse.jface.viewers.ISelection)
*/
public void selectionChanged(IAction action, ISelection selection) {
if (selection != null && selection instanceof IStructuredSelection) {
@@ -168,25 +172,18 @@
}
}
}
-
+
/*
- private String getFilePathSCA(String type) {
- String result = null;
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- if (workspace == null) {
- return null;
- }
- return result;
- }
+ * private String getFilePathSCA(String type) { String result = null;
+ * IWorkspace workspace = ResourcesPlugin.getWorkspace(); if (workspace ==
+ * null) { return null; } return result; }
+ *
+ * private class MyTypeNameRequestor extends TypeNameRequestor { String r =
+ * null;
+ *
+ * @Override public void acceptType(int modifiers, char[] packageName,
+ * char[] simpleTypeName, char[][] enclosingTypeNames, String path) { r =
+ * path; } }
+ */
- private class MyTypeNameRequestor extends TypeNameRequestor {
- String r = null;
-
- @Override
- public void acceptType(int modifiers, char[] packageName,
- char[] simpleTypeName, char[][] enclosingTypeNames, String path) {
- r = path;
- }
- }*/
-
}
Added: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram/customsrc/org/eclipse/stp/sca/diagram/dnd/AbstractFileDD.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram/customsrc/org/eclipse/stp/sca/diagram/dnd/AbstractFileDD.java (rev 0)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram/customsrc/org/eclipse/stp/sca/diagram/dnd/AbstractFileDD.java 2009-09-15 10:38:07 UTC (rev 3315)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2007-2009 Obeo
+ *
+ * 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:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.stp.sca.diagram.dnd;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.swt.dnd.DropTargetEvent;
+
+/**
+ *
+ * @author Stephane Drapeau - Obeo
+ *
+ */
+public abstract class AbstractFileDD implements IDragDropHandler {
+
+ protected Object getDnDedObject(Request request) {
+ Object transfer = null;
+ if (request != null && request instanceof DropObjectsRequest
+ && ((DropObjectsRequest) request).getObjects() != null
+ && !((DropObjectsRequest) request).getObjects().isEmpty()
+ && ((DropObjectsRequest) request).getObjects().get(0) != null) {
+ Object o = ((DropObjectsRequest) request).getObjects().get(0);
+ if (o instanceof DragDropFile)
+ transfer = ((DragDropFile) o).getResource();
+ else if (o instanceof DragDropAnyObject)
+ transfer = ((DragDropAnyObject) o).getObject();
+ }
+ return transfer;
+ }
+
+ /**
+ * Checks whether the drop action on the edit part is allowed.
+ * <p>
+ * This method is only called in {@link }.
+ * </p>
+ *
+ * @param editPart
+ * @return
+ */
+ protected abstract boolean editPartIsOk(GraphicalEditPart editPart);
+
+ protected abstract IElementType getType(GraphicalEditPart editPart);
+
+ public boolean isEnabled(DropTargetEvent event, EditPart part) {
+ return true;
+ }
+
+}
Property changes on: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram/customsrc/org/eclipse/stp/sca/diagram/dnd/AbstractFileDD.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram/customsrc/org/eclipse/stp/sca/diagram/dnd/MyScaDropTargetListener.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram/customsrc/org/eclipse/stp/sca/diagram/dnd/MyScaDropTargetListener.java 2009-09-15 10:35:25 UTC (rev 3314)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram/customsrc/org/eclipse/stp/sca/diagram/dnd/MyScaDropTargetListener.java 2009-09-15 10:38:07 UTC (rev 3315)
@@ -29,23 +29,26 @@
/**
* A class to handle DnD of objects on an SCA diagram.
* <p>
- * If the dropped object is an instance of {@link IResource}
- * or if it is adaptable to an IResource, then the object is
- * cast as an IResource.
+ * If the dropped object is an instance of {@link IResource} or if it is
+ * adaptable to an IResource, then the object is cast as an IResource.
* </p>
* <p>
- * If the object is not an IResource, it is added as if in the list
- * of objects being dropped.
+ * If the object is not an IResource, it is added as if in the list of objects
+ * being dropped.
* </p>
* <p>
- * It is the responsibility of the DnD handler to check the type of the
- * dropped resource before proceeding to the action to undertake.
+ * It is the responsibility of the DnD handler to check the type of the dropped
+ * resource before proceeding to the action to undertake.
* </p>
*
* @author Stephane Drapeau - Obeo
* @contributor Vincent Zurczak - EBM WebSourcing
- * <p>Handled DnD from the package explorer.</p>
- * <p>Allow the DnD of other objects than IResource</p>
+ * <p>
+ * Handled DnD from the package explorer.
+ * </p>
+ * <p>
+ * Allow the DnD of other objects than IResource
+ * </p>
*/
public class MyScaDropTargetListener extends DiagramDropTargetListener {
@@ -65,23 +68,25 @@
@Override
@SuppressWarnings("unchecked")
protected List getObjectsBeingDropped() {
-
- ISelection selection = LocalSelectionTransfer.getInstance().getSelection();
+
+ ISelection selection = LocalSelectionTransfer.getInstance()
+ .getSelection();
if (selection != null && selection instanceof IStructuredSelection) {
List l = new ArrayList();
-
- for (Object o : ((IStructuredSelection) selection).toList()) {
- if( o == null )
+
+ for (Object o : ((IStructuredSelection) selection).toList()) {
+ if (o == null) {
continue;
-
- if( o instanceof IResource)
- l.add( DragDropFile.getInstance((IResource) o));
+ }
+
+ if (o instanceof IResource)
+ l.add(DragDropFile.getInstance((IResource) o));
else {
- IResource resource = getAdaptableRessource( o );
- if( resource != null )
- l.add( DragDropFile.getInstance( resource ));
+ IResource resource = getAdaptableRessource(o);
+ if (resource != null)
+ l.add(DragDropFile.getInstance(resource));
else
- l.add( DragDropAnyObject.getInstance( o ));
+ l.add(DragDropAnyObject.getInstance(o));
}
}
return l;
@@ -89,34 +94,34 @@
return null;
}
-
/**
* Get the IResource adapter.
* <p>
- * Can only work if the argument implements {@link IAdaptable}
- * and is adaptable with IResource.class.
+ * Can only work if the argument implements {@link IAdaptable} and is
+ * adaptable with IResource.class.
* </p>
- *
+ *
* @param o
- * @return the IResource if it can be adapted as an IResource, null otherwise
+ * @return the IResource if it can be adapted as an IResource, null
+ * otherwise
*/
// VZ
- private IResource getAdaptableRessource( Object o ) {
+ private IResource getAdaptableRessource(Object o) {
try {
- Method m = o.getClass().getMethod( "getAdapter", Class.class ); //$NON-NLS-1$
- Object result = m.invoke( o, IResource.class );
- if( result instanceof IResource )
+ Method m = o.getClass().getMethod("getAdapter", Class.class); //$NON-NLS-1$
+ Object result = m.invoke(o, IResource.class);
+ if (result instanceof IResource)
return (IResource) result;
-
- } catch( Exception e ) {
+
+ } catch (Exception e) {
e.printStackTrace();
}
-
+
return null;
}
+
// VZ
-
/*
* (non-Javadoc)
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram/plugin.xml
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram/plugin.xml 2009-09-15 10:35:25 UTC (rev 3314)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram/plugin.xml 2009-09-15 10:38:07 UTC (rev 3315)
@@ -1516,13 +1516,5 @@
</action>
</objectContribution>
</extension>
- <extension
- point="org.eclipse.stp.sca.diagram.DragAndDropImplementation">
- <DragDropImplementation
- class="org.eclipse.stp.sca.diagram.dnd.client.ScaCompositeFileImplementationDD"
- id="org.eclipse.stp.sca.diagram.DragDropScaImplementation"
- name="Drag'n'Drop *.composite files as implementations">
- </DragDropImplementation>
- </extension>
</plugin>