Skip to content
Snippets Groups Projects
Commit e21b5791 authored by Hernan Ponce de Leon's avatar Hernan Ponce de Leon
Browse files

Merge branch '2845-cross-project-copy-and-paste' into 'master'

2845 cross project copy and paste

See merge request !7
parents e772c1ef 02efb321
No related branches found
No related tags found
1 merge request!72845 cross project copy and paste
...@@ -5,7 +5,7 @@ LibraryView.java 6f7273ee49b9049c7267c129bd59ed27ec5872e2 GREEN ...@@ -5,7 +5,7 @@ LibraryView.java 6f7273ee49b9049c7267c129bd59ed27ec5872e2 GREEN
LibraryViewDragSourceAdapter.java 56ef61b214ef5d6cb5b751791a92158bda0391ec GREEN LibraryViewDragSourceAdapter.java 56ef61b214ef5d6cb5b751791a92158bda0391ec GREEN
LinkWithEditorPartListener.java c5ab74424378e7b158a805c4dd14fc03c8abeded GREEN LinkWithEditorPartListener.java c5ab74424378e7b158a805c4dd14fc03c8abeded GREEN
MarkerViewContentProvider.java 297d9a5c355047796dc938eb909fd1cf27a2cbf3 GREEN MarkerViewContentProvider.java 297d9a5c355047796dc938eb909fd1cf27a2cbf3 GREEN
MarkerViewPart.java 074e8e65c46daf50749d26d5eb866eef3eac2f2d GREEN MarkerViewPart.java cbb650271b6877af205421b7cb11f930440a7ef9 GREEN
NavigatorNewMenu.java a35e391960d1dacbe7f77982e53e1891e9382d5a GREEN NavigatorNewMenu.java a35e391960d1dacbe7f77982e53e1891e9382d5a GREEN
NavigatorTreeContentProvider.java 1bdefa28c5e2c2619cabbcd1946269a52db34e6c GREEN NavigatorTreeContentProvider.java 1bdefa28c5e2c2619cabbcd1946269a52db34e6c GREEN
NavigatorTreeContentSorter.java 76fc94e441ac1a8f2c5ae573f0e2b1e6fa73c31a GREEN NavigatorTreeContentSorter.java 76fc94e441ac1a8f2c5ae573f0e2b1e6fa73c31a GREEN
......
...@@ -38,6 +38,7 @@ import org.eclipse.swt.widgets.Composite; ...@@ -38,6 +38,7 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart; import org.eclipse.ui.part.ViewPart;
import org.fortiss.tooling.kernel.extension.data.IConstraintViolation; import org.fortiss.tooling.kernel.extension.data.IConstraintViolation;
import org.fortiss.tooling.kernel.extension.data.IConstraintViolation.ESeverity; import org.fortiss.tooling.kernel.extension.data.IConstraintViolation.ESeverity;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.service.IPersistencyService; import org.fortiss.tooling.kernel.service.IPersistencyService;
import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler; import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.internal.MarkerService; import org.fortiss.tooling.kernel.ui.internal.MarkerService;
...@@ -95,9 +96,9 @@ public class MarkerViewPart extends ViewPart { ...@@ -95,9 +96,9 @@ public class MarkerViewPart extends ViewPart {
if(cell.getElement() instanceof IConstraintViolation) { if(cell.getElement() instanceof IConstraintViolation) {
IConstraintViolation<? extends EObject> violation = IConstraintViolation<? extends EObject> violation =
(IConstraintViolation<? extends EObject>)cell.getElement(); (IConstraintViolation<? extends EObject>)cell.getElement();
IModelElementHandlerService hs = IModelElementHandlerService.getInstance();
IModelElementHandler<EObject> handler = IModelElementHandler<EObject> handler =
IModelElementHandlerService.getInstance().getModelElementHandler( hs.getModelElementHandler(violation.getSource());
violation.getSource());
cell.setText(handler != null ? handler.getName(violation.getSource()) : ""); cell.setText(handler != null ? handler.getName(violation.getSource()) : "");
} else { } else {
cell.setText(""); cell.setText("");
...@@ -123,13 +124,17 @@ public class MarkerViewPart extends ViewPart { ...@@ -123,13 +124,17 @@ public class MarkerViewPart extends ViewPart {
if(cell.getElement() instanceof IConstraintViolation) { if(cell.getElement() instanceof IConstraintViolation) {
IConstraintViolation<? extends EObject> violation = IConstraintViolation<? extends EObject> violation =
(IConstraintViolation<? extends EObject>)cell.getElement(); (IConstraintViolation<? extends EObject>)cell.getElement();
EObject rootElement = IPersistencyService ps = IPersistencyService.getInstance();
IPersistencyService.getInstance() ITopLevelElement topElement = ps.getTopLevelElementFor(violation.getSource());
.getTopLevelElementFor(violation.getSource())
.getRootModelElement(); IModelElementHandler<EObject> handler = null;
IModelElementHandler<EObject> handler = EObject rootElement = null;
IModelElementHandlerService.getInstance().getModelElementHandler( if(topElement != null) {
rootElement); rootElement = topElement.getRootModelElement();
IModelElementHandlerService hs = IModelElementHandlerService.getInstance();
handler = hs.getModelElementHandler(rootElement);
}
cell.setText(handler != null ? handler.getName(rootElement) : ""); cell.setText(handler != null ? handler.getName(rootElement) : "");
} else { } else {
cell.setText(""); cell.setText("");
......
ActionUtils.java 4553e487264e3d1f86f4767da4a7400cce4b9a5d GREEN ActionUtils.java 4553e487264e3d1f86f4767da4a7400cce4b9a5d GREEN
ConstraintsUIUtils.java 69d5e08bbf768baf2790380e36f1020ef826a33e GREEN ConstraintsUIUtils.java 69d5e08bbf768baf2790380e36f1020ef826a33e GREEN
CopyPasteUtils.java 7da2d871bebecc7010e699b4625e1614bf2392ab GREEN CopyPasteUtils.java 66ff2c44bef3bfecc85a6d3109c6b15a8960fa38 GREEN
DataBindingUtils.java 0818014c193a22d5968435e78590368b95138d5e GREEN DataBindingUtils.java 0818014c193a22d5968435e78590368b95138d5e GREEN
DragAndDropUtils.java 7aab91518aa12d76533a345bf6ed0be9ac7ff0e5 GREEN DragAndDropUtils.java 7aab91518aa12d76533a345bf6ed0be9ac7ff0e5 GREEN
EObjectSelectionUtils.java 928280b5dd3bb634debc1ac3be9f15b4e45f2683 GREEN EObjectSelectionUtils.java 928280b5dd3bb634debc1ac3be9f15b4e45f2683 GREEN
......
...@@ -74,9 +74,9 @@ public class CopyPasteUtils { ...@@ -74,9 +74,9 @@ public class CopyPasteUtils {
((IConstrained)subObj).getConstraintInstances().clear(); ((IConstrained)subObj).getConstraintInstances().clear();
} }
} }
copier.copyReferences();
i++; i++;
} }
copier.copyReferences();
EList<ISpeciallyCopyiable> specialSel = EList<ISpeciallyCopyiable> specialSel =
pickInstanceOf(ISpeciallyCopyiable.class, new BasicEList<EObject>(sel)); pickInstanceOf(ISpeciallyCopyiable.class, new BasicEList<EObject>(sel));
for(ISpeciallyCopyiable obj : specialSel) { for(ISpeciallyCopyiable obj : specialSel) {
...@@ -121,16 +121,23 @@ public class CopyPasteUtils { ...@@ -121,16 +121,23 @@ public class CopyPasteUtils {
return; return;
} }
EcoreUtil.Copier copier = new EcoreUtil.Copier(); // canPasteInto() ensures that clip-board is non-empty
boolean sameResource = getClipBoardContent()[0].eResource() == target.eResource();
// Use original (non-copied) references only when copying within the same model resource.
// Otherwise, the copy in the destination resource will have a reference to the original
// resource.
EcoreUtil.Copier copier = new EcoreUtil.Copier(true, sameResource);
BasicEList<EObject> copiedObjects = new BasicEList<EObject>(); BasicEList<EObject> copiedObjects = new BasicEList<EObject>();
for(EObject obj : getClipBoardContent()) { for(EObject obj : getClipBoardContent()) {
EObject copy = copier.copy(obj); EObject copy = copier.copy(obj);
adaptCopyNames(copy, target); adaptCopyNames(copy, target);
copier.copyReferences();
IElementCompositorService.getInstance().compose(target, copy, IElementCompositorService.getInstance().compose(target, copy,
new PasteContext(getEditedEObject(), copier)); new PasteContext(getEditedEObject(), copier));
copiedObjects.add(copy); copiedObjects.add(copy);
} }
copier.copyReferences();
for(EObject obj : getClipBoardContent()) { for(EObject obj : getClipBoardContent()) {
if(obj instanceof ISpeciallyCopyiable) { if(obj instanceof ISpeciallyCopyiable) {
((ISpeciallyCopyiable)obj).specialCopyHook(copier); ((ISpeciallyCopyiable)obj).specialCopyHook(copier);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment