Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-09-06 17:36:24 +0000
committerEike Stepper2012-09-06 17:36:24 +0000
commita8bb4accd55f61451fe68f608a66ccc9a2d76cd5 (patch)
tree853ec4cda7a7ca71e0f9c4ca16dd171f47fb7729 /plugins
parentcfdef9afcf736cd872cd784647c25c52b653a7bb (diff)
downloadcdo-a8bb4accd55f61451fe68f608a66ccc9a2d76cd5.tar.gz
cdo-a8bb4accd55f61451fe68f608a66ccc9a2d76cd5.tar.xz
cdo-a8bb4accd55f61451fe68f608a66ccc9a2d76cd5.zip
[388928] Develop a resource transfer framework
https://bugs.eclipse.org/bugs/show_bug.cgi?id=388928
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.transfer.ui/src/org/eclipse/emf/cdo/transfer/ui/widgets/TransferMappingComposite.java220
-rw-r--r--plugins/org.eclipse.emf.cdo.transfer.ui/src/org/eclipse/emf/cdo/transfer/ui/widgets/TransferTreeComposite.java32
2 files changed, 183 insertions, 69 deletions
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/TransferMappingComposite.java
index 650eab0db9..a13f5f7db9 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/TransferMappingComposite.java
@@ -19,6 +19,8 @@ import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.event.IEvent;
import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.swt.SWT;
@@ -47,6 +49,10 @@ import java.util.Set;
*/
public class TransferMappingComposite extends Composite implements IListener
{
+ private static final String UP = "..";
+
+ private static final Path UP_PATH = new Path(UP);
+
private CDOTransfer transfer;
private CDOTransferMapping mapping;
@@ -57,13 +63,13 @@ public class TransferMappingComposite extends Composite implements IListener
private Combo transferType;
- private Label status;
+ private Text status;
private Text relativePath;
private Combo resolution;
- public TransferMappingComposite(Composite parent, int style, CDOTransfer transfer)
+ public TransferMappingComposite(Composite parent, int style, final CDOTransfer transfer)
{
super(parent, style);
this.transfer = transfer;
@@ -73,16 +79,16 @@ public class TransferMappingComposite extends Composite implements IListener
gl_composite.marginWidth = 10;
setLayout(gl_composite);
- Label lblSourcePath = new Label(this, SWT.NONE);
- lblSourcePath.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
- lblSourcePath.setText("Source Path:");
+ Label sourcePathLabel = new Label(this, SWT.NONE);
+ sourcePathLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
+ sourcePathLabel.setText("Source Path:");
sourcePath = new Text(this, SWT.BORDER | SWT.READ_ONLY);
sourcePath.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
- Label lblType = new Label(this, SWT.NONE);
- lblType.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
- lblType.setText("Type:");
+ Label transferTypeLabel = new Label(this, SWT.NONE);
+ transferTypeLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
+ transferTypeLabel.setText("Type:");
transferType = new Combo(this, SWT.NONE);
transferType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
@@ -94,7 +100,8 @@ public class TransferMappingComposite extends Composite implements IListener
if (mapping != null)
{
String text = transferType.getText();
- mapping.setTransferType(CDOTransferType.REGISTRY.get(text));
+ CDOTransferType type = CDOTransferType.REGISTRY.get(text);
+ mapping.setTransferType(type);
}
}
});
@@ -110,30 +117,34 @@ public class TransferMappingComposite extends Composite implements IListener
transferType.add(type.toString());
}
- Label lblTargetPath = new Label(this, SWT.NONE);
- lblTargetPath.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
- lblTargetPath.setText("Target Path:");
+ Label targetPathLabel = new Label(this, SWT.NONE);
+ targetPathLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
+ targetPathLabel.setText("Target Path:");
targetPath = new Text(this, SWT.BORDER | SWT.READ_ONLY);
targetPath.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
- Label lblStatus = new Label(this, SWT.NONE);
- lblStatus.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
- lblStatus.setText("Status:");
+ Label statusLabel = new Label(this, SWT.NONE);
+ statusLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
+ statusLabel.setText("Status:");
- status = new Label(this, SWT.NONE);
+ status = new Text(this, SWT.BORDER | SWT.READ_ONLY);
status.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
- Label lblRelativePath = new Label(this, SWT.NONE);
- lblRelativePath.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
- lblRelativePath.setText("Relative Path:");
+ Label relativePathLabel = new Label(this, SWT.NONE);
+ relativePathLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
+ relativePathLabel.setText("Relative Path:");
+
+ GridData gd_pathPane = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
+ gd_pathPane.heightHint = 27;
+
+ GridLayout pathPaneLayout = new GridLayout(4, false);
+ pathPaneLayout.marginWidth = 0;
+ pathPaneLayout.marginHeight = 0;
Composite pathPane = new Composite(this, 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);
+ pathPane.setLayoutData(gd_pathPane);
+ pathPane.setLayout(pathPaneLayout);
relativePath = new Text(pathPane, SWT.BORDER);
relativePath.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
@@ -149,24 +160,90 @@ public class TransferMappingComposite extends Composite implements IListener
}
});
- Button btnNewButton = new Button(pathPane, SWT.NONE);
- btnNewButton.setBounds(0, 0, 75, 25);
- btnNewButton.setText("<");
+ Button leftButton = new Button(pathPane, SWT.NONE);
+ leftButton.setBounds(0, 0, 75, 25);
+ leftButton.setText("<");
+ leftButton.addSelectionListener(new SelectionAdapter()
+ {
+ @Override
+ public void widgetSelected(SelectionEvent e)
+ {
+ IPath path = new Path(relativePath.getText());
+ if (path.isEmpty() || UP.equals(path.segment(0)))
+ {
+ path = UP_PATH.append(path);
+ }
+ else
+ {
+ path = path.removeFirstSegments(1);
+ }
+
+ mapping.setRelativePath(path);
+ }
+ });
+
+ Button rightButton = new Button(pathPane, SWT.NONE);
+ rightButton.setBounds(0, 0, 75, 25);
+ rightButton.setText(">");
+ rightButton.addSelectionListener(new SelectionAdapter()
+ {
+ @Override
+ public void widgetSelected(SelectionEvent e)
+ {
+ IPath path = new Path(relativePath.getText());
+ if (UP.equals(path.segment(0)))
+ {
+ path = path.removeFirstSegments(1);
+ }
+ else if (path.isEmpty())
+ {
+ path = new Path(mapping.getSource().getName());
+ }
+ else
+ {
+ path = new Path("folder").append(path);
+ }
+
+ mapping.setRelativePath(path);
+ }
+ });
+
+ Button renameButton = new Button(pathPane, SWT.NONE);
+ renameButton.setText("+");
+ renameButton.addSelectionListener(new SelectionAdapter()
+ {
+ @Override
+ public void widgetSelected(SelectionEvent e)
+ {
+ String sourceName = mapping.getSource().getName();
+
+ IPath path = new Path(relativePath.getText());
+ if (path.isEmpty() || UP.equals(path.segment(0)))
+ {
+ path = new Path(sourceName);
+ }
+
+ String name = path.lastSegment();
+ int i = 1;
+ while (transfer.getTargetSystem().getElement(path) != null) // TODO This condition is still wrong
+ {
+ path = path.removeLastSegments(1).append(name + i);
+ }
- Button btnNewButton_1 = new Button(pathPane, SWT.NONE);
- btnNewButton_1.setBounds(0, 0, 75, 25);
- btnNewButton_1.setText(">");
+ mapping.setRelativePath(path);
+ }
+ });
- Label lblResolution = new Label(this, SWT.NONE);
- lblResolution.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
- lblResolution.setText("Resolution:");
+ Label resolutionLabel = new Label(this, SWT.NONE);
+ resolutionLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
+ resolutionLabel.setText("Resolution:");
resolution = new Combo(this, SWT.NONE);
resolution.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
- Label lblUnmappedReferences = new Label(this, SWT.NONE);
- lblUnmappedReferences.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
- lblUnmappedReferences.setText("Unmapped References:");
+ Label unmappedReferencesLabel = new Label(this, SWT.NONE);
+ unmappedReferencesLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
+ unmappedReferencesLabel.setText("Unmapped References:");
TableViewer tableViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION);
Table table = tableViewer.getTable();
@@ -174,34 +251,35 @@ public class TransferMappingComposite extends Composite implements IListener
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 uriViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
+ TableColumn uriColumn = uriViewerColumn.getColumn();
+ uriColumn.setWidth(373);
+ uriColumn.setText("URI");
- TableViewerColumn tableViewerColumn_1 = new TableViewerColumn(tableViewer, SWT.NONE);
- TableColumn tblclmnNewColumn = tableViewerColumn_1.getColumn();
- tblclmnNewColumn.setWidth(341);
- tblclmnNewColumn.setText("Transformation");
+ TableViewerColumn transformationViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
+ TableColumn transformationColumn = transformationViewerColumn.getColumn();
+ transformationColumn.setWidth(341);
+ transformationColumn.setText("Transformation");
- Composite composite_1 = new Composite(this, 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));
+ GridLayout transformationButtonsPaneLayout = new GridLayout(1, false);
+ transformationButtonsPaneLayout.marginWidth = 0;
+ transformationButtonsPaneLayout.marginHeight = 0;
- Button mapSource = new Button(composite_1, SWT.NONE);
+ Composite transformationButtonsPane = new Composite(this, SWT.NONE);
+ transformationButtonsPane.setLayout(transformationButtonsPaneLayout);
+ transformationButtonsPane.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 2, 1));
+
+ Button mapSource = new Button(transformationButtonsPane, 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);
+ Button replaceTarget = new Button(transformationButtonsPane, 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);
+ Button keepAsIs = new Button(transformationButtonsPane, 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");
@@ -216,6 +294,11 @@ public class TransferMappingComposite extends Composite implements IListener
super.dispose();
}
+ public CDOTransfer getTransfer()
+ {
+ return transfer;
+ }
+
public CDOTransferMapping getMapping()
{
return mapping;
@@ -245,6 +328,36 @@ public class TransferMappingComposite extends Composite implements IListener
}
}
+ public Text getSourcePath()
+ {
+ return sourcePath;
+ }
+
+ public Text getTargetPath()
+ {
+ return targetPath;
+ }
+
+ public Combo getTransferType()
+ {
+ return transferType;
+ }
+
+ public Text getStatus()
+ {
+ return status;
+ }
+
+ public Text getRelativePath()
+ {
+ return relativePath;
+ }
+
+ public Combo getResolution()
+ {
+ return resolution;
+ }
+
@Override
public boolean setFocus()
{
@@ -291,6 +404,7 @@ public class TransferMappingComposite extends Composite implements IListener
public void run()
{
relativePath.setText(value);
+ status.setText(mapping.getStatus().toString());
}
});
}
diff --git a/plugins/org.eclipse.emf.cdo.transfer.ui/src/org/eclipse/emf/cdo/transfer/ui/widgets/TransferTreeComposite.java b/plugins/org.eclipse.emf.cdo.transfer.ui/src/org/eclipse/emf/cdo/transfer/ui/widgets/TransferTreeComposite.java
index a66b0c2ff7..f47cc15f7f 100644
--- a/plugins/org.eclipse.emf.cdo.transfer.ui/src/org/eclipse/emf/cdo/transfer/ui/widgets/TransferTreeComposite.java
+++ b/plugins/org.eclipse.emf.cdo.transfer.ui/src/org/eclipse/emf/cdo/transfer/ui/widgets/TransferTreeComposite.java
@@ -32,7 +32,7 @@ public class TransferTreeComposite extends Composite
{
private CDOTransfer transfer;
- private TreeViewer treeViewer;
+ private TreeViewer viewer;
public TransferTreeComposite(Composite parent, int style, CDOTransfer transfer)
{
@@ -40,36 +40,36 @@ public class TransferTreeComposite extends Composite
this.transfer = transfer;
setLayout(new FillLayout(SWT.VERTICAL));
- treeViewer = new TreeViewer(this, SWT.NONE);
+ viewer = new TreeViewer(this, SWT.NONE);
- Tree tree = treeViewer.getTree();
+ Tree tree = viewer.getTree();
tree.setLinesVisible(true);
tree.setHeaderVisible(true);
- TreeViewerColumn sourceViewerColumn = new TreeViewerColumn(treeViewer, SWT.NONE);
+ TreeViewerColumn sourceViewerColumn = new TreeViewerColumn(viewer, SWT.NONE);
TreeColumn sourceColumn = sourceViewerColumn.getColumn();
sourceColumn.setWidth(350);
- sourceColumn.setText("Source");
+ sourceColumn.setText("From " + transfer.getSourceSystem());
- TreeViewerColumn typeViewerColumn = new TreeViewerColumn(treeViewer, SWT.NONE);
+ TreeViewerColumn typeViewerColumn = new TreeViewerColumn(viewer, SWT.NONE);
TreeColumn typeColumn = typeViewerColumn.getColumn();
typeColumn.setWidth(100);
typeColumn.setText("Type");
- TreeViewerColumn targetViewerColumn = new TreeViewerColumn(treeViewer, SWT.NONE);
+ TreeViewerColumn targetViewerColumn = new TreeViewerColumn(viewer, SWT.NONE);
TreeColumn targetColumn = targetViewerColumn.getColumn();
targetColumn.setWidth(450);
- targetColumn.setText("Target");
+ targetColumn.setText("To " + transfer.getTargetSystem());
- TreeViewerColumn statusViewerColumn = new TreeViewerColumn(treeViewer, SWT.NONE);
+ TreeViewerColumn statusViewerColumn = new TreeViewerColumn(viewer, SWT.NONE);
TreeColumn statusColumn = statusViewerColumn.getColumn();
statusColumn.setWidth(100);
statusColumn.setText("Status");
- treeViewer.setAutoExpandLevel(TreeViewer.ALL_LEVELS);
- treeViewer.setContentProvider(new TransferContentProvider());
- treeViewer.setLabelProvider(new TransferLabelProvider(transfer));
- treeViewer.setInput(transfer.getRootMapping());
+ viewer.setAutoExpandLevel(TreeViewer.ALL_LEVELS);
+ viewer.setContentProvider(new TransferContentProvider());
+ viewer.setLabelProvider(new TransferLabelProvider(transfer));
+ viewer.setInput(transfer.getRootMapping());
}
public CDOTransfer getTransfer()
@@ -79,18 +79,18 @@ public class TransferTreeComposite extends Composite
public TreeViewer getViewer()
{
- return treeViewer;
+ return viewer;
}
public CDOTransferMapping getSelectedMapping()
{
- IStructuredSelection selection = (IStructuredSelection)treeViewer.getSelection();
+ IStructuredSelection selection = (IStructuredSelection)viewer.getSelection();
return (CDOTransferMapping)selection.getFirstElement();
}
@Override
public boolean setFocus()
{
- return treeViewer.getTree().setFocus();
+ return viewer.getTree().setFocus();
}
}

Back to the top