|
Lines 12-18
Link Here
|
| 12 |
package org.eclipse.jst.j2ee.internal.common.classpath; |
12 |
package org.eclipse.jst.j2ee.internal.common.classpath; |
| 13 |
|
13 |
|
| 14 |
import java.util.List; |
14 |
import java.util.List; |
| 15 |
|
|
|
| 16 |
import org.eclipse.core.resources.IProject; |
15 |
import org.eclipse.core.resources.IProject; |
| 17 |
import org.eclipse.core.runtime.CoreException; |
16 |
import org.eclipse.core.runtime.CoreException; |
| 18 |
import org.eclipse.core.runtime.IPath; |
17 |
import org.eclipse.core.runtime.IPath; |
|
Lines 23-32
Link Here
|
| 23 |
import org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider; |
22 |
import org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider; |
| 24 |
import org.eclipse.jst.common.project.facet.core.libprov.LibraryProviderFramework; |
23 |
import org.eclipse.jst.common.project.facet.core.libprov.LibraryProviderFramework; |
| 25 |
import org.eclipse.jst.common.project.facet.core.libprov.user.UserLibraryProviderInstallOperationConfig; |
24 |
import org.eclipse.jst.common.project.facet.core.libprov.user.UserLibraryProviderInstallOperationConfig; |
|
|
25 |
import org.eclipse.jst.j2ee.classpathdep.ClasspathDependencyUtil; |
| 26 |
import org.eclipse.jst.j2ee.classpathdep.IClasspathDependencyConstants; |
26 |
import org.eclipse.jst.j2ee.classpathdep.IClasspathDependencyConstants; |
|
|
27 |
import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants; |
| 27 |
import org.eclipse.wst.common.project.facet.core.IFacetedProjectBase; |
28 |
import org.eclipse.wst.common.project.facet.core.IFacetedProjectBase; |
| 28 |
import org.eclipse.wst.common.project.facet.core.IProjectFacet; |
29 |
import org.eclipse.wst.common.project.facet.core.IProjectFacet; |
| 29 |
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; |
30 |
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; |
|
|
31 |
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; |
| 32 |
import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent; |
| 33 |
import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener; |
| 30 |
|
34 |
|
| 31 |
/** |
35 |
/** |
| 32 |
* @author <a href="mailto:konstantin.komissarchik@oracle.com">Konstantin Komissarchik</a> |
36 |
* @author <a href="mailto:konstantin.komissarchik@oracle.com">Konstantin Komissarchik</a> |
|
Lines 37-60
Link Here
|
| 37 |
extends UserLibraryProviderInstallOperationConfig |
41 |
extends UserLibraryProviderInstallOperationConfig |
| 38 |
|
42 |
|
| 39 |
{ |
43 |
{ |
|
|
44 |
private static final IProjectFacet WEB_FACET |
| 45 |
= ProjectFacetsManager.getProjectFacet( IJ2EEFacetConstants.DYNAMIC_WEB ); |
| 46 |
|
| 40 |
private static final String CLASS_NAME |
47 |
private static final String CLASS_NAME |
| 41 |
= WtpUserLibraryProviderInstallOperationConfig.class.getName(); |
48 |
= WtpUserLibraryProviderInstallOperationConfig.class.getName(); |
| 42 |
|
49 |
|
| 43 |
public static final String PROP_INCLUDE_WITH_APPLICATION_ENABLED |
50 |
public static final String PROP_INCLUDE_WITH_APPLICATION_ENABLED |
| 44 |
= CLASS_NAME + ".INCLUDE_WITH_APPLICATION_ENABLED"; //$NON-NLS-1$ |
51 |
= CLASS_NAME + ".INCLUDE_WITH_APPLICATION_ENABLED"; //$NON-NLS-1$ |
| 45 |
|
52 |
|
| 46 |
private boolean includeWithApplication = true; |
53 |
private boolean includeWithApplicationEnabled; |
|
|
54 |
|
| 55 |
public static final String PROP_INCLUDE_WITH_APPLICATION_SETTING_ENABLED |
| 56 |
= CLASS_NAME + ".INCLUDE_WITH_APPLICATION_SETTING_ENABLED"; //$NON-NLS-1$ |
| 57 |
|
| 58 |
private boolean includeWithApplicationSettingEnabled; |
| 47 |
|
59 |
|
| 48 |
public boolean isIncludeWithApplicationEnabled() |
60 |
public boolean isIncludeWithApplicationEnabled() |
| 49 |
{ |
61 |
{ |
| 50 |
return this.includeWithApplication; |
62 |
return this.includeWithApplicationEnabled; |
|
|
63 |
} |
| 64 |
|
| 65 |
public void setIncludeWithApplicationEnabled( final boolean value ) |
| 66 |
{ |
| 67 |
final boolean oldValue = this.includeWithApplicationEnabled; |
| 68 |
this.includeWithApplicationEnabled = value; |
| 69 |
notifyListeners( PROP_INCLUDE_WITH_APPLICATION_ENABLED, oldValue, this.includeWithApplicationEnabled ); |
| 70 |
} |
| 71 |
|
| 72 |
public boolean isIncludeWithApplicationSettingEnabled() |
| 73 |
{ |
| 74 |
return this.includeWithApplicationSettingEnabled; |
| 51 |
} |
75 |
} |
| 52 |
|
76 |
|
| 53 |
public void setIncludeWithApplicationEnabled( final boolean includeWithApplication ) |
77 |
public void setIncludeWithApplicationSettingEnabled( final boolean value ) |
| 54 |
{ |
78 |
{ |
| 55 |
final boolean oldValue = this.includeWithApplication; |
79 |
final boolean oldValue = this.includeWithApplicationSettingEnabled; |
| 56 |
this.includeWithApplication = includeWithApplication; |
80 |
this.includeWithApplicationSettingEnabled = value; |
| 57 |
notifyListeners( PROP_INCLUDE_WITH_APPLICATION_ENABLED, oldValue, this.includeWithApplication ); |
81 |
notifyListeners( PROP_INCLUDE_WITH_APPLICATION_SETTING_ENABLED, oldValue, this.includeWithApplicationSettingEnabled ); |
| 58 |
} |
82 |
} |
| 59 |
|
83 |
|
| 60 |
@Override |
84 |
@Override |
|
Lines 64-70
Link Here
|
| 64 |
{ |
88 |
{ |
| 65 |
super.init( fproj, fv, provider ); |
89 |
super.init( fproj, fv, provider ); |
| 66 |
|
90 |
|
| 67 |
this.includeWithApplication = true; |
91 |
this.includeWithApplicationEnabled = isModuleFaceted( fproj ); |
| 68 |
|
92 |
|
| 69 |
final IProject project = fproj.getProject(); |
93 |
final IProject project = fproj.getProject(); |
| 70 |
|
94 |
|
|
Lines 77-100
Link Here
|
| 77 |
|
101 |
|
| 78 |
if( currentProvider == provider ) |
102 |
if( currentProvider == provider ) |
| 79 |
{ |
103 |
{ |
| 80 |
final List<IClasspathEntry> entries; |
104 |
this.includeWithApplicationEnabled = getIncludeWithApplicationSetting( project, f); |
| 81 |
|
105 |
} |
| 82 |
try |
106 |
} |
| 83 |
{ |
107 |
|
| 84 |
entries = ClasspathUtil.getClasspathEntries( project, f ); |
108 |
this.includeWithApplicationSettingEnabled |
| 85 |
} |
109 |
= ( this.includeWithApplicationEnabled ) ? true : isModuleFaceted( fproj ); |
| 86 |
catch( CoreException e ) |
110 |
|
| 87 |
{ |
111 |
IFacetedProjectListener listener = new IFacetedProjectListener() |
| 88 |
throw new RuntimeException( e ); |
112 |
{ |
| 89 |
} |
113 |
public void handleEvent( final IFacetedProjectEvent event ) |
| 90 |
|
114 |
{ |
| 91 |
this.includeWithApplication = getIncludeWithApplicationSetting( entries ); |
115 |
final boolean moduleFaceted = isModuleFaceted( event.getWorkingCopy() ); |
|
|
116 |
setIncludeWithApplicationEnabled( moduleFaceted ); |
| 117 |
setIncludeWithApplicationSettingEnabled( moduleFaceted ); |
| 118 |
} |
| 119 |
}; |
| 120 |
|
| 121 |
fproj.addListener( listener, IFacetedProjectEvent.Type.PROJECT_FACETS_CHANGED ); |
| 122 |
} |
| 123 |
|
| 124 |
protected boolean isModuleFaceted( final IFacetedProjectBase fproj ) { |
| 125 |
for( IProjectFacetVersion facetVersion : fproj.getProjectFacets() ) |
| 126 |
{ |
| 127 |
if( ProjectFacetsManager.getGroup( "modules" ).getMembers().contains( facetVersion ) ) //$NON-NLS-1$ |
| 128 |
{ |
| 129 |
return true; |
| 92 |
} |
130 |
} |
| 93 |
} |
131 |
} |
|
|
132 |
return false; |
| 94 |
} |
133 |
} |
| 95 |
|
134 |
|
| 96 |
private static boolean getIncludeWithApplicationSetting( final List<IClasspathEntry> entries ) |
135 |
private static boolean getIncludeWithApplicationSetting( final IProject proj, final IProjectFacet f ) |
| 97 |
{ |
136 |
{ |
|
|
137 |
final List<IClasspathEntry> entries; |
| 138 |
|
| 139 |
try |
| 140 |
{ |
| 141 |
entries = ClasspathUtil.getClasspathEntries( proj, f ); |
| 142 |
} |
| 143 |
catch( CoreException e ) |
| 144 |
{ |
| 145 |
throw new RuntimeException( e ); |
| 146 |
} |
| 147 |
|
| 98 |
for( IClasspathEntry cpe : entries ) |
148 |
for( IClasspathEntry cpe : entries ) |
| 99 |
{ |
149 |
{ |
| 100 |
if( cpe.getEntryKind() == IClasspathEntry.CPE_CONTAINER ) |
150 |
if( cpe.getEntryKind() == IClasspathEntry.CPE_CONTAINER ) |
|
Lines 105-121
Link Here
|
| 105 |
{ |
155 |
{ |
| 106 |
for( IClasspathAttribute attr : cpe.getExtraAttributes() ) |
156 |
for( IClasspathAttribute attr : cpe.getExtraAttributes() ) |
| 107 |
{ |
157 |
{ |
| 108 |
if( attr.getName().equals( IClasspathDependencyConstants.CLASSPATH_COMPONENT_NON_DEPENDENCY ) ) |
158 |
if( attr.getName().equals( IClasspathDependencyConstants.CLASSPATH_COMPONENT_DEPENDENCY ) ) |
| 109 |
{ |
159 |
{ |
| 110 |
return false; |
160 |
return true; |
| 111 |
} |
161 |
} |
| 112 |
} |
162 |
} |
| 113 |
} |
163 |
} |
| 114 |
} |
164 |
} |
| 115 |
} |
165 |
} |
| 116 |
|
166 |
|
| 117 |
return true; |
167 |
return false; |
| 118 |
} |
168 |
} |
| 119 |
|
169 |
|
| 120 |
|
170 |
public IClasspathAttribute[] getClasspathAttributes() |
|
|
171 |
{ |
| 172 |
final IFacetedProjectBase fproj = getFacetedProject(); |
| 173 |
final boolean isWebProject = fproj.hasProjectFacet( WEB_FACET ); |
| 174 |
|
| 175 |
if( isIncludeWithApplicationEnabled() ) |
| 176 |
{ |
| 177 |
final IClasspathAttribute attr |
| 178 |
= JavaCore.newClasspathAttribute( IClasspathDependencyConstants.CLASSPATH_COMPONENT_DEPENDENCY, |
| 179 |
ClasspathDependencyUtil.getDefaultRuntimePath( isWebProject ).toString() ); |
| 180 |
return new IClasspathAttribute[] { attr }; |
| 181 |
} |
| 182 |
else if ( isIncludeWithApplicationSettingEnabled() ) |
| 183 |
{ |
| 184 |
final IClasspathAttribute attr |
| 185 |
= JavaCore.newClasspathAttribute( IClasspathDependencyConstants.CLASSPATH_COMPONENT_NON_DEPENDENCY, "" ); //$NON-NLS-1$ |
| 186 |
return new IClasspathAttribute[] { attr }; |
| 187 |
} |
| 188 |
|
| 189 |
return new IClasspathAttribute[ 0 ]; |
| 190 |
} |
| 121 |
} |
191 |
} |