diff options
Diffstat (limited to 'bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project')
8 files changed, 0 insertions, 1600 deletions
diff --git a/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSFacetIncludeLibrariesGroup.java b/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSFacetIncludeLibrariesGroup.java deleted file mode 100644 index c4e0121c9..000000000 --- a/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSFacetIncludeLibrariesGroup.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20100310 291954 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS: Implement JAX-RS Facet - *******************************************************************************/ -package org.eclipse.jst.ws.jaxrs.ui.internal.project.facet; - -import org.eclipse.jst.ws.jaxrs.core.internal.project.facet.IJAXRSFacetInstallDataModelProperties; -import org.eclipse.jst.ws.jaxrs.ui.internal.JAXRSUIPlugin; -import org.eclipse.jst.ws.jaxrs.ui.internal.Messages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class JAXRSFacetIncludeLibrariesGroup extends Composite { - - private Button btnDeployJars; - private Button btnSharedLibrary; - Button copyOnPublishCheckBox; - private Composite includeLibRadiosComposite; - - public JAXRSFacetIncludeLibrariesGroup(Composite parent, int style) { - super(parent, style); - copyOnPublishCheckBox = new Button(parent, SWT.CHECK); - copyOnPublishCheckBox.setText(Messages.JAXRSLibraryConfigControl_IncludeGroupLabel); - includeLibRadiosComposite = new Composite(parent, SWT.NONE); - GridLayout gridlayout = new GridLayout(); - gridlayout.numColumns = 1; - gridlayout.marginTop = 0; - gridlayout.marginBottom = 0; - gridlayout.marginRight = 0; - gridlayout.marginLeft = 10; - - includeLibRadiosComposite.setLayout(gridlayout); - GridData griddata = new GridData(GridData.FILL_HORIZONTAL); - includeLibRadiosComposite.setLayoutData(griddata); - - btnDeployJars = createRadioButton(includeLibRadiosComposite, Messages.JAXRSLibraryConfigControl_DeployButtonLabel, Messages.JAXRSLibraryConfigControl_DeployJAR, null); - - btnSharedLibrary = createRadioButton(includeLibRadiosComposite, Messages.JAXRSLibraryConfigControl_SharedLibButtonLabel, Messages.JAXRSLibraryConfigControl_TooltipIncludeAsSharedLib, null); - - copyOnPublishCheckBox.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(final SelectionEvent event) - { - boolean selection = copyOnPublishCheckBox.getSelection(); - btnDeployJars.setEnabled(selection); - btnSharedLibrary.setEnabled(selection); - - } - }); - // Need to initialize this properly - btnDeployJars.setSelection(true); - - } - - public Button getBtnDeployJars() { - return btnDeployJars; - } - - public Button getBtnSharedLibrary() { - return btnSharedLibrary; - } - - public Button getCopyOnPublishCheckBox() { - return copyOnPublishCheckBox; - } - - public Composite getIncludeLibRadiosComposite() { - return includeLibRadiosComposite; - } - - private Button createButton(int kind, Composite parent, String labelName, String tooltip, String infopop) - { - Button button = new Button(parent, kind); - - tooltip = tooltip == null ? labelName : tooltip; - button.setText(labelName); - button.setToolTipText(tooltip); - - if (infopop != null) - PlatformUI.getWorkbench().getHelpSystem().setHelp(button, JAXRSUIPlugin.PLUGIN_ID + "." + infopop); - - return button; - } - - private Button createCheckbox(Composite parent, String labelName, String tooltip, String infopop) - { - return createButton(SWT.CHECK, parent, labelName, tooltip, infopop); - } - - private Button createRadioButton(Composite parent, String labelName, String tooltip, String infopop) - { - return createButton(SWT.RADIO, parent, labelName, tooltip, infopop); - } - - - -} diff --git a/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSFacetInstallPage.java b/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSFacetInstallPage.java deleted file mode 100644 index d84867177..000000000 --- a/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSFacetInstallPage.java +++ /dev/null @@ -1,635 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20091021 291954 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS: Implement JAX-RS Facet - * 20091106 291954 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS: Implement JAX-RS Facet - * 20100302 304405 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS Facet : support JAX-RS 1.1 (JSR 311) - * 20100303 291954 kchong@ca.ibm.com - Keith Chong, JAX-RS: Implement JAX-RS Facet - * 20100310 291954 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS: Implement JAX-RS Facet - * 20100324 306937 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS Properties page- NPE after pressing OK - * 20100413 307552 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS and Java EE 6 setup is incorrect - *******************************************************************************/ -package org.eclipse.jst.ws.jaxrs.ui.internal.project.facet; - -import java.util.Iterator; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.dialogs.DialogSettings; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider; -import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate; -import org.eclipse.jst.common.project.facet.core.libprov.LibraryProviderOperationConfig; -import org.eclipse.jst.common.project.facet.core.libprov.internal.LibraryProvider; -import org.eclipse.jst.common.project.facet.ui.libprov.LibraryProviderFrameworkUi; -import org.eclipse.jst.j2ee.project.EarUtilities; -import org.eclipse.jst.j2ee.project.WebUtilities; -import org.eclipse.jst.j2ee.project.facet.IJ2EEModuleFacetInstallDataModelProperties; -import org.eclipse.jst.server.core.FacetUtil; -import org.eclipse.jst.ws.jaxrs.core.internal.jaxrslibraryproviderconfig.JAXRSLibraryProviderUtil; -import org.eclipse.jst.ws.jaxrs.core.internal.jaxrssharedlibraryconfig.SharedLibraryConfiguratorUtil; -import org.eclipse.jst.ws.jaxrs.core.internal.project.facet.IJAXRSFacetInstallDataModelProperties; -import org.eclipse.jst.ws.jaxrs.core.internal.project.facet.JAXRSSharedLibraryProviderInstallOperationConfig; -import org.eclipse.jst.ws.jaxrs.core.internal.project.facet.JAXRSUserLibraryProviderInstallOperationConfig; -import org.eclipse.jst.ws.jaxrs.ui.internal.IJAXRSUIConstants; -import org.eclipse.jst.ws.jaxrs.ui.internal.JAXRSUIPlugin; -import org.eclipse.jst.ws.jaxrs.ui.internal.Messages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IPreset; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.common.project.facet.core.runtime.internal.BridgedRuntime; -import org.eclipse.wst.common.project.facet.ui.IFacetWizardPage; -import org.eclipse.wst.common.project.facet.ui.IWizardContext; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.IRuntimeType; - -/** - * JAXRS Facet installation wizard page. - * - */ -@SuppressWarnings("restriction") -public class JAXRSFacetInstallPage extends DataModelWizardPage implements IJAXRSFacetInstallDataModelProperties, IFacetWizardPage -{ - // UI - private ServletInformationGroup servletInfoGroup; - - private IDialogSettings dialogSettings; - private IDataModel webAppDataModel; - private String sEARProject = null; - private String sWEBProject = null; - private IWizardContext context; - private String sTargetRuntime = null; - private IRuntime targetRuntime = null; - private boolean bAddToEAR = false; - private static final String SETTINGS_SERVLET = "servletName"; //$NON-NLS-1$ - private static final String SETTINGS_SERVLET_CLASSNAME = "servletClassname"; //$NON-NLS-1$ - private static final String SETTINGS_URL_MAPPINGS = "urlMappings"; //$NON-NLS-1$ - private static final String SETTINGS_URL_PATTERN = "pattern"; //$NON-NLS-1$ - private Button updateDDCheckBox; - private Composite composite = null; - private java.util.List<IProject> earProjects = null; - private IPreset selectedPreset = null; - private boolean isProjectCreationMode = true; // project creation = true, - // add/remove facets mode = - // false - - /** - * Zero argument constructor - */ - public JAXRSFacetInstallPage() - { - super(DataModelFactory.createDataModel(new AbstractDataModelProvider() - {/* - * do nothing - */ - }), "jaxrs.facet.install.page"); //$NON-NLS-1$ - setTitle(Messages.JAXRSFacetInstallPage_title); - setDescription(Messages.JAXRSFacetInstallPage_description); - dialogSettings = JAXRSUIPlugin.getDefault().getDialogSettings(); - - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage - * #createTopLevelComposite(org.eclipse.swt.widgets.Composite) - */ - protected Composite createTopLevelComposite(final Composite parent) - { - initializeDialogUnits(parent); - composite = new Composite(parent, SWT.NONE); - final GridLayout jaxrsCompositeLayout = new GridLayout(1, false); - jaxrsCompositeLayout.marginTop = 0; - jaxrsCompositeLayout.marginBottom = 0; - jaxrsCompositeLayout.marginRight = 0; - jaxrsCompositeLayout.marginLeft = 0; - composite.setLayout(jaxrsCompositeLayout); - - final LibraryInstallDelegate librariesInstallDelegate = (LibraryInstallDelegate) getDataModel().getProperty(LIBRARY_PROVIDER_DELEGATE); - librariesInstallDelegate.getLibraryProviders(); - java.util.List<ILibraryProvider> providers = librariesInstallDelegate.getLibraryProviders(); - if (providers != null) { - for (ILibraryProvider provider : providers) { - if (provider != null) { - if (provider instanceof LibraryProvider) { - if (!provider.isAbstract()) { - LibraryProviderOperationConfig config = librariesInstallDelegate - .getLibraryProviderOperationConfig(provider); - - if (config instanceof JAXRSUserLibraryProviderInstallOperationConfig) { - JAXRSUserLibraryProviderInstallOperationConfig customConfig = (JAXRSUserLibraryProviderInstallOperationConfig) config; - customConfig.setModel(getDataModel()); - } else if (config instanceof JAXRSSharedLibraryProviderInstallOperationConfig) { - JAXRSSharedLibraryProviderInstallOperationConfig customConfig = (JAXRSSharedLibraryProviderInstallOperationConfig) config; - customConfig.setModel(getDataModel()); - } - } - } - } - } - } - - final Control librariesComposite = LibraryProviderFrameworkUi.createInstallLibraryPanel(composite, librariesInstallDelegate, Messages.JAXRSFacetInstallPage_JAXRSImplementationLibrariesFrame); - - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = 3; - - librariesComposite.setLayoutData(gd); - updateDDCheckBox = new Button(composite, SWT.CHECK); - updateDDCheckBox.setText(Messages.JAXRSFacetInstallPage_UpdateDD); - updateDDCheckBox.addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(final SelectionEvent event) { - servletInfoGroup.setVisible(updateDDCheckBox.getSelection()); - } - }); - - servletInfoGroup = new ServletInformationGroup(composite, SWT.NONE); - servletInfoGroup.setDataModel(model); - updateUpdateDDState(librariesInstallDelegate.getLibraryProvider().getId()); - - addModificationListeners(); - - return composite; - } - -private void updateUpdateDDState(String libraryProviderID) { - boolean bUserLibrary = libraryProviderID.equals(IJAXRSUIConstants.USER_LIBRARY_ID); - if (bUserLibrary) { - updateDDCheckBox.setVisible(isJEE6orGreater()); - } else - updateDDCheckBox.setVisible(showUpdateDDCheckBox(libraryProviderID)); - if (updateDDCheckBox.getVisible()) { - boolean selected; - if (!bUserLibrary) - selected = getUpdateDDCheckBoxSelected(libraryProviderID); - else - selected = true; - servletInfoGroup.setVisible(selected); - updateDDCheckBox.setSelection(selected); - updateDDCheckBox.getSelection(); - } - if (updateDDCheckBox.getVisible()) - model.setBooleanProperty(IJAXRSFacetInstallDataModelProperties.UPDATEDD, updateDDCheckBox.getSelection()); - else - model.setBooleanProperty(IJAXRSFacetInstallDataModelProperties.UPDATEDD, true); -} - - @SuppressWarnings("rawtypes") - private boolean isJEE6orGreater() { - sWEBProject = this.context.getProjectName(); - Iterator it = this.context.getSelectedProjectFacets().iterator(); - IProjectFacetVersion webFacetVersion = null; - while (it.hasNext()) { - // find Web facet - IProjectFacetVersion pfv = (IProjectFacetVersion) it.next(); - if (pfv.getProjectFacet().getId().equals("jst.web")) { //$NON-NLS-1$ - webFacetVersion = pfv; - break; - } - } - if (webFacetVersion != null) { - if (webFacetVersion.equals(WebUtilities.DYNAMIC_WEB_30)) - return true; - - } - - return false; - } - -private boolean getUpdateDDCheckBoxSelected(String libraryProviderID) { - return JAXRSLibraryProviderUtil.isUpdateDDCheckBoxSelectedByDefault(libraryProviderID); -} - -private boolean showUpdateDDCheckBox(String libraryProviderID) { - if (libraryProviderID.equals(IJAXRSUIConstants.USER_LIBRARY_ID)) - return true; - return JAXRSLibraryProviderUtil.isUpdateDDCheckBoxSupportAvailable(libraryProviderID); -} - -private void initializeValues() - { - IDialogSettings root = dialogSettings.getSection(IJAXRSUIConstants.SETTINGS_ROOT); - - if (!this.isProjectCreationMode) - { - // We are in add/remove facets mode - IProject webProject = SharedLibraryConfiguratorUtil.getWebProject(model); - if (webProject != null) - { - try - { - IFacetedProject fProject = ProjectFacetsManager.create(webProject); - // Get the runtime associated with this project - org.eclipse.wst.common.project.facet.core.runtime.IRuntime facetRuntime = fProject.getPrimaryRuntime(); - if (facetRuntime != null) - { - IRuntime runtime = FacetUtil.getRuntime(facetRuntime); - if (runtime != null) - { - IRuntimeType rtType = runtime.getRuntimeType(); - if (rtType != null) - { - sTargetRuntime = rtType.getId(); - } - // Now, set the property - model.setStringProperty(IJAXRSFacetInstallDataModelProperties.TARGETRUNTIME, sTargetRuntime); - } - } - } - catch (CoreException e) - { - // We should have a faceted project - } - } - String earName = model.getStringProperty(IJAXRSFacetInstallDataModelProperties.EARPROJECT_NAME); - if (earName == null || earName.equals("")) - { - if (webProject != null) - { - - IProject[] earProjects = EarUtilities.getReferencingEARProjects(webProject); // required - // org.eclipse.jem.util - if (earProjects.length > 0) - { - earName = earProjects[0].getName(); - // Since we do have an EAR... - this.bAddToEAR = true; - this.sEARProject = earName; - model.setBooleanProperty(IJAXRSFacetInstallDataModelProperties.ADD_TO_EAR, true); - model.setStringProperty(IJAXRSFacetInstallDataModelProperties.EARPROJECT_NAME, earName); - } - } - } - } - - String servletName = null; - if (root != null) - servletName = root.get(SETTINGS_SERVLET); - if (servletName == null || servletName.equals("")) { //$NON-NLS-1$ - servletName = (String) model.getDefaultProperty(IJAXRSFacetInstallDataModelProperties.SERVLET_NAME); - } - servletInfoGroup.txtJAXRSServletName.setText(servletName); - - String servletClassname = null; - String libraryProviderID = ""; - LibraryInstallDelegate librariesInstallDelegate = (LibraryInstallDelegate) getDataModel().getProperty(LIBRARY_PROVIDER_DELEGATE); - if (librariesInstallDelegate != null && librariesInstallDelegate.getLibraryProvider() != null) - libraryProviderID = librariesInstallDelegate.getLibraryProvider().getId(); - if (root != null) { - servletClassname = root.get(libraryProviderID + SETTINGS_SERVLET_CLASSNAME); - } - if (servletClassname == null) { - servletClassname = JAXRSLibraryProviderUtil.getServletClassName(libraryProviderID); - if (servletClassname == null) - servletClassname = (String) model.getDefaultProperty(IJAXRSFacetInstallDataModelProperties.SERVLET_CLASSNAME); - } - servletInfoGroup.txtJAXRSServletClassName.setText(servletClassname); - - loadURLMappingPatterns(root); - } - - private void saveSettings() - { - DialogSettings root = new DialogSettings(IJAXRSUIConstants.SETTINGS_ROOT); - dialogSettings.addSection(root); - root.put(SETTINGS_SERVLET, getJAXRSServletName()); - LibraryInstallDelegate librariesInstallDelegate = (LibraryInstallDelegate) getDataModel().getProperty(LIBRARY_PROVIDER_DELEGATE); - root.put(librariesInstallDelegate.getLibraryProvider().getId() + SETTINGS_SERVLET_CLASSNAME, getJAXRSServletClassname()); - DialogSettings mappings = new DialogSettings(SETTINGS_URL_MAPPINGS); - root.addSection(mappings); - mappings.put(SETTINGS_URL_PATTERN, getJAXRSPatterns()); - - } - - private String getJAXRSServletName() - { - return servletInfoGroup.txtJAXRSServletName.getText().trim(); - } - - private String getJAXRSServletClassname() - { - return servletInfoGroup.txtJAXRSServletClassName.getText().trim(); - } - - private String[] getJAXRSPatterns() - { - return servletInfoGroup.lstJAXRSServletURLPatterns.getItems(); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.wst.common.project.facet.ui.IFacetWizardPage#setConfig(java - * .lang.Object) - */ - public void setConfig(Object config) - { - model.removeListener(this); - synchHelper.dispose(); - - model = (IDataModel) config; - model.addListener(this); - synchHelper = initializeSynchHelper(model); - model.setStringProperty(IJAXRSFacetInstallDataModelProperties.EARPROJECT_NAME, sEARProject); - model.setStringProperty(IJAXRSFacetInstallDataModelProperties.WEBPROJECT_NAME, sWEBProject); - model.setStringProperty(IJAXRSFacetInstallDataModelProperties.TARGETRUNTIME, sTargetRuntime); - model.setBooleanProperty(IJAXRSFacetInstallDataModelProperties.ADD_TO_EAR, bAddToEAR); - - model.setProperty(IJAXRSFacetInstallDataModelProperties.SERVER_IRUNTIME, targetRuntime); - model.setProperty(IJAXRSFacetInstallDataModelProperties.CONFIGURATION_PRESET, selectedPreset); - model.setProperty(IJAXRSFacetInstallDataModelProperties.EARPROJECTS, earProjects); - - } - - /* - * (non-Javadoc) - * - * @seeorg.eclipse.wst.common.project.facet.ui.IFacetWizardPage# - * transferStateToConfig() - */ - public void transferStateToConfig() - { - saveSettings(); - } - - private void addModificationListeners() - { -// jaxrsLibCfgComp.setSynchHelper(synchHelper); - synchHelper.synchText(servletInfoGroup.txtJAXRSServletName, SERVLET_NAME, null); - synchHelper.synchText(servletInfoGroup.txtJAXRSServletClassName, SERVLET_CLASSNAME, null); - synchHelper.synchList(servletInfoGroup.lstJAXRSServletURLPatterns, SERVLET_URL_PATTERNS, null); - synchHelper.synchCheckbox(updateDDCheckBox, UPDATEDD, null); - } - - private void loadURLMappingPatterns(IDialogSettings root) - { - servletInfoGroup.lstJAXRSServletURLPatterns.removeAll(); - IDialogSettings mappings = null; - if (root != null) - mappings = root.getSection(SETTINGS_URL_MAPPINGS); - String[] patterns = null; - if (mappings != null) - patterns = mappings.getArray(SETTINGS_URL_PATTERN); - - if (patterns == null || patterns.length == 0) - { - patterns = (String[]) model.getDefaultProperty(IJAXRSFacetInstallDataModelProperties.SERVLET_URL_PATTERNS); - } - for (int i = 0; i < patterns.length; i++) - { - addItemToList(patterns[i], false); - } - } - - private void addItemToList(String pattern, boolean selectMe) - { - servletInfoGroup.lstJAXRSServletURLPatterns.add(pattern == null ? "" : pattern); //$NON-NLS-1$ - if (pattern == null && selectMe) - servletInfoGroup.lstJAXRSServletURLPatterns.setSelection(servletInfoGroup.lstJAXRSServletURLPatterns.getItemCount() - 1); - // When 119321 is fixed - remove code below - updateModelForURLPattern(); - } - - private void removeItemFromList(String[] selection) - { - for (int i = 0; i < selection.length; i++) - { - String sel = selection[i]; - servletInfoGroup.lstJAXRSServletURLPatterns.remove(sel); - } - // When 119321 is fixed - remove code below - updateModelForURLPattern(); - } - - private void updateModelForURLPattern() - { - model.setProperty(IJAXRSFacetInstallDataModelProperties.SERVLET_URL_PATTERNS, servletInfoGroup.lstJAXRSServletURLPatterns.getItems()); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage - * #getValidationPropertyNames() - */ - protected String[] getValidationPropertyNames() - { - return new String[] { SERVLET_NAME, SERVLET_CLASSNAME, LIBRARY_PROVIDER_DELEGATE }; - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.wst.common.project.facet.ui.IFacetWizardPage#setWizardContext - * (org.eclipse.wst.common.project.facet.ui.IWizardContext) - */ - @SuppressWarnings("unchecked") - public void setWizardContext(IWizardContext context) - { - // hook into web datamodel of new project wizard. - this.context = context; - sWEBProject = context.getProjectName(); - Iterator it = context.getSelectedProjectFacets().iterator(); - IProjectFacetVersion webFacetVersion = null; - while (it.hasNext()) - { - // find Web facet - IProjectFacetVersion pfv = (IProjectFacetVersion) it.next(); - if (pfv.getProjectFacet().getId().equals("jst.web")) { //$NON-NLS-1$ - webFacetVersion = pfv; - break; - } - } - if (webFacetVersion != null) - { - try - { - webAppDataModel = (IDataModel) context.getConfig(webFacetVersion, IFacetedProject.Action.Type.INSTALL, context.getProjectName()); - if (webAppDataModel == null) - { - // This means the web facet has already been installed! - isProjectCreationMode = false; - return; - } - Object oAddToEAR = webAppDataModel.getProperty(IJ2EEModuleFacetInstallDataModelProperties.ADD_TO_EAR); - Object oTargetRuntime = webAppDataModel.getProperty(IJ2EEModuleFacetInstallDataModelProperties.FACET_RUNTIME); - if (oAddToEAR != null) - { - if (((Boolean) oAddToEAR).booleanValue() == true) - { - bAddToEAR = true; - Object oEARProjectName = webAppDataModel.getProperty(IJ2EEModuleFacetInstallDataModelProperties.EAR_PROJECT_NAME); - if (oEARProjectName != null) - { - this.sEARProject = (String) oEARProjectName; - - } - } - } - if (oTargetRuntime != null && oTargetRuntime instanceof BridgedRuntime) - { - BridgedRuntime br = (BridgedRuntime) oTargetRuntime; - if (br != null) - { - IRuntime runtime = FacetUtil.getRuntime(br); - if (runtime != null) - { - IRuntimeType rtType = runtime.getRuntimeType(); - if (rtType != null) - sTargetRuntime = rtType.getId(); - } - } - } - - if (webAppDataModel != null) - { - webAppDataModel.addListener(this); - } - } - catch (CoreException e) - { - JAXRSUIPlugin.log(IStatus.ERROR, Messages.JAXRSFacetInstallPage_ErrorNoWebAppDataModel, e); - } - } - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage - * # - * propertyChanged(org.eclipse.wst.common.frameworks.datamodel.DataModelEvent - * ) - */ - public void propertyChanged(DataModelEvent event) - { - - if (webAppDataModel != null) - { - String propertyName = event.getPropertyName(); - if (propertyName.equals(IJ2EEModuleFacetInstallDataModelProperties.CONFIG_FOLDER)) - { - model.setStringProperty(WEBCONTENT_DIR, event.getProperty().toString()); - } - else if (propertyName.equals(IJ2EEModuleFacetInstallDataModelProperties.ADD_TO_EAR)) - { - model.setBooleanProperty(ADD_TO_EAR, ((Boolean) event.getProperty()).booleanValue()); - } - else if (propertyName.equals(IJ2EEModuleFacetInstallDataModelProperties.FACET_PROJECT_NAME)) - { - model.setStringProperty(WEBPROJECT_NAME, event.getProperty().toString()); - } - else if (propertyName.equals(IJ2EEModuleFacetInstallDataModelProperties.EAR_PROJECT_NAME)) - { - model.setStringProperty(EARPROJECT_NAME, event.getProperty().toString()); - } - else if (propertyName.equals(IJ2EEModuleFacetInstallDataModelProperties.FACET_RUNTIME)) - { - if (event.getProperty() != null) - model.setStringProperty(TARGETRUNTIME, event.getProperty().toString()); - } - else if (propertyName.equals(IJAXRSFacetInstallDataModelProperties.LIBRARY_PROVIDER_DELEGATE)) - { - if (event.getProperty() != null) { - - LibraryInstallDelegate librariesInstallDelegate = (LibraryInstallDelegate) getDataModel().getProperty(LIBRARY_PROVIDER_DELEGATE); - String libraryProviderID = librariesInstallDelegate.getLibraryProvider().getId(); - try { - updateUpdateDDState(libraryProviderID); - updateServletClassName(libraryProviderID); - } catch (Exception e) { - //TODO exception as we are notified in non-UI thread and Invalid thread access exception, - //should find another way to get notified when library provider changes - - } - - } - } - } - super.propertyChanged(event); - } - - private void updateServletClassName(String libraryProviderID) { - servletInfoGroup.txtJAXRSServletClassName.setText(JAXRSLibraryProviderUtil.getServletClassName(libraryProviderID)); - } - -/* - * (non-Javadoc) - * - * @see - * org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage - * #dispose() - */ - public void dispose() - { - if (webAppDataModel != null) - webAppDataModel.removeListener(this); - -// jaxrsLibCfgComp.dispose(); - super.dispose(); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage - * #restoreDefaultSettings() - */ - protected void restoreDefaultSettings() - { - initializeValues(); - -// checkToCompletePage(jaxrsLibCfgComp); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage - * #showValidationErrorsOnEnter() - */ - protected boolean showValidationErrorsOnEnter() - { - return true; - } - - private void setChildrenEnabled(Composite parentComposite, boolean enabled) { - Control[] wsdlControls = parentComposite.getChildren(); - for (int i = 0; i < wsdlControls.length; i++) { - wsdlControls[i].setEnabled(enabled); - } - } - -} diff --git a/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSLibraryPropertyPage.java b/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSLibraryPropertyPage.java deleted file mode 100644 index e234183a1..000000000 --- a/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSLibraryPropertyPage.java +++ /dev/null @@ -1,234 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20091109 291954 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS: Implement JAX-RS Facet - * 20100303 291954 kchong@ca.ibm.com - Keith Chong, JAX-RS: Implement JAX-RS Facet - * 20100319 306594 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS facet install fails for Web 2.3 & 2.4 - * 20100324 306937 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS Properties page- NPE after pressing OK - * 20100325 307059 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS properties page- fields empty or incorrect - * 20100408 308565 kchong@ca.ibm.com - Keith Chong, JAX-RS: Servlet name and class not updated - * 20100413 307552 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS and Java EE 6 setup is incorrect - *******************************************************************************/ -package org.eclipse.jst.ws.jaxrs.ui.internal.project.facet; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider; -import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate; -import org.eclipse.jst.common.project.facet.ui.libprov.LibraryFacetPropertyPage; -import org.eclipse.jst.j2ee.model.IModelProvider; -import org.eclipse.jst.javaee.core.UrlPatternType; -import org.eclipse.jst.javaee.web.Servlet; -import org.eclipse.jst.javaee.web.ServletMapping; -import org.eclipse.jst.javaee.web.WebApp; -import org.eclipse.jst.ws.jaxrs.core.internal.IJAXRSCoreConstants; -import org.eclipse.jst.ws.jaxrs.core.internal.project.facet.IJAXRSFacetInstallDataModelProperties; -import org.eclipse.jst.ws.jaxrs.core.internal.project.facet.JAXRSJ2EEUtils; -import org.eclipse.jst.ws.jaxrs.core.internal.project.facet.JAXRSJEEUtils; -import org.eclipse.jst.ws.jaxrs.core.internal.project.facet.JAXRSUtils; -import org.eclipse.jst.ws.jaxrs.ui.internal.IJAXRSUIConstants; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IProjectFacet; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; - -@SuppressWarnings("restriction") -public final class JAXRSLibraryPropertyPage - -extends LibraryFacetPropertyPage - -implements IJAXRSFacetInstallDataModelProperties - -{ - - private static final String SETTINGS_SERVLET = "servletName"; //$NON-NLS-1$ - private static final String SETTINGS_SERVLET_CLASSNAME = "servletClassname"; //$NON-NLS-1$ - private static final String SETTINGS_URL_MAPPINGS = "urlMappings"; //$NON-NLS-1$ - private static final String SETTINGS_URL_PATTERN = "pattern"; //$NON-NLS-1$ - - private ServletInformationGroup servletInfoGroup; - - private IPath webXMLPath; - private IModelProvider provider; - private Object webAppObj; - - // J2EE - private org.eclipse.jst.j2ee.webapplication.Servlet j2eeServlet = null; - private org.eclipse.jst.j2ee.webapplication.ServletMapping j2eeServletMapping = null; - private String initialInstallDelegateLibraryProviderID =""; //$NON-NLS-1$ - @Override - protected Control createPageContents(Composite parent) - { - Control c = super.createPageContents(parent); - LibraryInstallDelegate initialInstallDelegate = super.getLibraryInstallDelegate(); - if ( initialInstallDelegate != null ) { - ILibraryProvider initialLibraryProvider = initialInstallDelegate.getLibraryProvider(); - if (initialLibraryProvider != null) { - String initID = initialLibraryProvider.getId(); - initialInstallDelegateLibraryProviderID = (initID == null) ? initialInstallDelegateLibraryProviderID : initID; - } - } - this.webXMLPath = new Path("WEB-INF").append("web.xml"); //$NON-NLS-1$ //$NON-NLS-2$ - this.provider = JAXRSUtils.getModelProvider(getProject()); - if (provider != null) - this.webAppObj = provider.getModelObject(); - if (doesDDFileExist(getProject(), this.webXMLPath)) { - servletInfoGroup = new ServletInformationGroup((Composite) c, SWT.NONE); - initializeValues(); - } - return c; - } - - public IProjectFacetVersion getProjectFacetVersion() - { - final IProjectFacet jaxrsFacet = ProjectFacetsManager.getProjectFacet(IJAXRSCoreConstants.JAXRS_FACET_ID); - final IFacetedProject fproj = getFacetedProject(); - return fproj.getInstalledVersion(jaxrsFacet); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - protected void initializeValues() - { - List<ServletMapping> servletMappings = new ArrayList<ServletMapping>(); - if (webAppObj != null) - { - String servletName = JAXRSUtils.JAXRS_DEFAULT_SERVLET_NAME; - String servletClass = ""; //$NON-NLS-1$ - if (JAXRSJEEUtils.isWebApp25or30(webAppObj)) { - WebApp webApp = (WebApp) webAppObj; - Servlet servlet = JAXRSJEEUtils.findJAXRSServlet(webApp); - if (servlet != null) { - servletMappings = webApp.getServletMappings(); - servletName = (servlet.getServletName() == null) ? servletName : servlet.getServletName(); - servletClass =(servlet.getServletClass() == null) ? servletClass : servlet.getServletClass(); - } - } else { - // 2.3 or 2.4 web app - org.eclipse.jst.j2ee.webapplication.WebApp webApp = (org.eclipse.jst.j2ee.webapplication.WebApp) webAppObj; - org.eclipse.jst.j2ee.webapplication.Servlet servlet = JAXRSJ2EEUtils - .findJAXRSServlet(webApp); - if (servlet != null) { - this.j2eeServlet = servlet; - servletMappings = webApp.getServletMappings(); - servletName = (servlet.getServletName() == null) ? servletName : servlet.getServletName(); - if (servlet.getServletClass() != null) { - servletClass =(servlet.getServletClass().getQualifiedName() == null) ? servletClass : servlet.getServletClass().getQualifiedName(); - } - } - - } - servletInfoGroup.txtJAXRSServletName.setText(servletName); - servletInfoGroup.txtJAXRSServletClassName.setText(servletClass); - // Find the servletMapping that corresponds to the servletName - if (JAXRSJEEUtils.isWebApp25or30(webAppObj)) { - servletInfoGroup.lstJAXRSServletURLPatterns.removeAll(); - - for (Iterator<ServletMapping> i = servletMappings.iterator(); i.hasNext();) - { - Object o = i.next(); - if (o instanceof ServletMapping) - { - // init the servletMapping - ServletMapping next = (ServletMapping) o; - if (servletName.equals(next.getServletName())) - { - for (Iterator p = next.getUrlPatterns().iterator(); p.hasNext();) - { - UrlPatternType pattern = (UrlPatternType) p.next(); - servletInfoGroup.lstJAXRSServletURLPatterns.add(pattern.getValue()); - } - } - } - } - } else { - servletInfoGroup.lstJAXRSServletURLPatterns.removeAll(); - for (Iterator<ServletMapping> i = servletMappings.iterator(); i.hasNext();) - { - Object o = i.next(); - if (o instanceof org.eclipse.jst.j2ee.webapplication.ServletMapping) - { - // init the servletMapping - org.eclipse.jst.j2ee.webapplication.ServletMapping next = (org.eclipse.jst.j2ee.webapplication.ServletMapping) o; - org.eclipse.jst.j2ee.webapplication.Servlet aServlet = next.getServlet(); - // the servlet mapping may not have an associated servlet since the user could have modified the file - if (aServlet != null && servletName.equals(aServlet.getServletName())) - { - this.j2eeServletMapping = next; - String pattern = next.getUrlPattern(); - servletInfoGroup.lstJAXRSServletURLPatterns.add(new String(pattern)); - } - } - } - } - } - } - - public boolean performOk() - { - LibraryInstallDelegate installDelegate = super.getLibraryInstallDelegate(); - if ( installDelegate != null ) { - ILibraryProvider libraryProvider = installDelegate.getLibraryProvider(); - if (libraryProvider != null) { - String id = libraryProvider.getId(); - if (!initialInstallDelegateLibraryProviderID.equals(id) || IJAXRSUIConstants.USER_LIBRARY_ID.equals(id)) { - // This will update the libraries by calling the library provider delegate - super.performOk(); - } - } - } - - - // Update the servlet properties - if (doesDDFileExist(getProject(), webXMLPath)) { - createServletAndModifyWebXML(getProject(), null, new NullProgressMonitor()); - } - return true; - } - - private void createServletAndModifyWebXML(final IProject project, final IDataModel config, final IProgressMonitor monitor) - { - List<String> listOfMappings = Arrays.asList(servletInfoGroup.lstJAXRSServletURLPatterns.getItems()); - if (JAXRSJEEUtils.isWebApp25or30(webAppObj)) - { - provider.modify(new UpdateWebXMLForJavaEE(project, servletInfoGroup.txtJAXRSServletName.getText(), servletInfoGroup.txtJAXRSServletClassName.getText(), listOfMappings), - IModelProvider.FORCESAVE); - } - else - // must be 2.3 or 2.4 - { - provider.modify(new UpdateWebXMLForJ2EE(project, this.j2eeServlet, this.j2eeServletMapping, servletInfoGroup.txtJAXRSServletName.getText(), servletInfoGroup.txtJAXRSServletClassName.getText(), listOfMappings), webXMLPath); - } - } - - private boolean doesDDFileExist(IProject project, IPath webXMLPath) - { - return getWebContentPath(project) == null ? false : project.getLocation().append(getWebContentPath(project).lastSegment()).append(webXMLPath).toFile().exists(); - } - private IPath getWebContentPath(IProject project){ - IVirtualComponent component = ComponentCore.createComponent(project); - IPath modulePath = component.getRootFolder().getWorkspaceRelativePath(); - return modulePath; - } -} diff --git a/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSUserLibraryProviderInstallPanel.java b/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSUserLibraryProviderInstallPanel.java deleted file mode 100644 index 21d6259f6..000000000 --- a/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSUserLibraryProviderInstallPanel.java +++ /dev/null @@ -1,284 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20100303 291954 kchong@ca.ibm.com - Keith Chong, JAX-RS: Implement JAX-RS Facet - * 20100310 291954 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS: Implement JAX-RS Facet - * 20100319 306595 ericdp@ca.ibm.com - Eric D. Peters, several install scenarios fail for both user library & non-user library - * 20100324 306937 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS Properties page- NPE after pressing OK - * 20100407 308401 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS facet wizard page - Shared-library option should be disabled - *******************************************************************************/ -package org.eclipse.jst.ws.jaxrs.ui.internal.project.facet; - -import org.eclipse.jst.common.project.facet.core.libprov.IPropertyChangeListener; -import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate; -import org.eclipse.jst.common.project.facet.ui.libprov.user.UserLibraryProviderInstallPanel; -import org.eclipse.jst.ws.jaxrs.core.internal.jaxrslibraryconfig.JAXRSLibraryConfigDialogSettingData; -import org.eclipse.jst.ws.jaxrs.core.internal.jaxrslibraryconfig.JAXRSLibraryConfigModel; -import org.eclipse.jst.ws.jaxrs.core.internal.jaxrslibraryconfig.JAXRSLibraryConfiglModelSource; -import org.eclipse.jst.ws.jaxrs.core.internal.jaxrssharedlibraryconfig.SharedLibraryConfiguratorUtil; -import org.eclipse.jst.ws.jaxrs.core.internal.project.facet.IJAXRSFacetInstallDataModelProperties; -import org.eclipse.jst.ws.jaxrs.core.internal.project.facet.JAXRSUserLibraryProviderInstallOperationConfig; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class JAXRSUserLibraryProviderInstallPanel extends UserLibraryProviderInstallPanel -{ - private JAXRSFacetIncludeLibrariesGroup includeLibsGroup; - private JAXRSLibraryConfigModel workingCopyModel = null; - private IDataModel model; - private JAXRSUserLibraryProviderInstallOperationConfig cfg;; - private ServletInformationGroup servletInfoGroup; - private boolean sharedLibSupported; - - public JAXRSUserLibraryProviderInstallPanel() - { - super(); - } - - protected Control createControlNextToManageHyperlink(final Composite composite) - { - cfg = (JAXRSUserLibraryProviderInstallOperationConfig) getOperationConfig(); - model = cfg.getModel(); - - - Composite mainComp = new Composite(composite, SWT.NONE); - GridLayout gl = new GridLayout(); - gl.numColumns = 1; - gl.marginTop = 0; - gl.marginBottom = 0; - gl.marginRight = 0; - gl.marginLeft = 0; - mainComp.setLayout(gl); - if (!onPropertiesPage()) { - String libraryID = ((LibraryInstallDelegate)model.getProperty(IJAXRSFacetInstallDataModelProperties.LIBRARY_PROVIDER_DELEGATE)).getLibraryProvider().getId(); - sharedLibSupported = SharedLibraryConfiguratorUtil - .isSharedLibSupportAvailable( - libraryID, - model.getStringProperty(IJAXRSFacetInstallDataModelProperties.TARGETRUNTIME), - SharedLibraryConfiguratorUtil - .getWebProject(model), - SharedLibraryConfiguratorUtil - .getEARProject(model), - SharedLibraryConfiguratorUtil - .getAddToEar(model)); - - - //we are in facet install mode - includeLibsGroup = new JAXRSFacetIncludeLibrariesGroup(mainComp, SWT.NONE); - includeLibsGroup.getCopyOnPublishCheckBox().setSelection(cfg.isIncludeWithApplicationEnabled()); - - - - - includeLibsGroup.getCopyOnPublishCheckBox().addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(final SelectionEvent event) { - cfg.setIncludeWithApplicationEnabled(includeLibsGroup - .getCopyOnPublishCheckBox().getSelection()); - boolean deployLib = false; - boolean shareLib = false; - if (includeLibsGroup.getCopyOnPublishCheckBox() - .getSelection()) { - deployLib = includeLibsGroup - .getBtnDeployJars().getSelection(); - shareLib = includeLibsGroup - .getBtnSharedLibrary().getSelection(); - cfg.setIsDeploy(deployLib); - cfg.setSharedLibrary(shareLib); - IDataModel model = cfg.getModel(); - model.setProperty( - IJAXRSFacetInstallDataModelProperties.DEPLOY_IMPLEMENTATION, - deployLib); - model.setProperty( - IJAXRSFacetInstallDataModelProperties.SHAREDLIBRARY, - shareLib); - updateIncludeLibrariesGroupState(shareLib, deployLib, sharedLibSupported); - } else { - cfg.setIsDeploy(deployLib); - cfg.setSharedLibrary(shareLib); - IDataModel model = cfg.getModel(); - model.setProperty( - IJAXRSFacetInstallDataModelProperties.DEPLOY_IMPLEMENTATION, - deployLib); - model.setProperty( - IJAXRSFacetInstallDataModelProperties.SHAREDLIBRARY, - shareLib); - setChildrenEnabled(includeLibsGroup.getIncludeLibRadiosComposite(), false); - - } - - - - } - }); - - includeLibsGroup.getBtnDeployJars().addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - boolean deployLib = includeLibsGroup.getBtnDeployJars() - .getSelection(); - boolean shareLib = includeLibsGroup - .getBtnSharedLibrary().getSelection(); - cfg.setIsDeploy(deployLib); - cfg.setSharedLibrary(shareLib); - IDataModel model = cfg.getModel(); - model.setProperty( - IJAXRSFacetInstallDataModelProperties.DEPLOY_IMPLEMENTATION, - deployLib); - model.setProperty( - IJAXRSFacetInstallDataModelProperties.SHAREDLIBRARY, - shareLib); - } - }); - - includeLibsGroup.getBtnSharedLibrary().addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - boolean deployLib = includeLibsGroup.getBtnDeployJars() - .getSelection(); - boolean shareLib = includeLibsGroup - .getBtnSharedLibrary().getSelection(); - cfg.setIsDeploy(deployLib); - cfg.setSharedLibrary(shareLib); - IDataModel model = cfg.getModel(); - model.setProperty( - IJAXRSFacetInstallDataModelProperties.DEPLOY_IMPLEMENTATION, - deployLib); - model.setProperty( - IJAXRSFacetInstallDataModelProperties.SHAREDLIBRARY, - shareLib); - } - }); - - final IPropertyChangeListener listener = new IPropertyChangeListener() - { - public void propertyChanged(final String property, final Object oldValue, final Object newValue) - { - if (oldValue != newValue) - { -// copyOnPublishCheckBox.setSelection(cfg.isIncludeWithApplicationEnabled()); - } - } - }; - - cfg.addListener(listener, JAXRSUserLibraryProviderInstallOperationConfig.PROP_INCLUDE_WITH_APPLICATION_ENABLED); - - includeLibsGroup.getCopyOnPublishCheckBox().addDisposeListener(new DisposeListener() - { - public void widgetDisposed(final DisposeEvent event) - { - cfg.removeListener(listener); - } - }); - } - - setDownloadCommandEnabled(false); - initialize(); - return mainComp; - } - - private boolean onPropertiesPage() { - return cfg.getModel() == null; - } - - - private void initialize() - { - // if shared lib not supported but shared lib setting was true, assume they - // still want to include libraries - JAXRSLibraryConfiglModelSource source; - if (!onPropertiesPage()) - source = new JAXRSLibraryConfigDialogSettingData(includeLibsGroup.getBtnDeployJars().getSelection(), includeLibsGroup.getBtnSharedLibrary().getSelection(), true); - else - source = new JAXRSLibraryConfigDialogSettingData(true, false, false); - if (source != null) - { - // never read persistentModel = source; - workingCopyModel = JAXRSLibraryConfigModel.JAXRSLibraryConfigModelFactory.createInstance(source); - initializeControlValues(); - } - } - - private void initializeControlValues() - { -// btnDeployJars.setSelection(false); -// btnSharedLibrary.setSelection(false); -// copyOnPublishCheckBox.setSelection(false); - - if (!onPropertiesPage()) - { - boolean bSharedLib = (Boolean) model - .getDefaultProperty(IJAXRSFacetInstallDataModelProperties.SHAREDLIBRARY); - boolean bDeploy = (Boolean) model - .getDefaultProperty(IJAXRSFacetInstallDataModelProperties.DEPLOY_IMPLEMENTATION); - if (sharedLibSupported) { - bSharedLib = SharedLibraryConfiguratorUtil - .isSharedLibSelectedByDefault(model - .getStringProperty(IJAXRSFacetInstallDataModelProperties.TARGETRUNTIME)); - if (!bSharedLib) - bDeploy = true; - else - // don't want both to be true, shared lib takes - // precedence - bDeploy = false; - - } - // set the properties on the model - model.setBooleanProperty( - IJAXRSFacetInstallDataModelProperties.DEPLOY_IMPLEMENTATION, - bDeploy); - if (sharedLibSupported) { - model.setBooleanProperty( - IJAXRSFacetInstallDataModelProperties.SHAREDLIBRARY, - bSharedLib); - } - - updateIncludeLibrariesGroupState(bSharedLib, bDeploy, sharedLibSupported); - - } - -// redraw(); - } - - private void updateIncludeLibrariesGroupState(boolean bSharedLib, boolean bDeploy, boolean sharedLibSupported) { - includeLibsGroup.getCopyOnPublishCheckBox().setEnabled(true); - includeLibsGroup.getCopyOnPublishCheckBox().setSelection(bDeploy - || (sharedLibSupported &&bSharedLib)); - updateChildrenState(bSharedLib, bDeploy, sharedLibSupported); - - } - - private void updateChildrenState(boolean bSharedLib, boolean bDeploy, boolean sharedLibSupported) { - includeLibsGroup.getBtnDeployJars().setSelection(bDeploy - || (includeLibsGroup.getCopyOnPublishCheckBox().getSelection() && (!sharedLibSupported || (sharedLibSupported && !bSharedLib)))); - // shared library has precedence - includeLibsGroup.getBtnSharedLibrary().setSelection(sharedLibSupported - && bSharedLib); - includeLibsGroup.getBtnSharedLibrary().setEnabled(includeLibsGroup.getCopyOnPublishCheckBox().getSelection() && sharedLibSupported); - includeLibsGroup.getBtnDeployJars().setEnabled(includeLibsGroup.getCopyOnPublishCheckBox().getSelection()); - - } - public static void setChildrenEnabled(Composite parentComposite, boolean enabled) { - Control[] wsdlControls = parentComposite.getChildren(); - for (int i=0; i<wsdlControls.length; i++) { - wsdlControls[i].setEnabled(enabled); - } - } - - -} diff --git a/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/ServletInformationGroup.java b/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/ServletInformationGroup.java deleted file mode 100644 index b88100d28..000000000 --- a/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/ServletInformationGroup.java +++ /dev/null @@ -1,201 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20100303 291954 kchong@ca.ibm.com - Keith Chong, JAX-RS: Implement JAX-RS Facet - *******************************************************************************/ -package org.eclipse.jst.ws.jaxrs.ui.internal.project.facet; - -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.dialogs.IInputValidator; -import org.eclipse.jface.dialogs.InputDialog; -import org.eclipse.jface.window.Window; -import org.eclipse.jst.ws.jaxrs.core.internal.project.facet.IJAXRSFacetInstallDataModelProperties; -import org.eclipse.jst.ws.jaxrs.ui.internal.Messages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.List; -import org.eclipse.swt.widgets.Text; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class ServletInformationGroup extends Composite { - - private Group servletInfo; - private Label lblJAXRSServletName; - public Text txtJAXRSServletName; - private Label lblJAXRSServletClassName; - public Text txtJAXRSServletClassName; - private Label lblJAXRSServletURLPatterns; - public List lstJAXRSServletURLPatterns; - public Button btnAddPattern; - public Button btnRemovePattern; - - private IDataModel optionalModel; - - private IDialogSettings dialogSettings; - private IDataModel webAppDataModel; - private String sEARProject = null; - private String sWEBProject = null; - private String sTargetRuntime = null; - private boolean bAddToEAR = false; - private static final String SETTINGS_SERVLET = "servletName"; //$NON-NLS-1$ - private static final String SETTINGS_SERVLET_CLASSNAME = "servletClassname"; //$NON-NLS-1$ - private static final String SETTINGS_URL_MAPPINGS = "urlMappings"; //$NON-NLS-1$ - private static final String SETTINGS_URL_PATTERN = "pattern"; //$NON-NLS-1$ -// private Composite composite = null; - - public ServletInformationGroup(Composite parent, int style) { - super(parent, style); - - GridLayout gridLayout = new GridLayout(1, true); - gridLayout.marginHeight = 0; - gridLayout.marginWidth = 0; - gridLayout.verticalSpacing = 0; - gridLayout.horizontalSpacing = 0; - setLayout(gridLayout); - setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - servletInfo = new Group(this, SWT.NONE); - GridData servletGD = new GridData(GridData.FILL_HORIZONTAL); - servletInfo.setLayoutData(servletGD); - servletInfo.setLayout(new GridLayout(3, false)); - servletInfo.setText(Messages.JAXRSFacetInstallPage_JAXRSServletLabel); - - lblJAXRSServletName = new Label(servletInfo, SWT.NONE); - lblJAXRSServletName - .setText(Messages.JAXRSFacetInstallPage_JAXRSServletNameLabel); - lblJAXRSServletName.setLayoutData(new GridData(GridData.BEGINNING)); - - txtJAXRSServletName = new Text(servletInfo, SWT.BORDER); - GridData gd2 = new GridData(GridData.FILL_HORIZONTAL); - gd2.horizontalSpan = 2; - txtJAXRSServletName.setLayoutData(gd2); - - lblJAXRSServletClassName = new Label(servletInfo, SWT.NONE); - lblJAXRSServletClassName - .setText(Messages.JAXRSFacetInstallPage_JAXRSServletClassNameLabel); - lblJAXRSServletClassName - .setLayoutData(new GridData(GridData.BEGINNING)); - - txtJAXRSServletClassName = new Text(servletInfo, SWT.BORDER); - GridData gd2c = new GridData(GridData.FILL_HORIZONTAL); - gd2c.horizontalSpan = 2; - txtJAXRSServletClassName.setLayoutData(gd2c); - - lblJAXRSServletURLPatterns = new Label(servletInfo, SWT.NULL); - lblJAXRSServletURLPatterns - .setText(Messages.JAXRSFacetInstallPage_JAXRSURLMappingLabel); - lblJAXRSServletURLPatterns.setLayoutData(new GridData( - GridData.BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING)); - lstJAXRSServletURLPatterns = new List(servletInfo, SWT.BORDER); - GridData gd3 = new GridData(GridData.FILL_BOTH); -// gd3.heightHint = convertHeightInCharsToPixels(5); - lstJAXRSServletURLPatterns.setLayoutData(gd3); - lstJAXRSServletURLPatterns.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - btnRemovePattern.setEnabled(lstJAXRSServletURLPatterns - .getSelectionCount() > 0); - } - }); - - Composite btnComposite = new Composite(servletInfo, SWT.NONE); - GridLayout gl = new GridLayout(1, false); - gl.marginLeft = 0; - btnComposite.setLayout(gl); - btnComposite.setLayoutData(new GridData(GridData.END - | GridData.VERTICAL_ALIGN_FILL)); - - btnAddPattern = new Button(btnComposite, SWT.NONE); - btnAddPattern.setText(Messages.JAXRSFacetInstallPage_Add2); - btnAddPattern.setLayoutData(new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING)); - btnAddPattern.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - InputDialog dialog = new InputDialog(getShell(), - Messages.JAXRSFacetInstallPage_PatternDialogTitle, - Messages.JAXRSFacetInstallPage_PatternDialogDesc, null, - new IInputValidator() { - - public String isValid(String newText) { - return isValidPattern(newText); - } - - }); - dialog.open(); - if (dialog.getReturnCode() == Window.OK) { - addItemToList(dialog.getValue(), true); - } - } - }); - - btnRemovePattern = new Button(btnComposite, SWT.NONE); - btnRemovePattern.setText(Messages.JAXRSFacetInstallPage_Remove); - btnRemovePattern.setLayoutData(new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING)); - btnRemovePattern.setEnabled(false); - btnRemovePattern.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - removeItemFromList(lstJAXRSServletURLPatterns.getSelection()); - btnRemovePattern.setEnabled(false); - } - }); - - } - - - - - private String isValidPattern(String value) { - if (value == null || value.trim().equals("")) //$NON-NLS-1$ - return Messages.JAXRSFacetInstallPage_PatternEmptyMsg; - if (lstJAXRSServletURLPatterns.indexOf(value) >= 0) - return Messages.JAXRSFacetInstallPage_PatternSpecifiedMsg; - - return null; - } - - private void addItemToList(String pattern, boolean selectMe) { - lstJAXRSServletURLPatterns.add(pattern == null ? "" : pattern); //$NON-NLS-1$ - if (pattern == null && selectMe) - lstJAXRSServletURLPatterns.setSelection(lstJAXRSServletURLPatterns - .getItemCount() - 1); - // When 119321 is fixed - remove code below - updateModelForURLPattern(); - } - - private void updateModelForURLPattern() { - if (optionalModel != null) - optionalModel.setProperty( - IJAXRSFacetInstallDataModelProperties.SERVLET_URL_PATTERNS, - lstJAXRSServletURLPatterns.getItems()); - } - - private void removeItemFromList(String[] selection) { - for (int i = 0; i < selection.length; i++) { - String sel = selection[i]; - lstJAXRSServletURLPatterns.remove(sel); - } - // When 119321 is fixed - remove code below - updateModelForURLPattern(); - } - - - public void setDataModel(IDataModel model) - { - this.optionalModel = model; - } -} diff --git a/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/UpdateWebXMLBase.java b/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/UpdateWebXMLBase.java deleted file mode 100644 index 5f6af6483..000000000 --- a/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/UpdateWebXMLBase.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20100303 291954 kchong@ca.ibm.com - Keith Chong, JAX-RS: Implement JAX-RS Facet - *******************************************************************************/ -package org.eclipse.jst.ws.jaxrs.ui.internal.project.facet; - -public abstract class UpdateWebXMLBase implements Runnable { - - public abstract void run(); - -} diff --git a/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/UpdateWebXMLForJ2EE.java b/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/UpdateWebXMLForJ2EE.java deleted file mode 100644 index a164d4cb7..000000000 --- a/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/UpdateWebXMLForJ2EE.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20100303 291954 kchong@ca.ibm.com - Keith Chong, JAX-RS: Implement JAX-RS Facet - *******************************************************************************/ -package org.eclipse.jst.ws.jaxrs.ui.internal.project.facet; - -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.j2ee.webapplication.Servlet; -import org.eclipse.jst.j2ee.webapplication.ServletMapping; -import org.eclipse.jst.ws.jaxrs.core.internal.project.facet.JAXRSJ2EEUtils; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class UpdateWebXMLForJ2EE extends UpdateWebXMLBase implements Runnable { - private IProject project; - private Servlet servlet; - private ServletMapping servletMapping; - private String newServletName, newServletClass; - private List<String> listOfMappings; - - public UpdateWebXMLForJ2EE(IProject project, Servlet servlet, ServletMapping servletMapping, String newServletName, String newServletClass, List listOfMappings) { - this.project = project; - this.project = project; - this.servlet = servlet; - this.servletMapping = servletMapping; - this.newServletName = newServletName; - this.newServletClass = newServletClass; - this.listOfMappings = listOfMappings; - } - - public void run() { - org.eclipse.jst.j2ee.webapplication.WebApp webApp = (org.eclipse.jst.j2ee.webapplication.WebApp) ModelProviderManager - .getModelProvider(project).getModelObject(); - - JAXRSJ2EEUtils.createOrUpdateServletRef(webApp, this.newServletName, this.newServletClass, this.servlet); - - JAXRSJ2EEUtils.updateURLMappings(webApp, listOfMappings, servlet); - - } -} diff --git a/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/UpdateWebXMLForJavaEE.java b/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/UpdateWebXMLForJavaEE.java deleted file mode 100644 index 12292d79c..000000000 --- a/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/UpdateWebXMLForJavaEE.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20100303 291954 kchong@ca.ibm.com - Keith Chong, JAX-RS: Implement JAX-RS Facet - * 20100408 308565 kchong@ca.ibm.com - Keith Chong, JAX-RS: Servlet name and class not updated - *******************************************************************************/ -package org.eclipse.jst.ws.jaxrs.ui.internal.project.facet; - -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.javaee.web.Servlet; -import org.eclipse.jst.javaee.web.ServletMapping; -import org.eclipse.jst.javaee.web.WebApp; -import org.eclipse.jst.ws.jaxrs.core.internal.project.facet.JAXRSJEEUtils; - -public class UpdateWebXMLForJavaEE extends UpdateWebXMLBase implements Runnable { - private IProject project; - private String newServletName, newServletClass; - private List<String> listOfMappings; - - /** - * @deprecated - * @param project - * @param servlet - * @param servletMapping - * @param newServletName - * @param newServletClass - * @param listOfMappings - */ - public UpdateWebXMLForJavaEE(final IProject project, Servlet servlet, ServletMapping servletMapping, String newServletName, String newServletClass, List<String> listOfMappings) { - this.project = project; - this.newServletName = newServletName; - this.newServletClass = newServletClass; - this.listOfMappings = listOfMappings; - } - - public UpdateWebXMLForJavaEE(final IProject project, String newServletName, String newServletClass, List<String> listOfMappings) { - this.project = project; - this.newServletName = newServletName; - this.newServletClass = newServletClass; - this.listOfMappings = listOfMappings; - } - - public void run() { - WebApp webApp = (WebApp) ModelProviderManager.getModelProvider(project).getModelObject(); - Servlet servlet = JAXRSJEEUtils.findJAXRSServlet(webApp); - if (servlet != null) { - JAXRSJEEUtils.createOrUpdateServletRef(webApp, this.newServletName, this.newServletClass, servlet); - JAXRSJEEUtils.updateURLMappings(webApp, listOfMappings, servlet); - } - } -} |