diff options
author | Eike Stepper | 2012-09-07 10:09:40 +0000 |
---|---|---|
committer | Eike Stepper | 2012-09-07 10:09:40 +0000 |
commit | fe7a6fef988fb0c56b164c98aa46a7a41b9d1913 (patch) | |
tree | 995786234e0d89472120f3b23fe4fca0e925dffc /plugins | |
parent | c26b4d70ad02851641b1fc94e8b5f23a56ab376e (diff) | |
download | cdo-fe7a6fef988fb0c56b164c98aa46a7a41b9d1913.tar.gz cdo-fe7a6fef988fb0c56b164c98aa46a7a41b9d1913.tar.xz cdo-fe7a6fef988fb0c56b164c98aa46a7a41b9d1913.zip |
[388928] Develop a resource transfer framework
https://bugs.eclipse.org/bugs/show_bug.cgi?id=388928
Diffstat (limited to 'plugins')
17 files changed, 299 insertions, 425 deletions
diff --git a/plugins/org.eclipse.emf.cdo.transfer.repository.ui/about.ini b/plugins/org.eclipse.emf.cdo.transfer.repository.ui/about.ini deleted file mode 100644 index 32006ae5d6..0000000000 --- a/plugins/org.eclipse.emf.cdo.transfer.repository.ui/about.ini +++ /dev/null @@ -1,15 +0,0 @@ -# about.ini -# contains information about a feature -# java.io.Properties file (ISO 8859-1 with "\" escapes) -# "%key" are externalized strings defined in about.properties -# This file does not need to be translated. - -# Property "aboutText" contains blurb for "About" dialog (translated) -aboutText=%featureText - -# Property "featureImage" contains path to feature image (32x32) -featureImage=modeling32.png - -# Property "appName" contains name of the application (translated) -appName=%featureName - diff --git a/plugins/org.eclipse.emf.cdo.transfer.repository.ui/about.mappings b/plugins/org.eclipse.emf.cdo.transfer.repository.ui/about.mappings deleted file mode 100644 index bddaab4310..0000000000 --- a/plugins/org.eclipse.emf.cdo.transfer.repository.ui/about.mappings +++ /dev/null @@ -1,6 +0,0 @@ -# about.mappings -# contains fill-ins for about.properties -# java.io.Properties file (ISO 8859-1 with "\" escapes) -# This file does not need to be translated. - -0=@build@
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.transfer.repository.ui/about.properties b/plugins/org.eclipse.emf.cdo.transfer.repository.ui/about.properties deleted file mode 100644 index 79cec9c91e..0000000000 --- a/plugins/org.eclipse.emf.cdo.transfer.repository.ui/about.properties +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. -# 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: -# Eike Stepper - initial API and implementation - -# NLS_MESSAGEFORMAT_VAR - -# ============================================================================== -# Do not change the properties between this line and the last line containing: -# %%% END OF TRANSLATED PROPERTIES %%% -# Instead, either redefine an existing property, or create a new property, -# append it to the end of the file, and change the code to use the new name. -# ============================================================================== - -featureName = CDO Transfer Framework (Repository Support) -featureText = CDO Transfer Framework (Repository Support)\n\ -Version: {featureVersion}\n\ -Build id: {0}\n\ -\n\ -Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. All rights reserved.\n\ -\n\ -Visit http://www.eclipse.org/cdo - -# ============================================================================== -# %%% END OF TRANSLATED PROPERTIES %%% -# The above properties have been shipped for translation. -# ============================================================================== diff --git a/plugins/org.eclipse.emf.cdo.transfer.repository.ui/build.properties b/plugins/org.eclipse.emf.cdo.transfer.repository.ui/build.properties index 24cc819fc3..e07e9fa27f 100644 --- a/plugins/org.eclipse.emf.cdo.transfer.repository.ui/build.properties +++ b/plugins/org.eclipse.emf.cdo.transfer.repository.ui/build.properties @@ -15,10 +15,6 @@ bin.includes = .,\ .options,\ about.html,\ copyright.txt,\ - about.ini,\ - about.mappings,\ - about.properties,\ - modeling32.png,\ plugin.xml src.includes = about.html,\ copyright.txt diff --git a/plugins/org.eclipse.emf.cdo.transfer.repository.ui/modeling32.png b/plugins/org.eclipse.emf.cdo.transfer.repository.ui/modeling32.png Binary files differdeleted file mode 100644 index 6b08de2ada..0000000000 --- a/plugins/org.eclipse.emf.cdo.transfer.repository.ui/modeling32.png +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.transfer.repository.ui/plugin.properties b/plugins/org.eclipse.emf.cdo.transfer.repository.ui/plugin.properties index f099fb5bd4..e2d8b6f481 100644 --- a/plugins/org.eclipse.emf.cdo.transfer.repository.ui/plugin.properties +++ b/plugins/org.eclipse.emf.cdo.transfer.repository.ui/plugin.properties @@ -7,5 +7,5 @@ # Contributors: # Eike Stepper - initial API and implementation -pluginName = CDO Transfer Framework (Repository Support) +pluginName = CDO Transfer Framework (Repository Support UI) providerName = Eclipse Modeling Project diff --git a/plugins/org.eclipse.emf.cdo.transfer.ui/plugin.properties b/plugins/org.eclipse.emf.cdo.transfer.ui/plugin.properties index 43c520c639..c597e058b7 100644 --- a/plugins/org.eclipse.emf.cdo.transfer.ui/plugin.properties +++ b/plugins/org.eclipse.emf.cdo.transfer.ui/plugin.properties @@ -7,5 +7,5 @@ # Contributors: # Eike Stepper - initial API and implementation -pluginName = CDO Transfer Framework UI +pluginName = CDO Transfer Framework (UI) providerName = Eclipse Modeling Project diff --git a/plugins/org.eclipse.emf.cdo.transfer.ui/src/org/eclipse/emf/cdo/transfer/ui/widgets/TransferComposite.java b/plugins/org.eclipse.emf.cdo.transfer.ui/src/org/eclipse/emf/cdo/transfer/ui/widgets/TransferComposite.java index 284d568618..7d81ed411e 100644 --- a/plugins/org.eclipse.emf.cdo.transfer.ui/src/org/eclipse/emf/cdo/transfer/ui/widgets/TransferComposite.java +++ b/plugins/org.eclipse.emf.cdo.transfer.ui/src/org/eclipse/emf/cdo/transfer/ui/widgets/TransferComposite.java @@ -28,7 +28,7 @@ public class TransferComposite extends SashForm implements ISelectionChangedList { private TransferTreeComposite transferTreeComposite; - private TransferMappingComposite transferMappingComposite; + private TransferDetailsComposite transferDetailsComposite; public TransferComposite(Composite parent, CDOTransfer transfer) { @@ -38,144 +38,16 @@ public class TransferComposite extends SashForm implements ISelectionChangedList transferTreeComposite = new TransferTreeComposite(this, SWT.NONE, transfer); transferTreeComposite.getViewer().addSelectionChangedListener(this); - transferMappingComposite = new TransferMappingComposite(this, SWT.NONE, transfer); + transferDetailsComposite = new TransferDetailsComposite(this, SWT.NONE, transfer); selectionChanged(null); - // Composite details = new Composite(this, SWT.NONE); - // GridLayout gl_composite = new GridLayout(4, false); - // gl_composite.marginWidth = 10; - // details.setLayout(gl_composite); - // - // Label lblSourcePath = new Label(details, SWT.NONE); - // lblSourcePath.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); - // lblSourcePath.setText("Source Path:"); - // - // sourcePath = new Text(details, SWT.BORDER | SWT.READ_ONLY); - // sourcePath.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); - // - // Label lblType = new Label(details, SWT.NONE); - // lblType.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); - // lblType.setText("Type:"); - // - // transferType = new Combo(details, SWT.NONE); - // transferType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); - // - // Set<CDOTransferType> usedTransferTypes = transfer.getUsedTransferTypes(); - // usedTransferTypes.addAll(CDOTransferType.STANDARD_TYPES); - // - // List<CDOTransferType> transferTypes = new ArrayList<CDOTransferType>(usedTransferTypes); - // Collections.sort(transferTypes); - // - // for (CDOTransferType type : transferTypes) - // { - // transferType.add(type.toString()); - // } - // - // Label lblTargetPath = new Label(details, SWT.NONE); - // lblTargetPath.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); - // lblTargetPath.setText("Target Path:"); - // - // targetPath = new Text(details, SWT.BORDER | SWT.READ_ONLY); - // targetPath.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); - // - // Label lblStatus = new Label(details, SWT.NONE); - // lblStatus.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); - // lblStatus.setText("Status:"); - // - // status = new Label(details, SWT.NONE); - // status.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); - // - // Label lblRelativePath = new Label(details, SWT.NONE); - // lblRelativePath.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); - // lblRelativePath.setText("Relative Path:"); - // - // Composite pathPane = new Composite(details, SWT.NONE); - // pathPane.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); - // GridLayout gl_pathPane = new GridLayout(3, false); - // gl_pathPane.marginWidth = 0; - // gl_pathPane.marginHeight = 0; - // pathPane.setLayout(gl_pathPane); - // - // relativePath = new Text(pathPane, SWT.BORDER); - // relativePath.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); - // relativePath.addModifyListener(new ModifyListener() - // { - // public void modifyText(ModifyEvent e) - // { - // String text = relativePath.getText(); - // CDOTransferMapping mapping = getSelection(); - // if (!ObjectUtil.equals(mapping.getRelativePath().toString(), text)) - // { - // mapping.setRelativePath(text); - // UIUtil.refreshElement(treeViewer, mapping, true); - // } - // } - // }); - // - // Button btnNewButton = new Button(pathPane, SWT.NONE); - // btnNewButton.setBounds(0, 0, 75, 25); - // btnNewButton.setText("<"); - // - // Button btnNewButton_1 = new Button(pathPane, SWT.NONE); - // btnNewButton_1.setBounds(0, 0, 75, 25); - // btnNewButton_1.setText(">"); - // - // Label lblResolution = new Label(details, SWT.NONE); - // lblResolution.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); - // lblResolution.setText("Resolution:"); - // - // resolution = new Combo(details, SWT.NONE); - // resolution.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); - // - // Label lblUnmappedReferences = new Label(details, SWT.NONE); - // lblUnmappedReferences.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1)); - // lblUnmappedReferences.setText("Unmapped References:"); - // - // TableViewer tableViewer = new TableViewer(details, SWT.BORDER | SWT.FULL_SELECTION); - // Table table = tableViewer.getTable(); - // table.setLinesVisible(true); - // table.setHeaderVisible(true); - // table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); - // - // TableViewerColumn tableViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE); - // TableColumn tblclmnUri = tableViewerColumn.getColumn(); - // tblclmnUri.setWidth(373); - // tblclmnUri.setText("URI"); - // - // TableViewerColumn tableViewerColumn_1 = new TableViewerColumn(tableViewer, SWT.NONE); - // TableColumn tblclmnNewColumn = tableViewerColumn_1.getColumn(); - // tblclmnNewColumn.setWidth(341); - // tblclmnNewColumn.setText("Transformation"); - // - // Composite composite_1 = new Composite(details, SWT.NONE); - // GridLayout gl_composite_1 = new GridLayout(1, false); - // gl_composite_1.marginWidth = 0; - // gl_composite_1.marginHeight = 0; - // composite_1.setLayout(gl_composite_1); - // composite_1.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 2, 1)); - // - // Button mapSource = new Button(composite_1, SWT.NONE); - // mapSource.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); - // mapSource.setBounds(0, 0, 75, 25); - // mapSource.setText("Map From Source"); - // - // Button replaceTarget = new Button(composite_1, SWT.NONE); - // replaceTarget.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); - // replaceTarget.setBounds(0, 0, 75, 25); - // replaceTarget.setText("Replace With Target"); - // - // Button keepAsIs = new Button(composite_1, SWT.NONE); - // keepAsIs.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); - // keepAsIs.setBounds(0, 0, 75, 25); - // keepAsIs.setText("Keep As Is"); - setWeights(new int[] { 2, 1 }); } public void selectionChanged(SelectionChangedEvent event) { CDOTransferMapping mapping = transferTreeComposite.getSelectedMapping(); - transferMappingComposite.setMapping(mapping); + transferDetailsComposite.setMapping(mapping); } @Override diff --git a/plugins/org.eclipse.emf.cdo.transfer.ui/src/org/eclipse/emf/cdo/transfer/ui/widgets/TransferMappingComposite.java b/plugins/org.eclipse.emf.cdo.transfer.ui/src/org/eclipse/emf/cdo/transfer/ui/widgets/TransferDetailsComposite.java index 31dc5e8fea..88a86ddfb1 100644 --- a/plugins/org.eclipse.emf.cdo.transfer.ui/src/org/eclipse/emf/cdo/transfer/ui/widgets/TransferMappingComposite.java +++ b/plugins/org.eclipse.emf.cdo.transfer.ui/src/org/eclipse/emf/cdo/transfer/ui/widgets/TransferDetailsComposite.java @@ -18,9 +18,14 @@ import org.eclipse.net4j.util.ObjectUtil; import org.eclipse.net4j.util.StringUtil; import org.eclipse.net4j.util.event.IEvent; import org.eclipse.net4j.util.event.IListener; +import org.eclipse.net4j.util.ui.StructuredContentProvider; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; +import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.TableViewerColumn; import org.eclipse.swt.SWT; @@ -40,6 +45,7 @@ import org.eclipse.swt.widgets.Text; import java.util.ArrayList; import java.util.Collections; +import java.util.Iterator; import java.util.List; import java.util.Set; @@ -47,7 +53,7 @@ import java.util.Set; * @author Eike Stepper * @since 4.2 */ -public class TransferMappingComposite extends Composite implements IListener +public class TransferDetailsComposite extends Composite implements IListener { private static final String UP = ".."; @@ -69,7 +75,9 @@ public class TransferMappingComposite extends Composite implements IListener private Combo resolution; - public TransferMappingComposite(Composite parent, int style, final CDOTransfer transfer) + private TableViewer unmappedModels; + + public TransferDetailsComposite(Composite parent, int style, final CDOTransfer transfer) { super(parent, style); this.transfer = transfer; @@ -243,26 +251,50 @@ public class TransferMappingComposite extends Composite implements IListener resolution.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); resolution.setVisible(false); - Label unmappedReferencesLabel = new Label(this, SWT.NONE); - unmappedReferencesLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1)); - unmappedReferencesLabel.setText("Unmapped References:"); + Label unmappedModelsLabel = new Label(this, SWT.NONE); + unmappedModelsLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1)); + unmappedModelsLabel.setText("Unmapped Models:"); - TableViewer tableViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION); - Table table = tableViewer.getTable(); + unmappedModels = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION); + Table table = unmappedModels.getTable(); table.setLinesVisible(true); table.setHeaderVisible(true); table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); - TableViewerColumn uriViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE); + TableViewerColumn uriViewerColumn = new TableViewerColumn(unmappedModels, SWT.NONE); TableColumn uriColumn = uriViewerColumn.getColumn(); uriColumn.setWidth(373); uriColumn.setText("URI"); - TableViewerColumn transformationViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE); + TableViewerColumn transformationViewerColumn = new TableViewerColumn(unmappedModels, SWT.NONE); TableColumn transformationColumn = transformationViewerColumn.getColumn(); transformationColumn.setWidth(341); transformationColumn.setText("Transformation"); + unmappedModels.setContentProvider(new StructuredContentProvider<CDOTransfer>() + { + public Object[] getElements(Object inputElement) + { + CDOTransfer transfer = getInput(); + Set<Resource> resources = transfer.getModelTransferContext().resolve(); + + int size = resources.size(); + URI[] uris = new URI[size]; + + Iterator<Resource> it = resources.iterator(); + for (int i = 0; i < size; i++) + { + Resource resource = it.next(); + uris[i] = resource.getURI(); + } + + return uris; + } + }); + + unmappedModels.setLabelProvider(new LabelProvider()); + unmappedModels.setInput(transfer); + GridLayout transformationButtonsPaneLayout = new GridLayout(1, false); transformationButtonsPaneLayout.marginWidth = 0; transformationButtonsPaneLayout.marginHeight = 0; @@ -382,23 +414,25 @@ public class TransferMappingComposite extends Composite implements IListener { if (event instanceof CDOTransfer.TransferTypeChangedEvent) { - CDOTransfer.TransferTypeChangedEvent e2 = (CDOTransfer.TransferTypeChangedEvent)event; - final String value = e2.getNewType().toString(); - if (!ObjectUtil.equals(value, transferType.getText())) + CDOTransfer.TransferTypeChangedEvent e = (CDOTransfer.TransferTypeChangedEvent)event; + final String value = e.getNewType().toString(); + getDisplay().asyncExec(new Runnable() { - getDisplay().asyncExec(new Runnable() + public void run() { - public void run() + if (!ObjectUtil.equals(value, transferType.getText())) { transferType.setText(value); } - }); - } + + unmappedModels.refresh(); + } + }); } else if (event instanceof CDOTransfer.RelativePathChangedEvent) { - CDOTransfer.RelativePathChangedEvent e2 = (CDOTransfer.RelativePathChangedEvent)event; - final String value = e2.getNewPath().toString(); + CDOTransfer.RelativePathChangedEvent e = (CDOTransfer.RelativePathChangedEvent)event; + final String value = e.getNewPath().toString(); if (!ObjectUtil.equals(value, relativePath.getText())) { getDisplay().asyncExec(new Runnable() diff --git a/plugins/org.eclipse.emf.cdo.transfer.workspace.ui/about.ini b/plugins/org.eclipse.emf.cdo.transfer.workspace.ui/about.ini deleted file mode 100644 index 32006ae5d6..0000000000 --- a/plugins/org.eclipse.emf.cdo.transfer.workspace.ui/about.ini +++ /dev/null @@ -1,15 +0,0 @@ -# about.ini -# contains information about a feature -# java.io.Properties file (ISO 8859-1 with "\" escapes) -# "%key" are externalized strings defined in about.properties -# This file does not need to be translated. - -# Property "aboutText" contains blurb for "About" dialog (translated) -aboutText=%featureText - -# Property "featureImage" contains path to feature image (32x32) -featureImage=modeling32.png - -# Property "appName" contains name of the application (translated) -appName=%featureName - diff --git a/plugins/org.eclipse.emf.cdo.transfer.workspace.ui/about.mappings b/plugins/org.eclipse.emf.cdo.transfer.workspace.ui/about.mappings deleted file mode 100644 index bddaab4310..0000000000 --- a/plugins/org.eclipse.emf.cdo.transfer.workspace.ui/about.mappings +++ /dev/null @@ -1,6 +0,0 @@ -# about.mappings -# contains fill-ins for about.properties -# java.io.Properties file (ISO 8859-1 with "\" escapes) -# This file does not need to be translated. - -0=@build@
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.transfer.workspace.ui/about.properties b/plugins/org.eclipse.emf.cdo.transfer.workspace.ui/about.properties deleted file mode 100644 index 836c86d704..0000000000 --- a/plugins/org.eclipse.emf.cdo.transfer.workspace.ui/about.properties +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. -# 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: -# Eike Stepper - initial API and implementation - -# NLS_MESSAGEFORMAT_VAR - -# ============================================================================== -# Do not change the properties between this line and the last line containing: -# %%% END OF TRANSLATED PROPERTIES %%% -# Instead, either redefine an existing property, or create a new property, -# append it to the end of the file, and change the code to use the new name. -# ============================================================================== - -featureName = CDO Transfer Framework (Workspace Support) -featureText = CDO Transfer Framework (Workspace Support)\n\ -Version: {featureVersion}\n\ -Build id: {0}\n\ -\n\ -Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. All rights reserved.\n\ -\n\ -Visit http://www.eclipse.org/cdo - -# ============================================================================== -# %%% END OF TRANSLATED PROPERTIES %%% -# The above properties have been shipped for translation. -# ============================================================================== diff --git a/plugins/org.eclipse.emf.cdo.transfer.workspace.ui/build.properties b/plugins/org.eclipse.emf.cdo.transfer.workspace.ui/build.properties index 24cc819fc3..e07e9fa27f 100644 --- a/plugins/org.eclipse.emf.cdo.transfer.workspace.ui/build.properties +++ b/plugins/org.eclipse.emf.cdo.transfer.workspace.ui/build.properties @@ -15,10 +15,6 @@ bin.includes = .,\ .options,\ about.html,\ copyright.txt,\ - about.ini,\ - about.mappings,\ - about.properties,\ - modeling32.png,\ plugin.xml src.includes = about.html,\ copyright.txt diff --git a/plugins/org.eclipse.emf.cdo.transfer.workspace.ui/modeling32.png b/plugins/org.eclipse.emf.cdo.transfer.workspace.ui/modeling32.png Binary files differdeleted file mode 100644 index 6b08de2ada..0000000000 --- a/plugins/org.eclipse.emf.cdo.transfer.workspace.ui/modeling32.png +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.transfer.workspace.ui/plugin.properties b/plugins/org.eclipse.emf.cdo.transfer.workspace.ui/plugin.properties index 05ccf857d9..52f62749a6 100644 --- a/plugins/org.eclipse.emf.cdo.transfer.workspace.ui/plugin.properties +++ b/plugins/org.eclipse.emf.cdo.transfer.workspace.ui/plugin.properties @@ -7,5 +7,5 @@ # Contributors: # Eike Stepper - initial API and implementation -pluginName = CDO Transfer Framework (Workspace Support) +pluginName = CDO Transfer Framework (Workspace Support UI) providerName = Eclipse Modeling Project diff --git a/plugins/org.eclipse.emf.cdo.transfer/src/org/eclipse/emf/cdo/transfer/CDOTransfer.java b/plugins/org.eclipse.emf.cdo.transfer/src/org/eclipse/emf/cdo/transfer/CDOTransfer.java index da024157ec..83f4fbb283 100644 --- a/plugins/org.eclipse.emf.cdo.transfer/src/org/eclipse/emf/cdo/transfer/CDOTransfer.java +++ b/plugins/org.eclipse.emf.cdo.transfer/src/org/eclipse/emf/cdo/transfer/CDOTransfer.java @@ -56,7 +56,7 @@ public class CDOTransfer implements INotifier private CDOTransferType defaultTransferType = CDOTransferType.UNKNOWN; - private ModelTransferContext modelTransferContext = new ModelTransferContext(); + private ModelTransferContext modelTransferContext = createModelTransferContext(); public CDOTransfer(CDOTransferSystem sourceSystem, CDOTransferSystem targetSystem) { @@ -99,31 +99,6 @@ public class CDOTransfer implements INotifier return modelTransferContext; } - protected ResourceSet createResourceSet(CDOTransferSystem system) - { - Resource.Factory.Registry registry = new ResourceFactoryRegistryImpl() - { - { - getProtocolToFactoryMap().putAll(Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap()); - getExtensionToFactoryMap().putAll(Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap()); - getContentTypeToFactoryMap().putAll(Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap()); - - getExtensionToFactoryMap().remove(Resource.Factory.Registry.DEFAULT_EXTENSION); - getContentTypeToFactoryMap().remove(Resource.Factory.Registry.DEFAULT_CONTENT_TYPE_IDENTIFIER); - } - - @Override - protected Factory delegatedGetFactory(URI uri, String contentTypeIdentifier) - { - return null; - } - }; - - ResourceSet resourceSet = new ResourceSetImpl(); - resourceSet.setResourceFactoryRegistry(registry); - return resourceSet; - } - public final CDOTransferMapping getRootMapping() { return rootMapping; @@ -194,15 +169,20 @@ public class CDOTransfer implements INotifier return mapping; } + protected void unmap(CDOTransferMapping mapping) + { + mappings.remove(mapping.getSource()); + mapping.getChildren(); + } + protected CDOTransferMapping createMapping(CDOTransferElement source, CDOTransferMapping parent) throws IOException { return new CDOTransferMappingImpl(this, source, parent); } - protected void unmap(CDOTransferMapping mapping) + protected ModelTransferContext createModelTransferContext() { - mappings.remove(mapping.getSource()); - mapping.getChildren(); + return new ModelTransferContext(); } protected CDOTransferType getTransferType(CDOTransferElement source) @@ -314,132 +294,53 @@ public class CDOTransfer implements INotifier } } - /** - * @author Eike Stepper - */ - public class ModelTransferContext + protected void childrenChanged(CDOTransferMapping mapping, CDOTransferMapping child, ChildrenChangedEvent.Kind kind) { - private ResourceSet sourceResourceSet; - - private ResourceSet targetResourceSet; - - private Map<CDOTransferElement, Resource> resources = new HashMap<CDOTransferElement, Resource>(); - - private Set<Resource> resourcesToSave = new HashSet<Resource>(); - - protected ModelTransferContext() - { - } - - public final ResourceSet getSourceResourceSet() + if (child.getTransferType() == CDOTransferType.MODEL) { - if (sourceResourceSet == null) + if (kind == ChildrenChangedEvent.Kind.MAPPED) { - sourceResourceSet = sourceSystem.provideResourceSet(); - if (sourceResourceSet == null) - { - sourceResourceSet = createResourceSet(sourceSystem); - } + modelTransferContext.addModelMapping(child); } - - return sourceResourceSet; - } - - public final ResourceSet getTargetResourceSet() - { - if (targetResourceSet == null) + else { - targetResourceSet = targetSystem.provideResourceSet(); - if (targetResourceSet == null) - { - targetResourceSet = createResourceSet(targetSystem); - } + modelTransferContext.removeModelMapping(child); } - - return targetResourceSet; - } - - public void registerSourceExtension(String extension, Resource.Factory factory) - { - Map<String, Object> map = getSourceResourceSet().getResourceFactoryRegistry().getExtensionToFactoryMap(); - map.put(extension, factory); - } - - public void registerSourceProtocol(String protocol, Resource.Factory factory) - { - Map<String, Object> map = getSourceResourceSet().getResourceFactoryRegistry().getProtocolToFactoryMap(); - map.put(protocol, factory); - } - - public void registerSourceContentType(String contentType, Resource.Factory factory) - { - Map<String, Object> map = getSourceResourceSet().getResourceFactoryRegistry().getContentTypeToFactoryMap(); - map.put(contentType, factory); - } - - public void registerTargetExtension(String extension, Resource.Factory factory) - { - Map<String, Object> map = getTargetResourceSet().getResourceFactoryRegistry().getExtensionToFactoryMap(); - map.put(extension, factory); } - public void registerTargetProtocol(String protocol, Resource.Factory factory) + IListener[] listeners = notifier.getListeners(); + if (listeners != null) { - Map<String, Object> map = getTargetResourceSet().getResourceFactoryRegistry().getProtocolToFactoryMap(); - map.put(protocol, factory); + notifier.fireEvent(new ChildrenChangedEvent(mapping, child, kind), listeners); } + } - public void registerTargetContentType(String contentType, Resource.Factory factory) + protected void relativePathChanged(CDOTransferMapping mapping, IPath oldPath, IPath newPath) + { + IListener[] listeners = notifier.getListeners(); + if (listeners != null) { - Map<String, Object> map = getTargetResourceSet().getResourceFactoryRegistry().getContentTypeToFactoryMap(); - map.put(contentType, factory); + notifier.fireEvent(new RelativePathChangedEvent(mapping, oldPath, newPath), listeners); } + } - protected Resource getSourceResource(CDOTransferMapping mapping) + protected void transferTypeChanged(CDOTransferMapping mapping, CDOTransferType oldType, CDOTransferType newType) + { + if (oldType == CDOTransferType.MODEL) { - URI uri = mapping.getSource().getURI(); - ResourceSet sourceResourceSet = getSourceResourceSet(); - return sourceResourceSet.getResource(uri, true); + modelTransferContext.removeModelMapping(mapping); } - protected Resource getTargetResource(CDOTransferMapping mapping) throws IOException + if (newType == CDOTransferType.MODEL) { - IPath path = mapping.getFullPath(); - ResourceSet targetResourceSet = getTargetResourceSet(); - return targetSystem.createModel(targetResourceSet, path); + modelTransferContext.addModelMapping(mapping); } - protected boolean hasResourceFactory(CDOTransferElement source) + IListener[] listeners = notifier.getListeners(); + if (listeners != null) { - URI uri = source.getURI(); - // TODO Derive resourceSet from element.getSystem()? - Registry registry = getSourceResourceSet().getResourceFactoryRegistry(); - return registry.getFactory(uri) != null; + notifier.fireEvent(new TransferTypeChangedEvent(mapping, oldType, newType), listeners); } - - protected void perform(CDOTransferMapping mapping) throws IOException - { - Resource sourceResource = getSourceResource(mapping); - Resource targetResource = getTargetResource(mapping); - - EList<EObject> sourceContents = sourceResource.getContents(); - Collection<EObject> targetContents = EcoreUtil.copyAll(sourceContents); - - EList<EObject> contents = targetResource.getContents(); - contents.addAll(targetContents); - resourcesToSave.add(targetResource); - } - - protected void save() throws IOException - { - for (Resource resource : resourcesToSave) - { - resource.save(null); - } - - resourcesToSave.clear(); - } - } /** @@ -577,4 +478,205 @@ public class CDOTransfer implements INotifier return newType; } } + + /** + * @author Eike Stepper + */ + public class ModelTransferContext + { + private ResourceSet sourceResourceSet; + + private ResourceSet targetResourceSet; + + private Map<CDOTransferElement, Resource> elementResources = new HashMap<CDOTransferElement, Resource>(); + + private Map<Resource, CDOTransferElement> resourceElements = new HashMap<Resource, CDOTransferElement>(); + + private Set<Resource> unmappedModels; + + protected ModelTransferContext() + { + } + + public final ResourceSet getSourceResourceSet() + { + if (sourceResourceSet == null) + { + sourceResourceSet = sourceSystem.provideResourceSet(); + if (sourceResourceSet == null) + { + sourceResourceSet = createResourceSet(sourceSystem); + } + } + + return sourceResourceSet; + } + + public final ResourceSet getTargetResourceSet() + { + if (targetResourceSet == null) + { + targetResourceSet = targetSystem.provideResourceSet(); + if (targetResourceSet == null) + { + targetResourceSet = createResourceSet(targetSystem); + } + } + + return targetResourceSet; + } + + public void registerSourceExtension(String extension, Resource.Factory factory) + { + Map<String, Object> map = getSourceResourceSet().getResourceFactoryRegistry().getExtensionToFactoryMap(); + map.put(extension, factory); + } + + public void registerSourceProtocol(String protocol, Resource.Factory factory) + { + Map<String, Object> map = getSourceResourceSet().getResourceFactoryRegistry().getProtocolToFactoryMap(); + map.put(protocol, factory); + } + + public void registerSourceContentType(String contentType, Resource.Factory factory) + { + Map<String, Object> map = getSourceResourceSet().getResourceFactoryRegistry().getContentTypeToFactoryMap(); + map.put(contentType, factory); + } + + public void registerTargetExtension(String extension, Resource.Factory factory) + { + Map<String, Object> map = getTargetResourceSet().getResourceFactoryRegistry().getExtensionToFactoryMap(); + map.put(extension, factory); + } + + public void registerTargetProtocol(String protocol, Resource.Factory factory) + { + Map<String, Object> map = getTargetResourceSet().getResourceFactoryRegistry().getProtocolToFactoryMap(); + map.put(protocol, factory); + } + + public void registerTargetContentType(String contentType, Resource.Factory factory) + { + Map<String, Object> map = getTargetResourceSet().getResourceFactoryRegistry().getContentTypeToFactoryMap(); + map.put(contentType, factory); + } + + public Set<Resource> resolve() + { + if (unmappedModels == null) + { + unmappedModels = new HashSet<Resource>(); + + ResourceSet resourceSet = getSourceResourceSet(); + EList<Resource> resources = resourceSet.getResources(); + resources.clear(); + + Set<Resource> mappedModels = resourceElements.keySet(); + resources.addAll(mappedModels); + EcoreUtil.resolveAll(resourceSet); + + for (Resource resource : resources) + { + if (!mappedModels.contains(resource)) + { + unmappedModels.add(resource); + } + } + } + + return unmappedModels; + } + + protected void addModelMapping(CDOTransferMapping mapping) + { + CDOTransferElement element = mapping.getSource(); + URI uri = element.getURI(); + + ResourceSet resourceSet = getSourceResourceSet(); + Resource resource = resourceSet.getResource(uri, true); + elementResources.put(element, resource); + resourceElements.put(resource, element); + unmappedModels = null; + } + + protected void removeModelMapping(CDOTransferMapping mapping) + { + CDOTransferElement element = mapping.getSource(); + Resource resource = elementResources.remove(element); + resourceElements.remove(resource); + resource.unload(); + + ResourceSet resourceSet = getSourceResourceSet(); + resourceSet.getResources().remove(resource); + unmappedModels = null; + } + + protected Resource getSourceResource(CDOTransferMapping mapping) + { + URI uri = mapping.getSource().getURI(); + ResourceSet sourceResourceSet = getSourceResourceSet(); + return sourceResourceSet.getResource(uri, true); + } + + protected Resource getTargetResource(CDOTransferMapping mapping) throws IOException + { + IPath path = mapping.getFullPath(); + ResourceSet targetResourceSet = getTargetResourceSet(); + return targetSystem.createModel(targetResourceSet, path); + } + + protected ResourceSet createResourceSet(CDOTransferSystem system) + { + Resource.Factory.Registry registry = new ResourceFactoryRegistryImpl() + { + { + getProtocolToFactoryMap().putAll(Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap()); + getExtensionToFactoryMap().putAll(Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap()); + getContentTypeToFactoryMap().putAll(Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap()); + + getExtensionToFactoryMap().remove(Resource.Factory.Registry.DEFAULT_EXTENSION); + getContentTypeToFactoryMap().remove(Resource.Factory.Registry.DEFAULT_CONTENT_TYPE_IDENTIFIER); + } + + @Override + protected Factory delegatedGetFactory(URI uri, String contentTypeIdentifier) + { + return null; + } + }; + + ResourceSet resourceSet = new ResourceSetImpl(); + resourceSet.setResourceFactoryRegistry(registry); + return resourceSet; + } + + protected boolean hasResourceFactory(CDOTransferElement source) + { + URI uri = source.getURI(); + // TODO Derive resourceSet from element.getSystem()? + Registry registry = getSourceResourceSet().getResourceFactoryRegistry(); + return registry.getFactory(uri) != null; + } + + protected void perform(CDOTransferMapping mapping) throws IOException + { + Resource sourceResource = getSourceResource(mapping); + Resource targetResource = getTargetResource(mapping); + + EList<EObject> sourceContents = sourceResource.getContents(); + Collection<EObject> targetContents = EcoreUtil.copyAll(sourceContents); + + EList<EObject> contents = targetResource.getContents(); + contents.addAll(targetContents); + } + + protected void save() throws IOException + { + for (Resource resource : elementResources.values()) + { + resource.save(null); + } + } + } } diff --git a/plugins/org.eclipse.emf.cdo.transfer/src/org/eclipse/emf/cdo/transfer/CDOTransferMappingImpl.java b/plugins/org.eclipse.emf.cdo.transfer/src/org/eclipse/emf/cdo/transfer/CDOTransferMappingImpl.java index 438764e016..8c995778e2 100644 --- a/plugins/org.eclipse.emf.cdo.transfer/src/org/eclipse/emf/cdo/transfer/CDOTransferMappingImpl.java +++ b/plugins/org.eclipse.emf.cdo.transfer/src/org/eclipse/emf/cdo/transfer/CDOTransferMappingImpl.java @@ -10,10 +10,7 @@ */ package org.eclipse.emf.cdo.transfer; -import org.eclipse.emf.cdo.transfer.CDOTransfer.ChildrenChangedEvent.Kind; - import org.eclipse.net4j.util.ObjectUtil; -import org.eclipse.net4j.util.event.IListener; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; @@ -50,7 +47,7 @@ class CDOTransferMappingImpl implements CDOTransferMapping relativePath = new Path(source.getName()); CDOTransferType transferType = transfer.getTransferType(source); - setTransferType(transferType); + this.transferType = transferType; if (parent != null) { @@ -71,8 +68,8 @@ class CDOTransferMappingImpl implements CDOTransferMapping this.transfer = transfer; source = null; parent = null; + transferType = CDOTransferType.FOLDER; relativePath = Path.EMPTY; - setTransferType(CDOTransferType.FOLDER); } public CDOTransfer getTransfer() @@ -126,12 +123,7 @@ class CDOTransferMappingImpl implements CDOTransferMapping { IPath oldPath = this.relativePath; this.relativePath = relativePath; - - IListener[] listeners = transfer.notifier.getListeners(); - if (listeners != null) - { - transfer.notifier.fireEvent(new CDOTransfer.RelativePathChangedEvent(this, oldPath, relativePath), listeners); - } + transfer.relativePathChanged(this, oldPath, relativePath); } } @@ -193,7 +185,7 @@ class CDOTransferMappingImpl implements CDOTransferMapping if (!children.contains(child)) { children.add(child); - fireChildrenChangedEvent(child, CDOTransfer.ChildrenChangedEvent.Kind.MAPPED); + transfer.childrenChanged(this, child, CDOTransfer.ChildrenChangedEvent.Kind.MAPPED); } } @@ -201,7 +193,7 @@ class CDOTransferMappingImpl implements CDOTransferMapping { if (children != null && children.remove(child)) { - fireChildrenChangedEvent(child, CDOTransfer.ChildrenChangedEvent.Kind.UNMAPPED); + transfer.childrenChanged(this, child, CDOTransfer.ChildrenChangedEvent.Kind.UNMAPPED); } } @@ -213,15 +205,6 @@ class CDOTransferMappingImpl implements CDOTransferMapping } } - private void fireChildrenChangedEvent(CDOTransferMapping child, Kind kind) - { - IListener[] listeners = transfer.notifier.getListeners(); - if (listeners != null) - { - transfer.notifier.fireEvent(new CDOTransfer.ChildrenChangedEvent(this, child, kind), listeners); - } - } - public void unmap() { transfer.unmap(this); @@ -247,12 +230,7 @@ class CDOTransferMappingImpl implements CDOTransferMapping CDOTransferType oldType = this.transferType; this.transferType = transferType; - - IListener[] listeners = transfer.notifier.getListeners(); - if (listeners != null) - { - transfer.notifier.fireEvent(new CDOTransfer.TransferTypeChangedEvent(this, oldType, transferType), listeners); - } + transfer.transferTypeChanged(this, oldType, transferType); } } |