[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[List Home]
|
[stp-commits] r3345 - in org.eclipse.stp.sca/trunk: org.eclipse.stp.sca.common/src/org/eclipse/stp/sca/common/internal/builder org.eclipse.stp.sca.common/src/org/eclipse/stp/sca/common/internal/provisional/builder org.eclipse.stp.sca.common.java/src/org/eclipse/stp/sca/common/java/composite2java
|
- From: genie@xxxxxxxxxxx
- Date: Mon, 19 Oct 2009 03:07:05 -0400 (EDT)
- Delivered-to: stp-commits@eclipse.org
Author: vzurczak
Date: 2009-10-19 03:07:04 -0400 (Mon, 19 Oct 2009)
New Revision: 3345
Modified:
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.common.java/src/org/eclipse/stp/sca/common/java/composite2java/GenerationSelectionDialog.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.common/src/org/eclipse/stp/sca/common/internal/builder/ScaDependencyVertex.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.common/src/org/eclipse/stp/sca/common/internal/provisional/builder/ScaValidator.java
Log:
Use the new utility methods
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.common/src/org/eclipse/stp/sca/common/internal/builder/ScaDependencyVertex.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.common/src/org/eclipse/stp/sca/common/internal/builder/ScaDependencyVertex.java 2009-10-13 08:55:58 UTC (rev 3344)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.common/src/org/eclipse/stp/sca/common/internal/builder/ScaDependencyVertex.java 2009-10-19 07:07:04 UTC (rev 3345)
@@ -13,53 +13,54 @@
import java.io.File;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import javax.xml.namespace.QName;
-import org.eclipse.emf.common.command.BasicCommandStack;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
-import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
-import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
-import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
-import org.eclipse.stp.sca.DocumentRoot;
-import org.eclipse.stp.sca.provider.ScaItemProviderAdapterFactory;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.stp.sca.Composite;
+import org.eclipse.stp.sca.Include;
+import org.eclipse.stp.sca.common.utils.ScaModelUtils;
/**
* A vertex is an item of a dependency graph used to determine relations between *.composite files.
* @author Vincent Zurczak - EBM WebSourcing
*/
public class ScaDependencyVertex {
-
+
/** The *.composite file associated to this vertex. */
- private File file;
-
+ private final File file;
+
/** A composite has both a name and a target name space. */
private QName name;
-
+
/** A composite may include other composites, referenced by their name and target name space. */
- private List<QName> includes = new ArrayList<QName> ();
-
+ private final List<QName> includes = new ArrayList<QName> ();
+
/** True if EMF could load this file or never tried to. False otherwise. */
private boolean isValidEmfFile = true;
-
- /** The EMF resource associated to this composite. */
- private Resource resource;
-
-
-
+
/**
- * The constructor initializes and loads a composite with EMF.
+ * The composite model (not null if {@link #isValidEmfFile()} returns true).
*/
+ private Composite composite;
+
+ /**
+ *
+ */
+ private final ScaModelUtils scaModelUtils = new ScaModelUtils();
+
+
+
+ /**
+ * The constructor initializes and loads a composite with EMF.
+ */
protected ScaDependencyVertex( File file ) {
this.file = file;
- loadResource ();
- }
-
-
+ loadResource ();
+ }
+
+
/**
* Loads the EMF resource associated with {@link #file}.
* <p>
@@ -67,74 +68,47 @@
* </p>
*/
private void loadResource() {
-
+
try {
- Resource resource = getEmfResource();
- if( resource == null )
- return;
-
- DocumentRoot root = (DocumentRoot) resource.getContents().get( 0 );
- if( root.getComposite() != null ) {
+ this.composite = this.scaModelUtils.getCompositeFile( this.file );
+ if( this.composite != null ) {
this.name = new QName(
- root.getComposite().getTargetNamespace(),
- root.getComposite().getName()
- );
-
- // FIXME: it seems the EMF model does not handle inclusions
+ this.composite.getTargetNamespace(),
+ this.composite.getName()
+ );
+
+ // FIXME: it seems the EMF model does not handle inclusions
// - and currently, it could not handle more than one inclusion.
- if( root.getInclude() != null && root.getInclude().getName() != null ) {
- this.name = new QName(
- root.getInclude().getName().getNamespaceURI(),
- root.getInclude().getName().getLocalPart()
- );
+ EList<Include> includes = this.composite.getInclude();
+ if( includes != null ) {
+ for( int i=0; i<includes.size(); i++ ) {
+ Include include = includes.get( i );
+ QName qName = new QName(
+ include.getName().getNamespaceURI(),
+ include.getName().getLocalPart()
+ );
+
+ this.includes.add( qName );
+ }
}
}
else
- isValidEmfFile = false;
-
+ this.isValidEmfFile = false;
+
} catch( Exception e ) {
e.printStackTrace();
}
}
-
-
- /**
- * @return the EMF resource associated with this vertex.
- */
- public Resource getEmfResource() {
- if( resource == null && isValidEmfFile ) {
- ComposedAdapterFactory adapterFactory =
- new ComposedAdapterFactory( ComposedAdapterFactory.Descriptor.Registry.INSTANCE );
-
- adapterFactory.addAdapterFactory( new ResourceItemProviderAdapterFactory());
- adapterFactory.addAdapterFactory( new ScaItemProviderAdapterFactory());
- adapterFactory.addAdapterFactory( new ReflectiveItemProviderAdapterFactory());
-
- BasicCommandStack commandStack = new BasicCommandStack();
- AdapterFactoryEditingDomain editingDomain = new AdapterFactoryEditingDomain(
- adapterFactory, commandStack, new HashMap<Resource, Boolean>());
-
- try {
- URI uri = URI.createFileURI( file.getAbsolutePath());
- resource = editingDomain.getResourceSet().getResource( uri, true );
- } catch( Exception e ) {
- isValidEmfFile = false;
- e.printStackTrace();
- }
- }
-
- return resource;
- }
-
+
/**
* @return the file
*/
public File getFile() {
- return file;
+ return this.file;
}
-
-
+
+
/**
* @return the tnsNameCouple
*/
@@ -142,12 +116,12 @@
return this.name;
}
-
+
/**
* @return the includes
*/
public List<QName> getIncludes() {
- return includes;
+ return this.includes;
}
@@ -155,6 +129,14 @@
* @return the isValidEmfFile
*/
public boolean isValidEmfFile() {
- return isValidEmfFile;
+ return this.isValidEmfFile;
}
+
+
+ /**
+ * @return the composite
+ */
+ public Composite getComposite() {
+ return this.composite;
+ }
}
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.common/src/org/eclipse/stp/sca/common/internal/provisional/builder/ScaValidator.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.common/src/org/eclipse/stp/sca/common/internal/provisional/builder/ScaValidator.java 2009-10-13 08:55:58 UTC (rev 3344)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.common/src/org/eclipse/stp/sca/common/internal/provisional/builder/ScaValidator.java 2009-10-19 07:07:04 UTC (rev 3345)
@@ -25,14 +25,14 @@
import org.eclipse.osgi.util.NLS;
import org.eclipse.stp.sca.DocumentRoot;
import org.eclipse.stp.sca.common.internal.Messages;
-import org.eclipse.stp.sca.common.internal.builder.ScaCustomDiagnostician;
import org.eclipse.stp.sca.common.internal.builder.ScaDependencyGraph;
import org.eclipse.stp.sca.common.internal.builder.ScaDependencyVertex;
+import org.eclipse.stp.sca.common.utils.ScaModelUtils;
/**
* A class to validate an SCA application.
* <p>
- * The validation relies on the EMF meta-model of SCA,
+ * The validation relies on the EMF meta-model of SCA,
* and uses a graph to describe the relations between SCA artifacts.
* It can be used inside and outside Eclipse.
* </p>
@@ -65,49 +65,49 @@
* TODO: improve the builder performances. Reload every model is heavy and perform a full validation
* every time a java resource changes is heavy. Think about:
* -- Libraries added or new referenced project: full build.
- * -- Class changed: only reload the related SCA resources (e.g. composites that use the changed resource).
+ * -- Class changed: only reload the related SCA resources (e.g. composites that use the changed resource).
*
* @author Vincent Zurczak - EBM WebSourcing
*/
public class ScaValidator {
- private List<ScaAbstractValidationExtension> extensions =
+ private final List<ScaAbstractValidationExtension> extensions =
new ArrayList<ScaAbstractValidationExtension>();
-
- /**
- * The dependency graph used by this builder.
+
+ /**
+ * The dependency graph used by this builder.
*/
- private ScaDependencyGraph graph = new ScaDependencyGraph();
-
-
+ private final ScaDependencyGraph graph = new ScaDependencyGraph();
+
+
/**
* @param o
* @return
* @see java.util.List#add(java.lang.Object)
*/
public boolean addValidationExtension( ScaAbstractValidationExtension o ) {
- return extensions.add( o );
+ return this.extensions.add( o );
}
-
+
/**
* @param c
* @return
* @see java.util.List#addAll(java.util.Collection)
*/
public boolean addAllValidationExtensions( Collection<? extends ScaAbstractValidationExtension> c ) {
- return extensions.addAll( c );
+ return this.extensions.addAll( c );
}
-
-
+
+
/**
*
* @see org.eclipse.stp.sca.common.internal.builder.ScaDependencyGraph
* #clearVertices()
*/
public void clearResources() {
- graph.clearVertices();
+ this.graph.clearVertices();
}
@@ -117,7 +117,7 @@
* #loadVertex(org.eclipse.core.resources.File)
*/
public void loadResource( File file ) {
- graph.loadVertex( file );
+ this.graph.loadVertex( file );
}
@@ -127,7 +127,7 @@
* #removeVertex(org.eclipse.core.resources.File)
*/
public void removeResource( File file ) {
- graph.removeVertex( file );
+ this.graph.removeVertex( file );
}
@@ -139,129 +139,109 @@
* </p>
*/
public Map<Diagnostic,File> performValidation () {
-
+
Map<Diagnostic,File> diagnostics = new HashMap<Diagnostic, File>();
-
-
+
+
// 1st step in the validation: indicate which files could not be loaded by EMF
- for( ScaDependencyVertex vertex : graph.findFilesEmfCouldNotLoad()) {
+ for( ScaDependencyVertex vertex : this.graph.findFilesEmfCouldNotLoad()) {
String filename = vertex.getFile().getName();
String message = NLS.bind( Messages.IncrementalBuilder_2, filename );
-
- Diagnostic d = new BasicDiagnostic(
- Diagnostic.ERROR,
- vertex.getFile().getAbsolutePath(),
- 0,
- message,
- new Object[ 0 ]);
+
+ Diagnostic d = new BasicDiagnostic(
+ Diagnostic.ERROR,
+ vertex.getFile().getAbsolutePath(),
+ 0,
+ message,
+ new Object[ 0 ]);
diagnostics.put( d, vertex.getFile());
return diagnostics;
}
-
-
+
+
// 2nd step in the validation: composite name = *.composite file name
- for( ScaDependencyVertex vertex : graph.findFilesWithWrongName()) {
+ for( ScaDependencyVertex vertex : this.graph.findFilesWithWrongName()) {
String filename = vertex.getFile().getName();
String message = NLS.bind( Messages.IncrementalBuilder_3, filename );
-
+
EObject eObject = null;
- if( vertex.getEmfResource() != null ) {
- DocumentRoot root = (DocumentRoot) vertex.getEmfResource().getContents().get( 0 );
- eObject = root.getComposite() == null ? root : root.getComposite();
- }
-
- Diagnostic d = new BasicDiagnostic(
- Diagnostic.ERROR,
- vertex.getFile().getAbsolutePath(),
- 0,
- message,
- new Object[]{ eObject });
+ if( vertex.isValidEmfFile())
+ eObject = vertex.getComposite();
+
+ Diagnostic d = new BasicDiagnostic(
+ Diagnostic.ERROR,
+ vertex.getFile().getAbsolutePath(),
+ 0,
+ message,
+ new Object[]{ eObject });
diagnostics.put( d, vertex.getFile());
return diagnostics;
}
-
-
+
+
// 3rd step in the validation: the couple (name, tns) is unique in the project
- for( ScaDependencyVertex vertex : graph.findFilesWithSameIds()) {
- String message = NLS.bind(
- Messages.IncrementalBuilder_5,
- new Object[] {
- vertex.getName().getLocalPart(),
- vertex.getName().getNamespaceURI()});
-
+ for( ScaDependencyVertex vertex : this.graph.findFilesWithSameIds()) {
+ String message = NLS.bind(
+ Messages.IncrementalBuilder_5,
+ new Object[] {
+ vertex.getName().getLocalPart(),
+ vertex.getName().getNamespaceURI()});
+
EObject eObject = null;
- if( vertex.getEmfResource() != null ) {
- DocumentRoot root = (DocumentRoot) vertex.getEmfResource().getContents().get( 0 );
- eObject = root.getComposite() == null ? root : root.getComposite();
- }
-
- Diagnostic d = new BasicDiagnostic(
- Diagnostic.ERROR,
- vertex.getFile().getAbsolutePath(),
- 0,
- message,
- new Object[]{ eObject });
+ if( vertex.isValidEmfFile())
+ eObject = vertex.getComposite();
+
+ Diagnostic d = new BasicDiagnostic(
+ Diagnostic.ERROR,
+ vertex.getFile().getAbsolutePath(),
+ 0,
+ message,
+ new Object[]{ eObject });
diagnostics.put( d, vertex.getFile());
return diagnostics;
}
-
-
+
+
// 4th step in the validation: find cycles in inclusions
- for( Map.Entry<ScaDependencyVertex, String> entry : graph.findDependencyCycles().entrySet()) {
- File file = entry.getKey().getFile();
+ for( Map.Entry<ScaDependencyVertex, String> entry : this.graph.findDependencyCycles().entrySet()) {
+ File file = entry.getKey().getFile();
String message = NLS.bind( Messages.IncrementalBuilder_8, entry.getValue());
-
+
EObject eObject = null;
- if( entry.getKey().getEmfResource() != null ) {
- DocumentRoot root = (DocumentRoot) entry.getKey().getEmfResource().getContents().get( 0 );
- eObject = root.getComposite() == null ? root : root.getComposite();
- }
-
- Diagnostic d = new BasicDiagnostic(
- Diagnostic.ERROR,
- file.getAbsolutePath(),
- 0,
- message,
- new Object[]{ eObject });
+ if( entry.getKey().isValidEmfFile())
+ eObject = entry.getKey().getComposite();
+
+ Diagnostic d = new BasicDiagnostic(
+ Diagnostic.ERROR,
+ file.getAbsolutePath(),
+ 0,
+ message,
+ new Object[]{ eObject });
diagnostics.put( d, file );
return diagnostics;
}
-
-
+
+
// 5th step in the validation: run EMF + extended validation
- for( ScaDependencyVertex vertex : graph.getFilesToValidateWithEmf ()) {
- if( vertex.getEmfResource() == null )
+ for( ScaDependencyVertex vertex : this.graph.getFilesToValidateWithEmf ()) {
+ if( ! vertex.isValidEmfFile())
continue;
-
- DocumentRoot root = (DocumentRoot) vertex.getEmfResource().getContents().get( 0 );
- Diagnostic diagnostic = null;
- try {
- diagnostic = new ScaCustomDiagnostician().validate( root );
- } catch( Exception e ) {
- // Exception if a promote only defines the component
- diagnostic = new BasicDiagnostic (
- Diagnostic.ERROR,
- e.getMessage(),
- 0,
- Messages.ScaIncrementalBuilder_3,
- new Object[ 0 ]
- );
- }
-
+ Diagnostic diagnostic = ScaModelUtils.validate( vertex.getComposite());
if( diagnostic.getSeverity() != Diagnostic.OK )
diagnostics.put( diagnostic, vertex.getFile());
// Extended validation
+ DocumentRoot root = (DocumentRoot) vertex.getComposite().eContainer();
URI uri = root.eResource().getURI();
if( uri.isPlatform())
continue;
-
- for( ScaAbstractValidationExtension ext : extensions ) {
+
+ for( ScaAbstractValidationExtension ext : this.extensions ) {
if( ! ext.initialize( root, vertex.getFile()))
continue;
-
+
diagnostics.putAll( ext.validatePreRequisites());
diagnostics.putAll( ext.validateInterfaceCompatibilityInPromotes());
diagnostics.putAll( ext.validateInterfaceCompatibilityInWires());
@@ -270,7 +250,7 @@
diagnostics.putAll( ext.validateOthers());
}
}
-
+
return diagnostics;
}
}
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.common.java/src/org/eclipse/stp/sca/common/java/composite2java/GenerationSelectionDialog.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.common.java/src/org/eclipse/stp/sca/common/java/composite2java/GenerationSelectionDialog.java 2009-10-13 08:55:58 UTC (rev 3344)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.common.java/src/org/eclipse/stp/sca/common/java/composite2java/GenerationSelectionDialog.java 2009-10-19 07:07:04 UTC (rev 3345)
@@ -58,28 +58,30 @@
*/
public class GenerationSelectionDialog extends TitleAreaDialog {
- private IFile compositeFile;
- private JComposite jComposite;
+ private final IFile compositeFile;
+ private final JComposite jComposite;
private IClasspathEntry selectedEntry;
- private List<JavaFile> selectedFiles = new ArrayList<JavaFile> ();
+ private final List<JavaFile> selectedFiles = new ArrayList<JavaFile> ();
private Image cuImg, packageImg, sourceImg;
-
-
+
+
/**
* @param parentShell
+ * @param compositeFile
+ * @param jComposite
*/
public GenerationSelectionDialog( Shell parentShell, IFile compositeFile, JComposite jComposite ) {
super( parentShell );
this.compositeFile = compositeFile;
this.jComposite = jComposite;
setShellStyle( SWT.PRIMARY_MODAL | SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX );
-
- cuImg = ScaCommonJdtPlugin.getImage( "icons/obj16/jcu_obj.gif" ); //$NON-NLS-1$
- packageImg = ScaCommonJdtPlugin.getImage( "icons/obj16/package_obj.gif" ); //$NON-NLS-1$
- sourceImg = ScaCommonJdtPlugin.getImage( "icons/obj16/packagefolder_obj.gif" ); //$NON-NLS-1$
+
+ this.cuImg = ScaCommonJdtPlugin.getImage( "icons/obj16/jcu_obj.gif" ); //$NON-NLS-1$
+ this.packageImg = ScaCommonJdtPlugin.getImage( "icons/obj16/package_obj.gif" ); //$NON-NLS-1$
+ this.sourceImg = ScaCommonJdtPlugin.getImage( "icons/obj16/packagefolder_obj.gif" ); //$NON-NLS-1$
}
-
-
+
+
/*
* (non-Javadoc)
* @see org.eclipse.jface.dialogs.TitleAreaDialog
@@ -87,48 +89,39 @@
*/
@Override
protected Control createDialogArea( Composite parent ) {
-
+
Composite bigContainer = (Composite) super.createDialogArea( parent );
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
bigContainer.setLayout( layout );
bigContainer.setLayoutData( new GridData( GridData.FILL_BOTH ));
-
+
Composite container = new Composite( bigContainer, SWT.NONE );
layout = new GridLayout ();
layout.marginWidth = layout.marginHeight = 0;
container.setLayout( layout );
container.setLayoutData( new GridData( GridData.FILL_BOTH ));
-
-
+
+
// Source folder
Label l = new Label( container, SWT.NONE );
l.setText( Messages.GenerationSelectionDialog_3 );
-
+
Composite comp = new Composite( container, SWT.NONE );
layout = new GridLayout( 2, false );
layout.marginHeight = layout.marginWidth = 0;
comp.setLayout( layout );
comp.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ));
-
+
l = new Label( comp, SWT.NONE );
- l.setImage( sourceImg );
-
+ l.setImage( this.sourceImg );
+
Combo combo = new Combo( comp, SWT.READ_ONLY | SWT.BORDER | SWT.DROP_DOWN );
combo.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ));
- ComboViewer comboViewer = new ComboViewer( combo );
- final IJavaProject jp = JDTUtils.getJavaProject( compositeFile.getProject());
- List<IClasspathEntry> entries = new ArrayList<IClasspathEntry> ();
-
- try {
- for( IClasspathEntry entry : jp.getRawClasspath()) {
- if( entry.getEntryKind() == IClasspathEntry.CPE_SOURCE )
- entries.add( entry );
- }
- } catch( JavaModelException e ) {
- e.printStackTrace();
- }
-
+ ComboViewer comboViewer = new ComboViewer( combo );
+ final IJavaProject jp = JDTUtils.getJavaProject( this.compositeFile.getProject());
+ List<IClasspathEntry> entries = JDTUtils.getSourceFolders( jp );
+
comboViewer.setContentProvider( new ArrayContentProvider ());
comboViewer.setLabelProvider( new LabelProvider () {
@Override
@@ -136,37 +129,37 @@
IPath path = ((IClasspathEntry) element).getPath();
return " " + path.lastSegment() + " - " + path.toString(); //$NON-NLS-1$ //$NON-NLS-2$
}
-
+
@Override
public Image getImage( Object element ) {
- return sourceImg;
+ return GenerationSelectionDialog.this.sourceImg;
}
});
-
+
comboViewer.setInput( entries );
if( entries.size() > 0 ) {
- selectedEntry = entries.get( 0 );
- comboViewer.setSelection( new StructuredSelection( selectedEntry ));
+ this.selectedEntry = entries.get( 0 );
+ comboViewer.setSelection( new StructuredSelection( this.selectedEntry ));
}
-
+
comboViewer.addSelectionChangedListener( new ISelectionChangedListener () {
public void selectionChanged( SelectionChangedEvent event ) {
- selectedEntry = (IClasspathEntry) ((IStructuredSelection) event.getSelection()).getFirstElement();
+ GenerationSelectionDialog.this.selectedEntry = (IClasspathEntry) ((IStructuredSelection) event.getSelection()).getFirstElement();
}
});
-
-
+
+
// Java selection
l = new Label( container, SWT.NONE );
l.setText( Messages.GenerationSelectionDialog_6 );
GridData layoutData = new GridData();
layoutData.verticalIndent = 15;
l.setLayoutData( layoutData );
-
+
int style = SWT.BORDER | SWT.SINGLE | SWT.HIDE_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL;
final CheckboxTreeViewer treeViewer = new CheckboxTreeViewer( container, style );
treeViewer.getTree().setLayoutData( new GridData( GridData.FILL_BOTH ));
-
+
treeViewer.setLabelProvider( new LabelProvider () {
@Override
public String getText( Object element ) {
@@ -180,17 +173,17 @@
return ((JavaFile) element).name;
return super.getText( element );
}
-
+
@Override
public Image getImage( Object element ) {
if( element instanceof JavaPackage )
- return packageImg;
+ return GenerationSelectionDialog.this.packageImg;
if( element instanceof JavaFile )
- return cuImg;
+ return GenerationSelectionDialog.this.cuImg;
return super.getImage( element );
}
});
-
+
final Map<String, JavaPackage> javaPackages = new HashMap<String, JavaPackage> ();
treeViewer.setContentProvider( new ITreeContentProvider () {
public void dispose() {
@@ -216,29 +209,29 @@
public boolean hasChildren( Object element ) {
if( element instanceof JavaPackage )
return ((JavaPackage) element).classes.size() > 0;
- return false;
+ return false;
}
public Object[] getElements( Object inputElement ) {
-
+
if( !( inputElement instanceof JComposite ))
return new Object[ 0 ];
-
+
List<JInterface> elements = new ArrayList<JInterface> ();
elements.addAll( ((JComposite) inputElement).getInterfaces().values());
elements.addAll( ((JComposite) inputElement).getImplementations().values());
-
+
javaPackages.clear();
for( JInterface ji : elements ) {
try {
IType iType = jp.findType( ji.getName());
if( iType != null )
continue;
-
+
} catch( JavaModelException e ) {
e.printStackTrace();
}
-
+
String[] parts = JDTUtils.getQualifiedNameElements( ji.getName());
String pn = parts[ 0 ];
JavaPackage pck = javaPackages.get( pn );
@@ -246,7 +239,7 @@
pck = new JavaPackage();
pck.name = pn;
}
-
+
JavaFile jf = new JavaFile();
jf.name = parts[ 1 ];
jf.pck = pck;
@@ -254,45 +247,45 @@
pck.classes.add( jf );
javaPackages.put( pck.name, pck );
}
-
+
return javaPackages.values().toArray();
}
});
-
- treeViewer.setInput( jComposite );
+
+ treeViewer.setInput( this.jComposite );
treeViewer.setSorter( new ViewerSorter () {
@Override
public int compare( Viewer viewer, Object e1, Object e2 ) {
if( e1.getClass().equals( e2.getClass())) {
- if( e1 instanceof JavaPackage )
+ if( e1 instanceof JavaPackage )
return ((JavaPackage) e1).getName().compareTo(((JavaPackage) e2).getName());
- else
- return ((JavaFile) e1).getName().compareTo(((JavaFile) e2).getName());
+
+ return ((JavaFile) e1).getName().compareTo(((JavaFile) e2).getName());
}
return super.compare( viewer, e1, e2 );
}
});
-
+
treeViewer.expandAll();
for( JavaPackage pck : javaPackages.values())
- selectedFiles.addAll( pck.classes );
-
+ this.selectedFiles.addAll( pck.classes );
+
for( JavaPackage pck : javaPackages.values())
treeViewer.setSubtreeChecked( pck, true );
-
+
treeViewer.addCheckStateListener( new ICheckStateListener () {
public void checkStateChanged( CheckStateChangedEvent event ) {
-
+
if( event.getElement() instanceof JavaPackage ) {
JavaPackage pck = (JavaPackage) event.getElement();
treeViewer.setSubtreeChecked( pck, event.getChecked());
-
+
if( event.getChecked())
- selectedFiles.addAll( pck.classes );
+ GenerationSelectionDialog.this.selectedFiles.addAll( pck.classes );
else
- selectedFiles.removeAll( pck.classes );
+ GenerationSelectionDialog.this.selectedFiles.removeAll( pck.classes );
}
-
+
else {
JavaFile jf = (JavaFile) event.getElement();
int checked = 0;
@@ -300,7 +293,7 @@
if( treeViewer.getChecked( jfRun ))
checked ++;
}
-
+
if( checked == jf.pck.classes.size()) {
treeViewer.setGrayChecked( jf.pck, false );
treeViewer.setChecked( jf.pck, true );
@@ -311,26 +304,26 @@
else {
treeViewer.setGrayChecked( jf.pck, true );
}
-
+
if( event.getChecked())
- selectedFiles.add( jf );
+ GenerationSelectionDialog.this.selectedFiles.add( jf );
else
- selectedFiles.remove( jf );
+ GenerationSelectionDialog.this.selectedFiles.remove( jf );
}
}
});
-
+
getShell().setText( Messages.GenerationSelectionDialog_8 );
setTitle( Messages.GenerationSelectionDialog_8 );
- if( selectedFiles.size() ==
- jComposite.getImplementations().size() + jComposite.getInterfaces().size())
+ if( this.selectedFiles.size() ==
+ this.jComposite.getImplementations().size() + this.jComposite.getInterfaces().size())
setMessage( Messages.GenerationSelectionDialog_10 );
else
setMessage( Messages.GenerationSelectionDialog_11, DialogPage.WARNING );
return bigContainer;
}
-
-
+
+
/*
* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#getInitialSize()
@@ -339,52 +332,52 @@
protected Point getInitialSize () {
return new Point( 600, 500 );
}
-
-
+
+
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.TrayDialog#close()
*/
@Override
public boolean close() {
-
- if( sourceImg != null ) {
- sourceImg.dispose();
- sourceImg = null;
+
+ if( this.sourceImg != null ) {
+ this.sourceImg.dispose();
+ this.sourceImg = null;
}
- if( packageImg != null ) {
- packageImg.dispose();
- packageImg = null;
+ if( this.packageImg != null ) {
+ this.packageImg.dispose();
+ this.packageImg = null;
}
- if( cuImg != null ) {
- cuImg.dispose();
- cuImg = null;
+ if( this.cuImg != null ) {
+ this.cuImg.dispose();
+ this.cuImg = null;
}
-
+
return super.close();
}
-
+
/**
*
*/
public class JavaPackage {
String name;
HashSet<JavaFile> classes = new HashSet<JavaFile> ();
-
+
/**
* @return the name
*/
public String getName() {
- return name;
+ return this.name;
}
-
+
/**
* @return the classes
*/
public HashSet<JavaFile> getClasses() {
- return classes;
+ return this.classes;
}
}
-
+
/**
*
*/
@@ -392,26 +385,26 @@
String name;
JInterface jInterface;
JavaPackage pck;
-
+
/**
* @return the name
*/
public String getName() {
- return name;
+ return this.name;
}
-
+
/**
* @return the jInterface
*/
public JInterface getJInterface() {
- return jInterface;
+ return this.jInterface;
}
-
+
/**
* @return the pck
*/
public JavaPackage getPck() {
- return pck;
+ return this.pck;
}
}
@@ -419,18 +412,18 @@
* @return
*/
public IPackageFragmentRoot getPackageFragmentRoot() {
- IJavaProject jp = JDTUtils.getJavaProject( compositeFile.getProject());
- IPackageFragmentRoot[] roots = jp.findPackageFragmentRoots( selectedEntry );
-
+ IJavaProject jp = JDTUtils.getJavaProject( this.compositeFile.getProject());
+ IPackageFragmentRoot[] roots = jp.findPackageFragmentRoots( this.selectedEntry );
+
if( roots.length != 0 )
return roots[ 0 ];
return null;
}
-
+
/**
* @return the selected files
*/
public List<JavaFile> getSelectedFiles() {
- return selectedFiles;
+ return this.selectedFiles;
}
}
\ No newline at end of file