### Eclipse Workspace Patch 1.0 #P org.eclipse.emf Index: plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/templates/editor/PluginProperties.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.emf/plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/templates/editor/PluginProperties.java,v retrieving revision 1.17 diff -u -r1.17 PluginProperties.java --- plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/templates/editor/PluginProperties.java 28 Dec 2006 06:40:38 -0000 1.17 +++ plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/templates/editor/PluginProperties.java 13 Feb 2007 09:45:46 -0000 @@ -38,24 +38,27 @@ protected final String TEXT_21 = " Model Editor" + NL + "" + NL + "_UI_"; protected final String TEXT_22 = "FilenameDefaultBase = My" + NL + "_UI_"; protected final String TEXT_23 = "FilenameExtension = "; - protected final String TEXT_24 = NL; - protected final String TEXT_25 = NL + "_UI_Wizard_label = New" + NL + "" + NL + "_WARN_FilenameExtension = The file name must end in \".{0}\"" + NL + "" + NL + "_UI_ModelObject = Model Object" + NL + "_UI_XMLEncoding = XML Encoding" + NL + "_UI_XMLEncodingChoices = "; - protected final String TEXT_26 = NL + "_UI_Wizard_initial_object_description = Specify a file name and select a model object to create"; - protected final String TEXT_27 = NL + "_UI_Wizard_initial_object_description = Select a model object to create"; - protected final String TEXT_28 = NL + NL + "_UI_FileConflict_label = File Conflict" + NL + "_WARN_FileConflict = There are unsaved changes that conflict with changes made outside the editor. Do you wish to discard this editor's changes?" + NL; - protected final String TEXT_29 = NL + "_UI_"; - protected final String TEXT_30 = "_ActionSet_label = "; - protected final String TEXT_31 = " Action Set" + NL + "_UI_Perspective_label = "; - protected final String TEXT_32 = NL + NL + "_UI_Browse_label = &Browse..." + NL + "_UI_File_label = &File" + NL + "_UI_Question_title = Question" + NL + "_WARN_FileConflict = The file \"{0}\" already exists. Do you want to replace the existing file?" + NL + "_UI_Error_title = Error" + NL + "_WARN_No_Editor = There is no editor registered for the file \"{0}\"." + NL + "" + NL + "_UI_Application_title = "; - protected final String TEXT_33 = " Application" + NL + "_UI_Menu_File_label = &File" + NL + "_UI_Menu_New_label = &New" + NL + "_UI_Menu_Open_label = &Open..." + NL + "_UI_Menu_Open_description = Opens a model object file" + NL + "_UI_Menu_OpenURI_label = &Open URI..." + NL + "_UI_Menu_OpenURI_description = Opens a model object loading it from a URI" + NL + "_UI_Menu_Edit_label = &Edit" + NL + "_UI_Menu_Window_label = &Window" + NL + "_UI_Menu_Help_label = &Help" + NL + "_UI_Menu_About_label = "; - protected final String TEXT_34 = " &About..." + NL + "_UI_About_title = "; - protected final String TEXT_35 = " Application" + NL + "_UI_About_text = "; - protected final String TEXT_36 = " Application about box goes here." + NL; - protected final String TEXT_37 = NL + "_UI_"; - protected final String TEXT_38 = "_ActionSet_label = "; - protected final String TEXT_39 = " Model Action Set"; - protected final String TEXT_40 = NL; - protected final String TEXT_41 = NL; + protected final String TEXT_24 = NL + NL + "_UI_"; + protected final String TEXT_25 = "_label = "; + protected final String TEXT_26 = " Editor Preferences" + NL + "_UI_EditorPreference_description_ = "; + protected final String TEXT_27 = " Editor XML saving preferences." + NL + "_UI_EditorPreferenceTypeInformation_label = Save type information" + NL + "_UI_EditorPreferenceSaveDoctype_label = Save doctype declaration" + NL + "_UI_EditorPreferenceFormatted_label = Output formatted XML" + NL + "_UI_EditorPreferenceLineWidth_label = XML file line width" + NL; + protected final String TEXT_28 = NL + "_UI_Wizard_label = New" + NL + "" + NL + "_WARN_FilenameExtension = The file name must end in \".{0}\"" + NL + "" + NL + "_UI_ModelObject = Model Object" + NL + "_UI_XMLEncoding = XML Encoding" + NL + "_UI_XMLEncodingChoices = "; + protected final String TEXT_29 = NL + "_UI_Wizard_initial_object_description = Specify a file name and select a model object to create"; + protected final String TEXT_30 = NL + "_UI_Wizard_initial_object_description = Select a model object to create"; + protected final String TEXT_31 = NL + NL + "_UI_FileConflict_label = File Conflict" + NL + "_WARN_FileConflict = There are unsaved changes that conflict with changes made outside the editor. Do you wish to discard this editor's changes?" + NL; + protected final String TEXT_32 = NL + "_UI_"; + protected final String TEXT_33 = "_ActionSet_label = "; + protected final String TEXT_34 = " Action Set" + NL + "_UI_Perspective_label = "; + protected final String TEXT_35 = NL + NL + "_UI_Browse_label = &Browse..." + NL + "_UI_File_label = &File" + NL + "_UI_Question_title = Question" + NL + "_WARN_FileConflict = The file \"{0}\" already exists. Do you want to replace the existing file?" + NL + "_UI_Error_title = Error" + NL + "_WARN_No_Editor = There is no editor registered for the file \"{0}\"." + NL + "" + NL + "_UI_Application_title = "; + protected final String TEXT_36 = " Application" + NL + "_UI_Menu_File_label = &File" + NL + "_UI_Menu_New_label = &New" + NL + "_UI_Menu_Open_label = &Open..." + NL + "_UI_Menu_Open_description = Opens a model object file" + NL + "_UI_Menu_OpenURI_label = &Open URI..." + NL + "_UI_Menu_OpenURI_description = Opens a model object loading it from a URI" + NL + "_UI_Menu_Edit_label = &Edit" + NL + "_UI_Menu_Window_label = &Window" + NL + "_UI_Menu_Help_label = &Help" + NL + "_UI_Menu_About_label = "; + protected final String TEXT_37 = " &About..." + NL + "_UI_About_title = "; + protected final String TEXT_38 = " Application" + NL + "_UI_About_text = "; + protected final String TEXT_39 = " Application about box goes here." + NL; + protected final String TEXT_40 = NL + "_UI_"; + protected final String TEXT_41 = "_ActionSet_label = "; + protected final String TEXT_42 = " Model Action Set"; + protected final String TEXT_43 = NL; + protected final String TEXT_44 = NL; public String generate(Object argument) { @@ -125,24 +128,24 @@ stringBuffer.append(TEXT_23); stringBuffer.append(genPackage.getPrefix().toLowerCase()); stringBuffer.append(TEXT_24); - } + stringBuffer.append(genPackage.getEditorPreferencePageClassName()); stringBuffer.append(TEXT_25); - stringBuffer.append(genModel.getXMLEncodingChoices()); - if (genModel.isRichClientPlatform()) { + stringBuffer.append(genPackage.getPrefix()); stringBuffer.append(TEXT_26); - } else { + stringBuffer.append(genPackage.getPrefix()); stringBuffer.append(TEXT_27); } stringBuffer.append(TEXT_28); + stringBuffer.append(genModel.getXMLEncodingChoices()); if (genModel.isRichClientPlatform()) { stringBuffer.append(TEXT_29); - stringBuffer.append(genModel.getEditorAdvisorClassName()); + } else { stringBuffer.append(TEXT_30); - stringBuffer.append(genModel.getModelName()); + } stringBuffer.append(TEXT_31); - stringBuffer.append(genModel.getModelName()); + if (genModel.isRichClientPlatform()) { stringBuffer.append(TEXT_32); - stringBuffer.append(genModel.getModelName()); + stringBuffer.append(genModel.getEditorAdvisorClassName()); stringBuffer.append(TEXT_33); stringBuffer.append(genModel.getModelName()); stringBuffer.append(TEXT_34); @@ -150,16 +153,22 @@ stringBuffer.append(TEXT_35); stringBuffer.append(genModel.getModelName()); stringBuffer.append(TEXT_36); - for (GenPackage genPackage : genModel.getAllGenPackagesWithClassifiers()) {if (genPackage.isGenerateModelWizard()) { + stringBuffer.append(genModel.getModelName()); stringBuffer.append(TEXT_37); - stringBuffer.append(genPackage.getModelWizardClassName()); + stringBuffer.append(genModel.getModelName()); stringBuffer.append(TEXT_38); - stringBuffer.append(genPackage.getPrefix()); + stringBuffer.append(genModel.getModelName()); stringBuffer.append(TEXT_39); - }} + for (GenPackage genPackage : genModel.getAllGenPackagesWithClassifiers()) {if (genPackage.isGenerateModelWizard()) { stringBuffer.append(TEXT_40); - } + stringBuffer.append(genPackage.getModelWizardClassName()); stringBuffer.append(TEXT_41); + stringBuffer.append(genPackage.getPrefix()); + stringBuffer.append(TEXT_42); + }} + stringBuffer.append(TEXT_43); + } + stringBuffer.append(TEXT_44); return stringBuffer.toString(); } } Index: plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/templates/editor/PluginXML.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.emf/plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/templates/editor/PluginXML.java,v retrieving revision 1.22 diff -u -r1.22 PluginXML.java --- plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/templates/editor/PluginXML.java 28 Dec 2006 06:40:38 -0000 1.22 +++ plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/templates/editor/PluginXML.java 13 Feb 2007 09:45:47 -0000 @@ -88,9 +88,12 @@ protected final String TEXT_71 = "ModelFile.gif\"" + NL + " extensions = \""; protected final String TEXT_72 = "\"" + NL + " class = \""; protected final String TEXT_73 = "\" " + NL + " contributorClass=\""; - protected final String TEXT_74 = "\" >" + NL + " " + NL + " "; - protected final String TEXT_75 = NL + ""; - protected final String TEXT_76 = NL; + protected final String TEXT_74 = "\" >" + NL + " " + NL + " " + NL + " " + NL + " " + NL + " " + NL + " " + NL + " "; + protected final String TEXT_78 = NL + ""; + protected final String TEXT_79 = NL; public String generate(Object argument) { @@ -270,10 +273,16 @@ stringBuffer.append(TEXT_73); stringBuffer.append(genPackage.getQualifiedActionBarContributorClassName()); stringBuffer.append(TEXT_74); - } - } + stringBuffer.append(genPackage.getQualifiedEditorPreferencePageClassName()); stringBuffer.append(TEXT_75); + stringBuffer.append(genPackage.getQualifiedEditorPreferencePageClassName()); stringBuffer.append(TEXT_76); + stringBuffer.append(genPackage.getEditorPreferencePageClassName()); + stringBuffer.append(TEXT_77); + } + } + stringBuffer.append(TEXT_78); + stringBuffer.append(TEXT_79); return stringBuffer.toString(); } } Index: plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/templates/editor/Editor.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.emf/plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/templates/editor/Editor.java,v retrieving revision 1.43 diff -u -r1.43 Editor.java --- plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/templates/editor/Editor.java 30 Dec 2006 04:44:55 -0000 1.43 +++ plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/templates/editor/Editor.java 13 Feb 2007 09:45:45 -0000 @@ -23,7 +23,7 @@ protected final String TEXT_6 = NL + NL + "import org.eclipse.core.resources.IFile;" + NL + "import org.eclipse.core.resources.IMarker;" + NL + "import org.eclipse.core.resources.IResource;" + NL + "import org.eclipse.core.resources.IResourceChangeEvent;" + NL + "import org.eclipse.core.resources.IResourceChangeListener;" + NL + "import org.eclipse.core.resources.IResourceDelta;" + NL + "import org.eclipse.core.resources.IResourceDeltaVisitor;" + NL + "import org.eclipse.core.resources.ResourcesPlugin;"; protected final String TEXT_7 = NL; protected final String TEXT_8 = NL + "import org.eclipse.core.runtime.CoreException;" + NL + "import org.eclipse.core.runtime.IPath;"; - protected final String TEXT_9 = NL + "import org.eclipse.core.runtime.IProgressMonitor;" + NL + "import org.eclipse.core.runtime.NullProgressMonitor;" + NL + "" + NL + "import org.eclipse.jface.action.IMenuListener;" + NL + "import org.eclipse.jface.action.IMenuManager;" + NL + "import org.eclipse.jface.action.IStatusLineManager;" + NL + "import org.eclipse.jface.action.IToolBarManager;" + NL + "import org.eclipse.jface.action.MenuManager;" + NL + "import org.eclipse.jface.action.Separator;" + NL + "" + NL + "import org.eclipse.jface.dialogs.MessageDialog;" + NL + "import org.eclipse.jface.dialogs.ProgressMonitorDialog;" + NL; + protected final String TEXT_9 = NL + "import org.eclipse.core.runtime.IProgressMonitor;" + NL + "import org.eclipse.core.runtime.NullProgressMonitor;" + NL + "" + NL + "import org.eclipse.jface.action.IMenuListener;" + NL + "import org.eclipse.jface.action.IMenuManager;" + NL + "import org.eclipse.jface.action.IStatusLineManager;" + NL + "import org.eclipse.jface.action.IToolBarManager;" + NL + "import org.eclipse.jface.action.MenuManager;" + NL + "import org.eclipse.jface.action.Separator;" + NL + "" + NL + "import org.eclipse.jface.dialogs.MessageDialog;" + NL + "import org.eclipse.jface.dialogs.ProgressMonitorDialog;" + NL + "" + NL + "import org.eclipse.jface.preference.IPreferenceStore;" + NL; protected final String TEXT_10 = NL + "import org.eclipse.jface.viewers.ColumnWeightData;"; protected final String TEXT_11 = NL + "import org.eclipse.jface.viewers.ISelection;" + NL + "import org.eclipse.jface.viewers.ISelectionChangedListener;" + NL + "import org.eclipse.jface.viewers.ISelectionProvider;" + NL + "import org.eclipse.jface.viewers.IStructuredSelection;"; protected final String TEXT_12 = NL + "import org.eclipse.jface.viewers.ListViewer;"; @@ -48,7 +48,7 @@ protected final String TEXT_31 = NL + "import org.eclipse.emf.ecore.EObject;" + NL + "import org.eclipse.emf.ecore.EValidator;"; protected final String TEXT_32 = NL + NL + "import org.eclipse.emf.ecore.resource.Resource;"; protected final String TEXT_33 = NL + "import org.eclipse.emf.ecore.resource.ResourceSet;"; - protected final String TEXT_34 = NL + NL + "import org.eclipse.emf.ecore.util.EContentAdapter;" + NL + "import org.eclipse.emf.ecore.util.EcoreUtil;" + NL + "" + NL + "import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;" + NL + "import org.eclipse.emf.edit.domain.EditingDomain;" + NL + "import org.eclipse.emf.edit.domain.IEditingDomainProvider;" + NL + "" + NL + "import org.eclipse.emf.edit.provider.AdapterFactoryItemDelegator;" + NL + "import org.eclipse.emf.edit.provider.ComposedAdapterFactory;" + NL + "import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;" + NL + "" + NL + "import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;" + NL + "" + NL + "import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;" + NL + "" + NL + "import org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor;" + NL + "" + NL + "import org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter;" + NL + "import org.eclipse.emf.edit.ui.dnd.LocalTransfer;" + NL + "import org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter;" + NL + "" + NL + "import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;" + NL + "import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;"; + protected final String TEXT_34 = NL + NL + "import org.eclipse.emf.ecore.util.EContentAdapter;" + NL + "import org.eclipse.emf.ecore.util.EcoreUtil;" + NL + "" + NL + "import org.eclipse.emf.ecore.xmi.XMLResource;" + NL + "" + NL + "import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;" + NL + "import org.eclipse.emf.edit.domain.EditingDomain;" + NL + "import org.eclipse.emf.edit.domain.IEditingDomainProvider;" + NL + "" + NL + "import org.eclipse.emf.edit.provider.AdapterFactoryItemDelegator;" + NL + "import org.eclipse.emf.edit.provider.ComposedAdapterFactory;" + NL + "import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;" + NL + "" + NL + "import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;" + NL + "" + NL + "import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;" + NL + "" + NL + "import org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor;" + NL + "" + NL + "import org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter;" + NL + "import org.eclipse.emf.edit.ui.dnd.LocalTransfer;" + NL + "import org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter;" + NL + "" + NL + "import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;" + NL + "import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;"; protected final String TEXT_35 = NL + NL + "import org.eclipse.emf.edit.ui.util.EditUIMarkerHelper;"; protected final String TEXT_36 = NL + NL + "import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage;" + NL + "" + NL + "import "; protected final String TEXT_37 = ";" + NL; @@ -246,12 +246,12 @@ protected final String TEXT_229 = "()" + NL + "\t\t\t{" + NL + "\t\t\t\t// This is the method that gets invoked when the operation runs." + NL + "\t\t\t\t//"; protected final String TEXT_230 = NL + "\t\t\t\t@Override"; protected final String TEXT_231 = NL + "\t\t\t\tpublic void "; - protected final String TEXT_232 = "(IProgressMonitor monitor)" + NL + "\t\t\t\t{" + NL + "\t\t\t\t\t// Save the resources to the file system." + NL + "\t\t\t\t\t//" + NL + "\t\t\t\t\tboolean first = true;"; + protected final String TEXT_232 = "(IProgressMonitor monitor)" + NL + "\t\t\t\t{" + NL + "\t\t\t\t\t// Save the resources to the file system." + NL + "\t\t\t\t\t//" + NL + "\t\t\t\t\tboolean first = true;" + NL + "\t\t\t\t\tMap options = getOptions();"; protected final String TEXT_233 = NL + "\t\t\t\t\tfor (Resource resource : editingDomain.getResourceSet().getResources())"; protected final String TEXT_234 = NL + "\t\t\t\t\tfor (Iterator i = editingDomain.getResourceSet().getResources().iterator(); i.hasNext(); )"; protected final String TEXT_235 = NL + "\t\t\t\t\t{"; protected final String TEXT_236 = NL + "\t\t\t\t\t\tResource resource = (Resource)i.next();"; - protected final String TEXT_237 = NL + "\t\t\t\t\t\tif ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource))" + NL + "\t\t\t\t\t\t{" + NL + "\t\t\t\t\t\t\ttry" + NL + "\t\t\t\t\t\t\t{" + NL + "\t\t\t\t\t\t\t\tsavedResources.add(resource);" + NL + "\t\t\t\t\t\t\t\tresource.save(Collections.EMPTY_MAP);" + NL + "\t\t\t\t\t\t\t}" + NL + "\t\t\t\t\t\t\tcatch (Exception exception)" + NL + "\t\t\t\t\t\t\t{" + NL + "\t\t\t\t\t\t\t\tresourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));" + NL + "\t\t\t\t\t\t\t}" + NL + "\t\t\t\t\t\t\tfirst = false;" + NL + "\t\t\t\t\t\t}" + NL + "\t\t\t\t\t}" + NL + "\t\t\t\t}" + NL + "\t\t\t};" + NL + "" + NL + "\t\tupdateProblemIndication = false;" + NL + "\t\ttry" + NL + "\t\t{" + NL + "\t\t\t// This runs the options, and shows progress." + NL + "\t\t\t//" + NL + "\t\t\tnew ProgressMonitorDialog(getSite().getShell()).run(true, false, operation);" + NL + "" + NL + "\t\t\t// Refresh the necessary state." + NL + "\t\t\t//" + NL + "\t\t\t((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone();" + NL + "\t\t\tfirePropertyChange(IEditorPart.PROP_DIRTY);" + NL + "\t\t}" + NL + "\t\tcatch (Exception exception)" + NL + "\t\t{" + NL + "\t\t\t// Something went wrong that shouldn't." + NL + "\t\t\t//" + NL + "\t\t\t"; + protected final String TEXT_237 = NL + "\t\t\t\t\t\tif ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource))" + NL + "\t\t\t\t\t\t{" + NL + "\t\t\t\t\t\t\ttry" + NL + "\t\t\t\t\t\t\t{" + NL + "\t\t\t\t\t\t\t\tsavedResources.add(resource);" + NL + "\t\t\t\t\t\t\t\tresource.save(options);" + NL + "\t\t\t\t\t\t\t}" + NL + "\t\t\t\t\t\t\tcatch (Exception exception)" + NL + "\t\t\t\t\t\t\t{" + NL + "\t\t\t\t\t\t\t\tresourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));" + NL + "\t\t\t\t\t\t\t}" + NL + "\t\t\t\t\t\t\tfirst = false;" + NL + "\t\t\t\t\t\t}" + NL + "\t\t\t\t\t}" + NL + "\t\t\t\t}" + NL + "\t\t\t\t" + NL + "\t\t\t\t// determine save options from properties" + NL + "\t\t\t\tprivate Map getOptions() {" + NL + "\t\t\t\t\tMap options = new HashMap();" + NL + "\t\t\t\t\tIPreferenceStore store = ModelEditorPlugin.getPlugin().getPreferenceStore();" + NL + "\t\t\t\t\tString key = XMLResource.OPTION_SAVE_TYPE_INFORMATION;" + NL + "\t\t\t\t\tif (store.contains(key)) {" + NL + "\t\t\t\t\t\toptions.put(key, store.getBoolean(key));" + NL + "\t\t\t\t\t}" + NL + "\t\t\t\t\tkey = XMLResource.OPTION_SAVE_DOCTYPE;" + NL + "\t\t\t\t\tif (store.contains(key)) {" + NL + "\t\t\t\t\t\toptions.put(key, store.getBoolean(key));" + NL + "\t\t\t\t\t}" + NL + "\t\t\t\t\tkey = XMLResource.OPTION_FORMATTED;" + NL + "\t\t\t\t\tif (store.contains(key)) {" + NL + "\t\t\t\t\t\toptions.put(key, store.getBoolean(key));" + NL + "\t\t\t\t\t}" + NL + "\t\t\t\t\tkey = XMLResource.OPTION_LINE_WIDTH;" + NL + "\t\t\t\t\tif (store.contains(key)) {" + NL + "\t\t\t\t\t\toptions.put(key, store.getInt(key));" + NL + "\t\t\t\t\t}" + NL + "\t\t\t\t\t" + NL + "\t\t\t\t\treturn options;" + NL + "\t\t\t\t}" + NL + "\t\t\t};" + NL + "" + NL + "\t\tupdateProblemIndication = false;" + NL + "\t\ttry" + NL + "\t\t{" + NL + "\t\t\t// This runs the options, and shows progress." + NL + "\t\t\t//" + NL + "\t\t\tnew ProgressMonitorDialog(getSite().getShell()).run(true, false, operation);" + NL + "" + NL + "\t\t\t// Refresh the necessary state." + NL + "\t\t\t//" + NL + "\t\t\t((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone();" + NL + "\t\t\tfirePropertyChange(IEditorPart.PROP_DIRTY);" + NL + "\t\t}" + NL + "\t\tcatch (Exception exception)" + NL + "\t\t{" + NL + "\t\t\t// Something went wrong that shouldn't." + NL + "\t\t\t//" + NL + "\t\t\t"; protected final String TEXT_238 = ".INSTANCE.log(exception);" + NL + "\t\t}" + NL + "\t\tupdateProblemIndication = true;" + NL + "\t\tupdateProblemIndication();" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * This returns wether something has been persisted to the URI of the specified resource." + NL + "\t * The implementation uses the URI converter from the editor's resource set to try to open an input stream. " + NL + "\t * " + NL + "\t * " + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected boolean isPersisted(Resource resource)" + NL + "\t{" + NL + "\t\tboolean result = false;" + NL + "\t\ttry" + NL + "\t\t{" + NL + "\t\t\tInputStream stream = editingDomain.getResourceSet().getURIConverter().createInputStream(resource.getURI());" + NL + "\t\t\tif (stream != null)" + NL + "\t\t\t{" + NL + "\t\t\t\tresult = true;" + NL + "\t\t\t\tstream.close();" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t\tcatch (IOException e)" + NL + "\t\t{" + NL + "\t\t\t// Ignore" + NL + "\t\t}" + NL + "\t\treturn result;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * This always returns true because it is not currently supported." + NL + "\t * " + NL + "\t * " + NL + "\t * @generated" + NL + "\t */"; protected final String TEXT_239 = NL + "\t@Override"; protected final String TEXT_240 = NL + "\tpublic boolean isSaveAsAllowed()" + NL + "\t{" + NL + "\t\treturn true;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * This also changes the editor's input." + NL + "\t * " + NL + "\t * " + NL + "\t * @generated" + NL + "\t */"; Index: plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/genmodel/GenModel.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.emf/plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/genmodel/GenModel.java,v retrieving revision 1.41 diff -u -r1.41 GenModel.java --- plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/genmodel/GenModel.java 28 Dec 2006 08:40:32 -0000 1.41 +++ plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/genmodel/GenModel.java 13 Feb 2007 09:45:24 -0000 @@ -1088,7 +1088,7 @@ * @generated */ void setRichClientPlatform(boolean value); - + /** * Returns the value of the 'Reflective Delegation' attribute. * Index: plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/genmodel/GenPackage.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.emf/plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/genmodel/GenPackage.java,v retrieving revision 1.30 diff -u -r1.30 GenPackage.java --- plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/genmodel/GenPackage.java 29 Dec 2006 18:06:38 -0000 1.30 +++ plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/genmodel/GenPackage.java 13 Feb 2007 09:45:26 -0000 @@ -832,6 +832,8 @@ String getActionBarContributorClassName(); String getQualifiedActionBarContributorClassName(); String getImportedActionBarContributorClassName(); + String getEditorPreferencePageClassName(); + String getQualifiedEditorPreferencePageClassName(); String getAdapterFactoryDelegateName(GenPackage genDelegate); String getUncapAdapterFactoryDelegateName(GenPackage genDelegate); Index: plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/genmodel/impl/GenPackageImpl.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.emf/plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/genmodel/impl/GenPackageImpl.java,v retrieving revision 1.66 diff -u -r1.66 GenPackageImpl.java --- plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/genmodel/impl/GenPackageImpl.java 29 Dec 2006 18:06:38 -0000 1.66 +++ plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/genmodel/impl/GenPackageImpl.java 13 Feb 2007 09:45:38 -0000 @@ -3150,6 +3150,16 @@ { return getGenModel().getImportedName(getQualifiedActionBarContributorClassName()); } + + public String getEditorPreferencePageClassName() + { + return getPrefixedName("PreferencesPage"); + } + + public String getQualifiedEditorPreferencePageClassName() + { + return getPresentationPackageName() + "." + getEditorPreferencePageClassName(); + } public String getAdapterFactoryDelegateName(GenPackage genDelegate) { Index: plugins/org.eclipse.emf.codegen.ecore/templates/editor/Editor.javajet =================================================================== RCS file: /cvsroot/tools/org.eclipse.emf/plugins/org.eclipse.emf.codegen.ecore/templates/editor/Editor.javajet,v retrieving revision 1.42 diff -u -r1.42 Editor.javajet --- plugins/org.eclipse.emf.codegen.ecore/templates/editor/Editor.javajet 30 Dec 2006 04:44:55 -0000 1.42 +++ plugins/org.eclipse.emf.codegen.ecore/templates/editor/Editor.javajet 13 Feb 2007 09:45:51 -0000 @@ -76,6 +76,8 @@ import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.jface.preference.IPreferenceStore; + <%if (genPackage.isMultipleEditorPages()) {%> import org.eclipse.jface.viewers.ColumnWeightData; <%}%> @@ -189,6 +191,8 @@ import org.eclipse.emf.ecore.util.EContentAdapter; import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.xmi.XMLResource; + import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; import org.eclipse.emf.edit.domain.EditingDomain; import org.eclipse.emf.edit.domain.IEditingDomainProvider; @@ -1844,6 +1848,7 @@ // Save the resources to the file system. // boolean first = true; + Map options = getOptions(); <%if (genModel.useGenerics()) {%> for (Resource resource : editingDomain.getResourceSet().getResources()) <%} else {%> @@ -1858,7 +1863,7 @@ try { savedResources.add(resource); - resource.save(Collections.EMPTY_MAP); + resource.save(options); } catch (Exception exception) { @@ -1868,6 +1873,30 @@ } } } + + // determine save options from properties + private Map getOptions() { + Map options = new HashMap(); + IPreferenceStore store = ModelEditorPlugin.getPlugin().getPreferenceStore(); + String key = XMLResource.OPTION_SAVE_TYPE_INFORMATION; + if (store.contains(key)) { + options.put(key, store.getBoolean(key)); + } + key = XMLResource.OPTION_SAVE_DOCTYPE; + if (store.contains(key)) { + options.put(key, store.getBoolean(key)); + } + key = XMLResource.OPTION_FORMATTED; + if (store.contains(key)) { + options.put(key, store.getBoolean(key)); + } + key = XMLResource.OPTION_LINE_WIDTH; + if (store.contains(key)) { + options.put(key, store.getInt(key)); + } + + return options; + } }; updateProblemIndication = false; Index: plugins/org.eclipse.emf.codegen.ecore/templates/editor/plugin.propertiesjet =================================================================== RCS file: /cvsroot/tools/org.eclipse.emf/plugins/org.eclipse.emf.codegen.ecore/templates/editor/plugin.propertiesjet,v retrieving revision 1.16 diff -u -r1.16 plugin.propertiesjet --- plugins/org.eclipse.emf.codegen.ecore/templates/editor/plugin.propertiesjet 28 Dec 2006 06:40:38 -0000 1.16 +++ plugins/org.eclipse.emf.codegen.ecore/templates/editor/plugin.propertiesjet 13 Feb 2007 09:45:51 -0000 @@ -78,6 +78,13 @@ _UI_<%=genPackage.getEditorClassName()%>FilenameDefaultBase = My _UI_<%=genPackage.getEditorClassName()%>FilenameExtension = <%=genPackage.getPrefix().toLowerCase()%> +_UI_<%=genPackage.getEditorPreferencePageClassName()%>_label = <%=genPackage.getPrefix()%> Editor Preferences +_UI_EditorPreference_description_ = <%=genPackage.getPrefix()%> Editor XML saving preferences. +_UI_EditorPreferenceTypeInformation_label = Save type information +_UI_EditorPreferenceSaveDoctype_label = Save doctype declaration +_UI_EditorPreferenceFormatted_label = Output formatted XML +_UI_EditorPreferenceLineWidth_label = XML file line width + <%}%> _UI_Wizard_label = New Index: plugins/org.eclipse.emf.codegen.ecore/templates/editor/plugin.xmljet =================================================================== RCS file: /cvsroot/tools/org.eclipse.emf/plugins/org.eclipse.emf.codegen.ecore/templates/editor/plugin.xmljet,v retrieving revision 1.20 diff -u -r1.20 plugin.xmljet --- plugins/org.eclipse.emf.codegen.ecore/templates/editor/plugin.xmljet 28 Dec 2006 06:40:38 -0000 1.20 +++ plugins/org.eclipse.emf.codegen.ecore/templates/editor/plugin.xmljet 13 Feb 2007 09:45:52 -0000 @@ -205,7 +205,16 @@ class = "<%=genPackage.getQualifiedEditorClassName()%>" contributorClass="<%=genPackage.getQualifiedActionBarContributorClassName()%>" > - + + + + + + <%}%> <%}%> Index: plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/genmodel/generator/GenPackageGeneratorAdapter.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.emf/plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/genmodel/generator/GenPackageGeneratorAdapter.java,v retrieving revision 1.11 diff -u -r1.11 GenPackageGeneratorAdapter.java --- plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/genmodel/generator/GenPackageGeneratorAdapter.java 28 Dec 2006 06:40:38 -0000 1.11 +++ plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/genmodel/generator/GenPackageGeneratorAdapter.java 13 Feb 2007 09:45:28 -0000 @@ -67,7 +67,8 @@ protected static final int ACTION_BAR_CONTRIBUTOR_ID = 11; protected static final int PACKAGE_TEST_SUITE_ID = 12; protected static final int PACKAGE_EXAMPLE_ID = 13; - + protected static final int EDITOR_PREFERENCES_ID = 14; + private static final JETEmitterDescriptor[] JET_EMITTER_DESCRIPTORS = { new JETEmitterDescriptor("model/PackageClass.javajet", "org.eclipse.emf.codegen.ecore.templates.model.PackageClass"), @@ -83,7 +84,8 @@ new JETEmitterDescriptor("editor/ModelWizard.javajet", "org.eclipse.emf.codegen.ecore.templates.editor.ModelWizard"), new JETEmitterDescriptor("editor/ActionBarContributor.javajet", "org.eclipse.emf.codegen.ecore.templates.editor.ActionBarContributor"), new JETEmitterDescriptor("model.tests/PackageTestSuite.javajet", "org.eclipse.emf.codegen.ecore.templates.model.tests.PackageTestSuite"), - new JETEmitterDescriptor("model.tests/PackageExample.javajet", "org.eclipse.emf.codegen.ecore.templates.model.tests.PackageExample") + new JETEmitterDescriptor("model.tests/PackageExample.javajet", "org.eclipse.emf.codegen.ecore.templates.model.tests.PackageExample"), + new JETEmitterDescriptor("editor/EditorPreferencesPage.javajet", "org.eclipse.emf.codegen.ecore.templates.editor.EditorPreferencesPage") }; /** @@ -585,6 +587,7 @@ generateActionBarContributor(genPackage, monitor); generateModelIcon(genPackage, monitor); generateModelWizardIcon(genPackage, monitor); + generateEditorPreferencesPage(genPackage, monitor); return Diagnostic.OK_INSTANCE; } @@ -609,6 +612,27 @@ monitor.worked(1); } } + + protected void generateEditorPreferencesPage(GenPackage genPackage, Monitor monitor) + { + if (genPackage.hasConcreteClasses()) + { + message = CodeGenEcorePlugin.INSTANCE.getString + ("_UI_GeneratingJavaClass_message", new Object[] { genPackage.getQualifiedEditorPreferencePageClassName() }); + monitor.subTask(message); + generateJava + (genPackage.getGenModel().getEditorDirectory(), + genPackage.getPresentationPackageName(), + genPackage.getEditorPreferencePageClassName(), + getJETEmitter(getJETEmitterDescriptors(), EDITOR_PREFERENCES_ID), + null, + createMonitor(monitor, 1)); + } + else + { + monitor.worked(1); + } + } protected void generateModelWizard(GenPackage genPackage, Monitor monitor) { Index: plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/templates/editor/EditorPreferencesPage.java =================================================================== RCS file: plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/templates/editor/EditorPreferencesPage.java diff -N plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/templates/editor/EditorPreferencesPage.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/templates/editor/EditorPreferencesPage.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,98 @@ +package org.eclipse.emf.codegen.ecore.templates.editor; + +import java.util.*; +import org.eclipse.emf.codegen.ecore.genmodel.*; + +public class EditorPreferencesPage +{ + protected static String nl; + public static synchronized EditorPreferencesPage create(String lineSeparator) + { + nl = lineSeparator; + EditorPreferencesPage result = new EditorPreferencesPage(); + nl = null; + return result; + } + + protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; + protected final String TEXT_1 = ""; + protected final String TEXT_2 = "/**" + NL + " * " + NL + " * " + NL + " *" + NL + " * "; + protected final String TEXT_3 = "Id"; + protected final String TEXT_4 = NL + " */" + NL + "package "; + protected final String TEXT_5 = ";" + NL + "" + NL + "import org.eclipse.emf.ecore.xmi.XMLResource;" + NL + "import org.eclipse.jface.preference.BooleanFieldEditor;" + NL + "import org.eclipse.jface.preference.FieldEditor;" + NL + "import org.eclipse.jface.preference.FieldEditorPreferencePage;" + NL + "import org.eclipse.jface.preference.IPreferenceStore;" + NL + "import org.eclipse.jface.preference.IntegerFieldEditor;" + NL + "import org.eclipse.jface.resource.ImageDescriptor;" + NL + "import org.eclipse.ui.IWorkbench;" + NL + "import org.eclipse.ui.IWorkbenchPreferencePage;" + NL + "import org.eclipse.ui.internal.menus.SeparatorContributionItem;" + NL + "" + NL + "/**" + NL + " * This is an example of a "; + protected final String TEXT_6 = " model editor preferences." + NL + " * " + NL + " * " + NL + " * @generated" + NL + " */" + NL + "public class "; + protected final String TEXT_7 = " extends FieldEditorPreferencePage implements" + NL + "\t\tIWorkbenchPreferencePage {"; + protected final String TEXT_8 = NL + "\t/**" + NL + "\t * " + NL + "\t * " + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static final "; + protected final String TEXT_9 = " copyright = \""; + protected final String TEXT_10 = "\";"; + protected final String TEXT_11 = NL; + protected final String TEXT_12 = NL + " /**" + NL + "\t * Create the instance." + NL + "\t * " + NL + "\t * " + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic "; + protected final String TEXT_13 = "() {" + NL + "\t\tsuper(GRID);" + NL + "\t\tsetDescription(\"Cargarage Editor XML saving preferences.\");" + NL + "\t\tIPreferenceStore store = "; + protected final String TEXT_14 = ".getPlugin().getPreferenceStore();" + NL + "\t\tsetPreferenceStore(store);" + NL + "\t}" + NL + "" + NL + " /**" + NL + "\t * Create the preference page contents." + NL + "\t * " + NL + "\t * " + NL + "\t * @generated" + NL + "\t */\t" + NL + "\t@Override" + NL + "\tprotected void createFieldEditors() {" + NL + "\t\tFieldEditor saveTypeInformation = new BooleanFieldEditor(XMLResource.OPTION_SAVE_TYPE_INFORMATION, getString(\"_UI_EditorPreferenceTypeInformation_label\"), getFieldEditorParent());" + NL + "\t\taddField(saveTypeInformation);" + NL + "\t\t" + NL + "\t\tFieldEditor saveDoctype = new BooleanFieldEditor(XMLResource.OPTION_SAVE_DOCTYPE, getString(\"_UI_EditorPreferenceSaveDoctype_label\"), getFieldEditorParent());" + NL + "\t\taddField(saveDoctype);" + NL + "\t\t" + NL + "\t\tFieldEditor formatted = new BooleanFieldEditor(XMLResource.OPTION_FORMATTED, getString(\"_UI_EditorPreferenceFormatted_label\"), getFieldEditorParent());" + NL + "\t\taddField(formatted);" + NL + "\t\t" + NL + "\t\tIPreferenceStore store = ModelEditorPlugin.getPlugin().getPreferenceStore();" + NL + "\t\tif (! store.contains(XMLResource.OPTION_LINE_WIDTH)) {" + NL + "\t\t\tstore.setDefault(XMLResource.OPTION_LINE_WIDTH, 100);" + NL + "\t\t}" + NL + "\t\tIntegerFieldEditor lineWidth = new IntegerFieldEditor(XMLResource.OPTION_LINE_WIDTH, getString(\"_UI_EditorPreferenceLineWidth_label\"), getFieldEditorParent());" + NL + "\t\tlineWidth.setTextLimit(5);" + NL + "\t\taddField(lineWidth);" + NL + "\t}" + NL + "" + NL + "\tpublic void init(IWorkbench workbench) {" + NL + "\t\t// no init code" + NL + "\t}" + NL + "" + NL + " /**" + NL + "\t * This looks up a string in the plugin's plugin.properties file." + NL + "\t * " + NL + "\t * " + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate static String getString(String key) {" + NL + "\t\treturn ModelEditorPlugin.INSTANCE.getString(key);" + NL + "\t}" + NL + "}"; + protected final String TEXT_15 = NL; + + public String generate(Object argument) + { + final StringBuffer stringBuffer = new StringBuffer(); + +/** + * + * + * Copyright (c) 2002-2006 IBM Corporation 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: + * IBM - Initial API and implementation + * + * + */ + + GenPackage genPackage = (GenPackage)argument; GenModel genModel=genPackage.getGenModel(); +String importedOperationClassName = genModel.getImportedName(genModel.isRichClientPlatform() ? "org.eclipse.jface.operation.IRunnableWithProgress" : "org.eclipse.ui.actions.WorkspaceModifyOperation"); +String operationMethodName = genModel.isRichClientPlatform() ? "run" : "execute"; if (false) {/* Trick to import java.util.* without warnings */Iterator.class.getName();} + + String _ArrayListOfObject = "ArrayList" + (genModel.useGenerics() ? "" : ""); + String _ArrayListOfAdapterFactory = "ArrayList" + (genModel.useGenerics() ? "" : ""); + String _ListOfAdapterFactory = "List" + (genModel.useGenerics() ? "" : ""); + String _ArrayListOfSelectionChangedListener = "ArrayList" + (genModel.useGenerics() ? "" : ""); + String _CollectionOfSelectionChangedListener = "Collection" + (genModel.useGenerics() ? "" : ""); + String _ArrayListOfResource = "ArrayList" + (genModel.useGenerics() ? "" : ""); + String _CollectionOfResource = "Collection" + (genModel.useGenerics() ? "" : ""); + String _MapOfResourceToDiagnostic = "Map" + (genModel.useGenerics() ? "" : ""); + String _HashMapOfResourceToBoolean = "HashMap" + (genModel.useGenerics() ? "" : ""); + String _LinkedHashMapOfResourceToDiagnostic = "LinkedHashMap" + (genModel.useGenerics() ? "" : ""); + String _CollectionOfAnything = "Collection" + (genModel.useGenerics() ? "" : ""); + String _ListOfAnything = "List" + (genModel.useGenerics() ? "" : ""); + stringBuffer.append(TEXT_1); + stringBuffer.append(TEXT_2); + stringBuffer.append("$"); + stringBuffer.append(TEXT_3); + stringBuffer.append("$"); + stringBuffer.append(TEXT_4); + stringBuffer.append(genPackage.getPresentationPackageName()); + stringBuffer.append(TEXT_5); + stringBuffer.append(genPackage.getPrefix()); + stringBuffer.append(TEXT_6); + stringBuffer.append(genPackage.getEditorPreferencePageClassName()); + stringBuffer.append(TEXT_7); + if (genModel.getCopyrightText() != null) { + stringBuffer.append(TEXT_8); + stringBuffer.append(genModel.getImportedName("java.lang.String")); + stringBuffer.append(TEXT_9); + stringBuffer.append(genModel.getCopyrightText()); + stringBuffer.append(TEXT_10); + stringBuffer.append(genModel.getNonNLS()); + stringBuffer.append(TEXT_11); + } + stringBuffer.append(TEXT_12); + stringBuffer.append(genPackage.getEditorPreferencePageClassName()); + stringBuffer.append(TEXT_13); + stringBuffer.append(genModel.getEditorPluginClassName()); + stringBuffer.append(TEXT_14); + stringBuffer.append(TEXT_15); + return stringBuffer.toString(); + } +} Index: plugins/org.eclipse.emf.codegen.ecore/templates/editor/EditorPreferencesPage.javajet =================================================================== RCS file: plugins/org.eclipse.emf.codegen.ecore/templates/editor/EditorPreferencesPage.javajet diff -N plugins/org.eclipse.emf.codegen.ecore/templates/editor/EditorPreferencesPage.javajet --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ plugins/org.eclipse.emf.codegen.ecore/templates/editor/EditorPreferencesPage.javajet 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,117 @@ +<%@ jet package="org.eclipse.emf.codegen.ecore.templates.editor" imports="java.util.* org.eclipse.emf.codegen.ecore.genmodel.*" class="EditorPreferencesPage" version="" %> +<% +/** + * + * + * Copyright (c) 2002-2006 IBM Corporation 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: + * IBM - Initial API and implementation + * + * + */ +%> +<%GenPackage genPackage = (GenPackage)argument; GenModel genModel=genPackage.getGenModel(); +String importedOperationClassName = genModel.getImportedName(genModel.isRichClientPlatform() ? "org.eclipse.jface.operation.IRunnableWithProgress" : "org.eclipse.ui.actions.WorkspaceModifyOperation"); +String operationMethodName = genModel.isRichClientPlatform() ? "run" : "execute"; if (false) {/* Trick to import java.util.* without warnings */Iterator.class.getName();} +%> +<%String _ArrayListOfObject = "ArrayList" + (genModel.useGenerics() ? "" : "");%> +<%String _ArrayListOfAdapterFactory = "ArrayList" + (genModel.useGenerics() ? "" : "");%> +<%String _ListOfAdapterFactory = "List" + (genModel.useGenerics() ? "" : "");%> +<%String _ArrayListOfSelectionChangedListener = "ArrayList" + (genModel.useGenerics() ? "" : "");%> +<%String _CollectionOfSelectionChangedListener = "Collection" + (genModel.useGenerics() ? "" : "");%> +<%String _ArrayListOfResource = "ArrayList" + (genModel.useGenerics() ? "" : "");%> +<%String _CollectionOfResource = "Collection" + (genModel.useGenerics() ? "" : "");%> +<%String _MapOfResourceToDiagnostic = "Map" + (genModel.useGenerics() ? "" : "");%> +<%String _HashMapOfResourceToBoolean = "HashMap" + (genModel.useGenerics() ? "" : "");%> +<%String _LinkedHashMapOfResourceToDiagnostic = "LinkedHashMap" + (genModel.useGenerics() ? "" : "");%> +<%String _CollectionOfAnything = "Collection" + (genModel.useGenerics() ? "" : "");%> +<%String _ListOfAnything = "List" + (genModel.useGenerics() ? "" : "");%> +<%@ include file="../Header.javajetinc"%> +package <%=genPackage.getPresentationPackageName()%>; + +import org.eclipse.emf.ecore.xmi.XMLResource; +import org.eclipse.jface.preference.BooleanFieldEditor; +import org.eclipse.jface.preference.FieldEditor; +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.IntegerFieldEditor; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.ui.internal.menus.SeparatorContributionItem; + +/** + * This is an example of a <%=genPackage.getPrefix()%> model editor preferences. + * + * + * @generated + */ +public class <%=genPackage.getEditorPreferencePageClassName()%> extends FieldEditorPreferencePage implements + IWorkbenchPreferencePage { +<%if (genModel.getCopyrightText() != null) {%> + /** + * + * + * @generated + */ + public static final <%=genModel.getImportedName("java.lang.String")%> copyright = "<%=genModel.getCopyrightText()%>";<%=genModel.getNonNLS()%> + +<%}%> + /** + * Create the instance. + * + * + * @generated + */ + public <%=genPackage.getEditorPreferencePageClassName()%>() { + super(GRID); + setDescription("Cargarage Editor XML saving preferences."); + IPreferenceStore store = <%=genModel.getEditorPluginClassName()%>.getPlugin().getPreferenceStore(); + setPreferenceStore(store); + } + + /** + * Create the preference page contents. + * + * + * @generated + */ + @Override + protected void createFieldEditors() { + FieldEditor saveTypeInformation = new BooleanFieldEditor(XMLResource.OPTION_SAVE_TYPE_INFORMATION, getString("_UI_EditorPreferenceTypeInformation_label"), getFieldEditorParent()); + addField(saveTypeInformation); + + FieldEditor saveDoctype = new BooleanFieldEditor(XMLResource.OPTION_SAVE_DOCTYPE, getString("_UI_EditorPreferenceSaveDoctype_label"), getFieldEditorParent()); + addField(saveDoctype); + + FieldEditor formatted = new BooleanFieldEditor(XMLResource.OPTION_FORMATTED, getString("_UI_EditorPreferenceFormatted_label"), getFieldEditorParent()); + addField(formatted); + + IPreferenceStore store = ModelEditorPlugin.getPlugin().getPreferenceStore(); + if (! store.contains(XMLResource.OPTION_LINE_WIDTH)) { + store.setDefault(XMLResource.OPTION_LINE_WIDTH, 100); + } + IntegerFieldEditor lineWidth = new IntegerFieldEditor(XMLResource.OPTION_LINE_WIDTH, getString("_UI_EditorPreferenceLineWidth_label"), getFieldEditorParent()); + lineWidth.setTextLimit(5); + addField(lineWidth); + } + + public void init(IWorkbench workbench) { + // no init code + } + + /** + * This looks up a string in the plugin's plugin.properties file. + * + * + * @generated + */ + private static String getString(String key) { + return ModelEditorPlugin.INSTANCE.getString(key); + } +}