summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-02-26 14:17:12 (EST)
committerEike Stepper2007-02-26 14:17:12 (EST)
commita04abe02ec76c4012b3a4be451189923d25c1f96 (patch)
tree5873d54687e216e3693e76b32095b109957a6955
parent41c223e7667d4369f60be76ea7d63d59ab3e7785 (diff)
downloadcdo-a04abe02ec76c4012b3a4be451189923d25c1f96.zip
cdo-a04abe02ec76c4012b3a4be451189923d25c1f96.tar.gz
cdo-a04abe02ec76c4012b3a4be451189923d25c1f96.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/icons/full/obj16/EClass.gifbin0 -> 206 bytes
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/icons/full/obj16/EPackage.gifbin0 -> 207 bytes
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/icons/sample.gifbin0 -> 983 bytes
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/plugin.xml26
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/SharedIcons.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java49
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java23
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/StructuredView.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewEditorWizard.java129
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewEditorWizardPage.java405
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewSessionWizard.java111
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewSessionWizardPage.java173
13 files changed, 873 insertions, 51 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF
index 96ab136..d47873b 100644
--- a/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF
@@ -10,5 +10,6 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.emf.cdo.container,
org.eclipse.emf.edit.ui;visibility:=reexport,
org.eclipse.ui.ide;visibility:=reexport,
- org.eclipse.core.resources
+ org.eclipse.core.resources,
+ org.eclipse.emf.ecore.edit
Eclipse-LazyStart: true
diff --git a/plugins/org.eclipse.emf.cdo.ui/icons/full/obj16/EClass.gif b/plugins/org.eclipse.emf.cdo.ui/icons/full/obj16/EClass.gif
new file mode 100644
index 0000000..2b8da63
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/icons/full/obj16/EClass.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.cdo.ui/icons/full/obj16/EPackage.gif b/plugins/org.eclipse.emf.cdo.ui/icons/full/obj16/EPackage.gif
new file mode 100644
index 0000000..30c5c10
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/icons/full/obj16/EPackage.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.cdo.ui/icons/sample.gif b/plugins/org.eclipse.emf.cdo.ui/icons/sample.gif
new file mode 100644
index 0000000..34fb3c9
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/icons/sample.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.cdo.ui/plugin.xml b/plugins/org.eclipse.emf.cdo.ui/plugin.xml
index 2a7768f..8860860 100644
--- a/plugins/org.eclipse.emf.cdo.ui/plugin.xml
+++ b/plugins/org.eclipse.emf.cdo.ui/plugin.xml
@@ -30,5 +30,31 @@
</view>
</perspectiveExtension>
</extension>
+
+ <extension
+ point="org.eclipse.ui.newWizards">
+ <category
+ id="org.eclipse.emf.cdo.ui"
+ name="CDO">
+ </category>
+ <wizard
+ category="org.eclipse.emf.cdo.ui"
+ class="org.eclipse.emf.cdo.internal.ui.wizards.NewEditorWizard"
+ hasPages="true"
+ icon="icons/full/etool16/open_editor.gif"
+ id="org.eclipse.emf.cdo.ui.NewEditorWizard"
+ name="New CDO Editor"
+ project="false">
+ </wizard>
+ <wizard
+ category="org.eclipse.emf.cdo.ui"
+ class="org.eclipse.emf.cdo.internal.ui.wizards.NewSessionWizard"
+ hasPages="true"
+ icon="icons/full/etool16/open_session.gif"
+ id="org.eclipse.emf.cdo.ui.NewSessionWizard"
+ name="New CDO Session"
+ project="false">
+ </wizard>
+ </extension>
</plugin>
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/SharedIcons.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/SharedIcons.java
index 2e1ef30..9875f50 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/SharedIcons.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/SharedIcons.java
@@ -43,6 +43,10 @@ public class SharedIcons
public static final String OBJ_EDITOR_HISTORICAL = OBJ + "cdo_editor_historical";
+ public static final String OBJ_EPACKAGE = OBJ + "EPackage";
+
+ public static final String OBJ_ECLASS = OBJ + "EClass";
+
public static final String VIEW_SESSIONS = VIEW + "cdo_sessions";
public static Image getImage(String key)
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
index 7d81bf2..8f514aa 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
@@ -11,9 +11,6 @@ import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.common.command.BasicCommandStack;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CommandStack;
-import org.eclipse.emf.common.command.CommandStackListener;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.ui.MarkerHelper;
@@ -108,8 +105,6 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.EventObject;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
@@ -654,44 +649,6 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
//
Registry regsitry = EMFEditPlugin.getComposedAdapterFactoryDescriptorRegistry();
adapterFactory = new ComposedAdapterFactory(regsitry);
-
- // Create the command stack that will notify this editor as commands are
- // executed.
- //
- BasicCommandStack commandStack = new BasicCommandStack();
-
- // Add a listener to set the most recent command's affected objects to be
- // the selection of the viewer with focus.
- //
- commandStack.addCommandStackListener(new CommandStackListener()
- {
- public void commandStackChanged(final EventObject event)
- {
- getContainer().getDisplay().asyncExec(new Runnable()
- {
- public void run()
- {
- firePropertyChange(IEditorPart.PROP_DIRTY);
-
- // Try to select the affected objects.
- //
- Command mostRecentCommand = ((CommandStack)event.getSource()).getMostRecentCommand();
- if (mostRecentCommand != null)
- {
- setSelectionToViewer(mostRecentCommand.getAffectedObjects());
- }
- if (propertySheetPage != null && !propertySheetPage.getControl().isDisposed())
- {
- propertySheetPage.refresh();
- }
- }
- });
- }
- });
-
- // Create the editing domain with a special command stack.
- //
- editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>());
}
/**
@@ -924,14 +881,12 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
*/
public void createModel()
{
- // Assumes that the input is a file object.
- //
CDOEditorInput input = (CDOEditorInput)getEditorInput();
URI resourceURI = CDOUtil.createURI(input.getResourcePath());
- Exception exception = null;
ResourceSet resourceSet = editingDomain.getResourceSet();
Resource resource = null;
+ Exception exception = null;
CDOSession session = input.getSession();
if (input.isHistorical())
@@ -949,8 +904,6 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
try
{
- // Load the resource through the editing domain.
- //
resource = resourceSet.getResource(resourceURI, true);
}
catch (Exception e)
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java
index a02971d..1cf8c3e 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java
@@ -23,6 +23,11 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
public class CDOSessionsView extends StructuredView
{
private static final Container CONTAINER = ContainerManager.INSTANCE.getContainer();
@@ -55,6 +60,8 @@ public class CDOSessionsView extends StructuredView
viewer.setLabelProvider(ITEM_PROVIDER);
viewer.setSorter(new NameSorter());
viewer.setInput(CDO_ADAPTER);
+
+ getSite().setSelectionProvider(viewer);
}
@Override
@@ -227,7 +234,21 @@ public class CDOSessionsView extends StructuredView
@Override
protected void openEditor(CDOSession session)
{
- session.attach(new ResourceSetImpl(), System.currentTimeMillis());
+ DateFormat formatter = SimpleDateFormat.getInstance();
+ String value = formatter.format(new Date());
+ String str = showInputDialog("Enter a date", value);
+ if (str != null)
+ {
+ try
+ {
+ Date date = formatter.parse(str);
+ session.attach(new ResourceSetImpl(), date.getTime());
+ }
+ catch (ParseException ex)
+ {
+ CDOUI.LOG.error(ex);
+ }
+ }
}
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/StructuredView.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/StructuredView.java
index 7c5071c..9aa254b 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/StructuredView.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/StructuredView.java
@@ -24,7 +24,6 @@ import org.eclipse.ui.part.ViewPart;
public abstract class StructuredView extends ViewPart
{
-
public StructuredView()
{
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewEditorWizard.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewEditorWizard.java
new file mode 100644
index 0000000..fd7a94d
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewEditorWizard.java
@@ -0,0 +1,129 @@
+package org.eclipse.emf.cdo.internal.ui.wizards;
+
+import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.container.CDOContainerAdapter;
+
+import org.eclipse.net4j.container.Container;
+import org.eclipse.net4j.container.ContainerManager;
+import org.eclipse.net4j.transport.ConnectorException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+import java.lang.reflect.InvocationTargetException;
+
+public class NewEditorWizard extends Wizard implements INewWizard
+{
+ private NewSessionWizardPage sessionPage;
+
+ private NewEditorWizardPage editorPage;
+
+ private ISelection selection;
+
+ public NewEditorWizard()
+ {
+ setNeedsProgressMonitor(true);
+ }
+
+ public void addPages()
+ {
+ CDOSession session = null;
+ if (selection instanceof IStructuredSelection)
+ {
+ Object element = ((IStructuredSelection)selection).getFirstElement();
+ if (element instanceof CDOSession)
+ {
+ session = (CDOSession)element;
+ }
+ }
+
+ if (session == null)
+ {
+ addPage(sessionPage = new NewSessionWizardPage(selection));
+ }
+
+ addPage(editorPage = new NewEditorWizardPage());
+ editorPage.setSession(session);
+ }
+
+ public boolean performFinish()
+ {
+ final String connectorDescription = sessionPage.getConnectorDescription();
+ final String repositoryName = sessionPage.getRepositoryName();
+ IRunnableWithProgress op = new IRunnableWithProgress()
+ {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException
+ {
+ try
+ {
+ doFinish(connectorDescription, repositoryName, monitor);
+ }
+ catch (Exception e)
+ {
+ throw new InvocationTargetException(e);
+ }
+ finally
+ {
+ monitor.done();
+ }
+ }
+ };
+
+ try
+ {
+ getContainer().run(true, false, op);
+ }
+ catch (InterruptedException e)
+ {
+ return false;
+ }
+ catch (InvocationTargetException e)
+ {
+ Throwable realException = e.getTargetException();
+ MessageDialog.openError(getShell(), "Error", realException.getMessage());
+ return false;
+ }
+
+ return true;
+ }
+
+ private void doFinish(String connectorDescription, String repositoryName, IProgressMonitor monitor)
+ throws ConnectorException
+ {
+ String description = repositoryName + "@" + connectorDescription;
+ monitor.beginTask("Opening " + description, 1);
+ Container container = ContainerManager.INSTANCE.getContainer();
+ CDOContainerAdapter adapter = (CDOContainerAdapter)container.getAdapter("cdoclient");
+ adapter.getSession(description);
+ monitor.worked(1);
+
+ // monitor.setTaskName("Opening file for editing...");
+ // getShell().getDisplay().asyncExec(new Runnable()
+ // {
+ // public void run()
+ // {
+ // IWorkbenchPage page =
+ // PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ // try
+ // {
+ // IDE.openEditor(page, file, true);
+ // }
+ // catch (PartInitException e)
+ // {
+ // }
+ // }
+ // });
+ // monitor.worked(1);
+ }
+
+ public void init(IWorkbench workbench, IStructuredSelection selection)
+ {
+ this.selection = selection;
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewEditorWizardPage.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewEditorWizardPage.java
new file mode 100644
index 0000000..9b53194
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewEditorWizardPage.java
@@ -0,0 +1,405 @@
+package org.eclipse.emf.cdo.internal.ui.wizards;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.internal.ui.bundle.SharedIcons;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EPackage.Registry;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+public class NewEditorWizardPage extends WizardPage
+{
+ private CDOSession session;
+
+ private Label sessionLabel;
+
+ private Button loadResourceButton;
+
+ private LoadResourceComposite loadComposite;
+
+ private Button createResourceButton;
+
+ private CreateResourceComposite createComposite;
+
+ public NewEditorWizardPage()
+ {
+ super("wizardPage");
+ setTitle("Multi-page Editor File");
+ setDescription("This wizard creates a new file with *.mpe extension that can be opened by a multi-page editor.");
+ }
+
+ public CDOSession getSession()
+ {
+ return session;
+ }
+
+ public void setSession(CDOSession session)
+ {
+ this.session = session;
+ setSessionLabel();
+ }
+
+ public void createControl(Composite parent)
+ {
+ Composite container = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ container.setLayout(layout);
+ layout.numColumns = 2;
+ layout.verticalSpacing = 9;
+
+ Label label = new Label(container, SWT.NULL);
+ label.setText("Session:");
+
+ sessionLabel = new Label(container, SWT.NULL);
+ setSessionLabel();
+
+ loadResourceButton = createRadioButton(container, "Load resource:");
+ loadComposite = new LoadResourceComposite(container);
+
+ createResourceButton = createRadioButton(container, "Create resource:");
+ createComposite = new CreateResourceComposite(container);
+ createComposite.getViewer().setInput(EPackage.Registry.INSTANCE);
+
+ initialize();
+ dialogChanged();
+ setControl(container);
+ }
+
+ private Button createRadioButton(Composite container, String text)
+ {
+ Button button = new Button(container, SWT.RADIO);
+ button.setText(text);
+ button.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
+ button.addSelectionListener(new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent e)
+ {
+ dialogChanged();
+ }
+ });
+
+ return button;
+ }
+
+ private void setSessionLabel()
+ {
+ if (session != null && sessionLabel != null)
+ {
+ String repositoryName = session.getRepository().getName();
+ String connectorDescription = session.getChannel().getConnector().getDescription();
+ sessionLabel.setText(repositoryName + "@" + connectorDescription);
+ }
+ }
+
+ public void setVisible(boolean visible)
+ {
+ super.setVisible(visible);
+ if (visible)
+ {
+ setFocus();
+ }
+ }
+
+ private void setFocus()
+ {
+ if (loadResourceButton.getSelection())
+ {
+ loadComposite.getText().setFocus();
+ }
+ else
+ {
+ createComposite.getText().setFocus();
+ }
+ }
+
+ private void initialize()
+ {
+ if (false)
+ {
+ loadResourceButton.setSelection(true);
+ // resourceList.setItems(descriptions);
+ // resourceList.select(0);
+ }
+ else
+ {
+ createResourceButton.setSelection(true);
+ }
+ }
+
+ private void dialogChanged()
+ {
+ loadComposite.setEnabled(loadResourceButton.getSelection());
+ createComposite.setEnabled(createResourceButton.getSelection());
+ updateStatus(null);
+ }
+
+ private void updateStatus(String message)
+ {
+ setErrorMessage(message);
+ setPageComplete(message == null);
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class TextViewerComposite extends Composite implements ITreeContentProvider
+ {
+ private Text text;
+
+ private StructuredViewer viewer;
+
+ private LabelProvider labelProvider = new LabelProvider()
+ {
+ public Image getImage(Object element)
+ {
+ return TextViewerComposite.this.getImage(element);
+ }
+
+ public String getText(Object element)
+ {
+ return TextViewerComposite.this.getText(element);
+ }
+ };
+
+ public TextViewerComposite(Composite parent)
+ {
+ super(parent, SWT.NONE);
+ setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ GridLayout gridLayout = new GridLayout(1, false);
+ gridLayout.marginWidth = 0;
+ gridLayout.marginHeight = 0;
+ gridLayout.verticalSpacing = 5;
+ setLayout(gridLayout);
+
+ text = createText();
+ viewer = createViewer();
+ init();
+ }
+
+ public Text getText()
+ {
+ return text;
+ }
+
+ public StructuredViewer getViewer()
+ {
+ return viewer;
+ }
+
+ @Override
+ public void setEnabled(boolean enabled)
+ {
+ super.setEnabled(enabled);
+ text.setEnabled(enabled);
+ viewer.getControl().setEnabled(enabled);
+ }
+
+ protected Text createText()
+ {
+ Text text = new Text(this, SWT.BORDER);
+ text.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+ return text;
+ }
+
+ protected StructuredViewer createViewer()
+ {
+ Table table = new Table(this, SWT.BORDER | SWT.SINGLE);
+ table.setSize(300, 100);
+ table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ return new TableViewer(table);
+ }
+
+ protected void init()
+ {
+ viewer.setContentProvider(this);
+ viewer.setLabelProvider(labelProvider);
+ }
+
+ public Object[] getChildren(Object parentElement)
+ {
+ return new Object[0];
+ }
+
+ public Object getParent(Object element)
+ {
+ return null;
+ }
+
+ public boolean hasChildren(Object element)
+ {
+ return false;
+ }
+
+ public Object[] getElements(Object inputElement)
+ {
+ return getChildren(inputElement);
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
+ {
+ }
+
+ public Image getImage(Object element)
+ {
+ return null;
+ }
+
+ public String getText(Object element)
+ {
+ return element.toString();
+ }
+ }
+
+ public static class LoadResourceComposite extends TextViewerComposite
+ {
+ public LoadResourceComposite(Composite parent)
+ {
+ super(parent);
+ }
+ }
+
+ public static class CreateResourceComposite extends TextViewerComposite
+ {
+ private EPackage.Registry registry;
+
+ private Object[] uris;
+
+ public CreateResourceComposite(Composite parent)
+ {
+ super(parent);
+ }
+
+ protected StructuredViewer createViewer()
+ {
+ Tree tree = new Tree(this, SWT.BORDER | SWT.SINGLE);
+ tree.setSize(300, 100);
+ tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ return new TreeViewer(tree);
+ }
+
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
+ {
+ registry = (Registry)newInput;
+ Set<String> keySet = registry.keySet();
+ Iterator<String> it = keySet.iterator();
+ uris = new Object[keySet.size()];
+ for (int i = 0; i < uris.length; i++)
+ {
+ uris[i] = URI.createURI(it.next());
+ }
+ }
+
+ @Override
+ public boolean hasChildren(Object element)
+ {
+ return element instanceof URI;
+ }
+
+ @Override
+ public Object[] getChildren(Object parentElement)
+ {
+ if (parentElement == registry)
+ {
+ return uris;
+ }
+
+ if (parentElement instanceof URI)
+ {
+ URI uri = (URI)parentElement;
+ EPackage ePackage = registry.getEPackage(uri.toString());
+ List result = new ArrayList();
+ EList<EClassifier> classifiers = ePackage.getEClassifiers();
+ for (EClassifier classifier : classifiers)
+ {
+ if (classifier instanceof EClass)
+ {
+ EClass eClass = (EClass)classifier;
+ Class<?> instanceClass = eClass.getInstanceClass();
+ if (CDOObject.class.isAssignableFrom(instanceClass))
+ {
+ result.add(eClass);
+ }
+ }
+ }
+
+ return result.toArray(new Object[result.size()]);
+ }
+
+ return super.getChildren(parentElement);
+ }
+
+ @Override
+ public Object getParent(Object element)
+ {
+ if (element instanceof EClass)
+ {
+ EPackage ePackage = ((EClass)element).getEPackage();
+ return URI.createURI(ePackage.getNsURI());
+ }
+
+ return registry;
+ }
+
+ @Override
+ public String getText(Object element)
+ {
+ if (element instanceof URI)
+ {
+ return ((URI)element).toString();
+ }
+
+ if (element instanceof EClass)
+ {
+ return ((EClass)element).getName();
+ }
+
+ return super.getText(element);
+ }
+
+ @Override
+ public Image getImage(Object element)
+ {
+ if (element instanceof URI)
+ {
+ return SharedIcons.getImage(SharedIcons.OBJ_EPACKAGE);
+ }
+
+ if (element instanceof EClass)
+ {
+ return SharedIcons.getImage(SharedIcons.OBJ_ECLASS);
+ }
+
+ return super.getImage(element);
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewSessionWizard.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewSessionWizard.java
new file mode 100644
index 0000000..4dad73c
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewSessionWizard.java
@@ -0,0 +1,111 @@
+package org.eclipse.emf.cdo.internal.ui.wizards;
+
+import org.eclipse.emf.cdo.container.CDOContainerAdapter;
+
+import org.eclipse.net4j.container.Container;
+import org.eclipse.net4j.container.ContainerManager;
+import org.eclipse.net4j.transport.ConnectorException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+import java.lang.reflect.InvocationTargetException;
+
+public class NewSessionWizard extends Wizard implements INewWizard
+{
+ private NewSessionWizardPage page;
+
+ private ISelection selection;
+
+ public NewSessionWizard()
+ {
+ setNeedsProgressMonitor(true);
+ }
+
+ public void addPages()
+ {
+ page = new NewSessionWizardPage(selection);
+ addPage(page);
+ }
+
+ public boolean performFinish()
+ {
+ final String connectorDescription = page.getConnectorDescription();
+ final String repositoryName = page.getRepositoryName();
+ IRunnableWithProgress op = new IRunnableWithProgress()
+ {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException
+ {
+ try
+ {
+ doFinish(connectorDescription, repositoryName, monitor);
+ }
+ catch (Exception e)
+ {
+ throw new InvocationTargetException(e);
+ }
+ finally
+ {
+ monitor.done();
+ }
+ }
+ };
+
+ try
+ {
+ getContainer().run(true, false, op);
+ }
+ catch (InterruptedException e)
+ {
+ return false;
+ }
+ catch (InvocationTargetException e)
+ {
+ Throwable realException = e.getTargetException();
+ MessageDialog.openError(getShell(), "Error", realException.getMessage());
+ return false;
+ }
+
+ return true;
+ }
+
+ private void doFinish(String connectorDescription, String repositoryName, IProgressMonitor monitor)
+ throws ConnectorException
+ {
+ String description = repositoryName + "@" + connectorDescription;
+ monitor.beginTask("Opening " + description, 1);
+ Container container = ContainerManager.INSTANCE.getContainer();
+ CDOContainerAdapter adapter = (CDOContainerAdapter)container.getAdapter("cdoclient");
+ adapter.getSession(description);
+ monitor.worked(1);
+
+ // monitor.setTaskName("Opening file for editing...");
+ // getShell().getDisplay().asyncExec(new Runnable()
+ // {
+ // public void run()
+ // {
+ // IWorkbenchPage page =
+ // PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ // try
+ // {
+ // IDE.openEditor(page, file, true);
+ // }
+ // catch (PartInitException e)
+ // {
+ // }
+ // }
+ // });
+ // monitor.worked(1);
+ }
+
+ public void init(IWorkbench workbench, IStructuredSelection selection)
+ {
+ this.selection = selection;
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewSessionWizardPage.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewSessionWizardPage.java
new file mode 100644
index 0000000..6437d18
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewSessionWizardPage.java
@@ -0,0 +1,173 @@
+package org.eclipse.emf.cdo.internal.ui.wizards;
+
+import org.eclipse.net4j.container.Container;
+import org.eclipse.net4j.container.ContainerManager;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.Text;
+
+import java.util.Set;
+
+public class NewSessionWizardPage extends WizardPage
+{
+ private Button existingConnectorButton;
+
+ private Button newConnectorButton;
+
+ private List connectorList;
+
+ private Text connectorText;
+
+ private Text repositoryText;
+
+ private ISelection selection;
+
+ public NewSessionWizardPage(ISelection selection)
+ {
+ super("wizardPage");
+ setTitle("Multi-page Editor File");
+ setDescription("This wizard creates a new file with *.mpe extension that can be opened by a multi-page editor.");
+ this.selection = selection;
+ }
+
+ public void createControl(Composite parent)
+ {
+ Composite container = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ container.setLayout(layout);
+ layout.numColumns = 1;
+ layout.verticalSpacing = 9;
+
+ Group connectorGroup = new Group(container, SWT.None);
+ connectorGroup.setText("Connector");
+ connectorGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ connectorGroup.setLayout(new GridLayout(2, false));
+
+ existingConnectorButton = new Button(connectorGroup, SWT.RADIO);
+ existingConnectorButton.setText("Existing connector:");
+ existingConnectorButton.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
+ existingConnectorButton.addSelectionListener(new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent e)
+ {
+ dialogChanged();
+ }
+ });
+
+ connectorList = new List(connectorGroup, SWT.BORDER | SWT.SINGLE);
+ connectorList.setSize(300, 100);
+ connectorList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ newConnectorButton = new Button(connectorGroup, SWT.RADIO);
+ newConnectorButton.setText("New connector:");
+ newConnectorButton.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
+ newConnectorButton.addSelectionListener(new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent e)
+ {
+ dialogChanged();
+ }
+ });
+
+ connectorText = new Text(connectorGroup, SWT.BORDER);
+ connectorText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+
+ Group repositoryGroup = new Group(container, SWT.None);
+ repositoryGroup.setText("Repository");
+ repositoryGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+ repositoryGroup.setLayout(new GridLayout(2, false));
+
+ Label label = new Label(repositoryGroup, SWT.NULL);
+ label.setText("&Name:");
+
+ repositoryText = new Text(repositoryGroup, SWT.BORDER);
+ repositoryText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+
+ initialize();
+ dialogChanged();
+ setControl(container);
+ }
+
+ public void setVisible(boolean visible)
+ {
+ super.setVisible(visible);
+ if (visible)
+ {
+ setFocus();
+ }
+ }
+
+ private void setFocus()
+ {
+ if (existingConnectorButton.getSelection())
+ {
+ connectorList.setFocus();
+ }
+ else
+ {
+ connectorText.setFocus();
+ }
+ }
+
+ private String[] getConnectorDescriptions()
+ {
+ Container container = ContainerManager.INSTANCE.getContainer();
+ Set<String> keySet = container.getConnectorRegistry().keySet();
+ return keySet.toArray(new String[keySet.size()]);
+ }
+
+ private void initialize()
+ {
+ String[] descriptions = getConnectorDescriptions();
+ if (descriptions.length != 0)
+ {
+ existingConnectorButton.setSelection(true);
+ connectorList.setItems(descriptions);
+ connectorList.select(0);
+ }
+ else
+ {
+ existingConnectorButton.setEnabled(false);
+ newConnectorButton.setSelection(true);
+ }
+ }
+
+ private void dialogChanged()
+ {
+ connectorList.setEnabled(existingConnectorButton.getSelection());
+ connectorText.setEnabled(newConnectorButton.getSelection());
+ updateStatus(null);
+ }
+
+ private void updateStatus(String message)
+ {
+ setErrorMessage(message);
+ setPageComplete(message == null);
+ }
+
+ public String getRepositoryName()
+ {
+ return repositoryText.getText();
+ }
+
+ public String getConnectorDescription()
+ {
+ if (existingConnectorButton.getSelection())
+ {
+ return connectorList.getSelection()[0];
+ }
+
+ return connectorText.getText();
+ }
+} \ No newline at end of file