Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-11-07 08:26:04 +0000
committerEike Stepper2012-11-07 08:26:04 +0000
commit170c8839b0ad4264fd3d762f3a32a6796314d042 (patch)
tree4d6d7a1da854566b79fd3433bba036fcc0adee27 /plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui
parent0c072215632c9877c0655f49423d83d21cdbd0dd (diff)
downloadcdo-170c8839b0ad4264fd3d762f3a32a6796314d042.tar.gz
cdo-170c8839b0ad4264fd3d762f3a32a6796314d042.tar.xz
cdo-170c8839b0ad4264fd3d762f3a32a6796314d042.zip
[393744] [UI] Factor IDE dependencies out of org.eclipse.emf.cdo.ui
https://bugs.eclipse.org/bugs/show_bug.cgi?id=393744
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui')
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/CDOLobEditorInput.java579
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/CDOLobStorage.java209
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateBranchAction.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenResourceEditorAction.java79
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterWorkspacePackagesAction.java75
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/CreateBranchDialog.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenResourcesDialog.java29
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/PackageRegistryDialog.java127
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOActionBarContributor.java71
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java436
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/EditorEditorAdvisor.java606
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/PluginDelegator.java33
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties8
13 files changed, 1329 insertions, 932 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/CDOLobEditorInput.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/CDOLobEditorInput.java
index 07f85e40e6..11144b52ce 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/CDOLobEditorInput.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/CDOLobEditorInput.java
@@ -10,83 +10,55 @@
*/
package org.eclipse.emf.cdo.internal.ui;
-import org.eclipse.emf.cdo.common.lob.CDOBlob;
-import org.eclipse.emf.cdo.common.lob.CDOClob;
-import org.eclipse.emf.cdo.eresource.CDOBinaryResource;
-import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.eresource.CDOResourceLeaf;
-import org.eclipse.emf.cdo.eresource.CDOTextResource;
-import org.eclipse.emf.cdo.internal.ui.bundle.OM;
-import org.eclipse.emf.cdo.view.CDOView;
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.io.IORuntimeException;
-import org.eclipse.net4j.util.io.IOUtil;
-
-import org.eclipse.core.filesystem.EFS;
-import org.eclipse.core.filesystem.IFileInfo;
-import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.filesystem.provider.FileInfo;
-import org.eclipse.core.filesystem.provider.FileStore;
-import org.eclipse.core.filesystem.provider.FileSystem;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;
-import org.eclipse.ui.IURIEditorInput;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.CharArrayReader;
-import java.io.CharArrayWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.WeakHashMap;
/**
* @author Eike Stepper
*/
-public class CDOLobEditorInput extends PlatformObject implements IURIEditorInput
+public class CDOLobEditorInput extends PlatformObject implements IEditorInput
{
- private static final String SCHEME = "cdo.lob";
-
- private static final Map<CDOLobEditorInput, LobFileStore> fileStores = new WeakHashMap<CDOLobEditorInput, LobFileStore>();
+ // private static final String SCHEME = "cdo.lob";
+ //
+ // private static final Map<CDOLobEditorInput, LobFileStore> fileStores = new WeakHashMap<CDOLobEditorInput,
+ // LobFileStore>();
+ //
+ // private URI uri;
+ //
+ // public URI getURI()
+ // {
+ // return uri;
+ // }
private CDOResourceLeaf resource;
- private URI uri;
-
public CDOLobEditorInput(CDOResourceLeaf resource)
{
this.resource = resource;
- try
- {
- CDOView view = resource.cdoView();
- org.eclipse.emf.common.util.URI resourceURI = resource.getURI();
- String path = resourceURI.authority() + "/" + resourceURI.path() + "?session=" + view.getSessionID() + "&view="
- + view.getViewID();
-
- uri = new URI(SCHEME + "://" + path);
- }
- catch (URISyntaxException ex)
- {
- throw WrappedException.wrap(ex);
- }
-
- synchronized (fileStores)
- {
- fileStores.remove(this);
- fileStores.put(this, null);
- }
+ // try
+ // {
+ // CDOView view = resource.cdoView();
+ // org.eclipse.emf.common.util.URI resourceURI = resource.getURI();
+ // String path = resourceURI.authority() + "/" + resourceURI.path() + "?session=" + view.getSessionID() + "&view="
+ // + view.getViewID();
+ //
+ // uri = new URI(SCHEME + "://" + path);
+ // }
+ // catch (URISyntaxException ex)
+ // {
+ // throw WrappedException.wrap(ex);
+ // }
+ //
+ // synchronized (fileStores)
+ // {
+ // fileStores.remove(this);
+ // fileStores.put(this, null);
+ // }
}
public CDOResourceLeaf getResource()
@@ -119,250 +91,245 @@ public class CDOLobEditorInput extends PlatformObject implements IURIEditorInput
return resource.getURI().toString();
}
- public URI getURI()
- {
- return uri;
- }
-
- @Override
- public int hashCode()
- {
- final int prime = 31;
- int result = 1;
- result = prime * result + (uri == null ? 0 : uri.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (this == obj)
- {
- return true;
- }
-
- if (obj == null)
- {
- return false;
- }
-
- if (!(obj instanceof CDOLobEditorInput))
- {
- return false;
- }
-
- CDOLobEditorInput other = (CDOLobEditorInput)obj;
- if (uri == null)
- {
- if (other.uri != null)
- {
- return false;
- }
- }
- else if (!uri.equals(other.uri))
- {
- return false;
- }
-
- return true;
- }
-
- /**
- * @author Eike Stepper
- */
- public static class LobFileSystem extends FileSystem
- {
- @Override
- public IFileStore getStore(URI uri)
- {
- synchronized (fileStores)
- {
- for (Entry<CDOLobEditorInput, LobFileStore> entry : fileStores.entrySet())
- {
- CDOLobEditorInput editorInput = entry.getKey();
- if (uri.equals(editorInput.getURI()))
- {
- LobFileStore store = entry.getValue();
- if (store == null)
- {
- store = createStore(uri, editorInput);
- fileStores.put(editorInput, store);
- }
-
- return store;
- }
- }
- }
-
- throw new IllegalStateException("No editor input is cached for " + uri);
- }
-
- protected LobFileStore createStore(URI uri, CDOLobEditorInput editorInput)
- {
- CDOResourceLeaf resource = editorInput.getResource();
- return new LobFileStore(resource, uri);
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static class LobFileStore extends FileStore
- {
- private static final String[] NO_CHILDREN = new String[0];
-
- private CDOResourceLeaf resource;
-
- private final URI uri;
-
- private FileInfo info;
-
- public LobFileStore(CDOResourceLeaf resource, URI uri)
- {
- this.resource = resource;
- this.uri = uri;
- }
-
- @Override
- public URI toURI()
- {
- return uri;
- }
-
- @Override
- public IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreException
- {
- if (info == null)
- {
- info = new FileInfo(getName());
- info.setLastModified(0L);
- info.setExists(true);
- info.setDirectory(false);
- info.setLength(EFS.NONE);
- info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, false);
- info.setAttribute(EFS.ATTRIBUTE_HIDDEN, false);
- }
-
- return info;
- }
-
- @Override
- public InputStream openInputStream(int options, IProgressMonitor monitor) throws CoreException
- {
- try
- {
- if (resource instanceof CDOTextResource)
- {
- CDOTextResource textResource = (CDOTextResource)resource;
- CDOClob clob = textResource.getContents();
- if (clob == null)
- {
- return new ByteArrayInputStream(new byte[0]);
- }
-
- Reader reader = clob.getContents();
- CharArrayWriter writer = new CharArrayWriter();
- IOUtil.copyCharacter(reader, writer);
-
- String encoding = getEncoding(textResource);
- byte[] bytes = writer.toString().getBytes(encoding);
- return new ByteArrayInputStream(bytes);
- }
-
- if (resource instanceof CDOBinaryResource)
- {
- CDOBlob blob = ((CDOBinaryResource)resource).getContents();
- if (blob == null)
- {
- return new ByteArrayInputStream(new byte[0]);
- }
-
- InputStream inputStream = blob.getContents();
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- IOUtil.copy(inputStream, outputStream);
-
- byte[] bytes = outputStream.toByteArray();
- return new ByteArrayInputStream(bytes);
- }
-
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- ((CDOResource)resource).save(outputStream, null);
- byte[] bytes = outputStream.toByteArray();
- return new ByteArrayInputStream(bytes);
- }
- catch (IOException ex)
- {
- throw new IORuntimeException(ex);
- }
- }
-
- @Override
- public OutputStream openOutputStream(int options, IProgressMonitor monitor) throws CoreException
- {
- return new ByteArrayOutputStream()
- {
- @Override
- public void close() throws IOException
- {
- if (resource instanceof CDOTextResource)
- {
- CDOTextResource textResource = (CDOTextResource)resource;
- String encoding = getEncoding(textResource);
-
- String string = toString(encoding);
- CDOClob clob = new CDOClob(new CharArrayReader(string.toCharArray()));
- textResource.setContents(clob);
- }
- else if (resource instanceof CDOBinaryResource)
- {
- byte[] bytes = toByteArray();
- CDOBlob blob = new CDOBlob(new ByteArrayInputStream(bytes));
- ((CDOBinaryResource)resource).setContents(blob);
- }
- }
- };
- }
-
- @Override
- public String getName()
- {
- return resource.getName();
- }
-
- @Override
- public IFileStore getParent()
- {
- return null; // This is a flat file system
- }
-
- @Override
- public IFileStore getChild(String name)
- {
- return null; // This is a flat file system
- }
-
- @Override
- public String[] childNames(int options, IProgressMonitor monitor) throws CoreException
- {
- return NO_CHILDREN; // This is a flat file system
- }
-
- private String getEncoding(CDOTextResource textResource)
- {
- String encoding = textResource.getEncoding();
- if (encoding == null)
- {
- try
- {
- encoding = ResourcesPlugin.getWorkspace().getRoot().getDefaultCharset();
- }
- catch (CoreException ex)
- {
- OM.LOG.error(ex);
- }
- }
-
- return encoding;
- }
- }
+ // @Override
+ // public int hashCode()
+ // {
+ // final int prime = 31;
+ // int result = 1;
+ // result = prime * result + (uri == null ? 0 : uri.hashCode());
+ // return result;
+ // }
+ //
+ // @Override
+ // public boolean equals(Object obj)
+ // {
+ // if (this == obj)
+ // {
+ // return true;
+ // }
+ //
+ // if (obj == null)
+ // {
+ // return false;
+ // }
+ //
+ // if (!(obj instanceof CDOLobEditorInput))
+ // {
+ // return false;
+ // }
+ //
+ // CDOLobEditorInput other = (CDOLobEditorInput)obj;
+ // if (uri == null)
+ // {
+ // if (other.uri != null)
+ // {
+ // return false;
+ // }
+ // }
+ // else if (!uri.equals(other.uri))
+ // {
+ // return false;
+ // }
+ //
+ // return true;
+ // }
+ //
+ // /**
+ // * @author Eike Stepper
+ // */
+ // public static class LobFileSystem extends FileSystem
+ // {
+ // @Override
+ // public IFileStore getStore(URI uri)
+ // {
+ // synchronized (fileStores)
+ // {
+ // for (Entry<CDOLobEditorInput, LobFileStore> entry : fileStores.entrySet())
+ // {
+ // CDOLobEditorInput editorInput = entry.getKey();
+ // if (uri.equals(editorInput.getURI()))
+ // {
+ // LobFileStore store = entry.getValue();
+ // if (store == null)
+ // {
+ // store = createStore(uri, editorInput);
+ // fileStores.put(editorInput, store);
+ // }
+ //
+ // return store;
+ // }
+ // }
+ // }
+ //
+ // throw new IllegalStateException("No editor input is cached for " + uri);
+ // }
+ //
+ // protected LobFileStore createStore(URI uri, CDOLobEditorInput editorInput)
+ // {
+ // CDOResourceLeaf resource = editorInput.getResource();
+ // return new LobFileStore(resource, uri);
+ // }
+ // }
+ //
+ // /**
+ // * @author Eike Stepper
+ // */
+ // public static class LobFileStore extends FileStore
+ // {
+ // private static final String[] NO_CHILDREN = new String[0];
+ //
+ // private CDOResourceLeaf resource;
+ //
+ // private final URI uri;
+ //
+ // private FileInfo info;
+ //
+ // public LobFileStore(CDOResourceLeaf resource, URI uri)
+ // {
+ // this.resource = resource;
+ // this.uri = uri;
+ // }
+ //
+ // @Override
+ // public URI toURI()
+ // {
+ // return uri;
+ // }
+ //
+ // @Override
+ // public IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreException
+ // {
+ // if (info == null)
+ // {
+ // info = new FileInfo(getName());
+ // info.setLastModified(0L);
+ // info.setExists(true);
+ // info.setDirectory(false);
+ // info.setLength(EFS.NONE);
+ // info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, false);
+ // info.setAttribute(EFS.ATTRIBUTE_HIDDEN, false);
+ // }
+ //
+ // return info;
+ // }
+ //
+ // @Override
+ // public InputStream openInputStream(int options, IProgressMonitor monitor) throws CoreException
+ // {
+ // try
+ // {
+ // if (resource instanceof CDOTextResource)
+ // {
+ // CDOTextResource textResource = (CDOTextResource)resource;
+ // CDOClob clob = textResource.getContents();
+ // if (clob == null)
+ // {
+ // return new ByteArrayInputStream(new byte[0]);
+ // }
+ //
+ // Reader reader = clob.getContents();
+ // CharArrayWriter writer = new CharArrayWriter();
+ // IOUtil.copyCharacter(reader, writer);
+ //
+ // String encoding = getEncoding(textResource);
+ // byte[] bytes = writer.toString().getBytes(encoding);
+ // return new ByteArrayInputStream(bytes);
+ // }
+ //
+ // if (resource instanceof CDOBinaryResource)
+ // {
+ // CDOBlob blob = ((CDOBinaryResource)resource).getContents();
+ // if (blob == null)
+ // {
+ // return new ByteArrayInputStream(new byte[0]);
+ // }
+ //
+ // InputStream inputStream = blob.getContents();
+ // ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ // IOUtil.copy(inputStream, outputStream);
+ //
+ // byte[] bytes = outputStream.toByteArray();
+ // return new ByteArrayInputStream(bytes);
+ // }
+ //
+ // ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ // ((CDOResource)resource).save(outputStream, null);
+ // byte[] bytes = outputStream.toByteArray();
+ // return new ByteArrayInputStream(bytes);
+ // }
+ // catch (IOException ex)
+ // {
+ // throw new IORuntimeException(ex);
+ // }
+ // }
+ //
+ // @Override
+ // public OutputStream openOutputStream(int options, IProgressMonitor monitor) throws CoreException
+ // {
+ // return new ByteArrayOutputStream()
+ // {
+ // @Override
+ // public void close() throws IOException
+ // {
+ // if (resource instanceof CDOTextResource)
+ // {
+ // CDOTextResource textResource = (CDOTextResource)resource;
+ // String encoding = getEncoding(textResource);
+ //
+ // String string = toString(encoding);
+ // CDOClob clob = new CDOClob(new CharArrayReader(string.toCharArray()));
+ // textResource.setContents(clob);
+ // }
+ // else if (resource instanceof CDOBinaryResource)
+ // {
+ // byte[] bytes = toByteArray();
+ // CDOBlob blob = new CDOBlob(new ByteArrayInputStream(bytes));
+ // ((CDOBinaryResource)resource).setContents(blob);
+ // }
+ // }
+ // };
+ // }
+ //
+ // @Override
+ // public String getName()
+ // {
+ // return resource.getName();
+ // }
+ //
+ // @Override
+ // public IFileStore getParent()
+ // {
+ // return null; // This is a flat file system
+ // }
+ //
+ // @Override
+ // public IFileStore getChild(String name)
+ // {
+ // return null; // This is a flat file system
+ // }
+ //
+ // @Override
+ // public String[] childNames(int options, IProgressMonitor monitor) throws CoreException
+ // {
+ // return NO_CHILDREN; // This is a flat file system
+ // }
+ //
+ // private String getEncoding(CDOTextResource textResource)
+ // {
+ // String encoding = textResource.getEncoding();
+ // if (encoding == null)
+ // {
+ // try
+ // {
+ // encoding = ResourcesPlugin.getWorkspace().getRoot().getDefaultCharset();
+ // }
+ // catch (CoreException ex)
+ // {
+ // OM.LOG.error(ex);
+ // }
+ // }
+ //
+ // return encoding;
+ // }
+ // }
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/CDOLobStorage.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/CDOLobStorage.java
new file mode 100644
index 0000000000..d16f11edcd
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/CDOLobStorage.java
@@ -0,0 +1,209 @@
+/*
+ * 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
+ */
+package org.eclipse.emf.cdo.internal.ui;
+
+import org.eclipse.emf.cdo.common.lob.CDOBlob;
+import org.eclipse.emf.cdo.common.lob.CDOClob;
+import org.eclipse.emf.cdo.eresource.CDOBinaryResource;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.eresource.CDOResourceLeaf;
+import org.eclipse.emf.cdo.eresource.CDOTextResource;
+
+import org.eclipse.net4j.util.StringUtil;
+import org.eclipse.net4j.util.WrappedException;
+import org.eclipse.net4j.util.io.IORuntimeException;
+import org.eclipse.net4j.util.io.IOUtil;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.ui.texteditor.AbstractDocumentProvider;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.CharArrayReader;
+import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOLobStorage extends AbstractDocumentProvider
+{
+ private static final String CHARSET_UTF_8 = "UTF-8"; //$NON-NLS-1$
+
+ public CDOLobStorage()
+ {
+ }
+
+ @Override
+ protected IDocument createDocument(Object element) throws CoreException
+ {
+ if (element instanceof CDOLobEditorInput)
+ {
+ CDOResourceLeaf resource = ((CDOLobEditorInput)element).getResource();
+ String contents = getContents(resource);
+
+ IDocument document = new Document();
+ document.set(contents);
+ return document;
+ }
+
+ return null;
+ }
+
+ @Override
+ protected IAnnotationModel createAnnotationModel(Object element) throws CoreException
+ {
+ return null;
+ }
+
+ @Override
+ public boolean isReadOnly(Object element)
+ {
+ if (element instanceof CDOLobEditorInput)
+ {
+ CDOResourceLeaf resource = ((CDOLobEditorInput)element).getResource();
+ return resource.cdoView().isReadOnly();
+ }
+
+ return super.isReadOnly(element);
+ }
+
+ @Override
+ public boolean isModifiable(Object element)
+ {
+ return !isReadOnly(element);
+ }
+
+ @Override
+ protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite)
+ throws CoreException
+ {
+ if (element instanceof CDOLobEditorInput)
+ {
+ CDOResourceLeaf resource = ((CDOLobEditorInput)element).getResource();
+ String contents = document.get();
+
+ try
+ {
+ if (resource instanceof CDOTextResource)
+ {
+ CDOTextResource textResource = (CDOTextResource)resource;
+ CDOClob clob = new CDOClob(new CharArrayReader(contents.toCharArray()));
+ textResource.setContents(clob);
+ }
+ else if (resource instanceof CDOBinaryResource)
+ {
+ byte[] bytes = contents.getBytes(getDefaultEncoding());
+ CDOBlob blob = new CDOBlob(new ByteArrayInputStream(bytes));
+ ((CDOBinaryResource)resource).setContents(blob);
+ }
+ }
+ catch (Exception ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ }
+ }
+
+ @Override
+ protected IRunnableContext getOperationRunner(IProgressMonitor monitor)
+ {
+ return null;
+ }
+
+ private String getContents(CDOResourceLeaf resource)
+ {
+ try
+ {
+ if (resource instanceof CDOTextResource)
+ {
+ CDOTextResource textResource = (CDOTextResource)resource;
+ CDOClob clob = textResource.getContents();
+ if (clob == null)
+ {
+ return StringUtil.EMPTY;
+ }
+
+ Reader reader = null;
+
+ try
+ {
+ reader = clob.getContents();
+
+ CharArrayWriter writer = new CharArrayWriter();
+ IOUtil.copyCharacter(reader, writer);
+ return writer.toString();
+ }
+ finally
+ {
+ IOUtil.close(reader);
+ }
+
+ }
+
+ if (resource instanceof CDOBinaryResource)
+ {
+ CDOBlob blob = ((CDOBinaryResource)resource).getContents();
+ if (blob == null)
+ {
+ return StringUtil.EMPTY;
+ }
+
+ InputStream inputStream = null;
+
+ try
+ {
+ inputStream = blob.getContents();
+
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ IOUtil.copy(inputStream, outputStream);
+ return new String(outputStream.toByteArray(), getDefaultEncoding());
+ }
+ finally
+ {
+ IOUtil.close(inputStream);
+ }
+
+ }
+
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ ((CDOResource)resource).save(outputStream, null);
+ return new String(outputStream.toByteArray(), getDefaultEncoding());
+ }
+ catch (IOException ex)
+ {
+ throw new IORuntimeException(ex);
+ }
+ }
+
+ private String getDefaultEncoding()
+ {
+ String encoding = CHARSET_UTF_8;
+
+ try
+ {
+ encoding = org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getDefaultCharset();
+ }
+ catch (CoreException ex)
+ {
+ // Ignore
+ }
+
+ return encoding;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateBranchAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateBranchAction.java
index 84bd982ebb..675fa4c7bd 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateBranchAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateBranchAction.java
@@ -50,8 +50,7 @@ public class CreateBranchAction extends SessionAction
@Override
protected void preRun() throws Exception
{
- CreateBranchDialog dialog = new CreateBranchDialog(getPage(), getSession(), null, true,
- null)
+ CreateBranchDialog dialog = new CreateBranchDialog(getPage(), getSession(), null, true, null)
{
@Override
protected Control createDialogArea(Composite parent)
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenResourceEditorAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenResourceEditorAction.java
deleted file mode 100644
index 918248ac6d..0000000000
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenResourceEditorAction.java
+++ /dev/null
@@ -1,79 +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
- * Victor Roldan Betancort - maintenance
- */
-package org.eclipse.emf.cdo.internal.ui.actions;
-
-import org.eclipse.emf.cdo.eresource.CDOFileResource;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.eresource.CDOResourceLeaf;
-import org.eclipse.emf.cdo.internal.ui.CDOLobEditorInput;
-import org.eclipse.emf.cdo.internal.ui.bundle.OM;
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.ui.CDOEditorUtil;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * @author Eike Stepper
- */
-public final class OpenResourceEditorAction extends ResourceNodeAction
-{
- private static final String TITLE = Messages.getString("OpenResourceEditorAction.0"); //$NON-NLS-1$
-
- private static final String TOOL_TIP = Messages.getString("OpenResourceEditorAction.1"); //$NON-NLS-1$
-
- private static final String FILE_TITLE = Messages.getString("OpenFileEditorAction.0"); //$NON-NLS-1$
-
- private static final String FILE_TOOL_TIP = Messages.getString("OpenFileEditorAction.1"); //$NON-NLS-1$
-
- public OpenResourceEditorAction(IWorkbenchPage page, CDOResourceLeaf resource)
- {
- super(page, resource instanceof CDOResource ? TITLE : FILE_TITLE, resource instanceof CDOResource ? TOOL_TIP
- : FILE_TOOL_TIP, null, resource);
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- final CDOResourceLeaf resource = (CDOResourceLeaf)getResourceNode();
- final IWorkbenchPage page = getPage();
-
- if (resource instanceof CDOResource)
- {
- CDOView view = resource.cdoView();
- String resourcePath = resource.getPath();
- CDOEditorUtil.openEditor(page, view, resourcePath);
- }
- else if (resource instanceof CDOFileResource)
- {
- Display display = page.getWorkbenchWindow().getShell().getDisplay();
- display.asyncExec(new Runnable()
- {
- public void run()
- {
- try
- {
- IEditorInput input = new CDOLobEditorInput(resource);
- page.openEditor(input, "org.eclipse.ui.DefaultTextEditor");
- }
- catch (Exception ex)
- {
- OM.LOG.error(ex);
- }
- }
- });
- }
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterWorkspacePackagesAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterWorkspacePackagesAction.java
deleted file mode 100644
index b81d2e2fad..0000000000
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterWorkspacePackagesAction.java
+++ /dev/null
@@ -1,75 +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
- * Victor Roldan Betancort - maintenance
- */
-package org.eclipse.emf.cdo.internal.ui.actions;
-
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.internal.ui.dialogs.OpenResourcesDialog;
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.session.CDOSession;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchPage;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class RegisterWorkspacePackagesAction extends RegisterPackagesAction
-{
- private static final String TITLE = Messages.getString("RegisterWorkspacePackagesAction.0"); //$NON-NLS-1$
-
- private static final String TOOL_TIP = Messages.getString("RegisterWorkspacePackagesAction.1"); //$NON-NLS-1$
-
- public RegisterWorkspacePackagesAction(IWorkbenchPage page, CDOSession session)
- {
- super(page, TITLE, TOOL_TIP, null, session);
- }
-
- @Override
- protected List<EPackage> getEPackages(IWorkbenchPage page, CDOSession session)
- {
- Shell shell = page.getWorkbenchWindow().getShell();
- OpenResourcesDialog dialog = new OpenResourcesDialog(shell);
- if (dialog.open() == OpenResourcesDialog.OK)
- {
- Object[] result = dialog.getResult();
- if (result != null && result.length != 0)
- {
- ResourceSet resourceSet = EMFUtil.newEcoreResourceSet();
- List<EPackage> ePackages = new ArrayList<EPackage>(result.length);
- for (Object object : result)
- {
- if (object instanceof IFile)
- {
- IFile file = (IFile)object;
- URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
- Resource resource = resourceSet.getResource(uri, true);
- EPackage ePackage = (EPackage)resource.getContents().get(0);
- ePackages.add(ePackage);
- }
- }
-
- return ePackages;
- }
- }
-
- return null;
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/CreateBranchDialog.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/CreateBranchDialog.java
index 4db38575d8..da2f28c2a5 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/CreateBranchDialog.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/CreateBranchDialog.java
@@ -34,8 +34,8 @@ public class CreateBranchDialog extends SelectBranchPointDialog
private Text nameText;
- public CreateBranchDialog(IWorkbenchPage page, CDOSession session, CDOBranchPoint branchPoint, boolean allowTimeStamp,
- String name)
+ public CreateBranchDialog(IWorkbenchPage page, CDOSession session, CDOBranchPoint branchPoint,
+ boolean allowTimeStamp, String name)
{
super(page, session, branchPoint, allowTimeStamp);
this.name = StringUtil.safe(name);
@@ -85,4 +85,4 @@ public class CreateBranchDialog extends SelectBranchPointDialog
super.createBranchPointArea(parent);
}
-} \ No newline at end of file
+}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenResourcesDialog.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenResourcesDialog.java
deleted file mode 100644
index 52e9a00487..0000000000
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenResourcesDialog.java
+++ /dev/null
@@ -1,29 +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
- * Victor Roldan Betancort - maintenance
- */
-package org.eclipse.emf.cdo.internal.ui.dialogs;
-
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog;
-
-public class OpenResourcesDialog extends FilteredResourcesSelectionDialog
-{
- public OpenResourcesDialog(Shell parentShell)
- {
- super(parentShell, true, ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE);
- setTitle(Messages.getString("OpenResourcesDialog.0")); //$NON-NLS-1$
- setInitialPattern("*.ecore"); //$NON-NLS-1$
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/PackageRegistryDialog.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/PackageRegistryDialog.java
index 117a4a8f43..a8a42d2cbf 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/PackageRegistryDialog.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/PackageRegistryDialog.java
@@ -17,13 +17,14 @@ import org.eclipse.emf.cdo.common.model.CDOPackageUnit.Type;
import org.eclipse.emf.cdo.common.model.EMFUtil;
import org.eclipse.emf.cdo.internal.ui.actions.RegisterFilesystemPackagesAction;
import org.eclipse.emf.cdo.internal.ui.actions.RegisterGeneratedPackagesAction;
-import org.eclipse.emf.cdo.internal.ui.actions.RegisterWorkspacePackagesAction;
import org.eclipse.emf.cdo.internal.ui.messages.Messages;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.ui.shared.SharedIcons;
import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.container.IPluginContainer;
import org.eclipse.net4j.util.ui.UIUtil;
+import org.eclipse.net4j.util.ui.widgets.CustomizeableComposite;
import org.eclipse.emf.ecore.EPackage;
@@ -36,6 +37,8 @@ import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Button;
@@ -59,11 +62,7 @@ import java.util.Set;
*/
public class PackageRegistryDialog extends TitleAreaDialog
{
- private static final int REGISTER_GENERATED_PACKAGES_ID = IDialogConstants.CLIENT_ID + 1;
-
- private static final int REGISTER_WORKSPACE_PACKAGES_ID = IDialogConstants.CLIENT_ID + 2;
-
- private static final int REGISTER_FILESYSTEM_PACKAGES_ID = IDialogConstants.CLIENT_ID + 3;
+ public static final String PRODUCT_GROUP = "org.eclipse.emf.cdo.ui.packageRegistryDialogCustomizers";
private static final String TITLE = Messages.getString("PackageRegistryDialog.0"); //$NON-NLS-1$
@@ -83,11 +82,22 @@ public class PackageRegistryDialog extends TitleAreaDialog
setShellStyle(getShellStyle() | SWT.APPLICATION_MODAL | SWT.MAX | SWT.TITLE | SWT.RESIZE);
}
+ public IWorkbenchPage getPage()
+ {
+ return page;
+ }
+
+ public CDOSession getSession()
+ {
+ return session;
+ }
+
@Override
protected void configureShell(Shell newShell)
{
super.configureShell(newShell);
newShell.setText(TITLE);
+ newShell.setSize(660, 500);
}
@Override
@@ -102,10 +112,10 @@ public class PackageRegistryDialog extends TitleAreaDialog
table.setHeaderVisible(true);
table.setLayoutData(UIUtil.createGridData());
- addColumn(table, Messages.getString("PackageRegistryDialog.1"), 450, SWT.LEFT); //$NON-NLS-1$
- addColumn(table, Messages.getString("PackageRegistryDialog.2"), 80, SWT.CENTER); //$NON-NLS-1$
- addColumn(table, Messages.getString("PackageRegistryDialog.3"), 80, SWT.CENTER); //$NON-NLS-1$
- addColumn(table, Messages.getString("PackageRegistryDialog.4"), 80, SWT.CENTER); //$NON-NLS-1$
+ addColumn(table, Messages.getString("PackageRegistryDialog.1"), 400, SWT.LEFT); //$NON-NLS-1$
+ addColumn(table, Messages.getString("PackageRegistryDialog.2"), 75, SWT.CENTER); //$NON-NLS-1$
+ addColumn(table, Messages.getString("PackageRegistryDialog.3"), 75, SWT.CENTER); //$NON-NLS-1$
+ addColumn(table, Messages.getString("PackageRegistryDialog.4"), 75, SWT.CENTER); //$NON-NLS-1$
viewer.setContentProvider(new EPackageContentProvider());
viewer.setLabelProvider(new EPackageLabelProvider());
@@ -117,67 +127,60 @@ public class PackageRegistryDialog extends TitleAreaDialog
@Override
protected void createButtonsForButtonBar(Composite parent)
{
- Button button = createButton(parent, REGISTER_GENERATED_PACKAGES_ID,
- Messages.getString("PackageRegistryDialog.5"), false); //$NON-NLS-1$
+ Button button = createButton(parent, -1, Messages.getString("PackageRegistryDialog.5"), false); //$NON-NLS-1$
button.setEnabled(isGlobalPackageAvaliable());
-
- createButton(parent, REGISTER_WORKSPACE_PACKAGES_ID, Messages.getString("PackageRegistryDialog.6"), false); //$NON-NLS-1$
- createButton(parent, REGISTER_FILESYSTEM_PACKAGES_ID, Messages.getString("PackageRegistryDialog.7"), false); //$NON-NLS-1$
- createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, false);
- }
-
- private boolean isGlobalPackageAvaliable()
- {
- Set<String> uris = new HashSet<String>(EPackage.Registry.INSTANCE.keySet());
- uris.removeAll(session.getPackageRegistry().keySet());
- return !uris.isEmpty();
- }
-
- @Override
- protected void buttonPressed(int buttonId)
- {
- switch (buttonId)
+ button.addSelectionListener(new SelectionAdapter()
{
- case REGISTER_GENERATED_PACKAGES_ID:
- new RegisterGeneratedPackagesAction(page, session)
+ @Override
+ public void widgetSelected(SelectionEvent e)
{
- @Override
- protected void postRegistration(List<EPackage> ePackages)
+ new RegisterGeneratedPackagesAction(page, session)
{
- refreshViewer();
- }
- }.run();
-
- break;
+ @Override
+ protected void postRegistration(List<EPackage> ePackages)
+ {
+ refreshViewer();
+ }
+ }.run();
+ }
+ });
- case REGISTER_WORKSPACE_PACKAGES_ID:
- new RegisterWorkspacePackagesAction(page, session)
- {
- @Override
- protected void postRegistration(List<EPackage> ePackages)
+ createButton(parent, -1, Messages.getString("PackageRegistryDialog.7"), false) //$NON-NLS-1$
+ .addSelectionListener(new SelectionAdapter()
{
- refreshViewer();
- }
- }.run();
+ @Override
+ public void widgetSelected(SelectionEvent e)
+ {
+ new RegisterFilesystemPackagesAction(page, session)
+ {
+ @Override
+ protected void postRegistration(List<EPackage> ePackages)
+ {
+ refreshViewer();
+ }
+ }.run();
+ }
+ });
- break;
+ CustomizeableComposite.customize(parent, IPluginContainer.INSTANCE, PRODUCT_GROUP, this);
- case REGISTER_FILESYSTEM_PACKAGES_ID:
- new RegisterFilesystemPackagesAction(page, session)
- {
- @Override
- protected void postRegistration(List<EPackage> ePackages)
- {
- refreshViewer();
- }
- }.run();
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CLOSE_LABEL, false);
+ }
- break;
+ /**
+ * Expose this method publicly.
+ */
+ @Override
+ public Button createButton(Composite parent, int id, String label, boolean defaultButton)
+ {
+ return super.createButton(parent, id, label, defaultButton);
+ }
- case IDialogConstants.CLOSE_ID:
- close();
- break;
- }
+ private boolean isGlobalPackageAvaliable()
+ {
+ Set<String> uris = new HashSet<String>(EPackage.Registry.INSTANCE.keySet());
+ uris.removeAll(session.getPackageRegistry().keySet());
+ return !uris.isEmpty();
}
private void addColumn(Table table, String title, int width, int alignment)
@@ -192,7 +195,7 @@ public class PackageRegistryDialog extends TitleAreaDialog
return null;
}
- protected void refreshViewer()
+ public void refreshViewer()
{
page.getWorkbenchWindow().getShell().getDisplay().asyncExec(new Runnable()
{
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOActionBarContributor.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOActionBarContributor.java
index 2791d0a6cd..1adb910aa4 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOActionBarContributor.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOActionBarContributor.java
@@ -60,13 +60,6 @@ import java.util.Collection;
public class CDOActionBarContributor extends EditingDomainActionBarContributor implements ISelectionChangedListener
{
/**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public static final String copyright = "Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.\r\nAll rights reserved. This program and the accompanying materials\r\nare made available under the terms of the Eclipse Public License v1.0\r\nwhich accompanies this distribution, and is available at\r\nhttp://www.eclipse.org/legal/epl-v10.html\r\n\r\nContributors:\r\n Eike Stepper - initial API and implementation"; //$NON-NLS-1$
-
- /**
* @ADDED
*/
public static final String LOAD_RESOURCE_ID = "load-resource"; //$NON-NLS-1$
@@ -102,22 +95,22 @@ public class CDOActionBarContributor extends EditingDomainActionBarContributor i
protected ChangePassiveUpdateAction changePassiveUpdateAction;
/**
- * This keeps track of the active editor. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This keeps track of the active editor.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected IEditorPart activeEditorPart;
/**
- * This keeps track of the current selection provider. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This keeps track of the current selection provider.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected ISelectionProvider selectionProvider;
/**
- * This action opens the Properties view. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This action opens the Properties view.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected IAction showPropertiesViewAction = new Action(
@@ -138,9 +131,9 @@ public class CDOActionBarContributor extends EditingDomainActionBarContributor i
};
/**
- * This action refreshes the viewer of the current editor if the editor implements
- * {@link org.eclipse.emf.common.ui.viewer.IViewerProvider}. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This action refreshes the viewer of the current editor if the editor
+ * implements {@link org.eclipse.emf.common.ui.viewer.IViewerProvider}.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected IAction refreshViewerAction = new Action(PluginDelegator.INSTANCE.getString("_UI_RefreshViewer_menu_item"))
@@ -167,8 +160,8 @@ public class CDOActionBarContributor extends EditingDomainActionBarContributor i
/**
* This will contain one {@link org.eclipse.emf.edit.ui.action.CreateChildAction} corresponding to each descriptor
- * generated for the current selection by the item provider. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * generated for the current selection by the item provider.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected Collection<IAction> createChildActions;
@@ -183,8 +176,8 @@ public class CDOActionBarContributor extends EditingDomainActionBarContributor i
/**
* This will contain one {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} corresponding to each descriptor
- * generated for the current selection by the item provider. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * generated for the current selection by the item provider.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected Collection<IAction> createSiblingActions;
@@ -222,8 +215,8 @@ public class CDOActionBarContributor extends EditingDomainActionBarContributor i
}
/**
- * This adds Separators for editor additions to the tool bar. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This adds Separators for editor additions to the tool bar.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
@@ -234,9 +227,9 @@ public class CDOActionBarContributor extends EditingDomainActionBarContributor i
}
/**
- * This adds to the menu bar a menu and some separators for editor additions, as well as the sub-menus for object
- * creation items. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This adds to the menu bar a menu and some separators for editor additions,
+ * as well as the sub-menus for object creation items.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
@@ -312,10 +305,10 @@ public class CDOActionBarContributor extends EditingDomainActionBarContributor i
}
/**
- * This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener}, handling
- * {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings that can be
- * added to the selected object and updating the menus accordingly. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener},
+ * handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings
+ * that can be added to the selected object and updating the menus accordingly.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public void selectionChangedGen(SelectionChangedEvent event)
@@ -487,10 +480,10 @@ public class CDOActionBarContributor extends EditingDomainActionBarContributor i
/**
* This populates the specified <code>manager</code> with {@link org.eclipse.jface.action.ActionContributionItem}s
- * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection, by
- * inserting them before the specified contribution item <code>contributionID</code>. If <code>contributionID</code>
- * is <code>null</code>, they are simply added. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection,
+ * by inserting them before the specified contribution item <code>contributionID</code>.
+ * If <code>contributionID</code> is <code>null</code>, they are simply added.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected void populateManager(IContributionManager manager, Collection<? extends IAction> actions,
@@ -549,8 +542,8 @@ public class CDOActionBarContributor extends EditingDomainActionBarContributor i
}
/**
- * This populates the pop-up menu before it appears. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This populates the pop-up menu before it appears.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
@@ -569,8 +562,8 @@ public class CDOActionBarContributor extends EditingDomainActionBarContributor i
}
/**
- * This inserts global actions before the "additions-end" separator. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This inserts global actions before the "additions-end" separator.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected void addGlobalActionsGen(IMenuManager menuManager)
@@ -634,9 +627,9 @@ public class CDOActionBarContributor extends EditingDomainActionBarContributor i
}
/**
- * This ensures that a delete action will clean up all references to deleted objects. <!-- begin-user-doc --> <!--
+ * This ensures that a delete action will clean up all references to deleted objects.
+ * <!-- begin-user-doc --> <!--
* end-user-doc -->
- *
* @generated
*/
@Override
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 4ad584e7d9..3801e3fe3b 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
@@ -50,7 +50,7 @@ import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.ui.MarkerHelper;
+import org.eclipse.emf.common.ui.URIEditorInput;
import org.eclipse.emf.common.ui.editor.ProblemEditorPart;
import org.eclipse.emf.common.ui.viewer.IViewerProvider;
import org.eclipse.emf.common.util.BasicDiagnostic;
@@ -62,7 +62,6 @@ import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EValidator;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EContentAdapter;
@@ -85,21 +84,10 @@ import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
import org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider;
-import org.eclipse.emf.edit.ui.util.EditUIMarkerHelper;
import org.eclipse.emf.edit.ui.util.EditUIUtil;
import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage;
import org.eclipse.emf.spi.cdo.InternalCDOObject;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
@@ -158,10 +146,6 @@ import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-import org.eclipse.ui.dialogs.SaveAsDialog;
-import org.eclipse.ui.ide.IGotoMarker;
-import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.part.MultiPageEditorPart;
import org.eclipse.ui.views.contentoutline.ContentOutline;
import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
@@ -177,6 +161,7 @@ import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.text.MessageFormat;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
@@ -194,14 +179,32 @@ import java.util.Set;
* @generated
*/
public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProvider, ISelectionProvider,
- IMenuListener, IViewerProvider, IGotoMarker
+ IMenuListener, IViewerProvider
{
/**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * The filters for file extensions supported by the editor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
* @generated
*/
- public static final String copyright = "Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.\r\nAll rights reserved. This program and the accompanying materials\r\nare made available under the terms of the Eclipse Public License v1.0\r\nwhich accompanies this distribution, and is available at\r\nhttp://www.eclipse.org/legal/epl-v10.html\r\n\r\nContributors:\r\n Eike Stepper - initial API and implementation"; //$NON-NLS-1$
+ public static final List<String> FILE_EXTENSION_FILTERS = prefixExtensions(
+ Arrays.asList(PluginDelegator.INSTANCE.getString("_UI_CDOEditorFilenameExtensions").split("\\s*,\\s*")), "*.");
+
+ /**
+ * Returns a new unmodifiable list containing prefixed versions of the extensions in the given list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static List<String> prefixExtensions(List<String> extensions, String prefix)
+ {
+ List<String> result = new ArrayList<String>();
+ for (String extension : extensions)
+ {
+ result.add(prefix + extension);
+ }
+ return Collections.unmodifiableList(result);
+ }
/**
* @ADDED
@@ -224,9 +227,9 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
protected CDOEventHandler eventHandler;
/**
- * This keeps track of the editing domain that is used to track all changes to the model. <!-- begin-user-doc --> <!--
+ * This keeps track of the editing domain that is used to track all changes to the model.
+ * <!-- begin-user-doc --> <!--
* end-user-doc -->
- *
* @generated
*/
protected AdapterFactoryEditingDomain editingDomain;
@@ -240,82 +243,72 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
protected ComposedAdapterFactory adapterFactory;
/**
- * This is the content outline page. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This is the content outline page.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected IContentOutlinePage contentOutlinePage;
/**
- * This is a kludge... <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This is a kludge...
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected IStatusLineManager contentOutlineStatusLineManager;
/**
- * This is the content outline page's viewer. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This is the content outline page's viewer.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected TreeViewer contentOutlineViewer;
/**
- * This is the property sheet page. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This is the property sheet page.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected PropertySheetPage propertySheetPage;
/**
- * This is the viewer that shadows the selection in the content outline. The parent relation must be correctly defined
- * for this to work. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This is the viewer that shadows the selection in the content outline.
+ * The parent relation must be correctly defined for this to work.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected TreeViewer selectionViewer;
/**
- * This keeps track of the active content viewer, which may be either one of the viewers in the pages or the content
- * outline viewer. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This keeps track of the active content viewer, which may be either one of the viewers in the pages or the content outline viewer.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected Viewer currentViewer;
/**
- * This listens to which ever viewer is active. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This listens to which ever viewer is active.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected ISelectionChangedListener selectionChangedListener;
/**
- * This keeps track of all the {@link org.eclipse.jface.viewers.ISelectionChangedListener}s that are listening to this
- * editor. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This keeps track of all the {@link org.eclipse.jface.viewers.ISelectionChangedListener}s that are listening to this editor.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected Collection<ISelectionChangedListener> selectionChangedListeners = new ArrayList<ISelectionChangedListener>();
/**
- * This keeps track of the selection of the editor as a whole. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This keeps track of the selection of the editor as a whole.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected ISelection editorSelection = StructuredSelection.EMPTY;
/**
- * The MarkerHelper is responsible for creating workspace resource markers presented in Eclipse's Problems View. <!--
- * begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- protected MarkerHelper markerHelper = new EditUIMarkerHelper();
-
- /**
- * This listens for when the outline becomes active <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This listens for when the outline becomes active
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected IPartListener partListener = new IPartListener()
@@ -367,44 +360,44 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
};
/**
- * Resources that have been removed since last activation. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * Resources that have been removed since last activation.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected Collection<Resource> removedResources = new ArrayList<Resource>();
/**
- * Resources that have been changed since last activation. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * Resources that have been changed since last activation.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected Collection<Resource> changedResources = new ArrayList<Resource>();
/**
- * Resources that have been saved. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * Resources that have been saved.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected Collection<Resource> savedResources = new ArrayList<Resource>();
/**
- * Map to store the diagnostic associated with a resource. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * Map to store the diagnostic associated with a resource.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected Map<Resource, Diagnostic> resourceToDiagnosticMap = new LinkedHashMap<Resource, Diagnostic>();
/**
- * Controls whether the problem indication should be updated. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * Controls whether the problem indication should be updated.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected boolean updateProblemIndication = true;
/**
- * Adapter used to update the problem indication when resources are demanded loaded. <!-- begin-user-doc --> <!--
+ * Adapter used to update the problem indication when resources are demanded loaded.
+ * <!-- begin-user-doc --> <!--
* end-user-doc -->
- *
* @generated
*/
protected EContentAdapter problemIndicationAdapter = new EContentAdapter()
@@ -464,103 +457,6 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
};
- /**
- * This listens for workspace changes. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- protected IResourceChangeListener resourceChangeListener = new IResourceChangeListener()
- {
- public void resourceChanged(IResourceChangeEvent event)
- {
- IResourceDelta delta = event.getDelta();
- try
- {
- class ResourceDeltaVisitor implements IResourceDeltaVisitor
- {
- protected ResourceSet resourceSet = editingDomain.getResourceSet();
-
- protected Collection<Resource> changedResources = new ArrayList<Resource>();
-
- protected Collection<Resource> removedResources = new ArrayList<Resource>();
-
- public boolean visit(IResourceDelta delta)
- {
- if (delta.getResource().getType() == IResource.FILE)
- {
- if (delta.getKind() == IResourceDelta.REMOVED || delta.getKind() == IResourceDelta.CHANGED
- && delta.getFlags() != IResourceDelta.MARKERS)
- {
- Resource resource = resourceSet.getResource(
- URI.createPlatformResourceURI(delta.getFullPath().toString(), true), false);
- if (resource != null)
- {
- if (delta.getKind() == IResourceDelta.REMOVED)
- {
- removedResources.add(resource);
- }
- else if (!savedResources.remove(resource))
- {
- changedResources.add(resource);
- }
- }
- }
- }
-
- return true;
- }
-
- public Collection<Resource> getChangedResources()
- {
- return changedResources;
- }
-
- public Collection<Resource> getRemovedResources()
- {
- return removedResources;
- }
- }
-
- final ResourceDeltaVisitor visitor = new ResourceDeltaVisitor();
- delta.accept(visitor);
-
- if (!visitor.getRemovedResources().isEmpty())
- {
- getSite().getShell().getDisplay().asyncExec(new Runnable()
- {
- public void run()
- {
- removedResources.addAll(visitor.getRemovedResources());
- if (!isDirty())
- {
- getSite().getPage().closeEditor(CDOEditor.this, false);
- }
- }
- });
- }
-
- if (!visitor.getChangedResources().isEmpty())
- {
- getSite().getShell().getDisplay().asyncExec(new Runnable()
- {
- public void run()
- {
- changedResources.addAll(visitor.getChangedResources());
- if (getSite().getPage().getActiveEditor() == CDOEditor.this)
- {
- handleActivate();
- }
- }
- });
- }
- }
- catch (CoreException exception)
- {
- PluginDelegator.INSTANCE.log(exception);
- }
- }
- };
-
protected IListener viewTargetListener = new IListener()
{
protected CDOID inputID;
@@ -615,8 +511,8 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
};
/**
- * Handles activation of the editor or it's associated views. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * Handles activation of the editor or it's associated views.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected void handleActivateGen()
@@ -666,8 +562,8 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
/**
- * Handles what to do with changed resources on activation. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * Handles what to do with changed resources on activation.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected void handleChangedResources()
@@ -711,9 +607,9 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
/**
- * Updates the problems indication with the information described in the specified diagnostic. <!-- begin-user-doc -->
+ * Updates the problems indication with the information described in the specified diagnostic.
+ * <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
protected void updateProblemIndication()
@@ -743,7 +639,6 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
{
ProblemEditorPart problemEditorPart = new ProblemEditorPart();
problemEditorPart.setDiagnostic(diagnostic);
- problemEditorPart.setMarkerHelper(markerHelper);
try
{
addPage(++lastEditorPage, problemEditorPart, getEditorInput());
@@ -756,28 +651,12 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
PluginDelegator.INSTANCE.log(exception);
}
}
-
- if (markerHelper.hasMarkers(editingDomain.getResourceSet()))
- {
- markerHelper.deleteMarkers(editingDomain.getResourceSet());
- if (diagnostic.getSeverity() != Diagnostic.OK)
- {
- try
- {
- markerHelper.createMarkers(diagnostic);
- }
- catch (CoreException exception)
- {
- PluginDelegator.INSTANCE.log(exception);
- }
- }
- }
}
}
/**
- * Shows a dialog that asks if conflicting changes should be discarded. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * Shows a dialog that asks if conflicting changes should be discarded.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected boolean handleDirtyConflict()
@@ -787,8 +666,8 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
/**
- * This creates a model editor. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This creates a model editor.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public CDOEditor()
@@ -798,8 +677,8 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
/**
- * This sets up the editing domain for the model editor. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This sets up the editing domain for the model editor.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected void initializeEditingDomainGen()
@@ -860,8 +739,8 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
/**
- * This is here for the listener to be able to call it. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This is here for the listener to be able to call it.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
@@ -871,8 +750,8 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
/**
- * This sets the selection into whichever viewer is active. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This sets the selection into whichever viewer is active.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public void setSelectionToViewer(Collection<?> collection)
@@ -899,10 +778,10 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
/**
- * This returns the editing domain as required by the {@link IEditingDomainProvider} interface. This is important for
- * implementing the static methods of {@link AdapterFactoryEditingDomain} and for supporting
- * {@link org.eclipse.emf.edit.ui.action.CommandAction}. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This returns the editing domain as required by the {@link IEditingDomainProvider} interface.
+ * This is important for implementing the static methods of {@link AdapterFactoryEditingDomain}
+ * and for supporting {@link org.eclipse.emf.edit.ui.action.CommandAction}.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public EditingDomain getEditingDomain()
@@ -912,14 +791,12 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
- *
* @generated
*/
public class ReverseAdapterFactoryContentProvider extends AdapterFactoryContentProvider
{
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
- *
* @generated
*/
public ReverseAdapterFactoryContentProvider(AdapterFactory adapterFactory)
@@ -929,7 +806,6 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
- *
* @generated
*/
@Override
@@ -941,7 +817,6 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
- *
* @generated
*/
@Override
@@ -953,7 +828,6 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
- *
* @generated
*/
@Override
@@ -965,7 +839,6 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
- *
* @generated
*/
@Override
@@ -976,9 +849,9 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
/**
- * This makes sure that one content viewer, either for the current page or the outline view, if it has focus, is the
- * current one. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This makes sure that one content viewer, either for the current page or the outline view, if it has focus,
+ * is the current one.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public void setCurrentViewer(Viewer viewer)
@@ -1027,9 +900,9 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
/**
- * This returns the viewer as required by the {@link IViewerProvider} interface. <!-- begin-user-doc --> <!--
+ * This returns the viewer as required by the {@link IViewerProvider} interface.
+ * <!-- begin-user-doc --> <!--
* end-user-doc -->
- *
* @generated
*/
public Viewer getViewer()
@@ -1070,7 +943,6 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
/**
* This is the method called to load a resource into the editing domain's resource set based on the editor's input.
* <!-- begin-user-doc --> <!-- end-user-doc -->
- *
* @generated
*/
public void createModelGen()
@@ -1176,9 +1048,9 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
/**
- * Returns a diagnostic describing the errors and warnings listed in the resource and the specified exception (if
- * any). <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * Returns a diagnostic describing the errors and warnings listed in the resource
+ * and the specified exception (if any).
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public Diagnostic analyzeResourceProblems(Resource resource, Exception exception)
@@ -1617,8 +1489,8 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
/**
- * This is used to track the active viewer. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This is used to track the active viewer.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
@@ -1633,8 +1505,8 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
/**
- * This is how the framework determines which interfaces we implement. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This is how the framework determines which interfaces we implement.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("rawtypes")
@@ -1649,10 +1521,6 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
{
return getPropertySheetPage();
}
- else if (key.equals(IGotoMarker.class))
- {
- return this;
- }
else
{
return super.getAdapter(key);
@@ -1733,7 +1601,8 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
/**
- * This accesses a cached version of the property sheet. <!-- begin-user-doc --> <!-- end-user-doc -->
+ * This accesses a cached version of the property sheet.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public IPropertySheetPage getPropertySheetPageGen()
@@ -1758,6 +1627,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
};
propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory));
}
+
return propertySheetPage;
}
@@ -1803,9 +1673,9 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
/**
- * This deals with how we want selection in the outliner to affect the other views. <!-- begin-user-doc --> <!--
+ * This deals with how we want selection in the outliner to affect the other views.
+ * <!-- begin-user-doc --> <!--
* end-user-doc -->
- *
* @generated
*/
public void handleContentOutlineSelection(ISelection selection)
@@ -1846,9 +1716,9 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
/**
- * This is for implementing {@link IEditorPart} and simply saves the model file. <!-- begin-user-doc --> <!--
+ * This is for implementing {@link IEditorPart} and simply saves the model file.
+ * <!-- begin-user-doc --> <!--
* end-user-doc -->
- *
* @generated
*/
public void doSaveGen(IProgressMonitor progressMonitor)
@@ -1860,12 +1730,11 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
// Do the work within an operation because this is a long running activity that modifies the workbench.
//
- WorkspaceModifyOperation operation = new WorkspaceModifyOperation()
+ IRunnableWithProgress operation = new IRunnableWithProgress()
{
// This is the method that gets invoked when the operation runs.
//
- @Override
- public void execute(IProgressMonitor monitor)
+ public void run(IProgressMonitor monitor)
{
// Save the resources to the file system.
//
@@ -2025,10 +1894,10 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
/**
- * This returns whether something has been persisted to the URI of the specified resource. The implementation uses the
- * URI converter from the editor's resource set to try to open an input stream. <!-- begin-user-doc --> <!--
+ * This returns whether something has been persisted to the URI of the specified resource.
+ * The implementation uses the URI converter from the editor's resource set to try to open an input stream.
+ * <!-- begin-user-doc --> <!--
* end-user-doc -->
- *
* @generated
*/
protected boolean isPersisted(Resource resource)
@@ -2051,8 +1920,8 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
/**
- * This always returns true because it is not currently supported. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This always returns true because it is not currently supported.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public boolean isSaveAsAllowedGen()
@@ -2070,23 +1939,19 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
/**
- * This also changes the editor's input. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This also changes the editor's input.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public void doSaveAs()
{
- SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell());
- saveAsDialog.open();
- IPath path = saveAsDialog.getResult();
- if (path != null)
+ String[] filters = FILE_EXTENSION_FILTERS.toArray(new String[FILE_EXTENSION_FILTERS.size()]);
+ String[] files = EditorEditorAdvisor.openFilePathDialog(getSite().getShell(), SWT.SAVE, filters);
+ if (files.length > 0)
{
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
- if (file != null)
- {
- doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(), true), new FileEditorInput(file));
- }
+ URI uri = URI.createFileURI(files[0]);
+ doSaveAs(uri, new URIEditorInput(uri));
}
}
@@ -2098,47 +1963,11 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
protected void doSaveAs(URI uri, IEditorInput editorInput)
{
throw new UnsupportedOperationException();
-
- // CDONet4jUtil.getResources(editingDomain.getResourceSet()).get(0).setURI(uri);
- // setInputWithNotify(editorInput);
- // setPartName(editorInput.getName());
- // IProgressMonitor progressMonitor = getActionBars().getStatusLineManager() != null ? getActionBars()
- // .getStatusLineManager().getProgressMonitor() : new NullProgressMonitor();
- // doSave(progressMonitor);
}
/**
+ * This is called during startup.
* <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public void gotoMarker(IMarker marker)
- {
- try
- {
- if (marker.getType().equals(EValidator.MARKER))
- {
- String uriAttribute = marker.getAttribute(EValidator.URI_ATTRIBUTE, null);
- if (uriAttribute != null)
- {
- URI uri = URI.createURI(uriAttribute);
- EObject eObject = editingDomain.getResourceSet().getEObject(uri, true);
- if (eObject != null)
- {
- setSelectionToViewer(Collections.singleton(editingDomain.getWrapper(eObject)));
- }
- }
- }
- }
- catch (CoreException exception)
- {
- PluginDelegator.INSTANCE.log(exception);
- }
- }
-
- /**
- * This is called during startup. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
* @generated
*/
public void initGen(IEditorSite site, IEditorInput editorInput)
@@ -2148,7 +1977,6 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
setPartName(editorInput.getName());
site.setSelectionProvider(this);
site.getPage().addPartListener(partListener);
- ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_CHANGE);
}
/**
@@ -2166,7 +1994,6 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
- *
* @generated
*/
@Override
@@ -2176,8 +2003,8 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
/**
- * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public void addSelectionChangedListener(ISelectionChangedListener listener)
@@ -2186,8 +2013,8 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
/**
- * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public void removeSelectionChangedListener(ISelectionChangedListener listener)
@@ -2198,7 +2025,6 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
/**
* This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to return this editor's overall selection.
* <!-- begin-user-doc --> <!-- end-user-doc -->
- *
* @generated
*/
public ISelection getSelection()
@@ -2208,8 +2034,8 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
/**
* This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection.
- * Calling this result will notify the listeners. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * Calling this result will notify the listeners.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public void setSelection(ISelection selection)
@@ -2225,7 +2051,6 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
- *
* @generated
*/
public void setStatusLineManager(ISelection selection)
@@ -2266,29 +2091,28 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
/**
- * This looks up a string in the plugin's plugin.properties file. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This looks up a string in the plugin's plugin.properties file.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
- protected static String getString(String key)
+ private static String getString(String key)
{
return PluginDelegator.INSTANCE.getString(key);
}
/**
- * This looks up a string in plugin.properties, making a substitution. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This looks up a string in plugin.properties, making a substitution.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
- protected static String getString(String key, Object s1)
+ private static String getString(String key, Object s1)
{
return PluginDelegator.INSTANCE.getString(key, new Object[] { s1 });
}
/**
- * This implements {@link org.eclipse.jface.action.IMenuListener} to help fill the context menus with contributions
- * from the Edit menu. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * This implements {@link org.eclipse.jface.action.IMenuListener} to help fill the context menus with contributions from the Edit menu.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public void menuAboutToShowGen(IMenuManager menuManager)
@@ -2522,7 +2346,6 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
- *
* @generated
*/
public EditingDomainActionBarContributor getActionBarContributor()
@@ -2532,7 +2355,6 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
- *
* @generated
*/
public IActionBars getActionBars()
@@ -2542,7 +2364,6 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
- *
* @generated
*/
public AdapterFactory getAdapterFactory()
@@ -2552,15 +2373,12 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
- *
* @generated
*/
public void disposeGen()
{
updateProblemIndication = false;
- ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeListener);
-
getSite().getPage().removePartListener(partListener);
adapterFactory.dispose();
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/EditorEditorAdvisor.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/EditorEditorAdvisor.java
new file mode 100644
index 0000000000..fd545fe518
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/EditorEditorAdvisor.java
@@ -0,0 +1,606 @@
+/**
+ */
+package org.eclipse.emf.cdo.internal.ui.editor;
+
+import org.eclipse.emf.common.ui.URIEditorInput;
+import org.eclipse.emf.common.ui.action.WorkbenchWindowActionDelegate;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.edit.ui.action.LoadResourceAction;
+import org.eclipse.emf.edit.ui.util.EditUIUtil;
+
+import org.eclipse.equinox.app.IApplication;
+import org.eclipse.equinox.app.IApplicationContext;
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorDescriptor;
+import org.eclipse.ui.IFolderLayout;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.ContributionItemFactory;
+import org.eclipse.ui.application.ActionBarAdvisor;
+import org.eclipse.ui.application.IActionBarConfigurer;
+import org.eclipse.ui.application.IWorkbenchConfigurer;
+import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
+import org.eclipse.ui.application.WorkbenchAdvisor;
+import org.eclipse.ui.application.WorkbenchWindowAdvisor;
+
+import java.io.File;
+import java.util.Arrays;
+
+/**
+ * Customized {@link WorkbenchAdvisor} for the RCP application.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public final class EditorEditorAdvisor extends WorkbenchAdvisor
+{
+ /**
+ * The default file extension filters for use in dialogs.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static final String[] FILE_EXTENSION_FILTERS = CDOEditor.FILE_EXTENSION_FILTERS.toArray(new String[0]);
+
+ /**
+ * This looks up a string in the plugin's plugin.properties file.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static String getString(String key)
+ {
+ return PluginDelegator.INSTANCE.getString(key);
+ }
+
+ /**
+ * This looks up a string in plugin.properties, making a substitution.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static String getString(String key, Object s1)
+ {
+ return org.eclipse.emf.cdo.internal.ui.editor.PluginDelegator.INSTANCE.getString(key, new Object[] { s1 });
+ }
+
+ /**
+ * RCP's application
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static class Application implements IApplication
+ {
+ /**
+ * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Object start(IApplicationContext context) throws Exception
+ {
+ WorkbenchAdvisor workbenchAdvisor = new EditorEditorAdvisor();
+ Display display = PlatformUI.createDisplay();
+ try
+ {
+ int returnCode = PlatformUI.createAndRunWorkbench(display, workbenchAdvisor);
+ if (returnCode == PlatformUI.RETURN_RESTART)
+ {
+ return IApplication.EXIT_RESTART;
+ }
+ return IApplication.EXIT_OK;
+ }
+ finally
+ {
+ display.dispose();
+ }
+ }
+
+ /**
+ * @see org.eclipse.equinox.app.IApplication#stop()
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void stop()
+ {
+ // Do nothing.
+ }
+ }
+
+ /**
+ * RCP's perspective
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static class Perspective implements IPerspectiveFactory
+ {
+ /**
+ * Perspective ID
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String ID_PERSPECTIVE = "org.eclipse.emf.cdo.internal.ui.editor.EditorEditorAdvisorPerspective";
+
+ /**
+ * @see org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui.IPageLayout)
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void createInitialLayout(IPageLayout layout)
+ {
+ layout.setEditorAreaVisible(true);
+ layout.addPerspectiveShortcut(ID_PERSPECTIVE);
+
+ IFolderLayout right = layout.createFolder("right", IPageLayout.RIGHT, (float)0.66, layout.getEditorArea());
+ right.addView(IPageLayout.ID_OUTLINE);
+
+ IFolderLayout bottonRight = layout.createFolder("bottonRight", IPageLayout.BOTTOM, (float)0.60, "right");
+ bottonRight.addView(IPageLayout.ID_PROP_SHEET);
+ }
+ }
+
+ /**
+ * RCP's window advisor
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static class WindowAdvisor extends WorkbenchWindowAdvisor
+ {
+ /**
+ * @see WorkbenchWindowAdvisor#WorkbenchWindowAdvisor(org.eclipse.ui.application.IWorkbenchWindowConfigurer)
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public WindowAdvisor(IWorkbenchWindowConfigurer configurer)
+ {
+ super(configurer);
+ }
+
+ /**
+ * @see org.eclipse.ui.application.WorkbenchWindowAdvisor#preWindowOpen()
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void preWindowOpen()
+ {
+ IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
+ configurer.setInitialSize(new Point(600, 450));
+ configurer.setShowCoolBar(false);
+ configurer.setShowStatusLine(true);
+ configurer.setTitle(getString("_UI_Application_title"));
+ }
+
+ /**
+ * @see org.eclipse.ui.application.WorkbenchWindowAdvisor#createActionBarAdvisor(org.eclipse.ui.application.IActionBarConfigurer)
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer)
+ {
+ return new WindowActionBarAdvisor(configurer);
+ }
+ }
+
+ /**
+ * RCP's action bar advisor
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static class WindowActionBarAdvisor extends ActionBarAdvisor
+ {
+ /**
+ * @see ActionBarAdvisor#ActionBarAdvisor(org.eclipse.ui.application.IActionBarConfigurer)
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public WindowActionBarAdvisor(IActionBarConfigurer configurer)
+ {
+ super(configurer);
+ }
+
+ /**
+ * @see org.eclipse.ui.application.ActionBarAdvisor#fillMenuBar(org.eclipse.jface.action.IMenuManager)
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected void fillMenuBar(IMenuManager menuBar)
+ {
+ IWorkbenchWindow window = getActionBarConfigurer().getWindowConfigurer().getWindow();
+ menuBar.add(createFileMenu(window));
+ menuBar.add(createEditMenu(window));
+ menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
+ menuBar.add(createWindowMenu(window));
+ menuBar.add(createHelpMenu(window));
+ }
+
+ /**
+ * Creates the 'File' menu.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IMenuManager createFileMenu(IWorkbenchWindow window)
+ {
+ IMenuManager menu = new MenuManager(getString("_UI_Menu_File_label"), IWorkbenchActionConstants.M_FILE);
+ menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_START));
+
+ IMenuManager newMenu = new MenuManager(getString("_UI_Menu_New_label"), "new");
+ newMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
+
+ menu.add(newMenu);
+ menu.add(new Separator());
+ menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
+ menu.add(new Separator());
+ addToMenuAndRegister(menu, ActionFactory.CLOSE.create(window));
+ addToMenuAndRegister(menu, ActionFactory.CLOSE_ALL.create(window));
+ menu.add(new Separator());
+ addToMenuAndRegister(menu, ActionFactory.SAVE.create(window));
+ addToMenuAndRegister(menu, ActionFactory.SAVE_AS.create(window));
+ addToMenuAndRegister(menu, ActionFactory.SAVE_ALL.create(window));
+ menu.add(new Separator());
+ addToMenuAndRegister(menu, ActionFactory.QUIT.create(window));
+ menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_END));
+ return menu;
+ }
+
+ /**
+ * Creates the 'Edit' menu.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IMenuManager createEditMenu(IWorkbenchWindow window)
+ {
+ IMenuManager menu = new MenuManager(getString("_UI_Menu_Edit_label"), IWorkbenchActionConstants.M_EDIT);
+ menu.add(new GroupMarker(IWorkbenchActionConstants.EDIT_START));
+
+ addToMenuAndRegister(menu, ActionFactory.UNDO.create(window));
+ addToMenuAndRegister(menu, ActionFactory.REDO.create(window));
+ menu.add(new GroupMarker(IWorkbenchActionConstants.UNDO_EXT));
+ menu.add(new Separator());
+
+ addToMenuAndRegister(menu, ActionFactory.CUT.create(window));
+ addToMenuAndRegister(menu, ActionFactory.COPY.create(window));
+ addToMenuAndRegister(menu, ActionFactory.PASTE.create(window));
+ menu.add(new GroupMarker(IWorkbenchActionConstants.CUT_EXT));
+ menu.add(new Separator());
+
+ addToMenuAndRegister(menu, ActionFactory.DELETE.create(window));
+ addToMenuAndRegister(menu, ActionFactory.SELECT_ALL.create(window));
+ menu.add(new Separator());
+
+ menu.add(new GroupMarker(IWorkbenchActionConstants.ADD_EXT));
+
+ menu.add(new GroupMarker(IWorkbenchActionConstants.EDIT_END));
+ menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ return menu;
+ }
+
+ /**
+ * Creates the 'Window' menu.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IMenuManager createWindowMenu(IWorkbenchWindow window)
+ {
+ IMenuManager menu = new MenuManager(getString("_UI_Menu_Window_label"), IWorkbenchActionConstants.M_WINDOW);
+
+ addToMenuAndRegister(menu, ActionFactory.OPEN_NEW_WINDOW.create(window));
+ menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
+ menu.add(ContributionItemFactory.OPEN_WINDOWS.create(window));
+
+ return menu;
+ }
+
+ /**
+ * Creates the 'Help' menu.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IMenuManager createHelpMenu(IWorkbenchWindow window)
+ {
+ IMenuManager menu = new MenuManager(getString("_UI_Menu_Help_label"), IWorkbenchActionConstants.M_HELP);
+ // Welcome or intro page would go here
+ // Help contents would go here
+ // Tips and tricks page would go here
+ menu.add(new GroupMarker(IWorkbenchActionConstants.HELP_START));
+ menu.add(new GroupMarker(IWorkbenchActionConstants.HELP_END));
+ menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
+ return menu;
+ }
+
+ /**
+ * Adds the specified action to the given menu and also registers the action with the
+ * action bar configurer, in order to activate its key binding.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void addToMenuAndRegister(IMenuManager menuManager, IAction action)
+ {
+ menuManager.add(action);
+ getActionBarConfigurer().registerGlobalAction(action);
+ }
+ }
+
+ /**
+ * About action for the RCP application.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static class AboutAction extends WorkbenchWindowActionDelegate
+ {
+ /**
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void run(IAction action)
+ {
+ MessageDialog.openInformation(getWindow().getShell(), getString("_UI_About_title"), getString("_UI_About_text"));
+ }
+ }
+
+ /**
+ * Open action for the objects from the Editor model.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static class OpenAction extends WorkbenchWindowActionDelegate
+ {
+ /**
+ * Opens the editors for the files selected using the file dialog.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void run(IAction action)
+ {
+ String[] filePaths = openFilePathDialog(getWindow().getShell(), SWT.OPEN, null);
+ if (filePaths.length > 0)
+ {
+ openEditor(getWindow().getWorkbench(), URI.createFileURI(filePaths[0]));
+ }
+ }
+ }
+
+ /**
+ * Open URI action for the objects from the Editor model.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static class OpenURIAction extends WorkbenchWindowActionDelegate
+ {
+ /**
+ * Opens the editors for the files selected using the LoadResourceDialog.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void run(IAction action)
+ {
+ LoadResourceAction.LoadResourceDialog loadResourceDialog = new LoadResourceAction.LoadResourceDialog(getWindow()
+ .getShell());
+ if (Window.OK == loadResourceDialog.open())
+ {
+ for (URI uri : loadResourceDialog.getURIs())
+ {
+ openEditor(getWindow().getWorkbench(), uri);
+ }
+ }
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static String[] openFilePathDialog(Shell shell, int style, String[] fileExtensionFilters)
+ {
+ return openFilePathDialog(shell, style, fileExtensionFilters, (style & SWT.OPEN) != 0, (style & SWT.OPEN) != 0,
+ (style & SWT.SAVE) != 0);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static String[] openFilePathDialog(Shell shell, int style, String[] fileExtensionFilters,
+ boolean includeGroupFilter, boolean includeAllFilter, boolean addExtension)
+ {
+ FileDialog fileDialog = new FileDialog(shell, style);
+ if (fileExtensionFilters == null)
+ {
+ fileExtensionFilters = FILE_EXTENSION_FILTERS;
+ }
+
+ // If requested, augment the file extension filters by adding a group of all the other filters (*.ext1;*.ext2;...)
+ // at the beginning and/or an all files wildcard (*.*) at the end.
+ //
+ includeGroupFilter &= fileExtensionFilters.length > 1;
+ int offset = includeGroupFilter ? 1 : 0;
+
+ if (includeGroupFilter || includeAllFilter)
+ {
+ int size = fileExtensionFilters.length + offset + (includeAllFilter ? 1 : 0);
+ String[] allFilters = new String[size];
+ StringBuilder group = includeGroupFilter ? new StringBuilder() : null;
+
+ for (int i = 0; i < fileExtensionFilters.length; i++)
+ {
+ if (includeGroupFilter)
+ {
+ if (i != 0)
+ {
+ group.append(';');
+ }
+ group.append(fileExtensionFilters[i]);
+ }
+ allFilters[i + offset] = fileExtensionFilters[i];
+ }
+
+ if (includeGroupFilter)
+ {
+ allFilters[0] = group.toString();
+ }
+ if (includeAllFilter)
+ {
+ allFilters[allFilters.length - 1] = "*.*";
+ }
+
+ fileDialog.setFilterExtensions(allFilters);
+ }
+ else
+ {
+ fileDialog.setFilterExtensions(fileExtensionFilters);
+ }
+ fileDialog.open();
+
+ String[] filenames = fileDialog.getFileNames();
+ String[] result = new String[filenames.length];
+ String path = fileDialog.getFilterPath() + File.separator;
+ String extension = null;
+
+ // If extension adding requested, get the dotted extension corresponding to the selected filter.
+ //
+ if (addExtension)
+ {
+ int i = fileDialog.getFilterIndex();
+ if (i != -1 && (!includeAllFilter || i != fileExtensionFilters.length))
+ {
+ i = includeGroupFilter && i == 0 ? 0 : i - offset;
+ String filter = fileExtensionFilters[i];
+ int dot = filter.lastIndexOf('.');
+ if (dot == 1 && filter.charAt(0) == '*')
+ {
+ extension = filter.substring(dot);
+ }
+ }
+ }
+
+ // Build the result by adding the selected path and, if needed, auto-appending the extension.
+ //
+ for (int i = 0; i < filenames.length; i++)
+ {
+ String filename = path + filenames[i];
+ if (extension != null)
+ {
+ int dot = filename.lastIndexOf('.');
+ if (dot == -1 || !Arrays.asList(fileExtensionFilters).contains("*" + filename.substring(dot)))
+ {
+ filename += extension;
+ }
+ }
+ result[i] = filename;
+ }
+ return result;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static boolean openEditor(IWorkbench workbench, URI uri)
+ {
+ IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
+ IWorkbenchPage page = workbenchWindow.getActivePage();
+
+ IEditorDescriptor editorDescriptor = EditUIUtil.getDefaultEditor(uri, null);
+ if (editorDescriptor == null)
+ {
+ MessageDialog.openError(workbenchWindow.getShell(), getString("_UI_Error_title"),
+ getString("_WARN_No_Editor", uri.lastSegment()));
+ return false;
+ }
+ try
+ {
+ page.openEditor(new URIEditorInput(uri), editorDescriptor.getId());
+ }
+ catch (PartInitException exception)
+ {
+ MessageDialog.openError(workbenchWindow.getShell(), getString("_UI_OpenEditorError_label"),
+ exception.getMessage());
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * @see org.eclipse.ui.application.WorkbenchAdvisor#getInitialWindowPerspectiveId()
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public String getInitialWindowPerspectiveId()
+ {
+ return Perspective.ID_PERSPECTIVE;
+ }
+
+ /**
+ * @see org.eclipse.ui.application.WorkbenchAdvisor#initialize(org.eclipse.ui.application.IWorkbenchConfigurer)
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void initialize(IWorkbenchConfigurer configurer)
+ {
+ super.initialize(configurer);
+ configurer.setSaveAndRestore(true);
+ }
+
+ /**
+ * @see org.eclipse.ui.application.WorkbenchAdvisor#createWorkbenchWindowAdvisor(org.eclipse.ui.application.IWorkbenchWindowConfigurer)
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer)
+ {
+ return new WindowAdvisor(configurer);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/PluginDelegator.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/PluginDelegator.java
index ee46be8be0..0706d6f38d 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/PluginDelegator.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/PluginDelegator.java
@@ -23,29 +23,22 @@ import org.eclipse.emf.common.util.ResourceLocator;
public final class PluginDelegator extends EMFPlugin
{
/**
+ * Keep track of the singleton.
* <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public static final String copyright = "Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.\r\nAll rights reserved. This program and the accompanying materials\r\nare made available under the terms of the Eclipse Public License v1.0\r\nwhich accompanies this distribution, and is available at\r\nhttp://www.eclipse.org/legal/epl-v10.html\r\n\r\nContributors:\r\n Eike Stepper - initial API and implementation"; //$NON-NLS-1$
-
- /**
- * Keep track of the singleton. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
* @generated
*/
public static final PluginDelegator INSTANCE = new PluginDelegator();
/**
- * Keep track of the singleton. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * Keep track of the singleton.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
private static Implementation plugin;
/**
- * Create the instance. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * Create the instance.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public PluginDelegator()
@@ -70,8 +63,8 @@ public final class PluginDelegator extends EMFPlugin
}
/**
- * Returns the singleton instance of the Eclipse plugin. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * Returns the singleton instance of the Eclipse plugin.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @return the singleton instance.
* @generated
*/
@@ -82,8 +75,8 @@ public final class PluginDelegator extends EMFPlugin
}
/**
- * Returns the singleton instance of the Eclipse plugin. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * Returns the singleton instance of the Eclipse plugin.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @return the singleton instance.
* @generated
*/
@@ -93,15 +86,15 @@ public final class PluginDelegator extends EMFPlugin
}
/**
- * The actual implementation of the Eclipse <b>Plugin</b>. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * The actual implementation of the Eclipse <b>Plugin</b>.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public static class Implementation extends EclipseUIPlugin
{
/**
- * Creates an instance. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * Creates an instance.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public Implementation()
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties
index 3c51aa1314..08c9facee8 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties
@@ -150,11 +150,6 @@ OpenDurableViewAction.0=Open Durable View
OpenDurableViewAction.1=Open an existing durable view
OpenDurableViewDialog.0=Open Durable View
OpenDurableViewDialog.1=Area ID:
-OpenFileEditorAction.0=Open File Editor
-OpenFileEditorAction.1=Open a file editor for this resource
-OpenResourceEditorAction.0=Open Editor
-OpenResourceEditorAction.1=Open a model editor for this resource
-OpenResourcesDialog.0=Open Resources
OpenSessionAction.0=Open a new session
OpenSessionAction.3=Unable to open a session on the specified repository.\n\n
OpenSessionDialog.0=Open Session
@@ -170,7 +165,6 @@ PackageRegistryDialog.2=State
PackageRegistryDialog.3=Type
PackageRegistryDialog.4=Original
PackageRegistryDialog.5=Generated...
-PackageRegistryDialog.6=Workspace...
PackageRegistryDialog.7=Filesystem...
PackageRegistryDialog.8=?
ReadLockObjectsAction.1=Read Lock
@@ -189,8 +183,6 @@ RegisterPackagesAction.0=Failed to register package {0}
RegisterPackagesAction.1=\ {0} package has not been registered due to errors.\nSee the log for details.
RegisterPackagesAction.2=\ {0} packages have not been registered due to errors.\nSee the log for details.
RegisterSinglePackageAction.0=Register the package
-RegisterWorkspacePackagesAction.0=Register Workspace Packages
-RegisterWorkspacePackagesAction.1=Register dynamic packages from the workspace
ReloadObjectsAction.1=Reload
ReloadViewAction.0=Reload
ReloadViewAction.1=Reload this view

Back to the top