JBoss Tools SVN: r16828 - in workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui: META-INF and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2009-07-27 16:08:43 -0400 (Mon, 27 Jul 2009)
New Revision: 16828
Added:
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/ComponentCoreUIPlugin.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/AddFolderDialog.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/AddModuleDependenciesPropertiesPage.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/ComponentDependencyContentProvider.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/DependencyPageExtensionManager.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/EarModuleDependenciesPropertyPage.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/EarModuleDependencyPageProvider.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/ExternalJarReferenceWizardFragment.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/JarReferenceWizardFragment.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/ModuleAssemblyRootPage.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/NewReferenceRootWizardFragment.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/NewReferenceWizard.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/ProjectReferenceWizardFragment.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/VariableReferenceWizardFragment.java
Removed:
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/WTPOveridePlugin.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/AddFolderDialog.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/AddModuleDependenciesPropertiesPage.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ComponentDependencyContentProvider.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/DependencyPageExtensionManager.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ExternalJarReferenceWizardFragment.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/JarReferenceWizardFragment.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ModuleAssemblyRootPage.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/NewReferenceRootWizardFragment.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/NewReferenceWizard.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ProjectReferenceWizardFragment.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/VariableReferenceWizardFragment.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/impl/
Modified:
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/META-INF/MANIFEST.MF
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/plugin.xml
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/Messages.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/IDependencyPageProvider.java
Log:
getting workspace version into decent shape
Modified: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/META-INF/MANIFEST.MF
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/META-INF/MANIFEST.MF 2009-07-27 19:32:57 UTC (rev 16827)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/META-INF/MANIFEST.MF 2009-07-27 20:08:43 UTC (rev 16828)
@@ -3,7 +3,7 @@
Bundle-Name: WTP UI Overrides
Bundle-SymbolicName: org.eclipse.wst.common.componentcore.ui;singleton:=true
Bundle-Version: 1.0.0.qualifier
-Bundle-Activator: org.eclipse.wst.common.componentcore.ui.WTPOveridePlugin
+Bundle-Activator: org.eclipse.wst.common.componentcore.ui.ComponentCoreUIPlugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.core.resources;bundle-version="3.5.0",
Modified: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/plugin.xml
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/plugin.xml 2009-07-27 19:32:57 UTC (rev 16827)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/plugin.xml 2009-07-27 20:08:43 UTC (rev 16828)
@@ -11,7 +11,7 @@
adaptable="true"
objectClass="org.eclipse.core.resources.IProject"
name="Module Assembly"
- class="org.eclipse.wst.common.componentcore.ui.propertypage.ModuleAssemblyRootPage"
+ class="org.eclipse.wst.common.componentcore.ui.propertypage.internal.ModuleAssemblyRootPage"
id="org.eclipse.wst.common.componentcore.ui.J2EEDependenciesPage">
<enabledWhen>
<and>
@@ -25,32 +25,32 @@
<extension
point="org.eclipse.wst.common.componentcore.ui.moduleDependencyPropertyPage">
<dependencyPage
- class="org.eclipse.wst.common.componentcore.ui.propertypage.impl.EarModuleDependencyPageProvider"
+ class="org.eclipse.wst.common.componentcore.ui.propertypage.internal.EarModuleDependencyPageProvider"
id="org.eclipse.wst.common.componentcore.ui.earDependencyPage">
</dependencyPage>
</extension>
<extension
point="org.eclipse.wst.common.componentcore.ui.referenceWizardFragment">
<referenceFragment
- class="org.eclipse.wst.common.componentcore.ui.propertypage.ProjectReferenceWizardFragment"
+ class="org.eclipse.wst.common.componentcore.ui.propertypage.internal.ProjectReferenceWizardFragment"
icon="icons/prj_obj.gif"
id="org.eclipse.wst.common.componentcore.ui.newProjectReference"
name="Project">
</referenceFragment>
<referenceFragment
- class="org.eclipse.wst.common.componentcore.ui.propertypage.JarReferenceWizardFragment"
+ class="org.eclipse.wst.common.componentcore.ui.propertypage.internal.JarReferenceWizardFragment"
icon="icons/jar_obj.gif"
id="org.eclipse.wst.common.componentcore.ui.jarReference"
name="Jar">
</referenceFragment>
<referenceFragment
- class="org.eclipse.wst.common.componentcore.ui.propertypage.ExternalJarReferenceWizardFragment"
+ class="org.eclipse.wst.common.componentcore.ui.propertypage.internal.ExternalJarReferenceWizardFragment"
icon="icons/jar_obj.gif"
id="org.eclipse.wst.common.componentcore.ui.externalJarReference"
name="External Jar">
</referenceFragment>
<referenceFragment
- class="org.eclipse.wst.common.componentcore.ui.propertypage.VariableReferenceWizardFragment"
+ class="org.eclipse.wst.common.componentcore.ui.propertypage.internal.VariableReferenceWizardFragment"
icon="icons/jar_obj.gif"
id="org.eclipse.wst.common.componentcore.ui.variableReference"
name="Variable">
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/ComponentCoreUIPlugin.java (from rev 16826, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/WTPOveridePlugin.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/ComponentCoreUIPlugin.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/ComponentCoreUIPlugin.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -0,0 +1,87 @@
+package org.eclipse.wst.common.componentcore.ui;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class ComponentCoreUIPlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.wst.common.componentcore.ui"; //$NON-NLS-1$
+
+ // The shared instance
+ private static ComponentCoreUIPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public ComponentCoreUIPlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static ComponentCoreUIPlugin getDefault() {
+ return plugin;
+ }
+
+ public static void log(Exception e) {
+ log(e.getMessage(), e);
+ }
+
+ public static void log(String message, Exception e) {
+ IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, message, e);
+ getDefault().getLog().log(status);
+ }
+ public static IStatus createStatus(int severity, int aCode,
+ String aMessage, Throwable exception) {
+ return new Status(severity, PLUGIN_ID, aCode,
+ aMessage != null ? aMessage : "No message.", exception); //$NON-NLS-1$
+ }
+ public static IStatus createErrorStatus(int aCode, String aMessage,
+ Throwable exception) {
+ return createStatus(IStatus.ERROR, aCode, aMessage, exception);
+ }
+
+ public static IStatus createStatus(int severity, String message, Throwable exception) {
+ return new Status(severity, PLUGIN_ID, message, exception);
+ }
+
+ public static IStatus createStatus(int severity, String message) {
+ return createStatus(severity, message, null);
+ }
+ public static void logError(Throwable exception) {
+ Platform.getLog(Platform.getBundle(PLUGIN_ID)).log( createStatus(IStatus.ERROR, exception.getMessage(), exception));
+ }
+
+ public static void logError(CoreException exception) {
+ Platform.getLog(Platform.getBundle(PLUGIN_ID)).log( exception.getStatus() );
+ }
+
+}
Modified: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/Messages.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/Messages.java 2009-07-27 19:32:57 UTC (rev 16827)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/Messages.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -4,13 +4,8 @@
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.wst.common.componentcore.ui.messages"; //$NON-NLS-1$
- public static String AddModuleDependenciesPropertiesPage_AddProjectButton;
public static String AddModuleDependenciesPropertiesPage_DeployPathColumn;
- public static String AddModuleDependenciesPropertiesPage_RemoveSelectedButton;
- public static String AddModuleDependenciesPropertiesPage_SelectAProjectTitle;
public static String AddModuleDependenciesPropertiesPage_SourceColumn;
- public static String J2EEDependenciesPage_Description;
- public static String J2EEDependenciesPage_ErrorCheckingFacets;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/WTPOveridePlugin.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/WTPOveridePlugin.java 2009-07-27 19:32:57 UTC (rev 16827)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/WTPOveridePlugin.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -1,87 +0,0 @@
-package org.eclipse.wst.common.componentcore.ui;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class WTPOveridePlugin extends AbstractUIPlugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.eclipse.wst.common.componentcore.ui"; //$NON-NLS-1$
-
- // The shared instance
- private static WTPOveridePlugin plugin;
-
- /**
- * The constructor
- */
- public WTPOveridePlugin() {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static WTPOveridePlugin getDefault() {
- return plugin;
- }
-
- public static void log(Exception e) {
- log(e.getMessage(), e);
- }
-
- public static void log(String message, Exception e) {
- IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, message, e);
- getDefault().getLog().log(status);
- }
- public static IStatus createStatus(int severity, int aCode,
- String aMessage, Throwable exception) {
- return new Status(severity, PLUGIN_ID, aCode,
- aMessage != null ? aMessage : "No message.", exception); //$NON-NLS-1$
- }
- public static IStatus createErrorStatus(int aCode, String aMessage,
- Throwable exception) {
- return createStatus(IStatus.ERROR, aCode, aMessage, exception);
- }
-
- public static IStatus createStatus(int severity, String message, Throwable exception) {
- return new Status(severity, PLUGIN_ID, message, exception);
- }
-
- public static IStatus createStatus(int severity, String message) {
- return createStatus(severity, message, null);
- }
- public static void logError(Throwable exception) {
- Platform.getLog(Platform.getBundle(PLUGIN_ID)).log( createStatus(IStatus.ERROR, exception.getMessage(), exception));
- }
-
- public static void logError(CoreException exception) {
- Platform.getLog(Platform.getBundle(PLUGIN_ID)).log( exception.getStatus() );
- }
-
-}
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/AddFolderDialog.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/AddFolderDialog.java 2009-07-27 19:32:57 UTC (rev 16827)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/AddFolderDialog.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -1,133 +0,0 @@
-package org.eclipse.wst.common.componentcore.ui.propertypage;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.dialogs.TitleAreaDialog;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-
-public class AddFolderDialog extends TitleAreaDialog {
- private IProject project;
- private TreeViewer viewer;
- private IContainer selected = null;
- public AddFolderDialog(Shell parentShell, IProject project) {
- super(parentShell);
- this.project = project;
- }
-
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- shell.setText("Add Folder");
- shell.setBounds(shell.getLocation().x, shell.getLocation().y, 400,300);
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite c = (Composite)super.createDialogArea(parent);
- this.viewer = new TreeViewer(c, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- viewer.setContentProvider(getContentProvider());
- viewer.setLabelProvider(getLabelProvider());
- viewer.addFilter(getFilter());
- viewer.setInput(project);
- viewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
- viewer.addSelectionChangedListener(getListener());
- return c;
- }
-
- protected ISelectionChangedListener getListener() {
- return new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection sel = (IStructuredSelection)viewer.getSelection();
- Object first = sel.getFirstElement();
- if( first instanceof IContainer)
- selected = (IContainer)first;
- }
- };
- }
-
- public IContainer getSelected() {
- return selected;
- }
-
- protected ViewerFilter getFilter() {
- return new ViewerFilter() {
- public boolean select(Viewer viewer, Object parentElement,
- Object element) {
- return element instanceof IContainer;
- }
- };
- }
-
- protected ITreeContentProvider getContentProvider() {
- return new ITreeContentProvider() {
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- public void dispose() {
- }
-
- public Object[] getElements(Object inputElement) {
- try {
- return project.members();
- } catch( CoreException ce ) {
- return new Object[]{};
- }
- }
-
- public boolean hasChildren(Object element) {
- if( element instanceof IContainer) {
- try {
- return ((IContainer)element).members().length > 0;
- } catch( CoreException ce ) {
- }
- }
- return false;
- }
-
- public Object getParent(Object element) {
- if( element instanceof IResource)
- return ((IResource)element).getParent();
- return null;
- }
-
- public Object[] getChildren(Object parentElement) {
- if( parentElement instanceof IContainer) {
- try {
- return ((IContainer)parentElement).members();
- } catch( CoreException ce ) {
- }
- }
- return new Object[]{};
- }
- };
- }
-
- protected LabelProvider getLabelProvider() {
- return new LabelProvider() {
- public Image getImage(Object element) {
- return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
- }
- public String getText(Object element) {
- if( element instanceof IResource)
- return ((IResource)element).getName();
- return element.toString();
- }
- };
- }
-}
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/AddModuleDependenciesPropertiesPage.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/AddModuleDependenciesPropertiesPage.java 2009-07-27 19:32:57 UTC (rev 16827)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/AddModuleDependenciesPropertiesPage.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -1,893 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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
- * David Schneider, david.schneider(a)unisys.com - [142500] WTP properties pages fonts don't follow Eclipse preferences
- * Stefan Dimov, stefan.dimov(a)sap.com - bugs 207826, 222651
- *******************************************************************************/
-package org.eclipse.wst.common.componentcore.ui.propertypage;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-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.jface.dialogs.Dialog;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.ICellModifier;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TextCellEditor;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FillLayout;
-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.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties;
-import org.eclipse.wst.common.componentcore.internal.ComponentResource;
-import org.eclipse.wst.common.componentcore.internal.StructureEdit;
-import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent;
-import org.eclipse.wst.common.componentcore.internal.operation.CreateReferenceComponentsDataModelProvider;
-import org.eclipse.wst.common.componentcore.internal.operation.RemoveReferenceComponentsDataModelProvider;
-import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
-import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
-import org.eclipse.wst.common.componentcore.ui.Messages;
-import org.eclipse.wst.common.componentcore.ui.WTPOveridePlugin;
-import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
-
-public class AddModuleDependenciesPropertiesPage implements Listener,
- IModuleDependenciesControl {
-
- private static final String DEPLOY_PATH_PROPERTY = new Integer(0).toString();
- private static final String SOURCE_PROPERTY = new Integer(1).toString();
-
-
- protected final String PATH_SEPARATOR = ComponentDependencyContentProvider.PATH_SEPARATOR;
- private boolean hasInitialized = false;
- protected final IProject project;
- protected final ModuleAssemblyRootPage propPage;
- protected IVirtualComponent rootComponent = null;
- protected Text componentNameText;
- protected Label availableModules;
- protected TableViewer availableComponentsViewer;
- protected Button addMappingButton, addReferenceButton, removeButton;
- protected Composite buttonColumn;
- protected static final IStatus OK_STATUS = IDataModelProvider.OK_STATUS;
- protected Listener tableListener;
- protected Listener labelListener;
-
- // Mappings that existed when the page was opened (or last saved)
- protected HashMap<IVirtualComponent, String> oldComponentToRuntimePath = new HashMap<IVirtualComponent, String>();
-
- // Mappings that are current
- protected HashMap<IVirtualComponent, String> objectToRuntimePath = new HashMap<IVirtualComponent, String>();
-
- // A single list of wb-resource mappings. If there's any change,
- // all old will be removed and new ones added
- protected ArrayList<ComponentResourceProxy> resourceMappings = new ArrayList<ComponentResourceProxy>();
-
- // keeps track if a change has occurred in wb-resource mappings
- protected boolean resourceMappingsChanged = false;
-
- /**
- * Constructor for AddModulestoEARPropertiesControl.
- */
- public AddModuleDependenciesPropertiesPage(final IProject project,
- final ModuleAssemblyRootPage page) {
- this.project = project;
- this.propPage = page;
- rootComponent = ComponentCore.createComponent(project);
- }
-
- /*
- * UI Creation Methods
- */
-
- public Composite createContents(final Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.marginWidth = 0;
- layout.marginWidth = 0;
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- ModuleAssemblyRootPage.createDescriptionComposite(composite,
- "TODO Change this: Create and change packaging structure for this project ");
- createListGroup(composite);
- refresh();
- Dialog.applyDialogFont(parent);
- return composite;
- }
-
- protected void createListGroup(Composite parent) {
- Composite listGroup = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- listGroup.setLayout(layout);
- GridData gData = new GridData(GridData.FILL_BOTH);
- gData.horizontalIndent = 5;
- listGroup.setLayoutData(gData);
-
- availableModules = new Label(listGroup, SWT.NONE);
- gData = new GridData(GridData.HORIZONTAL_ALIGN_FILL
- | GridData.VERTICAL_ALIGN_FILL);
- availableModules.setText("Module Assembly"); //$NON-NLS-1$
- availableModules.setLayoutData(gData);
- createTableComposite(listGroup);
- }
-
- protected void createTableComposite(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- GridData gData = new GridData(GridData.FILL_BOTH);
- composite.setLayoutData(gData);
- fillComposite(composite);
- }
-
- public void fillComposite(Composite parent) {
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- layout.marginHeight = 0;
- parent.setLayout(layout);
- parent.setLayoutData(new GridData(GridData.FILL_BOTH));
- createTable(parent);
- createButtonColumn(parent);
- }
-
- protected void createButtonColumn(Composite parent) {
- buttonColumn = createButtonColumnComposite(parent);
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END);
- buttonColumn.setLayoutData(data);
- createPushButtons();
- }
-
- protected void createPushButtons() {
- addMappingButton = createPushButton("Add Folder...");
- addReferenceButton = createPushButton("Add Reference...");
- removeButton = createPushButton("Remove selected");
- }
-
- protected Button createPushButton(String label) {
- Button aButton = new Button(buttonColumn, SWT.PUSH);
- aButton.setText(label);
- aButton.addListener(SWT.Selection, this);
- aButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- return aButton;
- }
-
- public Composite createButtonColumnComposite(Composite parent) {
- Composite aButtonColumn = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- aButtonColumn.setLayout(layout);
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL
- | GridData.VERTICAL_ALIGN_BEGINNING);
- aButtonColumn.setLayoutData(data);
- return aButtonColumn;
- }
-
- public Group createGroup(Composite parent) {
- return new Group(parent, SWT.NULL);
- }
-
- protected void createTable(Composite parent) {
- if (rootComponent != null) {
- availableComponentsViewer = createAvailableComponentsViewer(parent);
- GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL
- | GridData.FILL_VERTICAL);
- availableComponentsViewer.getTable().setLayoutData(gd);
-
- ComponentDependencyContentProvider provider = createProvider();
- provider.setRuntimePaths(objectToRuntimePath);
- provider.setResourceMappings(resourceMappings);
- availableComponentsViewer.setContentProvider(provider);
- availableComponentsViewer.setLabelProvider(provider);
- addTableListeners();
- }
- }
-
- /**
- * Subclasses should over-ride this and extend the class
- */
- protected ComponentDependencyContentProvider createProvider() {
- return new ComponentDependencyContentProvider();
- }
-
- /*
- * Listeners of various events
- */
-
- protected void addTableListeners() {
- addHoverHelpListeners();
- addDoubleClickListener();
- addSelectionListener();
- }
-
- protected void addHoverHelpListeners() {
- final Table table = availableComponentsViewer.getTable();
- createLabelListener(table);
- createTableListener(table);
- table.addListener(SWT.Dispose, tableListener);
- table.addListener(SWT.KeyDown, tableListener);
- table.addListener(SWT.MouseMove, tableListener);
- table.addListener(SWT.MouseHover, tableListener);
- }
-
- protected void createLabelListener(final Table table) {
- labelListener = new Listener() {
- public void handleEvent(Event event) {
- Label label = (Label) event.widget;
- Shell shell = label.getShell();
- switch (event.type) {
- case SWT.MouseDown:
- Event e = new Event();
- e.item = (TableItem) label.getData("_TABLEITEM"); //$NON-NLS-1$
- table.setSelection(new TableItem[] { (TableItem) e.item });
- table.notifyListeners(SWT.Selection, e);
- shell.dispose();
- table.setFocus();
- break;
- case SWT.MouseExit:
- shell.dispose();
- break;
- }
- }
- };
- }
-
- protected void createTableListener(final Table table) {
- tableListener = new Listener() {
- Shell tip = null;
- Label label = null;
-
- public void handleEvent(Event event) {
- switch (event.type) {
- case SWT.Dispose:
- case SWT.KeyDown:
- case SWT.MouseMove: {
- if (tip == null)
- break;
- tip.dispose();
- tip = null;
- label = null;
- break;
- }
- case SWT.MouseHover: {
- TableItem item = table.getItem(new Point(event.x, event.y));
- if (item != null && item.getData() != null && !canEdit(item.getData())) {
- if (tip != null && !tip.isDisposed())
- tip.dispose();
- tip = new Shell(PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getShell(),
- SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL);
- tip.setBackground(Display.getDefault().getSystemColor(
- SWT.COLOR_INFO_BACKGROUND));
- FillLayout layout = new FillLayout();
- layout.marginWidth = 2;
- tip.setLayout(layout);
- label = new Label(tip, SWT.WRAP);
- label.setForeground(Display.getDefault()
- .getSystemColor(SWT.COLOR_INFO_FOREGROUND));
- label.setBackground(Display.getDefault()
- .getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- label.setData("_TABLEITEM", item); //$NON-NLS-1$
- label.setText(J2EEUIMessages
- .getResourceString(J2EEUIMessages.HOVER_HELP_FOR_DISABLED_LIBS));
- label.addListener(SWT.MouseExit, labelListener);
- label.addListener(SWT.MouseDown, labelListener);
- Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- Rectangle rect = item.getBounds(0);
- Point pt = table.toDisplay(rect.x, rect.y);
- tip.setBounds(pt.x, pt.y - size.y, size.x, size.y);
- tip.setVisible(true);
- }
- }
- }
- }
- };
- }
-
- protected boolean canEdit(Object data) {
- if( data == null ) return false;
- if( !(data instanceof VirtualArchiveComponent)) return true;
-
- VirtualArchiveComponent d2 = (VirtualArchiveComponent)data;
- boolean sameProject = d2.getWorkspaceRelativePath() != null
- && d2.getWorkspaceRelativePath().segment(0)
- .equals(rootComponent.getProject().getName());
- return !(sameProject && isPhysicallyAdded(d2));
- }
-
- protected void addDoubleClickListener() {
- availableComponentsViewer.setColumnProperties(new String[] {
- DEPLOY_PATH_PROPERTY, SOURCE_PROPERTY });
-
- CellEditor[] editors = new CellEditor[] {
- new TextCellEditor(availableComponentsViewer.getTable()),
- new TextCellEditor()};
- availableComponentsViewer.setCellEditors(editors);
- availableComponentsViewer
- .setCellModifier(new RuntimePathCellModifier());
- }
-
- protected void addSelectionListener() {
- availableComponentsViewer.addSelectionChangedListener(
- new ISelectionChangedListener(){
- public void selectionChanged(SelectionChangedEvent event) {
- viewerSelectionChanged();
- }
- });
- }
-
- protected void viewerSelectionChanged() {
- removeButton.setEnabled(getSelectedObject() != null && canEdit(getSelectedObject()));
- }
-
- protected Object getSelectedObject() {
- IStructuredSelection sel = (IStructuredSelection)availableComponentsViewer.getSelection();
- return sel.getFirstElement();
- }
-
- private class RuntimePathCellModifier implements ICellModifier {
-
- public boolean canModify(Object element, String property) {
- if( property.equals(DEPLOY_PATH_PROPERTY)) {
- if (element instanceof VirtualArchiveComponent) {
- try {
- return canEdit(element);
- } catch (IllegalArgumentException iae) {
- }
- }
- return true;
- }
- return false;
- }
-
- public Object getValue(Object element, String property) {
- Object data = element; //((TableItem)element).getData();
- if( data instanceof IVirtualComponent ) {
- return objectToRuntimePath.get(element) == null ? new Path("/") //$NON-NLS-1$
- .toString() : objectToRuntimePath.get(element);
- } else if( data instanceof ComponentResourceProxy) {
- return ((ComponentResourceProxy)data).runtimePath.toString();
- }
- return new Path("/");
- }
-
- public void modify(Object element, String property, Object value) {
- if (property.equals(DEPLOY_PATH_PROPERTY)) {
- TableItem item = (TableItem) element;
- if( item.getData() instanceof IVirtualComponent) {
- objectToRuntimePath.put((IVirtualComponent)item.getData(), (String) value);
- } else if( item.getData() instanceof ComponentResourceProxy) {
- ComponentResourceProxy c = ((ComponentResourceProxy)item.getData());
- c.runtimePath = new Path((String)value);
- resourceMappingsChanged = true;
- }
- refresh();
- }
- }
-
- }
-
- public void handleEvent(Event event) {
- if( event.widget == addMappingButton)
- handleAddMappingButton();
- else if( event.widget == addReferenceButton)
- handleAddReferenceButton();
- else if( event.widget == removeButton )
- handleRemoveSelectedButton();
- }
-
- protected void handleAddMappingButton() {
- AddFolderDialog afd = new AddFolderDialog(addMappingButton.getShell(), project);
- if( afd.open() == Window.OK) {
- IContainer c = afd.getSelected();
- if( c != null ) {
- IPath p = c.getProjectRelativePath();
- ComponentResourceProxy proxy = new ComponentResourceProxy(p, new Path("/"));
- resourceMappings.add(proxy);
- refresh();
- }
- }
- }
-
- protected void handleAddReferenceButton() {
- NewReferenceWizard wizard = new NewReferenceWizard();
- // fill the task model
- wizard.getTaskModel().putObject(NewReferenceWizard.PROJECT, project);
- wizard.getTaskModel().putObject(NewReferenceWizard.ROOT_COMPONENT, rootComponent);
-
- WizardDialog wd = new WizardDialog(addReferenceButton.getShell(), wizard);
- if( wd.open() != Window.CANCEL) {
- Object c1 = wizard.getTaskModel().getObject(NewReferenceWizard.COMPONENT);
- Object p1 = wizard.getTaskModel().getObject(NewReferenceWizard.COMPONENT_PATH);
- IVirtualComponent[] compArr = c1 instanceof IVirtualComponent ?
- new IVirtualComponent[] { (IVirtualComponent)c1 } :
- (IVirtualComponent[])c1;
- String[] pathArr = p1 instanceof String ?
- new String[] { (String)p1 } :
- (String[])p1;
- for( int i = 0; i < compArr.length; i++ ) {
- objectToRuntimePath.put(compArr[i], pathArr[i]);
- }
- refresh();
- }
- }
-
- protected void handleRemoveSelectedButton() {
- ISelection sel = availableComponentsViewer.getSelection();
- if( sel instanceof IStructuredSelection ) {
- Object o = ((IStructuredSelection)sel).getFirstElement();
- if( o instanceof IVirtualComponent)
- objectToRuntimePath.remove(o);
- else if( o instanceof ComponentResourceProxy)
- resourceMappings.remove(o);
- refresh();
- }
- }
-
- public TableViewer createAvailableComponentsViewer(Composite parent) {
- int flags = SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI;
-
- Table table = new Table(parent, flags);
- availableComponentsViewer = new TableViewer(table);
-
- // set up table layout
- TableLayout tableLayout = new org.eclipse.jface.viewers.TableLayout();
- tableLayout.addColumnData(new ColumnWeightData(400, true));
- tableLayout.addColumnData(new ColumnWeightData(500, true));
- table.setLayout(tableLayout);
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
- availableComponentsViewer.setSorter(null);
-
- TableColumn bndColumn = new TableColumn(table, SWT.NONE, 0);
- bndColumn.setText(Messages.AddModuleDependenciesPropertiesPage_DeployPathColumn);
- bndColumn.setResizable(true);
-
- TableColumn projectColumn = new TableColumn(table, SWT.NONE, 1);
- projectColumn.setText(Messages.AddModuleDependenciesPropertiesPage_SourceColumn);
- projectColumn.setResizable(true);
-
- tableLayout.layout(table, true);
- return availableComponentsViewer;
-
- }
-
- protected boolean isPhysicallyAdded(VirtualArchiveComponent component) {
- try {
- component.getProjectRelativePath();
- return true;
- } catch (IllegalArgumentException e) {
- return false;
- }
- }
-
- /**
- * This should only be called on changes, such as adding a project
- * reference, adding a lib reference etc.
- *
- * It will reset the input, manually re-add missing elements, and do other
- * tasks
- */
- public void refresh() {
- resetTableUI();
- if (!hasInitialized) {
- initialize();
- resetTableUI();
- }
-
- }
-
- protected void resetTableUI() {
- IWorkspaceRoot input = ResourcesPlugin.getWorkspace().getRoot();
- availableComponentsViewer.setInput(input);
- GridData data = new GridData(GridData.FILL_BOTH);
- int numlines = Math.min(10, availableComponentsViewer.getTable()
- .getItemCount());
- data.heightHint = availableComponentsViewer.getTable().getItemHeight()
- * numlines;
- availableComponentsViewer.getTable().setLayoutData(data);
- GridData btndata = new GridData(GridData.HORIZONTAL_ALIGN_FILL
- | GridData.VERTICAL_ALIGN_BEGINNING);
- buttonColumn.setLayoutData(btndata);
- }
-
- protected void initialize() {
- IVirtualReference[] refs = rootComponent.getReferences();
- IVirtualComponent comp;
- for( int i = 0; i < refs.length; i++ ) {
- comp = refs[i].getReferencedComponent();
- String val = refs[i].getRuntimePath().append(refs[i].getArchiveName()).toString();
- objectToRuntimePath.put(comp, val);
- oldComponentToRuntimePath.put((IVirtualComponent) comp, val);
- }
-
- ComponentResource[] allMappings = findAllMappings();
- for( int i = 0; i < allMappings.length; i++ ) {
- resourceMappings.add(new ComponentResourceProxy(
- allMappings[i].getSourcePath(), allMappings[i].getRuntimePath()
- ));
- }
- hasInitialized = true;
- }
-
- protected ComponentResource[] findAllMappings() {
- StructureEdit structureEdit = null;
- try {
- structureEdit = StructureEdit.getStructureEditForRead(project);
- WorkbenchComponent component = structureEdit.getComponent();
- Object[] arr = component.getResources().toArray();
- ComponentResource[] result = new ComponentResource[arr.length];
- for( int i = 0; i < arr.length; i++ )
- result[i] = (ComponentResource)arr[i];
- return result;
- } catch(Exception e) {
- } finally {
- structureEdit.dispose();
- }
- return new ComponentResource[]{};
- }
-
- public class ComponentResourceProxy {
- public IPath source, runtimePath;
- public ComponentResourceProxy(IPath source, IPath runtimePath) {
- this.source = source;
- this.runtimePath = runtimePath;
- }
- }
-
- /*
- * Clean-up methods are below. These include performCancel, performDefaults,
- * performOK, and any other methods that are called *only* by this one.
- */
- public void setVisible(boolean visible) {
- }
-
- public void performDefaults() {
- }
-
- public boolean performCancel() {
- return true;
- }
-
- public void dispose() {
- Table table = null;
- if (availableComponentsViewer != null) {
- table = availableComponentsViewer.getTable();
- }
- if (table == null || tableListener == null)
- return;
- table.removeListener(SWT.Dispose, tableListener);
- table.removeListener(SWT.KeyDown, tableListener);
- table.removeListener(SWT.MouseMove, tableListener);
- table.removeListener(SWT.MouseHover, tableListener);
- }
-
-
-
- /*
- * This is where the OK work goes. Lots of it. Watch your head.
- * xiao xin
- */
- protected boolean preHandleChanges(IProgressMonitor monitor) {
- return true;
- }
-
- protected boolean postHandleChanges(IProgressMonitor monitor) {
- return true;
- }
-
- public boolean performOk() {
- boolean result = true;
- result &= saveResourceChanges();
- result &= saveReferenceChanges();
- return result;
- }
-
- protected boolean saveResourceChanges() {
- removeAllResourceMappings();
- addNewResourceMappings();
- return true;
- }
- protected boolean addNewResourceMappings() {
- ComponentResourceProxy[] proxies = (ComponentResourceProxy[]) resourceMappings.toArray(new ComponentResourceProxy[resourceMappings.size()]);
- IVirtualFolder rootFolder = rootComponent.getRootFolder();
- for( int i = 0; i < proxies.length; i++ ) {
- try {
- rootFolder.getFolder(proxies[i].runtimePath).createLink(proxies[i].source, 0, null);
- } catch( CoreException ce ) {
- }
- }
- resourceMappingsChanged = false;
- return true;
- }
-
- protected boolean removeAllResourceMappings() {
- StructureEdit moduleCore = null;
- try {
- moduleCore = StructureEdit.getStructureEditForWrite(project);
- moduleCore.getComponent().getResources().clear();
- }
- finally {
- if (moduleCore != null) {
- moduleCore.saveIfNecessary(new NullProgressMonitor());
- moduleCore.dispose();
- }
- }
- return true;
- }
-
- protected boolean saveReferenceChanges() {
- // Fill our delta lists
- ArrayList<IVirtualComponent> added = new ArrayList<IVirtualComponent>();
- ArrayList<IVirtualComponent> removed = new ArrayList<IVirtualComponent>();
- ArrayList<IVirtualComponent> changed = new ArrayList<IVirtualComponent>();
-
- Iterator<IVirtualComponent> j = oldComponentToRuntimePath.keySet().iterator();
- Object key, val;
- while (j.hasNext()) {
- key = j.next();
- val = oldComponentToRuntimePath.get(key);
- if( !objectToRuntimePath.containsKey(key))
- removed.add((IVirtualComponent)key);
- else if (!val.equals(objectToRuntimePath.get(key)))
- changed.add((IVirtualComponent)key);
- }
-
- j = objectToRuntimePath.keySet().iterator();
- while (j.hasNext()) {
- key = j.next();
- if (!oldComponentToRuntimePath.containsKey(key))
- added.add((IVirtualComponent)key);
- }
-
- NullProgressMonitor monitor = new NullProgressMonitor();
- boolean subResult = preHandleChanges(monitor);
- if( !subResult )
- return false;
-
- handleDeltas(removed, changed, added);
- subResult &= postHandleChanges(monitor);
-
- // Now update the variables
- oldComponentToRuntimePath.clear();
- ArrayList<IVirtualComponent> keys = new ArrayList<IVirtualComponent>();
- keys.addAll(objectToRuntimePath.keySet());
- Iterator<IVirtualComponent> i = keys.iterator();
- while(i.hasNext()) {
- IVirtualComponent vc = i.next();
- String path = objectToRuntimePath.get(vc);
- oldComponentToRuntimePath.put(vc, path);
- }
- return subResult;
- }
-
- // Subclass can override if it has a good way to handle changed elements
- protected void handleDeltas(ArrayList<IVirtualComponent> removed,
- ArrayList<IVirtualComponent> changed, ArrayList<IVirtualComponent> added) {
- ArrayList<IVirtualComponent> removed2 = new ArrayList<IVirtualComponent>();
- ArrayList<IVirtualComponent> added2 = new ArrayList<IVirtualComponent>();
- removed2.addAll(removed);
- removed2.addAll(changed);
- added2.addAll(added);
- added2.addAll(changed);
-
- // meld the changed into the added / removed for less efficiency ;)
- // basically we lack "change" operations and only have add / remove
- handleRemoved(removed2);
- handleAdded(added2);
- }
- protected void handleRemoved(ArrayList<IVirtualComponent> removed) {
- // If it's removed it should *only* be a virtual component already
- Iterator<IVirtualComponent> i = removed.iterator();
- IVirtualComponent component;
- while(i.hasNext()) {
- try {
- component = i.next();
- IDataModelOperation operation = getRemoveComponentOperation(component);
- operation.execute(null, null);
- } catch( ExecutionException e) {
- WTPOveridePlugin.logError(e);
- }
- }
- }
-
- protected IDataModelOperation getRemoveComponentOperation(IVirtualComponent component) {
- String path, archiveName;
- path = new Path(oldComponentToRuntimePath.get(component)).removeLastSegments(1).toString();
- archiveName = new Path(oldComponentToRuntimePath.get(component)).lastSegment();
-
- IDataModelProvider provider = getRemoveReferenceDataModelProvider(component);
- IDataModel model = DataModelFactory.createDataModel(provider);
- model.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, rootComponent);
- List<IVirtualComponent> modHandlesList = (List<IVirtualComponent>) model.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST);
- modHandlesList.add(component);
- model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, modHandlesList);
- model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH, path);
- Map<IVirtualComponent, String> uriMap = new HashMap<IVirtualComponent, String>();
- uriMap.put(component, archiveName);
- model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, uriMap);
- return model.getDefaultOperation();
- }
-
- protected IDataModelProvider getRemoveReferenceDataModelProvider(IVirtualComponent component) {
- return new RemoveReferenceComponentsDataModelProvider();
- }
-
-
- protected void handleChanged(ArrayList<IVirtualComponent> changed) {
- Iterator<IVirtualComponent> i = changed.iterator();
- IVirtualComponent component;
- IVirtualReference ref;
- IPath p;
- while(i.hasNext()) {
- component = i.next();
- ref = rootComponent.getReference(component.getName());
- p = new Path(objectToRuntimePath.get(component));
- ref.setRuntimePath(p);
- }
- }
-
- protected void handleAdded(ArrayList<IVirtualComponent> added) {
- final ArrayList<IVirtualComponent> components = new ArrayList<IVirtualComponent>();
- Iterator<IVirtualComponent> i = added.iterator();
- IVirtualComponent o;
- while(i.hasNext()) {
- o = i.next();
- components.add((IVirtualComponent)o);
- }
-
- IWorkspaceRunnable runnable = new IWorkspaceRunnable(){
- public void run(IProgressMonitor monitor) throws CoreException{
- addComponents(components);
- }
- };
- try {
- ResourcesPlugin.getWorkspace().run(runnable, new NullProgressMonitor());
- } catch( CoreException e ) {
- WTPOveridePlugin.logError(e);
- }
- }
-
- protected void addComponents(ArrayList<IVirtualComponent> components) throws CoreException {
- Iterator<IVirtualComponent> i = components.iterator();
- while(i.hasNext()) {
- addOneComponent(i.next());
- }
- }
-
- protected IDataModelProvider getAddReferenceDataModelProvider(IVirtualComponent component) {
- return new CreateReferenceComponentsDataModelProvider();
- }
-
- protected void addOneComponent(IVirtualComponent component) throws CoreException {
- String path, archiveName;
- path = new Path(objectToRuntimePath.get(component)).removeLastSegments(1).toString();
- archiveName = new Path(objectToRuntimePath.get(component)).lastSegment();
-
- IDataModelProvider provider = getAddReferenceDataModelProvider(component);
- IDataModel dm = DataModelFactory.createDataModel(provider);
-
- dm.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, rootComponent);
- dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, Arrays.asList(component));
-
- //[Bug 238264] the uri map needs to be manually set correctly
- Map<IVirtualComponent, String> uriMap = new HashMap<IVirtualComponent, String>();
- uriMap.put(component, archiveName);
- dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, uriMap);
- dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH, path);
-
- IStatus stat = dm.validateProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST);
- if (stat != OK_STATUS)
- throw new CoreException(stat);
- try {
- dm.getDefaultOperation().execute(new NullProgressMonitor(), null);
- } catch (ExecutionException e) {
- WTPOveridePlugin.logError(e);
- }
- }
-
- /**
- * [Bug 238264]
- * determines a unique URI mapping name for a given component
- * this is in case two components have the same name.
- *
- * @return returns a valid (none duplicate) uri mapping name for the given component\
- */
- private String getURIMappingName(IVirtualComponent archive) {
-
- //get the default uri map name for the given archive
- IPath componentPath = Path.fromOSString(archive.getName());
- String uriMapName = componentPath.lastSegment().replace(' ', '_');
-
-
- //check to be sure this uri mapping is not already in use by another reference
- boolean dupeArchiveName;
- String refedCompName;
- int lastDotIndex;
- String increment;
- IVirtualReference [] existingRefs = rootComponent.getReferences();
- for(int i=0;i<existingRefs.length;i++){
- refedCompName = existingRefs[i].getReferencedComponent().getName();
-
- //if uri mapping names of the refed component and the given archive are the same
- // find a new uri map name for the given archive
- if(existingRefs[i].getArchiveName().equals(uriMapName)){
- dupeArchiveName = true;
- //find a new uriMapName for the given component
- for(int j=1; dupeArchiveName; j++){
- lastDotIndex = uriMapName.lastIndexOf('.');
- increment = "_"+j; //$NON-NLS-1$
-
- //create the new potential name
- if(lastDotIndex != -1){
- uriMapName = uriMapName.substring(0, lastDotIndex) + increment + uriMapName.substring(lastDotIndex);
- } else {
- uriMapName = uriMapName.substring(0)+increment;
- }
-
- //determine if the new potential name is valid
- for(int k=0; k<existingRefs.length; k++) {
- dupeArchiveName = existingRefs[k].getArchiveName().equals(uriMapName);
- if(dupeArchiveName) {
- break;
- }
- }
- }
- }
- }
-
- return uriMapName;
- }
-}
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ComponentDependencyContentProvider.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ComponentDependencyContentProvider.java 2009-07-27 19:32:57 UTC (rev 16827)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ComponentDependencyContentProvider.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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
- * Stefan Dimov, stefan.dimov(a)sap.com - bug 207826
- *******************************************************************************/
-package org.eclipse.wst.common.componentcore.ui.propertypage;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.common.componentcore.internal.ComponentResource;
-import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.ui.propertypage.AddModuleDependenciesPropertiesPage.ComponentResourceProxy;
-
-
-/*
- * The only valid elements this content provider (should) provide
- * are IProject or IVirtualComponent objects. The runtime paths portion is
- * shared with the preference page itself where they can both modify the data.
- *
- * This provider no longer "meddles" in to the content as it used to,
- * but rather serves as only a view of it.
- */
-public class ComponentDependencyContentProvider extends LabelProvider implements IStructuredContentProvider, ITableLabelProvider {
-
- final static String PATH_SEPARATOR = String.valueOf(IPath.SEPARATOR);
-
- private HashMap<IVirtualComponent, String> runtimePaths;
- private ArrayList<ComponentResourceProxy> resourceMappings;
- public ComponentDependencyContentProvider() {
- super();
- }
-
- public void setRuntimePaths(HashMap<IVirtualComponent, String> paths) {
- this.runtimePaths = paths;
- }
-
- public void setResourceMappings(ArrayList<ComponentResourceProxy> mappings) {
- this.resourceMappings = mappings;
- }
-
- public Object[] getElements(Object inputElement) {
- Object[] empty = new Object[0];
- if( !(inputElement instanceof IWorkspaceRoot))
- return empty;
- ArrayList<Object> list = new ArrayList<Object>();
- list.addAll(resourceMappings);
- list.addAll(runtimePaths.keySet());
- return list.toArray();
- }
-
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- public String getColumnText(Object element, int columnIndex) {
- if( element instanceof ComponentResourceProxy) {
- if( columnIndex == 0 )
- return ((ComponentResourceProxy)element).runtimePath.toString();
- else if( columnIndex == 1 )
- return ((ComponentResourceProxy)element).source.toString();
- }
- if (element instanceof IVirtualComponent) {
- IVirtualComponent comp = (IVirtualComponent)element;
- if (columnIndex == 0) {
- if( runtimePaths == null || runtimePaths.get(element) == null) {
- return new Path(PATH_SEPARATOR).toString();
- }
- return runtimePaths.get(element);
- } else if (columnIndex == 1) {
- if( comp.isBinary() && comp instanceof VirtualArchiveComponent) {
- IPath p = ((VirtualArchiveComponent)comp).getWorkspaceRelativePath();
- if( p == null )
- p = new Path(((VirtualArchiveComponent)comp).getUnderlyingDiskFile().getAbsolutePath());
- return p.toString();
- }
- return comp.getProject().getName();
- }
- } else if (element instanceof IProject){
- if (columnIndex == 0) {
- if( runtimePaths == null || runtimePaths.get(element) == null) {
- return new Path(PATH_SEPARATOR).toString();
- }
- return runtimePaths.get(element);
- } else {
- return ((IProject)element).getName();
- }
- }
- return null;
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-}
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/DependencyPageExtensionManager.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/DependencyPageExtensionManager.java 2009-07-27 19:32:57 UTC (rev 16827)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/DependencyPageExtensionManager.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -1,108 +0,0 @@
-package org.eclipse.wst.common.componentcore.ui.propertypage;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.wst.common.project.facet.core.IFacetedProject;
-import org.eclipse.wst.server.ui.wizard.WizardFragment;
-import org.eclipse.wst.common.componentcore.ui.WTPOveridePlugin;
-
-public class DependencyPageExtensionManager {
- private static DependencyPageExtensionManager manager = null;
- public static DependencyPageExtensionManager getManager() {
- if( manager == null )
- manager = new DependencyPageExtensionManager();
- return manager;
- }
-
- private HashMap<String, IDependencyPageProvider> providers = null;
-
- public IDependencyPageProvider getProvider(IFacetedProject project) {
- if( providers == null )
- loadProviders();
- Iterator<IDependencyPageProvider> i = providers.values().iterator();
- IDependencyPageProvider temp;
- while(i.hasNext()) {
- temp = i.next();
- if( temp.canHandle(project))
- return temp;
- }
- return null;
- }
-
- private void loadProviders() {
- HashMap<String, IDependencyPageProvider> temp = new HashMap<String, IDependencyPageProvider>();
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IConfigurationElement[] cf = registry.getConfigurationElementsFor(
- WTPOveridePlugin.PLUGIN_ID, "moduleDependencyPropertyPage"); //$NON-NLS-1$
- for( int i = 0; i < cf.length; i++ ) {
- try {
- temp.put(cf[i].getAttribute("id"), //$NON-NLS-1$
- (IDependencyPageProvider)cf[i].createExecutableExtension("class")); //$NON-NLS-1$
- } catch( CoreException ce ) {}
- }
- providers = temp;
- }
-
- public WizardFragment loadReferenceWizardFragment(String id) {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IConfigurationElement[] cf = registry.getConfigurationElementsFor(
- WTPOveridePlugin.PLUGIN_ID, "referenceWizardFragment"); //$NON-NLS-1$
- for( int i = 0; i < cf.length; i++ ) {
- if( cf[i].getAttribute("id").equals(id))
- try {
- return (WizardFragment)cf[i].createExecutableExtension("class");
- } catch( CoreException ce) {}
- }
- return null;
- }
-
- public ReferenceExtension[] getReferenceExtensions() {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IConfigurationElement[] cf = registry.getConfigurationElementsFor(
- WTPOveridePlugin.PLUGIN_ID, "referenceWizardFragment"); //$NON-NLS-1$
- ArrayList<ReferenceExtension> list = new ArrayList<ReferenceExtension>();
- for( int i = 0; i < cf.length; i++ ) {
- list.add(new ReferenceExtension(cf[i]));
- }
- return (ReferenceExtension[]) list
- .toArray(new ReferenceExtension[list.size()]);
- }
-
- public class ReferenceExtension {
- private IConfigurationElement element;
- private String id, name, imageLoc;
- private Image image;
- public ReferenceExtension(IConfigurationElement element) {
- this.element = element;
- this.id = element.getAttribute("id");
- this.name = element.getAttribute("name");
- this.imageLoc = element.getAttribute("icon");
- }
- public String getId() { return this.id;}
- public String getName() { return this.name; }
- public Image getImage() {
- if( image == null ) {
- if( imageLoc != null && element.getContributor().getName() != null) {
- ImageDescriptor desc = AbstractUIPlugin.imageDescriptorFromPlugin(element.getContributor().getName(), imageLoc);
- image = desc.createImage();
- }
- }
- return image;
- }
- public void disposeImage() {
- if( image != null ) {
- image.dispose();
- image = null;
- }
- }
- }
-}
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ExternalJarReferenceWizardFragment.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ExternalJarReferenceWizardFragment.java 2009-07-27 19:32:57 UTC (rev 16827)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ExternalJarReferenceWizardFragment.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -1,51 +0,0 @@
-package org.eclipse.wst.common.componentcore.ui.propertypage;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.server.ui.wizard.IWizardHandle;
-
-public class ExternalJarReferenceWizardFragment extends JarReferenceWizardFragment {
- public Composite createComposite(Composite parent, IWizardHandle handle) {
- Composite c = super.createComposite(parent, handle);
- handle.setTitle("Add an External Jar Reference");
- handle.setDescription("Here you can reference a filesystem Jar\n"
- + "This is not a suggested use-case, but is here for backwards compatability.");
- return c;
- }
-
- protected void buttonPressed() {
- selected = BuildPathDialogAccess
- .chooseExternalJAREntries(browse.getShell());
- viewer.refresh();
- }
-
- public void performFinish(IProgressMonitor monitor) throws CoreException {
- IVirtualComponent rootComponent = (IVirtualComponent)getTaskModel().getObject(NewReferenceWizard.ROOT_COMPONENT);
- if (selected != null && selected.length > 0) {
- ArrayList<IVirtualComponent> compList = new ArrayList<IVirtualComponent>();
- ArrayList<String> paths = new ArrayList<String>();
- for (int i = 0; i < selected.length; i++) {
- // IPath fullPath = project.getFile(selected[i]).getFullPath();
- String type = VirtualArchiveComponent.LIBARCHIVETYPE
- + IPath.SEPARATOR;
- IVirtualComponent archive = ComponentCore
- .createArchiveComponent(rootComponent.getProject(),
- type + selected[i].toString());
- compList.add(archive);
- paths.add(selected[i].lastSegment());
- }
- IVirtualComponent[] components = (IVirtualComponent[]) compList.toArray(new IVirtualComponent[compList.size()]);
- String[] paths2 = (String[]) paths.toArray(new String[paths.size()]);
- getTaskModel().putObject(NewReferenceWizard.COMPONENT, components);
- getTaskModel().putObject(NewReferenceWizard.COMPONENT_PATH, paths2);
- }
- }
-}
Modified: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/IDependencyPageProvider.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/IDependencyPageProvider.java 2009-07-27 19:32:57 UTC (rev 16827)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/IDependencyPageProvider.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -1,6 +1,7 @@
package org.eclipse.wst.common.componentcore.ui.propertypage;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.wst.common.componentcore.ui.propertypage.internal.ModuleAssemblyRootPage;
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
public interface IDependencyPageProvider {
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/JarReferenceWizardFragment.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/JarReferenceWizardFragment.java 2009-07-27 19:32:57 UTC (rev 16827)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/JarReferenceWizardFragment.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -1,149 +0,0 @@
-package org.eclipse.wst.common.componentcore.ui.propertypage;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.server.ui.wizard.IWizardHandle;
-import org.eclipse.wst.server.ui.wizard.WizardFragment;
-
-public class JarReferenceWizardFragment extends WizardFragment {
- protected LabelProvider labelProvider = null;
- protected ITreeContentProvider contentProvider = null;
- protected TreeViewer viewer;
- protected Button browse;
- protected IPath[] paths;
- protected IWizardHandle handle;
- protected IPath[] selected = new IPath[]{};
- public boolean hasComposite() {
- return true;
- }
-
- public Composite createComposite(Composite parent, IWizardHandle handle) {
- this.handle = handle;
- handle.setTitle("Add a Jar Reference");
- handle.setDescription("Here you can reference a workspace Jar\n"
- + "This is not a suggested use-case, but is here for backwards compatability.");
-
- Composite c = new Composite(parent, SWT.NONE);
- c.setLayout(new FormLayout());
- viewer = new TreeViewer(c, SWT.SINGLE | SWT.BORDER);
- viewer.setContentProvider(getContentProvider());
- viewer.setLabelProvider(getLabelProvider());
- viewer.setInput(ResourcesPlugin.getWorkspace());
-
- browse = new Button(c, SWT.NONE);
- browse.setText("Browse...");
- FormData fd = new FormData();
- fd.left = new FormAttachment(0, 5);
- fd.bottom = new FormAttachment(100, -5);
- browse.setLayoutData(fd);
-
- fd = new FormData();
- fd.left = new FormAttachment(0, 5);
- fd.top = new FormAttachment(0, 5);
- fd.right = new FormAttachment(100, -5);
- fd.bottom = new FormAttachment(browse, -5);
- viewer.getTree().setLayoutData(fd);
-
- browse.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- buttonPressed();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
- });
- return c;
- }
-
- protected void buttonPressed() {
- IProject project = (IProject)getTaskModel().getObject(NewReferenceWizard.PROJECT);
- selected = BuildPathDialogAccess.chooseJAREntries(
- browse.getShell(),
- project.getLocation(), new IPath[0]);
- viewer.refresh();
- }
-
- public void performFinish(IProgressMonitor monitor) throws CoreException {
- IVirtualComponent rootComponent = (IVirtualComponent)getTaskModel().getObject(NewReferenceWizard.ROOT_COMPONENT);
- if (selected != null && selected.length > 0) {
- ArrayList<IVirtualComponent> compList = new ArrayList<IVirtualComponent>();
- ArrayList<String> paths = new ArrayList<String>();
- for (int i = 0; i < selected.length; i++) {
- // IPath fullPath = project.getFile(selected[i]).getFullPath();
- String type = VirtualArchiveComponent.LIBARCHIVETYPE
- + IPath.SEPARATOR;
- IVirtualComponent archive = ComponentCore
- .createArchiveComponent(rootComponent.getProject(),
- type + selected[i].makeRelative().toString());
- compList.add(archive);
- paths.add(selected[i].lastSegment());
- }
- IVirtualComponent[] components = (IVirtualComponent[]) compList.toArray(new IVirtualComponent[compList.size()]);
- String[] paths2 = (String[]) paths.toArray(new String[paths.size()]);
- getTaskModel().putObject(NewReferenceWizard.COMPONENT, components);
- getTaskModel().putObject(NewReferenceWizard.COMPONENT_PATH, paths2);
- }
- }
-
- protected LabelProvider getLabelProvider() {
- if (labelProvider == null) {
- labelProvider = new LabelProvider() {
- public Image getImage(Object element) {
- return null;
- }
-
- public String getText(Object element) {
- return element == null ? "" : element.toString();//$NON-NLS-1$
- }
- };
- }
- return labelProvider;
- }
-
- protected ITreeContentProvider getContentProvider() {
- if (contentProvider == null) {
- contentProvider = new ITreeContentProvider() {
- public Object[] getElements(Object inputElement) {
- return selected == null ? new Object[]{} : selected;
- }
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- public void dispose() {
- }
- public boolean hasChildren(Object element) {
- return false;
- }
- public Object getParent(Object element) {
- return null;
- }
- public Object[] getChildren(Object parentElement) {
- return null;
- }
- };
- }
- return contentProvider;
- }
-}
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ModuleAssemblyRootPage.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ModuleAssemblyRootPage.java 2009-07-27 19:32:57 UTC (rev 16827)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ModuleAssemblyRootPage.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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 implementation as prop page heirarchy
- * rfrost(a)bea.com - conversion to single property page impl
- *******************************************************************************/
-
-package org.eclipse.wst.common.componentcore.ui.propertypage;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.dialogs.PropertyPage;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.project.facet.core.IFacetedProject;
-import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
-
-/**
- * Primary project property page for Module dependencies;
- */
-public class ModuleAssemblyRootPage extends PropertyPage {
-
- private IProject project;
- private IModuleDependenciesControl[] controls = new IModuleDependenciesControl[0];
-
- public ModuleAssemblyRootPage() {
- super();
- }
-
- private Composite getFacetErrorComposite(final Composite parent) {
- final String errorCheckingFacet = "Error Checking Project Facets";
- setErrorMessage(errorCheckingFacet);
- return getErrorComposite(parent, errorCheckingFacet);
- }
- private Composite getVirtCompErrorComposite(final Composite parent) {
- final String errorCheckingFacet = "The given project is not a virtual component project";
- setErrorMessage(errorCheckingFacet);
- return getErrorComposite(parent, errorCheckingFacet);
- }
-
-
- private Composite getErrorComposite(final Composite parent, final String error) {
- final Composite composite = new Composite(parent, SWT.NONE);
- final GridLayout layout = new GridLayout();
- layout.marginWidth = 0;
- layout.marginWidth = 0;
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- final Label label= new Label(composite, SWT.NONE);
- label.setText(error);
- return composite;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- public boolean performOk() {
- for (int i = 0; i < controls.length; i++) {
- if (controls[i] != null) {
- if (!controls[i].performOk()) {
- return false;
- }
- }
- }
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
- */
- public void performDefaults() {
- for (int i = 0; i < controls.length; i++) {
- if (controls[i] != null) {
- controls[i].performDefaults();
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.IPreferencePage#performCancel()
- */
- public boolean performCancel() {
- for (int i = 0; i < controls.length; i++) {
- if (controls[i] != null) {
- if (!controls[i].performCancel()) {
- return false;
- }
- }
- }
- return super.performCancel();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
- */
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- for (int i = 0; i < controls.length; i++) {
- if (controls[i] != null) {
- controls[i].setVisible(visible);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#dispose()
- */
- public void dispose() {
- super.dispose();
- for (int i = 0; i < controls.length; i++) {
- if(controls[i] != null){
- controls[i].dispose();
- }
- }
- }
-
- protected static void createDescriptionComposite(final Composite parent, final String description) {
- Composite descriptionComp = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- descriptionComp.setLayout(layout);
- descriptionComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fillDescription(descriptionComp, description);
- }
-
- private static void fillDescription(Composite c, String s) {
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = 250;
- Text text = new Text(c, SWT.READ_ONLY | SWT.WRAP);
- text.setLayoutData(data);
- text.setText(s);
- }
-
- protected Control createContents(Composite parent) {
-
- // Need to find out what type of project we are handling
- project = (IProject) getElement().getAdapter(IResource.class);
- if( project != null ) {
- try {
- IFacetedProject facetedProject = ProjectFacetsManager.create(project);
- IDependencyPageProvider provider = null;
- if( facetedProject == null )
- return getFacetErrorComposite(parent);
-
- provider = DependencyPageExtensionManager.getManager().getProvider(facetedProject);
- if( provider != null ) {
- controls = provider.createPages(facetedProject, this);
- return provider.createRootControl(controls, parent);
- }
-
- if( ComponentCore.createComponent(project) == null )
- return getVirtCompErrorComposite(parent);
-
- AddModuleDependenciesPropertiesPage page = new AddModuleDependenciesPropertiesPage(project, this);
- controls = new IModuleDependenciesControl[1];
- controls[0] = page;
- return page.createContents(parent);
- } catch( CoreException ce ) {
- }
- }
- return getFacetErrorComposite(parent);
- }
-}
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/NewReferenceRootWizardFragment.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/NewReferenceRootWizardFragment.java 2009-07-27 19:32:57 UTC (rev 16827)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/NewReferenceRootWizardFragment.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -1,148 +0,0 @@
-package org.eclipse.wst.common.componentcore.ui.propertypage;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.wst.server.ui.wizard.IWizardHandle;
-import org.eclipse.wst.server.ui.wizard.WizardFragment;
-import org.eclipse.wst.common.componentcore.ui.propertypage.DependencyPageExtensionManager.ReferenceExtension;
-
-public class NewReferenceRootWizardFragment extends WizardFragment {
- protected Map<String, WizardFragment> fragmentMap =
- new HashMap<String, WizardFragment>();
- private IWizardHandle wizard;
- private TreeViewer viewer;
- public boolean hasComposite() {
- return true;
- }
-
- public Composite createComposite(Composite parent, IWizardHandle wizard) {
- this.wizard = wizard;
- wizard.setTitle("Select a reference type");
- wizard.setDescription("Here you can select one of many types of references to add");
- Composite c = new Composite(parent, SWT.NONE);
- c.setLayout(new FillLayout());
- viewer = new TreeViewer(c, SWT.SINGLE | SWT.BORDER);
- viewer.setLabelProvider(getLabelProvider());
- viewer.setContentProvider(getContentProvider());
- viewer.setInput(ResourcesPlugin.getWorkspace());
- viewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- viewerSelectionChanged();
- }
- });
- return c;
- }
-
- protected void viewerSelectionChanged() {
- wizard.update();
- }
-
- protected WizardFragment getWizardFragment(String extensionPointID) {
- try {
- WizardFragment fragment = fragmentMap.get(extensionPointID);
- if (fragment != null)
- return fragment;
- } catch (Exception e) {
- // ignore
- }
-
- WizardFragment fragment = DependencyPageExtensionManager.getManager().loadReferenceWizardFragment(extensionPointID);
- if (fragment != null)
- fragmentMap.put(extensionPointID, fragment);
- return fragment;
- }
-
- public List getChildFragments() {
- List<WizardFragment> listImpl = new ArrayList<WizardFragment>();
- createChildFragments(listImpl);
- return listImpl;
- }
-
- protected void createChildFragments(List<WizardFragment> list) {
- // Instantiate and add the fragment for the current ID
- if( viewer != null ) {
- IStructuredSelection sel = (IStructuredSelection)viewer.getSelection();
- ReferenceExtension selected = (ReferenceExtension)sel.getFirstElement();
- if( selected != null ) {
- WizardFragment child = getWizardFragment(selected.getId());
- if( child != null )
- list.add(child);
- }
- }
- }
-
- public boolean isComplete() {
- return true;
- }
-
-
- private LabelProvider labelProvider = null;
- private ITreeContentProvider contentProvider = null;
- protected LabelProvider getLabelProvider() {
- if( labelProvider == null ) {
- labelProvider = new LabelProvider() {
- public Image getImage(Object element) {
- if( element instanceof ReferenceExtension)
- return ((ReferenceExtension)element).getImage();
- return null;
- }
- public String getText(Object element) {
- if( element instanceof ReferenceExtension)
- return ((ReferenceExtension)element).getName();
- return element == null ? "" : element.toString();//$NON-NLS-1$
- }
- public void dispose() {
- super.dispose();
- if( extensions != null ) {
- for( int i = 0; i < extensions.length; i++) {
- extensions[i].disposeImage();
- }
- }
- }
- };
- }
- return labelProvider;
- }
-
- private ReferenceExtension[] extensions = null;
- protected ITreeContentProvider getContentProvider() {
- if( contentProvider == null ) {
- contentProvider = new ITreeContentProvider() {
- public Object[] getElements(Object inputElement) {
- if( extensions == null )
- extensions = DependencyPageExtensionManager.getManager().getReferenceExtensions();
- return extensions;
- }
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- public void dispose() {
- }
- public boolean hasChildren(Object element) {
- return false;
- }
- public Object getParent(Object element) {
- return null;
- }
- public Object[] getChildren(Object parentElement) {
- return null;
- }
- };
- }
- return contentProvider;
- }
-}
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/NewReferenceWizard.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/NewReferenceWizard.java 2009-07-27 19:32:57 UTC (rev 16827)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/NewReferenceWizard.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -1,28 +0,0 @@
-package org.eclipse.wst.common.componentcore.ui.propertypage;
-
-import java.util.List;
-
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.wst.server.ui.internal.wizard.TaskWizard;
-import org.eclipse.wst.server.ui.wizard.WizardFragment;
-
-public class NewReferenceWizard extends TaskWizard {
-
- public static final String COMPONENT = "dependency.component";
- public static final String COMPONENT_PATH = "dependency.component.path";
- public static final String PROJECT = "root.project";
- public static final String ROOT_COMPONENT = "root.component";
-
- public NewReferenceWizard() {
- super("New Reference Wizard", new WizardFragment() {
- protected void createChildFragments(List<WizardFragment> list) {
- list.add(new NewReferenceRootWizardFragment());
- }
- });
- }
-
- public void init(IWorkbench newWorkbench, IStructuredSelection newSelection) {
- // do nothing
- }
-}
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ProjectReferenceWizardFragment.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ProjectReferenceWizardFragment.java 2009-07-27 19:32:57 UTC (rev 16827)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ProjectReferenceWizardFragment.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -1,146 +0,0 @@
-package org.eclipse.wst.common.componentcore.ui.propertypage;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jst.j2ee.project.facet.IJavaProjectMigrationDataModelProperties;
-import org.eclipse.jst.j2ee.project.facet.JavaProjectMigrationDataModelProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.ModuleCoreNature;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.server.ui.wizard.IWizardHandle;
-import org.eclipse.wst.server.ui.wizard.WizardFragment;
-
-public class ProjectReferenceWizardFragment extends WizardFragment {
- private LabelProvider labelProvider = null;
- private ITreeContentProvider contentProvider = null;
- private TreeViewer viewer;
- private IProject selected;
-
- public boolean hasComposite() {
- return true;
- }
-
- public Composite createComposite(Composite parent, IWizardHandle handle) {
- handle.setTitle("Add a Project Reference");
- handle.setDescription("Here you can make a project into a reference.\n" +
- "If the project is not already a flexible project, it will be converted into one.");
-
- Composite c = new Composite(parent, SWT.NONE);
- c.setLayout(new FillLayout());
- viewer = new TreeViewer(c, SWT.SINGLE | SWT.BORDER);
- viewer.setContentProvider(getContentProvider());
- viewer.setLabelProvider(getLabelProvider());
- viewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- selChanged();
- }
- });
- viewer.setInput(ResourcesPlugin.getWorkspace());
- return c;
- }
-
- private void selChanged() {
- if( viewer != null ) {
- IStructuredSelection sel = (IStructuredSelection)viewer.getSelection();
- if( sel != null )
- selected = (IProject)sel.getFirstElement();
- }
- }
-
- public void performFinish(IProgressMonitor monitor) throws CoreException {
- if( !ModuleCoreNature.isFlexibleProject(selected)) {
- try {
- IDataModel migrationdm = DataModelFactory.createDataModel(new JavaProjectMigrationDataModelProvider());
- migrationdm.setProperty(IJavaProjectMigrationDataModelProperties.PROJECT_NAME, selected.getName());
- migrationdm.getDefaultOperation().execute(new NullProgressMonitor(), null);
- } catch( ExecutionException ee) {
- // TODO something
- }
- }
- IVirtualComponent comp = ComponentCore.createComponent(selected);
- String path = selected.getName();
-
- // TODO extension point? API? Something?!
- //String extension = ComponentUtils.getDefaultProjectExtension(comp);
- path += ".jar"; //extension;
-
- getTaskModel().putObject(NewReferenceWizard.COMPONENT, comp);
- getTaskModel().putObject(NewReferenceWizard.COMPONENT_PATH, path);
- }
-
-
- protected LabelProvider getLabelProvider() {
- if( labelProvider == null ) {
- labelProvider = new LabelProvider() {
- public Image getImage(Object element) {
- return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_PROJECT);
- }
- public String getText(Object element) {
- if( element instanceof IProject )
- return ((IProject)element).getName();
- return element == null ? "" : element.toString();//$NON-NLS-1$
- }
- };
- }
- return labelProvider;
- }
-
- protected ITreeContentProvider getContentProvider() {
- if( contentProvider == null ) {
- contentProvider = new ITreeContentProvider() {
- public Object[] getElements(Object inputElement) {
- IProject root = (IProject)getTaskModel().getObject(NewReferenceWizard.PROJECT);
- IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- ArrayList<IProject> list = new ArrayList<IProject>(Arrays.asList(projects));
- Iterator<IProject> i = list.iterator();
- IProject p;
- while(i.hasNext()) {
- p = i.next();
- if( !p.isOpen())
- i.remove();
- else if( p.equals(root))
- i.remove();
- }
- return (IProject[]) list.toArray(new IProject[list.size()]);
- }
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- public void dispose() {
- }
- public boolean hasChildren(Object element) {
- return false;
- }
- public Object getParent(Object element) {
- return null;
- }
- public Object[] getChildren(Object parentElement) {
- return null;
- }
- };
- }
- return contentProvider;
- }
-}
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/VariableReferenceWizardFragment.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/VariableReferenceWizardFragment.java 2009-07-27 19:32:57 UTC (rev 16827)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/VariableReferenceWizardFragment.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -1,56 +0,0 @@
-package org.eclipse.wst.common.componentcore.ui.propertypage;
-
-import java.util.ArrayList;
-
-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.jdt.core.JavaCore;
-import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.server.ui.wizard.IWizardHandle;
-
-public class VariableReferenceWizardFragment extends JarReferenceWizardFragment {
- public Composite createComposite(Composite parent, IWizardHandle handle) {
- Composite c = super.createComposite(parent, handle);
- handle.setTitle("Add a Variable Reference");
- handle.setDescription("Here you can reference a variable which maps to a single jar.\n"
- + "This is not a suggested use-case, but is here for backwards compatability.");
- return c;
- }
-
- protected void buttonPressed() {
- selected = BuildPathDialogAccess.chooseVariableEntries(
- browse.getShell(), new Path[0]);
- viewer.refresh();
- }
-
- public void performFinish(IProgressMonitor monitor) throws CoreException {
- IVirtualComponent rootComponent = (IVirtualComponent)getTaskModel().getObject(NewReferenceWizard.ROOT_COMPONENT);
- if (selected != null && selected.length > 0) {
- ArrayList<IVirtualComponent> compList = new ArrayList<IVirtualComponent>();
- ArrayList<String> paths = new ArrayList<String>();
- for (int i = 0; i < selected.length; i++) {
- IPath resolvedPath = JavaCore.getResolvedVariablePath(selected[i]);
- java.io.File file = new java.io.File(resolvedPath.toOSString());
- if (file.isFile() && file.exists()) {
- String type = VirtualArchiveComponent.VARARCHIVETYPE
- + IPath.SEPARATOR;
- IVirtualComponent archive = ComponentCore
- .createArchiveComponent(rootComponent.getProject(),
- type + selected[i].toString());
- compList.add(archive);
- paths.add(resolvedPath.lastSegment());
- }
- }
- IVirtualComponent[] components = (IVirtualComponent[]) compList.toArray(new IVirtualComponent[compList.size()]);
- String[] paths2 = (String[]) paths.toArray(new String[paths.size()]);
- getTaskModel().putObject(NewReferenceWizard.COMPONENT, components);
- getTaskModel().putObject(NewReferenceWizard.COMPONENT_PATH, paths2);
- }
- }
-}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/AddFolderDialog.java (from rev 16826, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/AddFolderDialog.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/AddFolderDialog.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/AddFolderDialog.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -0,0 +1,133 @@
+package org.eclipse.wst.common.componentcore.ui.propertypage.internal;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+public class AddFolderDialog extends TitleAreaDialog {
+ private IProject project;
+ private TreeViewer viewer;
+ private IContainer selected = null;
+ public AddFolderDialog(Shell parentShell, IProject project) {
+ super(parentShell);
+ this.project = project;
+ }
+
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ shell.setText("Add Folder");
+ shell.setBounds(shell.getLocation().x, shell.getLocation().y, 400,300);
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite c = (Composite)super.createDialogArea(parent);
+ this.viewer = new TreeViewer(c, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ viewer.setContentProvider(getContentProvider());
+ viewer.setLabelProvider(getLabelProvider());
+ viewer.addFilter(getFilter());
+ viewer.setInput(project);
+ viewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
+ viewer.addSelectionChangedListener(getListener());
+ return c;
+ }
+
+ protected ISelectionChangedListener getListener() {
+ return new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection sel = (IStructuredSelection)viewer.getSelection();
+ Object first = sel.getFirstElement();
+ if( first instanceof IContainer)
+ selected = (IContainer)first;
+ }
+ };
+ }
+
+ public IContainer getSelected() {
+ return selected;
+ }
+
+ protected ViewerFilter getFilter() {
+ return new ViewerFilter() {
+ public boolean select(Viewer viewer, Object parentElement,
+ Object element) {
+ return element instanceof IContainer;
+ }
+ };
+ }
+
+ protected ITreeContentProvider getContentProvider() {
+ return new ITreeContentProvider() {
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ public void dispose() {
+ }
+
+ public Object[] getElements(Object inputElement) {
+ try {
+ return project.members();
+ } catch( CoreException ce ) {
+ return new Object[]{};
+ }
+ }
+
+ public boolean hasChildren(Object element) {
+ if( element instanceof IContainer) {
+ try {
+ return ((IContainer)element).members().length > 0;
+ } catch( CoreException ce ) {
+ }
+ }
+ return false;
+ }
+
+ public Object getParent(Object element) {
+ if( element instanceof IResource)
+ return ((IResource)element).getParent();
+ return null;
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ if( parentElement instanceof IContainer) {
+ try {
+ return ((IContainer)parentElement).members();
+ } catch( CoreException ce ) {
+ }
+ }
+ return new Object[]{};
+ }
+ };
+ }
+
+ protected LabelProvider getLabelProvider() {
+ return new LabelProvider() {
+ public Image getImage(Object element) {
+ return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
+ }
+ public String getText(Object element) {
+ if( element instanceof IResource)
+ return ((IResource)element).getName();
+ return element.toString();
+ }
+ };
+ }
+}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/AddModuleDependenciesPropertiesPage.java (from rev 16827, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/AddModuleDependenciesPropertiesPage.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/AddModuleDependenciesPropertiesPage.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/AddModuleDependenciesPropertiesPage.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -0,0 +1,894 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 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
+ * David Schneider, david.schneider(a)unisys.com - [142500] WTP properties pages fonts don't follow Eclipse preferences
+ * Stefan Dimov, stefan.dimov(a)sap.com - bugs 207826, 222651
+ *******************************************************************************/
+package org.eclipse.wst.common.componentcore.ui.propertypage.internal;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+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.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
+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.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties;
+import org.eclipse.wst.common.componentcore.internal.ComponentResource;
+import org.eclipse.wst.common.componentcore.internal.StructureEdit;
+import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent;
+import org.eclipse.wst.common.componentcore.internal.operation.CreateReferenceComponentsDataModelProvider;
+import org.eclipse.wst.common.componentcore.internal.operation.RemoveReferenceComponentsDataModelProvider;
+import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
+import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
+import org.eclipse.wst.common.componentcore.ui.Messages;
+import org.eclipse.wst.common.componentcore.ui.ComponentCoreUIPlugin;
+import org.eclipse.wst.common.componentcore.ui.propertypage.IModuleDependenciesControl;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
+
+public class AddModuleDependenciesPropertiesPage implements Listener,
+ IModuleDependenciesControl {
+
+ private static final String DEPLOY_PATH_PROPERTY = new Integer(0).toString();
+ private static final String SOURCE_PROPERTY = new Integer(1).toString();
+
+
+ protected final String PATH_SEPARATOR = ComponentDependencyContentProvider.PATH_SEPARATOR;
+ private boolean hasInitialized = false;
+ protected final IProject project;
+ protected final ModuleAssemblyRootPage propPage;
+ protected IVirtualComponent rootComponent = null;
+ protected Text componentNameText;
+ protected Label availableModules;
+ protected TableViewer availableComponentsViewer;
+ protected Button addMappingButton, addReferenceButton, removeButton;
+ protected Composite buttonColumn;
+ protected static final IStatus OK_STATUS = IDataModelProvider.OK_STATUS;
+ protected Listener tableListener;
+ protected Listener labelListener;
+
+ // Mappings that existed when the page was opened (or last saved)
+ protected HashMap<IVirtualComponent, String> oldComponentToRuntimePath = new HashMap<IVirtualComponent, String>();
+
+ // Mappings that are current
+ protected HashMap<IVirtualComponent, String> objectToRuntimePath = new HashMap<IVirtualComponent, String>();
+
+ // A single list of wb-resource mappings. If there's any change,
+ // all old will be removed and new ones added
+ protected ArrayList<ComponentResourceProxy> resourceMappings = new ArrayList<ComponentResourceProxy>();
+
+ // keeps track if a change has occurred in wb-resource mappings
+ protected boolean resourceMappingsChanged = false;
+
+ /**
+ * Constructor for AddModulestoEARPropertiesControl.
+ */
+ public AddModuleDependenciesPropertiesPage(final IProject project,
+ final ModuleAssemblyRootPage page) {
+ this.project = project;
+ this.propPage = page;
+ rootComponent = ComponentCore.createComponent(project);
+ }
+
+ /*
+ * UI Creation Methods
+ */
+
+ public Composite createContents(final Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ ModuleAssemblyRootPage.createDescriptionComposite(composite,
+ "TODO Change this: Create and change packaging structure for this project ");
+ createListGroup(composite);
+ refresh();
+ Dialog.applyDialogFont(parent);
+ return composite;
+ }
+
+ protected void createListGroup(Composite parent) {
+ Composite listGroup = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ listGroup.setLayout(layout);
+ GridData gData = new GridData(GridData.FILL_BOTH);
+ gData.horizontalIndent = 5;
+ listGroup.setLayoutData(gData);
+
+ availableModules = new Label(listGroup, SWT.NONE);
+ gData = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.VERTICAL_ALIGN_FILL);
+ availableModules.setText("Module Assembly"); //$NON-NLS-1$
+ availableModules.setLayoutData(gData);
+ createTableComposite(listGroup);
+ }
+
+ protected void createTableComposite(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridData gData = new GridData(GridData.FILL_BOTH);
+ composite.setLayoutData(gData);
+ fillComposite(composite);
+ }
+
+ public void fillComposite(Composite parent) {
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.marginHeight = 0;
+ parent.setLayout(layout);
+ parent.setLayoutData(new GridData(GridData.FILL_BOTH));
+ createTable(parent);
+ createButtonColumn(parent);
+ }
+
+ protected void createButtonColumn(Composite parent) {
+ buttonColumn = createButtonColumnComposite(parent);
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END);
+ buttonColumn.setLayoutData(data);
+ createPushButtons();
+ }
+
+ protected void createPushButtons() {
+ addMappingButton = createPushButton("Add Folder...");
+ addReferenceButton = createPushButton("Add Reference...");
+ removeButton = createPushButton("Remove selected");
+ }
+
+ protected Button createPushButton(String label) {
+ Button aButton = new Button(buttonColumn, SWT.PUSH);
+ aButton.setText(label);
+ aButton.addListener(SWT.Selection, this);
+ aButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ return aButton;
+ }
+
+ public Composite createButtonColumnComposite(Composite parent) {
+ Composite aButtonColumn = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ aButtonColumn.setLayout(layout);
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.VERTICAL_ALIGN_BEGINNING);
+ aButtonColumn.setLayoutData(data);
+ return aButtonColumn;
+ }
+
+ public Group createGroup(Composite parent) {
+ return new Group(parent, SWT.NULL);
+ }
+
+ protected void createTable(Composite parent) {
+ if (rootComponent != null) {
+ availableComponentsViewer = createAvailableComponentsViewer(parent);
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.FILL_VERTICAL);
+ availableComponentsViewer.getTable().setLayoutData(gd);
+
+ ComponentDependencyContentProvider provider = createProvider();
+ provider.setRuntimePaths(objectToRuntimePath);
+ provider.setResourceMappings(resourceMappings);
+ availableComponentsViewer.setContentProvider(provider);
+ availableComponentsViewer.setLabelProvider(provider);
+ addTableListeners();
+ }
+ }
+
+ /**
+ * Subclasses should over-ride this and extend the class
+ */
+ protected ComponentDependencyContentProvider createProvider() {
+ return new ComponentDependencyContentProvider();
+ }
+
+ /*
+ * Listeners of various events
+ */
+
+ protected void addTableListeners() {
+ addHoverHelpListeners();
+ addDoubleClickListener();
+ addSelectionListener();
+ }
+
+ protected void addHoverHelpListeners() {
+ final Table table = availableComponentsViewer.getTable();
+ createLabelListener(table);
+ createTableListener(table);
+ table.addListener(SWT.Dispose, tableListener);
+ table.addListener(SWT.KeyDown, tableListener);
+ table.addListener(SWT.MouseMove, tableListener);
+ table.addListener(SWT.MouseHover, tableListener);
+ }
+
+ protected void createLabelListener(final Table table) {
+ labelListener = new Listener() {
+ public void handleEvent(Event event) {
+ Label label = (Label) event.widget;
+ Shell shell = label.getShell();
+ switch (event.type) {
+ case SWT.MouseDown:
+ Event e = new Event();
+ e.item = (TableItem) label.getData("_TABLEITEM"); //$NON-NLS-1$
+ table.setSelection(new TableItem[] { (TableItem) e.item });
+ table.notifyListeners(SWT.Selection, e);
+ shell.dispose();
+ table.setFocus();
+ break;
+ case SWT.MouseExit:
+ shell.dispose();
+ break;
+ }
+ }
+ };
+ }
+
+ protected void createTableListener(final Table table) {
+ tableListener = new Listener() {
+ Shell tip = null;
+ Label label = null;
+
+ public void handleEvent(Event event) {
+ switch (event.type) {
+ case SWT.Dispose:
+ case SWT.KeyDown:
+ case SWT.MouseMove: {
+ if (tip == null)
+ break;
+ tip.dispose();
+ tip = null;
+ label = null;
+ break;
+ }
+ case SWT.MouseHover: {
+ TableItem item = table.getItem(new Point(event.x, event.y));
+ if (item != null && item.getData() != null && !canEdit(item.getData())) {
+ if (tip != null && !tip.isDisposed())
+ tip.dispose();
+ tip = new Shell(PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell(),
+ SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL);
+ tip.setBackground(Display.getDefault().getSystemColor(
+ SWT.COLOR_INFO_BACKGROUND));
+ FillLayout layout = new FillLayout();
+ layout.marginWidth = 2;
+ tip.setLayout(layout);
+ label = new Label(tip, SWT.WRAP);
+ label.setForeground(Display.getDefault()
+ .getSystemColor(SWT.COLOR_INFO_FOREGROUND));
+ label.setBackground(Display.getDefault()
+ .getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+ label.setData("_TABLEITEM", item); //$NON-NLS-1$
+ label.setText(J2EEUIMessages
+ .getResourceString(J2EEUIMessages.HOVER_HELP_FOR_DISABLED_LIBS));
+ label.addListener(SWT.MouseExit, labelListener);
+ label.addListener(SWT.MouseDown, labelListener);
+ Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ Rectangle rect = item.getBounds(0);
+ Point pt = table.toDisplay(rect.x, rect.y);
+ tip.setBounds(pt.x, pt.y - size.y, size.x, size.y);
+ tip.setVisible(true);
+ }
+ }
+ }
+ }
+ };
+ }
+
+ protected boolean canEdit(Object data) {
+ if( data == null ) return false;
+ if( !(data instanceof VirtualArchiveComponent)) return true;
+
+ VirtualArchiveComponent d2 = (VirtualArchiveComponent)data;
+ boolean sameProject = d2.getWorkspaceRelativePath() != null
+ && d2.getWorkspaceRelativePath().segment(0)
+ .equals(rootComponent.getProject().getName());
+ return !(sameProject && isPhysicallyAdded(d2));
+ }
+
+ protected void addDoubleClickListener() {
+ availableComponentsViewer.setColumnProperties(new String[] {
+ DEPLOY_PATH_PROPERTY, SOURCE_PROPERTY });
+
+ CellEditor[] editors = new CellEditor[] {
+ new TextCellEditor(availableComponentsViewer.getTable()),
+ new TextCellEditor()};
+ availableComponentsViewer.setCellEditors(editors);
+ availableComponentsViewer
+ .setCellModifier(new RuntimePathCellModifier());
+ }
+
+ protected void addSelectionListener() {
+ availableComponentsViewer.addSelectionChangedListener(
+ new ISelectionChangedListener(){
+ public void selectionChanged(SelectionChangedEvent event) {
+ viewerSelectionChanged();
+ }
+ });
+ }
+
+ protected void viewerSelectionChanged() {
+ removeButton.setEnabled(getSelectedObject() != null && canEdit(getSelectedObject()));
+ }
+
+ protected Object getSelectedObject() {
+ IStructuredSelection sel = (IStructuredSelection)availableComponentsViewer.getSelection();
+ return sel.getFirstElement();
+ }
+
+ private class RuntimePathCellModifier implements ICellModifier {
+
+ public boolean canModify(Object element, String property) {
+ if( property.equals(DEPLOY_PATH_PROPERTY)) {
+ if (element instanceof VirtualArchiveComponent) {
+ try {
+ return canEdit(element);
+ } catch (IllegalArgumentException iae) {
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public Object getValue(Object element, String property) {
+ Object data = element; //((TableItem)element).getData();
+ if( data instanceof IVirtualComponent ) {
+ return objectToRuntimePath.get(element) == null ? new Path("/") //$NON-NLS-1$
+ .toString() : objectToRuntimePath.get(element);
+ } else if( data instanceof ComponentResourceProxy) {
+ return ((ComponentResourceProxy)data).runtimePath.toString();
+ }
+ return new Path("/");
+ }
+
+ public void modify(Object element, String property, Object value) {
+ if (property.equals(DEPLOY_PATH_PROPERTY)) {
+ TableItem item = (TableItem) element;
+ if( item.getData() instanceof IVirtualComponent) {
+ objectToRuntimePath.put((IVirtualComponent)item.getData(), (String) value);
+ } else if( item.getData() instanceof ComponentResourceProxy) {
+ ComponentResourceProxy c = ((ComponentResourceProxy)item.getData());
+ c.runtimePath = new Path((String)value);
+ resourceMappingsChanged = true;
+ }
+ refresh();
+ }
+ }
+
+ }
+
+ public void handleEvent(Event event) {
+ if( event.widget == addMappingButton)
+ handleAddMappingButton();
+ else if( event.widget == addReferenceButton)
+ handleAddReferenceButton();
+ else if( event.widget == removeButton )
+ handleRemoveSelectedButton();
+ }
+
+ protected void handleAddMappingButton() {
+ AddFolderDialog afd = new AddFolderDialog(addMappingButton.getShell(), project);
+ if( afd.open() == Window.OK) {
+ IContainer c = afd.getSelected();
+ if( c != null ) {
+ IPath p = c.getProjectRelativePath();
+ ComponentResourceProxy proxy = new ComponentResourceProxy(p, new Path("/"));
+ resourceMappings.add(proxy);
+ refresh();
+ }
+ }
+ }
+
+ protected void handleAddReferenceButton() {
+ NewReferenceWizard wizard = new NewReferenceWizard();
+ // fill the task model
+ wizard.getTaskModel().putObject(NewReferenceWizard.PROJECT, project);
+ wizard.getTaskModel().putObject(NewReferenceWizard.ROOT_COMPONENT, rootComponent);
+
+ WizardDialog wd = new WizardDialog(addReferenceButton.getShell(), wizard);
+ if( wd.open() != Window.CANCEL) {
+ Object c1 = wizard.getTaskModel().getObject(NewReferenceWizard.COMPONENT);
+ Object p1 = wizard.getTaskModel().getObject(NewReferenceWizard.COMPONENT_PATH);
+ IVirtualComponent[] compArr = c1 instanceof IVirtualComponent ?
+ new IVirtualComponent[] { (IVirtualComponent)c1 } :
+ (IVirtualComponent[])c1;
+ String[] pathArr = p1 instanceof String ?
+ new String[] { (String)p1 } :
+ (String[])p1;
+ for( int i = 0; i < compArr.length; i++ ) {
+ objectToRuntimePath.put(compArr[i], pathArr[i]);
+ }
+ refresh();
+ }
+ }
+
+ protected void handleRemoveSelectedButton() {
+ ISelection sel = availableComponentsViewer.getSelection();
+ if( sel instanceof IStructuredSelection ) {
+ Object o = ((IStructuredSelection)sel).getFirstElement();
+ if( o instanceof IVirtualComponent)
+ objectToRuntimePath.remove(o);
+ else if( o instanceof ComponentResourceProxy)
+ resourceMappings.remove(o);
+ refresh();
+ }
+ }
+
+ public TableViewer createAvailableComponentsViewer(Composite parent) {
+ int flags = SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI;
+
+ Table table = new Table(parent, flags);
+ availableComponentsViewer = new TableViewer(table);
+
+ // set up table layout
+ TableLayout tableLayout = new org.eclipse.jface.viewers.TableLayout();
+ tableLayout.addColumnData(new ColumnWeightData(400, true));
+ tableLayout.addColumnData(new ColumnWeightData(500, true));
+ table.setLayout(tableLayout);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+ availableComponentsViewer.setSorter(null);
+
+ TableColumn bndColumn = new TableColumn(table, SWT.NONE, 0);
+ bndColumn.setText(Messages.AddModuleDependenciesPropertiesPage_DeployPathColumn);
+ bndColumn.setResizable(true);
+
+ TableColumn projectColumn = new TableColumn(table, SWT.NONE, 1);
+ projectColumn.setText(Messages.AddModuleDependenciesPropertiesPage_SourceColumn);
+ projectColumn.setResizable(true);
+
+ tableLayout.layout(table, true);
+ return availableComponentsViewer;
+
+ }
+
+ protected boolean isPhysicallyAdded(VirtualArchiveComponent component) {
+ try {
+ component.getProjectRelativePath();
+ return true;
+ } catch (IllegalArgumentException e) {
+ return false;
+ }
+ }
+
+ /**
+ * This should only be called on changes, such as adding a project
+ * reference, adding a lib reference etc.
+ *
+ * It will reset the input, manually re-add missing elements, and do other
+ * tasks
+ */
+ public void refresh() {
+ resetTableUI();
+ if (!hasInitialized) {
+ initialize();
+ resetTableUI();
+ }
+
+ }
+
+ protected void resetTableUI() {
+ IWorkspaceRoot input = ResourcesPlugin.getWorkspace().getRoot();
+ availableComponentsViewer.setInput(input);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ int numlines = Math.min(10, availableComponentsViewer.getTable()
+ .getItemCount());
+ data.heightHint = availableComponentsViewer.getTable().getItemHeight()
+ * numlines;
+ availableComponentsViewer.getTable().setLayoutData(data);
+ GridData btndata = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.VERTICAL_ALIGN_BEGINNING);
+ buttonColumn.setLayoutData(btndata);
+ }
+
+ protected void initialize() {
+ IVirtualReference[] refs = rootComponent.getReferences();
+ IVirtualComponent comp;
+ for( int i = 0; i < refs.length; i++ ) {
+ comp = refs[i].getReferencedComponent();
+ String val = refs[i].getRuntimePath().append(refs[i].getArchiveName()).toString();
+ objectToRuntimePath.put(comp, val);
+ oldComponentToRuntimePath.put((IVirtualComponent) comp, val);
+ }
+
+ ComponentResource[] allMappings = findAllMappings();
+ for( int i = 0; i < allMappings.length; i++ ) {
+ resourceMappings.add(new ComponentResourceProxy(
+ allMappings[i].getSourcePath(), allMappings[i].getRuntimePath()
+ ));
+ }
+ hasInitialized = true;
+ }
+
+ protected ComponentResource[] findAllMappings() {
+ StructureEdit structureEdit = null;
+ try {
+ structureEdit = StructureEdit.getStructureEditForRead(project);
+ WorkbenchComponent component = structureEdit.getComponent();
+ Object[] arr = component.getResources().toArray();
+ ComponentResource[] result = new ComponentResource[arr.length];
+ for( int i = 0; i < arr.length; i++ )
+ result[i] = (ComponentResource)arr[i];
+ return result;
+ } catch(Exception e) {
+ } finally {
+ structureEdit.dispose();
+ }
+ return new ComponentResource[]{};
+ }
+
+ public class ComponentResourceProxy {
+ public IPath source, runtimePath;
+ public ComponentResourceProxy(IPath source, IPath runtimePath) {
+ this.source = source;
+ this.runtimePath = runtimePath;
+ }
+ }
+
+ /*
+ * Clean-up methods are below. These include performCancel, performDefaults,
+ * performOK, and any other methods that are called *only* by this one.
+ */
+ public void setVisible(boolean visible) {
+ }
+
+ public void performDefaults() {
+ }
+
+ public boolean performCancel() {
+ return true;
+ }
+
+ public void dispose() {
+ Table table = null;
+ if (availableComponentsViewer != null) {
+ table = availableComponentsViewer.getTable();
+ }
+ if (table == null || tableListener == null)
+ return;
+ table.removeListener(SWT.Dispose, tableListener);
+ table.removeListener(SWT.KeyDown, tableListener);
+ table.removeListener(SWT.MouseMove, tableListener);
+ table.removeListener(SWT.MouseHover, tableListener);
+ }
+
+
+
+ /*
+ * This is where the OK work goes. Lots of it. Watch your head.
+ * xiao xin
+ */
+ protected boolean preHandleChanges(IProgressMonitor monitor) {
+ return true;
+ }
+
+ protected boolean postHandleChanges(IProgressMonitor monitor) {
+ return true;
+ }
+
+ public boolean performOk() {
+ boolean result = true;
+ result &= saveResourceChanges();
+ result &= saveReferenceChanges();
+ return result;
+ }
+
+ protected boolean saveResourceChanges() {
+ removeAllResourceMappings();
+ addNewResourceMappings();
+ return true;
+ }
+ protected boolean addNewResourceMappings() {
+ ComponentResourceProxy[] proxies = (ComponentResourceProxy[]) resourceMappings.toArray(new ComponentResourceProxy[resourceMappings.size()]);
+ IVirtualFolder rootFolder = rootComponent.getRootFolder();
+ for( int i = 0; i < proxies.length; i++ ) {
+ try {
+ rootFolder.getFolder(proxies[i].runtimePath).createLink(proxies[i].source, 0, null);
+ } catch( CoreException ce ) {
+ }
+ }
+ resourceMappingsChanged = false;
+ return true;
+ }
+
+ protected boolean removeAllResourceMappings() {
+ StructureEdit moduleCore = null;
+ try {
+ moduleCore = StructureEdit.getStructureEditForWrite(project);
+ moduleCore.getComponent().getResources().clear();
+ }
+ finally {
+ if (moduleCore != null) {
+ moduleCore.saveIfNecessary(new NullProgressMonitor());
+ moduleCore.dispose();
+ }
+ }
+ return true;
+ }
+
+ protected boolean saveReferenceChanges() {
+ // Fill our delta lists
+ ArrayList<IVirtualComponent> added = new ArrayList<IVirtualComponent>();
+ ArrayList<IVirtualComponent> removed = new ArrayList<IVirtualComponent>();
+ ArrayList<IVirtualComponent> changed = new ArrayList<IVirtualComponent>();
+
+ Iterator<IVirtualComponent> j = oldComponentToRuntimePath.keySet().iterator();
+ Object key, val;
+ while (j.hasNext()) {
+ key = j.next();
+ val = oldComponentToRuntimePath.get(key);
+ if( !objectToRuntimePath.containsKey(key))
+ removed.add((IVirtualComponent)key);
+ else if (!val.equals(objectToRuntimePath.get(key)))
+ changed.add((IVirtualComponent)key);
+ }
+
+ j = objectToRuntimePath.keySet().iterator();
+ while (j.hasNext()) {
+ key = j.next();
+ if (!oldComponentToRuntimePath.containsKey(key))
+ added.add((IVirtualComponent)key);
+ }
+
+ NullProgressMonitor monitor = new NullProgressMonitor();
+ boolean subResult = preHandleChanges(monitor);
+ if( !subResult )
+ return false;
+
+ handleDeltas(removed, changed, added);
+ subResult &= postHandleChanges(monitor);
+
+ // Now update the variables
+ oldComponentToRuntimePath.clear();
+ ArrayList<IVirtualComponent> keys = new ArrayList<IVirtualComponent>();
+ keys.addAll(objectToRuntimePath.keySet());
+ Iterator<IVirtualComponent> i = keys.iterator();
+ while(i.hasNext()) {
+ IVirtualComponent vc = i.next();
+ String path = objectToRuntimePath.get(vc);
+ oldComponentToRuntimePath.put(vc, path);
+ }
+ return subResult;
+ }
+
+ // Subclass can override if it has a good way to handle changed elements
+ protected void handleDeltas(ArrayList<IVirtualComponent> removed,
+ ArrayList<IVirtualComponent> changed, ArrayList<IVirtualComponent> added) {
+ ArrayList<IVirtualComponent> removed2 = new ArrayList<IVirtualComponent>();
+ ArrayList<IVirtualComponent> added2 = new ArrayList<IVirtualComponent>();
+ removed2.addAll(removed);
+ removed2.addAll(changed);
+ added2.addAll(added);
+ added2.addAll(changed);
+
+ // meld the changed into the added / removed for less efficiency ;)
+ // basically we lack "change" operations and only have add / remove
+ handleRemoved(removed2);
+ handleAdded(added2);
+ }
+ protected void handleRemoved(ArrayList<IVirtualComponent> removed) {
+ // If it's removed it should *only* be a virtual component already
+ Iterator<IVirtualComponent> i = removed.iterator();
+ IVirtualComponent component;
+ while(i.hasNext()) {
+ try {
+ component = i.next();
+ IDataModelOperation operation = getRemoveComponentOperation(component);
+ operation.execute(null, null);
+ } catch( ExecutionException e) {
+ ComponentCoreUIPlugin.logError(e);
+ }
+ }
+ }
+
+ protected IDataModelOperation getRemoveComponentOperation(IVirtualComponent component) {
+ String path, archiveName;
+ path = new Path(oldComponentToRuntimePath.get(component)).removeLastSegments(1).toString();
+ archiveName = new Path(oldComponentToRuntimePath.get(component)).lastSegment();
+
+ IDataModelProvider provider = getRemoveReferenceDataModelProvider(component);
+ IDataModel model = DataModelFactory.createDataModel(provider);
+ model.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, rootComponent);
+ List<IVirtualComponent> modHandlesList = (List<IVirtualComponent>) model.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST);
+ modHandlesList.add(component);
+ model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, modHandlesList);
+ model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH, path);
+ Map<IVirtualComponent, String> uriMap = new HashMap<IVirtualComponent, String>();
+ uriMap.put(component, archiveName);
+ model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, uriMap);
+ return model.getDefaultOperation();
+ }
+
+ protected IDataModelProvider getRemoveReferenceDataModelProvider(IVirtualComponent component) {
+ return new RemoveReferenceComponentsDataModelProvider();
+ }
+
+
+ protected void handleChanged(ArrayList<IVirtualComponent> changed) {
+ Iterator<IVirtualComponent> i = changed.iterator();
+ IVirtualComponent component;
+ IVirtualReference ref;
+ IPath p;
+ while(i.hasNext()) {
+ component = i.next();
+ ref = rootComponent.getReference(component.getName());
+ p = new Path(objectToRuntimePath.get(component));
+ ref.setRuntimePath(p);
+ }
+ }
+
+ protected void handleAdded(ArrayList<IVirtualComponent> added) {
+ final ArrayList<IVirtualComponent> components = new ArrayList<IVirtualComponent>();
+ Iterator<IVirtualComponent> i = added.iterator();
+ IVirtualComponent o;
+ while(i.hasNext()) {
+ o = i.next();
+ components.add((IVirtualComponent)o);
+ }
+
+ IWorkspaceRunnable runnable = new IWorkspaceRunnable(){
+ public void run(IProgressMonitor monitor) throws CoreException{
+ addComponents(components);
+ }
+ };
+ try {
+ ResourcesPlugin.getWorkspace().run(runnable, new NullProgressMonitor());
+ } catch( CoreException e ) {
+ ComponentCoreUIPlugin.logError(e);
+ }
+ }
+
+ protected void addComponents(ArrayList<IVirtualComponent> components) throws CoreException {
+ Iterator<IVirtualComponent> i = components.iterator();
+ while(i.hasNext()) {
+ addOneComponent(i.next());
+ }
+ }
+
+ protected IDataModelProvider getAddReferenceDataModelProvider(IVirtualComponent component) {
+ return new CreateReferenceComponentsDataModelProvider();
+ }
+
+ protected void addOneComponent(IVirtualComponent component) throws CoreException {
+ String path, archiveName;
+ path = new Path(objectToRuntimePath.get(component)).removeLastSegments(1).toString();
+ archiveName = new Path(objectToRuntimePath.get(component)).lastSegment();
+
+ IDataModelProvider provider = getAddReferenceDataModelProvider(component);
+ IDataModel dm = DataModelFactory.createDataModel(provider);
+
+ dm.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, rootComponent);
+ dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, Arrays.asList(component));
+
+ //[Bug 238264] the uri map needs to be manually set correctly
+ Map<IVirtualComponent, String> uriMap = new HashMap<IVirtualComponent, String>();
+ uriMap.put(component, archiveName);
+ dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, uriMap);
+ dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH, path);
+
+ IStatus stat = dm.validateProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST);
+ if (stat != OK_STATUS)
+ throw new CoreException(stat);
+ try {
+ dm.getDefaultOperation().execute(new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ ComponentCoreUIPlugin.logError(e);
+ }
+ }
+
+ /**
+ * [Bug 238264]
+ * determines a unique URI mapping name for a given component
+ * this is in case two components have the same name.
+ *
+ * @return returns a valid (none duplicate) uri mapping name for the given component\
+ */
+ private String getURIMappingName(IVirtualComponent archive) {
+
+ //get the default uri map name for the given archive
+ IPath componentPath = Path.fromOSString(archive.getName());
+ String uriMapName = componentPath.lastSegment().replace(' ', '_');
+
+
+ //check to be sure this uri mapping is not already in use by another reference
+ boolean dupeArchiveName;
+ String refedCompName;
+ int lastDotIndex;
+ String increment;
+ IVirtualReference [] existingRefs = rootComponent.getReferences();
+ for(int i=0;i<existingRefs.length;i++){
+ refedCompName = existingRefs[i].getReferencedComponent().getName();
+
+ //if uri mapping names of the refed component and the given archive are the same
+ // find a new uri map name for the given archive
+ if(existingRefs[i].getArchiveName().equals(uriMapName)){
+ dupeArchiveName = true;
+ //find a new uriMapName for the given component
+ for(int j=1; dupeArchiveName; j++){
+ lastDotIndex = uriMapName.lastIndexOf('.');
+ increment = "_"+j; //$NON-NLS-1$
+
+ //create the new potential name
+ if(lastDotIndex != -1){
+ uriMapName = uriMapName.substring(0, lastDotIndex) + increment + uriMapName.substring(lastDotIndex);
+ } else {
+ uriMapName = uriMapName.substring(0)+increment;
+ }
+
+ //determine if the new potential name is valid
+ for(int k=0; k<existingRefs.length; k++) {
+ dupeArchiveName = existingRefs[k].getArchiveName().equals(uriMapName);
+ if(dupeArchiveName) {
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return uriMapName;
+ }
+}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/ComponentDependencyContentProvider.java (from rev 16826, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ComponentDependencyContentProvider.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/ComponentDependencyContentProvider.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/ComponentDependencyContentProvider.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 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
+ * Stefan Dimov, stefan.dimov(a)sap.com - bug 207826
+ *******************************************************************************/
+package org.eclipse.wst.common.componentcore.ui.propertypage.internal;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.common.componentcore.internal.ComponentResource;
+import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.ui.propertypage.internal.AddModuleDependenciesPropertiesPage.ComponentResourceProxy;
+
+
+/*
+ * The only valid elements this content provider (should) provide
+ * are IProject or IVirtualComponent objects. The runtime paths portion is
+ * shared with the preference page itself where they can both modify the data.
+ *
+ * This provider no longer "meddles" in to the content as it used to,
+ * but rather serves as only a view of it.
+ */
+public class ComponentDependencyContentProvider extends LabelProvider implements IStructuredContentProvider, ITableLabelProvider {
+
+ final static String PATH_SEPARATOR = String.valueOf(IPath.SEPARATOR);
+
+ private HashMap<IVirtualComponent, String> runtimePaths;
+ private ArrayList<ComponentResourceProxy> resourceMappings;
+ public ComponentDependencyContentProvider() {
+ super();
+ }
+
+ public void setRuntimePaths(HashMap<IVirtualComponent, String> paths) {
+ this.runtimePaths = paths;
+ }
+
+ public void setResourceMappings(ArrayList<ComponentResourceProxy> mappings) {
+ this.resourceMappings = mappings;
+ }
+
+ public Object[] getElements(Object inputElement) {
+ Object[] empty = new Object[0];
+ if( !(inputElement instanceof IWorkspaceRoot))
+ return empty;
+ ArrayList<Object> list = new ArrayList<Object>();
+ list.addAll(resourceMappings);
+ list.addAll(runtimePaths.keySet());
+ return list.toArray();
+ }
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ if( element instanceof ComponentResourceProxy) {
+ if( columnIndex == 0 )
+ return ((ComponentResourceProxy)element).runtimePath.toString();
+ else if( columnIndex == 1 )
+ return ((ComponentResourceProxy)element).source.toString();
+ }
+ if (element instanceof IVirtualComponent) {
+ IVirtualComponent comp = (IVirtualComponent)element;
+ if (columnIndex == 0) {
+ if( runtimePaths == null || runtimePaths.get(element) == null) {
+ return new Path(PATH_SEPARATOR).toString();
+ }
+ return runtimePaths.get(element);
+ } else if (columnIndex == 1) {
+ if( comp.isBinary() && comp instanceof VirtualArchiveComponent) {
+ IPath p = ((VirtualArchiveComponent)comp).getWorkspaceRelativePath();
+ if( p == null )
+ p = new Path(((VirtualArchiveComponent)comp).getUnderlyingDiskFile().getAbsolutePath());
+ return p.toString();
+ }
+ return comp.getProject().getName();
+ }
+ } else if (element instanceof IProject){
+ if (columnIndex == 0) {
+ if( runtimePaths == null || runtimePaths.get(element) == null) {
+ return new Path(PATH_SEPARATOR).toString();
+ }
+ return runtimePaths.get(element);
+ } else {
+ return ((IProject)element).getName();
+ }
+ }
+ return null;
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/DependencyPageExtensionManager.java (from rev 16826, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/DependencyPageExtensionManager.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/DependencyPageExtensionManager.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/DependencyPageExtensionManager.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -0,0 +1,109 @@
+package org.eclipse.wst.common.componentcore.ui.propertypage.internal;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.server.ui.wizard.WizardFragment;
+import org.eclipse.wst.common.componentcore.ui.ComponentCoreUIPlugin;
+import org.eclipse.wst.common.componentcore.ui.propertypage.IDependencyPageProvider;
+
+public class DependencyPageExtensionManager {
+ private static DependencyPageExtensionManager manager = null;
+ public static DependencyPageExtensionManager getManager() {
+ if( manager == null )
+ manager = new DependencyPageExtensionManager();
+ return manager;
+ }
+
+ private HashMap<String, IDependencyPageProvider> providers = null;
+
+ public IDependencyPageProvider getProvider(IFacetedProject project) {
+ if( providers == null )
+ loadProviders();
+ Iterator<IDependencyPageProvider> i = providers.values().iterator();
+ IDependencyPageProvider temp;
+ while(i.hasNext()) {
+ temp = i.next();
+ if( temp.canHandle(project))
+ return temp;
+ }
+ return null;
+ }
+
+ private void loadProviders() {
+ HashMap<String, IDependencyPageProvider> temp = new HashMap<String, IDependencyPageProvider>();
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IConfigurationElement[] cf = registry.getConfigurationElementsFor(
+ ComponentCoreUIPlugin.PLUGIN_ID, "moduleDependencyPropertyPage"); //$NON-NLS-1$
+ for( int i = 0; i < cf.length; i++ ) {
+ try {
+ temp.put(cf[i].getAttribute("id"), //$NON-NLS-1$
+ (IDependencyPageProvider)cf[i].createExecutableExtension("class")); //$NON-NLS-1$
+ } catch( CoreException ce ) {}
+ }
+ providers = temp;
+ }
+
+ public WizardFragment loadReferenceWizardFragment(String id) {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IConfigurationElement[] cf = registry.getConfigurationElementsFor(
+ ComponentCoreUIPlugin.PLUGIN_ID, "referenceWizardFragment"); //$NON-NLS-1$
+ for( int i = 0; i < cf.length; i++ ) {
+ if( cf[i].getAttribute("id").equals(id))
+ try {
+ return (WizardFragment)cf[i].createExecutableExtension("class");
+ } catch( CoreException ce) {}
+ }
+ return null;
+ }
+
+ public ReferenceExtension[] getReferenceExtensions() {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IConfigurationElement[] cf = registry.getConfigurationElementsFor(
+ ComponentCoreUIPlugin.PLUGIN_ID, "referenceWizardFragment"); //$NON-NLS-1$
+ ArrayList<ReferenceExtension> list = new ArrayList<ReferenceExtension>();
+ for( int i = 0; i < cf.length; i++ ) {
+ list.add(new ReferenceExtension(cf[i]));
+ }
+ return (ReferenceExtension[]) list
+ .toArray(new ReferenceExtension[list.size()]);
+ }
+
+ public class ReferenceExtension {
+ private IConfigurationElement element;
+ private String id, name, imageLoc;
+ private Image image;
+ public ReferenceExtension(IConfigurationElement element) {
+ this.element = element;
+ this.id = element.getAttribute("id");
+ this.name = element.getAttribute("name");
+ this.imageLoc = element.getAttribute("icon");
+ }
+ public String getId() { return this.id;}
+ public String getName() { return this.name; }
+ public Image getImage() {
+ if( image == null ) {
+ if( imageLoc != null && element.getContributor().getName() != null) {
+ ImageDescriptor desc = AbstractUIPlugin.imageDescriptorFromPlugin(element.getContributor().getName(), imageLoc);
+ image = desc.createImage();
+ }
+ }
+ return image;
+ }
+ public void disposeImage() {
+ if( image != null ) {
+ image.dispose();
+ image = null;
+ }
+ }
+ }
+}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/EarModuleDependenciesPropertyPage.java (from rev 16826, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/impl/EarModuleDependenciesPropertyPage.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/EarModuleDependenciesPropertyPage.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/EarModuleDependenciesPropertyPage.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -0,0 +1,52 @@
+package org.eclipse.wst.common.componentcore.ui.propertypage.internal;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jst.j2ee.application.internal.operations.AddComponentToEnterpriseApplicationDataModelProvider;
+import org.eclipse.jst.j2ee.application.internal.operations.RemoveComponentFromEnterpriseApplicationDataModelProvider;
+import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathUpdater;
+import org.eclipse.jst.jee.project.facet.EarCreateDeploymentFilesDataModelProvider;
+import org.eclipse.jst.jee.project.facet.ICreateDeploymentFilesDataModelProperties;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
+
+public class EarModuleDependenciesPropertyPage extends
+ AddModuleDependenciesPropertiesPage {
+ public EarModuleDependenciesPropertyPage(IProject project,
+ ModuleAssemblyRootPage page) {
+ super(project, page);
+ }
+
+ protected IDataModelOperation generateEARDDOperation() {
+ IDataModel model = DataModelFactory.createDataModel(new EarCreateDeploymentFilesDataModelProvider());
+ model.setProperty(ICreateDeploymentFilesDataModelProperties.GENERATE_DD, rootComponent);
+ model.setProperty(ICreateDeploymentFilesDataModelProperties.TARGET_PROJECT, project);
+ return model.getDefaultOperation();
+ }
+
+ public boolean postHandleChanges(IProgressMonitor monitor) {
+ return true;
+ }
+
+ protected void handleRemoved(ArrayList<IVirtualComponent> removed) {
+ super.handleRemoved(removed);
+ J2EEComponentClasspathUpdater.getInstance().queueUpdateEAR(rootComponent.getProject());
+ }
+
+ protected IDataModelProvider getRemoveReferenceDataModelProvider(Object component) {
+ return new RemoveComponentFromEnterpriseApplicationDataModelProvider();
+ }
+
+// protected void postAddProjects(Set moduleProjects) throws CoreException {
+// EarFacetRuntimeHandler.updateModuleProjectRuntime(rootComponent.getProject(), moduleProjects, new NullProgressMonitor());
+// }
+
+ protected IDataModelProvider getAddReferenceDataModelProvider(IVirtualComponent component) {
+ return new AddComponentToEnterpriseApplicationDataModelProvider();
+ }
+}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/EarModuleDependencyPageProvider.java (from rev 16826, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/impl/EarModuleDependencyPageProvider.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/EarModuleDependencyPageProvider.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/EarModuleDependencyPageProvider.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -0,0 +1,29 @@
+package org.eclipse.wst.common.componentcore.ui.propertypage.internal;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.eclipse.wst.common.componentcore.ui.propertypage.IDependencyPageProvider;
+import org.eclipse.wst.common.componentcore.ui.propertypage.IModuleDependenciesControl;
+
+public class EarModuleDependencyPageProvider implements IDependencyPageProvider {
+
+ public boolean canHandle(IFacetedProject project) {
+ boolean isEAR = project.hasProjectFacet(ProjectFacetsManager.getProjectFacet("jst.ear")); //$NON-NLS-1$
+ return isEAR;
+ }
+
+ public IModuleDependenciesControl[] createPages(IFacetedProject project,
+ ModuleAssemblyRootPage parent) {
+ return new IModuleDependenciesControl[] {
+ new EarModuleDependenciesPropertyPage(project.getProject(), parent)
+ };
+ }
+
+ public Composite createRootControl(IModuleDependenciesControl[] pages,
+ Composite parent) {
+ if( pages.length == 1 && pages[0] != null)
+ return pages[0].createContents(parent);
+ return null;
+ }
+}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/ExternalJarReferenceWizardFragment.java (from rev 16827, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ExternalJarReferenceWizardFragment.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/ExternalJarReferenceWizardFragment.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/ExternalJarReferenceWizardFragment.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -0,0 +1,51 @@
+package org.eclipse.wst.common.componentcore.ui.propertypage.internal;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.server.ui.wizard.IWizardHandle;
+
+public class ExternalJarReferenceWizardFragment extends JarReferenceWizardFragment {
+ public Composite createComposite(Composite parent, IWizardHandle handle) {
+ Composite c = super.createComposite(parent, handle);
+ handle.setTitle("Add an External Jar Reference");
+ handle.setDescription("Here you can reference a filesystem Jar\n"
+ + "This is not a suggested use-case, but is here for backwards compatability.");
+ return c;
+ }
+
+ protected void buttonPressed() {
+ selected = BuildPathDialogAccess
+ .chooseExternalJAREntries(browse.getShell());
+ viewer.refresh();
+ }
+
+ public void performFinish(IProgressMonitor monitor) throws CoreException {
+ IVirtualComponent rootComponent = (IVirtualComponent)getTaskModel().getObject(NewReferenceWizard.ROOT_COMPONENT);
+ if (selected != null && selected.length > 0) {
+ ArrayList<IVirtualComponent> compList = new ArrayList<IVirtualComponent>();
+ ArrayList<String> paths = new ArrayList<String>();
+ for (int i = 0; i < selected.length; i++) {
+ // IPath fullPath = project.getFile(selected[i]).getFullPath();
+ String type = VirtualArchiveComponent.LIBARCHIVETYPE
+ + IPath.SEPARATOR;
+ IVirtualComponent archive = ComponentCore
+ .createArchiveComponent(rootComponent.getProject(),
+ type + selected[i].toString());
+ compList.add(archive);
+ paths.add(selected[i].lastSegment());
+ }
+ IVirtualComponent[] components = (IVirtualComponent[]) compList.toArray(new IVirtualComponent[compList.size()]);
+ String[] paths2 = (String[]) paths.toArray(new String[paths.size()]);
+ getTaskModel().putObject(NewReferenceWizard.COMPONENT, components);
+ getTaskModel().putObject(NewReferenceWizard.COMPONENT_PATH, paths2);
+ }
+ }
+}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/JarReferenceWizardFragment.java (from rev 16827, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/JarReferenceWizardFragment.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/JarReferenceWizardFragment.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/JarReferenceWizardFragment.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -0,0 +1,149 @@
+package org.eclipse.wst.common.componentcore.ui.propertypage.internal;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.server.ui.wizard.IWizardHandle;
+import org.eclipse.wst.server.ui.wizard.WizardFragment;
+
+public class JarReferenceWizardFragment extends WizardFragment {
+ protected LabelProvider labelProvider = null;
+ protected ITreeContentProvider contentProvider = null;
+ protected TreeViewer viewer;
+ protected Button browse;
+ protected IPath[] paths;
+ protected IWizardHandle handle;
+ protected IPath[] selected = new IPath[]{};
+ public boolean hasComposite() {
+ return true;
+ }
+
+ public Composite createComposite(Composite parent, IWizardHandle handle) {
+ this.handle = handle;
+ handle.setTitle("Add a Jar Reference");
+ handle.setDescription("Here you can reference a workspace Jar\n"
+ + "This is not a suggested use-case, but is here for backwards compatability.");
+
+ Composite c = new Composite(parent, SWT.NONE);
+ c.setLayout(new FormLayout());
+ viewer = new TreeViewer(c, SWT.SINGLE | SWT.BORDER);
+ viewer.setContentProvider(getContentProvider());
+ viewer.setLabelProvider(getLabelProvider());
+ viewer.setInput(ResourcesPlugin.getWorkspace());
+
+ browse = new Button(c, SWT.NONE);
+ browse.setText("Browse...");
+ FormData fd = new FormData();
+ fd.left = new FormAttachment(0, 5);
+ fd.bottom = new FormAttachment(100, -5);
+ browse.setLayoutData(fd);
+
+ fd = new FormData();
+ fd.left = new FormAttachment(0, 5);
+ fd.top = new FormAttachment(0, 5);
+ fd.right = new FormAttachment(100, -5);
+ fd.bottom = new FormAttachment(browse, -5);
+ viewer.getTree().setLayoutData(fd);
+
+ browse.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ buttonPressed();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ });
+ return c;
+ }
+
+ protected void buttonPressed() {
+ IProject project = (IProject)getTaskModel().getObject(NewReferenceWizard.PROJECT);
+ selected = BuildPathDialogAccess.chooseJAREntries(
+ browse.getShell(),
+ project.getLocation(), new IPath[0]);
+ viewer.refresh();
+ }
+
+ public void performFinish(IProgressMonitor monitor) throws CoreException {
+ IVirtualComponent rootComponent = (IVirtualComponent)getTaskModel().getObject(NewReferenceWizard.ROOT_COMPONENT);
+ if (selected != null && selected.length > 0) {
+ ArrayList<IVirtualComponent> compList = new ArrayList<IVirtualComponent>();
+ ArrayList<String> paths = new ArrayList<String>();
+ for (int i = 0; i < selected.length; i++) {
+ // IPath fullPath = project.getFile(selected[i]).getFullPath();
+ String type = VirtualArchiveComponent.LIBARCHIVETYPE
+ + IPath.SEPARATOR;
+ IVirtualComponent archive = ComponentCore
+ .createArchiveComponent(rootComponent.getProject(),
+ type + selected[i].makeRelative().toString());
+ compList.add(archive);
+ paths.add(selected[i].lastSegment());
+ }
+ IVirtualComponent[] components = (IVirtualComponent[]) compList.toArray(new IVirtualComponent[compList.size()]);
+ String[] paths2 = (String[]) paths.toArray(new String[paths.size()]);
+ getTaskModel().putObject(NewReferenceWizard.COMPONENT, components);
+ getTaskModel().putObject(NewReferenceWizard.COMPONENT_PATH, paths2);
+ }
+ }
+
+ protected LabelProvider getLabelProvider() {
+ if (labelProvider == null) {
+ labelProvider = new LabelProvider() {
+ public Image getImage(Object element) {
+ return null;
+ }
+
+ public String getText(Object element) {
+ return element == null ? "" : element.toString();//$NON-NLS-1$
+ }
+ };
+ }
+ return labelProvider;
+ }
+
+ protected ITreeContentProvider getContentProvider() {
+ if (contentProvider == null) {
+ contentProvider = new ITreeContentProvider() {
+ public Object[] getElements(Object inputElement) {
+ return selected == null ? new Object[]{} : selected;
+ }
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ public void dispose() {
+ }
+ public boolean hasChildren(Object element) {
+ return false;
+ }
+ public Object getParent(Object element) {
+ return null;
+ }
+ public Object[] getChildren(Object parentElement) {
+ return null;
+ }
+ };
+ }
+ return contentProvider;
+ }
+}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/ModuleAssemblyRootPage.java (from rev 16826, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ModuleAssemblyRootPage.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/ModuleAssemblyRootPage.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/ModuleAssemblyRootPage.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -0,0 +1,177 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 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 implementation as prop page heirarchy
+ * rfrost(a)bea.com - conversion to single property page impl
+ *******************************************************************************/
+
+package org.eclipse.wst.common.componentcore.ui.propertypage.internal;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.PropertyPage;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.ui.propertypage.IDependencyPageProvider;
+import org.eclipse.wst.common.componentcore.ui.propertypage.IModuleDependenciesControl;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+
+/**
+ * Primary project property page for Module dependencies;
+ */
+public class ModuleAssemblyRootPage extends PropertyPage {
+
+ private IProject project;
+ private IModuleDependenciesControl[] controls = new IModuleDependenciesControl[0];
+
+ public ModuleAssemblyRootPage() {
+ super();
+ }
+
+ private Composite getFacetErrorComposite(final Composite parent) {
+ final String errorCheckingFacet = "Error Checking Project Facets";
+ setErrorMessage(errorCheckingFacet);
+ return getErrorComposite(parent, errorCheckingFacet);
+ }
+ private Composite getVirtCompErrorComposite(final Composite parent) {
+ final String errorCheckingFacet = "The given project is not a virtual component project";
+ setErrorMessage(errorCheckingFacet);
+ return getErrorComposite(parent, errorCheckingFacet);
+ }
+
+
+ private Composite getErrorComposite(final Composite parent, final String error) {
+ final Composite composite = new Composite(parent, SWT.NONE);
+ final GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ final Label label= new Label(composite, SWT.NONE);
+ label.setText(error);
+ return composite;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.IPreferencePage#performOk()
+ */
+ public boolean performOk() {
+ for (int i = 0; i < controls.length; i++) {
+ if (controls[i] != null) {
+ if (!controls[i].performOk()) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
+ */
+ public void performDefaults() {
+ for (int i = 0; i < controls.length; i++) {
+ if (controls[i] != null) {
+ controls[i].performDefaults();
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.IPreferencePage#performCancel()
+ */
+ public boolean performCancel() {
+ for (int i = 0; i < controls.length; i++) {
+ if (controls[i] != null) {
+ if (!controls[i].performCancel()) {
+ return false;
+ }
+ }
+ }
+ return super.performCancel();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
+ */
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ for (int i = 0; i < controls.length; i++) {
+ if (controls[i] != null) {
+ controls[i].setVisible(visible);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#dispose()
+ */
+ public void dispose() {
+ super.dispose();
+ for (int i = 0; i < controls.length; i++) {
+ if(controls[i] != null){
+ controls[i].dispose();
+ }
+ }
+ }
+
+ protected static void createDescriptionComposite(final Composite parent, final String description) {
+ Composite descriptionComp = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ descriptionComp.setLayout(layout);
+ descriptionComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ fillDescription(descriptionComp, description);
+ }
+
+ private static void fillDescription(Composite c, String s) {
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = 250;
+ Text text = new Text(c, SWT.READ_ONLY | SWT.WRAP);
+ text.setLayoutData(data);
+ text.setText(s);
+ }
+
+ protected Control createContents(Composite parent) {
+
+ // Need to find out what type of project we are handling
+ project = (IProject) getElement().getAdapter(IResource.class);
+ if( project != null ) {
+ try {
+ IFacetedProject facetedProject = ProjectFacetsManager.create(project);
+ IDependencyPageProvider provider = null;
+ if( facetedProject == null )
+ return getFacetErrorComposite(parent);
+
+ provider = DependencyPageExtensionManager.getManager().getProvider(facetedProject);
+ if( provider != null ) {
+ controls = provider.createPages(facetedProject, this);
+ return provider.createRootControl(controls, parent);
+ }
+
+ if( ComponentCore.createComponent(project) == null )
+ return getVirtCompErrorComposite(parent);
+
+ AddModuleDependenciesPropertiesPage page = new AddModuleDependenciesPropertiesPage(project, this);
+ controls = new IModuleDependenciesControl[1];
+ controls[0] = page;
+ return page.createContents(parent);
+ } catch( CoreException ce ) {
+ }
+ }
+ return getFacetErrorComposite(parent);
+ }
+}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/NewReferenceRootWizardFragment.java (from rev 16826, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/NewReferenceRootWizardFragment.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/NewReferenceRootWizardFragment.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/NewReferenceRootWizardFragment.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -0,0 +1,148 @@
+package org.eclipse.wst.common.componentcore.ui.propertypage.internal;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.wst.server.ui.wizard.IWizardHandle;
+import org.eclipse.wst.server.ui.wizard.WizardFragment;
+import org.eclipse.wst.common.componentcore.ui.propertypage.internal.DependencyPageExtensionManager.ReferenceExtension;
+
+public class NewReferenceRootWizardFragment extends WizardFragment {
+ protected Map<String, WizardFragment> fragmentMap =
+ new HashMap<String, WizardFragment>();
+ private IWizardHandle wizard;
+ private TreeViewer viewer;
+ public boolean hasComposite() {
+ return true;
+ }
+
+ public Composite createComposite(Composite parent, IWizardHandle wizard) {
+ this.wizard = wizard;
+ wizard.setTitle("Select a reference type");
+ wizard.setDescription("Here you can select one of many types of references to add");
+ Composite c = new Composite(parent, SWT.NONE);
+ c.setLayout(new FillLayout());
+ viewer = new TreeViewer(c, SWT.SINGLE | SWT.BORDER);
+ viewer.setLabelProvider(getLabelProvider());
+ viewer.setContentProvider(getContentProvider());
+ viewer.setInput(ResourcesPlugin.getWorkspace());
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ viewerSelectionChanged();
+ }
+ });
+ return c;
+ }
+
+ protected void viewerSelectionChanged() {
+ wizard.update();
+ }
+
+ protected WizardFragment getWizardFragment(String extensionPointID) {
+ try {
+ WizardFragment fragment = fragmentMap.get(extensionPointID);
+ if (fragment != null)
+ return fragment;
+ } catch (Exception e) {
+ // ignore
+ }
+
+ WizardFragment fragment = DependencyPageExtensionManager.getManager().loadReferenceWizardFragment(extensionPointID);
+ if (fragment != null)
+ fragmentMap.put(extensionPointID, fragment);
+ return fragment;
+ }
+
+ public List getChildFragments() {
+ List<WizardFragment> listImpl = new ArrayList<WizardFragment>();
+ createChildFragments(listImpl);
+ return listImpl;
+ }
+
+ protected void createChildFragments(List<WizardFragment> list) {
+ // Instantiate and add the fragment for the current ID
+ if( viewer != null ) {
+ IStructuredSelection sel = (IStructuredSelection)viewer.getSelection();
+ ReferenceExtension selected = (ReferenceExtension)sel.getFirstElement();
+ if( selected != null ) {
+ WizardFragment child = getWizardFragment(selected.getId());
+ if( child != null )
+ list.add(child);
+ }
+ }
+ }
+
+ public boolean isComplete() {
+ return true;
+ }
+
+
+ private LabelProvider labelProvider = null;
+ private ITreeContentProvider contentProvider = null;
+ protected LabelProvider getLabelProvider() {
+ if( labelProvider == null ) {
+ labelProvider = new LabelProvider() {
+ public Image getImage(Object element) {
+ if( element instanceof ReferenceExtension)
+ return ((ReferenceExtension)element).getImage();
+ return null;
+ }
+ public String getText(Object element) {
+ if( element instanceof ReferenceExtension)
+ return ((ReferenceExtension)element).getName();
+ return element == null ? "" : element.toString();//$NON-NLS-1$
+ }
+ public void dispose() {
+ super.dispose();
+ if( extensions != null ) {
+ for( int i = 0; i < extensions.length; i++) {
+ extensions[i].disposeImage();
+ }
+ }
+ }
+ };
+ }
+ return labelProvider;
+ }
+
+ private ReferenceExtension[] extensions = null;
+ protected ITreeContentProvider getContentProvider() {
+ if( contentProvider == null ) {
+ contentProvider = new ITreeContentProvider() {
+ public Object[] getElements(Object inputElement) {
+ if( extensions == null )
+ extensions = DependencyPageExtensionManager.getManager().getReferenceExtensions();
+ return extensions;
+ }
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ public void dispose() {
+ }
+ public boolean hasChildren(Object element) {
+ return false;
+ }
+ public Object getParent(Object element) {
+ return null;
+ }
+ public Object[] getChildren(Object parentElement) {
+ return null;
+ }
+ };
+ }
+ return contentProvider;
+ }
+}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/NewReferenceWizard.java (from rev 16826, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/NewReferenceWizard.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/NewReferenceWizard.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/NewReferenceWizard.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -0,0 +1,28 @@
+package org.eclipse.wst.common.componentcore.ui.propertypage.internal;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.wst.server.ui.internal.wizard.TaskWizard;
+import org.eclipse.wst.server.ui.wizard.WizardFragment;
+
+public class NewReferenceWizard extends TaskWizard {
+
+ public static final String COMPONENT = "dependency.component";
+ public static final String COMPONENT_PATH = "dependency.component.path";
+ public static final String PROJECT = "root.project";
+ public static final String ROOT_COMPONENT = "root.component";
+
+ public NewReferenceWizard() {
+ super("New Reference Wizard", new WizardFragment() {
+ protected void createChildFragments(List<WizardFragment> list) {
+ list.add(new NewReferenceRootWizardFragment());
+ }
+ });
+ }
+
+ public void init(IWorkbench newWorkbench, IStructuredSelection newSelection) {
+ // do nothing
+ }
+}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/ProjectReferenceWizardFragment.java (from rev 16827, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ProjectReferenceWizardFragment.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/ProjectReferenceWizardFragment.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/ProjectReferenceWizardFragment.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -0,0 +1,146 @@
+package org.eclipse.wst.common.componentcore.ui.propertypage.internal;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jst.j2ee.project.facet.IJavaProjectMigrationDataModelProperties;
+import org.eclipse.jst.j2ee.project.facet.JavaProjectMigrationDataModelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.ModuleCoreNature;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.server.ui.wizard.IWizardHandle;
+import org.eclipse.wst.server.ui.wizard.WizardFragment;
+
+public class ProjectReferenceWizardFragment extends WizardFragment {
+ private LabelProvider labelProvider = null;
+ private ITreeContentProvider contentProvider = null;
+ private TreeViewer viewer;
+ private IProject selected;
+
+ public boolean hasComposite() {
+ return true;
+ }
+
+ public Composite createComposite(Composite parent, IWizardHandle handle) {
+ handle.setTitle("Add a Project Reference");
+ handle.setDescription("Here you can make a project into a reference.\n" +
+ "If the project is not already a flexible project, it will be converted into one.");
+
+ Composite c = new Composite(parent, SWT.NONE);
+ c.setLayout(new FillLayout());
+ viewer = new TreeViewer(c, SWT.SINGLE | SWT.BORDER);
+ viewer.setContentProvider(getContentProvider());
+ viewer.setLabelProvider(getLabelProvider());
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ selChanged();
+ }
+ });
+ viewer.setInput(ResourcesPlugin.getWorkspace());
+ return c;
+ }
+
+ private void selChanged() {
+ if( viewer != null ) {
+ IStructuredSelection sel = (IStructuredSelection)viewer.getSelection();
+ if( sel != null )
+ selected = (IProject)sel.getFirstElement();
+ }
+ }
+
+ public void performFinish(IProgressMonitor monitor) throws CoreException {
+ if( !ModuleCoreNature.isFlexibleProject(selected)) {
+ try {
+ IDataModel migrationdm = DataModelFactory.createDataModel(new JavaProjectMigrationDataModelProvider());
+ migrationdm.setProperty(IJavaProjectMigrationDataModelProperties.PROJECT_NAME, selected.getName());
+ migrationdm.getDefaultOperation().execute(new NullProgressMonitor(), null);
+ } catch( ExecutionException ee) {
+ // TODO something
+ }
+ }
+ IVirtualComponent comp = ComponentCore.createComponent(selected);
+ String path = selected.getName();
+
+ // TODO extension point? API? Something?!
+ //String extension = ComponentUtils.getDefaultProjectExtension(comp);
+ path += ".jar"; //extension;
+
+ getTaskModel().putObject(NewReferenceWizard.COMPONENT, comp);
+ getTaskModel().putObject(NewReferenceWizard.COMPONENT_PATH, path);
+ }
+
+
+ protected LabelProvider getLabelProvider() {
+ if( labelProvider == null ) {
+ labelProvider = new LabelProvider() {
+ public Image getImage(Object element) {
+ return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_PROJECT);
+ }
+ public String getText(Object element) {
+ if( element instanceof IProject )
+ return ((IProject)element).getName();
+ return element == null ? "" : element.toString();//$NON-NLS-1$
+ }
+ };
+ }
+ return labelProvider;
+ }
+
+ protected ITreeContentProvider getContentProvider() {
+ if( contentProvider == null ) {
+ contentProvider = new ITreeContentProvider() {
+ public Object[] getElements(Object inputElement) {
+ IProject root = (IProject)getTaskModel().getObject(NewReferenceWizard.PROJECT);
+ IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ ArrayList<IProject> list = new ArrayList<IProject>(Arrays.asList(projects));
+ Iterator<IProject> i = list.iterator();
+ IProject p;
+ while(i.hasNext()) {
+ p = i.next();
+ if( !p.isOpen())
+ i.remove();
+ else if( p.equals(root))
+ i.remove();
+ }
+ return (IProject[]) list.toArray(new IProject[list.size()]);
+ }
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ public void dispose() {
+ }
+ public boolean hasChildren(Object element) {
+ return false;
+ }
+ public Object getParent(Object element) {
+ return null;
+ }
+ public Object[] getChildren(Object parentElement) {
+ return null;
+ }
+ };
+ }
+ return contentProvider;
+ }
+}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/VariableReferenceWizardFragment.java (from rev 16826, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/VariableReferenceWizardFragment.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/VariableReferenceWizardFragment.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/internal/VariableReferenceWizardFragment.java 2009-07-27 20:08:43 UTC (rev 16828)
@@ -0,0 +1,56 @@
+package org.eclipse.wst.common.componentcore.ui.propertypage.internal;
+
+import java.util.ArrayList;
+
+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.jdt.core.JavaCore;
+import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.server.ui.wizard.IWizardHandle;
+
+public class VariableReferenceWizardFragment extends JarReferenceWizardFragment {
+ public Composite createComposite(Composite parent, IWizardHandle handle) {
+ Composite c = super.createComposite(parent, handle);
+ handle.setTitle("Add a Variable Reference");
+ handle.setDescription("Here you can reference a variable which maps to a single jar.\n"
+ + "This is not a suggested use-case, but is here for backwards compatability.");
+ return c;
+ }
+
+ protected void buttonPressed() {
+ selected = BuildPathDialogAccess.chooseVariableEntries(
+ browse.getShell(), new Path[0]);
+ viewer.refresh();
+ }
+
+ public void performFinish(IProgressMonitor monitor) throws CoreException {
+ IVirtualComponent rootComponent = (IVirtualComponent)getTaskModel().getObject(NewReferenceWizard.ROOT_COMPONENT);
+ if (selected != null && selected.length > 0) {
+ ArrayList<IVirtualComponent> compList = new ArrayList<IVirtualComponent>();
+ ArrayList<String> paths = new ArrayList<String>();
+ for (int i = 0; i < selected.length; i++) {
+ IPath resolvedPath = JavaCore.getResolvedVariablePath(selected[i]);
+ java.io.File file = new java.io.File(resolvedPath.toOSString());
+ if (file.isFile() && file.exists()) {
+ String type = VirtualArchiveComponent.VARARCHIVETYPE
+ + IPath.SEPARATOR;
+ IVirtualComponent archive = ComponentCore
+ .createArchiveComponent(rootComponent.getProject(),
+ type + selected[i].toString());
+ compList.add(archive);
+ paths.add(resolvedPath.lastSegment());
+ }
+ }
+ IVirtualComponent[] components = (IVirtualComponent[]) compList.toArray(new IVirtualComponent[compList.size()]);
+ String[] paths2 = (String[]) paths.toArray(new String[paths.size()]);
+ getTaskModel().putObject(NewReferenceWizard.COMPONENT, components);
+ getTaskModel().putObject(NewReferenceWizard.COMPONENT_PATH, paths2);
+ }
+ }
+}
15 years, 5 months
JBoss Tools SVN: r16827 - in workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui: src/org/eclipse/wst/common/componentcore/ui/propertypage and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2009-07-27 15:32:57 -0400 (Mon, 27 Jul 2009)
New Revision: 16827
Modified:
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/META-INF/MANIFEST.MF
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/AddModuleDependenciesPropertiesPage.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ExternalJarReferenceWizardFragment.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/JarReferenceWizardFragment.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ProjectReferenceWizardFragment.java
Log:
Some cleanup for eclipse patch
Modified: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/META-INF/MANIFEST.MF
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/META-INF/MANIFEST.MF 2009-07-27 18:51:58 UTC (rev 16826)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/META-INF/MANIFEST.MF 2009-07-27 19:32:57 UTC (rev 16827)
@@ -21,7 +21,6 @@
org.eclipse.jem.util;bundle-version="2.0.200",
org.eclipse.jst.jee;bundle-version="1.0.200",
org.eclipse.jdt.ui;bundle-version="3.5.0",
- org.jboss.ide.eclipse.as.wtp.override.core;bundle-version="1.0.0",
org.eclipse.wst.server.ui;bundle-version="1.1.102",
org.eclipse.wst.server.core;bundle-version="1.1.101",
org.eclipse.wst.common.emfworkbench.integration;bundle-version="1.1.300",
Modified: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/AddModuleDependenciesPropertiesPage.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/AddModuleDependenciesPropertiesPage.java 2009-07-27 18:51:58 UTC (rev 16826)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/AddModuleDependenciesPropertiesPage.java 2009-07-27 19:32:57 UTC (rev 16827)
@@ -75,13 +75,12 @@
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
+import org.eclipse.wst.common.componentcore.ui.Messages;
+import org.eclipse.wst.common.componentcore.ui.WTPOveridePlugin;
import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
-import org.jboss.ide.eclipse.as.wtp.override.core.vcf.ComponentUtils;
-import org.eclipse.wst.common.componentcore.ui.Messages;
-import org.eclipse.wst.common.componentcore.ui.WTPOveridePlugin;
public class AddModuleDependenciesPropertiesPage implements Listener,
IModuleDependenciesControl {
@@ -838,21 +837,6 @@
WTPOveridePlugin.logError(e);
}
}
- /**
- * Method returns the name of the given IVirtualComponent being sure the correct extension
- * is on the end of the name, this is important for internal projects. Added for [Bug 241509]
- *
- * Note (rs) : I do not believe this ever gets called with a binary virtComp
- *
- * @param virtComp the IVirtualComponent to get the name of with the correct extension
- * @return the name of the given IVirtualComponent with the correct extension
- */
- protected String getVirtualComponentNameWithExtension(IVirtualComponent virtComp) {
- String virtCompURIMapName = this.getURIMappingName(virtComp);
- String extension = ComponentUtils.getDefaultProjectExtension(virtComp);
- virtCompURIMapName += extension;
- return virtCompURIMapName;
- }
/**
* [Bug 238264]
Modified: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ExternalJarReferenceWizardFragment.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ExternalJarReferenceWizardFragment.java 2009-07-27 18:51:58 UTC (rev 16826)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ExternalJarReferenceWizardFragment.java 2009-07-27 19:32:57 UTC (rev 16827)
@@ -1,43 +1,16 @@
package org.eclipse.wst.common.componentcore.ui.propertypage;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jst.j2ee.project.facet.IJavaProjectMigrationDataModelProperties;
-import org.eclipse.jst.j2ee.project.facet.JavaProjectMigrationDataModelProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.ModuleCoreNature;
import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.server.ui.wizard.IWizardHandle;
-import org.eclipse.wst.server.ui.wizard.WizardFragment;
-import org.jboss.ide.eclipse.as.wtp.override.core.vcf.ComponentUtils;
public class ExternalJarReferenceWizardFragment extends JarReferenceWizardFragment {
public Composite createComposite(Composite parent, IWizardHandle handle) {
Modified: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/JarReferenceWizardFragment.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/JarReferenceWizardFragment.java 2009-07-27 18:51:58 UTC (rev 16826)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/JarReferenceWizardFragment.java 2009-07-27 19:32:57 UTC (rev 16827)
@@ -1,23 +1,17 @@
package org.eclipse.wst.common.componentcore.ui.propertypage;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jst.j2ee.project.facet.IJavaProjectMigrationDataModelProperties;
-import org.eclipse.jst.j2ee.project.facet.JavaProjectMigrationDataModelProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
@@ -27,17 +21,11 @@
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.ModuleCoreNature;
import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.server.ui.wizard.IWizardHandle;
import org.eclipse.wst.server.ui.wizard.WizardFragment;
-import org.jboss.ide.eclipse.as.wtp.override.core.vcf.ComponentUtils;
public class JarReferenceWizardFragment extends WizardFragment {
protected LabelProvider labelProvider = null;
Modified: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ProjectReferenceWizardFragment.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ProjectReferenceWizardFragment.java 2009-07-27 18:51:58 UTC (rev 16826)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ProjectReferenceWizardFragment.java 2009-07-27 19:32:57 UTC (rev 16827)
@@ -32,7 +32,6 @@
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.server.ui.wizard.IWizardHandle;
import org.eclipse.wst.server.ui.wizard.WizardFragment;
-import org.jboss.ide.eclipse.as.wtp.override.core.vcf.ComponentUtils;
public class ProjectReferenceWizardFragment extends WizardFragment {
private LabelProvider labelProvider = null;
@@ -83,8 +82,10 @@
}
IVirtualComponent comp = ComponentCore.createComponent(selected);
String path = selected.getName();
- String extension = ComponentUtils.getDefaultProjectExtension(comp);
- path += extension;
+
+ // TODO extension point? API? Something?!
+ //String extension = ComponentUtils.getDefaultProjectExtension(comp);
+ path += ".jar"; //extension;
getTaskModel().putObject(NewReferenceWizard.COMPONENT, comp);
getTaskModel().putObject(NewReferenceWizard.COMPONENT_PATH, path);
15 years, 5 months
JBoss Tools SVN: r16826 - in workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui: META-INF and 11 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2009-07-27 14:51:58 -0400 (Mon, 27 Jul 2009)
New Revision: 16826
Added:
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/Messages.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/WTPOveridePlugin.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/messages.properties
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/AddFolderDialog.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/AddModuleDependenciesPropertiesPage.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ComponentDependencyContentProvider.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/DependencyPageExtensionManager.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ExternalJarReferenceWizardFragment.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/IDependencyPageProvider.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/IModuleDependenciesControl.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/JarReferenceWizardFragment.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ModuleAssemblyRootPage.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/NewReferenceRootWizardFragment.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/NewReferenceWizard.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ProjectReferenceWizardFragment.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/VariableReferenceWizardFragment.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/impl/
Removed:
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/Messages.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/WTPOveridePlugin.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/messages.properties
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/AddFolderDialog.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/AddModuleDependenciesPropertiesPage.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ComponentDependencyContentProvider.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/DependencyPageExtensionManager.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ExternalJarReferenceWizardFragment.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/IDependencyPageProvider.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/IModuleDependenciesControl.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/JarReferenceWizardFragment.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ModuleAssemblyRootPage.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/NewReferenceRootWizardFragment.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/NewReferenceWizard.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ProjectReferenceWizardFragment.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/VariableReferenceWizardFragment.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/impl/
Modified:
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/.project
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/META-INF/MANIFEST.MF
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/plugin.xml
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/schema/moduleDependencyPropertyPage.exsd
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/schema/referenceWizardFragment.exsd
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/impl/EarModuleDependenciesPropertyPage.java
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/impl/EarModuleDependencyPageProvider.java
Log:
getting workspace version into decent shape
Modified: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/.project
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/.project 2009-07-27 18:37:50 UTC (rev 16825)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/.project 2009-07-27 18:51:58 UTC (rev 16826)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>org.jboss.ide.eclipse.as.wtp.override.ui</name>
+ <name>org.eclipse.wst.common.componentcore.ui</name>
<comment></comment>
<projects>
</projects>
Modified: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/META-INF/MANIFEST.MF
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/META-INF/MANIFEST.MF 2009-07-27 18:37:50 UTC (rev 16825)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/META-INF/MANIFEST.MF 2009-07-27 18:51:58 UTC (rev 16826)
@@ -1,9 +1,9 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: WTP UI Overrides
-Bundle-SymbolicName: org.jboss.ide.eclipse.as.wtp.override.ui;singleton:=true
+Bundle-SymbolicName: org.eclipse.wst.common.componentcore.ui;singleton:=true
Bundle-Version: 1.0.0.qualifier
-Bundle-Activator: org.jboss.ide.eclipse.as.wtp.override.ui.WTPOveridePlugin
+Bundle-Activator: org.eclipse.wst.common.componentcore.ui.WTPOveridePlugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.core.resources;bundle-version="3.5.0",
Modified: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/plugin.xml
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/plugin.xml 2009-07-27 18:37:50 UTC (rev 16825)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/plugin.xml 2009-07-27 18:51:58 UTC (rev 16826)
@@ -11,8 +11,8 @@
adaptable="true"
objectClass="org.eclipse.core.resources.IProject"
name="Module Assembly"
- class="org.jboss.ide.eclipse.as.wtp.override.ui.propertypage.ModuleAssemblyRootPage"
- id="org.jboss.ide.eclipse.as.wtp.override.ui.J2EEDependenciesPage">
+ class="org.eclipse.wst.common.componentcore.ui.propertypage.ModuleAssemblyRootPage"
+ id="org.eclipse.wst.common.componentcore.ui.J2EEDependenciesPage">
<enabledWhen>
<and>
<adapt
@@ -23,36 +23,36 @@
</page>
</extension>
<extension
- point="org.jboss.ide.eclipse.as.wtp.override.ui.moduleDependencyPropertyPage">
+ point="org.eclipse.wst.common.componentcore.ui.moduleDependencyPropertyPage">
<dependencyPage
- class="org.jboss.ide.eclipse.as.wtp.override.ui.propertypage.impl.EarModuleDependencyPageProvider"
- id="org.jboss.ide.eclipse.as.wtp.override.ui.earDependencyPage">
+ class="org.eclipse.wst.common.componentcore.ui.propertypage.impl.EarModuleDependencyPageProvider"
+ id="org.eclipse.wst.common.componentcore.ui.earDependencyPage">
</dependencyPage>
</extension>
<extension
- point="org.jboss.ide.eclipse.as.wtp.override.ui.referenceWizardFragment">
+ point="org.eclipse.wst.common.componentcore.ui.referenceWizardFragment">
<referenceFragment
- class="org.jboss.ide.eclipse.as.wtp.override.ui.propertypage.ProjectReferenceWizardFragment"
+ class="org.eclipse.wst.common.componentcore.ui.propertypage.ProjectReferenceWizardFragment"
icon="icons/prj_obj.gif"
- id="org.jboss.ide.eclipse.as.wtp.override.ui.newProjectReference"
+ id="org.eclipse.wst.common.componentcore.ui.newProjectReference"
name="Project">
</referenceFragment>
<referenceFragment
- class="org.jboss.ide.eclipse.as.wtp.override.ui.propertypage.JarReferenceWizardFragment"
+ class="org.eclipse.wst.common.componentcore.ui.propertypage.JarReferenceWizardFragment"
icon="icons/jar_obj.gif"
- id="org.jboss.ide.eclipse.as.wtp.override.ui.jarReference"
+ id="org.eclipse.wst.common.componentcore.ui.jarReference"
name="Jar">
</referenceFragment>
<referenceFragment
- class="org.jboss.ide.eclipse.as.wtp.override.ui.propertypage.ExternalJarReferenceWizardFragment"
+ class="org.eclipse.wst.common.componentcore.ui.propertypage.ExternalJarReferenceWizardFragment"
icon="icons/jar_obj.gif"
- id="org.jboss.ide.eclipse.as.wtp.override.ui.externalJarReference"
+ id="org.eclipse.wst.common.componentcore.ui.externalJarReference"
name="External Jar">
</referenceFragment>
<referenceFragment
- class="org.jboss.ide.eclipse.as.wtp.override.ui.propertypage.VariableReferenceWizardFragment"
+ class="org.eclipse.wst.common.componentcore.ui.propertypage.VariableReferenceWizardFragment"
icon="icons/jar_obj.gif"
- id="org.jboss.ide.eclipse.as.wtp.override.ui.variableReference"
+ id="org.eclipse.wst.common.componentcore.ui.variableReference"
name="Variable">
</referenceFragment>
</extension>
Modified: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/schema/moduleDependencyPropertyPage.exsd
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/schema/moduleDependencyPropertyPage.exsd 2009-07-27 18:37:50 UTC (rev 16825)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/schema/moduleDependencyPropertyPage.exsd 2009-07-27 18:51:58 UTC (rev 16826)
@@ -1,9 +1,9 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
-<schema targetNamespace="org.jboss.ide.eclipse.as.wtp.override.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+<schema targetNamespace="org.eclipse.wst.common.componentcore.ui" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
- <meta.schema plugin="org.jboss.ide.eclipse.as.wtp.override.ui" id="moduleDependencyPropertyPage" name="org.jboss.ide.eclipse.as.wtp.override.moduleDependencyPropertyPage"/>
+ <meta.schema plugin="org.eclipse.wst.common.componentcore.ui" id="moduleDependencyPropertyPage" name="org.jboss.ide.eclipse.as.wtp.override.moduleDependencyPropertyPage"/>
</appinfo>
<documentation>
[Enter description of this extension point.]
@@ -62,7 +62,7 @@
</documentation>
<appinfo>
- <meta.attribute kind="java" basedOn=":org.jboss.ide.eclipse.as.wtp.override.ui.propertypage.IDependencyPageProvider"/>
+ <meta.attribute kind="java" basedOn=":org.eclipse.wst.common.componentcore.ui.propertypage.IDependencyPageProvider"/>
</appinfo>
</annotation>
</attribute>
Modified: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/schema/referenceWizardFragment.exsd
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/schema/referenceWizardFragment.exsd 2009-07-27 18:37:50 UTC (rev 16825)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/schema/referenceWizardFragment.exsd 2009-07-27 18:51:58 UTC (rev 16826)
@@ -1,9 +1,9 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
-<schema targetNamespace="org.jboss.ide.eclipse.as.wtp.override.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+<schema targetNamespace="org.eclipse.wst.common.componentcore.ui" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
- <meta.schema plugin="org.jboss.ide.eclipse.as.wtp.override.ui" id="referenceWizardFragment" name="referenceWizardFragment"/>
+ <meta.schema plugin="org.eclipse.wst.common.componentcore.ui" id="referenceWizardFragment" name="referenceWizardFragment"/>
</appinfo>
<documentation>
[Enter description of this extension point.]
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/Messages.java (from rev 16825, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/Messages.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/Messages.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/Messages.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -0,0 +1,21 @@
+package org.eclipse.wst.common.componentcore.ui;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.wst.common.componentcore.ui.messages"; //$NON-NLS-1$
+ public static String AddModuleDependenciesPropertiesPage_AddProjectButton;
+ public static String AddModuleDependenciesPropertiesPage_DeployPathColumn;
+ public static String AddModuleDependenciesPropertiesPage_RemoveSelectedButton;
+ public static String AddModuleDependenciesPropertiesPage_SelectAProjectTitle;
+ public static String AddModuleDependenciesPropertiesPage_SourceColumn;
+ public static String J2EEDependenciesPage_Description;
+ public static String J2EEDependenciesPage_ErrorCheckingFacets;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/WTPOveridePlugin.java (from rev 16825, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/WTPOveridePlugin.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/WTPOveridePlugin.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/WTPOveridePlugin.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -0,0 +1,87 @@
+package org.eclipse.wst.common.componentcore.ui;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class WTPOveridePlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.wst.common.componentcore.ui"; //$NON-NLS-1$
+
+ // The shared instance
+ private static WTPOveridePlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public WTPOveridePlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static WTPOveridePlugin getDefault() {
+ return plugin;
+ }
+
+ public static void log(Exception e) {
+ log(e.getMessage(), e);
+ }
+
+ public static void log(String message, Exception e) {
+ IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, message, e);
+ getDefault().getLog().log(status);
+ }
+ public static IStatus createStatus(int severity, int aCode,
+ String aMessage, Throwable exception) {
+ return new Status(severity, PLUGIN_ID, aCode,
+ aMessage != null ? aMessage : "No message.", exception); //$NON-NLS-1$
+ }
+ public static IStatus createErrorStatus(int aCode, String aMessage,
+ Throwable exception) {
+ return createStatus(IStatus.ERROR, aCode, aMessage, exception);
+ }
+
+ public static IStatus createStatus(int severity, String message, Throwable exception) {
+ return new Status(severity, PLUGIN_ID, message, exception);
+ }
+
+ public static IStatus createStatus(int severity, String message) {
+ return createStatus(severity, message, null);
+ }
+ public static void logError(Throwable exception) {
+ Platform.getLog(Platform.getBundle(PLUGIN_ID)).log( createStatus(IStatus.ERROR, exception.getMessage(), exception));
+ }
+
+ public static void logError(CoreException exception) {
+ Platform.getLog(Platform.getBundle(PLUGIN_ID)).log( exception.getStatus() );
+ }
+
+}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/messages.properties (from rev 16825, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/messages.properties)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/messages.properties (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/messages.properties 2009-07-27 18:51:58 UTC (rev 16826)
@@ -0,0 +1,7 @@
+AddModuleDependenciesPropertiesPage_AddProjectButton=Add Project...
+AddModuleDependenciesPropertiesPage_DeployPathColumn=Deploy Path
+AddModuleDependenciesPropertiesPage_RemoveSelectedButton=Remove selected...
+AddModuleDependenciesPropertiesPage_SelectAProjectTitle=Select a Project
+AddModuleDependenciesPropertiesPage_SourceColumn=Source
+J2EEDependenciesPage_Description=ModuleDependency Page Description
+J2EEDependenciesPage_ErrorCheckingFacets=Error Checking Project Facets
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/AddFolderDialog.java (from rev 16825, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/AddFolderDialog.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/AddFolderDialog.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/AddFolderDialog.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -0,0 +1,133 @@
+package org.eclipse.wst.common.componentcore.ui.propertypage;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+public class AddFolderDialog extends TitleAreaDialog {
+ private IProject project;
+ private TreeViewer viewer;
+ private IContainer selected = null;
+ public AddFolderDialog(Shell parentShell, IProject project) {
+ super(parentShell);
+ this.project = project;
+ }
+
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ shell.setText("Add Folder");
+ shell.setBounds(shell.getLocation().x, shell.getLocation().y, 400,300);
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite c = (Composite)super.createDialogArea(parent);
+ this.viewer = new TreeViewer(c, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ viewer.setContentProvider(getContentProvider());
+ viewer.setLabelProvider(getLabelProvider());
+ viewer.addFilter(getFilter());
+ viewer.setInput(project);
+ viewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
+ viewer.addSelectionChangedListener(getListener());
+ return c;
+ }
+
+ protected ISelectionChangedListener getListener() {
+ return new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection sel = (IStructuredSelection)viewer.getSelection();
+ Object first = sel.getFirstElement();
+ if( first instanceof IContainer)
+ selected = (IContainer)first;
+ }
+ };
+ }
+
+ public IContainer getSelected() {
+ return selected;
+ }
+
+ protected ViewerFilter getFilter() {
+ return new ViewerFilter() {
+ public boolean select(Viewer viewer, Object parentElement,
+ Object element) {
+ return element instanceof IContainer;
+ }
+ };
+ }
+
+ protected ITreeContentProvider getContentProvider() {
+ return new ITreeContentProvider() {
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ public void dispose() {
+ }
+
+ public Object[] getElements(Object inputElement) {
+ try {
+ return project.members();
+ } catch( CoreException ce ) {
+ return new Object[]{};
+ }
+ }
+
+ public boolean hasChildren(Object element) {
+ if( element instanceof IContainer) {
+ try {
+ return ((IContainer)element).members().length > 0;
+ } catch( CoreException ce ) {
+ }
+ }
+ return false;
+ }
+
+ public Object getParent(Object element) {
+ if( element instanceof IResource)
+ return ((IResource)element).getParent();
+ return null;
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ if( parentElement instanceof IContainer) {
+ try {
+ return ((IContainer)parentElement).members();
+ } catch( CoreException ce ) {
+ }
+ }
+ return new Object[]{};
+ }
+ };
+ }
+
+ protected LabelProvider getLabelProvider() {
+ return new LabelProvider() {
+ public Image getImage(Object element) {
+ return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
+ }
+ public String getText(Object element) {
+ if( element instanceof IResource)
+ return ((IResource)element).getName();
+ return element.toString();
+ }
+ };
+ }
+}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/AddModuleDependenciesPropertiesPage.java (from rev 16825, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/AddModuleDependenciesPropertiesPage.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/AddModuleDependenciesPropertiesPage.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/AddModuleDependenciesPropertiesPage.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -0,0 +1,909 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 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
+ * David Schneider, david.schneider(a)unisys.com - [142500] WTP properties pages fonts don't follow Eclipse preferences
+ * Stefan Dimov, stefan.dimov(a)sap.com - bugs 207826, 222651
+ *******************************************************************************/
+package org.eclipse.wst.common.componentcore.ui.propertypage;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+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.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
+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.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties;
+import org.eclipse.wst.common.componentcore.internal.ComponentResource;
+import org.eclipse.wst.common.componentcore.internal.StructureEdit;
+import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent;
+import org.eclipse.wst.common.componentcore.internal.operation.CreateReferenceComponentsDataModelProvider;
+import org.eclipse.wst.common.componentcore.internal.operation.RemoveReferenceComponentsDataModelProvider;
+import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
+import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
+import org.jboss.ide.eclipse.as.wtp.override.core.vcf.ComponentUtils;
+import org.eclipse.wst.common.componentcore.ui.Messages;
+import org.eclipse.wst.common.componentcore.ui.WTPOveridePlugin;
+
+public class AddModuleDependenciesPropertiesPage implements Listener,
+ IModuleDependenciesControl {
+
+ private static final String DEPLOY_PATH_PROPERTY = new Integer(0).toString();
+ private static final String SOURCE_PROPERTY = new Integer(1).toString();
+
+
+ protected final String PATH_SEPARATOR = ComponentDependencyContentProvider.PATH_SEPARATOR;
+ private boolean hasInitialized = false;
+ protected final IProject project;
+ protected final ModuleAssemblyRootPage propPage;
+ protected IVirtualComponent rootComponent = null;
+ protected Text componentNameText;
+ protected Label availableModules;
+ protected TableViewer availableComponentsViewer;
+ protected Button addMappingButton, addReferenceButton, removeButton;
+ protected Composite buttonColumn;
+ protected static final IStatus OK_STATUS = IDataModelProvider.OK_STATUS;
+ protected Listener tableListener;
+ protected Listener labelListener;
+
+ // Mappings that existed when the page was opened (or last saved)
+ protected HashMap<IVirtualComponent, String> oldComponentToRuntimePath = new HashMap<IVirtualComponent, String>();
+
+ // Mappings that are current
+ protected HashMap<IVirtualComponent, String> objectToRuntimePath = new HashMap<IVirtualComponent, String>();
+
+ // A single list of wb-resource mappings. If there's any change,
+ // all old will be removed and new ones added
+ protected ArrayList<ComponentResourceProxy> resourceMappings = new ArrayList<ComponentResourceProxy>();
+
+ // keeps track if a change has occurred in wb-resource mappings
+ protected boolean resourceMappingsChanged = false;
+
+ /**
+ * Constructor for AddModulestoEARPropertiesControl.
+ */
+ public AddModuleDependenciesPropertiesPage(final IProject project,
+ final ModuleAssemblyRootPage page) {
+ this.project = project;
+ this.propPage = page;
+ rootComponent = ComponentCore.createComponent(project);
+ }
+
+ /*
+ * UI Creation Methods
+ */
+
+ public Composite createContents(final Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ ModuleAssemblyRootPage.createDescriptionComposite(composite,
+ "TODO Change this: Create and change packaging structure for this project ");
+ createListGroup(composite);
+ refresh();
+ Dialog.applyDialogFont(parent);
+ return composite;
+ }
+
+ protected void createListGroup(Composite parent) {
+ Composite listGroup = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ listGroup.setLayout(layout);
+ GridData gData = new GridData(GridData.FILL_BOTH);
+ gData.horizontalIndent = 5;
+ listGroup.setLayoutData(gData);
+
+ availableModules = new Label(listGroup, SWT.NONE);
+ gData = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.VERTICAL_ALIGN_FILL);
+ availableModules.setText("Module Assembly"); //$NON-NLS-1$
+ availableModules.setLayoutData(gData);
+ createTableComposite(listGroup);
+ }
+
+ protected void createTableComposite(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridData gData = new GridData(GridData.FILL_BOTH);
+ composite.setLayoutData(gData);
+ fillComposite(composite);
+ }
+
+ public void fillComposite(Composite parent) {
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.marginHeight = 0;
+ parent.setLayout(layout);
+ parent.setLayoutData(new GridData(GridData.FILL_BOTH));
+ createTable(parent);
+ createButtonColumn(parent);
+ }
+
+ protected void createButtonColumn(Composite parent) {
+ buttonColumn = createButtonColumnComposite(parent);
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END);
+ buttonColumn.setLayoutData(data);
+ createPushButtons();
+ }
+
+ protected void createPushButtons() {
+ addMappingButton = createPushButton("Add Folder...");
+ addReferenceButton = createPushButton("Add Reference...");
+ removeButton = createPushButton("Remove selected");
+ }
+
+ protected Button createPushButton(String label) {
+ Button aButton = new Button(buttonColumn, SWT.PUSH);
+ aButton.setText(label);
+ aButton.addListener(SWT.Selection, this);
+ aButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ return aButton;
+ }
+
+ public Composite createButtonColumnComposite(Composite parent) {
+ Composite aButtonColumn = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ aButtonColumn.setLayout(layout);
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.VERTICAL_ALIGN_BEGINNING);
+ aButtonColumn.setLayoutData(data);
+ return aButtonColumn;
+ }
+
+ public Group createGroup(Composite parent) {
+ return new Group(parent, SWT.NULL);
+ }
+
+ protected void createTable(Composite parent) {
+ if (rootComponent != null) {
+ availableComponentsViewer = createAvailableComponentsViewer(parent);
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.FILL_VERTICAL);
+ availableComponentsViewer.getTable().setLayoutData(gd);
+
+ ComponentDependencyContentProvider provider = createProvider();
+ provider.setRuntimePaths(objectToRuntimePath);
+ provider.setResourceMappings(resourceMappings);
+ availableComponentsViewer.setContentProvider(provider);
+ availableComponentsViewer.setLabelProvider(provider);
+ addTableListeners();
+ }
+ }
+
+ /**
+ * Subclasses should over-ride this and extend the class
+ */
+ protected ComponentDependencyContentProvider createProvider() {
+ return new ComponentDependencyContentProvider();
+ }
+
+ /*
+ * Listeners of various events
+ */
+
+ protected void addTableListeners() {
+ addHoverHelpListeners();
+ addDoubleClickListener();
+ addSelectionListener();
+ }
+
+ protected void addHoverHelpListeners() {
+ final Table table = availableComponentsViewer.getTable();
+ createLabelListener(table);
+ createTableListener(table);
+ table.addListener(SWT.Dispose, tableListener);
+ table.addListener(SWT.KeyDown, tableListener);
+ table.addListener(SWT.MouseMove, tableListener);
+ table.addListener(SWT.MouseHover, tableListener);
+ }
+
+ protected void createLabelListener(final Table table) {
+ labelListener = new Listener() {
+ public void handleEvent(Event event) {
+ Label label = (Label) event.widget;
+ Shell shell = label.getShell();
+ switch (event.type) {
+ case SWT.MouseDown:
+ Event e = new Event();
+ e.item = (TableItem) label.getData("_TABLEITEM"); //$NON-NLS-1$
+ table.setSelection(new TableItem[] { (TableItem) e.item });
+ table.notifyListeners(SWT.Selection, e);
+ shell.dispose();
+ table.setFocus();
+ break;
+ case SWT.MouseExit:
+ shell.dispose();
+ break;
+ }
+ }
+ };
+ }
+
+ protected void createTableListener(final Table table) {
+ tableListener = new Listener() {
+ Shell tip = null;
+ Label label = null;
+
+ public void handleEvent(Event event) {
+ switch (event.type) {
+ case SWT.Dispose:
+ case SWT.KeyDown:
+ case SWT.MouseMove: {
+ if (tip == null)
+ break;
+ tip.dispose();
+ tip = null;
+ label = null;
+ break;
+ }
+ case SWT.MouseHover: {
+ TableItem item = table.getItem(new Point(event.x, event.y));
+ if (item != null && item.getData() != null && !canEdit(item.getData())) {
+ if (tip != null && !tip.isDisposed())
+ tip.dispose();
+ tip = new Shell(PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell(),
+ SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL);
+ tip.setBackground(Display.getDefault().getSystemColor(
+ SWT.COLOR_INFO_BACKGROUND));
+ FillLayout layout = new FillLayout();
+ layout.marginWidth = 2;
+ tip.setLayout(layout);
+ label = new Label(tip, SWT.WRAP);
+ label.setForeground(Display.getDefault()
+ .getSystemColor(SWT.COLOR_INFO_FOREGROUND));
+ label.setBackground(Display.getDefault()
+ .getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+ label.setData("_TABLEITEM", item); //$NON-NLS-1$
+ label.setText(J2EEUIMessages
+ .getResourceString(J2EEUIMessages.HOVER_HELP_FOR_DISABLED_LIBS));
+ label.addListener(SWT.MouseExit, labelListener);
+ label.addListener(SWT.MouseDown, labelListener);
+ Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ Rectangle rect = item.getBounds(0);
+ Point pt = table.toDisplay(rect.x, rect.y);
+ tip.setBounds(pt.x, pt.y - size.y, size.x, size.y);
+ tip.setVisible(true);
+ }
+ }
+ }
+ }
+ };
+ }
+
+ protected boolean canEdit(Object data) {
+ if( data == null ) return false;
+ if( !(data instanceof VirtualArchiveComponent)) return true;
+
+ VirtualArchiveComponent d2 = (VirtualArchiveComponent)data;
+ boolean sameProject = d2.getWorkspaceRelativePath() != null
+ && d2.getWorkspaceRelativePath().segment(0)
+ .equals(rootComponent.getProject().getName());
+ return !(sameProject && isPhysicallyAdded(d2));
+ }
+
+ protected void addDoubleClickListener() {
+ availableComponentsViewer.setColumnProperties(new String[] {
+ DEPLOY_PATH_PROPERTY, SOURCE_PROPERTY });
+
+ CellEditor[] editors = new CellEditor[] {
+ new TextCellEditor(availableComponentsViewer.getTable()),
+ new TextCellEditor()};
+ availableComponentsViewer.setCellEditors(editors);
+ availableComponentsViewer
+ .setCellModifier(new RuntimePathCellModifier());
+ }
+
+ protected void addSelectionListener() {
+ availableComponentsViewer.addSelectionChangedListener(
+ new ISelectionChangedListener(){
+ public void selectionChanged(SelectionChangedEvent event) {
+ viewerSelectionChanged();
+ }
+ });
+ }
+
+ protected void viewerSelectionChanged() {
+ removeButton.setEnabled(getSelectedObject() != null && canEdit(getSelectedObject()));
+ }
+
+ protected Object getSelectedObject() {
+ IStructuredSelection sel = (IStructuredSelection)availableComponentsViewer.getSelection();
+ return sel.getFirstElement();
+ }
+
+ private class RuntimePathCellModifier implements ICellModifier {
+
+ public boolean canModify(Object element, String property) {
+ if( property.equals(DEPLOY_PATH_PROPERTY)) {
+ if (element instanceof VirtualArchiveComponent) {
+ try {
+ return canEdit(element);
+ } catch (IllegalArgumentException iae) {
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public Object getValue(Object element, String property) {
+ Object data = element; //((TableItem)element).getData();
+ if( data instanceof IVirtualComponent ) {
+ return objectToRuntimePath.get(element) == null ? new Path("/") //$NON-NLS-1$
+ .toString() : objectToRuntimePath.get(element);
+ } else if( data instanceof ComponentResourceProxy) {
+ return ((ComponentResourceProxy)data).runtimePath.toString();
+ }
+ return new Path("/");
+ }
+
+ public void modify(Object element, String property, Object value) {
+ if (property.equals(DEPLOY_PATH_PROPERTY)) {
+ TableItem item = (TableItem) element;
+ if( item.getData() instanceof IVirtualComponent) {
+ objectToRuntimePath.put((IVirtualComponent)item.getData(), (String) value);
+ } else if( item.getData() instanceof ComponentResourceProxy) {
+ ComponentResourceProxy c = ((ComponentResourceProxy)item.getData());
+ c.runtimePath = new Path((String)value);
+ resourceMappingsChanged = true;
+ }
+ refresh();
+ }
+ }
+
+ }
+
+ public void handleEvent(Event event) {
+ if( event.widget == addMappingButton)
+ handleAddMappingButton();
+ else if( event.widget == addReferenceButton)
+ handleAddReferenceButton();
+ else if( event.widget == removeButton )
+ handleRemoveSelectedButton();
+ }
+
+ protected void handleAddMappingButton() {
+ AddFolderDialog afd = new AddFolderDialog(addMappingButton.getShell(), project);
+ if( afd.open() == Window.OK) {
+ IContainer c = afd.getSelected();
+ if( c != null ) {
+ IPath p = c.getProjectRelativePath();
+ ComponentResourceProxy proxy = new ComponentResourceProxy(p, new Path("/"));
+ resourceMappings.add(proxy);
+ refresh();
+ }
+ }
+ }
+
+ protected void handleAddReferenceButton() {
+ NewReferenceWizard wizard = new NewReferenceWizard();
+ // fill the task model
+ wizard.getTaskModel().putObject(NewReferenceWizard.PROJECT, project);
+ wizard.getTaskModel().putObject(NewReferenceWizard.ROOT_COMPONENT, rootComponent);
+
+ WizardDialog wd = new WizardDialog(addReferenceButton.getShell(), wizard);
+ if( wd.open() != Window.CANCEL) {
+ Object c1 = wizard.getTaskModel().getObject(NewReferenceWizard.COMPONENT);
+ Object p1 = wizard.getTaskModel().getObject(NewReferenceWizard.COMPONENT_PATH);
+ IVirtualComponent[] compArr = c1 instanceof IVirtualComponent ?
+ new IVirtualComponent[] { (IVirtualComponent)c1 } :
+ (IVirtualComponent[])c1;
+ String[] pathArr = p1 instanceof String ?
+ new String[] { (String)p1 } :
+ (String[])p1;
+ for( int i = 0; i < compArr.length; i++ ) {
+ objectToRuntimePath.put(compArr[i], pathArr[i]);
+ }
+ refresh();
+ }
+ }
+
+ protected void handleRemoveSelectedButton() {
+ ISelection sel = availableComponentsViewer.getSelection();
+ if( sel instanceof IStructuredSelection ) {
+ Object o = ((IStructuredSelection)sel).getFirstElement();
+ if( o instanceof IVirtualComponent)
+ objectToRuntimePath.remove(o);
+ else if( o instanceof ComponentResourceProxy)
+ resourceMappings.remove(o);
+ refresh();
+ }
+ }
+
+ public TableViewer createAvailableComponentsViewer(Composite parent) {
+ int flags = SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI;
+
+ Table table = new Table(parent, flags);
+ availableComponentsViewer = new TableViewer(table);
+
+ // set up table layout
+ TableLayout tableLayout = new org.eclipse.jface.viewers.TableLayout();
+ tableLayout.addColumnData(new ColumnWeightData(400, true));
+ tableLayout.addColumnData(new ColumnWeightData(500, true));
+ table.setLayout(tableLayout);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+ availableComponentsViewer.setSorter(null);
+
+ TableColumn bndColumn = new TableColumn(table, SWT.NONE, 0);
+ bndColumn.setText(Messages.AddModuleDependenciesPropertiesPage_DeployPathColumn);
+ bndColumn.setResizable(true);
+
+ TableColumn projectColumn = new TableColumn(table, SWT.NONE, 1);
+ projectColumn.setText(Messages.AddModuleDependenciesPropertiesPage_SourceColumn);
+ projectColumn.setResizable(true);
+
+ tableLayout.layout(table, true);
+ return availableComponentsViewer;
+
+ }
+
+ protected boolean isPhysicallyAdded(VirtualArchiveComponent component) {
+ try {
+ component.getProjectRelativePath();
+ return true;
+ } catch (IllegalArgumentException e) {
+ return false;
+ }
+ }
+
+ /**
+ * This should only be called on changes, such as adding a project
+ * reference, adding a lib reference etc.
+ *
+ * It will reset the input, manually re-add missing elements, and do other
+ * tasks
+ */
+ public void refresh() {
+ resetTableUI();
+ if (!hasInitialized) {
+ initialize();
+ resetTableUI();
+ }
+
+ }
+
+ protected void resetTableUI() {
+ IWorkspaceRoot input = ResourcesPlugin.getWorkspace().getRoot();
+ availableComponentsViewer.setInput(input);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ int numlines = Math.min(10, availableComponentsViewer.getTable()
+ .getItemCount());
+ data.heightHint = availableComponentsViewer.getTable().getItemHeight()
+ * numlines;
+ availableComponentsViewer.getTable().setLayoutData(data);
+ GridData btndata = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.VERTICAL_ALIGN_BEGINNING);
+ buttonColumn.setLayoutData(btndata);
+ }
+
+ protected void initialize() {
+ IVirtualReference[] refs = rootComponent.getReferences();
+ IVirtualComponent comp;
+ for( int i = 0; i < refs.length; i++ ) {
+ comp = refs[i].getReferencedComponent();
+ String val = refs[i].getRuntimePath().append(refs[i].getArchiveName()).toString();
+ objectToRuntimePath.put(comp, val);
+ oldComponentToRuntimePath.put((IVirtualComponent) comp, val);
+ }
+
+ ComponentResource[] allMappings = findAllMappings();
+ for( int i = 0; i < allMappings.length; i++ ) {
+ resourceMappings.add(new ComponentResourceProxy(
+ allMappings[i].getSourcePath(), allMappings[i].getRuntimePath()
+ ));
+ }
+ hasInitialized = true;
+ }
+
+ protected ComponentResource[] findAllMappings() {
+ StructureEdit structureEdit = null;
+ try {
+ structureEdit = StructureEdit.getStructureEditForRead(project);
+ WorkbenchComponent component = structureEdit.getComponent();
+ Object[] arr = component.getResources().toArray();
+ ComponentResource[] result = new ComponentResource[arr.length];
+ for( int i = 0; i < arr.length; i++ )
+ result[i] = (ComponentResource)arr[i];
+ return result;
+ } catch(Exception e) {
+ } finally {
+ structureEdit.dispose();
+ }
+ return new ComponentResource[]{};
+ }
+
+ public class ComponentResourceProxy {
+ public IPath source, runtimePath;
+ public ComponentResourceProxy(IPath source, IPath runtimePath) {
+ this.source = source;
+ this.runtimePath = runtimePath;
+ }
+ }
+
+ /*
+ * Clean-up methods are below. These include performCancel, performDefaults,
+ * performOK, and any other methods that are called *only* by this one.
+ */
+ public void setVisible(boolean visible) {
+ }
+
+ public void performDefaults() {
+ }
+
+ public boolean performCancel() {
+ return true;
+ }
+
+ public void dispose() {
+ Table table = null;
+ if (availableComponentsViewer != null) {
+ table = availableComponentsViewer.getTable();
+ }
+ if (table == null || tableListener == null)
+ return;
+ table.removeListener(SWT.Dispose, tableListener);
+ table.removeListener(SWT.KeyDown, tableListener);
+ table.removeListener(SWT.MouseMove, tableListener);
+ table.removeListener(SWT.MouseHover, tableListener);
+ }
+
+
+
+ /*
+ * This is where the OK work goes. Lots of it. Watch your head.
+ * xiao xin
+ */
+ protected boolean preHandleChanges(IProgressMonitor monitor) {
+ return true;
+ }
+
+ protected boolean postHandleChanges(IProgressMonitor monitor) {
+ return true;
+ }
+
+ public boolean performOk() {
+ boolean result = true;
+ result &= saveResourceChanges();
+ result &= saveReferenceChanges();
+ return result;
+ }
+
+ protected boolean saveResourceChanges() {
+ removeAllResourceMappings();
+ addNewResourceMappings();
+ return true;
+ }
+ protected boolean addNewResourceMappings() {
+ ComponentResourceProxy[] proxies = (ComponentResourceProxy[]) resourceMappings.toArray(new ComponentResourceProxy[resourceMappings.size()]);
+ IVirtualFolder rootFolder = rootComponent.getRootFolder();
+ for( int i = 0; i < proxies.length; i++ ) {
+ try {
+ rootFolder.getFolder(proxies[i].runtimePath).createLink(proxies[i].source, 0, null);
+ } catch( CoreException ce ) {
+ }
+ }
+ resourceMappingsChanged = false;
+ return true;
+ }
+
+ protected boolean removeAllResourceMappings() {
+ StructureEdit moduleCore = null;
+ try {
+ moduleCore = StructureEdit.getStructureEditForWrite(project);
+ moduleCore.getComponent().getResources().clear();
+ }
+ finally {
+ if (moduleCore != null) {
+ moduleCore.saveIfNecessary(new NullProgressMonitor());
+ moduleCore.dispose();
+ }
+ }
+ return true;
+ }
+
+ protected boolean saveReferenceChanges() {
+ // Fill our delta lists
+ ArrayList<IVirtualComponent> added = new ArrayList<IVirtualComponent>();
+ ArrayList<IVirtualComponent> removed = new ArrayList<IVirtualComponent>();
+ ArrayList<IVirtualComponent> changed = new ArrayList<IVirtualComponent>();
+
+ Iterator<IVirtualComponent> j = oldComponentToRuntimePath.keySet().iterator();
+ Object key, val;
+ while (j.hasNext()) {
+ key = j.next();
+ val = oldComponentToRuntimePath.get(key);
+ if( !objectToRuntimePath.containsKey(key))
+ removed.add((IVirtualComponent)key);
+ else if (!val.equals(objectToRuntimePath.get(key)))
+ changed.add((IVirtualComponent)key);
+ }
+
+ j = objectToRuntimePath.keySet().iterator();
+ while (j.hasNext()) {
+ key = j.next();
+ if (!oldComponentToRuntimePath.containsKey(key))
+ added.add((IVirtualComponent)key);
+ }
+
+ NullProgressMonitor monitor = new NullProgressMonitor();
+ boolean subResult = preHandleChanges(monitor);
+ if( !subResult )
+ return false;
+
+ handleDeltas(removed, changed, added);
+ subResult &= postHandleChanges(monitor);
+
+ // Now update the variables
+ oldComponentToRuntimePath.clear();
+ ArrayList<IVirtualComponent> keys = new ArrayList<IVirtualComponent>();
+ keys.addAll(objectToRuntimePath.keySet());
+ Iterator<IVirtualComponent> i = keys.iterator();
+ while(i.hasNext()) {
+ IVirtualComponent vc = i.next();
+ String path = objectToRuntimePath.get(vc);
+ oldComponentToRuntimePath.put(vc, path);
+ }
+ return subResult;
+ }
+
+ // Subclass can override if it has a good way to handle changed elements
+ protected void handleDeltas(ArrayList<IVirtualComponent> removed,
+ ArrayList<IVirtualComponent> changed, ArrayList<IVirtualComponent> added) {
+ ArrayList<IVirtualComponent> removed2 = new ArrayList<IVirtualComponent>();
+ ArrayList<IVirtualComponent> added2 = new ArrayList<IVirtualComponent>();
+ removed2.addAll(removed);
+ removed2.addAll(changed);
+ added2.addAll(added);
+ added2.addAll(changed);
+
+ // meld the changed into the added / removed for less efficiency ;)
+ // basically we lack "change" operations and only have add / remove
+ handleRemoved(removed2);
+ handleAdded(added2);
+ }
+ protected void handleRemoved(ArrayList<IVirtualComponent> removed) {
+ // If it's removed it should *only* be a virtual component already
+ Iterator<IVirtualComponent> i = removed.iterator();
+ IVirtualComponent component;
+ while(i.hasNext()) {
+ try {
+ component = i.next();
+ IDataModelOperation operation = getRemoveComponentOperation(component);
+ operation.execute(null, null);
+ } catch( ExecutionException e) {
+ WTPOveridePlugin.logError(e);
+ }
+ }
+ }
+
+ protected IDataModelOperation getRemoveComponentOperation(IVirtualComponent component) {
+ String path, archiveName;
+ path = new Path(oldComponentToRuntimePath.get(component)).removeLastSegments(1).toString();
+ archiveName = new Path(oldComponentToRuntimePath.get(component)).lastSegment();
+
+ IDataModelProvider provider = getRemoveReferenceDataModelProvider(component);
+ IDataModel model = DataModelFactory.createDataModel(provider);
+ model.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, rootComponent);
+ List<IVirtualComponent> modHandlesList = (List<IVirtualComponent>) model.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST);
+ modHandlesList.add(component);
+ model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, modHandlesList);
+ model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH, path);
+ Map<IVirtualComponent, String> uriMap = new HashMap<IVirtualComponent, String>();
+ uriMap.put(component, archiveName);
+ model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, uriMap);
+ return model.getDefaultOperation();
+ }
+
+ protected IDataModelProvider getRemoveReferenceDataModelProvider(IVirtualComponent component) {
+ return new RemoveReferenceComponentsDataModelProvider();
+ }
+
+
+ protected void handleChanged(ArrayList<IVirtualComponent> changed) {
+ Iterator<IVirtualComponent> i = changed.iterator();
+ IVirtualComponent component;
+ IVirtualReference ref;
+ IPath p;
+ while(i.hasNext()) {
+ component = i.next();
+ ref = rootComponent.getReference(component.getName());
+ p = new Path(objectToRuntimePath.get(component));
+ ref.setRuntimePath(p);
+ }
+ }
+
+ protected void handleAdded(ArrayList<IVirtualComponent> added) {
+ final ArrayList<IVirtualComponent> components = new ArrayList<IVirtualComponent>();
+ Iterator<IVirtualComponent> i = added.iterator();
+ IVirtualComponent o;
+ while(i.hasNext()) {
+ o = i.next();
+ components.add((IVirtualComponent)o);
+ }
+
+ IWorkspaceRunnable runnable = new IWorkspaceRunnable(){
+ public void run(IProgressMonitor monitor) throws CoreException{
+ addComponents(components);
+ }
+ };
+ try {
+ ResourcesPlugin.getWorkspace().run(runnable, new NullProgressMonitor());
+ } catch( CoreException e ) {
+ WTPOveridePlugin.logError(e);
+ }
+ }
+
+ protected void addComponents(ArrayList<IVirtualComponent> components) throws CoreException {
+ Iterator<IVirtualComponent> i = components.iterator();
+ while(i.hasNext()) {
+ addOneComponent(i.next());
+ }
+ }
+
+ protected IDataModelProvider getAddReferenceDataModelProvider(IVirtualComponent component) {
+ return new CreateReferenceComponentsDataModelProvider();
+ }
+
+ protected void addOneComponent(IVirtualComponent component) throws CoreException {
+ String path, archiveName;
+ path = new Path(objectToRuntimePath.get(component)).removeLastSegments(1).toString();
+ archiveName = new Path(objectToRuntimePath.get(component)).lastSegment();
+
+ IDataModelProvider provider = getAddReferenceDataModelProvider(component);
+ IDataModel dm = DataModelFactory.createDataModel(provider);
+
+ dm.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, rootComponent);
+ dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, Arrays.asList(component));
+
+ //[Bug 238264] the uri map needs to be manually set correctly
+ Map<IVirtualComponent, String> uriMap = new HashMap<IVirtualComponent, String>();
+ uriMap.put(component, archiveName);
+ dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, uriMap);
+ dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH, path);
+
+ IStatus stat = dm.validateProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST);
+ if (stat != OK_STATUS)
+ throw new CoreException(stat);
+ try {
+ dm.getDefaultOperation().execute(new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ WTPOveridePlugin.logError(e);
+ }
+ }
+ /**
+ * Method returns the name of the given IVirtualComponent being sure the correct extension
+ * is on the end of the name, this is important for internal projects. Added for [Bug 241509]
+ *
+ * Note (rs) : I do not believe this ever gets called with a binary virtComp
+ *
+ * @param virtComp the IVirtualComponent to get the name of with the correct extension
+ * @return the name of the given IVirtualComponent with the correct extension
+ */
+ protected String getVirtualComponentNameWithExtension(IVirtualComponent virtComp) {
+ String virtCompURIMapName = this.getURIMappingName(virtComp);
+ String extension = ComponentUtils.getDefaultProjectExtension(virtComp);
+ virtCompURIMapName += extension;
+ return virtCompURIMapName;
+ }
+
+ /**
+ * [Bug 238264]
+ * determines a unique URI mapping name for a given component
+ * this is in case two components have the same name.
+ *
+ * @return returns a valid (none duplicate) uri mapping name for the given component\
+ */
+ private String getURIMappingName(IVirtualComponent archive) {
+
+ //get the default uri map name for the given archive
+ IPath componentPath = Path.fromOSString(archive.getName());
+ String uriMapName = componentPath.lastSegment().replace(' ', '_');
+
+
+ //check to be sure this uri mapping is not already in use by another reference
+ boolean dupeArchiveName;
+ String refedCompName;
+ int lastDotIndex;
+ String increment;
+ IVirtualReference [] existingRefs = rootComponent.getReferences();
+ for(int i=0;i<existingRefs.length;i++){
+ refedCompName = existingRefs[i].getReferencedComponent().getName();
+
+ //if uri mapping names of the refed component and the given archive are the same
+ // find a new uri map name for the given archive
+ if(existingRefs[i].getArchiveName().equals(uriMapName)){
+ dupeArchiveName = true;
+ //find a new uriMapName for the given component
+ for(int j=1; dupeArchiveName; j++){
+ lastDotIndex = uriMapName.lastIndexOf('.');
+ increment = "_"+j; //$NON-NLS-1$
+
+ //create the new potential name
+ if(lastDotIndex != -1){
+ uriMapName = uriMapName.substring(0, lastDotIndex) + increment + uriMapName.substring(lastDotIndex);
+ } else {
+ uriMapName = uriMapName.substring(0)+increment;
+ }
+
+ //determine if the new potential name is valid
+ for(int k=0; k<existingRefs.length; k++) {
+ dupeArchiveName = existingRefs[k].getArchiveName().equals(uriMapName);
+ if(dupeArchiveName) {
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return uriMapName;
+ }
+}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ComponentDependencyContentProvider.java (from rev 16825, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ComponentDependencyContentProvider.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ComponentDependencyContentProvider.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ComponentDependencyContentProvider.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 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
+ * Stefan Dimov, stefan.dimov(a)sap.com - bug 207826
+ *******************************************************************************/
+package org.eclipse.wst.common.componentcore.ui.propertypage;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.common.componentcore.internal.ComponentResource;
+import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.ui.propertypage.AddModuleDependenciesPropertiesPage.ComponentResourceProxy;
+
+
+/*
+ * The only valid elements this content provider (should) provide
+ * are IProject or IVirtualComponent objects. The runtime paths portion is
+ * shared with the preference page itself where they can both modify the data.
+ *
+ * This provider no longer "meddles" in to the content as it used to,
+ * but rather serves as only a view of it.
+ */
+public class ComponentDependencyContentProvider extends LabelProvider implements IStructuredContentProvider, ITableLabelProvider {
+
+ final static String PATH_SEPARATOR = String.valueOf(IPath.SEPARATOR);
+
+ private HashMap<IVirtualComponent, String> runtimePaths;
+ private ArrayList<ComponentResourceProxy> resourceMappings;
+ public ComponentDependencyContentProvider() {
+ super();
+ }
+
+ public void setRuntimePaths(HashMap<IVirtualComponent, String> paths) {
+ this.runtimePaths = paths;
+ }
+
+ public void setResourceMappings(ArrayList<ComponentResourceProxy> mappings) {
+ this.resourceMappings = mappings;
+ }
+
+ public Object[] getElements(Object inputElement) {
+ Object[] empty = new Object[0];
+ if( !(inputElement instanceof IWorkspaceRoot))
+ return empty;
+ ArrayList<Object> list = new ArrayList<Object>();
+ list.addAll(resourceMappings);
+ list.addAll(runtimePaths.keySet());
+ return list.toArray();
+ }
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ if( element instanceof ComponentResourceProxy) {
+ if( columnIndex == 0 )
+ return ((ComponentResourceProxy)element).runtimePath.toString();
+ else if( columnIndex == 1 )
+ return ((ComponentResourceProxy)element).source.toString();
+ }
+ if (element instanceof IVirtualComponent) {
+ IVirtualComponent comp = (IVirtualComponent)element;
+ if (columnIndex == 0) {
+ if( runtimePaths == null || runtimePaths.get(element) == null) {
+ return new Path(PATH_SEPARATOR).toString();
+ }
+ return runtimePaths.get(element);
+ } else if (columnIndex == 1) {
+ if( comp.isBinary() && comp instanceof VirtualArchiveComponent) {
+ IPath p = ((VirtualArchiveComponent)comp).getWorkspaceRelativePath();
+ if( p == null )
+ p = new Path(((VirtualArchiveComponent)comp).getUnderlyingDiskFile().getAbsolutePath());
+ return p.toString();
+ }
+ return comp.getProject().getName();
+ }
+ } else if (element instanceof IProject){
+ if (columnIndex == 0) {
+ if( runtimePaths == null || runtimePaths.get(element) == null) {
+ return new Path(PATH_SEPARATOR).toString();
+ }
+ return runtimePaths.get(element);
+ } else {
+ return ((IProject)element).getName();
+ }
+ }
+ return null;
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/DependencyPageExtensionManager.java (from rev 16825, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/DependencyPageExtensionManager.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/DependencyPageExtensionManager.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/DependencyPageExtensionManager.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -0,0 +1,108 @@
+package org.eclipse.wst.common.componentcore.ui.propertypage;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.server.ui.wizard.WizardFragment;
+import org.eclipse.wst.common.componentcore.ui.WTPOveridePlugin;
+
+public class DependencyPageExtensionManager {
+ private static DependencyPageExtensionManager manager = null;
+ public static DependencyPageExtensionManager getManager() {
+ if( manager == null )
+ manager = new DependencyPageExtensionManager();
+ return manager;
+ }
+
+ private HashMap<String, IDependencyPageProvider> providers = null;
+
+ public IDependencyPageProvider getProvider(IFacetedProject project) {
+ if( providers == null )
+ loadProviders();
+ Iterator<IDependencyPageProvider> i = providers.values().iterator();
+ IDependencyPageProvider temp;
+ while(i.hasNext()) {
+ temp = i.next();
+ if( temp.canHandle(project))
+ return temp;
+ }
+ return null;
+ }
+
+ private void loadProviders() {
+ HashMap<String, IDependencyPageProvider> temp = new HashMap<String, IDependencyPageProvider>();
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IConfigurationElement[] cf = registry.getConfigurationElementsFor(
+ WTPOveridePlugin.PLUGIN_ID, "moduleDependencyPropertyPage"); //$NON-NLS-1$
+ for( int i = 0; i < cf.length; i++ ) {
+ try {
+ temp.put(cf[i].getAttribute("id"), //$NON-NLS-1$
+ (IDependencyPageProvider)cf[i].createExecutableExtension("class")); //$NON-NLS-1$
+ } catch( CoreException ce ) {}
+ }
+ providers = temp;
+ }
+
+ public WizardFragment loadReferenceWizardFragment(String id) {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IConfigurationElement[] cf = registry.getConfigurationElementsFor(
+ WTPOveridePlugin.PLUGIN_ID, "referenceWizardFragment"); //$NON-NLS-1$
+ for( int i = 0; i < cf.length; i++ ) {
+ if( cf[i].getAttribute("id").equals(id))
+ try {
+ return (WizardFragment)cf[i].createExecutableExtension("class");
+ } catch( CoreException ce) {}
+ }
+ return null;
+ }
+
+ public ReferenceExtension[] getReferenceExtensions() {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IConfigurationElement[] cf = registry.getConfigurationElementsFor(
+ WTPOveridePlugin.PLUGIN_ID, "referenceWizardFragment"); //$NON-NLS-1$
+ ArrayList<ReferenceExtension> list = new ArrayList<ReferenceExtension>();
+ for( int i = 0; i < cf.length; i++ ) {
+ list.add(new ReferenceExtension(cf[i]));
+ }
+ return (ReferenceExtension[]) list
+ .toArray(new ReferenceExtension[list.size()]);
+ }
+
+ public class ReferenceExtension {
+ private IConfigurationElement element;
+ private String id, name, imageLoc;
+ private Image image;
+ public ReferenceExtension(IConfigurationElement element) {
+ this.element = element;
+ this.id = element.getAttribute("id");
+ this.name = element.getAttribute("name");
+ this.imageLoc = element.getAttribute("icon");
+ }
+ public String getId() { return this.id;}
+ public String getName() { return this.name; }
+ public Image getImage() {
+ if( image == null ) {
+ if( imageLoc != null && element.getContributor().getName() != null) {
+ ImageDescriptor desc = AbstractUIPlugin.imageDescriptorFromPlugin(element.getContributor().getName(), imageLoc);
+ image = desc.createImage();
+ }
+ }
+ return image;
+ }
+ public void disposeImage() {
+ if( image != null ) {
+ image.dispose();
+ image = null;
+ }
+ }
+ }
+}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ExternalJarReferenceWizardFragment.java (from rev 16825, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ExternalJarReferenceWizardFragment.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ExternalJarReferenceWizardFragment.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ExternalJarReferenceWizardFragment.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -0,0 +1,78 @@
+package org.eclipse.wst.common.componentcore.ui.propertypage;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jst.j2ee.project.facet.IJavaProjectMigrationDataModelProperties;
+import org.eclipse.jst.j2ee.project.facet.JavaProjectMigrationDataModelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.ModuleCoreNature;
+import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.server.ui.wizard.IWizardHandle;
+import org.eclipse.wst.server.ui.wizard.WizardFragment;
+import org.jboss.ide.eclipse.as.wtp.override.core.vcf.ComponentUtils;
+
+public class ExternalJarReferenceWizardFragment extends JarReferenceWizardFragment {
+ public Composite createComposite(Composite parent, IWizardHandle handle) {
+ Composite c = super.createComposite(parent, handle);
+ handle.setTitle("Add an External Jar Reference");
+ handle.setDescription("Here you can reference a filesystem Jar\n"
+ + "This is not a suggested use-case, but is here for backwards compatability.");
+ return c;
+ }
+
+ protected void buttonPressed() {
+ selected = BuildPathDialogAccess
+ .chooseExternalJAREntries(browse.getShell());
+ viewer.refresh();
+ }
+
+ public void performFinish(IProgressMonitor monitor) throws CoreException {
+ IVirtualComponent rootComponent = (IVirtualComponent)getTaskModel().getObject(NewReferenceWizard.ROOT_COMPONENT);
+ if (selected != null && selected.length > 0) {
+ ArrayList<IVirtualComponent> compList = new ArrayList<IVirtualComponent>();
+ ArrayList<String> paths = new ArrayList<String>();
+ for (int i = 0; i < selected.length; i++) {
+ // IPath fullPath = project.getFile(selected[i]).getFullPath();
+ String type = VirtualArchiveComponent.LIBARCHIVETYPE
+ + IPath.SEPARATOR;
+ IVirtualComponent archive = ComponentCore
+ .createArchiveComponent(rootComponent.getProject(),
+ type + selected[i].toString());
+ compList.add(archive);
+ paths.add(selected[i].lastSegment());
+ }
+ IVirtualComponent[] components = (IVirtualComponent[]) compList.toArray(new IVirtualComponent[compList.size()]);
+ String[] paths2 = (String[]) paths.toArray(new String[paths.size()]);
+ getTaskModel().putObject(NewReferenceWizard.COMPONENT, components);
+ getTaskModel().putObject(NewReferenceWizard.COMPONENT_PATH, paths2);
+ }
+ }
+}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/IDependencyPageProvider.java (from rev 16825, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/IDependencyPageProvider.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/IDependencyPageProvider.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/IDependencyPageProvider.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -0,0 +1,10 @@
+package org.eclipse.wst.common.componentcore.ui.propertypage;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+
+public interface IDependencyPageProvider {
+ public boolean canHandle(IFacetedProject project);
+ public IModuleDependenciesControl[] createPages(IFacetedProject project, ModuleAssemblyRootPage parent);
+ public Composite createRootControl(IModuleDependenciesControl[] pages, Composite parent);
+}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/IModuleDependenciesControl.java (from rev 16825, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/IModuleDependenciesControl.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/IModuleDependenciesControl.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/IModuleDependenciesControl.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -0,0 +1,42 @@
+package org.eclipse.wst.common.componentcore.ui.propertypage;
+
+import org.eclipse.swt.widgets.Composite;
+
+public interface IModuleDependenciesControl {
+ /**
+ * Creates the Composite associated with this control.
+ * @param parent Parent Composite.
+ * @return Composite for the control.
+ */
+ Composite createContents(Composite parent);
+
+ /**
+ * Called when the property page's <code>performOk()</code> method is called.
+ * @return
+ */
+ boolean performOk();
+
+ /**
+ * Called when the property page's <code>performDefaults()</code> method is called.
+ * @return
+ */
+ void performDefaults();
+
+ /**
+ * Called when the property page's <code>performCancel()</code> method is called.
+ * @return
+ */
+ boolean performCancel();
+
+ /**
+ * Called when the property page's <code>setVisible()</code> method is called.
+ * @return
+ */
+ void setVisible(boolean visible);
+
+ /**
+ * Called when the property page's <code>dispose()</code> method is called.
+ * @return
+ */
+ void dispose();
+}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/JarReferenceWizardFragment.java (from rev 16825, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/JarReferenceWizardFragment.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/JarReferenceWizardFragment.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/JarReferenceWizardFragment.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -0,0 +1,161 @@
+package org.eclipse.wst.common.componentcore.ui.propertypage;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jst.j2ee.project.facet.IJavaProjectMigrationDataModelProperties;
+import org.eclipse.jst.j2ee.project.facet.JavaProjectMigrationDataModelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.ModuleCoreNature;
+import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.server.ui.wizard.IWizardHandle;
+import org.eclipse.wst.server.ui.wizard.WizardFragment;
+import org.jboss.ide.eclipse.as.wtp.override.core.vcf.ComponentUtils;
+
+public class JarReferenceWizardFragment extends WizardFragment {
+ protected LabelProvider labelProvider = null;
+ protected ITreeContentProvider contentProvider = null;
+ protected TreeViewer viewer;
+ protected Button browse;
+ protected IPath[] paths;
+ protected IWizardHandle handle;
+ protected IPath[] selected = new IPath[]{};
+ public boolean hasComposite() {
+ return true;
+ }
+
+ public Composite createComposite(Composite parent, IWizardHandle handle) {
+ this.handle = handle;
+ handle.setTitle("Add a Jar Reference");
+ handle.setDescription("Here you can reference a workspace Jar\n"
+ + "This is not a suggested use-case, but is here for backwards compatability.");
+
+ Composite c = new Composite(parent, SWT.NONE);
+ c.setLayout(new FormLayout());
+ viewer = new TreeViewer(c, SWT.SINGLE | SWT.BORDER);
+ viewer.setContentProvider(getContentProvider());
+ viewer.setLabelProvider(getLabelProvider());
+ viewer.setInput(ResourcesPlugin.getWorkspace());
+
+ browse = new Button(c, SWT.NONE);
+ browse.setText("Browse...");
+ FormData fd = new FormData();
+ fd.left = new FormAttachment(0, 5);
+ fd.bottom = new FormAttachment(100, -5);
+ browse.setLayoutData(fd);
+
+ fd = new FormData();
+ fd.left = new FormAttachment(0, 5);
+ fd.top = new FormAttachment(0, 5);
+ fd.right = new FormAttachment(100, -5);
+ fd.bottom = new FormAttachment(browse, -5);
+ viewer.getTree().setLayoutData(fd);
+
+ browse.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ buttonPressed();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ });
+ return c;
+ }
+
+ protected void buttonPressed() {
+ IProject project = (IProject)getTaskModel().getObject(NewReferenceWizard.PROJECT);
+ selected = BuildPathDialogAccess.chooseJAREntries(
+ browse.getShell(),
+ project.getLocation(), new IPath[0]);
+ viewer.refresh();
+ }
+
+ public void performFinish(IProgressMonitor monitor) throws CoreException {
+ IVirtualComponent rootComponent = (IVirtualComponent)getTaskModel().getObject(NewReferenceWizard.ROOT_COMPONENT);
+ if (selected != null && selected.length > 0) {
+ ArrayList<IVirtualComponent> compList = new ArrayList<IVirtualComponent>();
+ ArrayList<String> paths = new ArrayList<String>();
+ for (int i = 0; i < selected.length; i++) {
+ // IPath fullPath = project.getFile(selected[i]).getFullPath();
+ String type = VirtualArchiveComponent.LIBARCHIVETYPE
+ + IPath.SEPARATOR;
+ IVirtualComponent archive = ComponentCore
+ .createArchiveComponent(rootComponent.getProject(),
+ type + selected[i].makeRelative().toString());
+ compList.add(archive);
+ paths.add(selected[i].lastSegment());
+ }
+ IVirtualComponent[] components = (IVirtualComponent[]) compList.toArray(new IVirtualComponent[compList.size()]);
+ String[] paths2 = (String[]) paths.toArray(new String[paths.size()]);
+ getTaskModel().putObject(NewReferenceWizard.COMPONENT, components);
+ getTaskModel().putObject(NewReferenceWizard.COMPONENT_PATH, paths2);
+ }
+ }
+
+ protected LabelProvider getLabelProvider() {
+ if (labelProvider == null) {
+ labelProvider = new LabelProvider() {
+ public Image getImage(Object element) {
+ return null;
+ }
+
+ public String getText(Object element) {
+ return element == null ? "" : element.toString();//$NON-NLS-1$
+ }
+ };
+ }
+ return labelProvider;
+ }
+
+ protected ITreeContentProvider getContentProvider() {
+ if (contentProvider == null) {
+ contentProvider = new ITreeContentProvider() {
+ public Object[] getElements(Object inputElement) {
+ return selected == null ? new Object[]{} : selected;
+ }
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ public void dispose() {
+ }
+ public boolean hasChildren(Object element) {
+ return false;
+ }
+ public Object getParent(Object element) {
+ return null;
+ }
+ public Object[] getChildren(Object parentElement) {
+ return null;
+ }
+ };
+ }
+ return contentProvider;
+ }
+}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ModuleAssemblyRootPage.java (from rev 16825, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ModuleAssemblyRootPage.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ModuleAssemblyRootPage.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ModuleAssemblyRootPage.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -0,0 +1,175 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 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 implementation as prop page heirarchy
+ * rfrost(a)bea.com - conversion to single property page impl
+ *******************************************************************************/
+
+package org.eclipse.wst.common.componentcore.ui.propertypage;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.PropertyPage;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+
+/**
+ * Primary project property page for Module dependencies;
+ */
+public class ModuleAssemblyRootPage extends PropertyPage {
+
+ private IProject project;
+ private IModuleDependenciesControl[] controls = new IModuleDependenciesControl[0];
+
+ public ModuleAssemblyRootPage() {
+ super();
+ }
+
+ private Composite getFacetErrorComposite(final Composite parent) {
+ final String errorCheckingFacet = "Error Checking Project Facets";
+ setErrorMessage(errorCheckingFacet);
+ return getErrorComposite(parent, errorCheckingFacet);
+ }
+ private Composite getVirtCompErrorComposite(final Composite parent) {
+ final String errorCheckingFacet = "The given project is not a virtual component project";
+ setErrorMessage(errorCheckingFacet);
+ return getErrorComposite(parent, errorCheckingFacet);
+ }
+
+
+ private Composite getErrorComposite(final Composite parent, final String error) {
+ final Composite composite = new Composite(parent, SWT.NONE);
+ final GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ final Label label= new Label(composite, SWT.NONE);
+ label.setText(error);
+ return composite;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.IPreferencePage#performOk()
+ */
+ public boolean performOk() {
+ for (int i = 0; i < controls.length; i++) {
+ if (controls[i] != null) {
+ if (!controls[i].performOk()) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
+ */
+ public void performDefaults() {
+ for (int i = 0; i < controls.length; i++) {
+ if (controls[i] != null) {
+ controls[i].performDefaults();
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.IPreferencePage#performCancel()
+ */
+ public boolean performCancel() {
+ for (int i = 0; i < controls.length; i++) {
+ if (controls[i] != null) {
+ if (!controls[i].performCancel()) {
+ return false;
+ }
+ }
+ }
+ return super.performCancel();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
+ */
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ for (int i = 0; i < controls.length; i++) {
+ if (controls[i] != null) {
+ controls[i].setVisible(visible);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#dispose()
+ */
+ public void dispose() {
+ super.dispose();
+ for (int i = 0; i < controls.length; i++) {
+ if(controls[i] != null){
+ controls[i].dispose();
+ }
+ }
+ }
+
+ protected static void createDescriptionComposite(final Composite parent, final String description) {
+ Composite descriptionComp = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ descriptionComp.setLayout(layout);
+ descriptionComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ fillDescription(descriptionComp, description);
+ }
+
+ private static void fillDescription(Composite c, String s) {
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = 250;
+ Text text = new Text(c, SWT.READ_ONLY | SWT.WRAP);
+ text.setLayoutData(data);
+ text.setText(s);
+ }
+
+ protected Control createContents(Composite parent) {
+
+ // Need to find out what type of project we are handling
+ project = (IProject) getElement().getAdapter(IResource.class);
+ if( project != null ) {
+ try {
+ IFacetedProject facetedProject = ProjectFacetsManager.create(project);
+ IDependencyPageProvider provider = null;
+ if( facetedProject == null )
+ return getFacetErrorComposite(parent);
+
+ provider = DependencyPageExtensionManager.getManager().getProvider(facetedProject);
+ if( provider != null ) {
+ controls = provider.createPages(facetedProject, this);
+ return provider.createRootControl(controls, parent);
+ }
+
+ if( ComponentCore.createComponent(project) == null )
+ return getVirtCompErrorComposite(parent);
+
+ AddModuleDependenciesPropertiesPage page = new AddModuleDependenciesPropertiesPage(project, this);
+ controls = new IModuleDependenciesControl[1];
+ controls[0] = page;
+ return page.createContents(parent);
+ } catch( CoreException ce ) {
+ }
+ }
+ return getFacetErrorComposite(parent);
+ }
+}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/NewReferenceRootWizardFragment.java (from rev 16825, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/NewReferenceRootWizardFragment.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/NewReferenceRootWizardFragment.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/NewReferenceRootWizardFragment.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -0,0 +1,148 @@
+package org.eclipse.wst.common.componentcore.ui.propertypage;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.wst.server.ui.wizard.IWizardHandle;
+import org.eclipse.wst.server.ui.wizard.WizardFragment;
+import org.eclipse.wst.common.componentcore.ui.propertypage.DependencyPageExtensionManager.ReferenceExtension;
+
+public class NewReferenceRootWizardFragment extends WizardFragment {
+ protected Map<String, WizardFragment> fragmentMap =
+ new HashMap<String, WizardFragment>();
+ private IWizardHandle wizard;
+ private TreeViewer viewer;
+ public boolean hasComposite() {
+ return true;
+ }
+
+ public Composite createComposite(Composite parent, IWizardHandle wizard) {
+ this.wizard = wizard;
+ wizard.setTitle("Select a reference type");
+ wizard.setDescription("Here you can select one of many types of references to add");
+ Composite c = new Composite(parent, SWT.NONE);
+ c.setLayout(new FillLayout());
+ viewer = new TreeViewer(c, SWT.SINGLE | SWT.BORDER);
+ viewer.setLabelProvider(getLabelProvider());
+ viewer.setContentProvider(getContentProvider());
+ viewer.setInput(ResourcesPlugin.getWorkspace());
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ viewerSelectionChanged();
+ }
+ });
+ return c;
+ }
+
+ protected void viewerSelectionChanged() {
+ wizard.update();
+ }
+
+ protected WizardFragment getWizardFragment(String extensionPointID) {
+ try {
+ WizardFragment fragment = fragmentMap.get(extensionPointID);
+ if (fragment != null)
+ return fragment;
+ } catch (Exception e) {
+ // ignore
+ }
+
+ WizardFragment fragment = DependencyPageExtensionManager.getManager().loadReferenceWizardFragment(extensionPointID);
+ if (fragment != null)
+ fragmentMap.put(extensionPointID, fragment);
+ return fragment;
+ }
+
+ public List getChildFragments() {
+ List<WizardFragment> listImpl = new ArrayList<WizardFragment>();
+ createChildFragments(listImpl);
+ return listImpl;
+ }
+
+ protected void createChildFragments(List<WizardFragment> list) {
+ // Instantiate and add the fragment for the current ID
+ if( viewer != null ) {
+ IStructuredSelection sel = (IStructuredSelection)viewer.getSelection();
+ ReferenceExtension selected = (ReferenceExtension)sel.getFirstElement();
+ if( selected != null ) {
+ WizardFragment child = getWizardFragment(selected.getId());
+ if( child != null )
+ list.add(child);
+ }
+ }
+ }
+
+ public boolean isComplete() {
+ return true;
+ }
+
+
+ private LabelProvider labelProvider = null;
+ private ITreeContentProvider contentProvider = null;
+ protected LabelProvider getLabelProvider() {
+ if( labelProvider == null ) {
+ labelProvider = new LabelProvider() {
+ public Image getImage(Object element) {
+ if( element instanceof ReferenceExtension)
+ return ((ReferenceExtension)element).getImage();
+ return null;
+ }
+ public String getText(Object element) {
+ if( element instanceof ReferenceExtension)
+ return ((ReferenceExtension)element).getName();
+ return element == null ? "" : element.toString();//$NON-NLS-1$
+ }
+ public void dispose() {
+ super.dispose();
+ if( extensions != null ) {
+ for( int i = 0; i < extensions.length; i++) {
+ extensions[i].disposeImage();
+ }
+ }
+ }
+ };
+ }
+ return labelProvider;
+ }
+
+ private ReferenceExtension[] extensions = null;
+ protected ITreeContentProvider getContentProvider() {
+ if( contentProvider == null ) {
+ contentProvider = new ITreeContentProvider() {
+ public Object[] getElements(Object inputElement) {
+ if( extensions == null )
+ extensions = DependencyPageExtensionManager.getManager().getReferenceExtensions();
+ return extensions;
+ }
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ public void dispose() {
+ }
+ public boolean hasChildren(Object element) {
+ return false;
+ }
+ public Object getParent(Object element) {
+ return null;
+ }
+ public Object[] getChildren(Object parentElement) {
+ return null;
+ }
+ };
+ }
+ return contentProvider;
+ }
+}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/NewReferenceWizard.java (from rev 16825, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/NewReferenceWizard.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/NewReferenceWizard.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/NewReferenceWizard.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -0,0 +1,28 @@
+package org.eclipse.wst.common.componentcore.ui.propertypage;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.wst.server.ui.internal.wizard.TaskWizard;
+import org.eclipse.wst.server.ui.wizard.WizardFragment;
+
+public class NewReferenceWizard extends TaskWizard {
+
+ public static final String COMPONENT = "dependency.component";
+ public static final String COMPONENT_PATH = "dependency.component.path";
+ public static final String PROJECT = "root.project";
+ public static final String ROOT_COMPONENT = "root.component";
+
+ public NewReferenceWizard() {
+ super("New Reference Wizard", new WizardFragment() {
+ protected void createChildFragments(List<WizardFragment> list) {
+ list.add(new NewReferenceRootWizardFragment());
+ }
+ });
+ }
+
+ public void init(IWorkbench newWorkbench, IStructuredSelection newSelection) {
+ // do nothing
+ }
+}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ProjectReferenceWizardFragment.java (from rev 16825, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ProjectReferenceWizardFragment.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ProjectReferenceWizardFragment.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/ProjectReferenceWizardFragment.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -0,0 +1,145 @@
+package org.eclipse.wst.common.componentcore.ui.propertypage;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jst.j2ee.project.facet.IJavaProjectMigrationDataModelProperties;
+import org.eclipse.jst.j2ee.project.facet.JavaProjectMigrationDataModelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.ModuleCoreNature;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.server.ui.wizard.IWizardHandle;
+import org.eclipse.wst.server.ui.wizard.WizardFragment;
+import org.jboss.ide.eclipse.as.wtp.override.core.vcf.ComponentUtils;
+
+public class ProjectReferenceWizardFragment extends WizardFragment {
+ private LabelProvider labelProvider = null;
+ private ITreeContentProvider contentProvider = null;
+ private TreeViewer viewer;
+ private IProject selected;
+
+ public boolean hasComposite() {
+ return true;
+ }
+
+ public Composite createComposite(Composite parent, IWizardHandle handle) {
+ handle.setTitle("Add a Project Reference");
+ handle.setDescription("Here you can make a project into a reference.\n" +
+ "If the project is not already a flexible project, it will be converted into one.");
+
+ Composite c = new Composite(parent, SWT.NONE);
+ c.setLayout(new FillLayout());
+ viewer = new TreeViewer(c, SWT.SINGLE | SWT.BORDER);
+ viewer.setContentProvider(getContentProvider());
+ viewer.setLabelProvider(getLabelProvider());
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ selChanged();
+ }
+ });
+ viewer.setInput(ResourcesPlugin.getWorkspace());
+ return c;
+ }
+
+ private void selChanged() {
+ if( viewer != null ) {
+ IStructuredSelection sel = (IStructuredSelection)viewer.getSelection();
+ if( sel != null )
+ selected = (IProject)sel.getFirstElement();
+ }
+ }
+
+ public void performFinish(IProgressMonitor monitor) throws CoreException {
+ if( !ModuleCoreNature.isFlexibleProject(selected)) {
+ try {
+ IDataModel migrationdm = DataModelFactory.createDataModel(new JavaProjectMigrationDataModelProvider());
+ migrationdm.setProperty(IJavaProjectMigrationDataModelProperties.PROJECT_NAME, selected.getName());
+ migrationdm.getDefaultOperation().execute(new NullProgressMonitor(), null);
+ } catch( ExecutionException ee) {
+ // TODO something
+ }
+ }
+ IVirtualComponent comp = ComponentCore.createComponent(selected);
+ String path = selected.getName();
+ String extension = ComponentUtils.getDefaultProjectExtension(comp);
+ path += extension;
+
+ getTaskModel().putObject(NewReferenceWizard.COMPONENT, comp);
+ getTaskModel().putObject(NewReferenceWizard.COMPONENT_PATH, path);
+ }
+
+
+ protected LabelProvider getLabelProvider() {
+ if( labelProvider == null ) {
+ labelProvider = new LabelProvider() {
+ public Image getImage(Object element) {
+ return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_PROJECT);
+ }
+ public String getText(Object element) {
+ if( element instanceof IProject )
+ return ((IProject)element).getName();
+ return element == null ? "" : element.toString();//$NON-NLS-1$
+ }
+ };
+ }
+ return labelProvider;
+ }
+
+ protected ITreeContentProvider getContentProvider() {
+ if( contentProvider == null ) {
+ contentProvider = new ITreeContentProvider() {
+ public Object[] getElements(Object inputElement) {
+ IProject root = (IProject)getTaskModel().getObject(NewReferenceWizard.PROJECT);
+ IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ ArrayList<IProject> list = new ArrayList<IProject>(Arrays.asList(projects));
+ Iterator<IProject> i = list.iterator();
+ IProject p;
+ while(i.hasNext()) {
+ p = i.next();
+ if( !p.isOpen())
+ i.remove();
+ else if( p.equals(root))
+ i.remove();
+ }
+ return (IProject[]) list.toArray(new IProject[list.size()]);
+ }
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ public void dispose() {
+ }
+ public boolean hasChildren(Object element) {
+ return false;
+ }
+ public Object getParent(Object element) {
+ return null;
+ }
+ public Object[] getChildren(Object parentElement) {
+ return null;
+ }
+ };
+ }
+ return contentProvider;
+ }
+}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/VariableReferenceWizardFragment.java (from rev 16825, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/VariableReferenceWizardFragment.java)
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/VariableReferenceWizardFragment.java (rev 0)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/VariableReferenceWizardFragment.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -0,0 +1,56 @@
+package org.eclipse.wst.common.componentcore.ui.propertypage;
+
+import java.util.ArrayList;
+
+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.jdt.core.JavaCore;
+import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.server.ui.wizard.IWizardHandle;
+
+public class VariableReferenceWizardFragment extends JarReferenceWizardFragment {
+ public Composite createComposite(Composite parent, IWizardHandle handle) {
+ Composite c = super.createComposite(parent, handle);
+ handle.setTitle("Add a Variable Reference");
+ handle.setDescription("Here you can reference a variable which maps to a single jar.\n"
+ + "This is not a suggested use-case, but is here for backwards compatability.");
+ return c;
+ }
+
+ protected void buttonPressed() {
+ selected = BuildPathDialogAccess.chooseVariableEntries(
+ browse.getShell(), new Path[0]);
+ viewer.refresh();
+ }
+
+ public void performFinish(IProgressMonitor monitor) throws CoreException {
+ IVirtualComponent rootComponent = (IVirtualComponent)getTaskModel().getObject(NewReferenceWizard.ROOT_COMPONENT);
+ if (selected != null && selected.length > 0) {
+ ArrayList<IVirtualComponent> compList = new ArrayList<IVirtualComponent>();
+ ArrayList<String> paths = new ArrayList<String>();
+ for (int i = 0; i < selected.length; i++) {
+ IPath resolvedPath = JavaCore.getResolvedVariablePath(selected[i]);
+ java.io.File file = new java.io.File(resolvedPath.toOSString());
+ if (file.isFile() && file.exists()) {
+ String type = VirtualArchiveComponent.VARARCHIVETYPE
+ + IPath.SEPARATOR;
+ IVirtualComponent archive = ComponentCore
+ .createArchiveComponent(rootComponent.getProject(),
+ type + selected[i].toString());
+ compList.add(archive);
+ paths.add(resolvedPath.lastSegment());
+ }
+ }
+ IVirtualComponent[] components = (IVirtualComponent[]) compList.toArray(new IVirtualComponent[compList.size()]);
+ String[] paths2 = (String[]) paths.toArray(new String[paths.size()]);
+ getTaskModel().putObject(NewReferenceWizard.COMPONENT, components);
+ getTaskModel().putObject(NewReferenceWizard.COMPONENT_PATH, paths2);
+ }
+ }
+}
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/impl (from rev 16825, workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/impl)
Modified: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/impl/EarModuleDependenciesPropertyPage.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/impl/EarModuleDependenciesPropertyPage.java 2009-07-27 18:37:50 UTC (rev 16825)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/impl/EarModuleDependenciesPropertyPage.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -1,4 +1,4 @@
-package org.jboss.ide.eclipse.as.wtp.override.ui.propertypage.impl;
+package org.eclipse.wst.common.componentcore.ui.propertypage.impl;
import java.util.ArrayList;
@@ -14,8 +14,8 @@
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
-import org.jboss.ide.eclipse.as.wtp.override.ui.propertypage.AddModuleDependenciesPropertiesPage;
-import org.jboss.ide.eclipse.as.wtp.override.ui.propertypage.ModuleAssemblyRootPage;
+import org.eclipse.wst.common.componentcore.ui.propertypage.AddModuleDependenciesPropertiesPage;
+import org.eclipse.wst.common.componentcore.ui.propertypage.ModuleAssemblyRootPage;
public class EarModuleDependenciesPropertyPage extends
AddModuleDependenciesPropertiesPage {
Modified: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/impl/EarModuleDependencyPageProvider.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/impl/EarModuleDependencyPageProvider.java 2009-07-27 18:37:50 UTC (rev 16825)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/eclipse/wst/common/componentcore/ui/propertypage/impl/EarModuleDependencyPageProvider.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -1,11 +1,11 @@
-package org.jboss.ide.eclipse.as.wtp.override.ui.propertypage.impl;
+package org.eclipse.wst.common.componentcore.ui.propertypage.impl;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
-import org.jboss.ide.eclipse.as.wtp.override.ui.propertypage.IDependencyPageProvider;
-import org.jboss.ide.eclipse.as.wtp.override.ui.propertypage.IModuleDependenciesControl;
-import org.jboss.ide.eclipse.as.wtp.override.ui.propertypage.ModuleAssemblyRootPage;
+import org.eclipse.wst.common.componentcore.ui.propertypage.IDependencyPageProvider;
+import org.eclipse.wst.common.componentcore.ui.propertypage.IModuleDependenciesControl;
+import org.eclipse.wst.common.componentcore.ui.propertypage.ModuleAssemblyRootPage;
public class EarModuleDependencyPageProvider implements IDependencyPageProvider {
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/Messages.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/Messages.java 2009-07-27 18:37:50 UTC (rev 16825)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/Messages.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -1,21 +0,0 @@
-package org.jboss.ide.eclipse.as.wtp.override.ui;
-
-import org.eclipse.osgi.util.NLS;
-
-public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.jboss.ide.eclipse.as.wtp.override.ui.messages"; //$NON-NLS-1$
- public static String AddModuleDependenciesPropertiesPage_AddProjectButton;
- public static String AddModuleDependenciesPropertiesPage_DeployPathColumn;
- public static String AddModuleDependenciesPropertiesPage_RemoveSelectedButton;
- public static String AddModuleDependenciesPropertiesPage_SelectAProjectTitle;
- public static String AddModuleDependenciesPropertiesPage_SourceColumn;
- public static String J2EEDependenciesPage_Description;
- public static String J2EEDependenciesPage_ErrorCheckingFacets;
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- private Messages() {
- }
-}
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/WTPOveridePlugin.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/WTPOveridePlugin.java 2009-07-27 18:37:50 UTC (rev 16825)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/WTPOveridePlugin.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -1,87 +0,0 @@
-package org.jboss.ide.eclipse.as.wtp.override.ui;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class WTPOveridePlugin extends AbstractUIPlugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.jboss.ide.eclipse.as.wtp.override.ui"; //$NON-NLS-1$
-
- // The shared instance
- private static WTPOveridePlugin plugin;
-
- /**
- * The constructor
- */
- public WTPOveridePlugin() {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static WTPOveridePlugin getDefault() {
- return plugin;
- }
-
- public static void log(Exception e) {
- log(e.getMessage(), e);
- }
-
- public static void log(String message, Exception e) {
- IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, message, e);
- getDefault().getLog().log(status);
- }
- public static IStatus createStatus(int severity, int aCode,
- String aMessage, Throwable exception) {
- return new Status(severity, PLUGIN_ID, aCode,
- aMessage != null ? aMessage : "No message.", exception); //$NON-NLS-1$
- }
- public static IStatus createErrorStatus(int aCode, String aMessage,
- Throwable exception) {
- return createStatus(IStatus.ERROR, aCode, aMessage, exception);
- }
-
- public static IStatus createStatus(int severity, String message, Throwable exception) {
- return new Status(severity, PLUGIN_ID, message, exception);
- }
-
- public static IStatus createStatus(int severity, String message) {
- return createStatus(severity, message, null);
- }
- public static void logError(Throwable exception) {
- Platform.getLog(Platform.getBundle(PLUGIN_ID)).log( createStatus(IStatus.ERROR, exception.getMessage(), exception));
- }
-
- public static void logError(CoreException exception) {
- Platform.getLog(Platform.getBundle(PLUGIN_ID)).log( exception.getStatus() );
- }
-
-}
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/messages.properties
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/messages.properties 2009-07-27 18:37:50 UTC (rev 16825)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/messages.properties 2009-07-27 18:51:58 UTC (rev 16826)
@@ -1,7 +0,0 @@
-AddModuleDependenciesPropertiesPage_AddProjectButton=Add Project...
-AddModuleDependenciesPropertiesPage_DeployPathColumn=Deploy Path
-AddModuleDependenciesPropertiesPage_RemoveSelectedButton=Remove selected...
-AddModuleDependenciesPropertiesPage_SelectAProjectTitle=Select a Project
-AddModuleDependenciesPropertiesPage_SourceColumn=Source
-J2EEDependenciesPage_Description=ModuleDependency Page Description
-J2EEDependenciesPage_ErrorCheckingFacets=Error Checking Project Facets
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/AddFolderDialog.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/AddFolderDialog.java 2009-07-27 18:37:50 UTC (rev 16825)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/AddFolderDialog.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -1,133 +0,0 @@
-package org.jboss.ide.eclipse.as.wtp.override.ui.propertypage;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.dialogs.TitleAreaDialog;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-
-public class AddFolderDialog extends TitleAreaDialog {
- private IProject project;
- private TreeViewer viewer;
- private IContainer selected = null;
- public AddFolderDialog(Shell parentShell, IProject project) {
- super(parentShell);
- this.project = project;
- }
-
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- shell.setText("Add Folder");
- shell.setBounds(shell.getLocation().x, shell.getLocation().y, 400,300);
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite c = (Composite)super.createDialogArea(parent);
- this.viewer = new TreeViewer(c, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- viewer.setContentProvider(getContentProvider());
- viewer.setLabelProvider(getLabelProvider());
- viewer.addFilter(getFilter());
- viewer.setInput(project);
- viewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
- viewer.addSelectionChangedListener(getListener());
- return c;
- }
-
- protected ISelectionChangedListener getListener() {
- return new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection sel = (IStructuredSelection)viewer.getSelection();
- Object first = sel.getFirstElement();
- if( first instanceof IContainer)
- selected = (IContainer)first;
- }
- };
- }
-
- public IContainer getSelected() {
- return selected;
- }
-
- protected ViewerFilter getFilter() {
- return new ViewerFilter() {
- public boolean select(Viewer viewer, Object parentElement,
- Object element) {
- return element instanceof IContainer;
- }
- };
- }
-
- protected ITreeContentProvider getContentProvider() {
- return new ITreeContentProvider() {
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- public void dispose() {
- }
-
- public Object[] getElements(Object inputElement) {
- try {
- return project.members();
- } catch( CoreException ce ) {
- return new Object[]{};
- }
- }
-
- public boolean hasChildren(Object element) {
- if( element instanceof IContainer) {
- try {
- return ((IContainer)element).members().length > 0;
- } catch( CoreException ce ) {
- }
- }
- return false;
- }
-
- public Object getParent(Object element) {
- if( element instanceof IResource)
- return ((IResource)element).getParent();
- return null;
- }
-
- public Object[] getChildren(Object parentElement) {
- if( parentElement instanceof IContainer) {
- try {
- return ((IContainer)parentElement).members();
- } catch( CoreException ce ) {
- }
- }
- return new Object[]{};
- }
- };
- }
-
- protected LabelProvider getLabelProvider() {
- return new LabelProvider() {
- public Image getImage(Object element) {
- return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
- }
- public String getText(Object element) {
- if( element instanceof IResource)
- return ((IResource)element).getName();
- return element.toString();
- }
- };
- }
-}
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/AddModuleDependenciesPropertiesPage.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/AddModuleDependenciesPropertiesPage.java 2009-07-27 18:37:50 UTC (rev 16825)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/AddModuleDependenciesPropertiesPage.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -1,909 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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
- * David Schneider, david.schneider(a)unisys.com - [142500] WTP properties pages fonts don't follow Eclipse preferences
- * Stefan Dimov, stefan.dimov(a)sap.com - bugs 207826, 222651
- *******************************************************************************/
-package org.jboss.ide.eclipse.as.wtp.override.ui.propertypage;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-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.jface.dialogs.Dialog;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.ICellModifier;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TextCellEditor;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FillLayout;
-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.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties;
-import org.eclipse.wst.common.componentcore.internal.ComponentResource;
-import org.eclipse.wst.common.componentcore.internal.StructureEdit;
-import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent;
-import org.eclipse.wst.common.componentcore.internal.operation.CreateReferenceComponentsDataModelProvider;
-import org.eclipse.wst.common.componentcore.internal.operation.RemoveReferenceComponentsDataModelProvider;
-import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
-import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
-import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
-import org.jboss.ide.eclipse.as.wtp.override.core.vcf.ComponentUtils;
-import org.jboss.ide.eclipse.as.wtp.override.ui.Messages;
-import org.jboss.ide.eclipse.as.wtp.override.ui.WTPOveridePlugin;
-
-public class AddModuleDependenciesPropertiesPage implements Listener,
- IModuleDependenciesControl {
-
- private static final String DEPLOY_PATH_PROPERTY = new Integer(0).toString();
- private static final String SOURCE_PROPERTY = new Integer(1).toString();
-
-
- protected final String PATH_SEPARATOR = ComponentDependencyContentProvider.PATH_SEPARATOR;
- private boolean hasInitialized = false;
- protected final IProject project;
- protected final ModuleAssemblyRootPage propPage;
- protected IVirtualComponent rootComponent = null;
- protected Text componentNameText;
- protected Label availableModules;
- protected TableViewer availableComponentsViewer;
- protected Button addMappingButton, addReferenceButton, removeButton;
- protected Composite buttonColumn;
- protected static final IStatus OK_STATUS = IDataModelProvider.OK_STATUS;
- protected Listener tableListener;
- protected Listener labelListener;
-
- // Mappings that existed when the page was opened (or last saved)
- protected HashMap<IVirtualComponent, String> oldComponentToRuntimePath = new HashMap<IVirtualComponent, String>();
-
- // Mappings that are current
- protected HashMap<IVirtualComponent, String> objectToRuntimePath = new HashMap<IVirtualComponent, String>();
-
- // A single list of wb-resource mappings. If there's any change,
- // all old will be removed and new ones added
- protected ArrayList<ComponentResourceProxy> resourceMappings = new ArrayList<ComponentResourceProxy>();
-
- // keeps track if a change has occurred in wb-resource mappings
- protected boolean resourceMappingsChanged = false;
-
- /**
- * Constructor for AddModulestoEARPropertiesControl.
- */
- public AddModuleDependenciesPropertiesPage(final IProject project,
- final ModuleAssemblyRootPage page) {
- this.project = project;
- this.propPage = page;
- rootComponent = ComponentCore.createComponent(project);
- }
-
- /*
- * UI Creation Methods
- */
-
- public Composite createContents(final Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.marginWidth = 0;
- layout.marginWidth = 0;
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- ModuleAssemblyRootPage.createDescriptionComposite(composite,
- "TODO Change this: Create and change packaging structure for this project ");
- createListGroup(composite);
- refresh();
- Dialog.applyDialogFont(parent);
- return composite;
- }
-
- protected void createListGroup(Composite parent) {
- Composite listGroup = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- listGroup.setLayout(layout);
- GridData gData = new GridData(GridData.FILL_BOTH);
- gData.horizontalIndent = 5;
- listGroup.setLayoutData(gData);
-
- availableModules = new Label(listGroup, SWT.NONE);
- gData = new GridData(GridData.HORIZONTAL_ALIGN_FILL
- | GridData.VERTICAL_ALIGN_FILL);
- availableModules.setText("Module Assembly"); //$NON-NLS-1$
- availableModules.setLayoutData(gData);
- createTableComposite(listGroup);
- }
-
- protected void createTableComposite(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- GridData gData = new GridData(GridData.FILL_BOTH);
- composite.setLayoutData(gData);
- fillComposite(composite);
- }
-
- public void fillComposite(Composite parent) {
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- layout.marginHeight = 0;
- parent.setLayout(layout);
- parent.setLayoutData(new GridData(GridData.FILL_BOTH));
- createTable(parent);
- createButtonColumn(parent);
- }
-
- protected void createButtonColumn(Composite parent) {
- buttonColumn = createButtonColumnComposite(parent);
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END);
- buttonColumn.setLayoutData(data);
- createPushButtons();
- }
-
- protected void createPushButtons() {
- addMappingButton = createPushButton("Add Folder...");
- addReferenceButton = createPushButton("Add Reference...");
- removeButton = createPushButton("Remove selected");
- }
-
- protected Button createPushButton(String label) {
- Button aButton = new Button(buttonColumn, SWT.PUSH);
- aButton.setText(label);
- aButton.addListener(SWT.Selection, this);
- aButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- return aButton;
- }
-
- public Composite createButtonColumnComposite(Composite parent) {
- Composite aButtonColumn = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- aButtonColumn.setLayout(layout);
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL
- | GridData.VERTICAL_ALIGN_BEGINNING);
- aButtonColumn.setLayoutData(data);
- return aButtonColumn;
- }
-
- public Group createGroup(Composite parent) {
- return new Group(parent, SWT.NULL);
- }
-
- protected void createTable(Composite parent) {
- if (rootComponent != null) {
- availableComponentsViewer = createAvailableComponentsViewer(parent);
- GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL
- | GridData.FILL_VERTICAL);
- availableComponentsViewer.getTable().setLayoutData(gd);
-
- ComponentDependencyContentProvider provider = createProvider();
- provider.setRuntimePaths(objectToRuntimePath);
- provider.setResourceMappings(resourceMappings);
- availableComponentsViewer.setContentProvider(provider);
- availableComponentsViewer.setLabelProvider(provider);
- addTableListeners();
- }
- }
-
- /**
- * Subclasses should over-ride this and extend the class
- */
- protected ComponentDependencyContentProvider createProvider() {
- return new ComponentDependencyContentProvider();
- }
-
- /*
- * Listeners of various events
- */
-
- protected void addTableListeners() {
- addHoverHelpListeners();
- addDoubleClickListener();
- addSelectionListener();
- }
-
- protected void addHoverHelpListeners() {
- final Table table = availableComponentsViewer.getTable();
- createLabelListener(table);
- createTableListener(table);
- table.addListener(SWT.Dispose, tableListener);
- table.addListener(SWT.KeyDown, tableListener);
- table.addListener(SWT.MouseMove, tableListener);
- table.addListener(SWT.MouseHover, tableListener);
- }
-
- protected void createLabelListener(final Table table) {
- labelListener = new Listener() {
- public void handleEvent(Event event) {
- Label label = (Label) event.widget;
- Shell shell = label.getShell();
- switch (event.type) {
- case SWT.MouseDown:
- Event e = new Event();
- e.item = (TableItem) label.getData("_TABLEITEM"); //$NON-NLS-1$
- table.setSelection(new TableItem[] { (TableItem) e.item });
- table.notifyListeners(SWT.Selection, e);
- shell.dispose();
- table.setFocus();
- break;
- case SWT.MouseExit:
- shell.dispose();
- break;
- }
- }
- };
- }
-
- protected void createTableListener(final Table table) {
- tableListener = new Listener() {
- Shell tip = null;
- Label label = null;
-
- public void handleEvent(Event event) {
- switch (event.type) {
- case SWT.Dispose:
- case SWT.KeyDown:
- case SWT.MouseMove: {
- if (tip == null)
- break;
- tip.dispose();
- tip = null;
- label = null;
- break;
- }
- case SWT.MouseHover: {
- TableItem item = table.getItem(new Point(event.x, event.y));
- if (item != null && item.getData() != null && !canEdit(item.getData())) {
- if (tip != null && !tip.isDisposed())
- tip.dispose();
- tip = new Shell(PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getShell(),
- SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL);
- tip.setBackground(Display.getDefault().getSystemColor(
- SWT.COLOR_INFO_BACKGROUND));
- FillLayout layout = new FillLayout();
- layout.marginWidth = 2;
- tip.setLayout(layout);
- label = new Label(tip, SWT.WRAP);
- label.setForeground(Display.getDefault()
- .getSystemColor(SWT.COLOR_INFO_FOREGROUND));
- label.setBackground(Display.getDefault()
- .getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- label.setData("_TABLEITEM", item); //$NON-NLS-1$
- label.setText(J2EEUIMessages
- .getResourceString(J2EEUIMessages.HOVER_HELP_FOR_DISABLED_LIBS));
- label.addListener(SWT.MouseExit, labelListener);
- label.addListener(SWT.MouseDown, labelListener);
- Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- Rectangle rect = item.getBounds(0);
- Point pt = table.toDisplay(rect.x, rect.y);
- tip.setBounds(pt.x, pt.y - size.y, size.x, size.y);
- tip.setVisible(true);
- }
- }
- }
- }
- };
- }
-
- protected boolean canEdit(Object data) {
- if( data == null ) return false;
- if( !(data instanceof VirtualArchiveComponent)) return true;
-
- VirtualArchiveComponent d2 = (VirtualArchiveComponent)data;
- boolean sameProject = d2.getWorkspaceRelativePath() != null
- && d2.getWorkspaceRelativePath().segment(0)
- .equals(rootComponent.getProject().getName());
- return !(sameProject && isPhysicallyAdded(d2));
- }
-
- protected void addDoubleClickListener() {
- availableComponentsViewer.setColumnProperties(new String[] {
- DEPLOY_PATH_PROPERTY, SOURCE_PROPERTY });
-
- CellEditor[] editors = new CellEditor[] {
- new TextCellEditor(availableComponentsViewer.getTable()),
- new TextCellEditor()};
- availableComponentsViewer.setCellEditors(editors);
- availableComponentsViewer
- .setCellModifier(new RuntimePathCellModifier());
- }
-
- protected void addSelectionListener() {
- availableComponentsViewer.addSelectionChangedListener(
- new ISelectionChangedListener(){
- public void selectionChanged(SelectionChangedEvent event) {
- viewerSelectionChanged();
- }
- });
- }
-
- protected void viewerSelectionChanged() {
- removeButton.setEnabled(getSelectedObject() != null && canEdit(getSelectedObject()));
- }
-
- protected Object getSelectedObject() {
- IStructuredSelection sel = (IStructuredSelection)availableComponentsViewer.getSelection();
- return sel.getFirstElement();
- }
-
- private class RuntimePathCellModifier implements ICellModifier {
-
- public boolean canModify(Object element, String property) {
- if( property.equals(DEPLOY_PATH_PROPERTY)) {
- if (element instanceof VirtualArchiveComponent) {
- try {
- return canEdit(element);
- } catch (IllegalArgumentException iae) {
- }
- }
- return true;
- }
- return false;
- }
-
- public Object getValue(Object element, String property) {
- Object data = element; //((TableItem)element).getData();
- if( data instanceof IVirtualComponent ) {
- return objectToRuntimePath.get(element) == null ? new Path("/") //$NON-NLS-1$
- .toString() : objectToRuntimePath.get(element);
- } else if( data instanceof ComponentResourceProxy) {
- return ((ComponentResourceProxy)data).runtimePath.toString();
- }
- return new Path("/");
- }
-
- public void modify(Object element, String property, Object value) {
- if (property.equals(DEPLOY_PATH_PROPERTY)) {
- TableItem item = (TableItem) element;
- if( item.getData() instanceof IVirtualComponent) {
- objectToRuntimePath.put((IVirtualComponent)item.getData(), (String) value);
- } else if( item.getData() instanceof ComponentResourceProxy) {
- ComponentResourceProxy c = ((ComponentResourceProxy)item.getData());
- c.runtimePath = new Path((String)value);
- resourceMappingsChanged = true;
- }
- refresh();
- }
- }
-
- }
-
- public void handleEvent(Event event) {
- if( event.widget == addMappingButton)
- handleAddMappingButton();
- else if( event.widget == addReferenceButton)
- handleAddReferenceButton();
- else if( event.widget == removeButton )
- handleRemoveSelectedButton();
- }
-
- protected void handleAddMappingButton() {
- AddFolderDialog afd = new AddFolderDialog(addMappingButton.getShell(), project);
- if( afd.open() == Window.OK) {
- IContainer c = afd.getSelected();
- if( c != null ) {
- IPath p = c.getProjectRelativePath();
- ComponentResourceProxy proxy = new ComponentResourceProxy(p, new Path("/"));
- resourceMappings.add(proxy);
- refresh();
- }
- }
- }
-
- protected void handleAddReferenceButton() {
- NewReferenceWizard wizard = new NewReferenceWizard();
- // fill the task model
- wizard.getTaskModel().putObject(NewReferenceWizard.PROJECT, project);
- wizard.getTaskModel().putObject(NewReferenceWizard.ROOT_COMPONENT, rootComponent);
-
- WizardDialog wd = new WizardDialog(addReferenceButton.getShell(), wizard);
- if( wd.open() != Window.CANCEL) {
- Object c1 = wizard.getTaskModel().getObject(NewReferenceWizard.COMPONENT);
- Object p1 = wizard.getTaskModel().getObject(NewReferenceWizard.COMPONENT_PATH);
- IVirtualComponent[] compArr = c1 instanceof IVirtualComponent ?
- new IVirtualComponent[] { (IVirtualComponent)c1 } :
- (IVirtualComponent[])c1;
- String[] pathArr = p1 instanceof String ?
- new String[] { (String)p1 } :
- (String[])p1;
- for( int i = 0; i < compArr.length; i++ ) {
- objectToRuntimePath.put(compArr[i], pathArr[i]);
- }
- refresh();
- }
- }
-
- protected void handleRemoveSelectedButton() {
- ISelection sel = availableComponentsViewer.getSelection();
- if( sel instanceof IStructuredSelection ) {
- Object o = ((IStructuredSelection)sel).getFirstElement();
- if( o instanceof IVirtualComponent)
- objectToRuntimePath.remove(o);
- else if( o instanceof ComponentResourceProxy)
- resourceMappings.remove(o);
- refresh();
- }
- }
-
- public TableViewer createAvailableComponentsViewer(Composite parent) {
- int flags = SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI;
-
- Table table = new Table(parent, flags);
- availableComponentsViewer = new TableViewer(table);
-
- // set up table layout
- TableLayout tableLayout = new org.eclipse.jface.viewers.TableLayout();
- tableLayout.addColumnData(new ColumnWeightData(400, true));
- tableLayout.addColumnData(new ColumnWeightData(500, true));
- table.setLayout(tableLayout);
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
- availableComponentsViewer.setSorter(null);
-
- TableColumn bndColumn = new TableColumn(table, SWT.NONE, 0);
- bndColumn.setText(Messages.AddModuleDependenciesPropertiesPage_DeployPathColumn);
- bndColumn.setResizable(true);
-
- TableColumn projectColumn = new TableColumn(table, SWT.NONE, 1);
- projectColumn.setText(Messages.AddModuleDependenciesPropertiesPage_SourceColumn);
- projectColumn.setResizable(true);
-
- tableLayout.layout(table, true);
- return availableComponentsViewer;
-
- }
-
- protected boolean isPhysicallyAdded(VirtualArchiveComponent component) {
- try {
- component.getProjectRelativePath();
- return true;
- } catch (IllegalArgumentException e) {
- return false;
- }
- }
-
- /**
- * This should only be called on changes, such as adding a project
- * reference, adding a lib reference etc.
- *
- * It will reset the input, manually re-add missing elements, and do other
- * tasks
- */
- public void refresh() {
- resetTableUI();
- if (!hasInitialized) {
- initialize();
- resetTableUI();
- }
-
- }
-
- protected void resetTableUI() {
- IWorkspaceRoot input = ResourcesPlugin.getWorkspace().getRoot();
- availableComponentsViewer.setInput(input);
- GridData data = new GridData(GridData.FILL_BOTH);
- int numlines = Math.min(10, availableComponentsViewer.getTable()
- .getItemCount());
- data.heightHint = availableComponentsViewer.getTable().getItemHeight()
- * numlines;
- availableComponentsViewer.getTable().setLayoutData(data);
- GridData btndata = new GridData(GridData.HORIZONTAL_ALIGN_FILL
- | GridData.VERTICAL_ALIGN_BEGINNING);
- buttonColumn.setLayoutData(btndata);
- }
-
- protected void initialize() {
- IVirtualReference[] refs = rootComponent.getReferences();
- IVirtualComponent comp;
- for( int i = 0; i < refs.length; i++ ) {
- comp = refs[i].getReferencedComponent();
- String val = refs[i].getRuntimePath().append(refs[i].getArchiveName()).toString();
- objectToRuntimePath.put(comp, val);
- oldComponentToRuntimePath.put((IVirtualComponent) comp, val);
- }
-
- ComponentResource[] allMappings = findAllMappings();
- for( int i = 0; i < allMappings.length; i++ ) {
- resourceMappings.add(new ComponentResourceProxy(
- allMappings[i].getSourcePath(), allMappings[i].getRuntimePath()
- ));
- }
- hasInitialized = true;
- }
-
- protected ComponentResource[] findAllMappings() {
- StructureEdit structureEdit = null;
- try {
- structureEdit = StructureEdit.getStructureEditForRead(project);
- WorkbenchComponent component = structureEdit.getComponent();
- Object[] arr = component.getResources().toArray();
- ComponentResource[] result = new ComponentResource[arr.length];
- for( int i = 0; i < arr.length; i++ )
- result[i] = (ComponentResource)arr[i];
- return result;
- } catch(Exception e) {
- } finally {
- structureEdit.dispose();
- }
- return new ComponentResource[]{};
- }
-
- public class ComponentResourceProxy {
- public IPath source, runtimePath;
- public ComponentResourceProxy(IPath source, IPath runtimePath) {
- this.source = source;
- this.runtimePath = runtimePath;
- }
- }
-
- /*
- * Clean-up methods are below. These include performCancel, performDefaults,
- * performOK, and any other methods that are called *only* by this one.
- */
- public void setVisible(boolean visible) {
- }
-
- public void performDefaults() {
- }
-
- public boolean performCancel() {
- return true;
- }
-
- public void dispose() {
- Table table = null;
- if (availableComponentsViewer != null) {
- table = availableComponentsViewer.getTable();
- }
- if (table == null || tableListener == null)
- return;
- table.removeListener(SWT.Dispose, tableListener);
- table.removeListener(SWT.KeyDown, tableListener);
- table.removeListener(SWT.MouseMove, tableListener);
- table.removeListener(SWT.MouseHover, tableListener);
- }
-
-
-
- /*
- * This is where the OK work goes. Lots of it. Watch your head.
- * xiao xin
- */
- protected boolean preHandleChanges(IProgressMonitor monitor) {
- return true;
- }
-
- protected boolean postHandleChanges(IProgressMonitor monitor) {
- return true;
- }
-
- public boolean performOk() {
- boolean result = true;
- result &= saveResourceChanges();
- result &= saveReferenceChanges();
- return result;
- }
-
- protected boolean saveResourceChanges() {
- removeAllResourceMappings();
- addNewResourceMappings();
- return true;
- }
- protected boolean addNewResourceMappings() {
- ComponentResourceProxy[] proxies = (ComponentResourceProxy[]) resourceMappings.toArray(new ComponentResourceProxy[resourceMappings.size()]);
- IVirtualFolder rootFolder = rootComponent.getRootFolder();
- for( int i = 0; i < proxies.length; i++ ) {
- try {
- rootFolder.getFolder(proxies[i].runtimePath).createLink(proxies[i].source, 0, null);
- } catch( CoreException ce ) {
- }
- }
- resourceMappingsChanged = false;
- return true;
- }
-
- protected boolean removeAllResourceMappings() {
- StructureEdit moduleCore = null;
- try {
- moduleCore = StructureEdit.getStructureEditForWrite(project);
- moduleCore.getComponent().getResources().clear();
- }
- finally {
- if (moduleCore != null) {
- moduleCore.saveIfNecessary(new NullProgressMonitor());
- moduleCore.dispose();
- }
- }
- return true;
- }
-
- protected boolean saveReferenceChanges() {
- // Fill our delta lists
- ArrayList<IVirtualComponent> added = new ArrayList<IVirtualComponent>();
- ArrayList<IVirtualComponent> removed = new ArrayList<IVirtualComponent>();
- ArrayList<IVirtualComponent> changed = new ArrayList<IVirtualComponent>();
-
- Iterator<IVirtualComponent> j = oldComponentToRuntimePath.keySet().iterator();
- Object key, val;
- while (j.hasNext()) {
- key = j.next();
- val = oldComponentToRuntimePath.get(key);
- if( !objectToRuntimePath.containsKey(key))
- removed.add((IVirtualComponent)key);
- else if (!val.equals(objectToRuntimePath.get(key)))
- changed.add((IVirtualComponent)key);
- }
-
- j = objectToRuntimePath.keySet().iterator();
- while (j.hasNext()) {
- key = j.next();
- if (!oldComponentToRuntimePath.containsKey(key))
- added.add((IVirtualComponent)key);
- }
-
- NullProgressMonitor monitor = new NullProgressMonitor();
- boolean subResult = preHandleChanges(monitor);
- if( !subResult )
- return false;
-
- handleDeltas(removed, changed, added);
- subResult &= postHandleChanges(monitor);
-
- // Now update the variables
- oldComponentToRuntimePath.clear();
- ArrayList<IVirtualComponent> keys = new ArrayList<IVirtualComponent>();
- keys.addAll(objectToRuntimePath.keySet());
- Iterator<IVirtualComponent> i = keys.iterator();
- while(i.hasNext()) {
- IVirtualComponent vc = i.next();
- String path = objectToRuntimePath.get(vc);
- oldComponentToRuntimePath.put(vc, path);
- }
- return subResult;
- }
-
- // Subclass can override if it has a good way to handle changed elements
- protected void handleDeltas(ArrayList<IVirtualComponent> removed,
- ArrayList<IVirtualComponent> changed, ArrayList<IVirtualComponent> added) {
- ArrayList<IVirtualComponent> removed2 = new ArrayList<IVirtualComponent>();
- ArrayList<IVirtualComponent> added2 = new ArrayList<IVirtualComponent>();
- removed2.addAll(removed);
- removed2.addAll(changed);
- added2.addAll(added);
- added2.addAll(changed);
-
- // meld the changed into the added / removed for less efficiency ;)
- // basically we lack "change" operations and only have add / remove
- handleRemoved(removed2);
- handleAdded(added2);
- }
- protected void handleRemoved(ArrayList<IVirtualComponent> removed) {
- // If it's removed it should *only* be a virtual component already
- Iterator<IVirtualComponent> i = removed.iterator();
- IVirtualComponent component;
- while(i.hasNext()) {
- try {
- component = i.next();
- IDataModelOperation operation = getRemoveComponentOperation(component);
- operation.execute(null, null);
- } catch( ExecutionException e) {
- WTPOveridePlugin.logError(e);
- }
- }
- }
-
- protected IDataModelOperation getRemoveComponentOperation(IVirtualComponent component) {
- String path, archiveName;
- path = new Path(oldComponentToRuntimePath.get(component)).removeLastSegments(1).toString();
- archiveName = new Path(oldComponentToRuntimePath.get(component)).lastSegment();
-
- IDataModelProvider provider = getRemoveReferenceDataModelProvider(component);
- IDataModel model = DataModelFactory.createDataModel(provider);
- model.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, rootComponent);
- List<IVirtualComponent> modHandlesList = (List<IVirtualComponent>) model.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST);
- modHandlesList.add(component);
- model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, modHandlesList);
- model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH, path);
- Map<IVirtualComponent, String> uriMap = new HashMap<IVirtualComponent, String>();
- uriMap.put(component, archiveName);
- model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, uriMap);
- return model.getDefaultOperation();
- }
-
- protected IDataModelProvider getRemoveReferenceDataModelProvider(IVirtualComponent component) {
- return new RemoveReferenceComponentsDataModelProvider();
- }
-
-
- protected void handleChanged(ArrayList<IVirtualComponent> changed) {
- Iterator<IVirtualComponent> i = changed.iterator();
- IVirtualComponent component;
- IVirtualReference ref;
- IPath p;
- while(i.hasNext()) {
- component = i.next();
- ref = rootComponent.getReference(component.getName());
- p = new Path(objectToRuntimePath.get(component));
- ref.setRuntimePath(p);
- }
- }
-
- protected void handleAdded(ArrayList<IVirtualComponent> added) {
- final ArrayList<IVirtualComponent> components = new ArrayList<IVirtualComponent>();
- Iterator<IVirtualComponent> i = added.iterator();
- IVirtualComponent o;
- while(i.hasNext()) {
- o = i.next();
- components.add((IVirtualComponent)o);
- }
-
- IWorkspaceRunnable runnable = new IWorkspaceRunnable(){
- public void run(IProgressMonitor monitor) throws CoreException{
- addComponents(components);
- }
- };
- try {
- ResourcesPlugin.getWorkspace().run(runnable, new NullProgressMonitor());
- } catch( CoreException e ) {
- WTPOveridePlugin.logError(e);
- }
- }
-
- protected void addComponents(ArrayList<IVirtualComponent> components) throws CoreException {
- Iterator<IVirtualComponent> i = components.iterator();
- while(i.hasNext()) {
- addOneComponent(i.next());
- }
- }
-
- protected IDataModelProvider getAddReferenceDataModelProvider(IVirtualComponent component) {
- return new CreateReferenceComponentsDataModelProvider();
- }
-
- protected void addOneComponent(IVirtualComponent component) throws CoreException {
- String path, archiveName;
- path = new Path(objectToRuntimePath.get(component)).removeLastSegments(1).toString();
- archiveName = new Path(objectToRuntimePath.get(component)).lastSegment();
-
- IDataModelProvider provider = getAddReferenceDataModelProvider(component);
- IDataModel dm = DataModelFactory.createDataModel(provider);
-
- dm.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, rootComponent);
- dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, Arrays.asList(component));
-
- //[Bug 238264] the uri map needs to be manually set correctly
- Map<IVirtualComponent, String> uriMap = new HashMap<IVirtualComponent, String>();
- uriMap.put(component, archiveName);
- dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, uriMap);
- dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH, path);
-
- IStatus stat = dm.validateProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST);
- if (stat != OK_STATUS)
- throw new CoreException(stat);
- try {
- dm.getDefaultOperation().execute(new NullProgressMonitor(), null);
- } catch (ExecutionException e) {
- WTPOveridePlugin.logError(e);
- }
- }
- /**
- * Method returns the name of the given IVirtualComponent being sure the correct extension
- * is on the end of the name, this is important for internal projects. Added for [Bug 241509]
- *
- * Note (rs) : I do not believe this ever gets called with a binary virtComp
- *
- * @param virtComp the IVirtualComponent to get the name of with the correct extension
- * @return the name of the given IVirtualComponent with the correct extension
- */
- protected String getVirtualComponentNameWithExtension(IVirtualComponent virtComp) {
- String virtCompURIMapName = this.getURIMappingName(virtComp);
- String extension = ComponentUtils.getDefaultProjectExtension(virtComp);
- virtCompURIMapName += extension;
- return virtCompURIMapName;
- }
-
- /**
- * [Bug 238264]
- * determines a unique URI mapping name for a given component
- * this is in case two components have the same name.
- *
- * @return returns a valid (none duplicate) uri mapping name for the given component\
- */
- private String getURIMappingName(IVirtualComponent archive) {
-
- //get the default uri map name for the given archive
- IPath componentPath = Path.fromOSString(archive.getName());
- String uriMapName = componentPath.lastSegment().replace(' ', '_');
-
-
- //check to be sure this uri mapping is not already in use by another reference
- boolean dupeArchiveName;
- String refedCompName;
- int lastDotIndex;
- String increment;
- IVirtualReference [] existingRefs = rootComponent.getReferences();
- for(int i=0;i<existingRefs.length;i++){
- refedCompName = existingRefs[i].getReferencedComponent().getName();
-
- //if uri mapping names of the refed component and the given archive are the same
- // find a new uri map name for the given archive
- if(existingRefs[i].getArchiveName().equals(uriMapName)){
- dupeArchiveName = true;
- //find a new uriMapName for the given component
- for(int j=1; dupeArchiveName; j++){
- lastDotIndex = uriMapName.lastIndexOf('.');
- increment = "_"+j; //$NON-NLS-1$
-
- //create the new potential name
- if(lastDotIndex != -1){
- uriMapName = uriMapName.substring(0, lastDotIndex) + increment + uriMapName.substring(lastDotIndex);
- } else {
- uriMapName = uriMapName.substring(0)+increment;
- }
-
- //determine if the new potential name is valid
- for(int k=0; k<existingRefs.length; k++) {
- dupeArchiveName = existingRefs[k].getArchiveName().equals(uriMapName);
- if(dupeArchiveName) {
- break;
- }
- }
- }
- }
- }
-
- return uriMapName;
- }
-}
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ComponentDependencyContentProvider.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ComponentDependencyContentProvider.java 2009-07-27 18:37:50 UTC (rev 16825)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ComponentDependencyContentProvider.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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
- * Stefan Dimov, stefan.dimov(a)sap.com - bug 207826
- *******************************************************************************/
-package org.jboss.ide.eclipse.as.wtp.override.ui.propertypage;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.common.componentcore.internal.ComponentResource;
-import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.jboss.ide.eclipse.as.wtp.override.ui.propertypage.AddModuleDependenciesPropertiesPage.ComponentResourceProxy;
-
-
-/*
- * The only valid elements this content provider (should) provide
- * are IProject or IVirtualComponent objects. The runtime paths portion is
- * shared with the preference page itself where they can both modify the data.
- *
- * This provider no longer "meddles" in to the content as it used to,
- * but rather serves as only a view of it.
- */
-public class ComponentDependencyContentProvider extends LabelProvider implements IStructuredContentProvider, ITableLabelProvider {
-
- final static String PATH_SEPARATOR = String.valueOf(IPath.SEPARATOR);
-
- private HashMap<IVirtualComponent, String> runtimePaths;
- private ArrayList<ComponentResourceProxy> resourceMappings;
- public ComponentDependencyContentProvider() {
- super();
- }
-
- public void setRuntimePaths(HashMap<IVirtualComponent, String> paths) {
- this.runtimePaths = paths;
- }
-
- public void setResourceMappings(ArrayList<ComponentResourceProxy> mappings) {
- this.resourceMappings = mappings;
- }
-
- public Object[] getElements(Object inputElement) {
- Object[] empty = new Object[0];
- if( !(inputElement instanceof IWorkspaceRoot))
- return empty;
- ArrayList<Object> list = new ArrayList<Object>();
- list.addAll(resourceMappings);
- list.addAll(runtimePaths.keySet());
- return list.toArray();
- }
-
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- public String getColumnText(Object element, int columnIndex) {
- if( element instanceof ComponentResourceProxy) {
- if( columnIndex == 0 )
- return ((ComponentResourceProxy)element).runtimePath.toString();
- else if( columnIndex == 1 )
- return ((ComponentResourceProxy)element).source.toString();
- }
- if (element instanceof IVirtualComponent) {
- IVirtualComponent comp = (IVirtualComponent)element;
- if (columnIndex == 0) {
- if( runtimePaths == null || runtimePaths.get(element) == null) {
- return new Path(PATH_SEPARATOR).toString();
- }
- return runtimePaths.get(element);
- } else if (columnIndex == 1) {
- if( comp.isBinary() && comp instanceof VirtualArchiveComponent) {
- IPath p = ((VirtualArchiveComponent)comp).getWorkspaceRelativePath();
- if( p == null )
- p = new Path(((VirtualArchiveComponent)comp).getUnderlyingDiskFile().getAbsolutePath());
- return p.toString();
- }
- return comp.getProject().getName();
- }
- } else if (element instanceof IProject){
- if (columnIndex == 0) {
- if( runtimePaths == null || runtimePaths.get(element) == null) {
- return new Path(PATH_SEPARATOR).toString();
- }
- return runtimePaths.get(element);
- } else {
- return ((IProject)element).getName();
- }
- }
- return null;
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-}
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/DependencyPageExtensionManager.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/DependencyPageExtensionManager.java 2009-07-27 18:37:50 UTC (rev 16825)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/DependencyPageExtensionManager.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -1,108 +0,0 @@
-package org.jboss.ide.eclipse.as.wtp.override.ui.propertypage;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.wst.common.project.facet.core.IFacetedProject;
-import org.eclipse.wst.server.ui.wizard.WizardFragment;
-import org.jboss.ide.eclipse.as.wtp.override.ui.WTPOveridePlugin;
-
-public class DependencyPageExtensionManager {
- private static DependencyPageExtensionManager manager = null;
- public static DependencyPageExtensionManager getManager() {
- if( manager == null )
- manager = new DependencyPageExtensionManager();
- return manager;
- }
-
- private HashMap<String, IDependencyPageProvider> providers = null;
-
- public IDependencyPageProvider getProvider(IFacetedProject project) {
- if( providers == null )
- loadProviders();
- Iterator<IDependencyPageProvider> i = providers.values().iterator();
- IDependencyPageProvider temp;
- while(i.hasNext()) {
- temp = i.next();
- if( temp.canHandle(project))
- return temp;
- }
- return null;
- }
-
- private void loadProviders() {
- HashMap<String, IDependencyPageProvider> temp = new HashMap<String, IDependencyPageProvider>();
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IConfigurationElement[] cf = registry.getConfigurationElementsFor(
- WTPOveridePlugin.PLUGIN_ID, "moduleDependencyPropertyPage"); //$NON-NLS-1$
- for( int i = 0; i < cf.length; i++ ) {
- try {
- temp.put(cf[i].getAttribute("id"), //$NON-NLS-1$
- (IDependencyPageProvider)cf[i].createExecutableExtension("class")); //$NON-NLS-1$
- } catch( CoreException ce ) {}
- }
- providers = temp;
- }
-
- public WizardFragment loadReferenceWizardFragment(String id) {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IConfigurationElement[] cf = registry.getConfigurationElementsFor(
- WTPOveridePlugin.PLUGIN_ID, "referenceWizardFragment"); //$NON-NLS-1$
- for( int i = 0; i < cf.length; i++ ) {
- if( cf[i].getAttribute("id").equals(id))
- try {
- return (WizardFragment)cf[i].createExecutableExtension("class");
- } catch( CoreException ce) {}
- }
- return null;
- }
-
- public ReferenceExtension[] getReferenceExtensions() {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IConfigurationElement[] cf = registry.getConfigurationElementsFor(
- WTPOveridePlugin.PLUGIN_ID, "referenceWizardFragment"); //$NON-NLS-1$
- ArrayList<ReferenceExtension> list = new ArrayList<ReferenceExtension>();
- for( int i = 0; i < cf.length; i++ ) {
- list.add(new ReferenceExtension(cf[i]));
- }
- return (ReferenceExtension[]) list
- .toArray(new ReferenceExtension[list.size()]);
- }
-
- public class ReferenceExtension {
- private IConfigurationElement element;
- private String id, name, imageLoc;
- private Image image;
- public ReferenceExtension(IConfigurationElement element) {
- this.element = element;
- this.id = element.getAttribute("id");
- this.name = element.getAttribute("name");
- this.imageLoc = element.getAttribute("icon");
- }
- public String getId() { return this.id;}
- public String getName() { return this.name; }
- public Image getImage() {
- if( image == null ) {
- if( imageLoc != null && element.getContributor().getName() != null) {
- ImageDescriptor desc = AbstractUIPlugin.imageDescriptorFromPlugin(element.getContributor().getName(), imageLoc);
- image = desc.createImage();
- }
- }
- return image;
- }
- public void disposeImage() {
- if( image != null ) {
- image.dispose();
- image = null;
- }
- }
- }
-}
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ExternalJarReferenceWizardFragment.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ExternalJarReferenceWizardFragment.java 2009-07-27 18:37:50 UTC (rev 16825)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ExternalJarReferenceWizardFragment.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -1,78 +0,0 @@
-package org.jboss.ide.eclipse.as.wtp.override.ui.propertypage;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jst.j2ee.project.facet.IJavaProjectMigrationDataModelProperties;
-import org.eclipse.jst.j2ee.project.facet.JavaProjectMigrationDataModelProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.ModuleCoreNature;
-import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.server.ui.wizard.IWizardHandle;
-import org.eclipse.wst.server.ui.wizard.WizardFragment;
-import org.jboss.ide.eclipse.as.wtp.override.core.vcf.ComponentUtils;
-
-public class ExternalJarReferenceWizardFragment extends JarReferenceWizardFragment {
- public Composite createComposite(Composite parent, IWizardHandle handle) {
- Composite c = super.createComposite(parent, handle);
- handle.setTitle("Add an External Jar Reference");
- handle.setDescription("Here you can reference a filesystem Jar\n"
- + "This is not a suggested use-case, but is here for backwards compatability.");
- return c;
- }
-
- protected void buttonPressed() {
- selected = BuildPathDialogAccess
- .chooseExternalJAREntries(browse.getShell());
- viewer.refresh();
- }
-
- public void performFinish(IProgressMonitor monitor) throws CoreException {
- IVirtualComponent rootComponent = (IVirtualComponent)getTaskModel().getObject(NewReferenceWizard.ROOT_COMPONENT);
- if (selected != null && selected.length > 0) {
- ArrayList<IVirtualComponent> compList = new ArrayList<IVirtualComponent>();
- ArrayList<String> paths = new ArrayList<String>();
- for (int i = 0; i < selected.length; i++) {
- // IPath fullPath = project.getFile(selected[i]).getFullPath();
- String type = VirtualArchiveComponent.LIBARCHIVETYPE
- + IPath.SEPARATOR;
- IVirtualComponent archive = ComponentCore
- .createArchiveComponent(rootComponent.getProject(),
- type + selected[i].toString());
- compList.add(archive);
- paths.add(selected[i].lastSegment());
- }
- IVirtualComponent[] components = (IVirtualComponent[]) compList.toArray(new IVirtualComponent[compList.size()]);
- String[] paths2 = (String[]) paths.toArray(new String[paths.size()]);
- getTaskModel().putObject(NewReferenceWizard.COMPONENT, components);
- getTaskModel().putObject(NewReferenceWizard.COMPONENT_PATH, paths2);
- }
- }
-}
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/IDependencyPageProvider.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/IDependencyPageProvider.java 2009-07-27 18:37:50 UTC (rev 16825)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/IDependencyPageProvider.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -1,10 +0,0 @@
-package org.jboss.ide.eclipse.as.wtp.override.ui.propertypage;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.wst.common.project.facet.core.IFacetedProject;
-
-public interface IDependencyPageProvider {
- public boolean canHandle(IFacetedProject project);
- public IModuleDependenciesControl[] createPages(IFacetedProject project, ModuleAssemblyRootPage parent);
- public Composite createRootControl(IModuleDependenciesControl[] pages, Composite parent);
-}
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/IModuleDependenciesControl.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/IModuleDependenciesControl.java 2009-07-27 18:37:50 UTC (rev 16825)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/IModuleDependenciesControl.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -1,42 +0,0 @@
-package org.jboss.ide.eclipse.as.wtp.override.ui.propertypage;
-
-import org.eclipse.swt.widgets.Composite;
-
-public interface IModuleDependenciesControl {
- /**
- * Creates the Composite associated with this control.
- * @param parent Parent Composite.
- * @return Composite for the control.
- */
- Composite createContents(Composite parent);
-
- /**
- * Called when the property page's <code>performOk()</code> method is called.
- * @return
- */
- boolean performOk();
-
- /**
- * Called when the property page's <code>performDefaults()</code> method is called.
- * @return
- */
- void performDefaults();
-
- /**
- * Called when the property page's <code>performCancel()</code> method is called.
- * @return
- */
- boolean performCancel();
-
- /**
- * Called when the property page's <code>setVisible()</code> method is called.
- * @return
- */
- void setVisible(boolean visible);
-
- /**
- * Called when the property page's <code>dispose()</code> method is called.
- * @return
- */
- void dispose();
-}
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/JarReferenceWizardFragment.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/JarReferenceWizardFragment.java 2009-07-27 18:37:50 UTC (rev 16825)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/JarReferenceWizardFragment.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -1,161 +0,0 @@
-package org.jboss.ide.eclipse.as.wtp.override.ui.propertypage;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jst.j2ee.project.facet.IJavaProjectMigrationDataModelProperties;
-import org.eclipse.jst.j2ee.project.facet.JavaProjectMigrationDataModelProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.ModuleCoreNature;
-import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.server.ui.wizard.IWizardHandle;
-import org.eclipse.wst.server.ui.wizard.WizardFragment;
-import org.jboss.ide.eclipse.as.wtp.override.core.vcf.ComponentUtils;
-
-public class JarReferenceWizardFragment extends WizardFragment {
- protected LabelProvider labelProvider = null;
- protected ITreeContentProvider contentProvider = null;
- protected TreeViewer viewer;
- protected Button browse;
- protected IPath[] paths;
- protected IWizardHandle handle;
- protected IPath[] selected = new IPath[]{};
- public boolean hasComposite() {
- return true;
- }
-
- public Composite createComposite(Composite parent, IWizardHandle handle) {
- this.handle = handle;
- handle.setTitle("Add a Jar Reference");
- handle.setDescription("Here you can reference a workspace Jar\n"
- + "This is not a suggested use-case, but is here for backwards compatability.");
-
- Composite c = new Composite(parent, SWT.NONE);
- c.setLayout(new FormLayout());
- viewer = new TreeViewer(c, SWT.SINGLE | SWT.BORDER);
- viewer.setContentProvider(getContentProvider());
- viewer.setLabelProvider(getLabelProvider());
- viewer.setInput(ResourcesPlugin.getWorkspace());
-
- browse = new Button(c, SWT.NONE);
- browse.setText("Browse...");
- FormData fd = new FormData();
- fd.left = new FormAttachment(0, 5);
- fd.bottom = new FormAttachment(100, -5);
- browse.setLayoutData(fd);
-
- fd = new FormData();
- fd.left = new FormAttachment(0, 5);
- fd.top = new FormAttachment(0, 5);
- fd.right = new FormAttachment(100, -5);
- fd.bottom = new FormAttachment(browse, -5);
- viewer.getTree().setLayoutData(fd);
-
- browse.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- buttonPressed();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
- });
- return c;
- }
-
- protected void buttonPressed() {
- IProject project = (IProject)getTaskModel().getObject(NewReferenceWizard.PROJECT);
- selected = BuildPathDialogAccess.chooseJAREntries(
- browse.getShell(),
- project.getLocation(), new IPath[0]);
- viewer.refresh();
- }
-
- public void performFinish(IProgressMonitor monitor) throws CoreException {
- IVirtualComponent rootComponent = (IVirtualComponent)getTaskModel().getObject(NewReferenceWizard.ROOT_COMPONENT);
- if (selected != null && selected.length > 0) {
- ArrayList<IVirtualComponent> compList = new ArrayList<IVirtualComponent>();
- ArrayList<String> paths = new ArrayList<String>();
- for (int i = 0; i < selected.length; i++) {
- // IPath fullPath = project.getFile(selected[i]).getFullPath();
- String type = VirtualArchiveComponent.LIBARCHIVETYPE
- + IPath.SEPARATOR;
- IVirtualComponent archive = ComponentCore
- .createArchiveComponent(rootComponent.getProject(),
- type + selected[i].makeRelative().toString());
- compList.add(archive);
- paths.add(selected[i].lastSegment());
- }
- IVirtualComponent[] components = (IVirtualComponent[]) compList.toArray(new IVirtualComponent[compList.size()]);
- String[] paths2 = (String[]) paths.toArray(new String[paths.size()]);
- getTaskModel().putObject(NewReferenceWizard.COMPONENT, components);
- getTaskModel().putObject(NewReferenceWizard.COMPONENT_PATH, paths2);
- }
- }
-
- protected LabelProvider getLabelProvider() {
- if (labelProvider == null) {
- labelProvider = new LabelProvider() {
- public Image getImage(Object element) {
- return null;
- }
-
- public String getText(Object element) {
- return element == null ? "" : element.toString();//$NON-NLS-1$
- }
- };
- }
- return labelProvider;
- }
-
- protected ITreeContentProvider getContentProvider() {
- if (contentProvider == null) {
- contentProvider = new ITreeContentProvider() {
- public Object[] getElements(Object inputElement) {
- return selected == null ? new Object[]{} : selected;
- }
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- public void dispose() {
- }
- public boolean hasChildren(Object element) {
- return false;
- }
- public Object getParent(Object element) {
- return null;
- }
- public Object[] getChildren(Object parentElement) {
- return null;
- }
- };
- }
- return contentProvider;
- }
-}
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ModuleAssemblyRootPage.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ModuleAssemblyRootPage.java 2009-07-27 18:37:50 UTC (rev 16825)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ModuleAssemblyRootPage.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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 implementation as prop page heirarchy
- * rfrost(a)bea.com - conversion to single property page impl
- *******************************************************************************/
-
-package org.jboss.ide.eclipse.as.wtp.override.ui.propertypage;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.dialogs.PropertyPage;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.project.facet.core.IFacetedProject;
-import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
-
-/**
- * Primary project property page for Module dependencies;
- */
-public class ModuleAssemblyRootPage extends PropertyPage {
-
- private IProject project;
- private IModuleDependenciesControl[] controls = new IModuleDependenciesControl[0];
-
- public ModuleAssemblyRootPage() {
- super();
- }
-
- private Composite getFacetErrorComposite(final Composite parent) {
- final String errorCheckingFacet = "Error Checking Project Facets";
- setErrorMessage(errorCheckingFacet);
- return getErrorComposite(parent, errorCheckingFacet);
- }
- private Composite getVirtCompErrorComposite(final Composite parent) {
- final String errorCheckingFacet = "The given project is not a virtual component project";
- setErrorMessage(errorCheckingFacet);
- return getErrorComposite(parent, errorCheckingFacet);
- }
-
-
- private Composite getErrorComposite(final Composite parent, final String error) {
- final Composite composite = new Composite(parent, SWT.NONE);
- final GridLayout layout = new GridLayout();
- layout.marginWidth = 0;
- layout.marginWidth = 0;
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- final Label label= new Label(composite, SWT.NONE);
- label.setText(error);
- return composite;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- public boolean performOk() {
- for (int i = 0; i < controls.length; i++) {
- if (controls[i] != null) {
- if (!controls[i].performOk()) {
- return false;
- }
- }
- }
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
- */
- public void performDefaults() {
- for (int i = 0; i < controls.length; i++) {
- if (controls[i] != null) {
- controls[i].performDefaults();
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.IPreferencePage#performCancel()
- */
- public boolean performCancel() {
- for (int i = 0; i < controls.length; i++) {
- if (controls[i] != null) {
- if (!controls[i].performCancel()) {
- return false;
- }
- }
- }
- return super.performCancel();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
- */
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- for (int i = 0; i < controls.length; i++) {
- if (controls[i] != null) {
- controls[i].setVisible(visible);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#dispose()
- */
- public void dispose() {
- super.dispose();
- for (int i = 0; i < controls.length; i++) {
- if(controls[i] != null){
- controls[i].dispose();
- }
- }
- }
-
- protected static void createDescriptionComposite(final Composite parent, final String description) {
- Composite descriptionComp = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- descriptionComp.setLayout(layout);
- descriptionComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fillDescription(descriptionComp, description);
- }
-
- private static void fillDescription(Composite c, String s) {
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = 250;
- Text text = new Text(c, SWT.READ_ONLY | SWT.WRAP);
- text.setLayoutData(data);
- text.setText(s);
- }
-
- protected Control createContents(Composite parent) {
-
- // Need to find out what type of project we are handling
- project = (IProject) getElement().getAdapter(IResource.class);
- if( project != null ) {
- try {
- IFacetedProject facetedProject = ProjectFacetsManager.create(project);
- IDependencyPageProvider provider = null;
- if( facetedProject == null )
- return getFacetErrorComposite(parent);
-
- provider = DependencyPageExtensionManager.getManager().getProvider(facetedProject);
- if( provider != null ) {
- controls = provider.createPages(facetedProject, this);
- return provider.createRootControl(controls, parent);
- }
-
- if( ComponentCore.createComponent(project) == null )
- return getVirtCompErrorComposite(parent);
-
- AddModuleDependenciesPropertiesPage page = new AddModuleDependenciesPropertiesPage(project, this);
- controls = new IModuleDependenciesControl[1];
- controls[0] = page;
- return page.createContents(parent);
- } catch( CoreException ce ) {
- }
- }
- return getFacetErrorComposite(parent);
- }
-}
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/NewReferenceRootWizardFragment.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/NewReferenceRootWizardFragment.java 2009-07-27 18:37:50 UTC (rev 16825)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/NewReferenceRootWizardFragment.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -1,148 +0,0 @@
-package org.jboss.ide.eclipse.as.wtp.override.ui.propertypage;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.wst.server.ui.wizard.IWizardHandle;
-import org.eclipse.wst.server.ui.wizard.WizardFragment;
-import org.jboss.ide.eclipse.as.wtp.override.ui.propertypage.DependencyPageExtensionManager.ReferenceExtension;
-
-public class NewReferenceRootWizardFragment extends WizardFragment {
- protected Map<String, WizardFragment> fragmentMap =
- new HashMap<String, WizardFragment>();
- private IWizardHandle wizard;
- private TreeViewer viewer;
- public boolean hasComposite() {
- return true;
- }
-
- public Composite createComposite(Composite parent, IWizardHandle wizard) {
- this.wizard = wizard;
- wizard.setTitle("Select a reference type");
- wizard.setDescription("Here you can select one of many types of references to add");
- Composite c = new Composite(parent, SWT.NONE);
- c.setLayout(new FillLayout());
- viewer = new TreeViewer(c, SWT.SINGLE | SWT.BORDER);
- viewer.setLabelProvider(getLabelProvider());
- viewer.setContentProvider(getContentProvider());
- viewer.setInput(ResourcesPlugin.getWorkspace());
- viewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- viewerSelectionChanged();
- }
- });
- return c;
- }
-
- protected void viewerSelectionChanged() {
- wizard.update();
- }
-
- protected WizardFragment getWizardFragment(String extensionPointID) {
- try {
- WizardFragment fragment = fragmentMap.get(extensionPointID);
- if (fragment != null)
- return fragment;
- } catch (Exception e) {
- // ignore
- }
-
- WizardFragment fragment = DependencyPageExtensionManager.getManager().loadReferenceWizardFragment(extensionPointID);
- if (fragment != null)
- fragmentMap.put(extensionPointID, fragment);
- return fragment;
- }
-
- public List getChildFragments() {
- List<WizardFragment> listImpl = new ArrayList<WizardFragment>();
- createChildFragments(listImpl);
- return listImpl;
- }
-
- protected void createChildFragments(List<WizardFragment> list) {
- // Instantiate and add the fragment for the current ID
- if( viewer != null ) {
- IStructuredSelection sel = (IStructuredSelection)viewer.getSelection();
- ReferenceExtension selected = (ReferenceExtension)sel.getFirstElement();
- if( selected != null ) {
- WizardFragment child = getWizardFragment(selected.getId());
- if( child != null )
- list.add(child);
- }
- }
- }
-
- public boolean isComplete() {
- return true;
- }
-
-
- private LabelProvider labelProvider = null;
- private ITreeContentProvider contentProvider = null;
- protected LabelProvider getLabelProvider() {
- if( labelProvider == null ) {
- labelProvider = new LabelProvider() {
- public Image getImage(Object element) {
- if( element instanceof ReferenceExtension)
- return ((ReferenceExtension)element).getImage();
- return null;
- }
- public String getText(Object element) {
- if( element instanceof ReferenceExtension)
- return ((ReferenceExtension)element).getName();
- return element == null ? "" : element.toString();//$NON-NLS-1$
- }
- public void dispose() {
- super.dispose();
- if( extensions != null ) {
- for( int i = 0; i < extensions.length; i++) {
- extensions[i].disposeImage();
- }
- }
- }
- };
- }
- return labelProvider;
- }
-
- private ReferenceExtension[] extensions = null;
- protected ITreeContentProvider getContentProvider() {
- if( contentProvider == null ) {
- contentProvider = new ITreeContentProvider() {
- public Object[] getElements(Object inputElement) {
- if( extensions == null )
- extensions = DependencyPageExtensionManager.getManager().getReferenceExtensions();
- return extensions;
- }
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- public void dispose() {
- }
- public boolean hasChildren(Object element) {
- return false;
- }
- public Object getParent(Object element) {
- return null;
- }
- public Object[] getChildren(Object parentElement) {
- return null;
- }
- };
- }
- return contentProvider;
- }
-}
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/NewReferenceWizard.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/NewReferenceWizard.java 2009-07-27 18:37:50 UTC (rev 16825)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/NewReferenceWizard.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -1,28 +0,0 @@
-package org.jboss.ide.eclipse.as.wtp.override.ui.propertypage;
-
-import java.util.List;
-
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.wst.server.ui.internal.wizard.TaskWizard;
-import org.eclipse.wst.server.ui.wizard.WizardFragment;
-
-public class NewReferenceWizard extends TaskWizard {
-
- public static final String COMPONENT = "dependency.component";
- public static final String COMPONENT_PATH = "dependency.component.path";
- public static final String PROJECT = "root.project";
- public static final String ROOT_COMPONENT = "root.component";
-
- public NewReferenceWizard() {
- super("New Reference Wizard", new WizardFragment() {
- protected void createChildFragments(List<WizardFragment> list) {
- list.add(new NewReferenceRootWizardFragment());
- }
- });
- }
-
- public void init(IWorkbench newWorkbench, IStructuredSelection newSelection) {
- // do nothing
- }
-}
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ProjectReferenceWizardFragment.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ProjectReferenceWizardFragment.java 2009-07-27 18:37:50 UTC (rev 16825)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ProjectReferenceWizardFragment.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -1,145 +0,0 @@
-package org.jboss.ide.eclipse.as.wtp.override.ui.propertypage;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jst.j2ee.project.facet.IJavaProjectMigrationDataModelProperties;
-import org.eclipse.jst.j2ee.project.facet.JavaProjectMigrationDataModelProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.ModuleCoreNature;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.server.ui.wizard.IWizardHandle;
-import org.eclipse.wst.server.ui.wizard.WizardFragment;
-import org.jboss.ide.eclipse.as.wtp.override.core.vcf.ComponentUtils;
-
-public class ProjectReferenceWizardFragment extends WizardFragment {
- private LabelProvider labelProvider = null;
- private ITreeContentProvider contentProvider = null;
- private TreeViewer viewer;
- private IProject selected;
-
- public boolean hasComposite() {
- return true;
- }
-
- public Composite createComposite(Composite parent, IWizardHandle handle) {
- handle.setTitle("Add a Project Reference");
- handle.setDescription("Here you can make a project into a reference.\n" +
- "If the project is not already a flexible project, it will be converted into one.");
-
- Composite c = new Composite(parent, SWT.NONE);
- c.setLayout(new FillLayout());
- viewer = new TreeViewer(c, SWT.SINGLE | SWT.BORDER);
- viewer.setContentProvider(getContentProvider());
- viewer.setLabelProvider(getLabelProvider());
- viewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- selChanged();
- }
- });
- viewer.setInput(ResourcesPlugin.getWorkspace());
- return c;
- }
-
- private void selChanged() {
- if( viewer != null ) {
- IStructuredSelection sel = (IStructuredSelection)viewer.getSelection();
- if( sel != null )
- selected = (IProject)sel.getFirstElement();
- }
- }
-
- public void performFinish(IProgressMonitor monitor) throws CoreException {
- if( !ModuleCoreNature.isFlexibleProject(selected)) {
- try {
- IDataModel migrationdm = DataModelFactory.createDataModel(new JavaProjectMigrationDataModelProvider());
- migrationdm.setProperty(IJavaProjectMigrationDataModelProperties.PROJECT_NAME, selected.getName());
- migrationdm.getDefaultOperation().execute(new NullProgressMonitor(), null);
- } catch( ExecutionException ee) {
- // TODO something
- }
- }
- IVirtualComponent comp = ComponentCore.createComponent(selected);
- String path = selected.getName();
- String extension = ComponentUtils.getDefaultProjectExtension(comp);
- path += extension;
-
- getTaskModel().putObject(NewReferenceWizard.COMPONENT, comp);
- getTaskModel().putObject(NewReferenceWizard.COMPONENT_PATH, path);
- }
-
-
- protected LabelProvider getLabelProvider() {
- if( labelProvider == null ) {
- labelProvider = new LabelProvider() {
- public Image getImage(Object element) {
- return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_PROJECT);
- }
- public String getText(Object element) {
- if( element instanceof IProject )
- return ((IProject)element).getName();
- return element == null ? "" : element.toString();//$NON-NLS-1$
- }
- };
- }
- return labelProvider;
- }
-
- protected ITreeContentProvider getContentProvider() {
- if( contentProvider == null ) {
- contentProvider = new ITreeContentProvider() {
- public Object[] getElements(Object inputElement) {
- IProject root = (IProject)getTaskModel().getObject(NewReferenceWizard.PROJECT);
- IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- ArrayList<IProject> list = new ArrayList<IProject>(Arrays.asList(projects));
- Iterator<IProject> i = list.iterator();
- IProject p;
- while(i.hasNext()) {
- p = i.next();
- if( !p.isOpen())
- i.remove();
- else if( p.equals(root))
- i.remove();
- }
- return (IProject[]) list.toArray(new IProject[list.size()]);
- }
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- public void dispose() {
- }
- public boolean hasChildren(Object element) {
- return false;
- }
- public Object getParent(Object element) {
- return null;
- }
- public Object[] getChildren(Object parentElement) {
- return null;
- }
- };
- }
- return contentProvider;
- }
-}
Deleted: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/VariableReferenceWizardFragment.java
===================================================================
--- workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/VariableReferenceWizardFragment.java 2009-07-27 18:37:50 UTC (rev 16825)
+++ workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/VariableReferenceWizardFragment.java 2009-07-27 18:51:58 UTC (rev 16826)
@@ -1,56 +0,0 @@
-package org.jboss.ide.eclipse.as.wtp.override.ui.propertypage;
-
-import java.util.ArrayList;
-
-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.jdt.core.JavaCore;
-import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.server.ui.wizard.IWizardHandle;
-
-public class VariableReferenceWizardFragment extends JarReferenceWizardFragment {
- public Composite createComposite(Composite parent, IWizardHandle handle) {
- Composite c = super.createComposite(parent, handle);
- handle.setTitle("Add a Variable Reference");
- handle.setDescription("Here you can reference a variable which maps to a single jar.\n"
- + "This is not a suggested use-case, but is here for backwards compatability.");
- return c;
- }
-
- protected void buttonPressed() {
- selected = BuildPathDialogAccess.chooseVariableEntries(
- browse.getShell(), new Path[0]);
- viewer.refresh();
- }
-
- public void performFinish(IProgressMonitor monitor) throws CoreException {
- IVirtualComponent rootComponent = (IVirtualComponent)getTaskModel().getObject(NewReferenceWizard.ROOT_COMPONENT);
- if (selected != null && selected.length > 0) {
- ArrayList<IVirtualComponent> compList = new ArrayList<IVirtualComponent>();
- ArrayList<String> paths = new ArrayList<String>();
- for (int i = 0; i < selected.length; i++) {
- IPath resolvedPath = JavaCore.getResolvedVariablePath(selected[i]);
- java.io.File file = new java.io.File(resolvedPath.toOSString());
- if (file.isFile() && file.exists()) {
- String type = VirtualArchiveComponent.VARARCHIVETYPE
- + IPath.SEPARATOR;
- IVirtualComponent archive = ComponentCore
- .createArchiveComponent(rootComponent.getProject(),
- type + selected[i].toString());
- compList.add(archive);
- paths.add(resolvedPath.lastSegment());
- }
- }
- IVirtualComponent[] components = (IVirtualComponent[]) compList.toArray(new IVirtualComponent[compList.size()]);
- String[] paths2 = (String[]) paths.toArray(new String[paths.size()]);
- getTaskModel().putObject(NewReferenceWizard.COMPONENT, components);
- getTaskModel().putObject(NewReferenceWizard.COMPONENT_PATH, paths2);
- }
- }
-}
15 years, 5 months
JBoss Tools SVN: r16825 - workspace/rstryker/wtpPropertyPageContrib.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2009-07-27 14:37:50 -0400 (Mon, 27 Jul 2009)
New Revision: 16825
Added:
workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui/
Log:
copying to workspace
Copied: workspace/rstryker/wtpPropertyPageContrib/org.eclipse.wst.common.componentcore.ui (from rev 16824, trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui)
15 years, 5 months
JBoss Tools SVN: r16824 - workspace/rstryker.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2009-07-27 14:28:14 -0400 (Mon, 27 Jul 2009)
New Revision: 16824
Added:
workspace/rstryker/wtpPropertyPageContrib/
Log:
new folder in workspace
15 years, 5 months
JBoss Tools SVN: r16823 - workspace/rstryker.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2009-07-27 14:27:28 -0400 (Mon, 27 Jul 2009)
New Revision: 16823
Removed:
workspace/rstryker/event_refactor/
Log:
fiddling in workspace
15 years, 5 months
JBoss Tools SVN: r16822 - in trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors: popup and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: vyemialyanchyk
Date: 2009-07-27 13:54:15 -0400 (Mon, 27 Jul 2009)
New Revision: 16822
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ExpandeableShapeTreeEditPart.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ShapeTreeEditPart.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/popup/PopupMenuProvider.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4621 - fixed
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ExpandeableShapeTreeEditPart.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ExpandeableShapeTreeEditPart.java 2009-07-27 15:40:13 UTC (rev 16821)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ExpandeableShapeTreeEditPart.java 2009-07-27 17:54:15 UTC (rev 16822)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.parts;
import java.beans.PropertyChangeEvent;
@@ -12,6 +22,9 @@
import org.jboss.tools.hibernate.ui.diagram.editors.model.Shape;
import org.jboss.tools.hibernate.ui.view.OrmLabelProvider;
+/**
+ *
+ */
public class ExpandeableShapeTreeEditPart extends
org.eclipse.gef.editparts.AbstractTreeEditPart implements
PropertyChangeListener {
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ShapeTreeEditPart.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ShapeTreeEditPart.java 2009-07-27 15:40:13 UTC (rev 16821)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/ShapeTreeEditPart.java 2009-07-27 17:54:15 UTC (rev 16822)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.parts;
import java.beans.PropertyChangeEvent;
@@ -11,6 +21,9 @@
import org.jboss.tools.hibernate.ui.diagram.editors.model.Shape;
import org.jboss.tools.hibernate.ui.view.OrmLabelProvider;
+/**
+ *
+ */
public class ShapeTreeEditPart extends
org.eclipse.gef.editparts.AbstractTreeEditPart implements
PropertyChangeListener {
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/popup/PopupMenuProvider.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/popup/PopupMenuProvider.java 2009-07-27 15:40:13 UTC (rev 16821)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/popup/PopupMenuProvider.java 2009-07-27 17:54:15 UTC (rev 16822)
@@ -12,6 +12,7 @@
import org.eclipse.gef.ContextMenuProvider;
import org.eclipse.gef.EditPartViewer;
+import org.eclipse.gef.editparts.AbstractTreeEditPart;
import org.eclipse.gef.ui.actions.ActionRegistry;
import org.eclipse.gef.ui.actions.GEFActionConstants;
import org.eclipse.jface.action.IAction;
@@ -39,7 +40,7 @@
import org.jboss.tools.hibernate.ui.diagram.editors.parts.OrmEditPart;
/**
- *
+ * Context menu provider for Diagram Viewer and Diagram Outline.
*/
public class PopupMenuProvider extends ContextMenuProvider {
private ActionRegistry actionRegistry;
@@ -56,26 +57,37 @@
menu.add(new Separator(GEFActionConstants.MB_ADDITIONS));
IAction action = null;
if (getViewer().getSelection() instanceof StructuredSelection) {
+ Shape selectedShape = null;
IStructuredSelection selection = (IStructuredSelection) getViewer().getSelection();
- if (selection != null && selection.getFirstElement() instanceof OrmEditPart) {
- Object obj = ((OrmEditPart)selection.getFirstElement()).getModel();
- if (null != obj && obj instanceof Shape) {
- Shape shape = (Shape)obj;
- Object first = shape.getOrmElement();
- if (first instanceof PersistentClass
- || first.getClass() == Property.class
- || first instanceof Table
- || first instanceof Column) {
- action = getActionRegistry().getAction(OpenSourceAction.ACTION_ID);
- appendToGroup(GEFActionConstants.MB_ADDITIONS, action);
- createMenuItem(getMenu(), action);
-
- action = getActionRegistry().getAction(OpenMappingAction.ACTION_ID);
- appendToGroup(GEFActionConstants.MB_ADDITIONS, action);
- createMenuItem(getMenu(), action);
+ if (selection != null) {
+ Object firstElement = selection.getFirstElement();
+ if (firstElement instanceof OrmEditPart) {
+ Object obj = ((OrmEditPart)firstElement).getModel();
+ if (null != obj && obj instanceof Shape) {
+ selectedShape = (Shape)obj;
+ }
+ } else if (firstElement instanceof AbstractTreeEditPart) {
+ Object obj = ((AbstractTreeEditPart)firstElement).getModel();
+ if (null != obj && obj instanceof Shape) {
+ selectedShape = (Shape)obj;
}
- }
+ }
}
+ if (selectedShape != null) {
+ Object first = selectedShape.getOrmElement();
+ if (first instanceof PersistentClass
+ || first.getClass() == Property.class
+ || first instanceof Table
+ || first instanceof Column) {
+ action = getActionRegistry().getAction(OpenSourceAction.ACTION_ID);
+ appendToGroup(GEFActionConstants.MB_ADDITIONS, action);
+ createMenuItem(getMenu(), action);
+
+ action = getActionRegistry().getAction(OpenMappingAction.ACTION_ID);
+ appendToGroup(GEFActionConstants.MB_ADDITIONS, action);
+ createMenuItem(getMenu(), action);
+ }
+ }
}
action = getActionRegistry().getAction(AutoLayoutAction.ACTION_ID);
15 years, 5 months
JBoss Tools SVN: r16821 - trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2009-07-27 11:40:13 -0400 (Mon, 27 Jul 2009)
New Revision: 16821
Modified:
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/PropertiesSection.java
Log:
//quick fix to solve appearing 2 scrolbars
Modified: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/PropertiesSection.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/PropertiesSection.java 2009-07-27 15:27:07 UTC (rev 16820)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/PropertiesSection.java 2009-07-27 15:40:13 UTC (rev 16821)
@@ -12,6 +12,7 @@
package org.jboss.tools.jst.css.properties;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyComposite;
import org.jboss.tools.jst.jsp.outline.cssdialog.tabs.BaseTabControl;
import org.jboss.tools.jst.jsp.outline.cssdialog.tabs.TabPropertySheetControl;
@@ -24,7 +25,10 @@
@Override
public BaseTabControl createSectionControl(Composite parent) {
+ //quick fix to solve appearing 2 scrollbars
+ ((TabbedPropertyComposite)getTabComposite()).getScrolledComposite().setExpandVertical(false);
return new TabPropertySheetControl(parent, getStyleAttributes(),
getBindingContext());
+
}
}
15 years, 5 months
JBoss Tools SVN: r16820 - trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/el.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-07-27 11:27:07 -0400 (Mon, 27 Jul 2009)
New Revision: 16820
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/el/AbstractELCompletionEngine.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2016
In case of collection and maps default EL parser used for JSF is extended to understand access to elements like iterator().next().
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/el/AbstractELCompletionEngine.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/el/AbstractELCompletionEngine.java 2009-07-27 15:23:22 UTC (rev 16819)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/el/AbstractELCompletionEngine.java 2009-07-27 15:27:07 UTC (rev 16820)
@@ -30,6 +30,8 @@
import org.jboss.tools.common.el.core.model.ELObjectType;
import org.jboss.tools.common.el.core.model.ELPropertyInvocation;
import org.jboss.tools.common.el.core.parser.ELParser;
+import org.jboss.tools.common.el.core.parser.ELParserFactory;
+import org.jboss.tools.common.el.core.parser.ELParserUtil;
import org.jboss.tools.common.el.core.parser.LexicalToken;
import org.jboss.tools.common.el.core.resolver.ELCompletionEngine;
import org.jboss.tools.common.el.core.resolver.ELContext;
@@ -135,9 +137,13 @@
}
public ELExpression parseOperand(String operand) {
+ return parseOperand(operand, getParserFactory());
+ }
+
+ public ELExpression parseOperand(String operand, ELParserFactory factory) {
if(operand == null) return null;
String el = (operand.indexOf("#{") < 0 && operand.indexOf("${") < 0) ? "#{" + operand + "}" : operand; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- ELParser p = getParserFactory().createParser();
+ ELParser p = factory.createParser();
ELModel model = p.parse(el);
List<ELInstance> is = model.getInstances();
if(is.isEmpty()) return null;
@@ -204,7 +210,11 @@
if(prefixWasChanged && isArray) {
member.setDataModel(true);
}
- ELExpression newOperand = (prefixWasChanged) ? parseOperand(newEl) : operand;
+ ELExpression newOperand = (prefixWasChanged)
+ ? ((suffix.length() > 0 && getParserFactory() == ELParserUtil.getDefaultFactory())
+ ? parseOperand(newEl, ELParserUtil.getCollectionFactory())
+ : parseOperand(newEl))
+ : operand;
ELOperandResolveStatus status = resolveELOperand(file, newOperand, returnEqualedVariablesOnly, prefixWasChanged);
15 years, 5 months
JBoss Tools SVN: r16819 - trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-07-27 11:23:22 -0400 (Mon, 27 Jul 2009)
New Revision: 16819
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParserUtil.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/TokenizerFactory.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2016
In case of collection and maps default EL parser used for JSF is extended to understand access to elements like iterator().next().
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParserUtil.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParserUtil.java 2009-07-27 15:03:34 UTC (rev 16818)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParserUtil.java 2009-07-27 15:23:22 UTC (rev 16819)
@@ -42,6 +42,29 @@
return DEFAULT_FACTORY;
}
+ private static ELParserFactory COLLECTION_FACTORY = new DefaultFactory() {
+ public ELParser newParser() {
+ return new DefaultParser() {
+ protected Tokenizer createTokenizer() {
+ return TokenizerFactory.createCollectionTokenizer();
+ }
+ public void dispose() {
+ super.dispose();
+ release(this);
+ }
+ };
+ }
+ };
+
+ /**
+ * Extends default factory by ability to parse method invocation without parameters
+ * to support access to collection and map elements by .iterator().next()
+ * @return
+ */
+ public static ELParserFactory getCollectionFactory() {
+ return COLLECTION_FACTORY;
+ }
+
private static ELParserFactory JBOSS_FACTORY = new DefaultFactory() {
public ELParser newParser() {
return new DefaultParser() {
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/TokenizerFactory.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/TokenizerFactory.java 2009-07-27 15:03:34 UTC (rev 16818)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/TokenizerFactory.java 2009-07-27 15:23:22 UTC (rev 16819)
@@ -11,6 +11,7 @@
package org.jboss.tools.common.el.core.parser;
import java.util.List;
+import java.util.regex.Pattern;
import org.jboss.tools.common.el.core.model.ELExpression;
import org.jboss.tools.common.el.core.model.ELInvocationExpression;
@@ -105,7 +106,35 @@
return t;
}
+ //Adds to default description set param start and param end to support access to collection and map elements.
+ private static ITokenDescription[] COLLECTIONS_DESCRIPTION_SET = new ITokenDescription[] {
+ ArgEndTokenDescription.INSTANCE,
+ ArgStartTokenDescription.INSTANCE,
+ DotTokenDescription.INSTANCE,
+ EndELTokenDescription.INSTANCE,
+ JavaNameTokenDescription.INSTANCE,
+ OperationTokenDescription.INSTANCE,
+ ParamEndTokenDescription.INSTANCE,
+ ParamStartTokenDescription.INSTANCE,
+ UnaryTokenDescription.INSTANCE,
+ PrimitiveValueTokenDescription.INSTANCE,
+ StartELTokenDescription.INSTANCE,
+ StringTokenDescription.INSTANCE,
+ WhiteSpaceTokenDescription.INSTANCE,
+ };
+
+ public static Tokenizer createCollectionTokenizer() {
+ Tokenizer t = new Tokenizer();
+ t.setTokenDescriptions(COLLECTIONS_DESCRIPTION_SET);
+ t.setRules(DEFAULT_RULE_SET);
+ return t;
+ }
+
+
public static void main(String[] args) {
+ boolean b = Pattern.matches("re(he|ma)*\\sat", "rehemahe at");
+ System.out.println(b);
+ if(true) return;
String text = "ioioio#{a(1.2e1i) + b c + d}ioioio#{0}"; //$NON-NLS-1$
//"#{a[b()['l'].j]}";
//"#{g11.g12.y13} #{#{ #{a14.b15(x.t.u(uu.ii[9], j)).b16(m17(v18(i19[2]).u20).)+ a21(c.).b.}";
15 years, 5 months