[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[List Home]
|
[stp-commits] r3304 - in org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor: . completion completion/attributes completion/preferences outline preferences preferences/beans preferences/dialogs preferences/viewers utils
|
- From: genie@xxxxxxxxxxx
- Date: Thu, 27 Aug 2009 11:13:15 -0400 (EDT)
- Delivered-to: stp-commits@eclipse.org
Author: vzurczak
Date: 2009-08-27 11:13:13 -0400 (Thu, 27 Aug 2009)
New Revision: 3304
Modified:
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/ImageRegistry.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/ScaXmlEditorPlugin.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/completion/AbstractProcessor.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/completion/ProxyProcessor.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/completion/XmlContextualDom.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/completion/attributes/AtttributeValueProposalMaker.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/completion/preferences/ScaPreferenceProcessor.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/outline/ScaXmlContentProvider.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/DefaultPreferences.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/ScaXmlPreferenceInitializer.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/ScaXmlPreferencePage.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/ScaXmlPreferenceUtils.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/beans/ScaXmlAttribute.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/beans/ScaXmlElement.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/beans/ScaXmlNamespace.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/beans/ScaXmlPlatform.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/dialogs/ElementEditionDialog.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/dialogs/RootElementEditionDialog.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/viewers/PlatformAndNsContentProvider.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/viewers/ScaXmlContentProvider.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/viewers/ScaXmlLabelProvider.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/viewers/ScaXmlViewerFilter.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/viewers/ScaXmlViewerSorter.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/utils/IncludesUtils.java
org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/utils/ScaUtils.java
Log:
Added last FraSCAti model changes to the XML preference page.
Used FindBugs to correct possible code issues.
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/ImageRegistry.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/ImageRegistry.java 2009-08-27 10:38:15 UTC (rev 3303)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/ImageRegistry.java 2009-08-27 15:13:13 UTC (rev 3304)
@@ -32,13 +32,13 @@
* @author Vincent Zurczak - EBM WebSourcing
*/
public class ImageRegistry {
-
+
/** The unique instance of this class. */
private static ImageRegistry instance = new ImageRegistry();
-
-
+
+
//
- // Image Descriptors.
+ // Image Descriptors.
// SCA basis.
public static final String wireImgLoc = "Wire.gif"; //$NON-NLS-1$
public static final String serviceImgLoc = "Service.gif"; //$NON-NLS-1$
@@ -52,7 +52,7 @@
public static final String propertyValueImgLoc = "PropertyValue.gif"; //$NON-NLS-1$
public static final String callbackImgLoc = "Callback.gif"; //$NON-NLS-1$
public static final String operationImgLoc = "Operation.gif"; //$NON-NLS-1$
-
+
// Implementations.
public static final String scriptImplImgLoc = "ScriptImplementation.gif"; //$NON-NLS-1$
public static final String springImplImgLoc = "SpringImplementation.gif"; //$NON-NLS-1$
@@ -64,11 +64,11 @@
public static final String javaImplImgLoc = "JavaImplementation.gif"; //$NON-NLS-1$
public static final String bpelImplImgLoc = "BpelImplementation.gif"; //$NON-NLS-1$
public static final String fractalImplImgLoc = "FractalImplementation.gif"; //$NON-NLS-1$
-
+
// Interfaces.
public static final String javaInterfaceImgLoc = "JavaInterface.gif"; //$NON-NLS-1$
public static final String wsdlInterfaceImgLoc = "WSDLPortType.gif"; //$NON-NLS-1$
-
+
// Bindings.
public static final String wsBindingImgLoc = "WebServiceBinding.gif"; //$NON-NLS-1$
public static final String scaBindingImgLoc = "SCABinding.gif"; //$NON-NLS-1$
@@ -81,7 +81,7 @@
public static final String dwrBindingImgLoc = "DWRBinding.gif"; //$NON-NLS-1$
public static final String atomBindingImgLoc = "AtomBinding.gif"; //$NON-NLS-1$
public static final String jbiBindingImgLoc = "JBIBinding.gif"; //$NON-NLS-1$
-
+
// Others.
public static final String allowImgLoc = "Allow.gif"; //$NON-NLS-1$
public static final String constrainingTypeImgLoc = "ConstrainingType.gif"; //$NON-NLS-1$
@@ -101,9 +101,9 @@
public static final String markupProposalImgLoc = "tag-generic.gif"; //$NON-NLS-1$
public static final String attributeImgLoc = "attribute_obj.gif"; //$NON-NLS-1$
public static final String elementImgLoc = "element_obj.gif"; //$NON-NLS-1$
- public static final String serverImgLoc = "server.gif"; //$NON-NLS-1$
-
-
+ public static final String serverImgLoc = "server.gif"; //$NON-NLS-1$
+
+
//
// Images
// SCA basis.
@@ -119,7 +119,7 @@
public Image propertyValueImg;
public Image callbackImg;
public Image operationImg;
-
+
// Implementations.
public Image scriptImplImg;
public Image springImplImg;
@@ -131,11 +131,11 @@
public Image javaImplImg;
public Image bpelImplImg;
public Image fractalImplImg;
-
+
// Interfaces.
public Image javaInterfaceImg;
public Image wsdlInterfaceImg;
-
+
// Bindings.
public Image wsBindingImg;
public Image scaBindingImg;
@@ -148,7 +148,7 @@
public Image dwrBindingImg;
public Image atomBindingImg;
public Image jbiBindingImg;
-
+
// Others.
public Image allowImg;
public Image constrainingTypeImg;
@@ -161,7 +161,7 @@
public Image bindingTypeImg;
public Image runAsImg;
public Image componentTypeImg;
-
+
// Auto-Completion.
public Image activeMarkupProposalImg;
public Image inactiveMarkupProposalImg;
@@ -169,359 +169,359 @@
public Image attributeImg;
public Image elementImg;
public Image serverImg;
-
-
+
+
/**
* The private constructor of this class.
* It creates the images from their Locriptors.
*/
private ImageRegistry() {
List<String> notFoundImages = new ArrayList<String> ();
-
+
// SCA basis.
try {
- wireImg = ScaXmlEditorPlugin.getScaCommonImage( wireImgLoc ).createImage();
+ this.wireImg = ScaXmlEditorPlugin.getScaCommonImage( wireImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( wireImgLoc );
}
-
+
try {
- serviceImg = ScaXmlEditorPlugin.getScaCommonImage( serviceImgLoc ).createImage();
+ this.serviceImg = ScaXmlEditorPlugin.getScaCommonImage( serviceImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( serverImgLoc );
}
-
+
try {
- referenceImg = ScaXmlEditorPlugin.getScaCommonImage( referenceImgLoc ).createImage();
+ this.referenceImg = ScaXmlEditorPlugin.getScaCommonImage( referenceImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( referenceImgLoc );
}
-
-
+
+
try {
- propertyImg = ScaXmlEditorPlugin.getScaCommonImage( propertyImgLoc ).createImage();
+ this.propertyImg = ScaXmlEditorPlugin.getScaCommonImage( propertyImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( propertyImgLoc );
}
-
+
try {
- includeImg = ScaXmlEditorPlugin.getScaCommonImage( includeImgLoc ).createImage();
- ImageDescriptor overlayLoc =
+ this.includeImg = ScaXmlEditorPlugin.getScaCommonImage( includeImgLoc ).createImage();
+ ImageDescriptor overlayLoc =
ScaXmlEditorPlugin.getImageDescriptor( "icons/full/ovr16/reference-overlay.gif" ); //$NON-NLS-1$
- DecorationOverlayIcon overlay =
- new DecorationOverlayIcon( includeImg, overlayLoc, IDecoration.BOTTOM_RIGHT );
- includeImg = overlay.createImage();
-
+ DecorationOverlayIcon overlay =
+ new DecorationOverlayIcon( this.includeImg, overlayLoc, IDecoration.BOTTOM_RIGHT );
+ this.includeImg = overlay.createImage();
+
} catch( Exception e ) {
notFoundImages.add( includeImgLoc );
}
-
-
+
+
try {
- compositeImg = ScaXmlEditorPlugin.getScaCommonImage( compositeImgLoc ).createImage();
+ this.compositeImg = ScaXmlEditorPlugin.getScaCommonImage( compositeImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( componentImgLoc );
}
-
+
try {
- componentImg = ScaXmlEditorPlugin.getScaCommonImage( componentImgLoc ).createImage();
+ this.componentImg = ScaXmlEditorPlugin.getScaCommonImage( componentImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( componentImgLoc );
}
-
+
try {
- componentReferenceImg = ScaXmlEditorPlugin.getScaCommonImage( componentReferenceImgLoc ).createImage();
+ this.componentReferenceImg = ScaXmlEditorPlugin.getScaCommonImage( componentReferenceImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( componentReferenceImgLoc );
}
-
+
try {
- componentServiceImg = ScaXmlEditorPlugin.getScaCommonImage( componentServiceImgLoc ).createImage();
+ this.componentServiceImg = ScaXmlEditorPlugin.getScaCommonImage( componentServiceImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( componentServiceImgLoc );
}
-
+
try {
- propertyValueImg = ScaXmlEditorPlugin.getScaCommonImage( propertyValueImgLoc ).createImage();
+ this.propertyValueImg = ScaXmlEditorPlugin.getScaCommonImage( propertyValueImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( propertyValueImgLoc );
}
-
+
try {
- callbackImg = ScaXmlEditorPlugin.getScaCommonImage( callbackImgLoc ).createImage();
+ this.callbackImg = ScaXmlEditorPlugin.getScaCommonImage( callbackImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( callbackImgLoc );
}
-
+
try {
- operationImg = ScaXmlEditorPlugin.getScaCommonImage( operationImgLoc ).createImage();
+ this.operationImg = ScaXmlEditorPlugin.getScaCommonImage( operationImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( operationImgLoc );
}
-
-
+
+
// Implementations.
try {
- scriptImplImg = ScaXmlEditorPlugin.getScaTuscanyImage( scriptImplImgLoc ).createImage();
+ this.scriptImplImg = ScaXmlEditorPlugin.getScaTuscanyImage( scriptImplImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( scriptImplImgLoc );
}
-
+
try {
- springImplImg = ScaXmlEditorPlugin.getScaCommonImage( springImplImgLoc ).createImage();
+ this.springImplImg = ScaXmlEditorPlugin.getScaCommonImage( springImplImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( springImplImgLoc );
}
-
+
try {
- xQueryImplImg = ScaXmlEditorPlugin.getScaTuscanyImage( xQueryImplImgLoc ).createImage();
+ this.xQueryImplImg = ScaXmlEditorPlugin.getScaTuscanyImage( xQueryImplImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( xQueryImplImgLoc );
}
-
+
try {
- scaImplImg = ScaXmlEditorPlugin.getScaCommonImage( scaImplImgLoc ).createImage();
+ this.scaImplImg = ScaXmlEditorPlugin.getScaCommonImage( scaImplImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( scaImplImgLoc );
}
-
+
try {
- resourceImplImg = ScaXmlEditorPlugin.getScaTuscanyImage( resourceImplImgLoc ).createImage();
+ this.resourceImplImg = ScaXmlEditorPlugin.getScaTuscanyImage( resourceImplImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( resourceImplImgLoc );
}
-
+
try {
- osgiImplImg = ScaXmlEditorPlugin.getScaTuscanyImage( osgiImplImgLoc ).createImage();
+ this.osgiImplImg = ScaXmlEditorPlugin.getScaTuscanyImage( osgiImplImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( osgiImplImgLoc );
}
-
+
try {
- notificationImplImg = ScaXmlEditorPlugin.getScaTuscanyImage( notificationImplImgLoc ).createImage();
+ this.notificationImplImg = ScaXmlEditorPlugin.getScaTuscanyImage( notificationImplImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( notificationImplImgLoc );
}
-
+
try {
- javaImplImg = ScaXmlEditorPlugin.getScaCommonImage( javaImplImgLoc ).createImage();
+ this.javaImplImg = ScaXmlEditorPlugin.getScaCommonImage( javaImplImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( javaImplImgLoc );
}
-
+
try {
- bpelImplImg = ScaXmlEditorPlugin.getScaCommonImage( bpelImplImgLoc ).createImage();
+ this.bpelImplImg = ScaXmlEditorPlugin.getScaCommonImage( bpelImplImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( bpelImplImgLoc );
}
-
+
try {
- fractalImplImg = ScaXmlEditorPlugin.getScaFrascatiImage( fractalImplImgLoc ).createImage();
+ this.fractalImplImg = ScaXmlEditorPlugin.getScaFrascatiImage( fractalImplImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( fractalImplImgLoc );
}
-
-
+
+
// Interfaces.
try {
- javaInterfaceImg = ScaXmlEditorPlugin.getScaCommonImage( javaInterfaceImgLoc ).createImage();
+ this.javaInterfaceImg = ScaXmlEditorPlugin.getScaCommonImage( javaInterfaceImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( javaInterfaceImgLoc );
}
-
+
try {
- wsdlInterfaceImg = ScaXmlEditorPlugin.getScaCommonImage( wsdlInterfaceImgLoc ).createImage();
+ this.wsdlInterfaceImg = ScaXmlEditorPlugin.getScaCommonImage( wsdlInterfaceImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( wsdlInterfaceImgLoc );
- }
-
-
+ }
+
+
// Bindings.
try {
- wsBindingImg = ScaXmlEditorPlugin.getScaCommonImage( wsBindingImgLoc ).createImage();
+ this.wsBindingImg = ScaXmlEditorPlugin.getScaCommonImage( wsBindingImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( wsBindingImgLoc );
}
-
+
try {
- scaBindingImg = ScaXmlEditorPlugin.getScaCommonImage( scaBindingImgLoc ).createImage();
+ this.scaBindingImg = ScaXmlEditorPlugin.getScaCommonImage( scaBindingImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( scaBindingImgLoc );
}
-
+
try {
- rssBindingImg = ScaXmlEditorPlugin.getScaTuscanyImage( rssBindingImgLoc ).createImage();
+ this.rssBindingImg = ScaXmlEditorPlugin.getScaTuscanyImage( rssBindingImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( rssBindingImgLoc );
}
-
+
try {
- rmiBindingImg = ScaXmlEditorPlugin.getScaTuscanyImage( rmiBindingImgLoc ).createImage();
+ this.rmiBindingImg = ScaXmlEditorPlugin.getScaTuscanyImage( rmiBindingImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( rmiBindingImgLoc );
}
-
+
try {
- notificationBindingImg = ScaXmlEditorPlugin.getScaTuscanyImage( notificationBindingImgLoc ).createImage();
+ this.notificationBindingImg = ScaXmlEditorPlugin.getScaTuscanyImage( notificationBindingImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( notificationBindingImgLoc );
}
-
+
try {
- jsonRpcBindingImg = ScaXmlEditorPlugin.getScaTuscanyImage( jsonRpcBindingImgLoc ).createImage();
+ this.jsonRpcBindingImg = ScaXmlEditorPlugin.getScaTuscanyImage( jsonRpcBindingImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( jsonRpcBindingImgLoc );
}
-
+
try {
- httpBindingImg = ScaXmlEditorPlugin.getScaTuscanyImage( httpBindingImgLoc ).createImage();
+ this.httpBindingImg = ScaXmlEditorPlugin.getScaTuscanyImage( httpBindingImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( httpBindingImgLoc );
}
-
+
try {
- ejbSessionBeanBindingImg = ScaXmlEditorPlugin.getScaCommonImage( ejbSessionBeanBindingImgLoc ).createImage();
+ this.ejbSessionBeanBindingImg = ScaXmlEditorPlugin.getScaCommonImage( ejbSessionBeanBindingImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( ejbSessionBeanBindingImgLoc );
}
-
+
try {
- dwrBindingImg = ScaXmlEditorPlugin.getScaTuscanyImage( dwrBindingImgLoc ).createImage();
+ this.dwrBindingImg = ScaXmlEditorPlugin.getScaTuscanyImage( dwrBindingImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( dwrBindingImgLoc );
}
-
+
try {
- atomBindingImg = ScaXmlEditorPlugin.getScaTuscanyImage( atomBindingImgLoc ).createImage();
+ this.atomBindingImg = ScaXmlEditorPlugin.getScaTuscanyImage( atomBindingImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( atomBindingImgLoc );
}
-
+
try {
- jbiBindingImg = ScaXmlEditorPlugin.getScaFrascatiImage( jbiBindingImgLoc ).createImage();
+ this.jbiBindingImg = ScaXmlEditorPlugin.getScaFrascatiImage( jbiBindingImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( jbiBindingImgLoc );
}
-
-
+
+
// Others.
try {
- allowImg = ScaXmlEditorPlugin.getScaCommonImage( allowImgLoc ).createImage();
+ this.allowImg = ScaXmlEditorPlugin.getScaCommonImage( allowImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( allowImgLoc );
}
-
+
try {
- constrainingTypeImg = ScaXmlEditorPlugin.getScaCommonImage( constrainingTypeImgLoc ).createImage();
+ this.constrainingTypeImg = ScaXmlEditorPlugin.getScaCommonImage( constrainingTypeImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( constrainingTypeImgLoc );
}
-
+
try {
- definitionsTypeImg = ScaXmlEditorPlugin.getScaCommonImage( definitionsTypeImgLoc ).createImage();
+ this.definitionsTypeImg = ScaXmlEditorPlugin.getScaCommonImage( definitionsTypeImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( definitionsTypeImgLoc );
}
-
+
try {
- denyAllImg = ScaXmlEditorPlugin.getScaCommonImage( denyAllImgLoc ).createImage();
+ this.denyAllImg = ScaXmlEditorPlugin.getScaCommonImage( denyAllImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( denyAllImgLoc );
}
-
+
try {
- implTypeImg = ScaXmlEditorPlugin.getScaCommonImage( implTypeImgLoc ).createImage();
+ this.implTypeImg = ScaXmlEditorPlugin.getScaCommonImage( implTypeImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( implTypeImgLoc );
}
-
+
try {
- intentImg = ScaXmlEditorPlugin.getScaCommonImage( intentImgLoc ).createImage();
+ this.intentImg = ScaXmlEditorPlugin.getScaCommonImage( intentImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( intentImgLoc );
}
-
+
try {
- permitAllImg = ScaXmlEditorPlugin.getScaCommonImage( permitAllImgLoc ).createImage();
+ this.permitAllImg = ScaXmlEditorPlugin.getScaCommonImage( permitAllImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( permitAllImgLoc );
}
-
+
try {
- policySetImg = ScaXmlEditorPlugin.getScaCommonImage( policySetImgLoc ).createImage();
+ this.policySetImg = ScaXmlEditorPlugin.getScaCommonImage( policySetImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( policySetImgLoc );
}
-
+
try {
- bindingTypeImg = ScaXmlEditorPlugin.getScaCommonImage( bindingTypeImgLoc ).createImage();
+ this.bindingTypeImg = ScaXmlEditorPlugin.getScaCommonImage( bindingTypeImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( bindingTypeImgLoc );
}
-
+
try {
- runAsImg = ScaXmlEditorPlugin.getScaCommonImage( runAsImgLoc ).createImage();
+ this.runAsImg = ScaXmlEditorPlugin.getScaCommonImage( runAsImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( runAsImgLoc );
}
-
+
try {
- componentTypeImg = ScaXmlEditorPlugin.getScaCommonImage( componentTypeImgLoc ).createImage();
+ this.componentTypeImg = ScaXmlEditorPlugin.getScaCommonImage( componentTypeImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( componentTypeImgLoc );
- }
-
-
+ }
+
+
// Auto-completion.
try {
- activeMarkupProposalImg = ScaXmlEditorPlugin.getScaXmlImage( activeMarkupProposalImgLoc ).createImage();
+ this.activeMarkupProposalImg = ScaXmlEditorPlugin.getScaXmlImage( activeMarkupProposalImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( activeMarkupProposalImgLoc );
}
-
+
try {
- inactiveMarkupProposalImg = ScaXmlEditorPlugin.getScaXmlImage( inactiveMarkupProposalImgLoc ).createImage();
+ this.inactiveMarkupProposalImg = ScaXmlEditorPlugin.getScaXmlImage( inactiveMarkupProposalImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( inactiveMarkupProposalImgLoc );
}
-
+
try {
- markupProposalImg = ScaXmlEditorPlugin.getScaXmlImage( markupProposalImgLoc ).createImage();
+ this.markupProposalImg = ScaXmlEditorPlugin.getScaXmlImage( markupProposalImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( markupProposalImgLoc );
}
-
+
try {
- attributeImg = ScaXmlEditorPlugin.getScaXmlImage( attributeImgLoc ).createImage();
+ this.attributeImg = ScaXmlEditorPlugin.getScaXmlImage( attributeImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( attributeImgLoc );
}
-
+
try {
- elementImg = ScaXmlEditorPlugin.getScaXmlImage( elementImgLoc ).createImage();
+ this.elementImg = ScaXmlEditorPlugin.getScaXmlImage( elementImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( elementImgLoc );
}
-
+
try {
- serverImg = ScaXmlEditorPlugin.getScaXmlImage( serverImgLoc ).createImage();
+ this.serverImg = ScaXmlEditorPlugin.getScaXmlImage( serverImgLoc ).createImage();
} catch( Exception e ) {
notFoundImages.add( serverImgLoc );
}
-
-
+
+
// Log errors for not found images
IStatus[] statuses = new IStatus[ notFoundImages.size() ];
for( int i=0; i<statuses.length; i++ ) {
statuses[ i ] = new Status(
- IStatus.ERROR,
- ScaXmlEditorPlugin.PLUGIN_ID,
- NLS.bind( Messages.ImageRegistry_0, notFoundImages.get( i )));
+ IStatus.ERROR,
+ ScaXmlEditorPlugin.PLUGIN_ID,
+ NLS.bind( Messages.ImageRegistry_0, notFoundImages.get( i )));
}
-
+
if( statuses.length > 0 ) {
- IStatus status = new MultiStatus(
- ScaXmlEditorPlugin.PLUGIN_ID,
+ IStatus status = new MultiStatus(
+ ScaXmlEditorPlugin.PLUGIN_ID,
IStatus.OK,
statuses,
Messages.ImageRegistry_2,
@@ -529,15 +529,15 @@
ScaXmlEditorPlugin.log( status );
}
}
-
+
/**
* @return the unique instance of this class.
*/
public static ImageRegistry getInstance() {
return instance;
}
-
-
+
+
/**
* Returns the associated image with the node argument.
* The association is generally based on the node name, but also in some cases on the parent type
@@ -547,12 +547,12 @@
* @return the associated image or null if none was found.
*/
public static Image getImage( Node node ) {
-
+
if( node.getNodeName() == null )
return null;
String nodeName = ScaUtils.removeNamespacePrefix( node.getNodeName());
nodeName = nodeName.toLowerCase();
-
+
// Get associated image.
if( nodeName.equals( "wire" )) //$NON-NLS-1$
return getInstance().wireImg;
@@ -566,8 +566,8 @@
return getInstance().operationImg;
if( nodeName.equals( "callback" )) //$NON-NLS-1$
return getInstance().callbackImg;
-
-
+
+
if( nodeName.equals( "implementation.java" )) //$NON-NLS-1$
return getInstance().javaImplImg;
if( nodeName.equals( "implementation.osgi" )) //$NON-NLS-1$
@@ -588,13 +588,13 @@
return getInstance().notificationImplImg;
if( nodeName.equals( "implementation.fractal" )) //$NON-NLS-1$
return getInstance().fractalImplImg;
-
-
+
+
if( nodeName.equals( "interface.java" )) //$NON-NLS-1$
return getInstance().javaInterfaceImg;
if( nodeName.equals( "interface.wsdl" )) //$NON-NLS-1$
return getInstance().wsdlInterfaceImg;
-
+
if( nodeName.equals( "binding.ws" )) //$NON-NLS-1$
return getInstance().wsBindingImg;
if( nodeName.equals( "binding.ejb" )) //$NON-NLS-1$
@@ -617,10 +617,10 @@
return getInstance().jbiBindingImg;
if( nodeName.equals( "binding.ajax" )) //$NON-NLS-1$
return getInstance().dwrBindingImg; // TODO: right binding name ???
-
+
if( nodeName.startsWith( "binding" )) //$NON-NLS-1$
return getInstance().bindingTypeImg; // FIXME: make a specific image for unknown bindings ?
-
+
if( nodeName.equals( "allow" )) //$NON-NLS-1$
return getInstance().allowImg;
if( nodeName.equals( "bindingtype" )) //$NON-NLS-1$
@@ -642,9 +642,9 @@
if( nodeName.equals( "implementationtype" )) //$NON-NLS-1$
return getInstance().implTypeImg;
if( nodeName.equals( "intent" )) //$NON-NLS-1$
- return getInstance().intentImg;
-
-
+ return getInstance().intentImg;
+
+
// Get parent node and check if it is a composite or a component.
Node parentNode = node.getParentNode();
if( parentNode == null )
@@ -653,306 +653,252 @@
boolean parentIsComposite = true;
if( parentNodeName.equals( "component" )) //$NON-NLS-1$
parentIsComposite = false;
-
+
// Get associated image for ambiguous nodes.
if( nodeName.equals( "reference" )) { //$NON-NLS-1$
if( parentIsComposite )
return getInstance().referenceImg;
- else
- return getInstance().componentReferenceImg;
+ return getInstance().componentReferenceImg;
}
-
+
if( nodeName.equals( "service" )) { //$NON-NLS-1$
if( parentIsComposite )
return getInstance().serviceImg;
- else
- return getInstance().componentServiceImg;
- }
-
+ return getInstance().componentServiceImg;
+ }
+
if( nodeName.equals( "property" )) { //$NON-NLS-1$
if( parentIsComposite )
return getInstance().propertyImg;
- else
- return getInstance().propertyValueImg;
+ return getInstance().propertyValueImg;
}
-
+
return null;
}
-
-
+
+
/**
* Delete the images.
* @see Object#finalize()
- */
+ */
@Override
protected void finalize() throws Throwable {
+
// Delete images.
// SCA basis.
- if( wireImg != null ) {
- wireImg.dispose();
- wireImg = null;
+ if( this.wireImg != null ) {
+ this.wireImg.dispose();
}
-
- if( serviceImg != null ) {
- serviceImg.dispose();
- serverImg = null;
+
+ if( this.serviceImg != null ) {
+ this.serviceImg.dispose();
}
-
- if( referenceImg != null ) {
- referenceImg.dispose();
- referenceImg = null;
+
+ if( this.referenceImg != null ) {
+ this.referenceImg.dispose();
}
-
- if( propertyImg != null ) {
- propertyImg.dispose();
- propertyImg = null;
+
+ if( this.propertyImg != null ) {
+ this.propertyImg.dispose();
}
-
- if( includeImg != null ) {
- includeImg.dispose();
- includeImg = null;
+
+ if( this.includeImg != null ) {
+ this.includeImg.dispose();
}
-
- if( compositeImg != null ) {
- compositeImg.dispose();
- compositeImg = null;
+
+ if( this.compositeImg != null ) {
+ this.compositeImg.dispose();
}
-
- if( componentImg != null ) {
- componentImg.dispose();
- componentImg = null;
+
+ if( this.componentImg != null ) {
+ this.componentImg.dispose();
}
-
- if( componentServiceImg != null ) {
- componentServiceImg.dispose();
- componentServiceImg = null;
+
+ if( this.componentServiceImg != null ) {
+ this.componentServiceImg.dispose();
}
-
- if( componentReferenceImg != null ) {
- componentReferenceImg.dispose();
- componentReferenceImg = null;
+
+ if( this.componentReferenceImg != null ) {
+ this.componentReferenceImg.dispose();
}
-
- if( propertyValueImg != null ) {
- propertyValueImg.dispose();
- propertyValueImg = null;
+
+ if( this.propertyValueImg != null ) {
+ this.propertyValueImg.dispose();
}
-
- if( callbackImg != null ) {
- callbackImg.dispose();
- callbackImg = null;
+
+ if( this.callbackImg != null ) {
+ this.callbackImg.dispose();
}
-
- if( operationImg != null ) {
- operationImg.dispose();
- operationImg = null;
+
+ if( this.operationImg != null ) {
+ this.operationImg.dispose();
}
-
+
// Implementations.
- if( scriptImplImg != null ) {
- scriptImplImg.dispose();
- scriptImplImg = null;
+ if( this.scriptImplImg != null ) {
+ this.scriptImplImg.dispose();
}
-
- if( springImplImg != null ) {
- springImplImg.dispose();
- springImplImg = null;
+
+ if( this.springImplImg != null ) {
+ this.springImplImg.dispose();
}
-
- if( xQueryImplImg != null ) {
- xQueryImplImg.dispose();
- xQueryImplImg = null;
+
+ if( this.xQueryImplImg != null ) {
+ this.xQueryImplImg.dispose();
}
-
- if( scaImplImg != null ) {
- scaImplImg.dispose();
- scaImplImg = null;
+
+ if( this.scaImplImg != null ) {
+ this.scaImplImg.dispose();
}
-
- if( resourceImplImg != null ) {
- resourceImplImg.dispose();
- resourceImplImg = null;
+
+ if( this.resourceImplImg != null ) {
+ this.resourceImplImg.dispose();
}
-
- if( osgiImplImg != null ) {
- osgiImplImg.dispose();
- osgiImplImg = null;
+
+ if( this.osgiImplImg != null ) {
+ this.osgiImplImg.dispose();
}
-
- if( notificationImplImg != null ) {
- notificationImplImg.dispose();
- notificationImplImg = null;
+
+ if( this.notificationImplImg != null ) {
+ this.notificationImplImg.dispose();
}
-
- if( javaImplImg != null ) {
- javaImplImg.dispose();
- javaImplImg = null;
+
+ if( this.javaImplImg != null ) {
+ this.javaImplImg.dispose();
}
-
- if( bpelImplImg != null ) {
- bpelImplImg.dispose();
- bpelImplImg = null;
+
+ if( this.bpelImplImg != null ) {
+ this.bpelImplImg.dispose();
}
-
- if( fractalImplImg != null ) {
- fractalImplImg.dispose();
- fractalImplImg = null;
+
+ if( this.fractalImplImg != null ) {
+ this.fractalImplImg.dispose();
}
-
+
// Interfaces.
- if( javaInterfaceImg != null ) {
- javaInterfaceImg.dispose();
- javaInterfaceImg = null;
+ if( this.javaInterfaceImg != null ) {
+ this.javaInterfaceImg.dispose();
}
-
- if( wsdlInterfaceImg != null ) {
- wsdlInterfaceImg.dispose();
- wsdlInterfaceImg = null;
+
+ if( this.wsdlInterfaceImg != null ) {
+ this.wsdlInterfaceImg.dispose();
}
-
+
// Bindings.
- if( wsBindingImg != null ) {
- wsBindingImg.dispose();
- wsBindingImg = null;
+ if( this.wsBindingImg != null ) {
+ this.wsBindingImg.dispose();
}
-
- if( scaBindingImg != null ) {
- scaBindingImg.dispose();
- scaBindingImg = null;
+
+ if( this.scaBindingImg != null ) {
+ this.scaBindingImg.dispose();
}
-
- if( rssBindingImg != null ) {
- rssBindingImg.dispose();
- rssBindingImg = null;
+
+ if( this.rssBindingImg != null ) {
+ this.rssBindingImg.dispose();
}
-
- if( rmiBindingImg != null ) {
- rmiBindingImg.dispose();
- rmiBindingImg = null;
+
+ if( this.rmiBindingImg != null ) {
+ this.rmiBindingImg.dispose();
}
-
- if( notificationBindingImg != null ) {
- notificationBindingImg.dispose();
- notificationBindingImg = null;
+
+ if( this.notificationBindingImg != null ) {
+ this.notificationBindingImg.dispose();
}
-
- if( jsonRpcBindingImg != null ) {
- jsonRpcBindingImg.dispose();
- jsonRpcBindingImg = null;
+
+ if( this.jsonRpcBindingImg != null ) {
+ this.jsonRpcBindingImg.dispose();
}
-
- if( httpBindingImg != null ) {
- httpBindingImg.dispose();
- httpBindingImg = null;
+
+ if( this.httpBindingImg != null ) {
+ this.httpBindingImg.dispose();
}
-
- if( ejbSessionBeanBindingImg != null ) {
- ejbSessionBeanBindingImg.dispose();
- ejbSessionBeanBindingImg = null;
+
+ if( this.ejbSessionBeanBindingImg != null ) {
+ this.ejbSessionBeanBindingImg.dispose();
}
-
- if( dwrBindingImg != null ) {
- dwrBindingImg.dispose();
- dwrBindingImg = null;
+
+ if( this.dwrBindingImg != null ) {
+ this.dwrBindingImg.dispose();
}
-
- if( atomBindingImg != null ) {
- atomBindingImg.dispose();
- atomBindingImg = null;
+
+ if( this.atomBindingImg != null ) {
+ this.atomBindingImg.dispose();
}
-
- if( jbiBindingImg != null ) {
- jbiBindingImg.dispose();
- jbiBindingImg = null;
+
+ if( this.jbiBindingImg != null ) {
+ this.jbiBindingImg.dispose();
}
-
+
// Others.
- if( allowImg != null ) {
- allowImg.dispose();
- allowImg = null;
+ if( this.allowImg != null ) {
+ this.allowImg.dispose();
}
-
- if( constrainingTypeImg != null ) {
- constrainingTypeImg.dispose();
- constrainingTypeImg = null;
+
+ if( this.constrainingTypeImg != null ) {
+ this.constrainingTypeImg.dispose();
}
-
- if( definitionsTypeImg != null ) {
- definitionsTypeImg.dispose();
- definitionsTypeImg = null;
+
+ if( this.definitionsTypeImg != null ) {
+ this.definitionsTypeImg.dispose();
}
-
- if( denyAllImg != null ) {
- denyAllImg.dispose();
- denyAllImg = null;
+
+ if( this.denyAllImg != null ) {
+ this.denyAllImg.dispose();
}
-
- if( implTypeImg != null ) {
- implTypeImg.dispose();
- implTypeImg = null;
+
+ if( this.implTypeImg != null ) {
+ this.implTypeImg.dispose();
}
-
- if( intentImg != null ) {
- intentImg.dispose();
- intentImg = null;
+
+ if( this.intentImg != null ) {
+ this.intentImg.dispose();
}
-
- if( permitAllImg != null ) {
- permitAllImg.dispose();
- permitAllImg = null;
+
+ if( this.permitAllImg != null ) {
+ this.permitAllImg.dispose();
}
-
- if( policySetImg != null ) {
- policySetImg.dispose();
- policySetImg = null;
+
+ if( this.policySetImg != null ) {
+ this.policySetImg.dispose();
}
-
- if( bindingTypeImg != null ) {
- bindingTypeImg.dispose();
- bindingTypeImg = null;
+
+ if( this.bindingTypeImg != null ) {
+ this.bindingTypeImg.dispose();
}
-
- if( runAsImg != null ) {
- runAsImg.dispose();
- runAsImg = null;
+
+ if( this.runAsImg != null ) {
+ this.runAsImg.dispose();
}
-
- if( componentTypeImg != null ) {
- componentTypeImg.dispose();
- componentTypeImg = null;
+
+ if( this.componentTypeImg != null ) {
+ this.componentTypeImg.dispose();
}
-
+
// Auto-completion.
- if( activeMarkupProposalImg != null ) {
- activeMarkupProposalImg.dispose();
- activeMarkupProposalImg = null;
+ if( this.activeMarkupProposalImg != null ) {
+ this.activeMarkupProposalImg.dispose();
}
-
- if( inactiveMarkupProposalImg != null ) {
- inactiveMarkupProposalImg.dispose();
- inactiveMarkupProposalImg = null;
+
+ if( this.inactiveMarkupProposalImg != null ) {
+ this.inactiveMarkupProposalImg.dispose();
}
-
- if( markupProposalImg != null ) {
- markupProposalImg.dispose();
- markupProposalImg = null;
+
+ if( this.markupProposalImg != null ) {
+ this.markupProposalImg.dispose();
}
-
- if( attributeImg != null ) {
- attributeImg.dispose();
- attributeImg = null;
+
+ if( this.attributeImg != null ) {
+ this.attributeImg.dispose();
}
-
- if( elementImg != null ) {
- elementImg.dispose();
- elementImg = null;
+
+ if( this.elementImg != null ) {
+ this.elementImg.dispose();
}
-
- if( serverImg != null ) {
- serverImg.dispose();
- serverImg = null;
+
+ if( this.serverImg != null ) {
+ this.serverImg.dispose();
}
-
+
// Call to super.
super.finalize();
}
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/ScaXmlEditorPlugin.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/ScaXmlEditorPlugin.java 2009-08-27 10:38:15 UTC (rev 3303)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/ScaXmlEditorPlugin.java 2009-08-27 15:13:13 UTC (rev 3304)
@@ -27,7 +27,7 @@
* @author Vincent Zurczak - EBM WebSourcing
*/
public class ScaXmlEditorPlugin extends AbstractUIPlugin {
-
+
/** The plug-in ID */
public static final String PLUGIN_ID = "org.eclipse.stp.sca.xmleditor"; //$NON-NLS-1$
/** The plug-in ID of the SCA Edit plug-in (required to reuse icons). */
@@ -36,15 +36,15 @@
public static final String SCA_TUSCANY_EDIT_PLUGIN_ID = "org.eclipse.stp.sca.domainmodel.tuscany.edit"; //$NON-NLS-1$
/** The plug-in ID of the SCA Frascati Edit plug-in (required to reuse icons). */
public static final String SCA_FRASCATI_EDIT_PLUGIN_ID = "org.eclipse.stp.sca.domainmodel.frascati.edit"; //$NON-NLS-1$
-
+
/** The shared instance. */
private static ScaXmlEditorPlugin plugin;
-
+
/**
* The constructor.
*/
- public ScaXmlEditorPlugin() {
+ public ScaXmlEditorPlugin() {
}
/*
@@ -74,7 +74,7 @@
public static ScaXmlEditorPlugin getDefault() {
return plugin;
}
-
+
/**
* Returns an image descriptor for the image file at the given plug-in relative path.
* @param path the path
@@ -83,18 +83,18 @@
public static ImageDescriptor getImageDescriptor( String path ) {
return imageDescriptorFromPlugin( PLUGIN_ID, path );
}
-
+
/**
* Log an error into the log file.
*
* @param message the message to log
* @param e the exception to log
* @param severity see {@link IStatus} constants
- */
+ */
public static void log( String message, Exception e, int severity ) {
String errorMessage = message;
if( errorMessage == null ) {
- if( e != null && e.getMessage() != null )
+ if( e != null && e.getMessage() != null )
errorMessage = e.getMessage();
else
errorMessage = NLS.bind( Messages.ScaCompositeXmlEditorPlugin_1, PLUGIN_ID );
@@ -102,72 +102,70 @@
IStatus status = new Status( severity, PLUGIN_ID, IStatus.OK, errorMessage, e );
log( status );
}
-
-
+
+
public static void log( IStatus status ) {
getDefault().getLog().log( status );
-
+
// Open the log view
try {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
page.showView( "org.eclipse.pde.runtime.LogView" ); //$NON-NLS-1$
-
+
} catch( PartInitException e1 ) {
e1.printStackTrace();
}
}
-
-
+
+
/**
* Get SCA icons provided by this plug-in in its "icons/full/obj16/" folder.
*
- * @param iconFileName the file name of the icon (e.g. "icon.gif").
+ * @param iconFileName the file name of the icon (e.g. "icon.gif").
* @return the associated image descriptor or null if it was not found.
*/
public static ImageDescriptor getScaXmlImage( String iconFileName ) {
return imageDescriptorFromPlugin( PLUGIN_ID, "icons/full/obj16/" + iconFileName ); //$NON-NLS-1$
}
-
-
+
+
/**
* Get SCA icons provided by the *.sca.edit plug-in in its "icons/full/obj16/" folder.
*
- * @param iconFileName the file name of the icon (e.g. "icon.gif").
+ * @param iconFileName the file name of the icon (e.g. "icon.gif").
* @return the associated image descriptor or null if it was not found.
*/
public static ImageDescriptor getScaCommonImage( String iconFileName ) {
return imageDescriptorFromPlugin( SCA_COMMON_EDIT_PLUGIN_ID, "icons/full/obj16/" + iconFileName ); //$NON-NLS-1$
}
-
-
+
+
/**
* Get SCA icons provided by the *.sca.tuscany.edit plug-in in its "icons/full/obj16/" folder.
*
- * @param iconFileName the file name of the icon (e.g. "icon.gif").
+ * @param iconFileName the file name of the icon (e.g. "icon.gif").
* @return the associated image descriptor if it was found, a default image if the Tuscany
* plug-in is not installed or null if it installed but the path is incorrect
*/
public static ImageDescriptor getScaTuscanyImage( String iconFileName ) {
-
+
if( Platform.getBundle( SCA_TUSCANY_EDIT_PLUGIN_ID ) != null )
return imageDescriptorFromPlugin( SCA_TUSCANY_EDIT_PLUGIN_ID, "icons/full/obj16/" + iconFileName ); //$NON-NLS-1$
- else
- return imageDescriptorFromPlugin( PLUGIN_ID, "icons/full/obj16/defaultScaImage.gif" ); //$NON-NLS-1$
+ return imageDescriptorFromPlugin( PLUGIN_ID, "icons/full/obj16/defaultScaImage.gif" ); //$NON-NLS-1$
}
-
-
+
+
/**
* Get SCA icons provided by the *.sca.frascati.edit plug-in in its "icons/full/obj16/" folder.
*
- * @param iconFileName the file name of the icon (e.g. "icon.gif").
+ * @param iconFileName the file name of the icon (e.g. "icon.gif").
* @return the associated image descriptor if it was found, a default image if the FraSCAti
* plug-in is not installed or null if it installed but the path is incorrect
*/
public static ImageDescriptor getScaFrascatiImage( String iconFileName ) {
-
+
if( Platform.getBundle( SCA_FRASCATI_EDIT_PLUGIN_ID ) != null )
return imageDescriptorFromPlugin( SCA_FRASCATI_EDIT_PLUGIN_ID, "icons/full/obj16/" + iconFileName ); //$NON-NLS-1$
- else
- return imageDescriptorFromPlugin( PLUGIN_ID, "icons/full/obj16/defaultScaImage.gif" ); //$NON-NLS-1$
+ return imageDescriptorFromPlugin( PLUGIN_ID, "icons/full/obj16/defaultScaImage.gif" ); //$NON-NLS-1$
}
}
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/completion/AbstractProcessor.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/completion/AbstractProcessor.java 2009-08-27 10:38:15 UTC (rev 3303)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/completion/AbstractProcessor.java 2009-08-27 15:13:13 UTC (rev 3304)
@@ -21,7 +21,7 @@
* @author Vincent Zurczak - EBM WebSourcing
*/
public abstract class AbstractProcessor implements IContentAssistProcessor {
-
+
/** The underlying model object of the edited file. */
protected Document domDoc;
/** */
@@ -29,14 +29,14 @@
/** */
protected int offset;
-
+
/**
* Compute proposals at the given offset.
* @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int)
*
* @param xmlContextualDom
* @param domDoc the underlying model object of the edited file.
- * @return
+ * @return a list of proposals
*/
public ICompletionProposal[] computeCompletionProposals( XmlContextualDom xmlContextualDom, Document domDoc, int offset ) {
this.domDoc = domDoc;
@@ -44,14 +44,14 @@
this.offset = offset;
return computeCompletionProposals();
}
-
+
/**
*
*/
public final ICompletionProposal[] computeCompletionProposals( ITextViewer viewer, int offset ) {
- xmlContextualDom = new XmlContextualDom( offset, viewer );
+ this.xmlContextualDom = new XmlContextualDom( offset, viewer );
return computeCompletionProposals();
}
-
+
protected abstract ICompletionProposal[] computeCompletionProposals();
}
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/completion/ProxyProcessor.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/completion/ProxyProcessor.java 2009-08-27 10:38:15 UTC (rev 3303)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/completion/ProxyProcessor.java 2009-08-27 15:13:13 UTC (rev 3304)
@@ -211,7 +211,7 @@
continue;
for( char c : cs )
- chars.add( new Character( c ));
+ chars.add( Character.valueOf( c ));
}
if( inheritedProcessors != null ) {
@@ -221,7 +221,7 @@
continue;
for( char c : cs )
- chars.add( new Character( c ));
+ chars.add( Character.valueOf( c ));
}
}
@@ -248,7 +248,7 @@
continue;
for( char c : cs )
- chars.add( new Character( c ));
+ chars.add( Character.valueOf( c ));
}
if( inheritedProcessors != null ) {
@@ -258,7 +258,7 @@
continue;
for( char c : cs )
- chars.add( new Character( c ));
+ chars.add( Character.valueOf( c ));
}
}
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/completion/XmlContextualDom.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/completion/XmlContextualDom.java 2009-08-27 10:38:15 UTC (rev 3303)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/completion/XmlContextualDom.java 2009-08-27 15:13:13 UTC (rev 3304)
@@ -14,7 +14,6 @@
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -41,7 +40,7 @@
/**
* This classes builds a <i>contextual DOM document</i>.
* <p>
- * This document is built from an ITextViewer using the elements defined between
+ * This document is built from an ITextViewer using the elements defined between
* the positions 0 and an offset (typically the position where the cursor was).
* However, in the case where the offset is inside an element, the parsing goes on
* until the closing mark-up symbol '>' is found. Thus, complete attributes following
@@ -60,15 +59,15 @@
* Otherwise, you are inside a mark-up writing its name, e.g. <code><sca:i...</code>.<br />
* The presence (or not) of the name space prefix is not important here, provided that this prefix
* has been defined completely in the previous mark-ups or in this mark-up (after the offset).<br />
- * In this case, the last node is the node in construction or is null if its prefix or default name
- * space could not be resolved.
+ * In this case, the last node is the node in construction or is null if its prefix or default name
+ * space could not be resolved.
* </li>
*
* <li>
* <b>ELEMENT_VALUE:</b><br />
* The offset is at a location where we may expect a new mark-up or a mark-up value
* (e.g. after a '>' symbol).<br />
- * In this case, the last node is the parent element.
+ * In this case, the last node is the parent element.
* </li>
*
* <li>
@@ -86,7 +85,7 @@
* <br /><br />
*
* The last attribute is the one currently edited (its value is the value until the offset).<br />
- * The following part of the attribute can be known from @link {@link #getEndOfAttributeValue()}.
+ * The following part of the attribute can be known from @link {@link #getEndOfAttributeValue()}.
* This last attribute can be used to determine the part of the attribute name already typed in.
* </li>
*
@@ -103,13 +102,13 @@
*
* <li>
* <b>INSIDE_MARK_UP:</b><br />
- * We are inside a mark-up but not in one of the previous states,
- * e.g. "attrName = {offset} attrValue".
+ * We are inside a mark-up but not in one of the previous states,
+ * e.g. "attrName = {offset} attrValue".
* </li>
*
* <li>
* <b>CORRUPTED:</b><br />
- * An exception occurred while analyzing the document
+ * An exception occurred while analyzing the document
* (that may be invalid XML or an undeclared name space).
* In this case, no field of this class may be considered as right, except the status.
*
@@ -121,7 +120,7 @@
* </code>
*
* <br /><br />
- * If the offset is before the name space declaration but that this declaration is made
+ * If the offset is before the name space declaration but that this declaration is made
* in the current element, then this status won't be set for an <i>undeclared name space</i> reason.
* Indeed, the parsing will go on until the end of the element and thus, the name space will be resolved.
* </li>
@@ -148,7 +147,7 @@
* {@link #getEndOfAttributeValue()} returns "ost".
* </p>
* <p>
- * <span style="font-weight: bold; text-decoration: underline;">N.B.:</span>
+ * <span style="font-weight: bold; text-decoration: underline;">N.B.:</span>
* this class is more <i>flexible</i> than usual XML parsers and allows some
* limit cases: empty name space URIs - not null, comments, processing instructions
* and CDATA are parsed but not added to the document. These elements are not even used
@@ -159,12 +158,12 @@
* @author Vincent Zurczak - EBM WebSourcing
*/
public class XmlContextualDom {
-
- /**
+
+ /**
* The DOM document built from the contextual position.
* <p>
* This document is made up of the elements from the beginning of the document
- * until the position offset in the document, plus the complete attributes following
+ * until the position offset in the document, plus the complete attributes following
* the offset and part of the last found element.
* </p>
*/
@@ -173,7 +172,7 @@
* The last found node, which is part of the built document.
* <p>
* It includes information about the current node (until and after the offset).
- * In case where we are in an attribute value position, the value of this element
+ * In case where we are in an attribute value position, the value of this element
* is trunked at the offset.
* </p>
*/
@@ -183,21 +182,21 @@
* @see PositionStatus
*/
private PositionStatus status = PositionStatus.OTHER;
- /**
+ /**
* The last found attribute (which may have incomplete information).
* <p>
- * It has a meaningful value only when the status is
+ * It has a meaningful value only when the status is
* {@link PositionStatus#ATTRIBUTE_NAME}, {@link PositionStatus#ATTRIBUTE_VALUE},
* {@link PositionStatus#NS_DECLARATION} or {@link PositionStatus#NS_URI}.
- * </p>
+ * </p>
*/
private Attr lastAttr;
- /**
+ /**
* True if the offset is located right after an opening mark-up '<'.
- * <p>False otherwise (and by default).</p>
+ * <p>False otherwise (and by default).</p>
*/
private boolean rightAfterOpeningMarkUp = false;
- /**
+ /**
* The attribute value part located after the offset.
* <p>
* It has a meaningful value only when the status is {@link PositionStatus#ATTRIBUTE_VALUE}
@@ -208,15 +207,15 @@
/**
* The offset position in the viewer, given in the constructor.
*/
- private int offset;
-
-
+ private final int offset;
+
+
/**
* Indicate the status of the offset position in the document.
*/
public enum PositionStatus {
/** The offset is after one or several non-white space characters found after a '<' symbol. */
- ELEMENT_NAME,
+ ELEMENT_NAME,
/** The offset is inside a mark-up, e.g. after a closing mark-up symbol '>'. */
ELEMENT_VALUE,
/** The offset is before a '=' symbol and after a white space or a closing quote. */
@@ -224,24 +223,24 @@
/** The offset is after a '=' symbol. */
ATTRIBUTE_VALUE,
/** Equivalent to {@link PositionStatus#ATTRIBUTE_NAME} but the attribute name begins with <b>xmlns</b>. */
- NS_DECLARATION,
+ NS_DECLARATION,
/** Equivalent to {@link PositionStatus#ATTRIBUTE_VALUE} but the attribute name begins with <b>xmlns</b>. */
- NS_URI,
+ NS_URI,
/** Inside a mark-up but not in one of the previous positions, e.g. "attrName = {offset} attrValue". */
INSIDE_MARK_UP,
/** An exception occurred, indicating this status is not relevant. */
CORRUPTED,
/** Any other context. */
OTHER
- }
-
-
+ }
+
+
/**
* @return the status
* @see #status
*/
public PositionStatus getStatus() {
- return status;
+ return this.status;
}
@@ -250,7 +249,7 @@
* @see #endOfAttributeValue
*/
public String getEndOfAttributeValue() {
- return endOfAttributeValue;
+ return this.endOfAttributeValue;
}
@@ -259,25 +258,25 @@
* @see #doc
*/
public Document getDoc() {
- return doc;
+ return this.doc;
}
-
+
/**
* @return the last node of the contextual DOM document.
* @see #lastNode
*/
public Node getLastNode() {
- return lastNode;
+ return this.lastNode;
}
-
-
+
+
/**
* @return the lastAttr
* @see #lastAttr
*/
public Attr getLastAttr() {
- return lastAttr;
+ return this.lastAttr;
}
@@ -286,21 +285,21 @@
* @see #rightAfterOpeningMarkUp
*/
public boolean isRightAfterOpeningMarkUp() {
- return rightAfterOpeningMarkUp;
+ return this.rightAfterOpeningMarkUp;
}
-
-
+
+
/**
* Constructor which builds the contextual DOM from a string.
* @param offset the offset in the IDocument
* @param xmlString the XML string
*/
public XmlContextualDom( int offset, String xmlString ) {
- this.offset = offset;
+ this.offset = offset;
parseViewerUntilOffset( offset, xmlString );
}
-
+
/**
* Constructor which builds the contextual DOM from an ITextViewer.
* @param offset the offset in the IDocument
@@ -308,21 +307,21 @@
*/
public XmlContextualDom( int offset, ITextViewer viewer ) {
this.offset = offset;
-
+
ITextSelection selection = (ITextSelection) viewer.getSelectionProvider().getSelection();
if( selection.getOffset() == offset )
offset = selection.getOffset() + selection.getLength(); // FIXME: check why (WTP...)
-
- String xmlString = viewer.getDocument().get();
+
+ String xmlString = viewer.getDocument().get();
parseViewerUntilOffset( offset, xmlString );
}
-
-
+
+
/**
* Parse an IDocument to build a contextual DOM.
* <p>
* This DOM is made up of the XML items defined in the XML string
- * from the position 0 (the beginning of the document)
+ * from the position 0 (the beginning of the document)
* until the offset position.
* </p>
* <p>
@@ -338,7 +337,7 @@
* Built a string containing the viewer characters between the position 0 and offset.
* </li>
* <li>
- * Use this string to read mark-ups sequentially, build
+ * Use this string to read mark-ups sequentially, build
* a DOM document and fill in this class fields.
* </li>
* </ul>
@@ -348,29 +347,31 @@
* @param xmlString
*/
private void parseViewerUntilOffset( int offset, String xmlString ) {
- try {
+
+ try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
- doc = builder.newDocument();
-
- doc.setXmlVersion( "1.0" ); //$NON-NLS-1$
- doc.setXmlStandalone( true );
-
- int index = 0;
- Node currentNode = doc;
- while( index < offset ) {
- NodeAndOffset nao = readMarkup( xmlString, index, currentNode );
- index = nao.index;
- currentNode = nao.node != null ? nao.node : currentNode;
-
- if( index - 1 < offset && xmlString.charAt( index - 1 ) == '>' )
- status = PositionStatus.ELEMENT_VALUE;
- }
-
- lastNode = currentNode;
+ this.doc = builder.newDocument();
+
+ this.doc.setXmlVersion( "1.0" ); //$NON-NLS-1$
+ this.doc.setXmlStandalone( true );
+
+ int index = 0;
+ Node currentNode = this.doc;
+ while( index < offset ) {
+ NodeAndOffset nao = readMarkup( xmlString, index, currentNode );
+ index = nao.index;
+ currentNode = nao.node != null ? nao.node : currentNode;
+
+ if( index - 1 < offset && xmlString.charAt( index - 1 ) == '>' )
+ this.status = PositionStatus.ELEMENT_VALUE;
+ }
+
+ this.lastNode = currentNode;
+
} catch( Exception e ) {
- status = PositionStatus.CORRUPTED;
- }
+ this.status = PositionStatus.CORRUPTED;
+ }
}
@@ -390,10 +391,10 @@
* Comments, CDATA and processing instructions are now added in the DOM document.<br />
* Closing mark-ups make the returned node to be the current one's parent.<br />
* Same things for <i>mark-ups which are not mark-ups</i>, e.g. element values.<br />
- * Other mark-ups are considered to be opening or single mark-ups.
+ * Other mark-ups are considered to be opening or single mark-ups.
* They are then parsed to get attributes and name spaces.
* </p>
- *
+ *
* @param xmlString the source string to parse
* @param index the start position for the parsing (expected to be less than the text length)
* @param currentNode the node used as the parent for the mark-up to create
@@ -403,49 +404,49 @@
private NodeAndOffset readMarkup( String xmlString, int index, Node currentNode ) throws SAXException {
// A mark-up begins with '<'.
// If not, we assume it is a value for the current node (possibly empty).
- status = PositionStatus.ELEMENT_VALUE;
+ this.status = PositionStatus.ELEMENT_VALUE;
char c = xmlString.charAt( index );
- while( Character.isWhitespace( c ) && index < offset )
+ while( Character.isWhitespace( c ) && index < this.offset )
c = xmlString.charAt( ++ index );
-
- if( index >= offset )
+
+ if( index >= this.offset )
return new NodeAndOffset( index, currentNode );
-
- if( c != '<' ) {
+
+ if( c != '<' ) {
String value = ""; //$NON-NLS-1$
- while( index < offset && c != '<' ) {
+ while( index < this.offset && c != '<' ) {
value += c;
- c = xmlString.charAt( ++ index );
+ c = xmlString.charAt( ++ index );
}
-
- currentNode.setNodeValue( value.trim());
+
+ currentNode.setNodeValue( value.trim());
return new NodeAndOffset( index, currentNode );
}
-
+
// Be here means we have found '<'.
- if( ++ index >= offset ) {
- status = PositionStatus.ELEMENT_NAME;
- rightAfterOpeningMarkUp = true;
+ if( ++ index >= this.offset ) {
+ this.status = PositionStatus.ELEMENT_NAME;
+ this.rightAfterOpeningMarkUp = true;
return new NodeAndOffset( index );
}
-
+
c = xmlString.charAt( index );
switch( c ) {
- case '/': // Closing mark-up
- return readEndingMarkup( xmlString, index, currentNode );
-
- case '?': // Processing Instructions
- return readPIMarkup( xmlString, index, currentNode );
-
- case '!': // Comments and CDATA
- return readCommentOrCDataMarkup( xmlString, index, currentNode );
-
- default: // Other mark-ups: handle "<.../>" and "<..>"
- return readEffectiveMarkup( xmlString, index, currentNode );
+ case '/': // Closing mark-up
+ return readEndingMarkup( xmlString, index, currentNode );
+
+ case '?': // Processing Instructions
+ return readPIMarkup( xmlString, index, currentNode );
+
+ case '!': // Comments and CDATA
+ return readCommentOrCDataMarkup( xmlString, index, currentNode );
+
+ default: // Other mark-ups: handle "<.../>" and "<..>"
+ return readEffectiveMarkup( xmlString, index, currentNode );
}
}
-
+
/**
* Read a comment or a CDATA mark-up in the XML string from the given index.
* <p>
@@ -460,38 +461,38 @@
* @throws SAXException if the XML string is syntactically invalid
*/
private NodeAndOffset readCommentOrCDataMarkup( String xmlString, int index, Node currentNode ) throws SAXException {
- status = PositionStatus.OTHER;
- if( ++ index >= offset )
+ this.status = PositionStatus.OTHER;
+ if( ++ index >= this.offset )
return new NodeAndOffset( index );
-
+
char c = xmlString.charAt( index );
- if( ++ index >= offset )
+ if( ++ index >= this.offset )
return new NodeAndOffset( index );
-
+
char c2 = xmlString.charAt( index );
if( c != c2 || ( c2 != '-' && c2 != '[' ))
throw new SAXException( "Found an invalid sequence of symbols \"<!" + c + c2 + "\" (position = " + index + ")." ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
+
boolean patternFound = false; // Looking for "--" or "]]"
- while( !patternFound && index < offset ) {
- while( index < offset && (c = xmlString.charAt( index )) != c2 )
+ while( !patternFound && index < this.offset ) {
+ while( index < this.offset && (c = xmlString.charAt( index )) != c2 )
index ++;
-
- if( ++ index >= offset )
+
+ if( ++ index >= this.offset )
return new NodeAndOffset( index );
else if( c2 == xmlString.charAt( index ))
patternFound = true;
}
- if( ++ index >= offset )
+ if( ++ index >= this.offset )
return new NodeAndOffset( index );
else if( xmlString.charAt( index ) != '>' )
throw new SAXException( "Found a '" + c2 + c2 + "' sequence not followed by '>' (position = " + index + ")." ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
else
return new NodeAndOffset( index + 1 );
}
-
+
/**
* Read a processing instruction mark-up in the XML string from the given index.
* <p>
@@ -506,20 +507,20 @@
* @throws SAXException if the XML string is syntactically invalid
*/
private NodeAndOffset readPIMarkup( String xmlString, int index, Node currentNode ) throws SAXException {
- status = PositionStatus.OTHER;
+ this.status = PositionStatus.OTHER;
index ++;
- while( index < offset && xmlString.charAt( index ) != '?' )
+ while( index < this.offset && xmlString.charAt( index ) != '?' )
index ++;
-
- if( ++ index >= offset )
+
+ if( ++ index >= this.offset )
return new NodeAndOffset( index );
else if( xmlString.charAt( index ) == '>' )
return new NodeAndOffset( index + 1 );
else
throw new SAXException( "Found a '?' symbol in a processing instruction and not followed by '>' (position =" + index + ")." ); //$NON-NLS-1$ //$NON-NLS-2$
}
-
+
/**
* Read a closing mark-up in the XML string from the given index.
* <p>
@@ -534,33 +535,33 @@
* @throws SAXException if the XML string is syntactically invalid
*/
private NodeAndOffset readEndingMarkup( String xmlString, int index, Node currentNode ) {
- status = PositionStatus.INSIDE_MARK_UP;
+ this.status = PositionStatus.INSIDE_MARK_UP;
char c = ' ';
index ++;
- while( index < offset && (c = xmlString.charAt( index )) != '>' )
+ while( index < this.offset && (c = xmlString.charAt( index )) != '>' )
index ++;
-
+
if( c == '>' )
- status = PositionStatus.OTHER;
-
+ this.status = PositionStatus.OTHER;
+
return new NodeAndOffset( index + 1, currentNode.getParentNode());
}
-
+
/**
* Read an opening or single mark-up in the XML string from the given index.
* <p>
* This methods handles <code><.../></code> and <code><...></code> cases.<br />
* Attributes, name spaces are registered during the parsing of this mark-up.<br />
* If the mark-up is correct and not empty (the name's length is longer than one),
- * then an element is created and appended to the built DOM document.
+ * then an element is created and appended to the built DOM document.
* </p>
* <p>
* The result indicates that whether the end of the string was reached or
* that the index is the position right after the one of the closing mark-up symbol.
* </p>
* <p>
- * In the case where the offset was found before the end of the mark-up,
+ * In the case where the offset was found before the end of the mark-up,
* the following complete attributes are parsed anyway and appended to the built node.
* </p>
*
@@ -570,52 +571,52 @@
* @return a bean containing the node and the index to use for the next call to this method
* @throws SAXException if the XML string is syntactically invalid
*/
- private NodeAndOffset readEffectiveMarkup( String xmlString, int index, Node currentNode ) throws SAXException {
+ private NodeAndOffset readEffectiveMarkup( String xmlString, int index, Node currentNode ) throws SAXException {
//
// Get element name
String elementName = ""; //$NON-NLS-1$
char c = '\n';
-
- while( index < offset && Character.isWhitespace( xmlString.charAt( index )))
+
+ while( index < this.offset && Character.isWhitespace( xmlString.charAt( index )))
index ++;
- while( index < offset
- && ( c = xmlString.charAt( index )) != '/'
+ while( index < this.offset
+ && ( c = xmlString.charAt( index )) != '/'
&& c != '>' && !Character.isWhitespace( c )) {
elementName += xmlString.charAt( index );
index ++;
}
-
+
//
// Get the rest of the mark-up and foresee the case where the mark-up is not closed
- int offsetInEndOfMarkup = offset - index;
+ int offsetInEndOfMarkup = this.offset - index;
String endOfMarkup = ""; //$NON-NLS-1$
boolean isSngleMarkupBeforeOffset = false;
- boolean isInAttrValue = false;;
-
- while( index < xmlString.length()) {
+ boolean isInAttrValue = false;
+
+ while( index < xmlString.length()) {
c = xmlString.charAt( index ++ );
if( c== '\'' || c == '"' )
isInAttrValue = !isInAttrValue;
-
+
if( c == '>' || ( c == '<' && !isInAttrValue )) {
if( endOfMarkup.endsWith( "/" )) { //$NON-NLS-1$
endOfMarkup = endOfMarkup.substring( 0, endOfMarkup.length() - 1 );
- isSngleMarkupBeforeOffset = (index - 1) < offset;
+ isSngleMarkupBeforeOffset = (index - 1) < this.offset;
}
break;
}
- else
- endOfMarkup += c;
+
+ endOfMarkup += c;
}
-
+
//
// Processing attributes
- String[] offsetSides = new String[ 0 ];
+ String[] offsetSides;
if( offsetInEndOfMarkup > 0 && endOfMarkup.length() >= offsetInEndOfMarkup ) // The offset is inside the mark-up
offsetSides = new String[] { endOfMarkup.substring( 0, offsetInEndOfMarkup ), endOfMarkup.substring( offsetInEndOfMarkup ) };
else
offsetSides = new String[] { endOfMarkup };
-
+
//
// "Patch" for the case " {offset}beginningOfAttribute"
if( offsetSides.length == 2 ) {
@@ -625,43 +626,43 @@
}
// End of "patch"
//
-
+
Pattern attrPattern = Pattern.compile( "(\\s){1}([\\w:])*(\\s)*=(\\s)*['\"]([^'\"])*['\"]", Pattern.MULTILINE ); //$NON-NLS-1$
Map<String, String> attributes = new LinkedHashMap<String, String> ();
for( int i=0; i<offsetSides.length; i++ ) {
Matcher matcher = attrPattern.matcher( offsetSides[ i ]);
while( matcher.find()) {
-
+
String attrPart = matcher.group();
offsetSides[ i ] = offsetSides[ i ].replace( attrPart, "" ); //$NON-NLS-1$
-
+
String[] attrParts = attrPart.split( "=" ); //$NON-NLS-1$
String key = attrParts[ 0 ].trim();
-
+
String attrValue = attrParts[ 1 ].trim();
attrValue = attrValue.substring( 1, attrValue.length() - 1 ); // remove surrounding quotes
- attributes.put( key, attrValue );
+ attributes.put( key, attrValue );
}
}
-
+
//
// Get the partial remaining attribute, if any
if( offsetSides[ 0 ].trim().length() == 0 ) {
attributes.put( "", "" ); //$NON-NLS-1$ //$NON-NLS-2$
- status = PositionStatus.ATTRIBUTE_NAME;
+ this.status = PositionStatus.ATTRIBUTE_NAME;
}
-
+
else {
String[] parts = offsetSides[ 0 ].split( "=" ); //$NON-NLS-1$
-
+
if( parts.length == 1 ) {
// Status
char lastChar = parts[ 0 ].charAt( parts[ 0 ].length() - 1 );
if( Character.isWhitespace( lastChar ))
- status = PositionStatus.INSIDE_MARK_UP;
+ this.status = PositionStatus.INSIDE_MARK_UP;
else
- status = PositionStatus.ATTRIBUTE_NAME;
-
+ this.status = PositionStatus.ATTRIBUTE_NAME;
+
// Partial attribute ?
if( Character.isWhitespace( parts[ 0 ].charAt( 0 )))
attributes.put( parts[ 0 ].trim(), "" ); //$NON-NLS-1$
@@ -670,12 +671,12 @@
// Status
String value = parts[ 1 ].trim();
value = value.length() > 0 ? value.substring( 1 ) : value;
-
+
if( parts[ 1 ].matches( "(\\s)*['\"]([^'\"]*)" )) //$NON-NLS-1$
- status = PositionStatus.ATTRIBUTE_VALUE;
- else
- status = PositionStatus.INSIDE_MARK_UP;
-
+ this.status = PositionStatus.ATTRIBUTE_VALUE;
+ else
+ this.status = PositionStatus.INSIDE_MARK_UP;
+
// Partial attribute ?
if( Character.isWhitespace( parts[ 0 ].charAt( 0 )))
attributes.put( parts[ 0 ].trim(), value );
@@ -683,109 +684,113 @@
else
throw new SAXException( Messages.XmlContextualDom_0 );
}
-
+
//
// Attribute value after the offset
- if( offsetSides.length == 2 && status == PositionStatus.ATTRIBUTE_VALUE ) {
- endOfAttributeValue = offsetSides[ 1 ].trim();
- endOfAttributeValue = endOfAttributeValue.substring( 0, endOfAttributeValue.length() - 1 );
+ if( offsetSides.length == 2 && this.status == PositionStatus.ATTRIBUTE_VALUE ) {
+ this.endOfAttributeValue = offsetSides[ 1 ].trim();
+ this.endOfAttributeValue = this.endOfAttributeValue.substring( 0, this.endOfAttributeValue.length() - 1 );
}
-
+
//
// NS_URI and NS_DECLARATION
- if( lastAttr != null && lastAttr.getName().startsWith( "xmlns" )) { //$NON-NLS-1$
- if( status == PositionStatus.ATTRIBUTE_NAME )
- status = PositionStatus.NS_DECLARATION;
- else if( status == PositionStatus.ATTRIBUTE_VALUE )
- status = PositionStatus.NS_URI;
+ if( this.lastAttr != null && this.lastAttr.getName().startsWith( "xmlns" )) { //$NON-NLS-1$
+ if( this.status == PositionStatus.ATTRIBUTE_NAME )
+ this.status = PositionStatus.NS_DECLARATION;
+ else if( this.status == PositionStatus.ATTRIBUTE_VALUE )
+ this.status = PositionStatus.NS_URI;
}
-
-
+
+
Element elt = createElement( currentNode, elementName, attributes );
if( offsetInEndOfMarkup <= 0 )
- status = PositionStatus.ELEMENT_NAME;
-
+ this.status = PositionStatus.ELEMENT_NAME;
+
if( isSngleMarkupBeforeOffset )
return new NodeAndOffset( index, currentNode );
return new NodeAndOffset( index, elt );
}
-
-
+
+
/**
* Create an element and append it in the built DOM document.
*
* @param parentNode the parent of the element to create
* @param elementName the element name found during the parsing
- * @param attributes
+ * @param attributes
* The attributes of the element to create as a map of (names, values).<br />
* It includes the name spaces ("xmlns:<i>prefix</i>" or "xmlns").
* @return a bean containing the node and the index to use for the next call to this method
* @throws SAXException if a name space can not be resolved
*/
- private Element createElement( Node parentNode, String elementName, Map<String, String> attributes )
- throws SAXException {
-
+ private Element createElement( Node parentNode, String elementName, Map<String, String> attributes )
+ throws SAXException {
+
//
// Process name spaces first
Map<String, String> namespaces = new HashMap<String, String> ();
- for( String key : attributes.keySet()) {
- if( !key.startsWith( "xmlns" ) ) //$NON-NLS-1$
+ for( Map.Entry<String,String> entry : attributes.entrySet()) {
+ if( ! entry.getKey().startsWith( "xmlns" ) ) //$NON-NLS-1$
continue;
-
- String prefix = ( key.length() > 5 ) ? key.substring( 6 ) : key.substring( 5 );
- namespaces.put( prefix, attributes.get( key ));
- }
-
+
+ String prefix = ( entry.getKey().length() > 5 )
+ ? entry.getKey().substring( 6 ) : entry.getKey().substring( 5 );
+ namespaces.put( prefix, entry.getValue());
+ }
+
//
// Process attributes - keep name spaces
- List<Attr> attributeNodes = new ArrayList<Attr> ();
- for( Iterator<String> it = attributes.keySet().iterator(); it.hasNext(); ) {
- String key = it.next();
+ List<Attr> attributeNodes = new ArrayList<Attr> ();
+ int i=0;
+ for( Map.Entry<String,String> entry : attributes.entrySet()) {
+ boolean hasNext = (i < attributes.size());
+ i++;
+ String key = entry.getKey();
Attr attr = null;
-
+
if( key.startsWith( "xmlns" )) { //$NON-NLS-1$
- attr = doc.createAttributeNS( "http://www.w3.org/2000/xmlns/", key ); //$NON-NLS-1$
- if( !it.hasNext() && status == PositionStatus.ATTRIBUTE_NAME )
- status = PositionStatus.NS_DECLARATION;
- else if( !it.hasNext() && status == PositionStatus.ATTRIBUTE_VALUE )
- status = PositionStatus.NS_URI;
+ attr = this.doc.createAttributeNS( "http://www.w3.org/2000/xmlns/", key ); //$NON-NLS-1$
+ if( ! hasNext && this.status == PositionStatus.ATTRIBUTE_NAME )
+ this.status = PositionStatus.NS_DECLARATION;
+ else if( ! hasNext && this.status == PositionStatus.ATTRIBUTE_VALUE )
+ this.status = PositionStatus.NS_URI;
}
else if( key.length() > 0 ) {
String[] parts = key.split( ":" ); //$NON-NLS-1$
if( parts.length == 2 ) {
String uri = resolveNamespaceUri( parentNode, parts[ 0 ], namespaces );
- attr = doc.createAttributeNS( uri, key );
+ attr = this.doc.createAttributeNS( uri, key );
}
else
- attr = doc.createAttribute( key );
+ attr = this.doc.createAttribute( key );
}
-
- lastAttr = attr;
+
+ this.lastAttr = attr;
if( attr != null ) {
- attr.setNodeValue( attributes.get( key ));
+ attr.setNodeValue( entry.getValue());
attributeNodes.add( attr );
}
- }
-
+ }
+
//
// Process element
Element elt;
String[] parts = elementName.split( ":" ); //$NON-NLS-1$
if( parts.length == 2 ) {
String uri = resolveNamespaceUri( parentNode, parts[ 0 ], namespaces );
- elt = doc.createElementNS( uri, elementName );
+ elt = this.doc.createElementNS( uri, elementName );
}
else
- elt = doc.createElement( elementName );
-
+ elt = this.doc.createElement( elementName );
+
parentNode.appendChild( elt );
for( Attr attr : attributeNodes )
elt.setAttributeNode( attr );
-
+
return elt;
}
-
-
+
+
/**
* Resolve a name space prefix using the parent node and the ones found for the <i>current node</i>.
*
@@ -798,14 +803,14 @@
private String resolveNamespaceUri( Node parentNode, String nsPrefix, Map<String, String> namespaces )
throws SAXException {
String uri = namespaces != null ? namespaces.get( nsPrefix ) : null;
- if( uri == null
+ if( uri == null
&& parentNode != null
- && doc.getDocumentElement() != null ) // for root mark-up
+ && this.doc.getDocumentElement() != null ) // for root mark-up
uri = parentNode.lookupNamespaceURI( nsPrefix );
-
+
if( uri == null )
throw new SAXException( "Unresolved namespace prefix '" + nsPrefix + "' in " + parentNode.toString() + "." ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
+
return uri;
}
@@ -817,19 +822,19 @@
/** The node to use as the parent node for the next parsing step. */
private Node node;
/** The index to use as the start position for the next parsing step. */
- private int index;
-
+ private final int index;
+
public NodeAndOffset(int index, Node node) {
this.index = index;
this.node = node;
}
-
+
public NodeAndOffset(int index) {
this.index = index;
- }
+ }
}
-
-
+
+
/*
* (non-Javadoc)
* @see java.lang.Object#toString()
@@ -837,30 +842,30 @@
@Override
public String toString() {
String result = "\n"; //$NON-NLS-1$
-
+
// Display specific information
- result += "Status: " + status.toString() + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
- if( lastNode != null ) {
- result += "Last Node: " + lastNode.toString() + "\nAttrs"; //$NON-NLS-1$ //$NON-NLS-2$
- for( int i=0; i < lastNode.getAttributes().getLength(); i++ )
- result += "\n\t" + lastNode.getAttributes().item( i ).toString(); //$NON-NLS-1$
+ result += "Status: " + this.status.toString() + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
+ if( this.lastNode != null ) {
+ result += "Last Node: " + this.lastNode.toString() + "\nAttrs"; //$NON-NLS-1$ //$NON-NLS-2$
+ for( int i=0; i < this.lastNode.getAttributes().getLength(); i++ )
+ result += "\n\t" + this.lastNode.getAttributes().item( i ).toString(); //$NON-NLS-1$
}
else
result += "Last Node: null"; //$NON-NLS-1$
-
- if( status == PositionStatus.ATTRIBUTE_NAME
- || status == PositionStatus.ATTRIBUTE_VALUE
- || status == PositionStatus.NS_DECLARATION
- || status == PositionStatus.NS_URI )
- result += "\nLast Attribute: " + ((lastAttr == null) ? "null" : lastAttr.toString()); //$NON-NLS-1$ //$NON-NLS-2$
-
- if( status == PositionStatus.ATTRIBUTE_VALUE
- || status == PositionStatus.NS_URI )
- result += "\nAttribute Value after the offset: " + endOfAttributeValue; //$NON-NLS-1$
-
+
+ if( this.status == PositionStatus.ATTRIBUTE_NAME
+ || this.status == PositionStatus.ATTRIBUTE_VALUE
+ || this.status == PositionStatus.NS_DECLARATION
+ || this.status == PositionStatus.NS_URI )
+ result += "\nLast Attribute: " + ((this.lastAttr == null) ? "null" : this.lastAttr.toString()); //$NON-NLS-1$ //$NON-NLS-2$
+
+ if( this.status == PositionStatus.ATTRIBUTE_VALUE
+ || this.status == PositionStatus.NS_URI )
+ result += "\nAttribute Value after the offset: " + this.endOfAttributeValue; //$NON-NLS-1$
+
return result;
}
-
+
/**
* @return the built document, prettily formatted (as much as possible).
*/
@@ -868,23 +873,23 @@
// Write XML document
String result = "\nDOM:\n-----\n"; //$NON-NLS-1$
try {
- DOMSource domSource = new DOMSource( doc );
-
+ DOMSource domSource = new DOMSource( this.doc );
+
StringWriter writer = new StringWriter();
StreamResult sr = new StreamResult( writer );
TransformerFactory tf = TransformerFactory.newInstance();
-
+
Transformer transformer = tf.newTransformer();
transformer.setOutputProperty( OutputKeys.INDENT, "yes" ); //$NON-NLS-1$
transformer.setOutputProperty( "{http://xml.apache.org/xslt}indent-amount", "2" ); //$NON-NLS-1$ //$NON-NLS-2$
-
+
transformer.transform( domSource, sr );
result += writer.toString();
-
+
} catch( Exception e ) {
e.printStackTrace();
}
-
+
return result;
}
}
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/completion/attributes/AtttributeValueProposalMaker.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/completion/attributes/AtttributeValueProposalMaker.java 2009-08-27 10:38:15 UTC (rev 3303)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/completion/attributes/AtttributeValueProposalMaker.java 2009-08-27 15:13:13 UTC (rev 3304)
@@ -22,9 +22,9 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.text.contentassist.CompletionProposal;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.stp.sca.common.utils.ResourceUtils;
import org.eclipse.stp.sca.xmleditor.completion.XmlContextualDom;
import org.eclipse.stp.sca.xmleditor.utils.IncludesUtils;
-import org.eclipse.stp.sca.common.utils.ResourceUtils;
import org.eclipse.stp.sca.xmleditor.utils.ScaUtils;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
@@ -34,50 +34,51 @@
* @author Vincent Zurczak - EBM WebSourcing
*/
public class AtttributeValueProposalMaker {
-
+
/** The file being currently edited. */
private IFile editedFile;
/** Gets the required information to make proposals using <code>include</code> mark-ups. */
private IncludesUtils includesUtils;
/** Keep track of generated name space prefixes for includes. */
- private Map<String, String> generatedIncludeNs = new HashMap<String, String> ();
+ private final Map<String, String> generatedIncludeNs = new HashMap<String, String> ();
/** The contextual DOM document used to have precise information about the <i>cursor location</i>. */
private XmlContextualDom contextualDom;
-
-
+
+
/**
* The constructor that initializes the fields related to composite inclusions.
*/
public AtttributeValueProposalMaker() {
initializeInclusionElements();
}
-
-
+
+
/**
* Called each time the elements related to composite inclusion should be reset.
*/
private void initializeInclusionElements() {
- editedFile = ResourceUtils.getIFileFromEditor();
- IProject project = editedFile.getProject();
- includesUtils = IncludesUtils.createIncludesUtils( project );
+ this.editedFile = ResourceUtils.getIFileFromEditor();
+ IProject project = this.editedFile.getProject();
+ this.includesUtils = IncludesUtils.createIncludesUtils( project );
}
-
-
+
+
/**
* The public facade to get proposals.
*
* @param domDoc the IDocument managed by the editor.
+ * @param contextualDom
* @param markupName the first previous mark-up name near of the offset position in the document.
- * @param attributeName the attribute name
+ * @param attributeName the attribute name
* @param attributeValue the attribute value, i.e. what the user already typed in.
* @param offset the document offset.
*
* @return a list of proposals for auto-completion, adapted to the context.
*/
- public ICompletionProposal[] makeProposals(
- Document domDoc, XmlContextualDom contextualDom,
+ public ICompletionProposal[] makeProposals(
+ Document domDoc, XmlContextualDom contextualDom,
String markupName, String attributeName, String attributeValue, int offset ) {
-
+
this.contextualDom = contextualDom;
try {
if( markupName.equalsIgnoreCase( "service" )) { //$NON-NLS-1$
@@ -95,49 +96,49 @@
}
catch( Exception e ) {
e.printStackTrace();
- }
+ }
return null;
}
-
-
+
+
/**
* Provide auto-completion proposals for attributes of a wire element.
* <p>The proposals take into account included files.</p>
*
* @param domDoc the IDocument managed by the editor
* @param offset the document offset
- * @param attributeName the attribute name
+ * @param attributeName the attribute name
* @param attributeValue the attribute value, i.e. what the user already typed in
*
* @return proposals for <code>wire</code> mark-ups.
*/
- private ICompletionProposal[] provideWireMarkupProposals(
- Document domDoc, int offset, String attributeName, String attributeValue ) {
-
+ private ICompletionProposal[] provideWireMarkupProposals(
+ Document domDoc, int offset, String attributeName, String attributeValue ) {
+
// Source attribute
if( attributeName.equalsIgnoreCase( "source" )) { //$NON-NLS-1$
String[] referenceNames = ScaUtils.getPromotions( domDoc, false );
-
+
ArrayList<ICompletionProposal> result = new ArrayList<ICompletionProposal> ();
for( String referenceName : referenceNames ) {
if( referenceName.startsWith( attributeValue )) {
-
- String s = contextualDom.getEndOfAttributeValue();
+
+ String s = this.contextualDom.getEndOfAttributeValue();
int replacementLength = attributeValue.length() + (s == null ? 0 : s.length());
- result.add(
- new CompletionProposal(
- referenceName,
- offset - attributeValue.length(),
- replacementLength,
- referenceName.length())
+ result.add(
+ new CompletionProposal(
+ referenceName,
+ offset - attributeValue.length(),
+ replacementLength,
+ referenceName.length())
);
}
- }
-
+ }
+
ICompletionProposal[] proposals = new ICompletionProposal[ result.size() ];
return result.toArray( proposals );
}
-
+
// Target attribute
else if( attributeName.equalsIgnoreCase( "target" )) { //$NON-NLS-1$
String[] serviceNames = ScaUtils.getPromotions( domDoc, true );
@@ -145,82 +146,82 @@
ArrayList<ICompletionProposal> result = new ArrayList<ICompletionProposal> ();
for( String serviceName : serviceNames ) {
if( serviceName.startsWith( attributeValue )) {
-
- String s = contextualDom.getEndOfAttributeValue();
+
+ String s = this.contextualDom.getEndOfAttributeValue();
int replacementLength = attributeValue.length() + (s == null ? 0 : s.length());
- result.add(
- new CompletionProposal(
- serviceName,
- offset - attributeValue.length(),
- replacementLength,
- serviceName.length())
+ result.add(
+ new CompletionProposal(
+ serviceName,
+ offset - attributeValue.length(),
+ replacementLength,
+ serviceName.length())
);
}
- }
-
+ }
+
ICompletionProposal[] proposals = new ICompletionProposal[ result.size() ];
return result.toArray( proposals );
}
-
+
return new ICompletionProposal[ 0 ];
}
-
+
/**
* Provide auto-completion proposals for attributes of a reference element.
* <p>The proposals take into account included files.</p>
*
* @param domDoc the IDocument managed by the editor
* @param offset the document offset
- * @param attributeName the attribute name
+ * @param attributeName the attribute name
* @param attributeValue the attribute value, i.e. what the user already typed in
*
* @return proposals for <code>reference</code> mark-ups.
*/
- private ICompletionProposal[] provideReferenceMarkupProposals(
+ private ICompletionProposal[] provideReferenceMarkupProposals(
Document domDoc, int offset, String attributeName, String attributeValue ) {
-
- String[] referenceNames;
+
+ String[] referenceNames;
if( attributeName.equalsIgnoreCase( "promote" )) //$NON-NLS-1$
referenceNames = ScaUtils.getPromotions( domDoc, false );
else if( attributeName.equalsIgnoreCase( "target" )) //$NON-NLS-1$
- referenceNames = ScaUtils.getPromotions( domDoc, true );
+ referenceNames = ScaUtils.getPromotions( domDoc, true );
else
referenceNames = new String[ 0 ];
-
+
ArrayList<ICompletionProposal> result = new ArrayList<ICompletionProposal> ();
for( String referenceName : referenceNames ) {
if( referenceName.startsWith( attributeValue )) {
-
- String s = contextualDom.getEndOfAttributeValue();
+
+ String s = this.contextualDom.getEndOfAttributeValue();
int replacementLength = attributeValue.length() + (s == null ? 0 : s.length());
- result.add(
- new CompletionProposal(
- referenceName,
- offset - attributeValue.length(),
- replacementLength,
- referenceName.length())
+ result.add(
+ new CompletionProposal(
+ referenceName,
+ offset - attributeValue.length(),
+ replacementLength,
+ referenceName.length())
);
}
- }
-
+ }
+
ICompletionProposal[] proposals = new ICompletionProposal[ result.size() ];
return result.toArray( proposals );
}
-
+
/**
* Provide auto-completion proposals for attributes of a service element.
* <p>The proposals take into account included files.</p>
*
* @param domDoc the IDocument managed by the editor
* @param offset the document offset
- * @param attributeName the attribute name
+ * @param attributeName the attribute name
* @param attributeValue the attribute value, i.e. what the user already typed in
*
* @return proposals for <code>service</code> mark-ups.
*/
- private ICompletionProposal[] provideServiceMarkupProposals(
+ private ICompletionProposal[] provideServiceMarkupProposals(
Document domDoc, int offset, String attributeName, String attributeValue ) {
String[] serviceNames;
@@ -232,24 +233,24 @@
ArrayList<ICompletionProposal> result = new ArrayList<ICompletionProposal> ();
for( String serviceName : serviceNames ) {
if( serviceName.startsWith( attributeValue )) {
-
- String s = contextualDom.getEndOfAttributeValue();
+
+ String s = this.contextualDom.getEndOfAttributeValue();
int replacementLength = attributeValue.length() + (s == null ? 0 : s.length());
- result.add(
- new CompletionProposal(
- serviceName,
- offset - attributeValue.length(),
- replacementLength,
- serviceName.length())
+ result.add(
+ new CompletionProposal(
+ serviceName,
+ offset - attributeValue.length(),
+ replacementLength,
+ serviceName.length())
);
}
- }
-
+ }
+
ICompletionProposal[] proposals = new ICompletionProposal[ result.size() ];
return result.toArray( proposals );
}
-
-
+
+
/**
* Get the included files of the document.
* @param domDoc the IDocument managed by the editor
@@ -257,23 +258,23 @@
private List<QName> getIncludedFiles( Document domDoc ) {
List<QName> includeQNames = new ArrayList<QName> ();
NodeList includes = domDoc.getElementsByTagNameNS( "*", "include" ); //$NON-NLS-1$ //$NON-NLS-2$
-
- for( int i=0; i<includes.getLength(); i++ ) {
- QName includeQName = ScaUtils.getIncludeQName( includes.item( i ));
+
+ for( int i=0; i<includes.getLength(); i++ ) {
+ QName includeQName = ScaUtils.getIncludeQName( includes.item( i ));
if( includeQName != null )
- includeQNames.add( includeQName );
+ includeQNames.add( includeQName );
}
-
- return includeQNames;
+
+ return includeQNames;
}
-
-
+
+
/**
* Provide auto-completion proposals for <code>include</code> mark-ups.
*
* @param domDoc the IDocument managed by the editor
* @param offset the document offset
- * @param attributeName the attribute name
+ * @param attributeName the attribute name
* @param attributeValue the attribute value, i.e. what the user already typed in
*
* @return proposals for <code>include</code> mark-ups.
@@ -281,91 +282,91 @@
private ICompletionProposal[] provideIncludesMarkupProposals( Document domDoc, int offset, String attributeName, String attributeValue ) {
try {
initializeInclusionElements(); // Re-initialize the inclusion elements
- List<QName> qNames = includesUtils.getQNames();
+ List<QName> qNames = this.includesUtils.getQNames();
List<QName> alreadyIncluded = getIncludedFiles( domDoc );
-
- QName currentQName = includesUtils.getQName( editedFile );
+
+ QName currentQName = this.includesUtils.getQName( this.editedFile );
if( currentQName != null )
alreadyIncluded.add( currentQName );
-
+
// Build the list of possibles includes by removing current includes
List<QName> toPropose = new ArrayList<QName> ( qNames );
- toPropose.removeAll( alreadyIncluded );
+ toPropose.removeAll( alreadyIncluded );
List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal> ();
-
- for( QName qName : toPropose ) {
+
+ for( QName qName : toPropose ) {
// Create the proposals. Try to reuse defined name space prefixes.
String nsUri = qName.getNamespaceURI();
- String nsPrefix = contextualDom.getLastNode().lookupPrefix( nsUri );
-
+ String nsPrefix = this.contextualDom.getLastNode().lookupPrefix( nsUri );
+
if( nsPrefix == null ) {
- nsPrefix = generatedIncludeNs.get( nsUri );
+ nsPrefix = this.generatedIncludeNs.get( nsUri );
if( nsPrefix == null ) {
-
- int num = generatedIncludeNs.size();
+
+ int num = this.generatedIncludeNs.size();
nsPrefix = "include" + num; //$NON-NLS-1$
-
- String s = contextualDom.getEndOfAttributeValue();
+
+ String s = this.contextualDom.getEndOfAttributeValue();
String currentNs = attributeValue + (s != null ? s : ""); //$NON-NLS-1$
-
+
boolean nsAlreadyExisting = true;
while( nsAlreadyExisting ) {
// Existing prefix with different URI ?
- if( contextualDom.getLastNode().lookupNamespaceURI( nsPrefix ) != null ) {
- String associatedUri = contextualDom.getLastNode().lookupNamespaceURI( nsPrefix );
+ if( this.contextualDom.getLastNode().lookupNamespaceURI( nsPrefix ) != null ) {
+ String associatedUri = this.contextualDom.getLastNode().lookupNamespaceURI( nsPrefix );
if( !nsUri.equals( associatedUri ))
nsPrefix = "include" + (++ num); //$NON-NLS-1$
}
-
+
// Edited attribute is a name space declaration using this prefix ?
else if( currentNs.startsWith( nsPrefix ))
nsPrefix = "include" + (++ num); //$NON-NLS-1$
-
+
else
nsAlreadyExisting = false;
}
-
- generatedIncludeNs.put( nsUri, nsPrefix );
+
+ this.generatedIncludeNs.put( nsUri, nsPrefix );
}
}
-
+
String proposal;
if( nsPrefix.length() == 0 )
proposal = qName.getLocalPart();
- else if( generatedIncludeNs.containsKey( nsUri ))
- proposal =
- nsPrefix + ":" + qName.getLocalPart() //$NON-NLS-1$
- + "\" xmlns:" + nsPrefix //$NON-NLS-1$
+ else if( this.generatedIncludeNs.containsKey( nsUri ))
+ proposal =
+ nsPrefix + ":" + qName.getLocalPart() //$NON-NLS-1$
+ + "\" xmlns:" + nsPrefix //$NON-NLS-1$
+ "=\"" + qName.getNamespaceURI(); //$NON-NLS-1$
else
proposal = nsPrefix + ":" + qName.getLocalPart(); //$NON-NLS-1$
-
+
// Check that the proposal fits the given attribute value
if( qName.getLocalPart().startsWith( attributeValue )
|| nsPrefix.startsWith( attributeValue )) {
-
- String s = contextualDom.getEndOfAttributeValue();
+
+ String s = this.contextualDom.getEndOfAttributeValue();
int replacementLength = attributeValue.length() + (s == null ? 0 : s.length());
proposals.add(
- new CompletionProposal(
- proposal,
- offset - attributeValue.length(),
- replacementLength,
- proposal.length(),
- null,
- qName.getLocalPart(),
- null,
- "<b>{" + qName.getNamespaceURI() + "}</b> " + qName.getLocalPart() //$NON-NLS-1$ //$NON-NLS-2$
- ));
+ new CompletionProposal(
+ proposal,
+ offset - attributeValue.length(),
+ replacementLength,
+ proposal.length(),
+ null,
+ qName.getLocalPart(),
+ null,
+ "<b>{" + qName.getNamespaceURI() + "}</b> " + qName.getLocalPart() //$NON-NLS-1$ //$NON-NLS-2$
+ ));
}
} // End of loop.
-
+
ICompletionProposal[] result = new ICompletionProposal[ proposals.size() ];
- return proposals.toArray( result ) ;
+ return proposals.toArray( result ) ;
} catch( Exception e ) {
e.printStackTrace();
}
-
+
return new ICompletionProposal[ 0 ];
}
}
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/completion/preferences/ScaPreferenceProcessor.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/completion/preferences/ScaPreferenceProcessor.java 2009-08-27 10:38:15 UTC (rev 3303)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/completion/preferences/ScaPreferenceProcessor.java 2009-08-27 15:13:13 UTC (rev 3304)
@@ -46,7 +46,7 @@
*/
public class ScaPreferenceProcessor extends AbstractProcessor {
-
+
/*
* @see org.eclipse.jface.text.contentassist.IContentAssistProcessor
* #computeContextInformation(org.eclipse.jface.text.ITextViewer, int)
@@ -55,7 +55,7 @@
return null;
}
-
+
/*
* @see org.eclipse.jface.text.contentassist.IContentAssistProcessor
* #getCompletionProposalAutoActivationCharacters()
@@ -63,8 +63,8 @@
public char[] getCompletionProposalAutoActivationCharacters() {
return new char[] { '.' }; // '.' for bindings, implementations and interfaces
}
-
+
/*
* @see org.eclipse.jface.text.contentassist.IContentAssistProcessor
* #getContextInformationAutoActivationCharacters()
@@ -72,8 +72,8 @@
public char[] getContextInformationAutoActivationCharacters() {
return null;
}
-
+
/*
* @see org.eclipse.jface.text.contentassist.IContentAssistProcessor
* #getContextInformationValidator()
@@ -81,155 +81,155 @@
public IContextInformationValidator getContextInformationValidator() {
return null;
}
-
+
/*
* @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage()
*/
public String getErrorMessage() {
return null;
}
-
-
+
+
/**
* Make proposals based on the context detailed in a {@link XmlContextualDom} instance.
* @see org.eclipse.stp.sca.xmleditor.completion.AbstractProcessor#computeCompletionProposals()
*/
@Override
protected ICompletionProposal[] computeCompletionProposals() {
- List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal> ();
- switch( xmlContextualDom.getStatus()) {
-
- // Element name
- case ELEMENT_NAME:
- boolean rightAfterOpeningMarkup = xmlContextualDom.isRightAfterOpeningMarkUp(); // offset right after '<'
- Map<ScaXmlElement, String> elementProposals = getElementProposals( rightAfterOpeningMarkup );
- String nodeName = xmlContextualDom.getLastNode().getNodeName();
- int replacedLength = xmlContextualDom.isRightAfterOpeningMarkUp() ? 0 : nodeName.length();
- Image image = ImageRegistry.getInstance().markupProposalImg;
-
- for( Map.Entry<ScaXmlElement, String> entry : elementProposals.entrySet()) {
- String prefix = entry.getValue();
- if( prefix.length() > 0 )
- prefix += ":"; //$NON-NLS-1$
-
- String proposalText;
- if( rightAfterOpeningMarkup || xmlContextualDom.getLastNode().getAttributes().getLength() == 0 ) {
- proposalText = createElementProposalText( entry.getKey(), prefix );
- proposalText = proposalText.substring( 1 ); // remove '<'
+ List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal> ();
+ switch( this.xmlContextualDom.getStatus()) {
+
+ // Element name
+ case ELEMENT_NAME:
+ boolean rightAfterOpeningMarkup = this.xmlContextualDom.isRightAfterOpeningMarkUp(); // offset right after '<'
+ Map<ScaXmlElement, String> elementProposals = getElementProposals( rightAfterOpeningMarkup );
+ String nodeName = this.xmlContextualDom.getLastNode().getNodeName();
+ int replacedLength = this.xmlContextualDom.isRightAfterOpeningMarkUp() ? 0 : nodeName.length();
+ Image image = ImageRegistry.getInstance().markupProposalImg;
+
+ for( Map.Entry<ScaXmlElement, String> entry : elementProposals.entrySet()) {
+ String prefix = entry.getValue();
+ if( prefix.length() > 0 )
+ prefix += ":"; //$NON-NLS-1$
+
+ String proposalText;
+ if( rightAfterOpeningMarkup || this.xmlContextualDom.getLastNode().getAttributes().getLength() == 0 ) {
+ proposalText = createElementProposalText( entry.getKey(), prefix );
+ proposalText = proposalText.substring( 1 ); // remove '<'
+ }
+ else
+ proposalText = prefix + entry.getKey().getName();
+
+ String explaination = "<b>" + Messages.ScaPreferenceProcessor_1 + "</b>" //$NON-NLS-1$ //$NON-NLS-2$
+ + entry.getKey().getName() + "<br><b>" //$NON-NLS-1$
+ + Messages.ScaPreferenceProcessor_2 + "</b>" //$NON-NLS-1$
+ + entry.getKey().getParentPlatform().getName();
+ proposals.add(
+ new CompletionProposal(
+ proposalText,
+ this.offset - replacedLength,
+ replacedLength,
+ proposalText.length(),
+ image,
+ prefix + entry.getKey().getName(),
+ null,
+ explaination ));
}
+ break;
+
+ // Element value
+ case ELEMENT_VALUE:
+ Map<ScaXmlElement, String> elementProposals2 = getElementProposals( true );
+ Image image2 = ImageRegistry.getInstance().activeMarkupProposalImg;
+
+ for( Map.Entry<ScaXmlElement, String> entry : elementProposals2.entrySet()) {
+ String prefix = entry.getValue();
+ if( prefix.length() > 0 )
+ prefix += ":"; //$NON-NLS-1$
+
+ String proposalText = createElementProposalText( entry.getKey(), prefix );
+ String explaination = "<b>" + Messages.ScaPreferenceProcessor_1 + "</b>" //$NON-NLS-1$ //$NON-NLS-2$
+ + entry.getKey().getName()
+ + "<br><b>" + Messages.ScaPreferenceProcessor_2 //$NON-NLS-1$
+ + "</b>" + entry.getKey().getParentPlatform().getName(); //$NON-NLS-1$
+ proposals.add(
+ new CompletionProposal(
+ proposalText,
+ this.offset,
+ 0,
+ proposalText.length(),
+ image2,
+ prefix + entry.getKey().getName(),
+ null,
+ explaination ));
+ }
+
+ break;
+
+ // Attribute name
+ case ATTRIBUTE_NAME:
+ Attr currentAttribute = this.xmlContextualDom.getLastAttr();
+ String attrName;
+ if( currentAttribute == null )
+ attrName = ""; //$NON-NLS-1$
else
- proposalText = prefix + entry.getKey().getName();
-
- String explaination = "<b>" + Messages.ScaPreferenceProcessor_1 + "</b>" //$NON-NLS-1$ //$NON-NLS-2$
- + entry.getKey().getName() + "<br><b>" //$NON-NLS-1$
- + Messages.ScaPreferenceProcessor_2 + "</b>" //$NON-NLS-1$
- + entry.getKey().getParentPlatform().getName();
- proposals.add(
- new CompletionProposal(
- proposalText,
- offset - replacedLength,
- replacedLength,
- proposalText.length(),
- image,
- prefix + entry.getKey().getName(),
- null,
- explaination ));
- }
- break;
-
- // Element value
- case ELEMENT_VALUE:
- Map<ScaXmlElement, String> elementProposals2 = getElementProposals( true );
- Image image2 = ImageRegistry.getInstance().activeMarkupProposalImg;
-
- for( Map.Entry<ScaXmlElement, String> entry : elementProposals2.entrySet()) {
- String prefix = entry.getValue();
- if( prefix.length() > 0 )
- prefix += ":"; //$NON-NLS-1$
-
- String proposalText = createElementProposalText( entry.getKey(), prefix );
- String explaination = "<b>" + Messages.ScaPreferenceProcessor_1 + "</b>" //$NON-NLS-1$ //$NON-NLS-2$
- + entry.getKey().getName()
- + "<br><b>" + Messages.ScaPreferenceProcessor_2 //$NON-NLS-1$
- + "</b>" + entry.getKey().getParentPlatform().getName(); //$NON-NLS-1$
- proposals.add(
- new CompletionProposal(
- proposalText,
- offset,
- 0,
- proposalText.length(),
- image2,
- prefix + entry.getKey().getName(),
- null,
- explaination ));
- }
-
- break;
-
- // Attribute name
- case ATTRIBUTE_NAME:
- Attr currentAttribute = xmlContextualDom.getLastAttr();
- String attrName;
- if( currentAttribute == null )
- attrName = ""; //$NON-NLS-1$
- else
- attrName = currentAttribute.getLocalName() == null
- ? currentAttribute.getNodeName() : currentAttribute.getLocalName();
-
- Map<ScaXmlElement, String> elementProposals3 = getElementProposals( false );
- Map<ScaXmlAttribute, String> attributeProposals = getAttributeProposals( elementProposals3, attrName );
- Image image3 = ImageRegistry.getInstance().attributeImg;
-
- for( Map.Entry<ScaXmlAttribute, String> entry : attributeProposals.entrySet()) {
- String explaination = "<b>" + Messages.ScaPreferenceProcessor_1 + "</b>" //$NON-NLS-1$ //$NON-NLS-2$
- + entry.getKey().getElement().getName()
- + "<br><b>" + Messages.ScaPreferenceProcessor_2 + "</b>" //$NON-NLS-1$ //$NON-NLS-2$
- + entry.getKey().getElement().getParentPlatform().getName();
- proposals.add(
- new CompletionProposal(
- entry.getValue(),
- offset - attrName.length(),
- attrName.length(),
- entry.getValue().length(),
- image3,
- entry.getKey().getName(),
- null,
- explaination ));
- }
- break;
-
- // Name space URI
- case NS_URI:
- String nsValue = xmlContextualDom.getLastAttr().getNodeValue();
- String s = xmlContextualDom.getEndOfAttributeValue();
- int replacementLength = nsValue.length() + (s == null ? 0 : s.length());
-
- for( ScaXmlNamespace namespace : ScaXmlPreferenceUtils.getAllNamespaces()) {
- String explaination = "<b>" + Messages.ScaPreferenceProcessor_3 + "</b>" //$NON-NLS-1$ //$NON-NLS-2$
- + namespace.getName() + "<br><b>" //$NON-NLS-1$
- + Messages.ScaPreferenceProcessor_2 + "</b>" //$NON-NLS-1$
- + namespace.getPlatform().getName();
- proposals.add(
- new CompletionProposal(
- namespace.getName(),
- offset - nsValue.length(),
- replacementLength,
- namespace.getName().length(),
- null,
- namespace.getName(),
- null,
- explaination ));
- }
- break;
- default: break;
- }
-
+ attrName = currentAttribute.getLocalName() == null
+ ? currentAttribute.getNodeName() : currentAttribute.getLocalName();
+
+ Map<ScaXmlElement, String> elementProposals3 = getElementProposals( false );
+ Map<ScaXmlAttribute, String> attributeProposals = getAttributeProposals( elementProposals3, attrName );
+ Image image3 = ImageRegistry.getInstance().attributeImg;
+
+ for( Map.Entry<ScaXmlAttribute, String> entry : attributeProposals.entrySet()) {
+ String explaination = "<b>" + Messages.ScaPreferenceProcessor_1 + "</b>" //$NON-NLS-1$ //$NON-NLS-2$
+ + entry.getKey().getElement().getName()
+ + "<br><b>" + Messages.ScaPreferenceProcessor_2 + "</b>" //$NON-NLS-1$ //$NON-NLS-2$
+ + entry.getKey().getElement().getParentPlatform().getName();
+ proposals.add(
+ new CompletionProposal(
+ entry.getValue(),
+ this.offset - attrName.length(),
+ attrName.length(),
+ entry.getValue().length(),
+ image3,
+ entry.getKey().getName(),
+ null,
+ explaination ));
+ }
+ break;
+
+ // Name space URI
+ case NS_URI:
+ String nsValue = this.xmlContextualDom.getLastAttr().getNodeValue();
+ String s = this.xmlContextualDom.getEndOfAttributeValue();
+ int replacementLength = nsValue.length() + (s == null ? 0 : s.length());
+
+ for( ScaXmlNamespace namespace : ScaXmlPreferenceUtils.getAllNamespaces()) {
+ String explaination = "<b>" + Messages.ScaPreferenceProcessor_3 + "</b>" //$NON-NLS-1$ //$NON-NLS-2$
+ + namespace.getName() + "<br><b>" //$NON-NLS-1$
+ + Messages.ScaPreferenceProcessor_2 + "</b>" //$NON-NLS-1$
+ + namespace.getPlatform().getName();
+ proposals.add(
+ new CompletionProposal(
+ namespace.getName(),
+ this.offset - nsValue.length(),
+ replacementLength,
+ namespace.getName().length(),
+ null,
+ namespace.getName(),
+ null,
+ explaination ));
+ }
+ break;
+ default: break;
+ }
+
ICompletionProposal[] result = new ICompletionProposal[ proposals.size() ];
return proposals.toArray( result );
}
-
+
/**
* Get element proposals using the last retrieved node.
* It is assumed the last node is not null.
@@ -237,31 +237,31 @@
* @param addNull true if the hierarchy of elements should be appended a null value
* @return a map of proposals, where the key is the Element and the value the name space prefix
*/
- private Map<ScaXmlElement, String> getElementProposals( boolean addNull ) {
- List<Node> hierarchy = getReversedNodeHierarchyForPreferences( xmlContextualDom.getLastNode());
+ private Map<ScaXmlElement, String> getElementProposals( boolean addNull ) {
+ List<Node> hierarchy = getReversedNodeHierarchyForPreferences( this.xmlContextualDom.getLastNode());
if( hierarchy.size() == 0 )
return Collections.emptyMap();
if( addNull && hierarchy.size() > 1 )
hierarchy.add( null );
-
+
// The first call is special
Map<ScaXmlElement, String> result = findMatchingElements( hierarchy.get( 0 ), null );
Collection<ScaXmlElement> possibleElements = result.keySet();
-
+
// Other calls are different
for( int i=1; i<hierarchy.size(); i++ ) {
Node node = hierarchy.get( i );
result = findMatchingElements( node, possibleElements );
-
+
possibleElements = new ArrayList<ScaXmlElement> ();
for( ScaXmlElement elt : result.keySet())
possibleElements.addAll( elt.children );
}
-
+
return result;
}
-
-
+
+
/**
* Get attribute proposals from a list of ScaXmlElements and filtering with the current attribute name.
* @param elementProposals the elements to use to retrieve attributes to propose
@@ -270,25 +270,25 @@
*/
private Map<ScaXmlAttribute, String> getAttributeProposals( Map<ScaXmlElement, String> elementProposals, String attributeName ) {
List<String> attrNames = new ArrayList<String> ();
- for( int i=0; i < xmlContextualDom.getLastNode().getAttributes().getLength(); i++ ) {
- Node attrNode = xmlContextualDom.getLastNode().getAttributes().item( i );
+ for( int i=0; i < this.xmlContextualDom.getLastNode().getAttributes().getLength(); i++ ) {
+ Node attrNode = this.xmlContextualDom.getLastNode().getAttributes().item( i );
String name = attrNode.getLocalName() == null ? attrNode.getNodeName() : attrNode.getLocalName();
attrNames.add( name );
- }
-
+ }
+
Map<ScaXmlAttribute, String> result = new HashMap<ScaXmlAttribute, String> ();
for( ScaXmlElement elt : elementProposals.keySet()) {
for( ScaXmlAttribute attribute : elt.attributes ) {
- if( attribute.getName().startsWith( attributeName )
- && !attrNames.contains( attribute.getName()))
+ if( attribute.getName().startsWith( attributeName )
+ && !attrNames.contains( attribute.getName()))
result.put( attribute, createAttributeProposalText( attribute ));
}
}
-
+
return result;
}
-
+
/**
* @param attribute the attribute to use to create the proposal text
* @return the proposal text, including the default value or the fixed value
@@ -297,13 +297,13 @@
String result = attribute.getName() + "=\""; //$NON-NLS-1$
if( attribute.getUse() == ScaXmlAttributeProperty.fixed )
result += attribute.getFixedValue();
- else
+ else
result += attribute.getDefaultValue();
result += "\""; //$NON-NLS-1$
return result;
}
-
-
+
+
/**
* @param element the element to use to create the proposal text
* @param prefix the name space prefix for this element
@@ -317,24 +317,24 @@
else if( attr.getUse() == ScaXmlAttributeProperty.fixed )
proposalText += " " + attr.getName() + "=\"" + attr.getFixedValue() + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
-
+
if( element.children.size() > 0 )
proposalText += "></" + prefix + element.getName() + ">"; //$NON-NLS-1$ //$NON-NLS-2$
else
proposalText += " />"; //$NON-NLS-1$
-
+
return proposalText;
}
-
-
+
+
/**
* @param currentNode the node used as the basis to retrieve the node hierarchy
- * @return the node hierarchy, starting from a component node, a service node or a reference node
+ * @return the node hierarchy, starting from a component node, a service node or a reference node
* and going to currentNode
*/
private List<Node> getReversedNodeHierarchyForPreferences( Node currentNode ) {
List<Node> hierarchy = new ArrayList<Node> ();
-
+
boolean removeComponent = false;
Node node = currentNode;
while( node != null ) {
@@ -344,31 +344,31 @@
|| node.getNodeName().endsWith( ":reference" ) //$NON-NLS-1$
|| node.getNodeName().equals( "reference" )) //$NON-NLS-1$
removeComponent = true;
-
+
if( "component".equalsIgnoreCase( node.getLocalName()) //$NON-NLS-1$
|| node.getNodeName().endsWith( ":component" )) //$NON-NLS-1$
node = null;
else
node = node.getParentNode();
}
-
+
// Reverse the order
Collections.reverse( hierarchy );
-
+
// The first element in the hierarchy should be a component
node = hierarchy.get( 0 );
if( ! "component".equalsIgnoreCase( node.getLocalName()) //$NON-NLS-1$
&& ! node.getNodeName().endsWith( ":component" )) //$NON-NLS-1$
return Collections.emptyList();
-
+
// Remove the component if the parent is supposed to be a service or a reference
if( removeComponent == true )
hierarchy.remove( 0 );
-
+
return hierarchy;
}
-
-
+
+
/**
* Search <b>possibleElements</b> the elements which match <b>currentNode</b>.
* <p>
@@ -381,9 +381,9 @@
* </p>
*
* <p>
- * Precondition: get the partial node hierarchy,
+ * Precondition: get the partial node hierarchy,
* <br />e.g. "component, implementation.osgi, prop"
- * <br />or "service, bind".
+ * <br />or "service, bind".
* </p>
* @see #getReversedNodeHierarchyForPreferences(Node)
*
@@ -392,11 +392,11 @@
* <br />
* First call: (Component node, null) :: associated implementations.
* <br /><br />
- * Following calls: (node, collections of possibly matching {@link ScaXmlElement}) :: the matching {@link ScaXmlElement}s
+ * Following calls: (node, collections of possibly matching {@link ScaXmlElement}) :: the matching {@link ScaXmlElement}s
* </p>
*
* <p>
- * It implies to make the calls in a distinct manner, depending on whether this the first call or not.
+ * It implies to make the calls in a distinct manner, depending on whether this the first call or not.
* </p>
*
* <p>Algorithm used for "root nodes" (component, service, reference).</p>
@@ -424,18 +424,18 @@
*/
private Map<ScaXmlElement, String> findMatchingElements( Node currentNode, Collection<ScaXmlElement> possibleMatchingElements ) {
Map<ScaXmlElement, String> result = new HashMap<ScaXmlElement, String>();
-
+
//
// Get all the name space(s) (and thus the platform(s)) from the current node.
Map<String, String> nsAndPrefix = new HashMap<String, String> ();
- Node node = currentNode == null ? xmlContextualDom.getLastNode() : currentNode;
-
- for( String nsUri : DomUtils.getNamespaceMappings( node ).values()) {
+ Node node = currentNode == null ? this.xmlContextualDom.getLastNode() : currentNode;
+
+ for( String nsUri : DomUtils.getNamespaceMappings( node ).values()) {
String prefix = node.lookupPrefix( nsUri );
if( prefix != null )
nsAndPrefix.put( prefix, nsUri );
}
-
+
//
// Case "service", "reference" or "component "mark-up: return the children
if( possibleMatchingElements == null ) {
@@ -448,26 +448,26 @@
}
}
}
-
+
List<ScaXmlElement> matchingElements = new ArrayList<ScaXmlElement>();
- if( currentNode.getNodeName().endsWith( ":service" ) //$NON-NLS-1$
- || currentNode.getNodeName().equals( "service" ) //$NON-NLS-1$
- || currentNode.getNodeName().endsWith( ":reference" ) //$NON-NLS-1$
- || currentNode.getNodeName().equals( "reference" )) { //$NON-NLS-1$
-
+ if( node.getNodeName().endsWith( ":service" ) //$NON-NLS-1$
+ || node.getNodeName().equals( "service" ) //$NON-NLS-1$
+ || node.getNodeName().endsWith( ":reference" ) //$NON-NLS-1$
+ || node.getNodeName().equals( "reference" )) { //$NON-NLS-1$
+
for( ScaXmlPlatform platform : matchingPlatforms ) {
matchingElements.addAll( platform.bindings );
matchingElements.addAll( platform.interfaces );
- }
+ }
}
-
- else if( currentNode.getNodeName().endsWith( ":component" ) //$NON-NLS-1$
- || currentNode.getNodeName().equals( "component" )) { //$NON-NLS-1$
+ else if( node.getNodeName().endsWith( ":component" ) //$NON-NLS-1$
+ || node.getNodeName().equals( "component" )) { //$NON-NLS-1$
+
for( ScaXmlPlatform platform : matchingPlatforms )
matchingElements.addAll( platform.implementations );
}
-
+
for( ScaXmlElement elt : matchingElements ) {
for( Map.Entry<String, String> entry : nsAndPrefix.entrySet()) {
if( elt.hasNamespace( entry.getValue()))
@@ -475,7 +475,7 @@
}
}
}
-
+
//
// Case where the node is null, no element name was typed in yet
else if( currentNode == null ) {
@@ -486,7 +486,7 @@
}
}
}
-
+
//
// Case sub-elements listed in the preference page
else {
@@ -495,7 +495,7 @@
for( Map.Entry<String, String> entry : nsAndPrefix.entrySet()) {
if( !elt.hasNamespace( entry.getValue()))
continue;
-
+
String filter = entry.getKey().length() == 0 ? "" : ( entry.getKey() + ":" ); //$NON-NLS-1$ //$NON-NLS-2$
filter += elt.getName();
if( filter.startsWith( currentNode.getNodeName())) // FIXME: startsWith or equals ? Depends on the node (the last one or not ?)
@@ -503,7 +503,7 @@
}
}
}
-
+
/*
* Filter by cardinality using minOccurs and maxOccurs is useless here.
* The default content assistant will propose already typed-in elements.
@@ -511,7 +511,7 @@
* So if we prevent this processor from displaying additional elements,
* the default one will do it anyway.
*/
-
+
return result;
}
}
\ No newline at end of file
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/outline/ScaXmlContentProvider.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/outline/ScaXmlContentProvider.java 2009-08-27 10:38:15 UTC (rev 3303)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/outline/ScaXmlContentProvider.java 2009-08-27 15:13:13 UTC (rev 3304)
@@ -41,31 +41,31 @@
*
* @author Vincent Zurczak - EBM WebSourcing
*/
-public class ScaXmlContentProvider implements ITreeContentProvider {
-
+public class ScaXmlContentProvider implements ITreeContentProvider {
+
// Basis.
/** The edited file. */
private IFile editedFile;
/** The tree viewer. */
private Viewer viewer;
-
+
// Includes.
/** The utils for <code>include</code> mark-ups. */
- private IncludesUtils includesUtils;
- /**
- * Key = child node, value = parent node
- * (used for includes only, since we break the XML tree when using several DOMs).
+ private IncludesUtils includesUtils;
+ /**
+ * Key = child node, value = parent node
+ * (used for includes only, since we break the XML tree when using several DOMs).
*
* If this map contains an element with key "k", this means the parent of "k" in the
* outline view is its value "v". "v" must to be an "include" node.
*/
- private Map<Node, Node> includeNodes = new HashMap<Node, Node> ();
-
+ private final Map<Node, Node> includeNodes = new HashMap<Node, Node> ();
+
// Listeners.
/** The listener waits model changes and updates the outline view. */
@SuppressWarnings("restriction")
- private IModelStateListener modelListener = new IModelStateListener() {
-
+ private final IModelStateListener modelListener = new IModelStateListener() {
+
public void modelChanged(IStructuredModel model) {
refreshViewer();
}
@@ -82,118 +82,118 @@
public void modelAboutToBeChanged(IStructuredModel model) {}
public void modelAboutToBeReinitialized(IStructuredModel structuredModel) {}
public void modelResourceDeleted(IStructuredModel model) {}
- public void modelResourceMoved(IStructuredModel oldModel, IStructuredModel newModel) {}
+ public void modelResourceMoved(IStructuredModel oldModel, IStructuredModel newModel) {}
};
-
-
-
-
+
+
+
+
/**
* The empty constructor has to be used when the input is an {@link IDOMModel} instance.
*/
public ScaXmlContentProvider() {
// nothing
}
-
-
+
+
/**
* The 1-argument constructor has to be used when the input is <b>just</b> an {@link Document} instance.
+ * @param editedFile
*/
public ScaXmlContentProvider( IFile editedFile ) {
this.editedFile = editedFile;
}
-
-
+
+
/*
* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreeContentProvider
* #getChildren(java.lang.Object)
*/
- public Object[] getChildren( Object parentElement ) {
- //
+ public Object[] getChildren( Object parentElement ) {
+ //
// Children for a Node element
- if( parentElement instanceof Node ) {
+ if( parentElement instanceof Node ) {
Node node = (Node) parentElement;
- if( node.getNodeType() == Node.ELEMENT_NODE
+ if( node.getNodeType() == Node.ELEMENT_NODE
&& node.getNodeName() != null ) {
-
+
NodeList children = node.getChildNodes();
if( children == null )
return new Object[ 0 ];
-
+
ArrayList<Node> result = new ArrayList<Node> ();
for( int i=0; i<children.getLength(); i++ ) {
Node child = children.item( i );
- if( child.getNodeType() == Node.ELEMENT_NODE
+ if( child.getNodeType() == Node.ELEMENT_NODE
&& node.getNodeName() != null )
result.add( child );
}
-
+
// Differentiate the processing of "includes".
if( !node.getNodeName().toLowerCase().equals( "include" ) //$NON-NLS-1$
&& !node.getNodeName().toLowerCase().endsWith( ":include" )) //$NON-NLS-1$
return result.toArray();
-
+
// Now, process includes.
- if( includesUtils == null )
+ if( this.includesUtils == null )
return result.toArray();
-
+
QName includeQName = ScaUtils.getIncludeQName( node );
if( includeQName == null )
return result.toArray();
-
- IFile includedFile = includesUtils.getIFile( includeQName );
+
+ IFile includedFile = this.includesUtils.getIFile( includeQName );
if( includedFile == null )
return result.toArray();
-
+
// At this stage, we have the name, the namespace URI and the namespace prefix.
- Document includedDocument = includesUtils.getDOM( includedFile );
+ Document includedDocument = this.includesUtils.getDOM( includedFile );
if( includedDocument == null )
return result.toArray();
-
- Node compositeNode = ScaUtils.getScaTopNode( includedDocument );
+
+ Node compositeNode = ScaUtils.getScaTopNode( includedDocument );
children = compositeNode.getChildNodes();
if( children == null )
return result.toArray();
-
+
for( int i=0; i<children.getLength(); i++ ) {
Node child = children.item( i );
- if( child.getNodeType() == Node.ELEMENT_NODE
+ if( child.getNodeType() == Node.ELEMENT_NODE
&& node.getNodeName() != null ) {
result.add( child );
-
- includeNodes.put( child, node );
+
+ this.includeNodes.put( child, node );
}
}
-
+
return result.toArray();
}
- }
+ }
return new Object[0];
- }
+ }
-
+
/*
* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreeContentProvider
* #getParent(java.lang.Object)
*/
public Object getParent( Object element ) {
- if( element instanceof Node ) {
+ if( element instanceof Node ) {
Node node = (Node) element;
- if( node.getNodeType() == Node.ELEMENT_NODE
+ if( node.getNodeType() == Node.ELEMENT_NODE
&& node.getNodeName() != null ) {
-
- if( !includeNodes.containsKey( node ))
+
+ if( ! this.includeNodes.containsKey( node ))
return node.getParentNode();
- else
- return includeNodes.get( node );
+ return this.includeNodes.get( node );
}
- }
+ }
return null;
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreeContentProvider
@@ -203,7 +203,7 @@
return getChildren( element ).length > 0;
}
-
+
/**
* The input should be a {@link Document} instance or an {@link IDOMModel} instance.
* <p>
@@ -215,49 +215,49 @@
*/
@SuppressWarnings("restriction")
public Object[] getElements( Object inputElement ) {
-
- Document rootDocument = null;
+
+ Document rootDocument = null;
if( inputElement instanceof IDOMModel ) {
IDOMDocument topNode = ((IDOMModel) inputElement).getDocument();
rootDocument = topNode;
-
+
String workspaceRelativePath = topNode.getModel().getBaseLocation();
IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember( workspaceRelativePath );
- if( resource == null ||
+ if( resource == null ||
! IFile.class.isAssignableFrom( resource.getClass()))
return new Object[ 0 ];
-
- editedFile = (IFile) resource;
- defineWorkspaceResources ();
+
+ this.editedFile = (IFile) resource;
+ defineWorkspaceResources ();
}
-
- if( inputElement instanceof Document )
+
+ if( inputElement instanceof Document )
rootDocument = (Document) inputElement;
-
+
if( rootDocument != null ) {
Node root = rootDocument.getFirstChild();
- while( root != null
+ while( root != null
&& root.getNodeType() != Node.ELEMENT_NODE )
- root = root.getNextSibling();
-
- if( root != null
+ root = root.getNextSibling();
+
+ if( root != null
&& root.getNodeName() != null
&& ScaUtils.removeNamespacePrefix( root.getNodeName())
- .toLowerCase().equals( "composite" )) //$NON-NLS-1$
+ .toLowerCase().equals( "composite" )) //$NON-NLS-1$
return new Object[] { root };
-
+
// No composite ? Maybe it's a componentType file...
- if( root != null
+ if( root != null
&& root.getNodeName() != null
&& ScaUtils.removeNamespacePrefix( root.getNodeName())
- .toLowerCase().equals( "componenttype" )) //$NON-NLS-1$
- return new Object[] { root };
+ .toLowerCase().equals( "componenttype" )) //$NON-NLS-1$
+ return new Object[] { root };
}
-
+
return new Object[0];
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
@@ -266,7 +266,7 @@
// The model listener should be removed in "inputChanged"
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider
@@ -275,52 +275,52 @@
@SuppressWarnings("restriction")
public void inputChanged( final Viewer viewer, Object oldInput, Object newInput ) {
this.viewer = viewer;
-
+
// Remove the model modelListener from the old input.
if( oldInput != null && oldInput instanceof IDOMModel ) {
- ((IDOMModel) oldInput).removeModelStateListener( modelListener );
+ ((IDOMModel) oldInput).removeModelStateListener( this.modelListener );
}
-
+
// Clear includes.
- includeNodes.clear();
-
+ this.includeNodes.clear();
+
// Add the model modelListener on the new input.
if( newInput != null && newInput instanceof IDOMModel ) {
- ((IDOMModel) newInput).addModelStateListener( modelListener );
+ ((IDOMModel) newInput).addModelStateListener( this.modelListener );
}
-
+
// Expand the outline view
Display.getDefault().asyncExec( new Runnable () {
public void run() {
if( viewer != null
&& viewer instanceof TreeViewer ) {
-
+
TreeViewer tv = (TreeViewer) viewer;
- if( tv.getTree() != null
+ if( tv.getTree() != null
&& !tv.getTree().isDisposed())
tv.expandAll();
}
}
});
}
-
-
+
+
/**
* Refreshes the tree viewer.
*/
private void refreshViewer() {
- if( viewer != null )
- viewer.refresh();
+ if( this.viewer != null )
+ this.viewer.refresh();
}
-
-
+
+
/**
* Define workspace resources.
* Gets the edited file and gets prepared for includes management.
* @param file not null.
*/
public void defineWorkspaceResources () {
- IProject project = editedFile.getProject();
- includesUtils = IncludesUtils.createIncludesUtils( project );
+ IProject project = this.editedFile.getProject();
+ this.includesUtils = IncludesUtils.createIncludesUtils( project );
}
}
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/DefaultPreferences.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/DefaultPreferences.java 2009-08-27 10:38:15 UTC (rev 3303)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/DefaultPreferences.java 2009-08-27 15:13:13 UTC (rev 3304)
@@ -23,65 +23,93 @@
/**
* Define default preferences, i.e. the elements for Fabric3, PEtALS / Frascati and Apache Tuscany.
* @author Vincent Zurczak - EBM WebSourcing
+ * TODO: use properties files to store these informations!
*/
public class DefaultPreferences {
+ private static DefaultPreferences instance = new DefaultPreferences();
+
+ /**
+ * Private constructor.
+ */
+ private DefaultPreferences() {
+ // nothing
+ }
+
+ /**
+ * @return the unique instance of this class.
+ */
+ public static DefaultPreferences getInstance() {
+ return instance;
+ }
+
+
+
// Platforms
- private static final ScaXmlPlatform fabric3 = new ScaXmlPlatform( "Fabric3" ); //$NON-NLS-1$
- private static final ScaXmlPlatform pFrascati = new ScaXmlPlatform( "FraSCAti / PEtALS" ); //$NON-NLS-1$
- private static final ScaXmlPlatform tuscany = new ScaXmlPlatform( "Tuscany" ); //$NON-NLS-1$
-
+ private ScaXmlPlatform fabric3 = new ScaXmlPlatform( "Fabric3" ); //$NON-NLS-1$
+ private ScaXmlPlatform pFrascati = new ScaXmlPlatform( "FraSCAti / PEtALS" ); //$NON-NLS-1$
+ private ScaXmlPlatform tuscany = new ScaXmlPlatform( "Tuscany" ); //$NON-NLS-1$
+
// Fabric3 name spaces
- private static final ScaXmlNamespace fabric3_0_5_1 =
- new ScaXmlNamespace( "http://fabric3.org/xmlns/sca/tutorials/0.5.1", fabric3 ); //$NON-NLS-1$
-
+ private final ScaXmlNamespace fabric3_0_5_1 =
+ new ScaXmlNamespace( "http://fabric3.org/xmlns/sca/tutorials/0.5.1", this.fabric3 ); //$NON-NLS-1$
+
// Frascati name spaces
- private static final ScaXmlNamespace pFrascatiNs =
- new ScaXmlNamespace( "http://frascati.ow2.org", pFrascati ); //$NON-NLS-1$
-
+ private final ScaXmlNamespace pFrascatiNs =
+ new ScaXmlNamespace( "http://frascati.ow2.org", this.pFrascati ); //$NON-NLS-1$
+ private final ScaXmlNamespace pFrascati11Ns =
+ new ScaXmlNamespace( "http://frascati.ow2.org/xmlns/sca/1.1", this.pFrascati ); //$NON-NLS-1$
+
// Tuscany name spaces
- private static final ScaXmlNamespace tuscanyNs =
- new ScaXmlNamespace( "http://tuscany.apache.org/xmlns/sca/1.0", tuscany ); //$NON-NLS-1$
-
-
+ private final ScaXmlNamespace tuscanyNs =
+ new ScaXmlNamespace( "http://tuscany.apache.org/xmlns/sca/1.0", this.tuscany ); //$NON-NLS-1$
+
+
/**
* Register the default preferences in the preference store.
+ * @return the list of default platforms, with their elements.
*/
- public static List<ScaXmlPlatform> getDefaultPreferences() {
-
+ public List<ScaXmlPlatform> getDefaultPreferences() {
+
+ this.fabric3 = new ScaXmlPlatform( "Fabric3" ); //$NON-NLS-1$
+ this.pFrascati = new ScaXmlPlatform( "FraSCAti / PEtALS" ); //$NON-NLS-1$
+ this.tuscany = new ScaXmlPlatform( "Tuscany" ); //$NON-NLS-1$
+
+
// Define platforms
- fabric3.namespaces.add( fabric3_0_5_1 );
+ this.fabric3.namespaces.add( this.fabric3_0_5_1 );
addFabric3DefaultBindings ();
-
- pFrascati.namespaces.add( pFrascatiNs );
+
+ this.pFrascati.namespaces.add( this.pFrascatiNs );
+ this.pFrascati.namespaces.add( this.pFrascati11Ns );
addPetalsFrascatiDefaultBindings ();
addPetalsFrascatiDefaultImplementations ();
-
- tuscany.namespaces.add( tuscanyNs );
+
+ this.tuscany.namespaces.add( this.tuscanyNs );
addTuscanyDefaultBindings ();
addTuscanyDefaultImplementations ();
addTuscanyDefaultInterfaces ();
-
+
// Save preferences
List<ScaXmlPlatform> platforms = new ArrayList<ScaXmlPlatform>();
- platforms.add( fabric3 );
- platforms.add( pFrascati );
- platforms.add( tuscany );
-
+ platforms.add( this.fabric3 );
+ platforms.add( this.pFrascati );
+ platforms.add( this.tuscany );
+
return platforms;
}
-
+
/* "PEtALS / Frascati" */
-
+
/**
* Create default binding preferences for "PEtALS / Frascati".
*/
- private static void addPetalsFrascatiDefaultBindings () {
+ private void addPetalsFrascatiDefaultBindings () {
+
// The best way to manage things correctly is probably to declare them in the version order.
-
- // Version ?
- // Bindings
- ScaXmlElement jbiElement = new ScaXmlElement( "binding.jbi", pFrascati ); //$NON-NLS-1$
+
+ // Version "SCOrWare review"
+ ScaXmlElement jbiElement = new ScaXmlElement( "binding.jbi", this.pFrascati ); //$NON-NLS-1$
new ScaXmlAttribute( "interfaceName", jbiElement, ScaXmlAttributeProperty.required ); //$NON-NLS-1$
new ScaXmlAttribute( "interfaceNamespace", jbiElement, ScaXmlAttributeProperty.required ); //$NON-NLS-1$
new ScaXmlAttribute( "serviceName", jbiElement, ScaXmlAttributeProperty.optional ); //$NON-NLS-1$
@@ -91,97 +119,138 @@
new ScaXmlAttribute( "operationNamespace", jbiElement, ScaXmlAttributeProperty.optional ); //$NON-NLS-1$
new ScaXmlAttribute( "wsdl", jbiElement, ScaXmlAttributeProperty.optional ); //$NON-NLS-1$
new ScaXmlAttribute( "timeout", jbiElement, ScaXmlAttributeProperty.optional ); //$NON-NLS-1$
-
+
List<ScaXmlElement> elements = new ArrayList<ScaXmlElement> ();
- elements.add( jbiElement );
-
+ elements.add( jbiElement );
+
// Register bindings and define mapping with name spaces
- pFrascati.bindings.addAll( elements );
- pFrascati.nsToBindings.put( pFrascatiNs, elements );
-
+ this.pFrascati.bindings.addAll( elements );
+ this.pFrascati.nsToBindings.put( this.pFrascatiNs, elements );
+
+
+ // Version SCA 1.1
+ ScaXmlElement restElement = new ScaXmlElement( "binding.rest", this.pFrascati ); //$NON-NLS-1$
+
+ ScaXmlElement rmiElement = new ScaXmlElement( "binding.rmi", this.pFrascati ); //$NON-NLS-1$
+ new ScaXmlAttribute( "host", rmiElement, ScaXmlAttributeProperty.required ); //$NON-NLS-1$
+ new ScaXmlAttribute( "serviceName", rmiElement, ScaXmlAttributeProperty.required ); //$NON-NLS-1$
+ new ScaXmlAttribute( "port", rmiElement, ScaXmlAttributeProperty.required ); //$NON-NLS-1$
+
+ elements = new ArrayList<ScaXmlElement> ();
+ elements.add( jbiElement ); // Keep JBI
+ elements.add( restElement );
+ elements.add( rmiElement );
+
+ // Register bindings and define mapping with name spaces
+ this.pFrascati.bindings.addAll( elements );
+ this.pFrascati.nsToBindings.put( this.pFrascati11Ns, elements );
+
+
// Modify "elements" with respect to the next version
}
-
+
/**
* Create default implementation preferences for FraSCAti.
*/
- private static void addPetalsFrascatiDefaultImplementations () {
- ScaXmlElement fractalElement = new ScaXmlElement( "binding.fractal", pFrascati ); //$NON-NLS-1$
+ private void addPetalsFrascatiDefaultImplementations () {
+
+ // Initial version
+ ScaXmlElement fractalElement = new ScaXmlElement( "binding.fractal", this.pFrascati ); //$NON-NLS-1$
new ScaXmlAttribute( "definition", fractalElement, ScaXmlAttributeProperty.required ); //$NON-NLS-1$
-
+
List<ScaXmlElement> elements = new ArrayList<ScaXmlElement> ();
- elements.add( fractalElement );
-
+ elements.add( fractalElement );
+
// Register bindings and define mapping with name spaces
- pFrascati.implementations.addAll( elements );
- pFrascati.nsToImplementations.put( pFrascatiNs, elements );
+ this.pFrascati.implementations.addAll( elements );
+ this.pFrascati.nsToImplementations.put( this.pFrascatiNs, elements );
+
+
+ // Version 1.1
+ ScaXmlElement osgiElement = new ScaXmlElement( "implementation.osgi", this.pFrascati ); //$NON-NLS-1$
+ new ScaXmlAttribute( "bundle", osgiElement, ScaXmlAttributeProperty.required ); //$NON-NLS-1$
+
+ ScaXmlElement scriptElement = new ScaXmlElement( "implementation.script", this.pFrascati ); //$NON-NLS-1$
+ new ScaXmlAttribute( "language", scriptElement, ScaXmlAttributeProperty.optional ); //$NON-NLS-1$
+ new ScaXmlAttribute( "script", scriptElement, ScaXmlAttributeProperty.optional ); //$NON-NLS-1$
+
+ elements = new ArrayList<ScaXmlElement> ();
+ elements.add( fractalElement ); // Keep Fractal
+ elements.add( osgiElement );
+ elements.add( scriptElement );
+
+ // Register bindings and define mapping with name spaces
+ this.pFrascati.implementations.addAll( elements );
+ this.pFrascati.nsToImplementations.put( this.pFrascati11Ns, elements );
}
-
+
/* FABRIC 3 */
-
+
/**
* Create default binding preferences for "Fabric3".
*/
- private static void addFabric3DefaultBindings () {
+ private void addFabric3DefaultBindings () {
+
// The best way to manage things correctly is probably to declare them in the version order.
-
+
// Version 0.5.1
// Bindings
- ScaXmlElement burlapElement = new ScaXmlElement( "binding.burlap", fabric3 ); //$NON-NLS-1$
+ ScaXmlElement burlapElement = new ScaXmlElement( "binding.burlap", this.fabric3 ); //$NON-NLS-1$
new ScaXmlAttribute( "uri", burlapElement, ScaXmlAttributeProperty.required ); //$NON-NLS-1$
-
- ScaXmlElement hessianElement = new ScaXmlElement( "binding.hessian", fabric3 ); //$NON-NLS-1$
+
+ ScaXmlElement hessianElement = new ScaXmlElement( "binding.hessian", this.fabric3 ); //$NON-NLS-1$
new ScaXmlAttribute( "uri", hessianElement, ScaXmlAttributeProperty.required ); //$NON-NLS-1$
-
+
List<ScaXmlElement> elements = new ArrayList<ScaXmlElement> ();
elements.add( burlapElement );
elements.add( hessianElement );
-
+
// Register bindings and define mapping with name spaces
- fabric3.bindings.addAll( elements );
- fabric3.nsToBindings.put( fabric3_0_5_1, elements );
-
-
+ this.fabric3.bindings.addAll( elements );
+ this.fabric3.nsToBindings.put( this.fabric3_0_5_1, elements );
+
+
// Modify "elements" with respect to the next version
}
-
+
/* TUSCANY */
-
+
/**
* Create default binding preferences for "Tuscany".
*/
- private static void addTuscanyDefaultBindings () {
+ private void addTuscanyDefaultBindings () {
+
// The best way to manage things correctly is probably to declare them in the version order.
-
+
// Version ?
// Bindings
- ScaXmlElement ajaxElement = new ScaXmlElement( "binding.ajax", tuscany ); //$NON-NLS-1$
- ScaXmlElement dwrElement = new ScaXmlElement( "binding.dwr", tuscany ); //$NON-NLS-1$
- ScaXmlElement httpElement = new ScaXmlElement( "binding.http", tuscany ); //$NON-NLS-1$
- ScaXmlElement jsonRpcElement = new ScaXmlElement( "binding.jsonrpc", tuscany ); //$NON-NLS-1$
-
- ScaXmlElement atomElement = new ScaXmlElement( "binding.atom", tuscany ); //$NON-NLS-1$
+ ScaXmlElement ajaxElement = new ScaXmlElement( "binding.ajax", this.tuscany ); //$NON-NLS-1$
+ ScaXmlElement dwrElement = new ScaXmlElement( "binding.dwr", this.tuscany ); //$NON-NLS-1$
+ ScaXmlElement httpElement = new ScaXmlElement( "binding.http", this.tuscany ); //$NON-NLS-1$
+ ScaXmlElement jsonRpcElement = new ScaXmlElement( "binding.jsonrpc", this.tuscany ); //$NON-NLS-1$
+
+ ScaXmlElement atomElement = new ScaXmlElement( "binding.atom", this.tuscany ); //$NON-NLS-1$
new ScaXmlAttribute( "title", atomElement, ScaXmlAttributeProperty.optional ); //$NON-NLS-1$
-
- ScaXmlElement ejbElement = new ScaXmlElement( "binding.ejb", tuscany ); //$NON-NLS-1$
+
+ ScaXmlElement ejbElement = new ScaXmlElement( "binding.ejb", this.tuscany ); //$NON-NLS-1$
new ScaXmlAttribute( "uri", ejbElement, ScaXmlAttributeProperty.required ); //$NON-NLS-1$
-
- ScaXmlElement jmsElement = new ScaXmlElement( "binding.jms", tuscany ); //$NON-NLS-1$
+
+ ScaXmlElement jmsElement = new ScaXmlElement( "binding.jms", this.tuscany ); //$NON-NLS-1$
new ScaXmlAttribute( "uri", jmsElement, ScaXmlAttributeProperty.required ); //$NON-NLS-1$
-
- ScaXmlElement notificationElement = new ScaXmlElement( "binding.notification", tuscany ); //$NON-NLS-1$
+
+ ScaXmlElement notificationElement = new ScaXmlElement( "binding.notification", this.tuscany ); //$NON-NLS-1$
new ScaXmlAttribute( "ntm", notificationElement, ScaXmlAttributeProperty.optional ); //$NON-NLS-1$
new ScaXmlAttribute( "notificationType", notificationElement, ScaXmlAttributeProperty.optional ); //$NON-NLS-1$
- ScaXmlElement rmiElement = new ScaXmlElement( "binding.rmi", tuscany ); //$NON-NLS-1$
+ ScaXmlElement rmiElement = new ScaXmlElement( "binding.rmi", this.tuscany ); //$NON-NLS-1$
String[] rmiAttributes = new String[] { "host", "port", "serviceName" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
for( String rmiAttribute : rmiAttributes ) {
new ScaXmlAttribute( rmiAttribute, rmiElement, ScaXmlAttributeProperty.required );
}
-
- ScaXmlElement rssElement = new ScaXmlElement( "binding.rss", tuscany ); //$NON-NLS-1$
+
+ ScaXmlElement rssElement = new ScaXmlElement( "binding.rss", this.tuscany ); //$NON-NLS-1$
new ScaXmlAttribute( "title", rssElement, ScaXmlAttributeProperty.optional ); //$NON-NLS-1$
-
+
// Register bindings and define mapping with name spaces
List<ScaXmlElement> elements = new ArrayList<ScaXmlElement> ();
elements.add( ajaxElement );
@@ -194,47 +263,48 @@
elements.add( notificationElement );
elements.add( rmiElement );
elements.add( rssElement );
-
- tuscany.bindings.addAll( elements );
- tuscany.nsToBindings.put( tuscanyNs, elements );
-
-
+
+ this.tuscany.bindings.addAll( elements );
+ this.tuscany.nsToBindings.put( this.tuscanyNs, elements );
+
+
// Modify "elements" with respect to the next version
}
-
+
/**
* Create default implementation preferences for Tuscany.
*/
- private static void addTuscanyDefaultImplementations () {
+ private void addTuscanyDefaultImplementations () {
+
// The best way to manage things correctly is probably to declare them in the version order.
-
+
// Version ?
// Implementations
- ScaXmlElement bpelElement = new ScaXmlElement( "implementation.bpel", tuscany ); //$NON-NLS-1$
+ ScaXmlElement bpelElement = new ScaXmlElement( "implementation.bpel", this.tuscany ); //$NON-NLS-1$
new ScaXmlAttribute( "process", bpelElement, ScaXmlAttributeProperty.required ); //$NON-NLS-1$
-
+
//
- ScaXmlElement dasElement = new ScaXmlElement( "implementation.das", tuscany ); //$NON-NLS-1$
+ ScaXmlElement dasElement = new ScaXmlElement( "implementation.das", this.tuscany ); //$NON-NLS-1$
new ScaXmlAttribute( "config", dasElement, ScaXmlAttributeProperty.required ); //$NON-NLS-1$
new ScaXmlAttribute( "dataAccessType", dasElement, ScaXmlAttributeProperty.required ); //$NON-NLS-1$
-
+
ScaXmlElement connectionInfoElement = new ScaXmlElement( "ConnectionInfo", dasElement ); //$NON-NLS-1$
new ScaXmlAttribute( "dataSource", connectionInfoElement, ScaXmlAttributeProperty.optional ); //$NON-NLS-1$
new ScaXmlAttribute( "managedtx", connectionInfoElement, ScaXmlAttributeProperty.optional, "", "true" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
+
ScaXmlElement connectionPropertiesElement = new ScaXmlElement( "ConnectionProperties", connectionInfoElement ); //$NON-NLS-1$
new ScaXmlAttribute( "driverClass", connectionPropertiesElement, ScaXmlAttributeProperty.optional ); //$NON-NLS-1$
new ScaXmlAttribute( "databaseURL", connectionPropertiesElement, ScaXmlAttributeProperty.optional ); //$NON-NLS-1$
new ScaXmlAttribute( "username", connectionPropertiesElement, ScaXmlAttributeProperty.optional, "", "" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new ScaXmlAttribute( "password", connectionPropertiesElement, ScaXmlAttributeProperty.optional, "", "" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new ScaXmlAttribute( "loginTimeout", connectionPropertiesElement, ScaXmlAttributeProperty.optional, "", "0" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
+
//
- ScaXmlElement dataElement = new ScaXmlElement( "implementation.data", tuscany ); //$NON-NLS-1$
+ ScaXmlElement dataElement = new ScaXmlElement( "implementation.data", this.tuscany ); //$NON-NLS-1$
connectionInfoElement = new ScaXmlElement( "ConnectionInfo", dataElement ); //$NON-NLS-1$
new ScaXmlAttribute( "dataSource", connectionInfoElement, ScaXmlAttributeProperty.optional ); //$NON-NLS-1$
new ScaXmlAttribute( "managedtx", connectionInfoElement, ScaXmlAttributeProperty.optional, "", "true" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
+
connectionPropertiesElement = new ScaXmlElement( "ConnectionProperties", connectionInfoElement ); //$NON-NLS-1$
new ScaXmlAttribute( "driverClass", connectionPropertiesElement, ScaXmlAttributeProperty.optional ); //$NON-NLS-1$
new ScaXmlAttribute( "databaseURL", connectionPropertiesElement, ScaXmlAttributeProperty.optional ); //$NON-NLS-1$
@@ -243,47 +313,47 @@
new ScaXmlAttribute( "loginTimeout", connectionPropertiesElement, ScaXmlAttributeProperty.optional, "", "0" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//
- ScaXmlElement nodeElement = new ScaXmlElement( "implementation.node", tuscany ); //$NON-NLS-1$
+ ScaXmlElement nodeElement = new ScaXmlElement( "implementation.node", this.tuscany ); //$NON-NLS-1$
new ScaXmlAttribute( "uri", nodeElement, ScaXmlAttributeProperty.required ); //$NON-NLS-1$
new ScaXmlAttribute( "composite", nodeElement, ScaXmlAttributeProperty.required ); //$NON-NLS-1$
-
+
//
- ScaXmlElement notificationElement = new ScaXmlElement( "implementation.notification", tuscany ); //$NON-NLS-1$
+ ScaXmlElement notificationElement = new ScaXmlElement( "implementation.notification", this.tuscany ); //$NON-NLS-1$
new ScaXmlAttribute( "name", notificationElement, ScaXmlAttributeProperty.required ); //$NON-NLS-1$
-
+
//
- ScaXmlElement osgiElement = new ScaXmlElement( "implementation.osgi", tuscany ); //$NON-NLS-1$
+ ScaXmlElement osgiElement = new ScaXmlElement( "implementation.osgi", this.tuscany ); //$NON-NLS-1$
new ScaXmlAttribute( "bundleSymbolicName", osgiElement, ScaXmlAttributeProperty.required ); //$NON-NLS-1$
new ScaXmlAttribute( "bundleVersion", osgiElement, ScaXmlAttributeProperty.optional ); //$NON-NLS-1$
new ScaXmlAttribute( "classes", osgiElement, ScaXmlAttributeProperty.optional ); //$NON-NLS-1$
new ScaXmlAttribute( "imports", osgiElement, ScaXmlAttributeProperty.optional ); //$NON-NLS-1$
-
+
ScaXmlElement osgiPropertiesElement = new ScaXmlElement( "properties", osgiElement ); //$NON-NLS-1$
new ScaXmlAttribute( "service", osgiPropertiesElement, ScaXmlAttributeProperty.optional ); //$NON-NLS-1$
new ScaXmlAttribute( "reference", osgiPropertiesElement, ScaXmlAttributeProperty.optional ); //$NON-NLS-1$
new ScaXmlAttribute( "serviceCallback", osgiPropertiesElement, ScaXmlAttributeProperty.optional ); //$NON-NLS-1$
new ScaXmlAttribute( "referenceCallback", osgiPropertiesElement, ScaXmlAttributeProperty.optional ); //$NON-NLS-1$
-
+
//
- ScaXmlElement resourceElement = new ScaXmlElement( "implementation.resource", tuscany ); //$NON-NLS-1$
+ ScaXmlElement resourceElement = new ScaXmlElement( "implementation.resource", this.tuscany ); //$NON-NLS-1$
new ScaXmlAttribute( "location", resourceElement, ScaXmlAttributeProperty.required ); //$NON-NLS-1$
-
+
//
- ScaXmlElement scriptElement = new ScaXmlElement( "implementation.script", tuscany ); //$NON-NLS-1$
+ ScaXmlElement scriptElement = new ScaXmlElement( "implementation.script", this.tuscany ); //$NON-NLS-1$
new ScaXmlAttribute( "script", scriptElement, ScaXmlAttributeProperty.optional ); //$NON-NLS-1$
new ScaXmlAttribute( "language", scriptElement, ScaXmlAttributeProperty.optional ); //$NON-NLS-1$
-
+
//
- ScaXmlElement xqueryElement = new ScaXmlElement( "implementation.xquery", tuscany ); //$NON-NLS-1$
+ ScaXmlElement xqueryElement = new ScaXmlElement( "implementation.xquery", this.tuscany ); //$NON-NLS-1$
new ScaXmlAttribute( "location", xqueryElement, ScaXmlAttributeProperty.required ); //$NON-NLS-1$
-
+
//
- ScaXmlElement widgetElement = new ScaXmlElement( "implementation.widget", tuscany ); //$NON-NLS-1$
+ ScaXmlElement widgetElement = new ScaXmlElement( "implementation.widget", this.tuscany ); //$NON-NLS-1$
new ScaXmlAttribute( "location", widgetElement, ScaXmlAttributeProperty.required ); //$NON-NLS-1$
-
+
//
- ScaXmlElement springElement = new ScaXmlElement( "implementation.spring", tuscany ); //$NON-NLS-1$
-
+ ScaXmlElement springElement = new ScaXmlElement( "implementation.spring", this.tuscany ); //$NON-NLS-1$
+
// Register bindings and define mapping with name spaces
List<ScaXmlElement> elements = new ArrayList<ScaXmlElement> ();
elements.add( bpelElement );
@@ -297,32 +367,33 @@
elements.add( xqueryElement );
elements.add( widgetElement );
elements.add( springElement );
-
- tuscany.implementations.addAll( elements );
- tuscany.nsToImplementations.put( tuscanyNs, elements );
-
-
+
+ this.tuscany.implementations.addAll( elements );
+ this.tuscany.nsToImplementations.put( this.tuscanyNs, elements );
+
+
// Modify "elements" with respect to the next version
}
-
+
/**
* Create default interface preferences for Tuscany.
*/
- private static void addTuscanyDefaultInterfaces () {
+ private void addTuscanyDefaultInterfaces () {
+
// The best way to manage things correctly is probably to declare them in the version order.
-
+
// Version ?
// Interfaces
- ScaXmlElement cppElement = new ScaXmlElement( "interface.cpp", tuscany ); //$NON-NLS-1$
-
+ ScaXmlElement cppElement = new ScaXmlElement( "interface.cpp", this.tuscany ); //$NON-NLS-1$
+
List<ScaXmlElement> elements = new ArrayList<ScaXmlElement> ();
elements.add( cppElement );
-
+
// Register interfaces and define mapping with name spaces
- tuscany.interfaces.addAll( elements );
- tuscany.nsToInterfaces.put( tuscanyNs, elements );
-
-
+ this.tuscany.interfaces.addAll( elements );
+ this.tuscany.nsToInterfaces.put( this.tuscanyNs, elements );
+
+
// Modify "elements" with respect to the next version
}
}
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/ScaXmlPreferenceInitializer.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/ScaXmlPreferenceInitializer.java 2009-08-27 10:38:15 UTC (rev 3303)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/ScaXmlPreferenceInitializer.java 2009-08-27 15:13:13 UTC (rev 3304)
@@ -28,7 +28,7 @@
*/
@Override
public void initializeDefaultPreferences() {
- List<ScaXmlPlatform> platforms = DefaultPreferences.getDefaultPreferences();
+ List<ScaXmlPlatform> platforms = DefaultPreferences.getInstance().getDefaultPreferences();
ScaXmlPreferenceUtils.savePlatformsToPS( platforms );
}
}
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/ScaXmlPreferencePage.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/ScaXmlPreferencePage.java 2009-08-27 10:38:15 UTC (rev 3303)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/ScaXmlPreferencePage.java 2009-08-27 15:13:13 UTC (rev 3304)
@@ -90,7 +90,7 @@
*/
@Override
protected void performDefaults() {
- platforms = DefaultPreferences.getDefaultPreferences();
+ platforms = DefaultPreferences.getInstance().getDefaultPreferences();
refreshViewers ();
}
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/ScaXmlPreferenceUtils.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/ScaXmlPreferenceUtils.java 2009-08-27 10:38:15 UTC (rev 3303)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/ScaXmlPreferenceUtils.java 2009-08-27 15:13:13 UTC (rev 3304)
@@ -61,7 +61,7 @@
ByteArrayInputStream iStream = new ByteArrayInputStream( Base64.decode( prefs.getBytes()));
ObjectInputStream o = new ObjectInputStream( iStream );
- List<ScaXmlPlatform> platforms = (List<ScaXmlPlatform>) o.readObject();
+ List<ScaXmlPlatform> platforms = (List<ScaXmlPlatform>) o.readObject();
return platforms;
@@ -191,11 +191,15 @@
* @return the platforms owning one of the argument name spaces.
*/
public static Set<ScaXmlPlatform> getPlatforms( String... namespaces ) {
+
Set<ScaXmlPlatform> platforms = new HashSet<ScaXmlPlatform> ();
for( ScaXmlPlatform platform : getPlatformsFromPS()) {
- for( String namespace : namespaces ) {
- if( platform.namespaces.contains( namespace ))
- platforms.add( platform );
+ for( ScaXmlNamespace ns : platform.namespaces ) {
+ for( String namespace : namespaces ) {
+ if( ns.getName() != null
+ && ns.getName().equals( namespace ))
+ platforms.add( platform );
+ }
}
}
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/beans/ScaXmlAttribute.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/beans/ScaXmlAttribute.java 2009-08-27 10:38:15 UTC (rev 3303)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/beans/ScaXmlAttribute.java 2009-08-27 15:13:13 UTC (rev 3304)
@@ -21,6 +21,7 @@
* @author Vincent Zurczak - EBM WebSourcing
*/
public class ScaXmlAttribute extends ScaXmlItem implements Externalizable {
+
/**
* The use of the attribute.
* @see ScaXmlAttributeProperty
@@ -159,7 +160,7 @@
if( this.element != null )
this.element.attributes.remove( this );
- this.element = element;
+ this.element = element;
if( element != null && !element.attributes.contains( this ))
element.attributes.add( this );
}
@@ -174,12 +175,13 @@
/**
- * Two {@link ScaXmlAttribute} instances are equal if they have the same element and the name.
+ * Two {@link ScaXmlAttribute} instances are equal if they have the same element and name.
* @see org.eclipse.stp.sca.xmleditor.preferences.beans.ScaXmlItem#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
- if( !super.equals( obj ) )
+
+ if( ! super.equals( obj ) )
return false;
ScaXmlAttribute attr = (ScaXmlAttribute) obj;
@@ -193,6 +195,18 @@
// Last case: all null => equal.
return true;
}
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.stp.sca.xmleditor.preferences.beans.ScaXmlItem#hashCode()
+ */
+ @Override
+ public int hashCode() {
+
+ int eltHash = element == null ? 31 : element.hashCode();
+ int nameHashCode = name == null ? 2017 : name.hashCode();
+ return eltHash * nameHashCode;
+ }
/*
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/beans/ScaXmlElement.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/beans/ScaXmlElement.java 2009-08-27 10:38:15 UTC (rev 3303)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/beans/ScaXmlElement.java 2009-08-27 15:13:13 UTC (rev 3304)
@@ -28,11 +28,12 @@
* An XmlElement may have a parent element if it is a custom type, or a platform if it
* is a binding, an implementation or an interface. It can't have both an element and a platform.
* <br />Two XmlElements may have the same name but be associated with different name spaces.
- * </p>
- *
+ * </p>
+ *
* @author Vincent Zurczak - EBM WebSourcing
*/
public class ScaXmlElement extends ScaXmlItem implements Externalizable {
+
/**
* The minimal integer value that can be used as an ID for an {@link ScaXmlElement} instance.
* <p>
@@ -41,61 +42,59 @@
* </p>
*/
private static int idCpt = 0;
-
+
private int id;
private int minOccurs = 0;
private int maxOccurs = 1;
- private boolean unbounded = false;
+ private boolean unbounded = false;
private ScaXmlElement parent;
private ScaXmlPlatform platform;
-
+
final public Set<ScaXmlAttribute> attributes = new HashSet<ScaXmlAttribute> ();
final public Set<ScaXmlElement> children = new HashSet<ScaXmlElement> ();
-
-
-
+
+
+
/**
* Default constructor for the serialization (incremented ID).
*/
- public ScaXmlElement() {
- id = idCpt ++;
- };
-
-
+ public ScaXmlElement() {}
+
+
/**
* Simple constructor to set the platform name.
* @param name the element name
* @param platform the element platform (if it's a binding, an implementation or an interface)
*/
- public ScaXmlElement( String name, ScaXmlPlatform platform ) {
- this();
+ public ScaXmlElement( String name, ScaXmlPlatform platform ) {
+ this.id = idCpt ++;
this.name = name;
this.platform = platform;
}
-
-
+
+
/**
* Simple constructor to set the platform name and the element owner.
* <p>If the parent is not null, then this element is added to the parent children.</p>
- *
+ *
* @param name the element name
* @param parent the XML element which owns this element
*/
public ScaXmlElement( String name, ScaXmlElement parent ) {
- this();
+ this.id = idCpt ++;
this.name = name;
this.parent = parent;
-
+
if( parent != null )
parent.children.add( this );
}
-
+
/**
* @return the minOccurs
*/
public int getMinOccurs() {
- return minOccurs;
+ return this.minOccurs;
}
@@ -111,7 +110,7 @@
* @return the maxOccurs
*/
public int getMaxOccurs() {
- return maxOccurs;
+ return this.maxOccurs;
}
@@ -127,7 +126,7 @@
* @return the unbounded
*/
public boolean isUnbounded() {
- return unbounded;
+ return this.unbounded;
}
@@ -143,7 +142,7 @@
* @return the id
*/
public int getId() {
- return id;
+ return this.id;
}
@@ -151,7 +150,7 @@
* @return the parent
*/
public ScaXmlElement getParent() {
- return parent;
+ return this.parent;
}
@@ -168,7 +167,7 @@
public void setParent( ScaXmlElement parent ) {
if( this.parent != null )
this.parent.children.remove( this );
-
+
this.parent = parent;
if( parent != null )
parent.children.add( this );
@@ -179,7 +178,7 @@
* @return the platform
*/
public ScaXmlPlatform getPlatform() {
- return platform;
+ return this.platform;
}
@@ -189,15 +188,14 @@
public void setPlatform( ScaXmlPlatform platform ) {
this.platform = platform;
}
-
+
/**
* @return the parent platform
*/
public ScaXmlPlatform getParentPlatform() {
- if( platform != null )
- return platform;
- else
- return parent.getParentPlatform();
+ if( this.platform != null )
+ return this.platform;
+ return this.parent.getParentPlatform();
}
@@ -207,36 +205,50 @@
*/
@Override
public boolean equals( Object obj ) {
- if( obj == null || !ScaXmlElement.class.equals( obj.getClass()))
+
+ if( obj == null || !( obj instanceof ScaXmlElement ))
return false;
-
+
ScaXmlElement elt = (ScaXmlElement) obj;
- return id == elt.id;
+ return this.id == elt.id;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.stp.sca.xmleditor.preferences.beans.ScaXmlItem#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return this.id;
+ }
+
+
/*
* (non-Javadoc)
* @see java.io.Externalizable#readExternal(java.io.ObjectInput)
*/
- @SuppressWarnings("unchecked")
public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException {
- name = in.readUTF();
- id = in.readInt();
- if( idCpt < id )
- idCpt = id + 1;
-
- minOccurs = in.readInt();
- maxOccurs = in.readInt();
- unbounded = in.readBoolean();
-
- attributes.addAll((Set<ScaXmlAttribute>) in.readObject());
- for( ScaXmlAttribute attr : attributes )
+
+ this.name = in.readUTF();
+ this.id = in.readInt();
+ if( idCpt < this.id )
+ idCpt = this.id + 1;
+
+ this.minOccurs = in.readInt();
+ this.maxOccurs = in.readInt();
+ this.unbounded = in.readBoolean();
+
+ for( Object o : (Set<?>) in.readObject()) {
+ ScaXmlAttribute attr = (ScaXmlAttribute) o;
attr.setElement( this );
-
- children.addAll((Set<ScaXmlElement>) in.readObject());
- for( ScaXmlElement child : children )
+ this.attributes.add( attr );
+ }
+
+ for( Object o : (Set<?>) in.readObject()) {
+ ScaXmlElement child = (ScaXmlElement) o;
child.setParent( this );
+ this.children.add( child );
+ }
}
@@ -245,60 +257,60 @@
* @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
*/
public void writeExternal( ObjectOutput out ) throws IOException {
- out.writeUTF( name );
- out.writeInt( id );
- out.writeInt( minOccurs );
- out.writeInt( maxOccurs );
- out.writeBoolean( unbounded );
-
- out.writeObject( attributes );
- out.writeObject( children );
+ out.writeUTF( this.name );
+ out.writeInt( this.id );
+ out.writeInt( this.minOccurs );
+ out.writeInt( this.maxOccurs );
+ out.writeBoolean( this.unbounded );
+
+ out.writeObject( this.attributes );
+ out.writeObject( this.children );
}
-
-
+
+
/**
* @return the name spaces of the element
*/
public List<ScaXmlNamespace> getNameSpaces() {
- if( platform != null ) {
+ if( this.platform != null ) {
List<ScaXmlNamespace> ns = new ArrayList<ScaXmlNamespace> ();
-
- for( Map.Entry<ScaXmlNamespace, List<ScaXmlElement>> entry : platform.nsToBindings.entrySet()) {
+
+ for( Map.Entry<ScaXmlNamespace, List<ScaXmlElement>> entry : this.platform.nsToBindings.entrySet()) {
if( entry.getValue().contains( this ))
ns.add( entry.getKey());
}
-
- for( Map.Entry<ScaXmlNamespace, List<ScaXmlElement>> entry : platform.nsToImplementations.entrySet()) {
+
+ for( Map.Entry<ScaXmlNamespace, List<ScaXmlElement>> entry : this.platform.nsToImplementations.entrySet()) {
if( entry.getValue().contains( this ))
ns.add( entry.getKey());
}
-
- for( Map.Entry<ScaXmlNamespace, List<ScaXmlElement>> entry : platform.nsToInterfaces.entrySet()) {
+
+ for( Map.Entry<ScaXmlNamespace, List<ScaXmlElement>> entry : this.platform.nsToInterfaces.entrySet()) {
if( entry.getValue().contains( this ))
ns.add( entry.getKey());
}
-
+
return ns;
}
-
- if( parent != null )
- return parent.getNameSpaces();
-
+
+ if( this.parent != null )
+ return this.parent.getNameSpaces();
+
return Collections.emptyList();
}
-
-
+
+
/**
- *
+ *
* @param nsUri
- * @return
+ * @return true if this elements is associated to this name space
*/
public boolean hasNamespace( String nsUri ) {
for( ScaXmlNamespace ns : getNameSpaces()) {
if( ns.getName().equals( nsUri ))
return true;
}
-
+
return false;
}
}
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/beans/ScaXmlNamespace.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/beans/ScaXmlNamespace.java 2009-08-27 10:38:15 UTC (rev 3303)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/beans/ScaXmlNamespace.java 2009-08-27 15:13:13 UTC (rev 3304)
@@ -21,6 +21,7 @@
* @author Vincent Zurczak - EBM WebSourcing
*/
public class ScaXmlNamespace extends ScaXmlItem implements Externalizable {
+
/**
* The platform which owns this name space.
*/
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/beans/ScaXmlPlatform.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/beans/ScaXmlPlatform.java 2009-08-27 10:38:15 UTC (rev 3303)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/beans/ScaXmlPlatform.java 2009-08-27 15:13:13 UTC (rev 3304)
@@ -29,7 +29,7 @@
* and take as less space as possible.<br />
* A specific care must be given to the meaning of the elements.
* A platform has name spaces, bindings, implementations and interfaces.
- * Each of these elements exists independently from the others.
+ * Each of these elements exists independently from the others.
* </p>
* <p>
* However, there are also associations between these elements.<br />
@@ -42,11 +42,11 @@
* Roughly, we are reinventing data bases, except that we have to use
* the Eclipse preferences mechanism.
* </p>
- *
+ *
* @author Vincent Zurczak - EBM WebSourcing
*/
public class ScaXmlPlatform extends ScaXmlItem implements Externalizable {
-
+
/**
* The platform name spaces.
*/
@@ -58,7 +58,7 @@
* But two bindings with the same name can't be associated with a same name space.
* </p>
*/
- public final List<ScaXmlElement> bindings = new ArrayList<ScaXmlElement> ();
+ public final Set<ScaXmlElement> bindings = new HashSet<ScaXmlElement> ();
/**
* The platform implementations.
* <p>
@@ -66,7 +66,7 @@
* But two implementations with the same name can't be associated with a same name space.
* </p>
*/
- public final List<ScaXmlElement> implementations = new ArrayList<ScaXmlElement> ();
+ public final Set<ScaXmlElement> implementations = new HashSet<ScaXmlElement> ();
/**
* The platform interfaces.
* <p>
@@ -74,36 +74,36 @@
* But two interfaces with the same name can't be associated with a same name space.
* </p>
*/
- public final List<ScaXmlElement> interfaces = new ArrayList<ScaXmlElement> ();
-
-
- /**
+ public final Set<ScaXmlElement> interfaces = new HashSet<ScaXmlElement> ();
+
+
+ /**
* Map name spaces with bindings.
- * It is the responsibility of the client to make sure the name space used as key
- * already exists in {@link #namespaces}.
+ * It is the responsibility of the client to make sure the name space used as key
+ * already exists in {@link #namespaces}.
*/
public final Map<ScaXmlNamespace, List<ScaXmlElement>> nsToBindings = new HashMap<ScaXmlNamespace, List<ScaXmlElement>> ();
- /**
+ /**
* Map name spaces with implementations.
- * It is the responsibility of the client to make sure the name space used as key
- * already exists in {@link #namespaces}.
+ * It is the responsibility of the client to make sure the name space used as key
+ * already exists in {@link #namespaces}.
*/
public final Map<ScaXmlNamespace, List<ScaXmlElement>> nsToImplementations = new HashMap<ScaXmlNamespace, List<ScaXmlElement>> ();
- /**
+ /**
* Map name spaces with interfaces.
- * It is the responsibility of the client to make sure the name space used as key
- * already exists in {@link #namespaces}.
+ * It is the responsibility of the client to make sure the name space used as key
+ * already exists in {@link #namespaces}.
*/
public final Map<ScaXmlNamespace, List<ScaXmlElement>> nsToInterfaces = new HashMap<ScaXmlNamespace, List<ScaXmlElement>> ();
-
-
+
+
/**
* Public empty constructor for the serialization.
*/
- public ScaXmlPlatform() {};
-
-
+ public ScaXmlPlatform() {}
+
+
/**
* Simple constructor which sets the platform name.
* @param name the platform name
@@ -111,8 +111,8 @@
public ScaXmlPlatform( String name ) {
this.name = name;
}
-
+
/**
* The types of the SCA elements owned by a platform: bindings, interfaces and implementations.
*/
@@ -120,39 +120,78 @@
bindings, implementations, interfaces;
}
-
+
/*
* (non-Javadoc)
* @see java.io.Externalizable#readExternal(java.io.ObjectInput)
*/
- @SuppressWarnings("unchecked")
public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException {
- name = in.readUTF();
-
- namespaces.addAll((Set<ScaXmlNamespace>) in.readObject());
- for( ScaXmlNamespace ns : namespaces )
+
+ this.name = in.readUTF();
+
+ Set<?> set = (Set<?>) in.readObject();
+ for( Object o : set ) {
+ ScaXmlNamespace ns = (ScaXmlNamespace) o;
ns.setPlatform( this );
-
- bindings.addAll((List<ScaXmlElement>) in.readObject());
- for( ScaXmlElement elt : bindings )
+ this.namespaces.add( ns );
+ }
+
+ set = (Set<?>) in.readObject();
+ for( Object o : set ) {
+ ScaXmlElement elt = (ScaXmlElement) o;
elt.setPlatform( this );
-
- implementations.addAll((List<ScaXmlElement>) in.readObject());
- for( ScaXmlElement elt : implementations )
+ this.bindings.add( elt );
+ }
+
+ set = (Set<?>) in.readObject();
+ for( Object o : set ) {
+ ScaXmlElement elt = (ScaXmlElement) o;
elt.setPlatform( this );
-
- interfaces.addAll((List<ScaXmlElement>) in.readObject());
- for( ScaXmlElement elt : interfaces )
+ this.implementations.add( elt );
+ }
+
+ set = (Set<?>) in.readObject();
+ for( Object o : set ) {
+ ScaXmlElement elt = (ScaXmlElement) o;
elt.setPlatform( this );
-
- Map<ScaXmlNamespace, List<Integer>> bindMapIds = (Map<ScaXmlNamespace, List<Integer>>) in.readObject();
- nsToBindings.putAll( getMappingToElements( bindMapIds, ScaXmlElementType.bindings ));
-
- Map<ScaXmlNamespace, List<Integer>> implMapIds = (Map<ScaXmlNamespace, List<Integer>>) in.readObject();
- nsToImplementations.putAll( getMappingToElements( implMapIds, ScaXmlElementType.implementations ));
-
- Map<ScaXmlNamespace, List<Integer>> interfMapIds = (Map<ScaXmlNamespace, List<Integer>>) in.readObject();
- nsToInterfaces.putAll( getMappingToElements( interfMapIds, ScaXmlElementType.interfaces ));
+ this.interfaces.add( elt );
+ }
+
+ Map<?,?> map = (Map<?,?>) in.readObject();
+ for( Map.Entry<?,?> entry : map.entrySet()) {
+ ScaXmlNamespace ns = (ScaXmlNamespace) entry.getKey();
+ List<Integer> ids = new ArrayList<Integer>();
+
+ for( Object id : (List<?>) entry.getValue())
+ ids.add((Integer) id);
+
+ this.nsToBindings.put( ns,
+ getMappingToElements( ids, ScaXmlElementType.bindings ));
+ }
+
+ map = (Map<?,?>) in.readObject();
+ for( Map.Entry<?,?> entry : map.entrySet()) {
+ ScaXmlNamespace ns = (ScaXmlNamespace) entry.getKey();
+ List<Integer> ids = new ArrayList<Integer>();
+
+ for( Object id : (List<?>) entry.getValue())
+ ids.add((Integer) id);
+
+ this.nsToImplementations.put( ns,
+ getMappingToElements( ids, ScaXmlElementType.implementations ));
+ }
+
+ map = (Map<?,?>) in.readObject();
+ for( Map.Entry<?,?> entry : map.entrySet()) {
+ ScaXmlNamespace ns = (ScaXmlNamespace) entry.getKey();
+ List<Integer> ids = new ArrayList<Integer>();
+
+ for( Object id : (List<?>) entry.getValue())
+ ids.add((Integer) id);
+
+ this.nsToInterfaces.put( ns,
+ getMappingToElements( ids, ScaXmlElementType.interfaces ));
+ }
}
@@ -161,77 +200,67 @@
* @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
*/
public void writeExternal( ObjectOutput out ) throws IOException {
- out.writeUTF( name );
- out.writeObject( namespaces );
- out.writeObject( bindings );
- out.writeObject( implementations );
- out.writeObject( interfaces );
-
- Map<ScaXmlNamespace, List<Integer>> bindMapIds = getMappingToIds( nsToBindings );
+
+ out.writeUTF( this.name );
+ out.writeObject( this.namespaces );
+ out.writeObject( this.bindings );
+ out.writeObject( this.implementations );
+ out.writeObject( this.interfaces );
+
+ Map<ScaXmlNamespace, List<Integer>> bindMapIds = getMappingToIds( this.nsToBindings );
out.writeObject( bindMapIds );
- Map<ScaXmlNamespace, List<Integer>> implMapIds = getMappingToIds( nsToImplementations );
+ Map<ScaXmlNamespace, List<Integer>> implMapIds = getMappingToIds( this.nsToImplementations );
out.writeObject( implMapIds );
- Map<ScaXmlNamespace, List<Integer>> interfMapIds = getMappingToIds( nsToInterfaces );
+ Map<ScaXmlNamespace, List<Integer>> interfMapIds = getMappingToIds( this.nsToInterfaces );
out.writeObject( interfMapIds );
}
-
-
+
+
/**
- * @param association a map like {@link #bindings}, {@link #implementations} or {@link #interfaces}.
+ * @param association a map like {@link #bindings}, {@link #implementations} or {@link #interfaces}.
* @return a map equivalent to the argument map but with {@link ScaXmlElement} IDs instead of {@link ScaXmlElement}s.
*/
private Map<ScaXmlNamespace, List<Integer>> getMappingToIds( Map<ScaXmlNamespace, List<ScaXmlElement>> association ) {
-
+
Map<ScaXmlNamespace, List<Integer>> nsToElementIds = new HashMap<ScaXmlNamespace, List<Integer>> ();
for( Map.Entry<ScaXmlNamespace, List<ScaXmlElement>> entry : association.entrySet()) {
-
+
List<Integer> ids = new ArrayList<Integer> ();
for( ScaXmlElement elt : entry.getValue())
ids.add( elt.getId());
-
+
nsToElementIds.put( entry.getKey(), ids );
} // end of "association" loop
-
+
return nsToElementIds;
}
-
-
+
+
/**
- * @param association a map like {@link #bindings} but with {@link ScaXmlElement} IDs instead of {@link ScaXmlElement}s.
- * @return a map equivalent to the argument map but with {@link ScaXmlElement}s instead of {@link ScaXmlElement} IDs.
+ * @param ids the element IDs
+ * @param type the list type
+ * @return a list of elements from the right list and associated to the given name space
*/
- private Map<ScaXmlNamespace, List<ScaXmlElement>> getMappingToElements(
- Map<ScaXmlNamespace, List<Integer>> association, ScaXmlElementType type ) {
-
- // Get the right element list
- Map<ScaXmlNamespace, List<ScaXmlElement>> nsToElements = new HashMap<ScaXmlNamespace, List<ScaXmlElement>> ();
- List<ScaXmlElement> elementList;
+ private List<ScaXmlElement> getMappingToElements( List<Integer> ids, ScaXmlElementType type ) {
+
+ Set<ScaXmlElement> elementSet;
if( type == ScaXmlElementType.bindings )
- elementList = bindings;
+ elementSet = this.bindings;
else if( type == ScaXmlElementType.implementations )
- elementList = implementations;
+ elementSet = this.implementations;
else
- elementList = interfaces;
-
- // Build a mapping of IDs to Elements
- Map<Integer, ScaXmlElement> idsToElements = new HashMap<Integer, ScaXmlElement> ();
- for( ScaXmlElement elt : elementList ) {
- idsToElements.put( elt.getId(), elt );
- }
-
+ elementSet = this.interfaces;
+
// Build the result
- for( Map.Entry<ScaXmlNamespace, List<Integer>> entry : association.entrySet()) {
- List<ScaXmlElement> elements = new ArrayList<ScaXmlElement> ();
- for( Integer eltId : entry.getValue()) {
- ScaXmlElement elt = idsToElements.get( eltId );
- if( elt != null )
+ List<ScaXmlElement> elements = new ArrayList<ScaXmlElement> ();
+ for( Integer id : ids ) {
+ for( ScaXmlElement elt : elementSet ) {
+ if( id == elt.getId())
elements.add( elt );
- } // end of "Integer loop"
-
- nsToElements.put( entry.getKey(), elements );
- } // end of "association" loop
-
- return nsToElements;
+ }
+ }
+
+ return elements;
}
@@ -240,15 +269,16 @@
* @param element the element to remove
*/
public void remove( ScaXmlItem element ) {
- bindings.remove( element );
- implementations.remove( element );
- interfaces.remove( element );
-
- for( List<ScaXmlElement> set : nsToBindings.values())
+
+ this.bindings.remove( element );
+ this.implementations.remove( element );
+ this.interfaces.remove( element );
+
+ for( List<ScaXmlElement> set : this.nsToBindings.values())
set.remove( element );
- for( List<ScaXmlElement> set : nsToImplementations.values())
+ for( List<ScaXmlElement> set : this.nsToImplementations.values())
set.remove( element );
- for( List<ScaXmlElement> set : nsToInterfaces.values())
+ for( List<ScaXmlElement> set : this.nsToInterfaces.values())
set.remove( element );
}
}
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/dialogs/ElementEditionDialog.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/dialogs/ElementEditionDialog.java 2009-08-27 10:38:15 UTC (rev 3303)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/dialogs/ElementEditionDialog.java 2009-08-27 15:13:13 UTC (rev 3304)
@@ -38,11 +38,12 @@
* @author Vincent Zurczak - EBM WebSourcing
*/
public class ElementEditionDialog extends Dialog {
- /** The element created or edited ion this dialog. */
+
+ /** The element created or edited in this dialog. */
private ScaXmlElement newElement;
/** The parent element. */
- private ScaXmlElement parent;
-
+ private final ScaXmlElement parent;
+
/** The SWT text for the element name. */
private Text nameText;
/** The spinner for the minimal value (in XSDs, would be used with referenced elements). */
@@ -54,24 +55,21 @@
/** The label to display error messages. */
private Label errorLabel;
-
-
+
+
/**
* Constructor using a {@link ScaXmlElement}.
*
* @param parentShell the parent shell
- * @param scaElementType the element type (binding, interface, implementation)
+ * @param elementType the element type (binding, interface, implementation)
* @param parent the parent element
*/
public ElementEditionDialog( Shell parentShell, ScaXmlElementType elementType, ScaXmlElement parent ) {
super( parentShell );
this.parent = parent;
- String type = elementType.toString();
- if( type != null && type.endsWith( "s" )) //$NON-NLS-1$
- type = type.substring( 0, type.length() - 1 );
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
@@ -80,114 +78,114 @@
protected Control createDialogArea( Composite parent ) {
Composite container = (Composite) super.createDialogArea( parent );
getShell().setText( NLS.bind( Messages.ElementEditionDialog_1, this.parent.getName()));
-
+
GridLayout layout = new GridLayout( 2, false );
layout.marginHeight = layout.marginWidth = 20;
layout.horizontalSpacing = 20;
container.setLayout( layout );
container.setLayoutData( new GridData( GridData.FILL_BOTH ));
-
-
+
+
// Element name
new Label( container, SWT.NONE ).setText( Messages.ElementEditionDialog_2 );
- nameText = new Text( container, SWT.SINGLE | SWT.BORDER );
- if( newElement != null && newElement.getName() != null )
- nameText.setText( newElement.getName());
+ this.nameText = new Text( container, SWT.SINGLE | SWT.BORDER );
+ if( this.newElement != null && this.newElement.getName() != null )
+ this.nameText.setText( this.newElement.getName());
else
- nameText.setText( Messages.ElementEditionDialog_3 );
-
- nameText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ));
- nameText.addModifyListener( new ModifyListener() {
+ this.nameText.setText( Messages.ElementEditionDialog_3 );
+
+ this.nameText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ));
+ this.nameText.addModifyListener( new ModifyListener() {
public void modifyText( ModifyEvent e ) {
validate();
- }
+ }
});
-
-
+
+
// Element min occurrence
new Label( container, SWT.NONE ).setText( Messages.ElementEditionDialog_4 );
- minSpinner = new Spinner( container, SWT.BORDER );
- minSpinner.setMinimum( 0 );
- if( newElement != null )
- minSpinner.setSelection( newElement.getMinOccurs());
-
+ this.minSpinner = new Spinner( container, SWT.BORDER );
+ this.minSpinner.setMinimum( 0 );
+ if( this.newElement != null )
+ this.minSpinner.setSelection( this.newElement.getMinOccurs());
+
GridData spinnerLayoutData = new GridData();
spinnerLayoutData.widthHint = 60;
- minSpinner.setLayoutData( spinnerLayoutData );
- minSpinner.addSelectionListener( new SelectionAdapter () {
+ this.minSpinner.setLayoutData( spinnerLayoutData );
+ this.minSpinner.addSelectionListener( new SelectionAdapter () {
@Override
public void widgetSelected(SelectionEvent e) {
validate();
}
});
-
-
+
+
// Element max occurrence
new Label( container, SWT.NONE ).setText( Messages.ElementEditionDialog_5 );
Composite buttonContainer = new Composite( container, SWT.NONE );
layout = new GridLayout( 3, false );
layout.marginHeight = layout.marginWidth = 0;
buttonContainer.setLayout( layout );
-
- maxSpinner = new Spinner( buttonContainer, SWT.BORDER );
- maxSpinner.setMinimum( 1 );
-
- if( newElement != null )
- maxSpinner.setSelection( newElement.getMaxOccurs());
+
+ this.maxSpinner = new Spinner( buttonContainer, SWT.BORDER );
+ this.maxSpinner.setMinimum( 1 );
+
+ if( this.newElement != null )
+ this.maxSpinner.setSelection( this.newElement.getMaxOccurs());
else
- maxSpinner.setSelection( 1 );
-
+ this.maxSpinner.setSelection( 1 );
+
spinnerLayoutData = new GridData();
spinnerLayoutData.widthHint = 60;
- maxSpinner.setLayoutData( spinnerLayoutData );
- maxSpinner.addSelectionListener( new SelectionAdapter () {
+ this.maxSpinner.setLayoutData( spinnerLayoutData );
+ this.maxSpinner.addSelectionListener( new SelectionAdapter () {
@Override
public void widgetSelected(SelectionEvent e) {
validate();
}
});
-
-
- // Unbounded.
- unboundedButton = new Button( buttonContainer, SWT.CHECK );
+
+
+ // Unbounded.
+ this.unboundedButton = new Button( buttonContainer, SWT.CHECK );
GridData layoutData = new GridData();
layoutData.horizontalIndent = 10;
layoutData.verticalIndent = 2;
- unboundedButton.setLayoutData( layoutData );
-
+ this.unboundedButton.setLayoutData( layoutData );
+
new Label( buttonContainer, SWT.NONE ).setText( Messages.ElementEditionDialog_6 );
- if( newElement != null ) {
- unboundedButton.setSelection( newElement.isUnbounded());
- if( newElement.isUnbounded())
- maxSpinner.setEnabled( false );
+ if( this.newElement != null ) {
+ this.unboundedButton.setSelection( this.newElement.isUnbounded());
+ if( this.newElement.isUnbounded())
+ this.maxSpinner.setEnabled( false );
}
-
- unboundedButton.addSelectionListener( new SelectionAdapter() {
+
+ this.unboundedButton.addSelectionListener( new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- if( unboundedButton.getSelection())
- maxSpinner.setEnabled( false );
+ if( ElementEditionDialog.this.unboundedButton.getSelection())
+ ElementEditionDialog.this.maxSpinner.setEnabled( false );
else
- maxSpinner.setEnabled( true );
+ ElementEditionDialog.this.maxSpinner.setEnabled( true );
}
});
-
-
- // Error label
+
+
+ // Error label
layoutData = new GridData();
layoutData.horizontalSpan = 2;
layoutData.verticalIndent = 10;
- errorLabel = new Label( container, SWT.NONE );
- errorLabel.setLayoutData( layoutData );
-
-
+ this.errorLabel = new Label( container, SWT.NONE );
+ this.errorLabel.setLayoutData( layoutData );
+
+
// Focus.
- nameText.setFocus();
- nameText.setSelection( nameText.getText().length());
+ this.nameText.setFocus();
+ this.nameText.setSelection( this.nameText.getText().length());
return container;
}
-
-
+
+
/*
* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#getInitialSize()
@@ -196,43 +194,43 @@
protected Point getInitialSize () {
return new Point( 400, 200 );
}
-
-
+
+
/*
* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
*/
@Override
- protected void okPressed() {
- if( newElement != null )
- newElement.setName( nameText.getText());
+ protected void okPressed() {
+ if( this.newElement != null )
+ this.newElement.setName( this.nameText.getText());
else
- newElement = new ScaXmlElement( nameText.getText(), parent );
-
- newElement.setMinOccurs( minSpinner.getSelection());
- newElement.setMaxOccurs( maxSpinner.getSelection());
- newElement.setUnbounded( unboundedButton.getSelection());
-
+ this.newElement = new ScaXmlElement( this.nameText.getText(), this.parent );
+
+ this.newElement.setMinOccurs( this.minSpinner.getSelection());
+ this.newElement.setMaxOccurs( this.maxSpinner.getSelection());
+ this.newElement.setUnbounded( this.unboundedButton.getSelection());
+
super.okPressed();
}
-
+
/**
* @return the newElement
*/
public ScaXmlElement getNewElement() {
- return newElement;
+ return this.newElement;
}
-
+
/**
* @param newElement the newElement to set
*/
public void setNewElement( ScaXmlElement newElement ) {
this.newElement = newElement;
}
-
-
+
+
/*
* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
@@ -242,35 +240,35 @@
super.createButtonsForButtonBar(parent);
getButton( IDialogConstants.OK_ID ).setEnabled( false );
}
-
-
+
+
/**
* Validate the dialog fields.
*/
public void validate() {
// Validate name.
- String name = nameText.getText();
- if( name.length() == 0
+ String name = this.nameText.getText();
+ if( name.length() == 0
|| !Character.isJavaIdentifierStart( name.charAt( 0 ))) {
updateStatus( Messages.ElementEditionDialog_7 );
return;
}
-
- for( ScaXmlElement elt : parent.children ) {
- if( elt.getName().equals( name ) &&
- ( newElement == null || elt.getId() != newElement.getId())) {
+
+ for( ScaXmlElement elt : this.parent.children ) {
+ if( elt.getName().equals( name ) &&
+ ( this.newElement == null || elt.getId() != this.newElement.getId())) {
updateStatus( Messages.ElementEditionDialog_8 );
return;
}
}
-
- for( ScaXmlElement elt = parent; elt != null; elt = elt.getParent()) {
+
+ for( ScaXmlElement elt = this.parent; elt != null; elt = elt.getParent()) {
if( elt.getName().equals( name )) {
updateStatus( Messages.ElementEditionDialog_9 );
return;
}
}
-
+
if( name.equalsIgnoreCase( "service" ) //$NON-NLS-1$
|| name.equals( "reference" ) //$NON-NLS-1$
|| name.equals( "component" ) //$NON-NLS-1$
@@ -278,32 +276,32 @@
updateStatus( NLS.bind( Messages.ElementEditionDialog_14, name ));
return;
}
-
+
// Validate min and max values.
- int minValue = minSpinner.getSelection();
- int maxValue = maxSpinner.getSelection();
+ int minValue = this.minSpinner.getSelection();
+ int maxValue = this.maxSpinner.getSelection();
if( minValue > maxValue ) {
updateStatus( Messages.ElementEditionDialog_16 );
return;
}
-
+
updateStatus( null );
}
-
-
+
+
/**
* Update the status of the dialog (error message displayed and OK button enabled or disabled).
* @param msg the message to display in the dialog, null for no message
*/
public void updateStatus( String msg ) {
if( msg != null ) {
- errorLabel.setText( msg );
- errorLabel.getParent().layout();
+ this.errorLabel.setText( msg );
+ this.errorLabel.getParent().layout();
getButton( IDialogConstants.OK_ID ).setEnabled( false );
}
else {
- errorLabel.setText( "" ); //$NON-NLS-1$
- errorLabel.getParent().layout();
+ this.errorLabel.setText( "" ); //$NON-NLS-1$
+ this.errorLabel.getParent().layout();
getButton( IDialogConstants.OK_ID ).setEnabled( true );
}
}
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/dialogs/RootElementEditionDialog.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/dialogs/RootElementEditionDialog.java 2009-08-27 10:38:15 UTC (rev 3303)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/dialogs/RootElementEditionDialog.java 2009-08-27 15:13:13 UTC (rev 3304)
@@ -45,12 +45,12 @@
*/
public class RootElementEditionDialog extends Dialog {
/** The element created or edited ion this dialog. */
- private ScaXmlElement newElement;
+ private ScaXmlElement newElement;
/** The platform which owns this element. */
- private ScaXmlPlatform platform;
+ private final ScaXmlPlatform platform;
/** The element prefix (which can be "binding.", "implementation.", or "interface."). */
private String prefix;
-
+
/** The SWT text for the element name. */
private Text nameText;
/** The table for the platform name spaces. */
@@ -60,13 +60,13 @@
/** The name space association map for the current element type (binding, implementation or interface). */
private Map<ScaXmlNamespace, List<ScaXmlElement>> map;
-
-
+
+
/**
* Constructor using a {@link ScaXmlPlatform}.
*
* @param parentShell the parent shell
- * @param scaElementType the element type (binding, interface, implementation)
+ * @param elementType the element type (binding, interface, implementation)
* @param platform the platform
*/
public RootElementEditionDialog( Shell parentShell, ScaXmlElementType elementType, ScaXmlPlatform platform ) {
@@ -74,74 +74,74 @@
this.setShellStyle( getShellStyle() | SWT.RESIZE );
this.platform = platform;
this.prefix = elementType.toString();
- this.prefix = prefix.substring( 0, prefix.length() - 1 );
-
+ this.prefix = this.prefix.substring( 0, this.prefix.length() - 1 );
+
if( elementType == ScaXmlElementType.bindings )
- map = platform.nsToBindings;
+ this.map = platform.nsToBindings;
else if( elementType == ScaXmlElementType.implementations )
- map = platform.nsToImplementations;
+ this.map = platform.nsToImplementations;
else
- map = platform.nsToInterfaces;
+ this.map = platform.nsToInterfaces;
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea( Composite parent ) {
- Composite container = (Composite) super.createDialogArea( parent );
- String type = prefix.toUpperCase().charAt( 0 ) + prefix.toLowerCase().substring( 1 );
- getShell().setText( NLS.bind( Messages.RootElementEditionDialog_0, new Object[] { platform.getName(), type }));
-
+ Composite container = (Composite) super.createDialogArea( parent );
+ String type = this.prefix.toUpperCase().charAt( 0 ) + this.prefix.toLowerCase().substring( 1 );
+ getShell().setText( NLS.bind( Messages.RootElementEditionDialog_0, new Object[] { this.platform.getName(), type }));
+
GridLayout layout = new GridLayout ();
layout.marginHeight = layout.marginWidth = 20;
layout.horizontalSpacing = 20;
container.setLayout( layout );
- container.setLayoutData( new GridData( GridData.FILL_BOTH ));
-
-
+ container.setLayoutData( new GridData( GridData.FILL_BOTH ));
+
+
// Element name
new Label( container, SWT.NONE ).setText( Messages.RootElementEditionDialog_2 );
- nameText = new Text( container, SWT.SINGLE | SWT.BORDER );
- if( newElement != null && newElement.getName() != null )
- nameText.setText( newElement.getName());
+ this.nameText = new Text( container, SWT.SINGLE | SWT.BORDER );
+ if( this.newElement != null && this.newElement.getName() != null )
+ this.nameText.setText( this.newElement.getName());
else
- nameText.setText( NLS.bind( Messages.RootElementEditionDialog_3, prefix ));
-
- nameText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ));
- nameText.addModifyListener( new ModifyListener() {
+ this.nameText.setText( NLS.bind( Messages.RootElementEditionDialog_3, this.prefix ));
+
+ this.nameText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ));
+ this.nameText.addModifyListener( new ModifyListener() {
public void modifyText( ModifyEvent e ) {
validate();
- }
- });
-
-
+ }
+ });
+
+
// Name spaces
Label l = new Label( container, SWT.NONE );
l.setText( Messages.RootElementEditionDialog_4 );
GridData layoutData = new GridData( GridData.VERTICAL_ALIGN_BEGINNING );
layoutData.verticalIndent = 10;
l.setLayoutData( layoutData );
-
- namespacesTable = new Table( container,
+
+ this.namespacesTable = new Table( container,
SWT.CHECK | SWT.FULL_SELECTION | SWT.HIDE_SELECTION | SWT.BORDER );
layoutData = new GridData( GridData.FILL_BOTH );
layoutData.heightHint = 50;
- namespacesTable.setLayoutData( layoutData );
- namespacesTable.setHeaderVisible( false );
-
- for( ScaXmlNamespace ns : platform.namespaces ) {
- TableItem item = new TableItem( namespacesTable, SWT.NONE );
+ this.namespacesTable.setLayoutData( layoutData );
+ this.namespacesTable.setHeaderVisible( false );
+
+ for( ScaXmlNamespace ns : this.platform.namespaces ) {
+ TableItem item = new TableItem( this.namespacesTable, SWT.NONE );
item.setText( ns.getName());
item.setData( ns );
-
- if( newElement != null && map.get( ns ) != null && map.get( ns ).contains( newElement ))
+
+ if( this.newElement != null && this.map.get( ns ) != null && this.map.get( ns ).contains( this.newElement ))
item.setChecked( true );
}
-
- namespacesTable.addSelectionListener( new SelectionAdapter () {
+
+ this.namespacesTable.addSelectionListener( new SelectionAdapter () {
/* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@@ -150,93 +150,93 @@
validate();
}
});
-
- // Error label
+
+ // Error label
layoutData = new GridData();
layoutData.verticalIndent = 10;
- errorLabel = new Label( container, SWT.NONE );
- errorLabel.setLayoutData( layoutData );
-
-
+ this.errorLabel = new Label( container, SWT.NONE );
+ this.errorLabel.setLayoutData( layoutData );
+
+
// Focus.
- nameText.setFocus();
- nameText.setSelection( nameText.getText().length());
+ this.nameText.setFocus();
+ this.nameText.setSelection( this.nameText.getText().length());
return container;
}
-
-
+
+
/**
- * Create or update the element and its associations when the OK button is selected.
+ * Create or update the element and its associations when the OK button is selected.
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
*/
@Override
protected void okPressed() {
// Update name
- if( newElement != null )
- newElement.setName( getElementName());
+ if( this.newElement != null )
+ this.newElement.setName( getElementName());
else {
- newElement = new ScaXmlElement( getElementName(), platform );
- if( map == platform.nsToBindings )
- platform.bindings.add( newElement );
- else if( map == platform.nsToImplementations )
- platform.implementations.add( newElement );
+ this.newElement = new ScaXmlElement( getElementName(), this.platform );
+ if( this.map == this.platform.nsToBindings )
+ this.platform.bindings.add( this.newElement );
+ else if( this.map == this.platform.nsToImplementations )
+ this.platform.implementations.add( this.newElement );
else
- platform.interfaces.add( newElement );
+ this.platform.interfaces.add( this.newElement );
}
-
+
// Update name space associations
- for( List<ScaXmlElement> set : map.values())
- set.remove( newElement );
-
- List<TableItem> checkedItems = new ArrayList<TableItem> ();
- for( TableItem item : namespacesTable.getItems()) {
+ for( List<ScaXmlElement> set : this.map.values())
+ set.remove( this.newElement );
+
+ List<TableItem> checkedItems = new ArrayList<TableItem> ();
+ for( TableItem item : this.namespacesTable.getItems()) {
if( item.getChecked())
checkedItems.add( item );
}
-
+
for( TableItem item : checkedItems ) {
ScaXmlNamespace ns = (ScaXmlNamespace) item.getData();
- List<ScaXmlElement> elements = map.get( ns );
- if( elements != null )
- elements.add( newElement );
+ List<ScaXmlElement> elements = this.map.get( ns );
+ if( elements != null )
+ elements.add( this.newElement );
else {
elements = new ArrayList<ScaXmlElement> ();
- elements.add( newElement );
- }
- map.put( ns, elements );
- }
-
+ elements.add( this.newElement );
+ }
+ this.map.put( ns, elements );
+ }
+
super.okPressed();
}
-
-
+
+
/**
* @return the full element name (starts with "binding.", "implementation." or "interface.").
* <p>If the given element name does not start with these prefixes, the right one is automatically inserted.</p>
*/
private String getElementName() {
- if( !nameText.getText().startsWith( prefix + "." )) //$NON-NLS-1$
- return prefix + "." + nameText.getText(); //$NON-NLS-1$
- return nameText.getText();
+ if( !this.nameText.getText().startsWith( this.prefix + "." )) //$NON-NLS-1$
+ return this.prefix + "." + this.nameText.getText(); //$NON-NLS-1$
+ return this.nameText.getText();
}
-
+
/**
* @return the newElement
*/
public ScaXmlElement getNewElement() {
- return newElement;
+ return this.newElement;
}
-
+
/**
* @param newElement the newElement to set
*/
public void setNewElement( ScaXmlElement newElement ) {
this.newElement = newElement;
}
-
-
+
+
/*
* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
@@ -246,8 +246,8 @@
super.createButtonsForButtonBar(parent);
getButton( IDialogConstants.OK_ID ).setEnabled( false );
}
-
-
+
+
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#getInitialSize()
*/
@@ -255,67 +255,67 @@
protected Point getInitialSize() {
return new Point( 400, 300 );
}
-
-
+
+
/**
* Validate the dialog fields.
*/
public void validate() {
// Validate name.
- String name = nameText.getText();
- if( name.length() == 0
+ String name = this.nameText.getText();
+ if( name.length() == 0
|| !Character.isJavaIdentifierStart( name.charAt( 0 ))) {
updateStatus( Messages.RootElementEditionDialog_7 );
return;
}
-
+
// Validate name spaces
- List<TableItem> checkedItems = new ArrayList<TableItem> ();
- for( TableItem item : namespacesTable.getItems()) {
+ List<TableItem> checkedItems = new ArrayList<TableItem> ();
+ for( TableItem item : this.namespacesTable.getItems()) {
if( item.getChecked())
checkedItems.add( item );
}
-
+
if( checkedItems.size() == 0 ) {
updateStatus( Messages.RootElementEditionDialog_8 );
return;
}
-
+
for( TableItem item : checkedItems ) {
ScaXmlNamespace ns = (ScaXmlNamespace) item.getData();
- List<ScaXmlElement> elements = map.get( ns );
+ List<ScaXmlElement> elements = this.map.get( ns );
if( elements == null )
continue;
-
+
name = getElementName();
for( ScaXmlElement elt : elements ) {
- if( elt.getName().equals( name ) &&
- ( newElement == null || elt.getId() != newElement.getId())) {
-
- updateStatus( NLS.bind(
+ if( elt.getName().equals( name ) &&
+ ( this.newElement == null || elt.getId() != this.newElement.getId())) {
+
+ updateStatus( NLS.bind(
Messages.RootElementEditionDialog_9,
new Object[] { elt.getName(), ns.getName() } ));
return;
}
}
- }
+ }
updateStatus( null );
}
-
-
+
+
/**
* Update the status of the dialog (error message displayed and OK button enabled or disabled).
* @param msg the message to display in the dialog, null for no message
*/
public void updateStatus( String msg ) {
if( msg != null ) {
- errorLabel.setText( msg );
- errorLabel.getParent().layout();
+ this.errorLabel.setText( msg );
+ this.errorLabel.getParent().layout();
getButton( IDialogConstants.OK_ID ).setEnabled( false );
}
else {
- errorLabel.setText( "" ); //$NON-NLS-1$
- errorLabel.getParent().layout();
+ this.errorLabel.setText( "" ); //$NON-NLS-1$
+ this.errorLabel.getParent().layout();
getButton( IDialogConstants.OK_ID ).setEnabled( true );
}
}
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/viewers/PlatformAndNsContentProvider.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/viewers/PlatformAndNsContentProvider.java 2009-08-27 10:38:15 UTC (rev 3303)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/viewers/PlatformAndNsContentProvider.java 2009-08-27 15:13:13 UTC (rev 3304)
@@ -15,8 +15,8 @@
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.stp.sca.xmleditor.preferences.beans.ScaXmlNamespace;
import org.eclipse.stp.sca.xmleditor.preferences.beans.ScaXmlPlatform;
-import org.eclipse.stp.sca.xmleditor.preferences.beans.ScaXmlNamespace;
/**
* The content provider used in the "platform" tab (the one with the name spaces).
@@ -30,7 +30,7 @@
public Object[] getChildren( Object object ) {
if( object != null && object instanceof ScaXmlPlatform )
return ((ScaXmlPlatform) object).namespaces.toArray();
-
+
return new Object[ 0 ];
}
@@ -40,17 +40,17 @@
public Object getParent( Object object ) {
if( object != null && object instanceof ScaXmlNamespace )
return ((ScaXmlNamespace) object).getPlatform();
-
+
return null;
}
-
+
/*
* @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
*/
public boolean hasChildren( Object object ) {
if( object != null && object instanceof ScaXmlPlatform )
return true;
-
+
return false;
}
@@ -58,9 +58,9 @@
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
*/
public Object[] getElements( Object object ) {
- if( object instanceof List )
+ if( object instanceof List<?> )
return ((List<?>) object).toArray();
-
+
return new Object[ 0 ];
}
@@ -68,7 +68,7 @@
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
public void dispose() {}
-
+
/*
* @see org.eclipse.jface.viewers.IContentProvider
* #inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/viewers/ScaXmlContentProvider.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/viewers/ScaXmlContentProvider.java 2009-08-27 10:38:15 UTC (rev 3303)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/viewers/ScaXmlContentProvider.java 2009-08-27 15:13:13 UTC (rev 3304)
@@ -27,20 +27,20 @@
* @author Vincent Zurczak - EBM WebSourcing
*/
public class ScaXmlContentProvider implements ITreeContentProvider {
-
- /**
+
+ /**
* The kind of SCA element managed by the content provider.
- * It can be bindings, implementations and interfaces.
+ * It can be bindings, implementations and interfaces.
*/
- private ScaXmlElementType elementType;
-
-
+ private final ScaXmlElementType elementType;
+
+
/**
* @param elementType the kind of SCA element managed by the content provider
*/
public ScaXmlContentProvider( ScaXmlElementType elementType ) {
this.elementType = elementType;
- }
+ }
/*
* (non-Javadoc)
@@ -53,12 +53,12 @@
children.addAll(((ScaXmlElement) object).children );
return children.toArray();
}
-
+
if( object instanceof ScaXmlPlatform ) {
- switch( elementType ) {
- case bindings: return ((ScaXmlPlatform) object).bindings.toArray();
- case implementations: return ((ScaXmlPlatform) object).implementations.toArray();
- case interfaces: return ((ScaXmlPlatform) object).interfaces.toArray();
+ switch( this.elementType ) {
+ case bindings: return ((ScaXmlPlatform) object).bindings.toArray();
+ case implementations: return ((ScaXmlPlatform) object).implementations.toArray();
+ case interfaces: return ((ScaXmlPlatform) object).interfaces.toArray();
}
}
@@ -74,10 +74,10 @@
ScaXmlElement elt = (ScaXmlElement) object;
return elt.getParent() == null ? elt.getPlatform() : elt.getParent();
}
-
+
if( object instanceof ScaXmlAttribute )
return ((ScaXmlAttribute) object).getElement();
-
+
return null;
}
@@ -85,20 +85,20 @@
* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
*/
- public boolean hasChildren( Object object ) {
- if( object instanceof ScaXmlElement )
- return ((ScaXmlElement) object).attributes.size() > 0
- || ((ScaXmlElement) object).children.size() > 0;
-
- if( object instanceof ScaXmlPlatform ) {
- switch( elementType ) {
- case bindings: return ((ScaXmlPlatform) object).bindings.size() > 0;
- case implementations: return ((ScaXmlPlatform) object).implementations.size() > 0;
- case interfaces: return ((ScaXmlPlatform) object).interfaces.size() > 0;
+ public boolean hasChildren( Object object ) {
+ if( object instanceof ScaXmlElement )
+ return ((ScaXmlElement) object).attributes.size() > 0
+ || ((ScaXmlElement) object).children.size() > 0;
+
+ if( object instanceof ScaXmlPlatform ) {
+ switch( this.elementType ) {
+ case bindings: return ((ScaXmlPlatform) object).bindings.size() > 0;
+ case implementations: return ((ScaXmlPlatform) object).implementations.size() > 0;
+ case interfaces: return ((ScaXmlPlatform) object).interfaces.size() > 0;
+ }
}
- }
-
- return false;
+
+ return false;
}
/*
@@ -106,31 +106,31 @@
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
*/
public Object[] getElements( Object object ) {
-
+
// Only add platforms with "children" ? No...
- if( object instanceof List ) {
-// List<Object> result = new ArrayList<Object> ();
-// for( Object o :(List<?>) object ) {
-//
-// if( o != null && o instanceof ScaXmlPlatform ) {
-// List<ScaXmlElement> elements;
-// if( elementType == ScaXmlElementType.bindings )
-// elements = ((ScaXmlPlatform) o).bindings;
-// else if( elementType == ScaXmlElementType.implementations )
-// elements = ((ScaXmlPlatform) o).implementations;
-// else
-// elements = ((ScaXmlPlatform) o).interfaces;
-//
-// if( elements.size() > 0 )
-// result.add( o );
-// }
-// } // end of "for" loop
-//
-// return result.toArray();
-
+ if( object instanceof List<?> ) {
+ // List<Object> result = new ArrayList<Object> ();
+ // for( Object o :(List<?>) object ) {
+ //
+ // if( o != null && o instanceof ScaXmlPlatform ) {
+ // List<ScaXmlElement> elements;
+ // if( elementType == ScaXmlElementType.bindings )
+ // elements = ((ScaXmlPlatform) o).bindings;
+ // else if( elementType == ScaXmlElementType.implementations )
+ // elements = ((ScaXmlPlatform) o).implementations;
+ // else
+ // elements = ((ScaXmlPlatform) o).interfaces;
+ //
+ // if( elements.size() > 0 )
+ // result.add( o );
+ // }
+ // } // end of "for" loop
+ //
+ // return result.toArray();
+
return ((List<?>) object).toArray();
}
-
+
return new Object[ 0 ];
}
@@ -145,5 +145,5 @@
* @see org.eclipse.jface.viewers.IContentProvider
* #inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
- public void inputChanged(Viewer arg0, Object arg1, Object arg2) {}
+ public void inputChanged(Viewer arg0, Object arg1, Object arg2) {}
}
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/viewers/ScaXmlLabelProvider.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/viewers/ScaXmlLabelProvider.java 2009-08-27 10:38:15 UTC (rev 3303)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/viewers/ScaXmlLabelProvider.java 2009-08-27 15:13:13 UTC (rev 3304)
@@ -16,9 +16,9 @@
import org.eclipse.stp.sca.xmleditor.ImageRegistry;
import org.eclipse.stp.sca.xmleditor.preferences.beans.ScaXmlAttribute;
import org.eclipse.stp.sca.xmleditor.preferences.beans.ScaXmlElement;
+import org.eclipse.stp.sca.xmleditor.preferences.beans.ScaXmlNamespace;
import org.eclipse.stp.sca.xmleditor.preferences.beans.ScaXmlPlatform;
import org.eclipse.stp.sca.xmleditor.preferences.beans.ScaXmlAttribute.ScaXmlAttributeProperty;
-import org.eclipse.stp.sca.xmleditor.preferences.beans.ScaXmlNamespace;
import org.eclipse.swt.graphics.Image;
/**
@@ -26,7 +26,7 @@
* @author Vincent Zurczak - EBM WebSourcing
*/
public class ScaXmlLabelProvider extends LabelProvider implements ITableLabelProvider {
-
+
/*
* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
@@ -72,12 +72,11 @@
if( element.getPlatform() == null )
return element.getMinOccurs() + "-" //$NON-NLS-1$
+ (element.isUnbounded() ? "*" : element.getMaxOccurs()); //$NON-NLS-1$
- else
- return ""; //$NON-NLS-1$
+ return ""; //$NON-NLS-1$
default: break;
}
}
-
+
// Attribute
else if( object instanceof ScaXmlAttribute ) {
ScaXmlAttribute attribute = (ScaXmlAttribute) object;
@@ -89,19 +88,19 @@
String result = attribute.getUse().toString();
if( attribute.getUse() == ScaXmlAttributeProperty.fixed )
result += "=" + attribute.getFixedValue(); //$NON-NLS-1$
- return result;
+ return result;
default: break;
}
}
-
+
// Platform
else if( index == 0 && object instanceof ScaXmlPlatform )
return ((ScaXmlPlatform) object).getName();
-
+
// Name space
else if( index == 0 && object instanceof ScaXmlNamespace )
return ((ScaXmlNamespace) object).getName();
return ""; //$NON-NLS-1$
- }
+ }
}
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/viewers/ScaXmlViewerFilter.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/viewers/ScaXmlViewerFilter.java 2009-08-27 10:38:15 UTC (rev 3303)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/viewers/ScaXmlViewerFilter.java 2009-08-27 15:13:13 UTC (rev 3304)
@@ -28,71 +28,71 @@
*/
public class ScaXmlViewerFilter extends ViewerFilter {
private String namespaceFilter;
- private ScaXmlElementType elementType;
+ private final ScaXmlElementType elementType;
-
+
/**
* Simple constructor.
* <p>If the argument name space is null, it is replaced by the empty string.</p>
*
- * @param ScaXmlViewerFilter
+ * @param namespaceFilter
* @param elementType
*/
- public ScaXmlViewerFilter( String ScaXmlViewerFilter, ScaXmlElementType elementType ) {
+ public ScaXmlViewerFilter( String namespaceFilter, ScaXmlElementType elementType ) {
this.namespaceFilter = namespaceFilter == null ? "" : namespaceFilter; //$NON-NLS-1$
this.elementType = elementType;
}
-
-
+
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerFilter
* #select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
@Override
public boolean select( Viewer viewer, Object parentElement, Object element ) {
-
+
// Platform : visible only if it has the name space
// or a name space having the name space filter as prefix.
if( element instanceof ScaXmlPlatform ) {
ScaXmlPlatform platform = (ScaXmlPlatform) element;
-
- if( namespaceFilter.length() == 0
+
+ if( this.namespaceFilter.length() == 0
&& platform.namespaces.size() == 0 )
return true;
-
+
for( ScaXmlNamespace ns : platform.namespaces ) {
- if( ns.getName().startsWith( namespaceFilter ))
+ if( ns.getName().startsWith( this.namespaceFilter ))
return true;
}
}
-
+
// Element : visible only if its root element is associated
- // with a name space having the name space filter as prefix.
+ // with a name space having the name space filter as prefix.
else if( element instanceof ScaXmlElement ) {
- ScaXmlElement elt = (ScaXmlElement) element;
+ ScaXmlElement elt = (ScaXmlElement) element;
if( elt.getPlatform() == null )
return true;
-
+
ScaXmlPlatform platform = elt.getPlatform();
Map<ScaXmlNamespace, List<ScaXmlElement>> elements;
-
- if( elementType == ScaXmlElementType.bindings )
+
+ if( this.elementType == ScaXmlElementType.bindings )
elements = platform.nsToBindings;
- else if( elementType == ScaXmlElementType.implementations )
+ else if( this.elementType == ScaXmlElementType.implementations )
elements = platform.nsToImplementations;
else
elements = platform.nsToInterfaces;
-
+
for( Map.Entry<ScaXmlNamespace, List<ScaXmlElement>> entry : elements.entrySet()) {
- if( entry.getKey().getName().startsWith( namespaceFilter )
+ if( entry.getKey().getName().startsWith( this.namespaceFilter )
&& entry.getValue().contains( element ))
return true;
}
}
-
+
else if( element instanceof ScaXmlAttribute )
return true;
-
+
return false;
}
@@ -101,7 +101,7 @@
* @return the namespaceFilter
*/
public String getNamespaceFilter() {
- return namespaceFilter;
+ return this.namespaceFilter;
}
@@ -111,5 +111,5 @@
*/
public void setNamespaceFilter( String namespaceFilter ) {
this.namespaceFilter = namespaceFilter == null ? "" : namespaceFilter; //$NON-NLS-1$
- }
+ }
}
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/viewers/ScaXmlViewerSorter.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/viewers/ScaXmlViewerSorter.java 2009-08-27 10:38:15 UTC (rev 3303)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/preferences/viewers/ScaXmlViewerSorter.java 2009-08-27 15:13:13 UTC (rev 3304)
@@ -78,21 +78,21 @@
*/
@Override
public int category(Object element) {
- if( element == null )
- return super.category( element );
- if( element instanceof ScaXmlPlatform )
- return 5;
+ if( element != null ) {
+ if( element instanceof ScaXmlPlatform )
+ return 5;
+
+ if( element instanceof ScaXmlNamespace )
+ return 4;
+
+ if( element instanceof ScaXmlElement )
+ return 3;
+
+ if( element instanceof ScaXmlAttribute )
+ return 2;
+ }
- if( element instanceof ScaXmlNamespace )
- return 4;
-
- if( element instanceof ScaXmlElement )
- return 3;
-
- if( element instanceof ScaXmlAttribute )
- return 2;
-
return super.category( element );
}
}
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/utils/IncludesUtils.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/utils/IncludesUtils.java 2009-08-27 10:38:15 UTC (rev 3303)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/utils/IncludesUtils.java 2009-08-27 15:13:13 UTC (rev 3304)
@@ -36,42 +36,42 @@
*
* Inclusions are searched in the argument given in the {@link #createIncludesUtils(IProject)}
* and in the projects this project argument references.
- *
+ *
* @author Vincent Zurczak - EBM WebSourcing
*/
@SuppressWarnings( "restriction" )
public class IncludesUtils {
-
+
/** The XML parser. */
private static SAXBuilder builder = new SAXBuilder();
-
+
/** The XML out-putter to transform JDOM documents into org.w3c.dom.documents. */
- private static DOMOutputter format = new DOMOutputter();
-
+ private static DOMOutputter format = new DOMOutputter();
+
/** The project given in the constructor and the projects it references. */
- private List<IProject> projects = new ArrayList<IProject> ();
-
+ private final List<IProject> projects = new ArrayList<IProject> ();
+
/**
* Protected constructor.
- * Add the current project and all the SCA projects it references to the
+ * Add the current project and all the SCA projects it references to the
* list of projects to search for inclusions.
*
- * @param project
+ * @param project
*/
protected IncludesUtils( IProject project ) {
- projects.add( project );
-
+ this.projects.add( project );
+
try {
// FIXME: keep only the projects with the SCA nature ?
for( IProject ref : project.getReferencedProjects()) {
- projects.add( ref );
+ this.projects.add( ref );
}
} catch( CoreException e ) {
e.printStackTrace();
}
}
-
+
/**
* Create an instance of IncludesUtils if the argument is valid.
* @param project
@@ -80,10 +80,10 @@
public static IncludesUtils createIncludesUtils( IProject project ) {
if( project != null )
return new IncludesUtils( project );
-
+
return null;
}
-
+
/**
* Get the QName of a composite file.
* @param file
@@ -91,41 +91,41 @@
*/
public QName getQName( IFile file ) {
Document document = getDOM( file );
-
+
try {
- Node compositeNode = ScaUtils.getScaTopNode( document );
+ Node compositeNode = ScaUtils.getScaTopNode( document );
String compositeName = ScaUtils.getAttributeValue( compositeNode, "name" ); //$NON-NLS-1$
String namespaceUri = ScaUtils.getAttributeValue( compositeNode, "targetNamespace" ); //$NON-NLS-1$
-
+
if( "".equals( namespaceUri )) //$NON-NLS-1$
return null;
return new QName( namespaceUri, compositeName );
} catch( Exception e ) {
//e.printStackTrace();
}
-
+
return null;
}
-
+
/**
- * Get QNames of composite files.
+ * Get QNames of composite files.
* @param files
* @return a list of QNames for the valid composite files given in argument.
*/
public List<QName> getQNames( IFile[] files ) {
List<QName> result = new ArrayList<QName> ();
-
+
for( IFile file : files ) {
QName qName = getQName( file );
if( qName != null )
result.add( qName );
}
-
+
return result;
}
-
+
/**
- * Get QNames of composite files.
+ * Get QNames of composite files.
* @param files
* @return a list of QNames for the valid composite files given in argument.
*/
@@ -133,7 +133,7 @@
IFile[] iFiles = new IFile[ files.size() ];
return getQNames( files.toArray( iFiles ));
}
-
+
/**
* Get QNames for all the files in the projects.
* Files are filtered to avoid binary folders (e.g. as in Java projects).
@@ -142,34 +142,34 @@
*/
public List<QName> getQNames () {
List<IFile> iFiles = new ArrayList<IFile> ();
-
- for( IProject project : projects ) {
+
+ for( IProject project : this.projects ) {
List<IFile> pIFiles = ResourceUtils.getFiles( project, "composite" ); //$NON-NLS-1$
pIFiles = ScaResourceFiltersEPManager.getInstance().filterAllowedFiles( pIFiles );
iFiles.addAll( pIFiles );
}
return getQNames( iFiles );
}
-
+
/**
* Get the associated file for a given QName.
* @param qName
* @return the associated IFile or null if none was found.
*/
public IFile getIFile( QName qName ) {
-
- // Get every IFile in the projects, and for each of them,
+
+ // Get every IFile in the projects, and for each of them,
// check in the document if they have the right QName.
List<IFile> files = new ArrayList<IFile> ();
-
- for( IProject project : projects ) {
+
+ for( IProject project : this.projects ) {
List<IFile> pIFiles = ResourceUtils.getFiles( project, "composite" ); //$NON-NLS-1$
pIFiles = ScaResourceFiltersEPManager.getInstance().filterAllowedFiles( pIFiles );
files.addAll( pIFiles );
}
-
+
for( IFile file : files ) {
- QName fileQName = getQName( file );
+ QName fileQName = getQName( file );
try {
if( fileQName != null
&& qName.equals( fileQName ))
@@ -178,10 +178,10 @@
e.printStackTrace();
}
}
-
+
return null;
}
-
+
/**
* Get the associated files for a given list of QNames.
* @param qNames
@@ -189,16 +189,16 @@
*/
public List<IFile> getIFiles( QName[] qNames ) {
List<IFile> result = new ArrayList<IFile> ();
-
+
for( QName name : qNames ) {
IFile file = getIFile( name );
if( file != null )
result.add( file );
}
-
+
return result;
}
-
+
/**
* Get the associated files for a given list of QNames.
* @param qNames
@@ -208,44 +208,44 @@
QName[] names = new QName[ qNames.size() ];
return getIFiles( qNames.toArray( names ));
}
-
+
/**
* Get all the composite files from the projects.
* Files are filtered to avoid binary folders (e.g. as in Java projects).
*
- * @return
+ * @return all the composite files from the projects.
*/
public List<IFile> getIFiles() {
List<IFile> iFiles = new ArrayList<IFile> ();
-
- for( IProject project : projects ) {
+
+ for( IProject project : this.projects ) {
List<IFile> pIFiles = ResourceUtils.getFiles( project, "composite" ); //$NON-NLS-1$
pIFiles = ScaResourceFiltersEPManager.getInstance().filterAllowedFiles( pIFiles );
iFiles.addAll( pIFiles );
}
-
+
return iFiles;
}
-
+
/**
* Get the DOM document of an IFile.
* @param file
- * @return the document if the file is a valid XML file.
+ * @return the document if the file is a valid XML file.
*/
public Document getDOM( IFile file ) {
try {
IPath fullPath = ResourcesPlugin.getWorkspace().getRoot().getLocation().append( file.getFullPath());
File inputFile = new File( fullPath.toString());
-
- org.jdom.Document jDomDocument = builder.build( inputFile );
+
+ org.jdom.Document jDomDocument = builder.build( inputFile );
return format.output( jDomDocument );
} catch( Exception e ) {
e.printStackTrace();
}
-
+
return null;
}
-
+
/**
* Get the DOM documents of the files given in argument.
* @param files
@@ -253,16 +253,16 @@
*/
public List<Document> getDOMs( IFile[] files ) {
List<Document> result = new ArrayList<Document> ();
-
+
for( IFile file : files ) {
Document document = getDOM( file );
if( document != null )
result.add( document );
}
-
+
return result;
}
-
+
/**
* Get the DOM documents of the files given in argument.
* @param files
@@ -272,25 +272,25 @@
IFile[] iFiles = new IFile[ files.size() ];
return getDOMs( files.toArray( iFiles ));
}
-
+
/**
* Get the DOM documents of the valid composite files in the project.
* Files are filtered to avoid binary folders (e.g. as in Java projects).
*
- * @return
+ * @return the DOM documents of the valid composite files in the project
*/
public List<Document> getDOMs () {
List<IFile> iFiles = new ArrayList<IFile> ();
-
- for( IProject project : projects ) {
+
+ for( IProject project : this.projects ) {
List<IFile> pIFiles = ResourceUtils.getFiles( project, "composite" ); //$NON-NLS-1$
pIFiles = ScaResourceFiltersEPManager.getInstance().filterAllowedFiles( pIFiles );
iFiles.addAll( pIFiles );
}
-
+
return getDOMs( iFiles );
}
-
+
/**
* Get a document by QName.
* @param name
@@ -302,7 +302,7 @@
return getDOM( file );
return null;
}
-
+
/**
* Get documents by QNames.
* @param names
@@ -310,16 +310,16 @@
*/
public List<Document> getDOMsByQName( QName[] names ) {
List<Document> result = new ArrayList<Document> ();
-
+
for( QName name : names ) {
Document document = getDOMbyQName( name );
if( document != null )
result.add( document );
}
-
+
return result;
}
-
+
/**
* Get documents by QNames.
* @param names
@@ -329,22 +329,22 @@
QName[] qNames = new QName[ names.size() ];
return getDOMsByQName( names.toArray( qNames ));
}
-
+
/**
* Get the included file referenced through the node argument and which should be in the project argument.
* @param node
* @param project
- * @return
+ * @return the referenced included file
*/
public static IFile getIncludedFile( Object node, IProject project ) {
if( !ScaUtils.isIncludeNode( node ))
return null;
-
+
QName qName = ScaUtils.getIncludeQName((Node) node );
if( qName == null )
return null;
-
- IncludesUtils includesUtils = new IncludesUtils( project );
+
+ IncludesUtils includesUtils = new IncludesUtils( project );
return includesUtils.getIFile( qName );
}
}
Modified: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/utils/ScaUtils.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/utils/ScaUtils.java 2009-08-27 10:38:15 UTC (rev 3303)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.xmleditor/src/org/eclipse/stp/sca/xmleditor/utils/ScaUtils.java 2009-08-27 15:13:13 UTC (rev 3304)
@@ -31,38 +31,41 @@
public class ScaUtils {
/**
- * Get the top node of a SCA document.
+ * Gets the top node of a SCA document.
+ * <p>
* Get the <code>composite</code> element from a composite document.
- * Or, if the document is not a *.composite file, get the <code>componentType</code> element.
- * @param domDoc
- * @return
+ * Or, if the document is not a *.composite file, get the <code>componentType</code> element.
+ * </p>
+ *
+ * @param domDoc the DOM document
+ * @return the root SCA node
*/
- public static Node getScaTopNode( Document domDoc ) {
+ public static Node getScaTopNode( Document domDoc ) {
NodeList nodes = domDoc.getChildNodes();
-
+
// Get composite.
- for( int i=0; i<nodes.getLength(); i++ ) {
+ for( int i=0; i<nodes.getLength(); i++ ) {
Node node = nodes.item( i );
- if( node.getLocalName() != null
+ if( node.getLocalName() != null
&& node.getLocalName().equalsIgnoreCase( "composite" )) { //$NON-NLS-1$
return node;
}
}
-
+
// Get componentType.
- for( int i=0; i<nodes.getLength(); i++ ) {
+ for( int i=0; i<nodes.getLength(); i++ ) {
Node node = nodes.item( i );
- if( node.getLocalName() != null
+ if( node.getLocalName() != null
&& node.getLocalName().equalsIgnoreCase( "componenttype" )) { //$NON-NLS-1$
return node;
}
}
-
+
return null;
}
-
+
/**
- * Get the QName from an "include" node.
+ * Gets the QName from an "include" node.
* Cover the following cases:
* <ul>
* <li>there is no namespace (use the default one).</li>
@@ -80,143 +83,143 @@
Node nameNode = node.getAttributes().getNamedItem( "name" ); //$NON-NLS-1$
if( nameNode == null )
return null;
-
+
String name = nameNode.getNodeValue();
-
+
// Get prefix.
String prefix = null;
int colonPosition = name.lastIndexOf( ":" ); //$NON-NLS-1$
if( colonPosition == 0 || colonPosition >= name.length())
return null;
-
+
else if( colonPosition > 0 ) {
- prefix = name.substring( 0, colonPosition );
+ prefix = name.substring( 0, colonPosition );
name = name.substring( colonPosition + 1 );
}
-
+
// Get namespace URI.
String namespaceUri = null;
if( prefix != null ) {
Node namespaceNode = node.getAttributes().getNamedItem( "xmlns:" + prefix ); //$NON-NLS-1$
-
+
// Namespace defined in the "include" element.
if( namespaceNode != null )
namespaceUri = namespaceNode.getNodeValue();
-
+
else {
// Check in the root element of the composite the prefix namespace.
Node compositeNode = ScaUtils.getScaTopNode( node.getOwnerDocument());
if( compositeNode == null )
return null;
-
+
namespaceNode = compositeNode.getAttributes().getNamedItem( "xmlns:" + prefix ); //$NON-NLS-1$
if( namespaceNode != null )
namespaceUri = namespaceNode.getNodeValue();
}
}
-
+
// Null prefix means we use the default namespace of the document.
else {
Node compositeNode = ScaUtils.getScaTopNode( node.getOwnerDocument());
if( compositeNode != null )
namespaceUri = compositeNode.getNamespaceURI();
}
-
+
if( !"".equals( name ) && !"".equals( namespaceUri )) //$NON-NLS-1$ //$NON-NLS-2$
return new QName( namespaceUri, name );
}
catch( Exception e ) {
e.printStackTrace();
}
-
+
return null;
}
-
+
/**
- * Remove the namespace prefix from a string.
+ * Removes the namespace prefix from a string.
* @param nodeName not null.
- * @return the substring right after the first colon or the entire string if no colon was found.
+ * @return the substring right after the first colon or the entire string if no colon was found.
*/
public static String removeNamespacePrefix( String nodeName ) {
String[] splits = nodeName.split( ":" ); //$NON-NLS-1$
if( splits.length == 1 )
return nodeName;
-
- // In any other case, return the string at index 1.
+
+ // In any other case, return the string at index 1.
return splits[ 1 ];
}
/**
- * Get the namespace prefix of a an element.
+ * Gets the namespace prefix of a an element.
*
* @param element not null.
- * @return
+ * @return the namepsace prefix
*/
public static String getNamespacePrefix( String element ) {
String[] splits = element.split( ":" ); //$NON-NLS-1$
if( splits.length == 1 )
return null;
-
- // In any other case, return the string at index 0.
+
+ // In any other case, return the string at index 0.
return splits[ 0 ];
}
-
+
/**
- * Capitalize a string.
+ * Capitalizes a string.
* @param text
- * @return
+ * @return the capitalized text
*/
public static String capitalize( String text ) {
if( text == null || text.length() == 0 )
return text;
-
-// text = text.toLowerCase();
+
+ // text = text.toLowerCase();
Character firstLetter = Character.toUpperCase( text.charAt( 0 ));
return firstLetter + text.substring( 1 );
}
-
+
/**
- * Determine if an object is an <code>include</code> node.
+ * Determines if an object is an <code>include</code> node.
* @param node
- * @return
+ * @return true if the object is a node and is called "include"
*/
public static boolean isIncludeNode( Object node ) {
- if( node == null || !Node.class.isAssignableFrom( node.getClass()))
+ if( node == null || !Node.class.isAssignableFrom( node.getClass()))
return false;
-
+
return isIncludeNode((Node) node );
}
-
+
/**
- * Determine if a node is an <code>include</code> node.
+ * Determines if a node is an <code>include</code> node.
* @param node
- * @return
+ * @return true if the node is called "include", false otherwise
*/
public static boolean isIncludeNode( Node node ) {
String name = node.getNodeName();
if( name == null )
return false;
-
+
if( removeNamespacePrefix( name ).toLowerCase().equals( "include" )) //$NON-NLS-1$
return true;
-
+
return false;
}
-
+
/**
- * Get the attribute value for a given <b>attribute name</b> in a given <b>node</b>.
- * Usage: String name = getAttributeValue( myNode, "name" );
+ * Gets the attribute value for a given <b>attribute name</b> in a given <b>node</b>.
+ * Usage: String name = getAttributeValue( myNode, "name" );
*
* @param node
* @param attributeName
- * @return
+ * @return the attribute value
*/
public static String getAttributeValue( Node node, String attributeName ) {
try {
NamedNodeMap attributes = node.getAttributes();
for( int i=0; i<attributes.getLength(); i++ ) {
- String attrName = attributes.item( i ).getNodeName().toLowerCase();
- if( attrName.equals( attributeName.toLowerCase())) {
+ String attrName = attributes.item( i ).getNodeName().toLowerCase();
+ if( attrName.equals( attributeName.toLowerCase())) {
return attributes.item( i ).getNodeValue();
}
}
@@ -224,46 +227,46 @@
catch( Exception e ) {
e.printStackTrace();
}
-
+
return null;
}
-
-
-
+
+
+
/**
* Not sensitive to name spaces (for instance, but not sure either it will be one day).
*/
private static XPath X_PATH = XPathFactory.newInstance().newXPath();
-
-
+
+
public static String[] getPromotions( Document doc, boolean forService ) {
String expr;
if( forService )
expr = "/*[local-name()='composite']/*[local-name()='component']/*[local-name()='service']"; //$NON-NLS-1$
else
expr = "/*[local-name()='composite']/*[local-name()='component']/*[local-name()='reference']"; //$NON-NLS-1$
-
+
try {
Object o = X_PATH.evaluate( expr, doc, XPathConstants.NODESET );
if( o instanceof NodeList ) {
NodeList nodes = (NodeList) o;
String[] result = new String[ nodes.getLength() ];
-
+
for( int i=0; i<result.length; i++ ) {
Node node = nodes.item( i );
String name = getAttributeValue( node, "name" ); //$NON-NLS-1$
String parentName = getAttributeValue( node.getParentNode(), "name" ); //$NON-NLS-1$
result[ i ] = parentName + "/" + name; //$NON-NLS-1$
}
-
+
Arrays.sort( result );
return result;
}
-
+
} catch( XPathExpressionException e ) {
e.printStackTrace();
}
-
+
return new String[ 0 ];
}
}