|
From: jistrawn <jis...@us...> - 2006-10-30 15:15:04
|
Update of /cvsroot/modelwizard/source/Model Wizard Plugin/src/net/sourceforge/modelWizard/modelAbstraction In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv22048/src/net/sourceforge/modelWizard/modelAbstraction Modified Files: ModelAccess.java Log Message: reformatted Index: ModelAccess.java =================================================================== RCS file: /cvsroot/modelwizard/source/Model Wizard Plugin/src/net/sourceforge/modelWizard/modelAbstraction/ModelAccess.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ModelAccess.java 24 Oct 2006 21:41:30 -0000 1.8 --- ModelAccess.java 30 Oct 2006 15:14:59 -0000 1.9 *************** *** 69,82 **** private URI currentMenuFolder = null; ! private ArrayList listeners = new ArrayList(); private class ModelExporter { ! private IModelExporter exporter; private String name; private String fileExt; private String targetType; ! public ModelExporter(IConfigurationElement element) { Object o = null; --- 69,85 ---- private URI currentMenuFolder = null; ! private ArrayList listeners = new ArrayList(); private class ModelExporter { ! private IModelExporter exporter; + private String name; + private String fileExt; + private String targetType; ! public ModelExporter(IConfigurationElement element) { Object o = null; *************** *** 84,95 **** o = element.createExecutableExtension("class"); } catch (CoreException e) { ! throw new ModelAbstractionError( ! "Cannot instantiate Model Exporter", e); } if (o instanceof IModelExporter) exporter = (IModelExporter) o; else ! throw new ModelAbstractionError( ! "Did not get an instance of IModelExporter"); name = element.getAttribute("name"); fileExt = element.getAttribute("fileExtension"); --- 87,96 ---- o = element.createExecutableExtension("class"); } catch (CoreException e) { ! throw new ModelAbstractionError("Cannot instantiate Model Exporter", e); } if (o instanceof IModelExporter) exporter = (IModelExporter) o; else ! throw new ModelAbstractionError("Did not get an instance of IModelExporter"); name = element.getAttribute("name"); fileExt = element.getAttribute("fileExtension"); *************** *** 108,113 **** return name; } ! ! public boolean isFile(){ if (targetType == null || targetType.equalsIgnoreCase("file")) return true; --- 109,114 ---- return name; } ! ! public boolean isFile() { if (targetType == null || targetType.equalsIgnoreCase("file")) return true; *************** *** 116,120 **** } } ! /** * Container for model abstraction information. --- 117,121 ---- } } ! /** * Container for model abstraction information. *************** *** 125,128 **** --- 126,130 ---- private IConfigurationElement ce; + private ArrayList modelExporters = new ArrayList(); *************** *** 130,134 **** this.ce = ce; IConfigurationElement[] exports = ce.getChildren("modelExport"); ! for (int i = 0;i<exports.length;i++){ modelExporters.add(new ModelExporter(exports[i])); } --- 132,136 ---- this.ce = ce; IConfigurationElement[] exports = ce.getChildren("modelExport"); ! for (int i = 0; i < exports.length; i++) { modelExporters.add(new ModelExporter(exports[i])); } *************** *** 140,151 **** o = ce.createExecutableExtension("class"); } catch (CoreException e) { ! throw new ModelAbstractionError( ! "Cannot instantiate Model Abstraction", e); } if (o instanceof IModel) return (IModel) o; else ! throw new ModelAbstractionError( ! "Did not get an instance of IModel"); } --- 142,151 ---- o = ce.createExecutableExtension("class"); } catch (CoreException e) { ! throw new ModelAbstractionError("Cannot instantiate Model Abstraction", e); } if (o instanceof IModel) return (IModel) o; else ! throw new ModelAbstractionError("Did not get an instance of IModel"); } *************** *** 155,160 **** URL folderUrl = Platform.find(b, new Path(folder)); if (folderUrl == null) ! throw new ModelAbstractionError( ! "Invalid or non-existant folder directory:"+folder); URL resolved = Platform.resolve(folderUrl); URI fUri = URI.createFileURI(resolved.getFile()); --- 155,159 ---- URL folderUrl = Platform.find(b, new Path(folder)); if (folderUrl == null) ! throw new ModelAbstractionError("Invalid or non-existant folder directory:" + folder); URL resolved = Platform.resolve(folderUrl); URI fUri = URI.createFileURI(resolved.getFile()); *************** *** 167,172 **** URL folderUrl = Platform.find(b, new Path(folder)); if (folderUrl == null) ! throw new ModelAbstractionError( ! "Invalid or non-existant menu directory:"+folder); URL resolved = Platform.resolve(folderUrl); URI fUri = URI.createFileURI(resolved.getFile()); --- 166,170 ---- URL folderUrl = Platform.find(b, new Path(folder)); if (folderUrl == null) ! throw new ModelAbstractionError("Invalid or non-existant menu directory:" + folder); URL resolved = Platform.resolve(folderUrl); URI fUri = URI.createFileURI(resolved.getFile()); *************** *** 174,178 **** } ! public boolean isPrimary(){ String pri = ce.getAttribute("primary"); if (pri == null) --- 172,176 ---- } ! public boolean isPrimary() { String pri = ce.getAttribute("primary"); if (pri == null) *************** *** 182,191 **** return false; } ! ! public String getPluginId(){ Bundle b = Platform.getBundle(ce.getDeclaringExtension().getNamespace()); return b.getSymbolicName(); } ! public URI getDefaultModelFile() throws IOException { Bundle b = Platform.getBundle(ce.getDeclaringExtension().getNamespace()); --- 180,189 ---- return false; } ! ! public String getPluginId() { Bundle b = Platform.getBundle(ce.getDeclaringExtension().getNamespace()); return b.getSymbolicName(); } ! public URI getDefaultModelFile() throws IOException { Bundle b = Platform.getBundle(ce.getDeclaringExtension().getNamespace()); *************** *** 203,225 **** return ce.getAttribute("name"); } ! ! public int getNumberOfExporters(){ return modelExporters.size(); } ! ! public IModelExporter getExporter(int n){ ModelExporter m = (ModelExporter) modelExporters.get(n); return m.getExporter(); } ! public String getExporterFileExt(int n){ ModelExporter m = (ModelExporter) modelExporters.get(n); return m.getFileExt(); } ! public String getExporterName(int n){ ModelExporter m = (ModelExporter) modelExporters.get(n); return m.getName(); } ! public boolean isFile(int n){ ModelExporter m = (ModelExporter) modelExporters.get(n); return m.isFile(); --- 201,225 ---- return ce.getAttribute("name"); } ! ! public int getNumberOfExporters() { return modelExporters.size(); } ! ! public IModelExporter getExporter(int n) { ModelExporter m = (ModelExporter) modelExporters.get(n); return m.getExporter(); } ! public String getExporterFileExt(int n) { ModelExporter m = (ModelExporter) modelExporters.get(n); return m.getFileExt(); } ! ! public String getExporterName(int n) { ModelExporter m = (ModelExporter) modelExporters.get(n); return m.getName(); } ! ! public boolean isFile(int n) { ModelExporter m = (ModelExporter) modelExporters.get(n); return m.isFile(); *************** *** 243,271 **** * same do nothing. - If model is different, - Just change the profile (no * performance impact. - Need to trigger notification of changes... ! * @throws IOException */ public void updateCurrentSetting() throws IOException { URI candidateModelFile; ! String newKey = preferences ! .getString(PreferencesInitializer.MODEL_PLUGIN); if (newKey.equals("") || !definitions.containsKey(newKey)) { newKey = getPrimary(); preferences.setValue(PreferencesInitializer.MODEL_PLUGIN, newKey); } ! ModelDefinition newMd = (ModelDefinition) definitions.get(newKey); ! boolean useDefaultModel = preferences ! .getBoolean(PreferencesInitializer.USE_DEFAULT_MODEL); String model = preferences.getString(PreferencesInitializer.MODEL); ! boolean useProfileDefault = preferences ! .getBoolean(PreferencesInitializer.USE_DEFAULT_PROFILES); ! String profileFolder = preferences ! .getString(PreferencesInitializer.PROFILE_FOLDER); ! boolean useMenuDefault = preferences ! .getBoolean(PreferencesInitializer.USE_DEFAULT_MENU); ! String menuFolder = preferences ! .getString(PreferencesInitializer.MENU_FOLDER); ! if (useDefaultModel) candidateModelFile = newMd.getDefaultModelFile(); --- 243,266 ---- * same do nothing. - If model is different, - Just change the profile (no * performance impact. - Need to trigger notification of changes... ! * ! * @throws IOException */ public void updateCurrentSetting() throws IOException { URI candidateModelFile; ! String newKey = preferences.getString(PreferencesInitializer.MODEL_PLUGIN); if (newKey.equals("") || !definitions.containsKey(newKey)) { newKey = getPrimary(); preferences.setValue(PreferencesInitializer.MODEL_PLUGIN, newKey); } ! ModelDefinition newMd = (ModelDefinition) definitions.get(newKey); ! boolean useDefaultModel = preferences.getBoolean(PreferencesInitializer.USE_DEFAULT_MODEL); String model = preferences.getString(PreferencesInitializer.MODEL); ! boolean useProfileDefault = preferences.getBoolean(PreferencesInitializer.USE_DEFAULT_PROFILES); ! String profileFolder = preferences.getString(PreferencesInitializer.PROFILE_FOLDER); ! boolean useMenuDefault = preferences.getBoolean(PreferencesInitializer.USE_DEFAULT_MENU); ! String menuFolder = preferences.getString(PreferencesInitializer.MENU_FOLDER); ! if (useDefaultModel) candidateModelFile = newMd.getDefaultModelFile(); *************** *** 285,292 **** notifyProfileChanges(); notifyMenuChanges(); ! if (key == null || !newKey.equalsIgnoreCase(key)) { // set up all defaults and open model ... ! currentModel = null; key = newKey; currentModelFile = candidateModelFile; --- 280,287 ---- notifyProfileChanges(); notifyMenuChanges(); ! if (key == null || !newKey.equalsIgnoreCase(key)) { // set up all defaults and open model ... ! currentModel = null; key = newKey; currentModelFile = candidateModelFile; *************** *** 312,330 **** private void getAbstractionInterfaces() { IExtensionRegistry registry = Platform.getExtensionRegistry(); ! IExtensionPoint point = registry ! .getExtensionPoint("net.sourceforge.modelWizard.modelAbstraction"); if (point == null) return; IExtension[] extensions = point.getExtensions(); for (int n = 0; n < extensions.length; n++) { ! IConfigurationElement[] ce = extensions[n] ! .getConfigurationElements(); for (int m = 0; m < ce.length; m++) { ! definitions.put(ce[m].getAttribute("name"), ! new ModelDefinition(ce[m])); } } } ! /** * Use by preferences only ... --- 307,322 ---- private void getAbstractionInterfaces() { IExtensionRegistry registry = Platform.getExtensionRegistry(); ! IExtensionPoint point = registry.getExtensionPoint("net.sourceforge.modelWizard.modelAbstraction"); if (point == null) return; IExtension[] extensions = point.getExtensions(); for (int n = 0; n < extensions.length; n++) { ! IConfigurationElement[] ce = extensions[n].getConfigurationElements(); for (int m = 0; m < ce.length; m++) { ! definitions.put(ce[m].getAttribute("name"), new ModelDefinition(ce[m])); } } } ! /** * Use by preferences only ... *************** *** 346,352 **** /** ! * Use by preferences only ... ! * It will return the key for the primary model. If multiple primaries are set the first one will be return, ! * if none then the first key will be returned. * * @return --- 338,344 ---- /** ! * Use by preferences only ... It will return the key for the primary model. ! * If multiple primaries are set the first one will be return, if none then ! * the first key will be returned. * * @return *************** *** 368,372 **** * * @return ! * @throws IOException */ public URI getDefaultModel(String key) throws IOException { --- 360,364 ---- * * @return ! * @throws IOException */ public URI getDefaultModel(String key) throws IOException { *************** *** 379,383 **** * * @return ! * @throws IOException */ public URI getDefaultProfileDirectory(String key) throws IOException { --- 371,375 ---- * * @return ! * @throws IOException */ public URI getDefaultProfileDirectory(String key) throws IOException { *************** *** 462,468 **** public String getPluginId(String key) { ! return ((ModelDefinition)definitions.get(key)).getPluginId(); } ! /** * Get the number of exporters for the current model --- 454,460 ---- public String getPluginId(String key) { ! return ((ModelDefinition) definitions.get(key)).getPluginId(); } ! /** * Get the number of exporters for the current model *************** *** 470,474 **** * @return */ ! public int getNumberOfModelExporters(){ ModelDefinition md = (ModelDefinition) definitions.get(key); return md.getNumberOfExporters(); --- 462,466 ---- * @return */ ! public int getNumberOfModelExporters() { ModelDefinition md = (ModelDefinition) definitions.get(key); return md.getNumberOfExporters(); *************** *** 477,484 **** /** * Get one of the exporter classes ! * @param n the index for the exporter element * @return */ ! public IModelExporter getModelExporter(int n){ ModelDefinition md = (ModelDefinition) definitions.get(key); return md.getExporter(n); --- 469,478 ---- /** * Get one of the exporter classes ! * ! * @param n ! * the index for the exporter element * @return */ ! public IModelExporter getModelExporter(int n) { ModelDefinition md = (ModelDefinition) definitions.get(key); return md.getExporter(n); *************** *** 487,512 **** /** * Get the name of an Exporter ! * @param n the index for the exporter element * @return */ ! public String getExporterName(int n){ ModelDefinition md = (ModelDefinition) definitions.get(key); return md.getExporterName(n); } /** * Get the file extension for an Exporter ! * @param n the index for the exporter element * @return */ ! public String getExporterFileExt(int n){ ModelDefinition md = (ModelDefinition) definitions.get(key); return md.getExporterFileExt(n); } /** * Does this exporter output to a file or a folder? ! * @param n the index for the exporter element * @return */ ! public boolean isFile(int n){ ModelDefinition md = (ModelDefinition) definitions.get(key); return md.isFile(n); --- 481,514 ---- /** * Get the name of an Exporter ! * ! * @param n ! * the index for the exporter element * @return */ ! public String getExporterName(int n) { ModelDefinition md = (ModelDefinition) definitions.get(key); return md.getExporterName(n); } + /** * Get the file extension for an Exporter ! * ! * @param n ! * the index for the exporter element * @return */ ! public String getExporterFileExt(int n) { ModelDefinition md = (ModelDefinition) definitions.get(key); return md.getExporterFileExt(n); } + /** * Does this exporter output to a file or a folder? ! * ! * @param n ! * the index for the exporter element * @return */ ! public boolean isFile(int n) { ModelDefinition md = (ModelDefinition) definitions.get(key); return md.isFile(n); |