Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorseberle2009-01-21 16:34:10 -0500
committerseberle2009-01-21 16:34:10 -0500
commitd99846616e8eaac30af7b4b64e91ef2ca47f2cf9 (patch)
treed6c53ba11e1d060f3f1e21bbcdfc8b80f539b82e
parenta25f4960679cc1fb4becd720fdc6e1ad690b29bb (diff)
downloadorg.eclipse.emf.teneo-d99846616e8eaac30af7b4b64e91ef2ca47f2cf9.tar.gz
org.eclipse.emf.teneo-d99846616e8eaac30af7b4b64e91ef2ca47f2cf9.tar.xz
org.eclipse.emf.teneo-d99846616e8eaac30af7b4b64e91ef2ca47f2cf9.zip
Removed implicit DatabaseEObjectImpl root class from GenModel, added explicitly modeled Identifiable base class with uuid:long version:long fields to all model elements
-rw-r--r--examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/META-INF/MANIFEST.MF2
-rw-r--r--examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/plugin.properties9
-rw-r--r--examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/plugin.xml77
-rw-r--r--examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/src/org/eclipse/emf/teneo/eclipselink/examples/library/editor/LibraryEditor.java133
-rw-r--r--examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/src/org/eclipse/emf/teneo/eclipselink/examples/library/editor/LibraryModelWizard.java43
-rw-r--r--examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/src/org/eclipse/emf/teneo/eclipselink/examples/library/forum/editor/ForumEditor.java134
-rw-r--r--examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/src/org/eclipse/emf/teneo/eclipselink/examples/library/forum/editor/ForumModelWizard.java106
7 files changed, 256 insertions, 248 deletions
diff --git a/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/META-INF/MANIFEST.MF b/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/META-INF/MANIFEST.MF
index cdff6cea1..9654844fc 100644
--- a/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/META-INF/MANIFEST.MF
+++ b/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.emf.teneo.eclipselink.examples.library.editor; singleton:=true
+Bundle-SymbolicName: org.eclipse.emf.teneo.eclipselink.examples.library.editor;singleton:=true
Bundle-Version: 1.0.0
Bundle-ClassPath: .
Bundle-Activator: org.eclipse.emf.teneo.eclipselink.examples.library.editor.Activator$Implementation
diff --git a/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/plugin.properties b/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/plugin.properties
index a9fe90caa..2b3fc138a 100644
--- a/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/plugin.properties
+++ b/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/plugin.properties
@@ -2,7 +2,7 @@
# <copyright>
# </copyright>
#
-# $Id: plugin.properties,v 1.1 2008/04/15 21:14:36 seberle Exp $
+# $Id: plugin.properties,v 1.2 2009/01/21 21:34:10 seberle Exp $
# ====================================================================
# To code developer:
@@ -52,11 +52,12 @@ _UI_LibraryModelWizard_description = Create a new Library model
_UI_LibraryEditor_label = Library Model Editor
_UI_LibraryEditorFilenameDefaultBase = My
-_UI_LibraryEditorFilenameExtension = library
+_UI_LibraryEditorFilenameExtensions = library
_UI_Wizard_label = New
-_WARN_FilenameExtension = The file name must end in ".{0}"
+_WARN_FilenameExtension = The file name must end in ''.{0}''
+_WARN_FilenameExtensions = The file name must have one of the following extensions: {0}
_UI_ModelObject = &Model Object
_UI_XMLEncoding = &XML Encoding
@@ -71,5 +72,5 @@ _UI_ForumEditor_menu = &Forum Editor
_UI_ForumModelWizard_description = Create a new Forum model
_UI_ForumEditor_label = Forum Model Editor
_UI_ForumEditorFilenameDefaultBase = My
-_UI_ForumEditorFilenameExtension = forum
+_UI_ForumEditorFilenameExtensions = forum
\ No newline at end of file
diff --git a/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/plugin.xml b/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/plugin.xml
index 638b40d02..d2df07c75 100644
--- a/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/plugin.xml
+++ b/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/plugin.xml
@@ -1,58 +1,47 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<?eclipse version="3.0"?>
-
<!--
<copyright>
</copyright>
- $Id: plugin.xml,v 1.1 2008/04/15 21:14:36 seberle Exp $
+ $Id: plugin.xml,v 1.2 2009/01/21 21:34:10 seberle Exp $
-->
-
<plugin>
-
-
- <extension
- point = "org.eclipse.ui.newWizards">
- <category
- id = "org.eclipse.emf.ecore.Wizard.category.ID"
- name="%_UI_Wizard_category">
- </category>
- <wizard
- id = "org.eclipse.emf.teneo.eclipselink.examples.library.editor.LibraryModelWizardID"
- name = "%_UI_LibraryModelWizard_label"
- class = "org.eclipse.emf.teneo.eclipselink.examples.library.editor.LibraryModelWizard"
- category = "org.eclipse.emf.ecore.Wizard.category.ID"
- icon = "icons/full/obj16/LibraryModelFile.gif">
- <description>%_UI_LibraryModelWizard_description</description>
- <selection class = "org.eclipse.core.resources.IResource" />
+ <extension point="org.eclipse.ui.newWizards">
+ <category id="org.eclipse.emf.ecore.Wizard.category.ID"
+ name="%_UI_Wizard_category" />
+ <wizard id="org.eclipse.emf.teneo.eclipselink.examples.library.editor.LibraryModelWizardID"
+ name="%_UI_LibraryModelWizard_label"
+ class="org.eclipse.emf.teneo.eclipselink.examples.library.editor.LibraryModelWizard"
+ category="org.eclipse.emf.ecore.Wizard.category.ID"
+ icon="icons/full/obj16/LibraryModelFile.gif">
+ <description>
+ %_UI_LibraryModelWizard_description</description>
+ <selection class="org.eclipse.core.resources.IResource" />
</wizard>
- <wizard
- id = "org.eclipse.emf.teneo.eclipselink.examples.library.forum.editor.ForumModelWizardID"
- name = "%_UI_ForumModelWizard_label"
- class = "org.eclipse.emf.teneo.eclipselink.examples.library.forum.editor.ForumModelWizard"
- category = "org.eclipse.emf.ecore.Wizard.category.ID"
- icon = "icons/full/obj16/ForumModelFile.gif">
+ <wizard id="org.eclipse.emf.teneo.eclipselink.examples.library.forum.editor.ForumModelWizardID"
+ name="%_UI_ForumModelWizard_label"
+ class="org.eclipse.emf.teneo.eclipselink.examples.library.forum.editor.ForumModelWizard"
+ category="org.eclipse.emf.ecore.Wizard.category.ID"
+ icon="icons/full/obj16/ForumModelFile.gif">
<description>%_UI_ForumModelWizard_description</description>
- <selection class = "org.eclipse.core.resources.IResource" />
+ <selection class="org.eclipse.core.resources.IResource" />
</wizard>
</extension>
-
- <extension point = "org.eclipse.ui.editors">
- <editor
- id = "org.eclipse.emf.teneo.eclipselink.examples.library.editor.LibraryEditorID"
- name = "%_UI_LibraryEditor_label"
- icon = "icons/full/obj16/LibraryModelFile.gif"
- extensions = "library, database"
- class = "org.eclipse.emf.teneo.eclipselink.examples.library.editor.LibraryEditor"
- contributorClass="org.eclipse.emf.teneo.eclipselink.examples.library.editor.LibraryActionBarContributor" >
+ <extension point="org.eclipse.ui.editors">
+ <editor id="org.eclipse.emf.teneo.eclipselink.examples.library.editor.LibraryEditorID"
+ name="%_UI_LibraryEditor_label"
+ icon="icons/full/obj16/LibraryModelFile.gif"
+ extensions="library, database"
+ class="org.eclipse.emf.teneo.eclipselink.examples.library.editor.LibraryEditor"
+ contributorClass="org.eclipse.emf.teneo.eclipselink.examples.library.editor.LibraryActionBarContributor">
</editor>
- <editor
- id = "org.eclipse.emf.teneo.eclipselink.examples.library.forum.editor.ForumEditorID"
- name = "%_UI_ForumEditor_label"
- icon = "icons/full/obj16/ForumModelFile.gif"
- extensions = "forum"
- class = "org.eclipse.emf.teneo.eclipselink.examples.library.forum.editor.ForumEditor"
- contributorClass="org.eclipse.emf.teneo.eclipselink.examples.library.forum.editor.ForumActionBarContributor" >
+ <editor id="org.eclipse.emf.teneo.eclipselink.examples.library.forum.editor.ForumEditorID"
+ name="%_UI_ForumEditor_label"
+ icon="icons/full/obj16/ForumModelFile.gif"
+ extensions="forum"
+ class="org.eclipse.emf.teneo.eclipselink.examples.library.forum.editor.ForumEditor"
+ contributorClass="org.eclipse.emf.teneo.eclipselink.examples.library.forum.editor.ForumActionBarContributor">
</editor>
- </extension>
+ </extension>
</plugin>
diff --git a/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/src/org/eclipse/emf/teneo/eclipselink/examples/library/editor/LibraryEditor.java b/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/src/org/eclipse/emf/teneo/eclipselink/examples/library/editor/LibraryEditor.java
index 46dca35d3..74154df6f 100644
--- a/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/src/org/eclipse/emf/teneo/eclipselink/examples/library/editor/LibraryEditor.java
+++ b/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/src/org/eclipse/emf/teneo/eclipselink/examples/library/editor/LibraryEditor.java
@@ -430,76 +430,71 @@ public class LibraryEditor
protected IResourceChangeListener resourceChangeListener =
new IResourceChangeListener() {
public void resourceChanged(IResourceChangeEvent event) {
- // Only listening to these.
- // if (event.getType() == IResourceDelta.POST_CHANGE)
- {
- 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.getFlags() != IResourceDelta.MARKERS &&
- delta.getResource().getType() == IResource.FILE) {
- if ((delta.getKind() & (IResourceDelta.CHANGED | IResourceDelta.REMOVED)) != 0) {
- Resource resource = resourceSet.getResource(URI.createURI(delta.getFullPath().toString()), false);
- if (resource != null) {
- if ((delta.getKind() & IResourceDelta.REMOVED) != 0) {
- removedResources.add(resource);
- }
- else if (!savedResources.remove(resource)) {
- changedResources.add(resource);
- }
+ 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.createURI(delta.getFullPath().toString()), 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;
- }
+ return true;
}
- ResourceDeltaVisitor visitor = new ResourceDeltaVisitor();
- delta.accept(visitor);
+ public Collection<Resource> getChangedResources() {
+ return changedResources;
+ }
- if (!visitor.getRemovedResources().isEmpty()) {
- removedResources.addAll(visitor.getRemovedResources());
- if (!isDirty()) {
- getSite().getShell().getDisplay().asyncExec
- (new Runnable() {
- public void run() {
- getSite().getPage().closeEditor(LibraryEditor.this, false);
- LibraryEditor.this.dispose();
- }
- });
- }
+ public Collection<Resource> getRemovedResources() {
+ return removedResources;
}
+ }
- if (!visitor.getChangedResources().isEmpty()) {
- changedResources.addAll(visitor.getChangedResources());
- if (getSite().getPage().getActiveEditor() == LibraryEditor.this) {
- getSite().getShell().getDisplay().asyncExec
- (new Runnable() {
- public void run() {
- handleActivate();
- }
- });
- }
+ ResourceDeltaVisitor visitor = new ResourceDeltaVisitor();
+ delta.accept(visitor);
+
+ if (!visitor.getRemovedResources().isEmpty()) {
+ removedResources.addAll(visitor.getRemovedResources());
+ if (!isDirty()) {
+ getSite().getShell().getDisplay().asyncExec
+ (new Runnable() {
+ public void run() {
+ getSite().getPage().closeEditor(LibraryEditor.this, false);
+ }
+ });
}
}
- catch (CoreException exception) {
- Activator.INSTANCE.log(exception);
+
+ if (!visitor.getChangedResources().isEmpty()) {
+ changedResources.addAll(visitor.getChangedResources());
+ if (getSite().getPage().getActiveEditor() == LibraryEditor.this) {
+ getSite().getShell().getDisplay().asyncExec
+ (new Runnable() {
+ public void run() {
+ handleActivate();
+ }
+ });
+ }
}
}
+ catch (CoreException exception) {
+ Activator.INSTANCE.log(exception);
+ }
}
};
@@ -523,7 +518,6 @@ public class LibraryEditor
if (!removedResources.isEmpty()) {
if (handleDirtyConflict()) {
getSite().getPage().closeEditor(LibraryEditor.this, false);
- LibraryEditor.this.dispose();
}
else {
removedResources.clear();
@@ -547,6 +541,9 @@ public class LibraryEditor
*/
protected void handleChangedResources() {
if (!changedResources.isEmpty() && (!isDirty() || handleDirtyConflict())) {
+ if (isDirty()) {
+ changedResources.addAll(editingDomain.getResourceSet().getResources());
+ }
editingDomain.getCommandStack().flush();
updateProblemIndication = false;
@@ -563,6 +560,11 @@ public class LibraryEditor
}
}
}
+
+ if (AdapterFactoryEditingDomain.isStale(editorSelection)) {
+ setSelection(StructuredSelection.EMPTY);
+ }
+
updateProblemIndication = true;
updateProblemIndication();
}
@@ -913,7 +915,7 @@ public class LibraryEditor
* 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
+ * @generated NOT
*/
public void createModel() {
URI resourceURI = EditUIUtil.getURI(getEditorInput());
@@ -984,8 +986,7 @@ public class LibraryEditor
// Only creates the other pages if there is something that can be edited
//
- if (!getEditingDomain().getResourceSet().getResources().isEmpty() &&
- !(getEditingDomain().getResourceSet().getResources().get(0)).getContents().isEmpty()) {
+ if (!getEditingDomain().getResourceSet().getResources().isEmpty()) {
// Create a page for the selection tree view.
//
{
@@ -1462,8 +1463,11 @@ public class LibraryEditor
for (Resource resource : editingDomain.getResourceSet().getResources()) {
if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource)) {
try {
- savedResources.add(resource);
+ long timeStamp = resource.getTimeStamp();
resource.save(saveOptions);
+ if (resource.getTimeStamp() != timeStamp) {
+ savedResources.add(resource);
+ }
}
catch (Exception exception) {
resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
@@ -1761,7 +1765,7 @@ public class LibraryEditor
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @generated
+ * @generated NOT
*/
@Override
public void dispose() {
@@ -1801,6 +1805,11 @@ public class LibraryEditor
return true;
}
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated NOT
+ */
protected Map<String, Object> getLoadOptions() {
Map<String, Object> result = new HashMap<String, Object>();
diff --git a/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/src/org/eclipse/emf/teneo/eclipselink/examples/library/editor/LibraryModelWizard.java b/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/src/org/eclipse/emf/teneo/eclipselink/examples/library/editor/LibraryModelWizard.java
index ca5e6e708..cf1432351 100644
--- a/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/src/org/eclipse/emf/teneo/eclipselink/examples/library/editor/LibraryModelWizard.java
+++ b/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/src/org/eclipse/emf/teneo/eclipselink/examples/library/editor/LibraryModelWizard.java
@@ -12,6 +12,7 @@ package org.eclipse.emf.teneo.eclipselink.examples.library.editor;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -75,6 +76,24 @@ import org.eclipse.ui.part.ISetSelectionTarget;
*/
public class LibraryModelWizard extends Wizard implements INewWizard {
/**
+ * The supported extensions for created files.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final List<String> FILE_EXTENSIONS =
+ Collections.unmodifiableList(Arrays.asList(org.eclipse.emf.teneo.eclipselink.examples.library.editor.Activator.INSTANCE.getString("_UI_LibraryEditorFilenameExtensions").split("\\s*,\\s*")));
+
+ /**
+ * A formatted list of supported file extensions, suitable for display.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String FORMATTED_FILE_EXTENSIONS =
+ org.eclipse.emf.teneo.eclipselink.examples.library.editor.Activator.INSTANCE.getString("_UI_LibraryEditorFilenameExtensions").replaceAll("\\s*,\\s*", ", ");
+
+ /**
* This caches an instance of the model package.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -291,24 +310,18 @@ public class LibraryModelWizard extends Wizard implements INewWizard {
* <!-- end-user-doc -->
* @generated
*/
- @Override
+ @Override
protected boolean validatePage() {
if (super.validatePage()) {
- // Make sure the file ends in ".library".
- //
- String requiredExt = org.eclipse.emf.teneo.eclipselink.examples.library.editor.Activator.INSTANCE.getString("_UI_LibraryEditorFilenameExtension");
- String enteredExt = new Path(getFileName()).getFileExtension();
- if (enteredExt == null || !enteredExt.equals(requiredExt)) {
- setErrorMessage(org.eclipse.emf.teneo.eclipselink.examples.library.editor.Activator.INSTANCE.getString("_WARN_FilenameExtension", new Object [] { requiredExt }));
+ String extension = new Path(getFileName()).getFileExtension();
+ if (extension == null || !FILE_EXTENSIONS.contains(extension)) {
+ String key = FILE_EXTENSIONS.size() > 1 ? "_WARN_FilenameExtensions" : "_WARN_FilenameExtension";
+ setErrorMessage(org.eclipse.emf.teneo.eclipselink.examples.library.editor.Activator.INSTANCE.getString(key, new Object [] { FORMATTED_FILE_EXTENSIONS }));
return false;
}
- else {
- return true;
- }
- }
- else {
- return false;
+ return true;
}
+ return false;
}
/**
@@ -543,7 +556,7 @@ public class LibraryModelWizard extends Wizard implements INewWizard {
newFileCreationPage = new LibraryModelWizardNewFileCreationPage("Whatever", selection);
newFileCreationPage.setTitle(org.eclipse.emf.teneo.eclipselink.examples.library.editor.Activator.INSTANCE.getString("_UI_LibraryModelWizard_label"));
newFileCreationPage.setDescription(org.eclipse.emf.teneo.eclipselink.examples.library.editor.Activator.INSTANCE.getString("_UI_LibraryModelWizard_description"));
- newFileCreationPage.setFileName(org.eclipse.emf.teneo.eclipselink.examples.library.editor.Activator.INSTANCE.getString("_UI_LibraryEditorFilenameDefaultBase") + "." + org.eclipse.emf.teneo.eclipselink.examples.library.editor.Activator.INSTANCE.getString("_UI_LibraryEditorFilenameExtension"));
+ newFileCreationPage.setFileName(org.eclipse.emf.teneo.eclipselink.examples.library.editor.Activator.INSTANCE.getString("_UI_LibraryEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0));
addPage(newFileCreationPage);
// Try and get the resource selection to determine a current directory for the file dialog.
@@ -570,7 +583,7 @@ public class LibraryModelWizard extends Wizard implements INewWizard {
// Make up a unique new name here.
//
String defaultModelBaseFilename = org.eclipse.emf.teneo.eclipselink.examples.library.editor.Activator.INSTANCE.getString("_UI_LibraryEditorFilenameDefaultBase");
- String defaultModelFilenameExtension = org.eclipse.emf.teneo.eclipselink.examples.library.editor.Activator.INSTANCE.getString("_UI_LibraryEditorFilenameExtension");
+ String defaultModelFilenameExtension = FILE_EXTENSIONS.get(0);
String modelFilename = defaultModelBaseFilename + "." + defaultModelFilenameExtension;
for (int i = 1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i) {
modelFilename = defaultModelBaseFilename + i + "." + defaultModelFilenameExtension;
diff --git a/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/src/org/eclipse/emf/teneo/eclipselink/examples/library/forum/editor/ForumEditor.java b/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/src/org/eclipse/emf/teneo/eclipselink/examples/library/forum/editor/ForumEditor.java
index 56da99f2a..7c63efc03 100644
--- a/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/src/org/eclipse/emf/teneo/eclipselink/examples/library/forum/editor/ForumEditor.java
+++ b/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/src/org/eclipse/emf/teneo/eclipselink/examples/library/forum/editor/ForumEditor.java
@@ -430,76 +430,71 @@ public class ForumEditor
protected IResourceChangeListener resourceChangeListener =
new IResourceChangeListener() {
public void resourceChanged(IResourceChangeEvent event) {
- // Only listening to these.
- // if (event.getType() == IResourceDelta.POST_CHANGE)
- {
- 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.getFlags() != IResourceDelta.MARKERS &&
- delta.getResource().getType() == IResource.FILE) {
- if ((delta.getKind() & (IResourceDelta.CHANGED | IResourceDelta.REMOVED)) != 0) {
- Resource resource = resourceSet.getResource(URI.createURI(delta.getFullPath().toString()), false);
- if (resource != null) {
- if ((delta.getKind() & IResourceDelta.REMOVED) != 0) {
- removedResources.add(resource);
- }
- else if (!savedResources.remove(resource)) {
- changedResources.add(resource);
- }
+ 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.createURI(delta.getFullPath().toString()), 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;
- }
+ return true;
}
- ResourceDeltaVisitor visitor = new ResourceDeltaVisitor();
- delta.accept(visitor);
+ public Collection<Resource> getChangedResources() {
+ return changedResources;
+ }
- if (!visitor.getRemovedResources().isEmpty()) {
- removedResources.addAll(visitor.getRemovedResources());
- if (!isDirty()) {
- getSite().getShell().getDisplay().asyncExec
- (new Runnable() {
- public void run() {
- getSite().getPage().closeEditor(ForumEditor.this, false);
- ForumEditor.this.dispose();
- }
- });
- }
+ public Collection<Resource> getRemovedResources() {
+ return removedResources;
}
+ }
- if (!visitor.getChangedResources().isEmpty()) {
- changedResources.addAll(visitor.getChangedResources());
- if (getSite().getPage().getActiveEditor() == ForumEditor.this) {
- getSite().getShell().getDisplay().asyncExec
- (new Runnable() {
- public void run() {
- handleActivate();
- }
- });
- }
+ ResourceDeltaVisitor visitor = new ResourceDeltaVisitor();
+ delta.accept(visitor);
+
+ if (!visitor.getRemovedResources().isEmpty()) {
+ removedResources.addAll(visitor.getRemovedResources());
+ if (!isDirty()) {
+ getSite().getShell().getDisplay().asyncExec
+ (new Runnable() {
+ public void run() {
+ getSite().getPage().closeEditor(ForumEditor.this, false);
+ }
+ });
}
}
- catch (CoreException exception) {
- Activator.INSTANCE.log(exception);
+
+ if (!visitor.getChangedResources().isEmpty()) {
+ changedResources.addAll(visitor.getChangedResources());
+ if (getSite().getPage().getActiveEditor() == ForumEditor.this) {
+ getSite().getShell().getDisplay().asyncExec
+ (new Runnable() {
+ public void run() {
+ handleActivate();
+ }
+ });
+ }
}
}
+ catch (CoreException exception) {
+ Activator.INSTANCE.log(exception);
+ }
}
};
@@ -523,7 +518,6 @@ public class ForumEditor
if (!removedResources.isEmpty()) {
if (handleDirtyConflict()) {
getSite().getPage().closeEditor(ForumEditor.this, false);
- ForumEditor.this.dispose();
}
else {
removedResources.clear();
@@ -547,6 +541,9 @@ public class ForumEditor
*/
protected void handleChangedResources() {
if (!changedResources.isEmpty() && (!isDirty() || handleDirtyConflict())) {
+ if (isDirty()) {
+ changedResources.addAll(editingDomain.getResourceSet().getResources());
+ }
editingDomain.getCommandStack().flush();
updateProblemIndication = false;
@@ -563,6 +560,11 @@ public class ForumEditor
}
}
}
+
+ if (AdapterFactoryEditingDomain.isStale(editorSelection)) {
+ setSelection(StructuredSelection.EMPTY);
+ }
+
updateProblemIndication = true;
updateProblemIndication();
}
@@ -907,7 +909,7 @@ public class ForumEditor
* 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
+ * @generated NOT
*/
public void createModel() {
URI resourceURI = EditUIUtil.getURI(getEditorInput());
@@ -978,8 +980,7 @@ public class ForumEditor
// Only creates the other pages if there is something that can be edited
//
- if (!getEditingDomain().getResourceSet().getResources().isEmpty() &&
- !(getEditingDomain().getResourceSet().getResources().get(0)).getContents().isEmpty()) {
+ if (!getEditingDomain().getResourceSet().getResources().isEmpty()) {
// Create a page for the selection tree view.
//
{
@@ -1456,8 +1457,11 @@ public class ForumEditor
for (Resource resource : editingDomain.getResourceSet().getResources()) {
if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource)) {
try {
- savedResources.add(resource);
+ long timeStamp = resource.getTimeStamp();
resource.save(saveOptions);
+ if (resource.getTimeStamp() != timeStamp) {
+ savedResources.add(resource);
+ }
}
catch (Exception exception) {
resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
@@ -1750,7 +1754,7 @@ public class ForumEditor
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @generated
+ * @generated NOT
*/
@Override
public void dispose() {
@@ -1791,8 +1795,12 @@ public class ForumEditor
return true;
}
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated NOT
+ */
protected Map<String, String> getLoadOptions() {
-
Map<String, String> result = new HashMap<String, String>();
IPreferenceStore store = org.eclipse.emf.teneo.eclipselink.common.ui.Activator.getDefault().getPreferenceStore();
String useLoginFrom = store.getString(IDatabasePreferenceConstants.USE_LOGIN_FROM);
diff --git a/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/src/org/eclipse/emf/teneo/eclipselink/examples/library/forum/editor/ForumModelWizard.java b/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/src/org/eclipse/emf/teneo/eclipselink/examples/library/forum/editor/ForumModelWizard.java
index d91e32960..90742d9bf 100644
--- a/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/src/org/eclipse/emf/teneo/eclipselink/examples/library/forum/editor/ForumModelWizard.java
+++ b/examples/org.eclipse.emf.teneo.eclipselink.examples.library.editor/src/org/eclipse/emf/teneo/eclipselink/examples/library/forum/editor/ForumModelWizard.java
@@ -12,6 +12,7 @@ package org.eclipse.emf.teneo.eclipselink.examples.library.forum.editor;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -20,76 +21,51 @@ import java.util.Map;
import java.util.MissingResourceException;
import java.util.StringTokenizer;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.emf.common.CommonPlugin;
-
import org.eclipse.emf.common.util.URI;
-
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
-
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
-
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-
-import org.eclipse.emf.ecore.EObject;
-
import org.eclipse.emf.ecore.xmi.XMLResource;
-
import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
+import org.eclipse.emf.teneo.eclipselink.examples.library.edit.Activator;
+import org.eclipse.emf.teneo.eclipselink.examples.library.forum.ForumFactory;
+import org.eclipse.emf.teneo.eclipselink.examples.library.forum.ForumPackage;
import org.eclipse.jface.dialogs.MessageDialog;
-
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
-
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardPage;
-
import org.eclipse.swt.SWT;
-
-import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.ModifyEvent;
-
+import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
-
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
-
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
-
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-
-import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
-
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.part.ISetSelectionTarget;
-
-import org.eclipse.emf.teneo.eclipselink.examples.library.forum.ForumFactory;
-import org.eclipse.emf.teneo.eclipselink.examples.library.forum.ForumPackage;
-import org.eclipse.emf.teneo.eclipselink.examples.library.edit.Activator;
-
-
-import org.eclipse.core.runtime.Path;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.part.ISetSelectionTarget;
/**
@@ -100,6 +76,24 @@ import org.eclipse.ui.PartInitException;
*/
public class ForumModelWizard extends Wizard implements INewWizard {
/**
+ * The supported extensions for created files.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final List<String> FILE_EXTENSIONS =
+ Collections.unmodifiableList(Arrays.asList(org.eclipse.emf.teneo.eclipselink.examples.library.editor.Activator.INSTANCE.getString("_UI_ForumEditorFilenameExtensions").split("\\s*,\\s*")));
+
+ /**
+ * A formatted list of supported file extensions, suitable for display.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String FORMATTED_FILE_EXTENSIONS =
+ org.eclipse.emf.teneo.eclipselink.examples.library.editor.Activator.INSTANCE.getString("_UI_ForumEditorFilenameExtensions").replaceAll("\\s*,\\s*", ", ");
+
+ /**
* This caches an instance of the model package.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -316,24 +310,18 @@ public class ForumModelWizard extends Wizard implements INewWizard {
* <!-- end-user-doc -->
* @generated
*/
- @Override
+ @Override
protected boolean validatePage() {
if (super.validatePage()) {
- // Make sure the file ends in ".forum".
- //
- String requiredExt = org.eclipse.emf.teneo.eclipselink.examples.library.editor.Activator.INSTANCE.getString("_UI_ForumEditorFilenameExtension");
- String enteredExt = new Path(getFileName()).getFileExtension();
- if (enteredExt == null || !enteredExt.equals(requiredExt)) {
- setErrorMessage(org.eclipse.emf.teneo.eclipselink.examples.library.editor.Activator.INSTANCE.getString("_WARN_FilenameExtension", new Object [] { requiredExt }));
+ String extension = new Path(getFileName()).getFileExtension();
+ if (extension == null || !FILE_EXTENSIONS.contains(extension)) {
+ String key = FILE_EXTENSIONS.size() > 1 ? "_WARN_FilenameExtensions" : "_WARN_FilenameExtension";
+ setErrorMessage(org.eclipse.emf.teneo.eclipselink.examples.library.editor.Activator.INSTANCE.getString(key, new Object [] { FORMATTED_FILE_EXTENSIONS }));
return false;
}
- else {
- return true;
- }
- }
- else {
- return false;
+ return true;
}
+ return false;
}
/**
@@ -568,7 +556,7 @@ public class ForumModelWizard extends Wizard implements INewWizard {
newFileCreationPage = new ForumModelWizardNewFileCreationPage("Whatever", selection);
newFileCreationPage.setTitle(org.eclipse.emf.teneo.eclipselink.examples.library.editor.Activator.INSTANCE.getString("_UI_ForumModelWizard_label"));
newFileCreationPage.setDescription(org.eclipse.emf.teneo.eclipselink.examples.library.editor.Activator.INSTANCE.getString("_UI_ForumModelWizard_description"));
- newFileCreationPage.setFileName(org.eclipse.emf.teneo.eclipselink.examples.library.editor.Activator.INSTANCE.getString("_UI_ForumEditorFilenameDefaultBase") + "." + org.eclipse.emf.teneo.eclipselink.examples.library.editor.Activator.INSTANCE.getString("_UI_ForumEditorFilenameExtension"));
+ newFileCreationPage.setFileName(org.eclipse.emf.teneo.eclipselink.examples.library.editor.Activator.INSTANCE.getString("_UI_ForumEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0));
addPage(newFileCreationPage);
// Try and get the resource selection to determine a current directory for the file dialog.
@@ -595,7 +583,7 @@ public class ForumModelWizard extends Wizard implements INewWizard {
// Make up a unique new name here.
//
String defaultModelBaseFilename = org.eclipse.emf.teneo.eclipselink.examples.library.editor.Activator.INSTANCE.getString("_UI_ForumEditorFilenameDefaultBase");
- String defaultModelFilenameExtension = org.eclipse.emf.teneo.eclipselink.examples.library.editor.Activator.INSTANCE.getString("_UI_ForumEditorFilenameExtension");
+ String defaultModelFilenameExtension = FILE_EXTENSIONS.get(0);
String modelFilename = defaultModelBaseFilename + "." + defaultModelFilenameExtension;
for (int i = 1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i) {
modelFilename = defaultModelBaseFilename + i + "." + defaultModelFilenameExtension;

Back to the top