diff options
author | justinchen | 2006-09-22 22:27:46 +0000 |
---|---|---|
committer | justinchen | 2006-09-22 22:27:46 +0000 |
commit | c99a0f82aa6aa4795d8418402f90cc3dba8d9587 (patch) | |
tree | b228da15c8c108f219f99c59559e1c6c738c99a0 | |
parent | 2c216e49673b584046c07d4eadc759b497eb6b2d (diff) | |
download | webtools.jsf-c99a0f82aa6aa4795d8418402f90cc3dba8d9587.tar.gz webtools.jsf-c99a0f82aa6aa4795d8418402f90cc3dba8d9587.tar.xz webtools.jsf-c99a0f82aa6aa4795d8418402f90cc3dba8d9587.zip |
[146052] JSF Libraries default incorrectly for a New Project.
19 files changed, 1422 insertions, 1086 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/Messages.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/Messages.java index 15b6834ce..f6967d1c7 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/Messages.java +++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/Messages.java @@ -21,6 +21,10 @@ import org.eclipse.osgi.util.NLS; public class Messages extends NLS { private static final String BUNDLE_NAME = "org.eclipse.jst.jsf.core.internal.messages"; //$NON-NLS-1$ + public static String JSFLibCfgDialogSettingData_Sticky_Component_Lib_Not_Exist; + + public static String JSFLibraryConfigModel_Null_Data_Source; + public static String JSFLibraryConfigPersistData_SAVED_COMPLIB_NOT_FOUND; public static String JSFLibraryConfigPersistData_SAVED_IMPLLIB_NOT_FOUND; diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/J2EEModuleDependencyDelegate.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/J2EEModuleDependencyDelegate.java index 4725f588a..909914358 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/J2EEModuleDependencyDelegate.java +++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/J2EEModuleDependencyDelegate.java @@ -16,6 +16,8 @@ import java.io.InputStream; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Collections; +import java.util.Iterator; +import java.util.List; import java.util.jar.Manifest; import org.eclipse.core.resources.IContainer; @@ -28,6 +30,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; import org.eclipse.emf.common.util.URI; @@ -54,18 +57,18 @@ import org.eclipse.wst.common.componentcore.resources.IVirtualReference; import org.eclipse.wst.common.frameworks.internal.ui.WTPUIPlugin; /** - * The <b>J2EEModuleDependencyDelegate</b> provide services to update - * J2EE module dependencies and java build path if JSF libraries - * are referenced in a web application. + * <b>J2EEModuleDependencyDelegate</b> provides a service to update project dependencies. + * It includes updating web library dependencies and java build path for web modules. * * @author Justin Chen - Oracle */ public class J2EEModuleDependencyDelegate { - private IProject project = null; - private ClasspathModel model = null; + final private IProject project; + final private ClasspathModel model; /** - * @param project + * Constructor + * @param project IProject instance on which to update dependencies. */ public J2EEModuleDependencyDelegate(IProject project) { this.project = project; @@ -73,49 +76,90 @@ public class J2EEModuleDependencyDelegate { } /** - * Add given <b>jsfLibrary</b> as project dependency. - * If <b>toDeploy</b> flag is true, the JSF library JARs will be - * added as J2EE module dependencies. + * To update project dependencies including Java buildpath and + * web library dependencies from JSFLibraryConfigModel. + * + * @param model JSFLibraryConfigModel instance with information to update project dependencies + * @param monitor IProgressMonitor progress monitor passed. New instance is creatsed if a null is given + */ + public void updateProjectDependencies(final JSFLibraryConfigModel model, + IProgressMonitor monitor) { + if (monitor == null) { + monitor = new NullProgressMonitor(); + } + // update implementation library + JSFProjectLibraryReference newImplLib = model.getCurrentJSFImplementationLibrarySelection(); + JSFProjectLibraryReference savedImplLib = model.getSavedJSFImplementationLibrary(); + if (savedImplLib != null) { + this.removeProjectDependency(savedImplLib.getLibrary(), monitor); + this.addProjectDependency(newImplLib.getLibrary(), newImplLib.isCheckedToBeDeployed(), monitor); + } else { + this.addProjectDependency(newImplLib.getLibrary(), newImplLib.isCheckedToBeDeployed(), monitor); + } + + // update component libraries + // Remove first and then add dependencies from selected libraries currently. + JSFProjectLibraryReference compLibDctr = null; + List savedCompLibs = model.getSavedJSFComponentLibraries(); + Iterator it = savedCompLibs.iterator(); + while (it.hasNext()) { + compLibDctr = (JSFProjectLibraryReference) it.next(); + this.removeProjectDependency(compLibDctr.getLibrary(), monitor); + } + + List selComponentLibs = model.getCurrentJSFComponentLibrarySelection(); + it = selComponentLibs.iterator(); + while (it.hasNext()) { + compLibDctr = (JSFProjectLibraryReference) it.next(); + if (compLibDctr.isSelected()) { + this.addProjectDependency(compLibDctr.getLibrary(), + compLibDctr.isCheckedToBeDeployed(), + monitor); + } + } + } + + /** + * Add the given jsfLibrary instance as project dependency. + * If toDeploy is true, the JARs from JSF library is added as web library dependencies. * Otherwise, JARs are added in project build path only. * - * @param jsfLibrary - * @param toDeploy - * @param monitor + * @param jsfLibrary JSFLibrary instance to be added as project dependencies. + * @param toDeploy boolean add as web library project for a web module if true. Otheriwse, add to build path only + * @param monitor IProgressMOnitor */ - public void addProjectDependency(JSFLibrary jsfLibrary, boolean toDeploy, IProgressMonitor monitor) { + private void addProjectDependency(final JSFLibrary jsfLibrary, + final boolean toDeploy, + final IProgressMonitor monitor) { IPath[] jarPaths = JSFUtils.getJARPathforJSFLibwFilterMissingJars(jsfLibrary, true); - this.updateProjectDependency(jarPaths, toDeploy, monitor); + updateProjectDependency(jarPaths, toDeploy, monitor); } /** - * Remove given <b>jsfLibrary</b> from project dependency. + * Remove given <b>jsfLibrary</b> from project dependency, + * including web library dependencies and project build path. * - * @param jsfLibrary - * @param monitor + * @param jsfLibrary JSFLibrary instance to be removed from project dependencies. + * @param monitor */ - public void removeProjectDependency(JSFLibrary jsfLibrary, IProgressMonitor monitor) { + private void removeProjectDependency(final JSFLibrary jsfLibrary, final IProgressMonitor monitor) { IPath[] elements = JSFUtils.getJARPathforJSFLib(jsfLibrary, false); - this.removeProjectDependency_(elements, monitor); + removeProjectDependency_(elements, monitor); } /** - * @param jsfLibrary - * @param monitor + * To update project dependencies by the path collection of JARs. * - public void addLibraryToBuildPath(JSFLibraryDecorator jsfLibrary, IProgressMonitor monitor) { - IPath[] elements = JSFUtils.getJARPathforJSFLib(jsfLibrary.getLibrary()); - this.updateProjectDependency(elements, false, monitor); - } - */ - - /** - * To update J2EE Module dependencies from given collection of JARs and deployment flag. + * All JARs are added into project build path. + * However, JARs are added as web library dependencies only if deployme is true. * - * @param elems - * @param deployme - * @param monitor + * @param elems IPath[] + * @param deployme boolean + * @param monitor IProgressMonitor */ - private void updateProjectDependency(IPath[] elems, boolean deployme, IProgressMonitor monitor) { + private void updateProjectDependency(final IPath[] elems, + final boolean deployme, + final IProgressMonitor monitor) { ClassPathSelection selection = null; /** @@ -130,28 +174,7 @@ public class J2EEModuleDependencyDelegate { // Added as J2EE Module Dependency if need to be deployed if (deployme) { - /* fix for bug# 144006 - wrap in WorkspaceJob - ArrayList vlist = new ArrayList(Collections.EMPTY_LIST); - IVirtualReference[] oldrefs = model.getComponent().getReferences(); - for (int j = 0; j < oldrefs.length; j++) { - IVirtualReference ref = oldrefs[j]; - vlist.add(ref); - } - - IVirtualReference ref = ComponentCore.createReference( - model.getComponent(), - archive, - new Path("/WEB-INF/lib") ); //$NON-NLS-1$ - addReferences(vlist, ref); - - IVirtualReference[] refs = new IVirtualReference[vlist.size()]; - for (int j = 0; j < vlist.size(); j++) { - IVirtualReference tmpref = (IVirtualReference) vlist.get(j); - refs[j] = tmpref; - } - - model.getComponent().setReferences(refs); - */ + // fix for bug# 144006 - wrap in WorkspaceJob SetReferencesJob setRefsJob = new SetReferencesJob(project, model.getComponent(), archive, true); setRefsJob.schedule(); } else { @@ -180,40 +203,18 @@ public class J2EEModuleDependencyDelegate { } /** - * To remove given collection of JARs from project's J2EE Module Dependencies. + * To remove project dependencies from the path collection of JARs. * - * @param elems - * @param monitor + * @param elems IPath[] elems + * @param monitor IProgressMonitor */ - private void removeProjectDependency_(IPath[] elems, IProgressMonitor monitor) { + private void removeProjectDependency_(final IPath[] elems, final IProgressMonitor monitor) { ClassPathSelection selection = null; for (int i= 0; i < elems.length; i++) { String type = VirtualArchiveComponent.LIBARCHIVETYPE + IPath.SEPARATOR; IVirtualComponent archive = ComponentCore.createArchiveComponent( model.getComponent().getProject(), type + elems[i].toString()); - /* fix for bug# 144006 - wrap in WorkspaceJob - ArrayList vlist = new ArrayList(Collections.EMPTY_LIST); - IVirtualReference[] oldrefs = model.getComponent().getReferences(); - for (int j = 0; j < oldrefs.length; j++) { - IVirtualReference ref = oldrefs[j]; - vlist.add(ref); - } - - // Remove the reference - IVirtualReference ref = ComponentCore.createReference( - model.getComponent(), - archive, - new Path("/WEB-INF/lib") ); //$NON-NLS-1$ - removeReference(vlist, ref); - - IVirtualReference[] refs = new IVirtualReference[vlist.size()]; - for (int j = 0; j < vlist.size(); j++) { - IVirtualReference tmpref = (IVirtualReference) vlist.get(j); - refs[j] = tmpref; - } - - model.getComponent().setReferences(refs); - */ + // fix for bug# 144006 - wrap in WorkspaceJob SetReferencesJob setRefsJob = new SetReferencesJob(project, model.getComponent(), archive, false); setRefsJob.schedule(); @@ -249,11 +250,10 @@ public class J2EEModuleDependencyDelegate { } /** - * Check if archive component already exists - * But, how to tell if two references are equal? + * To Do: check if archive component already exists * - * @param vlist - * @param ref + * @param vlist ArrayList + * @param ref IVirtualReference */ private void addReferences(ArrayList vlist, IVirtualReference ref) { IVirtualReference elem = null; @@ -306,8 +306,9 @@ public class J2EEModuleDependencyDelegate { } private void updateModelManifest(ClasspathModel model) { - if (JemProjectUtilities.isBinaryProject(project) || model.getAvailableEARComponents().length == 0) + if (JemProjectUtilities.isBinaryProject(project) || model.getAvailableEARComponents().length == 0) { return; + } IContainer root = null; IFile manifestFile = null; @@ -319,8 +320,9 @@ public class J2EEModuleDependencyDelegate { if (root != null) { manifestFile = root.getFile(new Path(J2EEConstants.MANIFEST_URI)); } - if (manifestFile == null || !manifestFile.exists()) + if (manifestFile == null || !manifestFile.exists()) { return; + } InputStream in = null; try { @@ -402,7 +404,7 @@ public class J2EEModuleDependencyDelegate { 5); if (parentComponent != null) { //copy from array to list - ArrayList refList = new ArrayList(Collections.EMPTY_LIST); + ArrayList refList = new ArrayList(); IVirtualReference[] refArray = parentComponent.getReferences(); for (int i = 0; i < refArray.length; i++) { refList.add(refArray[i]); diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfigDialogSettingData.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfigDialogSettingData.java new file mode 100644 index 000000000..d7fbff4b7 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfigDialogSettingData.java @@ -0,0 +1,139 @@ +/******************************************************************************* + * Copyright (c) 2006 Oracle Corporation. + * 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: + * Justin Chen + *******************************************************************************/ +package org.eclipse.jst.jsf.core.internal.jsflibraryconfig; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; +import org.eclipse.jst.jsf.core.internal.Messages; + +/** + * To construct implementation library and component libraries from sticky values + * in DialogSettings as saved libraries. + * + * @author Justin Chen - Oracle + */ +public class JSFLibraryConfigDialogSettingData implements JSFLibraryConfiglModelSource { + /** + * Delimintor for parsing a persistent property string. + */ + final protected static String SEPARATOR =":"; //$NON-NLS-1$ + + final private JSFLibraryRegistryUtil jsfLibReg; + final private boolean dftImplLibDeployFlag; + final private String[] savedCompLibs; + private JSFProjectLibraryReference selJSFLibImpl; // lazy initialized + private List selJSFLibComp; // lazy initialized + + /** + * Constructor + * @param implLibDeployFlag String valid options are "true" or "false" + * @param compLibs String[] saved component library settings in string array + * + public JSFLibraryConfigDialogSettingData(String implLibDeployFlag, String[] compLibs) { + this.jsfLibReg = JSFLibraryRegistryUtil.getInstance(); + this.dftImplLibDeployFlag = implLibDeployFlag; + this.savedCompLibs = compLibs; + + // Verify and log a message if a saved component library no longer exists. + verifySavedLibAvailability(); + } + */ + public JSFLibraryConfigDialogSettingData(boolean implLibDeployFlag, String[] compLibs) { + this.jsfLibReg = JSFLibraryRegistryUtil.getInstance(); + this.dftImplLibDeployFlag = implLibDeployFlag; + this.savedCompLibs = compLibs; + + // Verify and log a message if a saved component library no longer exists. + verifySavedLibAvailability(); + } + + /** + * There is no saved JSFImplLibrary per se if initializing from DialogSettings + * since default implementation library is always selected and only the + * deployment flag is saved. + * + * A null is returned when there is no default + * implementation library in registry. + * + * @return selJSFLibImpl JSFProjectLibraryReference return default implementation library with updated deployment flag + */ + public JSFProjectLibraryReference getJSFImplementationLibrary() { + if (selJSFLibImpl == null) { + // To instanciate a JSFProjectLibraryReference object from default impl lib as the saved library. + JSFProjectLibraryReference dftImplLib = jsfLibReg.getDefaultJSFImplementationLibrary(); + if (dftImplLib != null) { + selJSFLibImpl = new JSFProjectLibraryReference(dftImplLib.getLibrary(), + true, // selected + dftImplLibDeployFlag); + } + } + return selJSFLibImpl; + } + + /** + * Return the list of saved component libraries and their deployment settings. + * + * @return selJSFLibComp List + */ + public List getJSFComponentLibraries() { + if (selJSFLibComp == null) { + selJSFLibComp = new ArrayList(); + + if (savedCompLibs != null && savedCompLibs.length > 0) { + JSFProjectLibraryReference lib = null; + String item; + String[] attributes; + String id; + boolean deploy = false; + + for (int i = 0; i < savedCompLibs.length; i++) { + item = savedCompLibs[i]; + attributes = item.split(SEPARATOR); + + id = attributes[0]; + deploy = Boolean.valueOf(attributes[1]).booleanValue(); + + lib = jsfLibReg.getJSFLibryReferencebyID(id); + if (lib != null) { + selJSFLibComp.add(new JSFProjectLibraryReference(lib.getLibrary(), true, deploy)); + } /*else { + // already logged if a saved component library is no longer available. + }*/ + } + } + } + return selJSFLibComp; + } + + /** + * Only need to verify component library availability from sticky settings. + */ + private void verifySavedLibAvailability() { + if (savedCompLibs != null && savedCompLibs.length > 0) { + String item = null; + String[] attributes; + + for (int i = 0; i < savedCompLibs.length; i++) { + item = savedCompLibs[i]; + attributes = item.split(SEPARATOR); + + if (jsfLibReg.getJSFLibryReferencebyID(attributes[0]) == null) { + JSFCorePlugin.log(IStatus.INFO, Messages.JSFLibCfgDialogSettingData_Sticky_Component_Lib_Not_Exist); + } + } + } + } + +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfigModel.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfigModel.java new file mode 100644 index 000000000..955d5181b --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfigModel.java @@ -0,0 +1,259 @@ +/******************************************************************************* + * Copyright (c) 2006 Oracle Corporation. + * 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: Oracle + *******************************************************************************/ +package org.eclipse.jst.jsf.core.internal.jsflibraryconfig; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.core.resources.IProject; +import org.eclipse.jst.jsf.core.internal.Messages; + +/** + * Model for the custom control <b>JSFLibraryConfigControl</b>. + * A JSFLibraryConfigModel object is initialized from a source and updated with + * selected implementation and component libraries when selections are changed. + * + * @author Justin Chen - Oracle + */ +public class JSFLibraryConfigModel { + final private JSFLibraryConfiglModelSource data; + final private JSFLibraryRegistryUtil jsfLibReg; + private List colJSFImplLib; + private List colJSFCompLib; + + /** + * Private constructor. + * @param data + */ + private JSFLibraryConfigModel(JSFLibraryConfiglModelSource data) { + this.data = data; + this.jsfLibReg = JSFLibraryRegistryUtil.getInstance(); + } + + /** + * Return JSF implementation libraries. + * + * This list is initialized from JSF library registry and updated with persistent configuration data. + * + * @return List + * @see org.eclipse.jst.jsf.ui.properties.IJSFLibraryDecoratorProvider#getProjectJSFImplementationLibraries() + */ + public List getJSFImplementationLibraries() { + if (colJSFImplLib == null) { + /* To initialze an implementation library list from registry + * and then update the list with saved implementation library. + */ + colJSFImplLib = jsfLibReg.getJSFImplementationLibraries(); + JSFProjectLibraryReference targetLib = data.getJSFImplementationLibrary(); + if (targetLib == null) { + // no saved implementation, get default implementation library + targetLib = jsfLibReg.getDefaultJSFImplementationLibrary(); + } + if (targetLib != null) { + JSFProjectLibraryReference srcLib = jsfLibReg.getJSFLibryReferencebyID(targetLib.getID()); + if (srcLib != null) { + srcLib.setSelected(true); + srcLib.setToBeDeployed(targetLib.isCheckedToBeDeployed()); + } + } + } + return colJSFImplLib; + } + + /** + * Return JSF component libraries. + * + * This list is initialized from JSF library registry and updated with persistent + * configuration data. + * + * @return List + * @see org.eclipse.jst.jsf.ui.properties.IJSFLibraryDecoratorProvider#getProjectJSFComponentLibraries() + */ + public List getJSFComponentLibraries() { + if (colJSFCompLib == null) { + /* To initialize a component library list from registry and then + * update list with saved component libraries. + */ + colJSFCompLib = jsfLibReg.getJSFComponentLibraries(); + Iterator it = data.getJSFComponentLibraries().iterator(); + JSFProjectLibraryReference targetItem = null; + JSFProjectLibraryReference srcItem = null; + while (it.hasNext()) { + targetItem = (JSFProjectLibraryReference) it.next(); + srcItem = jsfLibReg.getJSFLibryReferencebyID(targetItem.getID()); + if (srcItem != null) { + srcItem.setSelected(true); + srcItem.setToBeDeployed(targetItem.isCheckedToBeDeployed()); + } + } + } + return colJSFCompLib; + } + + /** + * Return the selected JSF implementation library currently. + * A null is returned if none is selected. + * + * @return JSFProjectLibraryReference + */ + public JSFProjectLibraryReference getCurrentJSFImplementationLibrarySelection() { + Iterator it = getJSFImplementationLibraries().iterator(); + JSFProjectLibraryReference crtItem = null; + while (it.hasNext()) { + crtItem = (JSFProjectLibraryReference) it.next(); + if (crtItem.isSelected()) { + return crtItem; + } + } + return null; + } + + /** + * Return the selected JSF component libraries currently. + * An empty list is returned when no component libraries are selected. + * + * @return list List + */ + public List getCurrentJSFComponentLibrarySelection() { + List list = new ArrayList(); + + Iterator it = getJSFComponentLibraries().iterator(); + JSFProjectLibraryReference crtItem = null; + while (it.hasNext()) { + crtItem = (JSFProjectLibraryReference) it.next(); + if (crtItem.isSelected()) { + list.add(crtItem); + } + } + return list; + } + + /** + * Returned a saved implementation library which was persisted as + * DialogSettings or as project properties. + * + * @return JSFProjectLibraryReference + */ + public JSFProjectLibraryReference getSavedJSFImplementationLibrary() { + return data.getJSFImplementationLibrary(); + } + + /** + * Returned saved component libraries which were persisted as + * DialogSettings or project persistent properties. + * + * @return List + */ + public List getSavedJSFComponentLibraries() { + return data.getJSFComponentLibraries(); + } + + /** + * Update the selected JSF implementation library. + * + * Note: The library parameter won't be not added into the collection + * if it does not exist already. + * + * @param library JSFProjectLibraryReference + */ + public void setCurrentJSFImplementationLibrarySelection(final JSFProjectLibraryReference library) { + if (library != null) { + Iterator it = getJSFImplementationLibraries().iterator(); + JSFProjectLibraryReference crtjsflib = null; + while (it.hasNext()) { + crtjsflib = (JSFProjectLibraryReference) it.next(); + if (crtjsflib.getID().equals(library.getID())) { + crtjsflib.setSelected(true); + crtjsflib.setToBeDeployed(library.isCheckedToBeDeployed()); + } else { + crtjsflib.setSelected(false); + } + } + } + } + + /** + * Update the JSF library component libraries selection. + * + * @param libraries List + */ + public void setCurrentJSFComponentLibrarySelection(final List libraries) { + if (libraries != null) { + /* Reset all item in component library list to unselect first. + * Then, update each item in cmponent libraries to the provided list. + */ + setJSFLibrariesSelection(getJSFComponentLibraries(), false); + + Iterator it = libraries.iterator(); + JSFProjectLibraryReference crtItem; + JSFProjectLibraryReference srcItem = null; + while (it.hasNext()) { + crtItem = (JSFProjectLibraryReference) it.next(); + srcItem = jsfLibReg.getJSFLibryReferencebyID(crtItem.getID()); + + if (srcItem != null) { + srcItem.setSelected(true); + srcItem.setToBeDeployed(crtItem.isCheckedToBeDeployed()); + } + } + } + } + + /** + * To save current configuration of implementation and component libraries + * as project properties. + * + * @param project IProject + */ + public void saveData(final IProject project) { + // Instantiate one to make sure it is for a project. + JSFLibraryConfigProjectData data = new JSFLibraryConfigProjectData(project); + List implLibs = new ArrayList(); + implLibs.add(getCurrentJSFImplementationLibrarySelection()); + data.saveData(implLibs, getCurrentJSFComponentLibrarySelection()); + } + + /** + * Set selection state to given state to each libray in the collection. + * + * @param libs List + * @param state boolean + */ + private void setJSFLibrariesSelection(final List libs, final boolean state) { + Iterator it = libs.iterator(); + JSFProjectLibraryReference crtjsflib; + while (it.hasNext()) { + crtjsflib = (JSFProjectLibraryReference) it.next(); + crtjsflib.setSelected(state); + } + } + + /** + * Factory class to create new JSFLibraryConfigModel instances + */ + public static final class JSFLibraryConfigModelFactory { + /** + * To create a new instance of JSFLibraryConfigModel object. + * A NullPointerException is raised if source is null. + * + * @param source JSFLibraryConfiglModelSource + * @return JSFLibraryConfigModel + */ + public static JSFLibraryConfigModel createInstance(final JSFLibraryConfiglModelSource source) { + if (source == null) { + throw new NullPointerException(Messages.JSFLibraryConfigModel_Null_Data_Source); + } + return new JSFLibraryConfigModel(source); + } + } + +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfigModelAdapter.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfigModelAdapter.java deleted file mode 100644 index 0eb41532d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfigModelAdapter.java +++ /dev/null @@ -1,370 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Justin Chen - development check in - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryconfig; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.emf.common.util.EList; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry; - -/** - * To provide the following services. - * - * 1. return previously selected JSF libraries. - * 2. return JSF libraries collection. - * 3. update JSF libraries selections. - * 4. save JSF libraries selection as property resource. - * 5. return JSF Library Registry. - * 6. update project dependencies based on jsf library selections. - * 7. Return default jsf implementation library. - * 8. Add a JSF library. - * - * @author Justin Chen - Oracle - */ -public class JSFLibraryConfigModelAdapter { - private IProject project; - private JSFLibraryRegistry jsfLibReg; - private List colJSFImplLib; - private List colJSFCompLib; - private JSFLibraryConfigPersistData data; - private J2EEModuleDependencyDelegate modulesDep; - - /** - * Constructor. - * - * @param project - */ - public JSFLibraryConfigModelAdapter(IProject project) { - this.project = project; - this.jsfLibReg = JSFCorePlugin.getDefault().getJSFLibraryRegistry(); - this.data = new JSFLibraryConfigPersistData(this.project); - this.modulesDep = new J2EEModuleDependencyDelegate(this.project); - } - - /** - * Update project dependencies based on the model information. - * - */ - public void updateProjectDependencies() { - IProgressMonitor monitor = new NullProgressMonitor(); - - JSFLibraryDecorator newImplLib = getSelectedJSFImplLibrary(); - JSFLibraryDecorator preSelectedJSFImplLib = getSavedJSFImplementationLibrary(); - if (preSelectedJSFImplLib != null) { - modulesDep.removeProjectDependency(preSelectedJSFImplLib.getLibrary(), monitor); - modulesDep.addProjectDependency(newImplLib.getLibrary(), newImplLib.isCheckedToBeDeployed(), monitor); - } else { - modulesDep.addProjectDependency(newImplLib.getLibrary(), newImplLib.isCheckedToBeDeployed(), monitor); - } - - List ComponentLibs = getSavedJSFComponentLibraries(); - JSFLibraryDecorator prjJSFCompLib = null; - JSFLibrary compLib = null; - for (int i = 0; i < ComponentLibs.size(); i++) { - prjJSFCompLib = (JSFLibraryDecorator) ComponentLibs.get(i); - compLib = prjJSFCompLib.getLibrary(); - modulesDep.removeProjectDependency(compLib, monitor); - } - - List SelComponentLibs = getSelectedJSFCompLibraries(); - JSFLibraryDecorator jsfCompLibDctr = null; - for (int i = 0; i < SelComponentLibs.size(); i++) { - jsfCompLibDctr = (JSFLibraryDecorator) SelComponentLibs.get(i); - if (jsfCompLibDctr.isSelected()) { - modulesDep.addProjectDependency(jsfCompLibDctr.getLibrary(), jsfCompLibDctr.isCheckedToBeDeployed(), monitor); - } - } - } - - /** - * Delegate to JSFlibraryConfigPersistData and return previously selected - * JSF implementation library. - * - * The return library is used to remove dependencies selected previously. - * - * @return List - */ - public JSFLibraryDecorator getSavedJSFImplementationLibrary() { - return data.getSavedJSFImplLib(); - } - - /** - * Delegate to JSFlibraryConfigPersistData and return a list of selected JSF - * component libraries previously. - * - * The list is used to remove dependencies selected previously. - * - * @return List - */ - public List getSavedJSFComponentLibraries() { - return data.getSavedJSFCompLibs(); - } - - /** - * Return a list of all JSF implementation libraries in JSF Library Registry. - * - * This list is initialized w/ persistent JSF library reference - * configuration data and updated constantly to reflect current - * selections from UI. - * - * @return List - * @see org.eclipse.jst.jsf.ui.properties.IJSFLibraryDecoratorProvider#getProjectJSFImplementationLibraries() - */ - public List getJSFImplementationLibraries() { - if (colJSFImplLib == null) { - List list = new ArrayList(Collections.EMPTY_LIST); - - JSFLibraryDecorator savedImplLib = data.getSavedJSFImplLib(); - if (savedImplLib != null) { - list.add(savedImplLib); - } - colJSFImplLib = buildJSFLibraryDecoratorList(jsfLibReg - .getImplJSFLibraries(), list); - } - return colJSFImplLib; - } - - /** - * Return a list of all JSF implementation libraries in JSF Library Registry. - * - * This list is initialized w/ persistent JSF library reference - * configuration data and updated constantly to reflect current - * selections from UI. - * - * @return List - * @see org.eclipse.jst.jsf.ui.properties.IJSFLibraryDecoratorProvider#getProjectJSFComponentLibraries() - */ - public List getJSFComponentLibraries() { - if (colJSFCompLib == null) { - colJSFCompLib = buildJSFLibraryDecoratorList(jsfLibReg - .getNonImplJSFLibraries(), data.getSavedJSFCompLibs()); - } - return colJSFCompLib; - } - - /** - * Return currently selected JSF implementation library. - * - * @return JSFLibraryDecorator - */ - public JSFLibraryDecorator getSelectedJSFImplLibrary() { - List list = getSelectedJSFImplLibs(); - if (list.size() > 0) { - return (JSFLibraryDecorator) list.get(0); - } - return null; - } - - /** - * Return currently selected JSF component libraries. - * - * @return List - */ - public List getSelectedJSFCompLibraries() { - return getSelectedJSFCompLibs(); - } - - /** - * Add a JSF Library into collection for either - * JSF implementation libraries or component libraries. - * The decision is based on if a JSF library is an implementation. - * - * @param jsflib - * @param type - */ - public void addJSFLibrary(JSFLibraryDecorator jsflib) { - List list = null; - if (jsflib.isImplementation()) { - list = getJSFImplementationLibraries(); - } else { - list = getJSFComponentLibraries(); - } - list.add(jsflib); - } - - /** - * Update selected JSF implementation library from provided library. - * The provided jsf library needs to be added first if it is newly created. - * @param jsflib - */ - public void updateJSFImplementationLibrary(JSFLibraryDecorator jsflib) { - if (jsflib != null) { - Iterator it = getJSFImplementationLibraries().iterator(); - JSFLibraryDecorator crtjsflib = null; - while (it.hasNext()) { - crtjsflib = (JSFLibraryDecorator) it.next(); - if (crtjsflib.getID().equals(jsflib.getID())) { - crtjsflib.setSelected(true); - crtjsflib.setToBeDeployed(jsflib.isCheckedToBeDeployed()); - } else { - crtjsflib.setSelected(false); - } - } - } - } - - /** - * Update JSF library state in component libraries from given list. - * - * @param complibs - */ - public void updateJSFComponentLibraries(List complibs) { - if (complibs != null) { - setJSFLibrariesSelection(this.getJSFComponentLibraries(), false); - - Iterator it = complibs.iterator(); - JSFLibraryDecorator crtjsflib; - while (it.hasNext()) { - crtjsflib = (JSFLibraryDecorator) it.next(); - setJSFLibStateAsGivenTarget(getJSFComponentLibraries(), crtjsflib); - } - } - } - - /** - * Save JSF libraries selection and state as property resource. - */ - public void saveData() { - data.saveData(getSelectedJSFImplLibs(), getSelectedJSFCompLibs()); - - colJSFImplLib = null; - colJSFCompLib = null; - } - - /** - * Return default JSF implementation library defined in JSF Library Registry. - * Return null if no default implementation in registry. - */ - public JSFLibraryDecorator getDefaultJSFImplemntationLibrary() { - return data.getDefaultJSFImplLib(); - } - - /** - * Return the currently selected JSF implementation library - * as a single item collection - * - * @return List - */ - private List getSelectedJSFImplLibs() { - List list = new ArrayList(Collections.EMPTY_LIST); - - Iterator it = getJSFImplementationLibraries().iterator(); - JSFLibraryDecorator jsflib = null; - while (it.hasNext()) { - jsflib = (JSFLibraryDecorator) it.next(); - if (jsflib.isSelected()) { - list.add(jsflib); - break; // Only one selection. - } - } - return list; - } - - /** - * Return currently selected JSF component libraries. - * - * @return List - */ - private List getSelectedJSFCompLibs() { - List list = new ArrayList(Collections.EMPTY_LIST); - - Iterator it = getJSFComponentLibraries().iterator(); - JSFLibraryDecorator jsflib = null; - while (it.hasNext()) { - jsflib = (JSFLibraryDecorator) it.next(); - if (jsflib.isSelected()) { - list.add(jsflib); - } - } - return list; - } - - /** - * Set selection to true and isCheckedToBeDeployed as given target - * when JSF library ID matched. - * - * @param jsflibs - * @param target - */ - private void setJSFLibStateAsGivenTarget(List jsflibs, - JSFLibraryDecorator target) { - Iterator it = jsflibs.iterator(); - JSFLibraryDecorator crtjsflib = null; - while (it.hasNext()) { - crtjsflib = (JSFLibraryDecorator) it.next(); - if (crtjsflib.getID().equals(target.getID())) { - crtjsflib.setSelected(true); - crtjsflib.setToBeDeployed(target.isCheckedToBeDeployed()); - break; - } - } - } - - /** - * Set selection state to given state to each libray in the collection. - * - * @param libs - * @param state - */ - private void setJSFLibrariesSelection(List libs, boolean state) { - Iterator it = libs.iterator(); - JSFLibraryDecorator crtjsflib; - while (it.hasNext()) { - crtjsflib = (JSFLibraryDecorator) it.next(); - crtjsflib.setSelected(state); - } - } - - /** - * Helper method to construct a list of JSFLibraryDecorator - * - * @param wsJSFLibs - * @param pjJSFLibs - * @return List - */ - private List buildJSFLibraryDecoratorList(EList wsJSFLibs, List pjJSFLibs) { - List list = new ArrayList(Collections.EMPTY_LIST); - - JSFLibraryDecorator newPrjJSFLib; - JSFLibraryDecorator prjJSFLib = null; - JSFLibrary jsfLib; - Iterator it = wsJSFLibs.iterator(); - while (it.hasNext()) { - jsfLib = (JSFLibrary) it.next(); - - Iterator itPrjLibs = pjJSFLibs.iterator(); - boolean selected = false; - while (itPrjLibs.hasNext()) { - prjJSFLib = (JSFLibraryDecorator) itPrjLibs.next(); - selected = prjJSFLib.getID().equals(jsfLib.getID()); - if (selected) { - break; - } - } - if (selected && prjJSFLib != null) { - newPrjJSFLib = prjJSFLib; - } else { - newPrjJSFLib = new JSFLibraryDecorator(jsfLib, false, true); - } - list.add(newPrjJSFLib); - } - return list; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfigPersistData.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfigPersistData.java deleted file mode 100644 index 58a906399..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfigPersistData.java +++ /dev/null @@ -1,301 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Justin Chen - development check in - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryconfig; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.core.internal.Messages; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry; -import org.eclipse.jst.jsf.core.internal.project.facet.JSFUtils; -import org.eclipse.osgi.util.NLS; - -/** - * To save and retore JSF library reference configuration - * for <b>JSFLibraryConfigControl</b>. - * - * @author Justin Chen - Oracle - * - */ -public class JSFLibraryConfigPersistData { - /** - * Parsing delimnitor for elements in a tuple. - */ - final protected static String SPTR_TUPLE = ":"; //$NON-NLS-1$ - /** - * Parsing delimintor for tuples in a persistent property string. - */ - final protected static String EO_TUPLE = ";"; //$NON-NLS-1$ - - private IProject project; - private JSFLibraryRegistry jsfLibReg; - private JSFLibraryDecorator dftImplLib = null; - private JSFLibraryDecorator selJSFLibImpl = null; - private List selJSFLibComp = null; - - protected JSFLibraryConfigPersistData(IProject project) { - this.project = project; - this.jsfLibReg = JSFCorePlugin.getDefault().getJSFLibraryRegistry(); - - // Checked when object is instanciated instead of at method call - if (!isProjectFirstCreated()) { - VerifySavedLibAvailability(); - } - } - - /** - * Return default JSF implementation library - * if there is one defined in JSF library registry. - * - * @return JSFLibraryDecorator dftImplLib - */ - protected JSFLibraryDecorator getDefaultJSFImplLib() { - if (dftImplLib == null) { - if (jsfLibReg != null) { - JSFLibrary jsfLib = jsfLibReg.getDefaultImplementation(); - if (jsfLib != null) { - dftImplLib = new JSFLibraryDecorator(jsfLib, true, true); - } - } - } - return dftImplLib; - } - - /** - * Return previoulsly selected JSF implementation library. - * The default JSF implementation library is returned if - * there is one defined in registry. - * Otheriwise, null is returned. - * - * @return JSFLibraryDecorator - */ - protected JSFLibraryDecorator getSavedJSFImplLib() { - try { - if (!isProjectFirstCreated()) { - if ( selJSFLibImpl == null ) { - String strImplLibs = ((IResource)project).getPersistentProperty(new QualifiedName("", JSFUtils.PP_JSF_IMPLEMENTATION_LIBRARIES)); - selJSFLibImpl = getJSFImplLibfromPersistentProperties(getTuples(strImplLibs)); - // project created but no JSF facet installed yet. - if (selJSFLibImpl == null) { - selJSFLibImpl = getDefaultJSFImplLib(); - } - } - } else { - selJSFLibImpl = getDefaultJSFImplLib(); - } - } catch (CoreException e) { - JSFCorePlugin.getDefault().getMsgLogger().log(e); - } - return selJSFLibImpl; - } - - - /** - * Return the collection of selected JSF component libraries. - * An empty List is returned if no JSF comp libs saved or - * the project is newly created. - * - * @return List - */ - protected List getSavedJSFCompLibs() { - try { - if (!isProjectFirstCreated()) { - if ( selJSFLibComp == null ) { - selJSFLibComp = new ArrayList(Collections.EMPTY_LIST); - String strCompLibs = ((IResource)project).getPersistentProperty(new QualifiedName("", JSFUtils.PP_JSF_COMPONENT_LIBRARIES)); - getJSFCompLibsfromPersistentProperties(getTuples(strCompLibs), selJSFLibComp); - } - } else { - selJSFLibComp = new ArrayList(Collections.EMPTY_LIST); - } - } catch (CoreException e) { - JSFCorePlugin.getDefault().getMsgLogger().log(e); - } - return selJSFLibComp; - } - - /** - * To save configuration data as a project resource. - * - * @param selJSFLibImpl - * @param selJSFLibComp - */ - protected void saveData(List selJSFLibImpl, List selJSFLibComp) { - try { - ((IResource)project).setPersistentProperty(new QualifiedName("", JSFUtils.PP_JSF_IMPLEMENTATION_LIBRARIES), generatePersistString(selJSFLibImpl)); - ((IResource)project).setPersistentProperty(new QualifiedName("", JSFUtils.PP_JSF_COMPONENT_LIBRARIES), generatePersistString(selJSFLibComp)); - - /** - * Flush the selection so that they are reconstructed from - * persistent properties when getSavedJSFImplLib and getSavedJSFCompLibs - * called next time. - */ - this.selJSFLibImpl = null; - this.selJSFLibComp = null; - - } catch (CoreException e) { - JSFCorePlugin.getDefault().getMsgLogger().log(e); - } - } - - - /** - * Check if a project is just created by inspecting persistent properties - * if there is any. ? - */ - private boolean isProjectFirstCreated() { - boolean isNew = false; - try { - String strImplLibs = ((IResource)project).getPersistentProperty(new QualifiedName("", JSFUtils.PP_JSF_IMPLEMENTATION_LIBRARIES)); - } catch (CoreException e) { - isNew = true; - } - return isNew; - } - - private void VerifySavedLibAvailability() { - try { - String strImplLibs = ((IResource)project).getPersistentProperty(new QualifiedName("", JSFUtils.PP_JSF_IMPLEMENTATION_LIBRARIES)); - String strCompLibs = ((IResource)project).getPersistentProperty(new QualifiedName("", JSFUtils.PP_JSF_COMPONENT_LIBRARIES)); - - logMissingLib(getTuples(strImplLibs), true); - logMissingLib(getTuples(strCompLibs), false); - - } catch (CoreException e) { - JSFCorePlugin.getDefault().getMsgLogger().log(e); - } - } - - private void logMissingLib(List jsfLibTuples, boolean isVerifyImpl) { - if (jsfLibReg != null) { - Iterator itTuple = jsfLibTuples.iterator(); - while(itTuple.hasNext()) { - Tuple tuple = (Tuple)itTuple.next(); - JSFLibrary jsfLib = jsfLibReg.getJSFLibraryByID(tuple.ID); - // Info logged when saved JSF lib is removed from registry. - // One log entry is created for each missing library. - if (jsfLib == null) { - String prjName = project.getName(); - String msg = (isVerifyImpl) ? - Messages.JSFLibraryConfigPersistData_SAVED_IMPLLIB_NOT_FOUND : - Messages.JSFLibraryConfigPersistData_SAVED_COMPLIB_NOT_FOUND; - JSFCorePlugin.log(IStatus.INFO, NLS.bind(msg, prjName)); - } - } - } - } - - private JSFLibraryDecorator getJSFImplLibfromPersistentProperties(List jsfLibTuples) { - if (jsfLibReg != null) { - Iterator itTuple = jsfLibTuples.iterator(); - - while(itTuple.hasNext()) { - Tuple tuple = (Tuple)itTuple.next(); - JSFLibrary jsfLib = jsfLibReg.getJSFLibraryByID(tuple.ID); - if (jsfLib != null) { - return new JSFLibraryDecorator(jsfLib, tuple.selected, tuple.deploy); - } - } - } - return null; - } - - private void getJSFCompLibsfromPersistentProperties(List jsfLibTuples, List JSFCompLibs) { - if (jsfLibReg != null) { - Iterator itTuple = jsfLibTuples.iterator(); - while(itTuple.hasNext()) { - Tuple tuple = (Tuple)itTuple.next(); - - JSFLibrary jsfLib = jsfLibReg.getJSFLibraryByID(tuple.ID); - if (jsfLib != null) { - JSFLibraryDecorator newJSFLibDcrt = new JSFLibraryDecorator(jsfLib, tuple.selected, tuple.deploy); - JSFCompLibs.add(newJSFLibDcrt); - } - } - } - } - - private String generatePersistString(List list) { - JSFLibraryDecorator jsfLibItem; - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < list.size(); i++) { - jsfLibItem = (JSFLibraryDecorator)list.get(i); - sb = sb.append(jsfLibItem.generatePersistString()); - sb.append(JSFLibraryConfigPersistData.EO_TUPLE); - } - return sb.toString(); - } - - private List getTuples(String strJSFLibs) { - List list = new ArrayList(Collections.EMPTY_LIST); - - if (strJSFLibs != null) { - String patternStr = JSFLibraryConfigPersistData.EO_TUPLE; - String[] fields = strJSFLibs.split(patternStr); - if (strJSFLibs.length() > 0) { - Tuple tuple; - for (int i = 0; i < fields.length; i++) { - tuple = new Tuple(fields[i]); - list.add(tuple); - } - } - } - return list; - } - - /** - * Inner class for parsing persistent property resource. - * - * Note: Take out selected attribute since it is not needed. - * And, to provide a way to migrating earlier - * project. - */ - class Tuple { - private String ID; - private boolean selected = false; - private boolean deploy = true; - - Tuple(String ID, boolean selected, boolean deploy) { - this.ID = ID; - this.selected = selected; - this.deploy = deploy; - } - // parse tuple = ID:selected:deploy - Tuple(String tuple) { - String[] fields = tuple.split(JSFLibraryConfigPersistData.SPTR_TUPLE); - this.ID = fields[0]; - this.selected = Boolean.valueOf(fields[1]).booleanValue(); - this.deploy = Boolean.valueOf(fields[2]).booleanValue(); - } - - String getID() { - return ID; - } - - boolean isSelected() { - return selected; - } - - boolean needDeploy() { - return deploy; - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfigProjectData.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfigProjectData.java new file mode 100644 index 000000000..5ad8b4034 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfigProjectData.java @@ -0,0 +1,283 @@ +/******************************************************************************* + * Copyright (c) 2006 Oracle Corporation. + * 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: Oracle + *******************************************************************************/ +package org.eclipse.jst.jsf.core.internal.jsflibraryconfig; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; +import org.eclipse.jst.jsf.core.internal.Messages; +import org.eclipse.jst.jsf.core.internal.project.facet.JSFUtils; +import org.eclipse.osgi.util.NLS; + +/** + * To construct implementation library and component libraries + * from persistent project properties as saved libraries. + * + * @author Justin Chen - Oracle + */ +public class JSFLibraryConfigProjectData implements JSFLibraryConfiglModelSource { + final static private String QUALIFIEDNAME = "org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryConfigProjectData"; + /** + * Parsing delimnitor for elements in a tuple. + */ + final protected static String SPTR_TUPLE = ":"; //$NON-NLS-1$ + /** + * Parsing delimintor for tuples in a persistent property string. + */ + final protected static String EO_TUPLE = ";"; //$NON-NLS-1$ + + final private IProject project; + final private JSFLibraryRegistryUtil jsfLibReg; + private JSFProjectLibraryReference selJSFLibImpl = null; + private List selJSFLibComp = null; + + /** + * Constructor + * @param project + */ + public JSFLibraryConfigProjectData(IProject project) { + this.project = project; + this.jsfLibReg = JSFLibraryRegistryUtil.getInstance(); + + /* logging message when object is instantiated instead of at method call to + * reduce log entries. + */ + if (!isProjectFirstCreated()) { + verifySavedLibAvailability(); + } + } + + /** + * Return the previously selected JSF implementation library from project persistent properties. + * Return null if none exists. + * + * @return selJSFLibImpl JSFLibraryDecorator + */ + public JSFProjectLibraryReference getJSFImplementationLibrary() { + try { + if (!isProjectFirstCreated() && + selJSFLibImpl == null ) { + String strImplLibs = ((IResource)project).getPersistentProperty(new QualifiedName(QUALIFIEDNAME, + JSFUtils.PP_JSF_IMPLEMENTATION_LIBRARIES)); + selJSFLibImpl = getJSFImplLibfromPersistentProperties(getTuples(strImplLibs)); + } + } catch (CoreException e) { + JSFCorePlugin.getDefault().getMsgLogger().log(e); + } + return selJSFLibImpl; + } + + /** + * Return the selected JSF component libraries from project persistent properties. + * An empty List is returned if no JSF component libraries were saved or + * if the project is newly created. + * + * @return selJSFLibComp List + */ + public List getJSFComponentLibraries() { + try { + if (!isProjectFirstCreated()) { + if ( selJSFLibComp == null ) { + selJSFLibComp = new ArrayList(); + + String strCompLibs = ((IResource)project).getPersistentProperty(new QualifiedName(QUALIFIEDNAME, JSFUtils.PP_JSF_COMPONENT_LIBRARIES)); + List savedList = getTuples(strCompLibs); + + Iterator it = savedList.iterator(); + Tuple crtTuple = null; + JSFProjectLibraryReference srcItem = null; + while (it.hasNext()) { + crtTuple = (Tuple) it.next(); + + srcItem = jsfLibReg.getJSFLibryReferencebyID(crtTuple.getID()); + if (srcItem != null) { + selJSFLibComp.add( new JSFProjectLibraryReference(srcItem.getLibrary(), + true, + crtTuple.needDeploy()) ); + } /*else { + // already logged a message for a missing library + }*/ + } + } + } else { + selJSFLibComp = new ArrayList(0); + } + } catch (CoreException e) { + JSFCorePlugin.getDefault().getMsgLogger().log(e); + } + return selJSFLibComp; + } + + /** + * To save configuration data as a project persistent properties. + * + * @param implementation + * @param component + */ + void saveData(final List implementation, final List component) { + try { + ((IResource)project).setPersistentProperty(new QualifiedName(QUALIFIEDNAME, JSFUtils.PP_JSF_IMPLEMENTATION_LIBRARIES), generatePersistString(implementation)); + ((IResource)project).setPersistentProperty(new QualifiedName(QUALIFIEDNAME, JSFUtils.PP_JSF_COMPONENT_LIBRARIES), generatePersistString(component)); + + /* Flush the selection so that they can be reconstructed from + * persistent properties when getSavedJSFImplLib and getSavedJSFCompLibs + * called next time. + */ + selJSFLibImpl = null; + selJSFLibComp = null; + + } catch (CoreException e) { + JSFCorePlugin.getDefault().getMsgLogger().log(e); + } + } + + /** + * Check if a project is just created by inspecting persistent properties + * if there is any. ? + */ + private boolean isProjectFirstCreated() { + boolean isNew = false; + try { + ((IResource)project).getPersistentProperty(new QualifiedName(QUALIFIEDNAME, + JSFUtils.PP_JSF_IMPLEMENTATION_LIBRARIES)); + } catch (CoreException e) { + isNew = true; + } + return isNew; + } + + private void verifySavedLibAvailability() { + try { + String strImplLibs = ((IResource)project).getPersistentProperty(new QualifiedName(QUALIFIEDNAME, JSFUtils.PP_JSF_IMPLEMENTATION_LIBRARIES)); + String strCompLibs = ((IResource)project).getPersistentProperty(new QualifiedName(QUALIFIEDNAME, JSFUtils.PP_JSF_COMPONENT_LIBRARIES)); + + logMissingLib(getTuples(strImplLibs), true); + logMissingLib(getTuples(strCompLibs), false); + + } catch (CoreException e) { + JSFCorePlugin.getDefault().getMsgLogger().log(e); + } + } + + private void logMissingLib(final List jsfLibTuples, final boolean isVerifyImpl) { + if (jsfLibReg != null) { + Iterator itTuple = jsfLibTuples.iterator(); + while(itTuple.hasNext()) { + Tuple tuple = (Tuple)itTuple.next(); + JSFProjectLibraryReference jsfLib = jsfLibReg.getJSFLibryReferencebyID(tuple.getID()); + /* Information logged when saved JSF lib is removed from registry. + * One log entry is created for each missing library. + */ + if (jsfLib == null) { + String prjName = project.getName(); + String msg = (isVerifyImpl) ? + Messages.JSFLibraryConfigPersistData_SAVED_IMPLLIB_NOT_FOUND : + Messages.JSFLibraryConfigPersistData_SAVED_COMPLIB_NOT_FOUND; + JSFCorePlugin.log(IStatus.INFO, NLS.bind(msg, prjName)); + } + } + } + } + + private JSFProjectLibraryReference getJSFImplLibfromPersistentProperties(final List jsfLibTuples) { + if (jsfLibReg != null) { + Tuple tuple = null; + JSFProjectLibraryReference lib = null; + Iterator itTuple = jsfLibTuples.iterator(); + while(itTuple.hasNext()) { + tuple = (Tuple) itTuple.next(); + lib = jsfLibReg.getJSFLibryReferencebyID(tuple.id); + if (lib != null) { + return new JSFProjectLibraryReference(lib.getLibrary(), + tuple.selected, + tuple.deploy); + } /*else { + // already logged a message for a missing library + }*/ + } + } + return null; + } + + private String generatePersistString(List list) { + JSFProjectLibraryReference jsfLibItem; + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < list.size(); i++) { + jsfLibItem = (JSFProjectLibraryReference)list.get(i); + sb = sb.append(jsfLibItem.generatePersistString()); + sb.append(JSFLibraryConfigProjectData.EO_TUPLE); + } + return sb.toString(); + } + + private List getTuples(String strJSFLibs) { + List list = new ArrayList(); + + if (strJSFLibs != null) { + String patternStr = JSFLibraryConfigProjectData.EO_TUPLE; + String[] fields = strJSFLibs.split(patternStr); + if (strJSFLibs.length() > 0) { + Tuple tuple; + for (int i = 0; i < fields.length; i++) { + tuple = new Tuple(fields[i]); + list.add(tuple); + } + } + } + return list; + } + + /** + * Inner class for parsing project persistent properties. + * + * To Do: Take out selected attribute since it is not needed. + * Add the library name as an attribute. + * Provide code path to migrate earlier project. + */ + private static class Tuple { + final private String id; + final private boolean selected; + final private boolean deploy; + + Tuple(String id, boolean selected, boolean deploy) { + this.id = id; + this.selected = selected; + this.deploy = deploy; + } + // parse tuple = ID:selected:deploy + Tuple(String tuple) { + String[] fields = tuple.split(JSFLibraryConfigProjectData.SPTR_TUPLE); + this.id = fields[0]; + this.selected = Boolean.valueOf(fields[1]).booleanValue(); + this.deploy = Boolean.valueOf(fields[2]).booleanValue(); + } + + String getID() { + return id; + } + + boolean isSelected() { + return selected; + } + + boolean needDeploy() { + return deploy; + } + } + +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfiglModelSource.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfiglModelSource.java new file mode 100644 index 000000000..1413571d3 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryConfiglModelSource.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2006 Oracle Corporation. + * 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: + * Justin Chen + *******************************************************************************/ +package org.eclipse.jst.jsf.core.internal.jsflibraryconfig; + +import java.util.List; + +/** + * Interface for data source to instanciate a <b>JSFLibraryConfigModel</b> object. + * + * @author Justin Chen - Oracle + */ +public interface JSFLibraryConfiglModelSource { + /** + * Return a saved JSF implementation library. + * Depends on the model source, it could be sticky values from DialogSettings or + * project property values. + * + * A null could be returned when creating first web project in a new workspace. + * + * @return JSFProjectLibraryReference + */ + public JSFProjectLibraryReference getJSFImplementationLibrary(); + + /** + * Return a list of saved JSF component libraries. + * Otheriwse, return an empty list. + * + * @return List + */ + public List getJSFComponentLibraries(); +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryDecorator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryDecorator.java deleted file mode 100644 index 68ef90771..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryDecorator.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Justin Chen - development check in - *******************************************************************************/ -package org.eclipse.jst.jsf.core.internal.jsflibraryconfig; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryImpl; - -/** - * Additional functionality to check if a JSF libary - * is selected and needs to be deloyed. - * - * @author Justin Chen - Oracle - */ -public class JSFLibraryDecorator extends JSFLibraryImpl { - private JSFLibrary jsfLib; - private boolean check4Deploy; // Initialized from default in workspace - private boolean isSelected = false; // selected for project - - /** - * @param jsfLib - * @param selected - * @param deploy - */ - public JSFLibraryDecorator(JSFLibrary jsfLib, boolean selected, boolean deploy) { - this.jsfLib = jsfLib; - this.isSelected = selected; - this.check4Deploy = deploy; - } - - /** - * @return JSFLibrary - */ - public JSFLibrary getLibrary() { - return jsfLib; - } - - /** - * @param deploy - */ - public void setToBeDeployed(boolean deploy) { - this.check4Deploy = deploy; - } - - /** - * Return true if the JSF library needs to be deployed to server. - * Otheriwse, return false. - * - * The value is initialized from default value defined in JSF Library Registry. - * - * @return boolean - */ - public boolean isCheckedToBeDeployed() { - return check4Deploy; - } - - /** - * Set the JSF library to be selected. - * - * @param selected - */ - public void setSelected(boolean selected) { - this.isSelected = selected; - } - - /** - * Return true if the JSF library is referenced - * for the project. Otherwise, return false. - * @return boolean - */ - public boolean isSelected() { - return isSelected; - } - - /** - * @return String - */ - protected String generatePersistString() { - String sptr = JSFLibraryConfigPersistData.SPTR_TUPLE; - return this.getID() + sptr + String.valueOf(this.isSelected()) + - sptr + - String.valueOf(this.isCheckedToBeDeployed()); - } - - public String getID() { - return jsfLib.getID(); - } - - public String getName() { - return jsfLib.getName(); - } - - public boolean isImplementation() { - return jsfLib.isImplementation(); - } - - public EList getArchiveFiles() { - return jsfLib.getArchiveFiles(); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryRegistryUtil.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryRegistryUtil.java new file mode 100644 index 000000000..0207fe808 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFLibraryRegistryUtil.java @@ -0,0 +1,238 @@ +/******************************************************************************* + * Copyright (c) 2006 Oracle Corporation. + * 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: Oracle + *******************************************************************************/ +package org.eclipse.jst.jsf.core.internal.jsflibraryconfig; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; +import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile; +import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary; +import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry; + +/** + * A singleton maintains lists of implementation and component libraries + * in registry. + * + * Each item in the lists contains a workingcopy of a JSF library and + * decorates with usage information such selection and deployment. + * + * The lists are updated when there are changes in JSF library registry. + * + * @author Justin Chen - Oracle + */ +public class JSFLibraryRegistryUtil { + private static JSFLibraryRegistryUtil instance = null; + final private JSFLibraryRegistry jsfLibReg; + private List implLibs = null; + private List compLibs = null; + + /** + * Private constructor + */ + private JSFLibraryRegistryUtil() { + jsfLibReg = JSFCorePlugin.getDefault().getJSFLibraryRegistry(); + } + + /** + * Return the singleton instance of JSFLibraryRegistryUtil. + * + * @return JSFLibraryRegistryUtil + */ + public static JSFLibraryRegistryUtil getInstance() { + if ( instance == null ) { + instance = new JSFLibraryRegistryUtil(); + } + return instance; + } + + /** + * Return the JSFLibraryRegistry instance. + * + * @return jsfLibReg JSFLibraryRegistry + */ + public JSFLibraryRegistry getJSFLibraryRegistry() { + return jsfLibReg; + } + + /** + * Get the default JSF implementation library instance. + * A null is returned when there is no libraries in the registry. + * + * @return JSFLibraryDecorator + */ + public JSFProjectLibraryReference getDefaultJSFImplementationLibrary() { + JSFLibrary dftImplLib = jsfLibReg.getDefaultImplementation(); + + return ((dftImplLib != null) ? + getJSFLibryReferencebyID(dftImplLib.getID()) : + null); + } + + /** + * Get the working copy of JSF implementation libraries. + * The list is updated when there are changes in registry. + * + * @return List + */ + List getJSFImplementationLibraries() { + if (implLibs == null) { + implLibs = wrapJSFLibraries(jsfLibReg.getImplJSFLibraries()); + } else { + if (implLibs.size() != jsfLibReg.getImplJSFLibraries().size() || + isAnyLibraryChanged(implLibs)) { + implLibs.clear(); + implLibs = wrapJSFLibraries(jsfLibReg.getImplJSFLibraries()); + } + } + return implLibs; + } + + /** + * Get the working copy of JSF component libraries. + * The list is updated when there are changes in registry. + * + * @return List + */ + List getJSFComponentLibraries() { + if (compLibs == null) { + compLibs = wrapJSFLibraries(jsfLibReg.getNonImplJSFLibraries()); + } else { + if (compLibs.size() != jsfLibReg.getNonImplJSFLibraries().size() || + isAnyLibraryChanged(compLibs)) { + compLibs.clear(); + compLibs = wrapJSFLibraries(jsfLibReg.getNonImplJSFLibraries()); + } + } + return compLibs; + } + + /** + * Get the JSFLibraryDecorator object from the provided ID. + * A null is returned no library matches the ID. + * + * @param id String + * @return JSFLibraryDecorator + */ + public JSFProjectLibraryReference getJSFLibryReferencebyID(final String id) { + Iterator it = getJSFImplementationLibraries().iterator(); + JSFProjectLibraryReference crtItem = null; + + // search implementation libraries + while(it.hasNext()) { + crtItem = (JSFProjectLibraryReference)it.next(); + if (id.equals(crtItem.getID())) { + return crtItem; + } + } + // search component libraries + it = getJSFComponentLibraries().iterator(); + while(it.hasNext()) { + crtItem = (JSFProjectLibraryReference)it.next(); + if (id.equals(crtItem.getID())) { + return crtItem; + } + } + return null; + } + + /** + * Add a JSF Library into collection for either + * JSF implementation libraries or component libraries. + * The decision is based on if a JSF library is an implementation. + * + * @param library JSFProjectLibraryReference + */ + public void addJSFLibrary(final JSFProjectLibraryReference library) { + // Library is added only if it does not exist in registry + if (library != null && jsfLibReg.getJSFLibraryByID(library.getID()) == null) { + // Add the library working copy into workspace registry. + JSFLibrary jsfLib = library.getLibrary(); + jsfLibReg.addJSFLibrary(jsfLib.getWorkingCopy()); + + // Add library into the collection depends on its type. + List list = (library.isImplementation() ? + getJSFImplementationLibraries() : + getJSFComponentLibraries()); + list.add(library); + } + } + + private List wrapJSFLibraries(final EList libs) { + List list = new ArrayList(); + if (libs != null) { + JSFLibrary jsfLib; + JSFProjectLibraryReference jsfLibDctr; + + Iterator it = libs.iterator(); + while (it.hasNext()) { + jsfLib = (JSFLibrary) it.next(); + // Set unselected and undeployed initially. + jsfLibDctr = new JSFProjectLibraryReference(jsfLib.getWorkingCopy(), + false, + false); + list.add(jsfLibDctr); + } + } + return list; + } + + private boolean isAnyLibraryChanged(final List list) { + Iterator it = list.iterator(); + JSFProjectLibraryReference wclib = null; // working copy library + JSFLibrary lib = null; + + while(it.hasNext()) { + wclib = (JSFProjectLibraryReference)it.next(); + lib = getJSFLibraryRegistry().getJSFLibraryByID(wclib.getID()); + if (lib == null) { // removed. Hence, changed. + return true; + } + if (wclib.getArchiveFiles().size() != + lib.getArchiveFiles().size()) { // Archives changed.. + return true; + } + if (isAnyArchiveFileChanged(wclib.getArchiveFiles(), + lib.getArchiveFiles())) { // Check archive file changes. I.e., name and location + return true; + } + } + return false; + } + + private boolean isAnyArchiveFileChanged(final EList source, EList target) { + ArchiveFile arSrc = null; + Iterator it = source.iterator(); + while (it.hasNext()) { + arSrc = (ArchiveFile) it.next(); + if (!findMatchedArchive(arSrc, target)) { + return true; + } + } + return false; + } + + private boolean findMatchedArchive(ArchiveFile source, EList list) { + ArchiveFile target = null; + Iterator it = list.iterator(); + while (it.hasNext()) { + target = (ArchiveFile) it.next(); + if (target.getName().equals(source.getName()) && + target.getResolvedSourceLocation().equals(source.getSourceLocation())) { + return true; + } + } + return false; + } + +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFProjectLibraryReference.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFProjectLibraryReference.java new file mode 100644 index 000000000..9d4b481ca --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/jsflibraryconfig/JSFProjectLibraryReference.java @@ -0,0 +1,137 @@ +/******************************************************************************* + * Copyright (c) 2006 Oracle Corporation. + * 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: Oracle + *******************************************************************************/ +package org.eclipse.jst.jsf.core.internal.jsflibraryconfig; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary; + +/** + * Attach additonal attributes such as selection and deployment + * to a JSF library when it is referenced by a project. + * + * @author Justin Chen - Oracle + */ +public class JSFProjectLibraryReference { + final private JSFLibrary jsfLib; + private boolean check4Deploy; // Initialized from default in workspace + private boolean selected; // selected for project + + /** + * Constructor + * @param jsfLib JSFLibrary instance embedded inside. + * @param selected boolean true if selected, otherwise, not selected. + * @param deploy boolean true if needs to be deployed, otherwise, won't be deployed. + */ + public JSFProjectLibraryReference(JSFLibrary jsfLib, boolean selected, boolean deploy) { + this.jsfLib = jsfLib; + this.selected = selected; + this.check4Deploy = deploy; + } + + /** + * Return the embedded JSFLibrary instance. + * + * @return jsfLib JSFLibrary + */ + public JSFLibrary getLibrary() { + return jsfLib; + } + + /** + * Set the to be deployed flag. + * + * @param deploy boolean + */ + public void setToBeDeployed(final boolean deploy) { + check4Deploy = deploy; + } + + /** + * Return true if the JSF library needs to be deployed. + * Otheriwse, return false. + * + * @return boolean + */ + public boolean isCheckedToBeDeployed() { + return check4Deploy; + } + + /** + * Set the selected attribute to a JSFLibraryReference object. + * + * @param selected boolean + */ + public void setSelected(final boolean selected) { + this.selected = selected; + } + + /** + * Return true if the JSF library is referenced by a project. + * Otherwise, return false. + * + * @return selected boolean + */ + public boolean isSelected() { + return selected; + } + + /** + * To generate a string that represents the JSFLibraryRefernce + * object for persistence. + * + * @return String + */ + protected String generatePersistString() { + return (getID() + JSFLibraryConfigProjectData.SPTR_TUPLE + + String.valueOf(isSelected()) + JSFLibraryConfigProjectData.SPTR_TUPLE + + String.valueOf(isCheckedToBeDeployed())); + } + + /** + * Helper method to return the library ID from the embedded + * JSFLibrary instance. + * + * @return id String + */ + public String getID() { + return jsfLib.getID(); + } + + /** + * Helper method to return the library name from the embedded + * JSFLibrary instance. + * + * @return name String + */ + public String getName() { + return jsfLib.getName(); + } + + /** + * Return true if the embedded JSF library instance i implementation. + * Otherwise, return false. + * + * @return boolean + */ + public boolean isImplementation() { + return jsfLib.isImplementation(); + } + + /** + * Help method to return a list of Archive files from + * the embedded JSFLibrary instance. + * + * @return boolean + */ + public EList getArchiveFiles() { + return jsfLib.getArchiveFiles(); + } + +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/messages.properties b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/messages.properties index 0ac3de3aa..ee8240357 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/messages.properties +++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/messages.properties @@ -13,6 +13,7 @@ JSFLibraryRegistry_ErrorCreatingURL=Error creating URL for JSF Library Registry JSFLibraryRegistry_NoLoadCreatingNew=Could not load JSF Library Registry; creating new registry JSFLibraryRegistry_ErrorSaving=Error saving JSF Library Registry JSFLibraryRegistry_DEFAULT_IMPL_LABEL=<Default> +JSFLibraryConfigModel_Null_Data_Source=Data Source is not provided. JSFLibraryRegistry_ErrorLoadingFromExtPt=Error while loading JSF Libaries from extension points JSFFacetInstallDataModelProvider_ValidateServletName=Specify a servlet name to use @@ -25,6 +26,7 @@ JSFFacetInstallDataModelProvider_ValidateConfigFileRelative1=Configuration file JSFFacetInstallDataModelProvider_ValidateConfigFileRelative2=Configuration file must be located in the project's {0} folder JSFFacetInstallDataModelProvider_ValidateConfigFileXML=JSF configuration file must be an XML file JSFFacetInstallDataModelProvider_ValidateConfigFileSlashes=Configuration file path must not contain "\\"s. Use "/" instead. +JSFLibCfgDialogSettingData_Sticky_Component_Lib_Not_Exist=A sticky component library selection no longer exists. ArchiveFileImpl_CannotCopyFile=Cannot copy file ArchiveFileImpl_CannotCloseFile=Cannot close file diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetInstallDataModelProvider.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetInstallDataModelProvider.java index be7a76d00..743b21845 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetInstallDataModelProvider.java +++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetInstallDataModelProvider.java @@ -12,7 +12,6 @@ package org.eclipse.jst.jsf.core.internal.project.facet; import java.util.ArrayList; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.Set; @@ -24,7 +23,7 @@ import org.eclipse.core.runtime.Path; import org.eclipse.jst.j2ee.web.componentcore.util.WebArtifactEdit; import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; import org.eclipse.jst.jsf.core.internal.Messages; -import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryDecorator; +import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFProjectLibraryReference; import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary; import org.eclipse.osgi.util.NLS; import org.eclipse.wst.common.componentcore.datamodel.FacetInstallDataModelProvider; @@ -79,7 +78,7 @@ public class JSFFacetInstallDataModelProvider extends } else if (propertyName.equals(WEBCONTENT_DIR)){ return "WebContent"; //not sure I need this } else if (propertyName.equals(COMPONENT_LIBRARIES)) { - return getDefaultJSFComponentLibraries(); + return new ArrayList(0); } else if (propertyName.equals(IMPLEMENTATION_LIBRARIES)) { return getDefaultJSFImplementationLibraries(); } else if (propertyName.equals(DEFAULT_IMPLEMENTATION_LIBRARY)) { @@ -151,7 +150,6 @@ public class JSFFacetInstallDataModelProvider extends // //skip validation here // return OK_STATUS; // } - if (passedPath.getDevice() != null) { errorMessage = NLS.bind( Messages.JSFFacetInstallDataModelProvider_ValidateConfigFileRelative1, @@ -189,7 +187,7 @@ public class JSFFacetInstallDataModelProvider extends private IPath getWebContentFolder() { //One can get here 2 ways: //if web app exists and user is adding a facet, or - // if creating a new web app. + // if creating a new web app. if (webContentPath != null) return webContentPath; @@ -215,38 +213,21 @@ public class JSFFacetInstallDataModelProvider extends } } - - // Is this called at all? - private List getDefaultJSFComponentLibraries() { - List list = new ArrayList(Collections.EMPTY_LIST); - JSFLibraryDecorator prjJSFLib = null; - JSFLibrary jsfLib = null; - if (JSFCorePlugin.getDefault().getJSFLibraryRegistry() != null) { - Iterator it = JSFCorePlugin.getDefault().getJSFLibraryRegistry().getNonImplJSFLibraries().iterator(); - while (it.hasNext()) { - jsfLib = (JSFLibrary)it.next(); - prjJSFLib = new JSFLibraryDecorator(jsfLib, true, true); - list.add(prjJSFLib); - } - } - return list; - } - + private List getDefaultJSFImplementationLibraries() { - List list = new ArrayList(Collections.EMPTY_LIST); - + List list = new ArrayList(); if (JSFCorePlugin.getDefault().getJSFLibraryRegistry() != null) { JSFLibrary jsfLib = JSFCorePlugin.getDefault().getJSFLibraryRegistry().getDefaultImplementation(); - JSFLibraryDecorator prjJSFLib = new JSFLibraryDecorator(jsfLib, true, true); + JSFProjectLibraryReference prjJSFLib = new JSFProjectLibraryReference(jsfLib, true, true); list.add(prjJSFLib); } return list; } - private JSFLibraryDecorator getDefaultImplementationLibrary() { + private JSFProjectLibraryReference getDefaultImplementationLibrary() { if (JSFCorePlugin.getDefault().getJSFLibraryRegistry() != null) { JSFLibrary jsfLib = JSFCorePlugin.getDefault().getJSFLibraryRegistry().getDefaultImplementation(); - return new JSFLibraryDecorator(jsfLib, true, true); + return new JSFProjectLibraryReference(jsfLib, true, true); } return null; } diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetInstallDelegate.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetInstallDelegate.java index 050299190..516201ba5 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetInstallDelegate.java +++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetInstallDelegate.java @@ -21,16 +21,16 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Path; -import org.eclipse.jface.window.Window; import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; import org.eclipse.jst.j2ee.web.componentcore.util.WebArtifactEdit; import org.eclipse.jst.j2ee.webapplication.Servlet; import org.eclipse.jst.j2ee.webapplication.WebApp; import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.J2EEModuleDependencyDelegate; -import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryConfigModelAdapter; -import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryDecorator; -import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary; +import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryConfiglModelSource; +import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryConfigProjectData; +import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryConfigModel; +import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFProjectLibraryReference; import org.eclipse.wst.common.frameworks.datamodel.IDataModel; import org.eclipse.wst.common.project.facet.core.IDelegate; import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; @@ -74,21 +74,19 @@ public class JSFFacetInstallDelegate implements IDelegate { } // Create JSF App Model // tbd - - // Add JSF Impls to WEB-INF/lib - //deployJSFLibraries(project, config, monitor); // Update project dependencies and save configiuration data java.util.List implLibs = (List) config.getProperty(IJSFFacetInstallDataModelProperties.IMPLEMENTATION_LIBRARIES); java.util.List compLibs = (List) config.getProperty(IJSFFacetInstallDataModelProperties.COMPONENT_LIBRARIES); - JSFLibraryConfigModelAdapter provider = new JSFLibraryConfigModelAdapter(project); - provider.updateJSFImplementationLibrary((JSFLibraryDecorator) implLibs.get(0)); - provider.updateJSFComponentLibraries(compLibs); - - provider.updateProjectDependencies(); + JSFLibraryConfiglModelSource source = new JSFLibraryConfigProjectData(project); + JSFLibraryConfigModel model = JSFLibraryConfigModel.JSFLibraryConfigModelFactory.createInstance(source); + model.setCurrentJSFImplementationLibrarySelection((JSFProjectLibraryReference) implLibs.get(0)); + model.setCurrentJSFComponentLibrarySelection(compLibs); - provider.saveData(); + J2EEModuleDependencyDelegate updateDependecnies = new J2EEModuleDependencyDelegate(project); + updateDependecnies.updateProjectDependencies(model, monitor); + model.saveData(project); // Create config file createConfigFile(project, fv, config, monitor); @@ -106,37 +104,7 @@ public class JSFFacetInstallDelegate implements IDelegate { } } } - /* - private void updateProjectDependency(JSFLibraryDecorator prevLib, - List implLibs, - List compLibs, - IProject project, - IProgressMonitor monitor) { - // Update Model - //java.util.List implLibs = (List) config.getProperty(IJSFFacetInstallDataModelProperties.IMPLEMENTATION_LIBRARIES); - //java.util.List compLibs = (List) config.getProperty(IJSFFacetInstallDataModelProperties.COMPONENT_LIBRARIES); - //JSFLibraryConfigModelAdapter provider = new JSFLibraryConfigModelAdapter(project); - //JSFLibraryDecorator preSelJSFImplLib = provider.getPreviousJSFImplementation(); - //JSFLibraryDecorator preSelJSFImplLib = provider.getSavedJSFImplementationLibrary(); - - // Update J2EE Module dependency for deployment and add JARs into project build path. - J2EEModuleDependencyDelegate modulesDep = new J2EEModuleDependencyDelegate(project); - JSFLibraryDecorator selJSFImplLib = (JSFLibraryDecorator)implLibs.get(0); - if (prevLib != null) { - modulesDep.removeProjectDependency(prevLib.getLibrary(), monitor); - } - modulesDep.addProjectDependency(selJSFImplLib.getLibrary(), selJSFImplLib.isCheckedToBeDeployed(), monitor); - JSFLibraryDecorator jsfLibItem; - for(int i = 0; i < compLibs.size(); i++) { - jsfLibItem = (JSFLibraryDecorator)compLibs.get(i); - if (jsfLibItem.isSelected()) { - modulesDep.addProjectDependency(jsfLibItem.getLibrary(), jsfLibItem.isCheckedToBeDeployed(), monitor); - } - } - // Update Model - //provider.saveData(implLibs, compLibs); - } - */ + /** Obsoleted M1 approach private void deployJSFLibraries(IProject project, final IDataModel config, IProgressMonitor monitor) { diff --git a/jsf/plugins/org.eclipse.jst.jsf.ui/src/org/eclipse/jst/jsf/ui/internal/Messages.java b/jsf/plugins/org.eclipse.jst.jsf.ui/src/org/eclipse/jst/jsf/ui/internal/Messages.java index de8b7ee67..f658fc916 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.ui/src/org/eclipse/jst/jsf/ui/internal/Messages.java +++ b/jsf/plugins/org.eclipse.jst.jsf.ui/src/org/eclipse/jst/jsf/ui/internal/Messages.java @@ -82,6 +82,10 @@ public class Messages extends NLS { public static String JSFLibraryContainerWizardPage_Add; public static String JSFLibraryContainerWizardPage_ErrorInitializing; + public static String JSFLibraryPropertyPage_No_JSF_Facet_Installed; + + public static String JSFLibraryPropertyPage_No_JSF_Implementation_Lib_Selected; + public static String JSFLibraryWizard_DESCRIPTION; public static String JSFLibraryWizard_IMPLS_ONLY_DESC; public static String JSFLibraryWizard_CreateImplementation; diff --git a/jsf/plugins/org.eclipse.jst.jsf.ui/src/org/eclipse/jst/jsf/ui/internal/jsflibraryconfig/JSFLibraryConfigControl.java b/jsf/plugins/org.eclipse.jst.jsf.ui/src/org/eclipse/jst/jsf/ui/internal/jsflibraryconfig/JSFLibraryConfigControl.java index 60d7725f6..5da37449f 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.ui/src/org/eclipse/jst/jsf/ui/internal/jsflibraryconfig/JSFLibraryConfigControl.java +++ b/jsf/plugins/org.eclipse.jst.jsf.ui/src/org/eclipse/jst/jsf/ui/internal/jsflibraryconfig/JSFLibraryConfigControl.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Justin Chen - development check in + * Justin Chen *******************************************************************************/ package org.eclipse.jst.jsf.ui.internal.jsflibraryconfig; @@ -16,7 +16,6 @@ import java.util.Iterator; import java.util.List; import java.util.Vector; -import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.CheckStateChangedEvent; @@ -41,8 +40,10 @@ import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.jface.window.Window; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryConfigModelAdapter; -import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryDecorator; +import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryConfiglModelSource; +import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryRegistryUtil; +import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryConfigModel; +import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFProjectLibraryReference; import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile; import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary; import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry; @@ -70,13 +71,14 @@ import org.eclipse.ui.PlatformUI; /** * A custom control used in wizard and property pages. * - * @author Justin Chen - Oracle + * @author Justin Chen */ public class JSFLibraryConfigControl extends Composite { final private int COLUMN_DEPLOY = 0; final private int COLUMN_LIB_NAME = 1; - private JSFLibraryConfigModelAdapter provider = null; + private JSFLibraryConfigModel workingCopyModel = null; + private JSFLibraryConfiglModelSource persistentModel = null; private ComboViewer cvImplLib; private CheckboxTableViewer ctvSelCompLib; @@ -102,33 +104,25 @@ public class JSFLibraryConfigControl extends Composite { */ public JSFLibraryConfigControl(Composite parent, int style) { super(parent, style); - + createControls(); } /** - * To initialize control valaues from a model instanciated w/ a project. + * set control values from provided model. * - * @param project + * @param source */ - public void initControlsValues(IProject project) { - if (project != null) { - provider = new JSFLibraryConfigModelAdapter(project); + public void loadControlValuesFromModel(JSFLibraryConfiglModelSource source) { + if (source != null) { + persistentModel = source; + workingCopyModel = JSFLibraryConfigModel.JSFLibraryConfigModelFactory.createInstance(source); initializeControlValues(); } else { JSFUiPlugin.log(IStatus.ERROR, Messages.JSFLibraryConfigControl_NullProject); } - } - - /** - * Return the working model. - * - * @return JSFLibraryConfigModelAdapter - */ - public JSFLibraryConfigModelAdapter getModelProvider() { - return provider; } - + /* (non-Javadoc) * @see org.eclipse.swt.widgets.Widget#dispose() */ @@ -148,64 +142,83 @@ public class JSFLibraryConfigControl extends Composite { * * @return JSFLibraryDecorator */ - public JSFLibraryDecorator getSelectedJSFLibImplementation() { - return provider.getSelectedJSFImplLibrary(); + public JSFProjectLibraryReference getSelectedJSFLibImplementation() { + return workingCopyModel.getCurrentJSFImplementationLibrarySelection(); } - + /** * Return a list of selected JSF Component Libraries. * Otherwise, return an empty list. * * @return a list of selected JSF Component Libraries - */ + */ public List getSelectedJSFLibComponents() { - return provider.getSelectedJSFCompLibraries(); + return workingCopyModel.getCurrentJSFComponentLibrarySelection(); } - + + /** + * + * @return JSFLibraryConfigModelAdapter + */ + public JSFLibraryConfigModel getWorkingModel() { + return workingCopyModel; + } + private void initializeControlValues() { loadJSFImplList(); btnDeployJars.setSelection(false); - if ( provider.getSavedJSFImplementationLibrary() != null ) { - JSFLibraryDecorator selJSFImplLib = provider.getSavedJSFImplementationLibrary(); - cvImplLib.setSelection(new StructuredSelection(selJSFImplLib), true); - btnDeployJars.setSelection(selJSFImplLib.isCheckedToBeDeployed()); + //JSFLibraryDecorator savedImplLib = persistentModel.getJSFImplementationLibrary(); + JSFProjectLibraryReference savedImplLib = workingCopyModel.getSavedJSFImplementationLibrary(); + if ( savedImplLib != null ) { + /* + * Get the input for the control to set selection. + */ + JSFProjectLibraryReference selected = JSFLibraryRegistryUtil.getInstance().getJSFLibryReferencebyID(savedImplLib.getID()); + if (selected != null) { + btnDeployJars.setSelection(selected.isCheckedToBeDeployed()); + cvImplLib.setSelection(new StructuredSelection(selected), true); + } } else { - JSFLibraryDecorator dftJSFImplLib = provider.getDefaultJSFImplemntationLibrary(); - if (dftJSFImplLib != null) { + JSFProjectLibraryReference dftJSFImplLib = JSFLibraryRegistryUtil.getInstance().getDefaultJSFImplementationLibrary(); + if (dftJSFImplLib != null) { + btnDeployJars.setSelection(dftJSFImplLib.isCheckedToBeDeployed()); cvImplLib.setSelection(new StructuredSelection(dftJSFImplLib), true); - btnDeployJars.setSelection(dftJSFImplLib.isCheckedToBeDeployed()); } } loadJSFCompList(); - JSFLibraryDecorator jsfLibDctr = null; - List jsfCompLibs = provider.getSavedJSFComponentLibraries(); - for (int i = 0; i < jsfCompLibs.size(); i++) { - jsfLibDctr = (JSFLibraryDecorator)jsfCompLibs.get(i); - ctvSelCompLib.setChecked(jsfLibDctr, jsfLibDctr.isCheckedToBeDeployed()); - } + JSFProjectLibraryReference savedCompLib = null; + JSFProjectLibraryReference selected = null; + //Iterator it = persistentModel.getJSFComponentLibraries().iterator(); + Iterator it = workingCopyModel.getJSFComponentLibraries().iterator(); + while (it.hasNext()) { + savedCompLib = (JSFProjectLibraryReference) it.next(); + selected = JSFLibraryRegistryUtil.getInstance().getJSFLibryReferencebyID(savedCompLib.getID()); + if (selected != null) { + ctvSelCompLib.setChecked(selected, selected.isCheckedToBeDeployed()); + } + } redraw(); } private void loadJSFImplList() { - cvImplLib.setInput(provider.getJSFImplementationLibraries()); + cvImplLib.setInput(workingCopyModel.getJSFImplementationLibraries()); } private void loadJSFCompList() { - tvCompLib.setInput(provider.getJSFComponentLibraries()); - ctvSelCompLib.setInput(provider.getJSFComponentLibraries()); + tvCompLib.setInput(workingCopyModel.getJSFComponentLibraries()); + ctvSelCompLib.setInput(workingCopyModel.getJSFComponentLibraries()); } - private JSFLibraryDecorator getJSFImplLibwUpdatedState() { - JSFLibraryDecorator selJSFImpl = null; + private JSFProjectLibraryReference getCurrentSelectedJSFImplLib() { + JSFProjectLibraryReference selJSFImpl = null; StructuredSelection objs = (StructuredSelection)cvImplLib.getSelection(); if (objs != null){ - if (objs.getFirstElement() instanceof JSFLibraryDecorator){ - selJSFImpl = (JSFLibraryDecorator)objs.getFirstElement(); - selJSFImpl.setToBeDeployed(btnDeployJars.getSelection()); + if (objs.getFirstElement() instanceof JSFProjectLibraryReference){ + selJSFImpl = (JSFProjectLibraryReference)objs.getFirstElement(); } } return selJSFImpl; @@ -232,8 +245,9 @@ public class JSFLibraryConfigControl extends Composite { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { - JSFLibraryDecorator jsflib = getJSFImplLibwUpdatedState(); - provider.updateJSFImplementationLibrary(jsflib); + JSFProjectLibraryReference jsflib = getCurrentSelectedJSFImplLib(); + jsflib.setToBeDeployed(btnDeployJars.getSelection()); + workingCopyModel.setCurrentJSFImplementationLibrarySelection(jsflib); } } ); @@ -259,7 +273,9 @@ public class JSFLibraryConfigControl extends Composite { new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { StructuredSelection ss = (StructuredSelection) event.getSelection(); - provider.updateJSFImplementationLibrary((JSFLibraryDecorator) ss.getFirstElement()); + JSFProjectLibraryReference crtSelImplLib = (JSFProjectLibraryReference) ss.getFirstElement(); + crtSelImplLib.setToBeDeployed(btnDeployJars.getSelection()); + workingCopyModel.setCurrentJSFImplementationLibrarySelection(crtSelImplLib); } } ); @@ -275,18 +291,15 @@ public class JSFLibraryConfigControl extends Composite { WizardDialog dialog = new WizardDialog(wb .getActiveWorkbenchWindow().getShell(), wizard); int ret = dialog.open(); - if (ret == Window.OK) { - JSFLibraryDecorator jsfLibDctr = new JSFLibraryDecorator(wizard.getJSFLibrary(), true, true); - JSFLibraryRegistry jsflibreg = JSFCorePlugin.getDefault().getJSFLibraryRegistry(); - jsflibreg.addJSFLibrary(wizard.getJSFLibrary()); - - provider.addJSFLibrary(jsfLibDctr); - provider.updateJSFImplementationLibrary(jsfLibDctr); + if (ret == Window.OK) { + JSFProjectLibraryReference lib = new JSFProjectLibraryReference(wizard.getJSFLibrary(), true, true); + JSFLibraryRegistryUtil.getInstance().addJSFLibrary(lib); + workingCopyModel.getJSFImplementationLibraries().add(lib); + workingCopyModel.setCurrentJSFImplementationLibrarySelection(lib); loadJSFImplList(); - btnDeployJars.setSelection(true); - cvImplLib.setSelection(new StructuredSelection(jsfLibDctr), true); + cvImplLib.setSelection(new StructuredSelection(lib), true); } // notify listeners that a JSF implementation is created. JSFImplLibraryCreationEvent event = new JSFImplLibraryCreationEvent(this, (ret == Window.OK)); @@ -369,16 +382,15 @@ public class JSFLibraryConfigControl extends Composite { .getActiveWorkbenchWindow().getShell(), wizard); int ret = dialog.open(); if (ret == Window.OK) { - JSFLibrary newCompLib = wizard.getJSFLibrary(); - JSFLibraryDecorator jsfLibDctr = new JSFLibraryDecorator(newCompLib, true, true); - JSFLibraryRegistry jsflibreg = JSFCorePlugin.getDefault().getJSFLibraryRegistry(); - jsflibreg.addJSFLibrary(newCompLib); - - provider.addJSFLibrary(jsfLibDctr); + JSFProjectLibraryReference lib = new JSFProjectLibraryReference( + wizard.getJSFLibrary(), + true, + true); + JSFLibraryRegistryUtil.getInstance().addJSFLibrary(lib); + workingCopyModel.getJSFComponentLibraries().add(lib); loadJSFCompList(); - - ctvSelCompLib.setChecked(jsfLibDctr, true); + ctvSelCompLib.setChecked(lib, true); } } }); @@ -401,14 +413,14 @@ public class JSFLibraryConfigControl extends Composite { ctvSelCompLib.setContentProvider(new CompLibCTVContentProvider()); ctvSelCompLib.addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { - JSFLibraryDecorator changedItem = (JSFLibraryDecorator) event.getElement(); + JSFProjectLibraryReference changedItem = (JSFProjectLibraryReference) event.getElement(); boolean isChecked4Deploy = event.getChecked(); - List list = provider.getJSFComponentLibraries(); + List list = workingCopyModel.getJSFComponentLibraries(); Iterator it = list.iterator(); - JSFLibraryDecorator crtjsflib = null; + JSFProjectLibraryReference crtjsflib = null; while (it.hasNext()) { - crtjsflib = (JSFLibraryDecorator) it.next(); + crtjsflib = (JSFProjectLibraryReference) it.next(); if (crtjsflib.getID().equals(changedItem.getID())) { crtjsflib.setToBeDeployed(isChecked4Deploy); break; @@ -456,12 +468,12 @@ public class JSFLibraryConfigControl extends Composite { CheckboxTableViewer destViewer, boolean state) { if (item != null && item.getFirstElement() != null) { - JSFLibraryDecorator jsfLibDctr = (JSFLibraryDecorator)item.getFirstElement(); - List list = provider.getJSFComponentLibraries(); + JSFProjectLibraryReference jsfLibDctr = (JSFProjectLibraryReference)item.getFirstElement(); + List list = workingCopyModel.getJSFComponentLibraries(); Iterator it = list.iterator(); - JSFLibraryDecorator crtjsfLibDctr = null; + JSFProjectLibraryReference crtjsfLibDctr = null; while(it.hasNext()) { - crtjsfLibDctr = (JSFLibraryDecorator)it.next(); + crtjsfLibDctr = (JSFProjectLibraryReference)it.next(); if (crtjsfLibDctr.getID().equals(jsfLibDctr.getID())) { crtjsfLibDctr.setToBeDeployed(state); crtjsfLibDctr.setSelected(state); @@ -481,11 +493,11 @@ public class JSFLibraryConfigControl extends Composite { CheckboxTableViewer destViewer, boolean state) { - List list = provider.getJSFComponentLibraries(); + List list = workingCopyModel.getJSFComponentLibraries(); Iterator it = list.iterator(); - JSFLibraryDecorator jsfLibDctr; + JSFProjectLibraryReference jsfLibDctr; while(it.hasNext()) { - jsfLibDctr = (JSFLibraryDecorator)it.next(); + jsfLibDctr = (JSFProjectLibraryReference)it.next(); jsfLibDctr.setSelected(state); jsfLibDctr.setToBeDeployed(state); } @@ -503,8 +515,8 @@ public class JSFLibraryConfigControl extends Composite { */ class CheckedTableViewerFilter extends ViewerFilter { public boolean select(Viewer viewer, Object parentElement, Object element) { - if (element instanceof JSFLibraryDecorator) { - return ((JSFLibraryDecorator)element).isSelected(); + if (element instanceof JSFProjectLibraryReference) { + return ((JSFProjectLibraryReference)element).isSelected(); } return false; } @@ -512,15 +524,15 @@ public class JSFLibraryConfigControl extends Composite { class TreeViewerFilter extends ViewerFilter { public boolean select(Viewer viewer, Object parentElement, Object element) { - if (element instanceof JSFLibraryDecorator) { - return !((JSFLibraryDecorator)element).isSelected(); + if (element instanceof JSFProjectLibraryReference) { + return !((JSFProjectLibraryReference)element).isSelected(); } return true; } } class CompLibCTVContentProvider implements IStructuredContentProvider { - private List jsfComplLibs = new ArrayList(Collections.EMPTY_LIST); + private List jsfComplLibs = new ArrayList(0); public Object[] getElements(Object inputElement) { return jsfComplLibs.toArray(); @@ -536,7 +548,7 @@ public class JSFLibraryConfigControl extends Composite { } } class ImplLibCVContentProvider implements IStructuredContentProvider { - private List jsfImplLibs = new ArrayList(Collections.EMPTY_LIST); + private List jsfImplLibs = new ArrayList(0); public Object[] getElements(Object inputElement) { return jsfImplLibs.toArray(); @@ -555,13 +567,13 @@ public class JSFLibraryConfigControl extends Composite { // Label Provider class SelectedCompLibCTVLabelProvider extends LabelProvider implements ITableLabelProvider { public String getColumnText(Object element, int columnIndex) { - if (element instanceof JSFLibraryDecorator){ + if (element instanceof JSFProjectLibraryReference){ switch(columnIndex) { case COLUMN_DEPLOY: return " "; //$NON-NLS-1$ case COLUMN_LIB_NAME: - return ((JSFLibraryDecorator)element).getName(); + return ((JSFProjectLibraryReference)element).getName(); } } return ""; //$NON-NLS-1$ @@ -575,9 +587,9 @@ public class JSFLibraryConfigControl extends Composite { private JSFLibrary defaultImpl = null; public String getText(Object element) { - if (element instanceof JSFLibraryDecorator){ - StringBuffer nameBuf = new StringBuffer(((JSFLibraryDecorator)element).getName()); - if ((((JSFLibraryDecorator)element).getLibrary()) == getDefaultImpl()) + if (element instanceof JSFProjectLibraryReference){ + StringBuffer nameBuf = new StringBuffer(((JSFProjectLibraryReference)element).getName()); + if ((((JSFProjectLibraryReference)element).getLibrary()).getID().equals(getDefaultImpl().getID())) nameBuf.append(" ").append(JSFLibraryRegistry.DEFAULT_IMPL_LABEL); //$NON-NLS-1$ return nameBuf.toString() ; } @@ -598,10 +610,10 @@ public class JSFLibraryConfigControl extends Composite { // Sorter class SelectedCompLibCTVSorter extends ViewerSorter { public int compare(Viewer viewer, Object e1, Object e2) { - if (e1 instanceof JSFLibraryDecorator && - e2 instanceof JSFLibraryDecorator) { - JSFLibraryDecorator item1 = (JSFLibraryDecorator)e1; - JSFLibraryDecorator item2 = (JSFLibraryDecorator)e2; + if (e1 instanceof JSFProjectLibraryReference && + e2 instanceof JSFProjectLibraryReference) { + JSFProjectLibraryReference item1 = (JSFProjectLibraryReference)e1; + JSFProjectLibraryReference item2 = (JSFProjectLibraryReference)e2; return item1.getName().compareToIgnoreCase(item2.getName()); } return 0; @@ -628,12 +640,12 @@ public class JSFLibraryConfigControl extends Composite { } public Object[] getElements(Object obj) { - return provider.getJSFComponentLibraries().toArray(); + return workingCopyModel.getJSFComponentLibraries().toArray(); } public Object[] getChildren(Object element) { - if (element instanceof JSFLibraryDecorator) { - return ((JSFLibraryDecorator)element).getArchiveFiles().toArray(); + if (element instanceof JSFProjectLibraryReference) { + return ((JSFProjectLibraryReference)element).getArchiveFiles().toArray(); } return NO_ELEMENTS; } @@ -643,7 +655,7 @@ public class JSFLibraryConfigControl extends Composite { } public boolean hasChildren(Object element) { - if (element instanceof JSFLibraryDecorator) { + if (element instanceof JSFProjectLibraryReference) { return true; } return false; @@ -679,7 +691,7 @@ public class JSFLibraryConfigControl extends Composite { } public Image getImage(Object element) { - if (element instanceof JSFLibraryDecorator) + if (element instanceof JSFProjectLibraryReference) return libImg; else return jarImg; @@ -687,8 +699,8 @@ public class JSFLibraryConfigControl extends Composite { public String getText(Object element) { StringBuffer labelBuf = new StringBuffer(); - if (element instanceof JSFLibraryDecorator) { - JSFLibraryDecorator libWrapper = (JSFLibraryDecorator)element; + if (element instanceof JSFProjectLibraryReference) { + JSFProjectLibraryReference libWrapper = (JSFProjectLibraryReference)element; JSFLibrary lib = (JSFLibrary)libWrapper.getLibrary(); labelBuf.append(lib.getName()); if (lib.isImplementation()) { diff --git a/jsf/plugins/org.eclipse.jst.jsf.ui/src/org/eclipse/jst/jsf/ui/internal/jsflibraryconfig/JSFLibraryPropertyPage.java b/jsf/plugins/org.eclipse.jst.jsf.ui/src/org/eclipse/jst/jsf/ui/internal/jsflibraryconfig/JSFLibraryPropertyPage.java index 6c905d486..0b3a6c6c9 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.ui/src/org/eclipse/jst/jsf/ui/internal/jsflibraryconfig/JSFLibraryPropertyPage.java +++ b/jsf/plugins/org.eclipse.jst.jsf.ui/src/org/eclipse/jst/jsf/ui/internal/jsflibraryconfig/JSFLibraryPropertyPage.java @@ -14,11 +14,14 @@ import java.util.Iterator; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryConfigModelAdapter; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.J2EEModuleDependencyDelegate; +import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryConfiglModelSource; +import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryConfigProjectData; +import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryConfigModel; +import org.eclipse.jst.jsf.ui.internal.Messages; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; @@ -28,12 +31,11 @@ import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; /** - * @author Justin Chen - Oracle + * @author Justin Chen */ public class JSFLibraryPropertyPage extends PropertyPage { private static String JSF_FACET_ID = "jst.jsf"; //$NON-NLS-1$ private JSFLibraryConfigControl jsfLibCfgControl; - private JSFLibraryConfigModelAdapter provider; private IProject project; /** @@ -56,20 +58,25 @@ public class JSFLibraryPropertyPage extends PropertyPage { * @see org.eclipse.jface.preference.PreferencePage#performOk() */ public boolean performOk() { - // Do nothing because of invalid settings. if (!validatePage()) { return true; } - provider = jsfLibCfgControl.getModelProvider(); - provider.updateProjectDependencies(); - provider.saveData(); // save library configuration data + JSFLibraryConfigModel model = jsfLibCfgControl.getWorkingModel(); + if (model != null) { + J2EEModuleDependencyDelegate dependencyUpdate = new J2EEModuleDependencyDelegate(project); + dependencyUpdate.updateProjectDependencies(model, new NullProgressMonitor()); + model.saveData(project); + } else { + // log an error message + } return true; } - /* (non-Javadoc) + /* + * (non-Javadoc) * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) */ protected Control createContents(Composite parent) { @@ -80,9 +87,10 @@ public class JSFLibraryPropertyPage extends PropertyPage { //} } - private Control createForJSFProject(Composite parent) { - jsfLibCfgControl = new JSFLibraryConfigControl(parent, SWT.NULL); - jsfLibCfgControl.initControlsValues(project); + private Control createForJSFProject(Composite parent) { + JSFLibraryConfiglModelSource model = new JSFLibraryConfigProjectData(project); + jsfLibCfgControl = new JSFLibraryConfigControl(parent, SWT.NULL); + jsfLibCfgControl.loadControlValuesFromModel(model); jsfLibCfgControl.addOkClickedListener(new IJSFImplLibraryCreationListener() { public void okClicked(JSFImplLibraryCreationEvent event) { @@ -101,10 +109,10 @@ public class JSFLibraryPropertyPage extends PropertyPage { protected boolean validatePage() { if (!isJSFFacetInstalled() || jsfLibCfgControl.getSelectedJSFLibImplementation() == null) { if (!isJSFFacetInstalled()) { - JSFLibraryPropertyPage.this.setErrorMessage("JSF Facet not installed."); + JSFLibraryPropertyPage.this.setErrorMessage(Messages.JSFLibraryPropertyPage_No_JSF_Facet_Installed); } if (jsfLibCfgControl.getSelectedJSFLibImplementation() == null) { - JSFLibraryPropertyPage.this.setErrorMessage("No JSF implementation library selected."); + JSFLibraryPropertyPage.this.setErrorMessage(Messages.JSFLibraryPropertyPage_No_JSF_Implementation_Lib_Selected); } return false; }/* else { diff --git a/jsf/plugins/org.eclipse.jst.jsf.ui/src/org/eclipse/jst/jsf/ui/internal/messages.properties b/jsf/plugins/org.eclipse.jst.jsf.ui/src/org/eclipse/jst/jsf/ui/internal/messages.properties index 8ea0fffb9..ccf57e9ef 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.ui/src/org/eclipse/jst/jsf/ui/internal/messages.properties +++ b/jsf/plugins/org.eclipse.jst.jsf.ui/src/org/eclipse/jst/jsf/ui/internal/messages.properties @@ -35,6 +35,7 @@ JSFLibrariesPreferencePage_CannotRemovePluginProvidedMessage=Plugin provided lib JSFLibrariesPreferencePage_MakeDefault=Make Default JSFLibrariesPreferencePage_Description=JSF Libraries contain jars with JSF components and tag libraries. Some JSF Libaries can be specially marked as implementations so that the WebApp can be executed. JSFLibrariesPreferencePage_CannotModifyPluginProvidedTitle=Cannot Modify +JSFLibraryPropertyPage_No_JSF_Implementation_Lib_Selected=No JSF implementation library selected. JSFLibrariesPreferencePage_CannotModifyPluginProvidedMessage=Plugin provided libraries cannot be edited JSFLibraryContainerWizardPage_PageName=Add JSF Library @@ -64,6 +65,7 @@ JSFLibraryWizard_ValidateNoLibraryName=A library name must be supplied. JSFLibraryWizard_ValidateExistingLibraryName=A library or implementation by this name already exists. JSFLibraryConfigControl_ImplementationLibrary=Implementation Library +JSFLibraryPropertyPage_No_JSF_Facet_Installed=JSF Facet not installed. JSFLibraryConfigControl_NewImplementationLibrary=New... JSFLibraryConfigControl_DeployJAR=Deploy jars to WEB-INF/lib JSFLibraryConfigControl_ComponentLibrary=Component Libraries diff --git a/jsf/plugins/org.eclipse.jst.jsf.ui/src/org/eclipse/jst/jsf/ui/internal/project/facet/JSFFacetInstallPage.java b/jsf/plugins/org.eclipse.jst.jsf.ui/src/org/eclipse/jst/jsf/ui/internal/project/facet/JSFFacetInstallPage.java index a760ac33e..7218afb8a 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.ui/src/org/eclipse/jst/jsf/ui/internal/project/facet/JSFFacetInstallPage.java +++ b/jsf/plugins/org.eclipse.jst.jsf.ui/src/org/eclipse/jst/jsf/ui/internal/project/facet/JSFFacetInstallPage.java @@ -11,11 +11,9 @@ package org.eclipse.jst.jsf.ui.internal.project.facet; import java.util.ArrayList; +import java.util.Collections; import java.util.Iterator; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.dialogs.DialogSettings; @@ -24,6 +22,9 @@ import org.eclipse.jface.dialogs.IInputValidator; import org.eclipse.jface.dialogs.InputDialog; import org.eclipse.jface.window.Window; import org.eclipse.jst.j2ee.project.facet.IJ2EEModuleFacetInstallDataModelProperties; +import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryConfiglModelSource; +import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryConfigDialogSettingData; +import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFProjectLibraryReference; import org.eclipse.jst.jsf.core.internal.project.facet.IJSFFacetInstallDataModelProperties; import org.eclipse.jst.jsf.ui.internal.JSFUiPlugin; import org.eclipse.jst.jsf.ui.internal.Messages; @@ -76,9 +77,13 @@ public class JSFFacetInstallPage extends DataModelWizardPage implements IJSFFace private static final String SETTINGS_URL_MAPPINGS = "urlMappings"; //$NON-NLS-1$ private static final String SETTINGS_URL_PATTERN = "pattern"; //$NON-NLS-1$ private static final String SETTINGS_DEPLOY_IMPL = "deployImplementation"; //$NON-NLS-1$ + private static final String SETTINGS_COMPLIB = "selectedComponent"; //$NON-NLS-1$ + private static final String SETTINGS_COMPLIB_SELECT_DEPLOY = "selectdeploycomplib"; //$NON-NLS-1$ + private static final String SEPARATOR =":"; //$NON-NLS-1$ + private JSFLibraryConfigControl jsfLibCfgComp = null; - private String projectName = null; + //private String projectName = null; private Composite composite = null; /** @@ -212,6 +217,8 @@ public class JSFFacetInstallPage extends DataModelWizardPage implements IJSFFace private void initializeValues() { IDialogSettings root = dialogSettings.getSection(SETTINGS_ROOT); + initJSFCfgCtrlValues(root); + String conf = null; if (root != null) conf = root.get(SETTINGS_CONFIG); @@ -231,6 +238,31 @@ public class JSFFacetInstallPage extends DataModelWizardPage implements IJSFFace loadURLMappingPatterns(root); } + private void initJSFCfgCtrlValues(IDialogSettings root) { + String deployImpl = null; + if (root != null) { + deployImpl = root.get(SETTINGS_DEPLOY_IMPL); + } + if (deployImpl == null || deployImpl.equals("")) { //$NON-NLS-1$ + deployImpl = ((Boolean)model.getDefaultProperty(IJSFFacetInstallDataModelProperties.DEPLOY_IMPLEMENTATION)).toString(); + } + + IDialogSettings complibs = null; + if (root != null) { + complibs = root.getSection(SETTINGS_COMPLIB); + } + + String[] selection = null; + if (complibs != null) { + selection = (String[])complibs.getArray(SETTINGS_COMPLIB_SELECT_DEPLOY); + } + + JSFLibraryConfiglModelSource source = new JSFLibraryConfigDialogSettingData( + Boolean.valueOf(deployImpl).booleanValue(), + selection); + jsfLibCfgComp.loadControlValuesFromModel(source); + } + private void saveSettings() { DialogSettings root = new DialogSettings(SETTINGS_ROOT); dialogSettings.addSection(root); @@ -241,6 +273,10 @@ public class JSFFacetInstallPage extends DataModelWizardPage implements IJSFFace DialogSettings mappings = new DialogSettings(SETTINGS_URL_MAPPINGS); root.addSection(mappings); mappings.put(SETTINGS_URL_PATTERN, getJSFPatterns()); + + DialogSettings complibs = new DialogSettings(SETTINGS_COMPLIB); + root.addSection(complibs); + complibs.put(SETTINGS_COMPLIB_SELECT_DEPLOY, getCompLibSelections()); } private boolean getDeployJSFImpl() { @@ -262,6 +298,27 @@ public class JSFFacetInstallPage extends DataModelWizardPage implements IJSFFace return lstJSFServletURLPatterns.getItems(); } + private String[] getCompLibSelections() { + /* + * Iterate thru the selected component libraries + * and return selected component libraries and their deployment flags + * in a string array. + */ + JSFProjectLibraryReference complib = null; + String str = null; + ArrayList al = new ArrayList(); + + java.util.List list = jsfLibCfgComp.getSelectedJSFLibComponents(); + Iterator it = list.iterator(); + while(it.hasNext()) { + complib = (JSFProjectLibraryReference) it.next(); + str = complib.getID() + SEPARATOR + complib.isCheckedToBeDeployed(); + al.add(str); + } + + return (String[]) al.toArray(new String[al.size()]); + } + /* * (non-Javadoc) * @@ -285,8 +342,8 @@ public class JSFFacetInstallPage extends DataModelWizardPage implements IJSFFace saveSettings(); //convenient place for this. don't want to save if user cancelled. //do nothing else now. being handled by synchHelper // config.setProperty(IJSFFacetInstallDataModelProperties.IMPLEMENTATION, getJSFImpl()); -// config.setStringProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH, getJSFConfig()); -// config.setStringProperty(IJSFFacetInstallDataModelProperties.SERVLET_NAME, getJSFServletName()); + model.setStringProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH, getJSFConfig()); + model.setStringProperty(IJSFFacetInstallDataModelProperties.SERVLET_NAME, getJSFServletName()); // config.setProperty(IJSFFacetInstallDataModelProperties.SERVLET_URL_PATTERNS, getJSFPatterns()); java.util.List implLibs = new ArrayList(); @@ -300,8 +357,8 @@ public class JSFFacetInstallPage extends DataModelWizardPage implements IJSFFace // 119330 - enhancement request for ComboViewer support. Manually update model for now // addJSFImplComboListeners(); // synchHelper.synchComboViewer(cboJSFImplViewer, IMPLEMENTATION, null); - synchHelper.synchText(txtJSFConfig, CONFIG_PATH, null); - synchHelper.synchText(txtJSFServletName, SERVLET_NAME, null); +// synchHelper.synchText(txtJSFConfig, CONFIG_PATH, null); +// synchHelper.synchText(txtJSFServletName, SERVLET_NAME, null); // synchHelper.synchCheckbox(chkDeployImpl, DEPLOY_IMPLEMENTATION, null); // Until 119321 is fixed, need to comment out below and handle model updates 'manually'. // This is being done on Add and Remove, currently @@ -316,7 +373,7 @@ public class JSFFacetInstallPage extends DataModelWizardPage implements IJSFFace return null; } - + private void loadURLMappingPatterns(IDialogSettings root) { lstJSFServletURLPatterns.removeAll(); IDialogSettings mappings = null; @@ -361,8 +418,6 @@ public class JSFFacetInstallPage extends DataModelWizardPage implements IJSFFace } public void setWizardContext(IWizardContext context) { - projectName = context.getProjectName(); - //hook into web datamodel if new project wizard. Iterator it = context.getSelectedProjectFacets().iterator(); IProjectFacetVersion webFacetVersion = null; @@ -409,22 +464,5 @@ public class JSFFacetInstallPage extends DataModelWizardPage implements IJSFFace protected void restoreDefaultSettings() { initializeValues(); } - - /** - * (non-Javadoc) - * @see org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage#updateControls() - */ - protected void updateControls() { - projectName = model.getStringProperty(IJ2EEModuleFacetInstallDataModelProperties.FACET_PROJECT_NAME); - IProject project = getProjectHandle(); - jsfLibCfgComp.initControlsValues(project); - } - - private IProject getProjectHandle() { - if (projectName != null && projectName.length() > 0) { - return ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); - } - return null; - } - + } |