CheckIn:
Fix Bugzilla bug 132950 Support multi nodes can be inserted into the column mapping in one time
Fix Bugzilla bug 182027 BIRT Designer - Enhancements to XML dataset editor UI
diff --git a/plugins/org.eclipse.datatools.enablement.oda.xml.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.datatools.enablement.oda.xml.ui/META-INF/MANIFEST.MF
index 61b1dd5..4f009ad 100644
--- a/plugins/org.eclipse.datatools.enablement.oda.xml.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.datatools.enablement.oda.xml.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %plugin.name
Bundle-SymbolicName: org.eclipse.datatools.enablement.oda.xml.ui;singleton:=true
-Bundle-Version: 1.0.3.200711191
+Bundle-Version: 1.0.3.200712291
Bundle-ClassPath: .
Bundle-Activator: org.eclipse.datatools.enablement.oda.xml.ui.UiPlugin
Bundle-Vendor: Eclipse.org
diff --git a/plugins/org.eclipse.datatools.enablement.oda.xml.ui/plugin.properties b/plugins/org.eclipse.datatools.enablement.oda.xml.ui/plugin.properties
index 8eaa630..026ebf2 100644
--- a/plugins/org.eclipse.datatools.enablement.oda.xml.ui/plugin.properties
+++ b/plugins/org.eclipse.datatools.enablement.oda.xml.ui/plugin.properties
@@ -17,8 +17,8 @@
# NLS Strings
#
oda.xml.datasource=XML Data Source
-oda.xml.dataset=XML Data Set
-oda.xml.tablemapping=Table Mapping
+oda.xml.dataset=Sample XML Settings
+oda.xml.tablemapping=Row Mapping
oda.xml.columnmapping=Column Mapping
#
plugin.name=Eclipse Data Tools Platform XML ODA Designer
diff --git a/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/i18n/messages.properties b/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/i18n/messages.properties
index 41bb10b..0a99eb2 100644
--- a/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/i18n/messages.properties
+++ b/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/i18n/messages.properties
@@ -16,21 +16,29 @@
wizard.title.selectXmlFile=Select XML Data for Preview
wizard.defaultMessage.selectFile=Select a sample XML source to enable data preview in this session.
wizard.title.xPathChoose=Define Table Mapping
-wizard.defaultMessage.selectXPath=Define the element to be used as a table by selecting the element in XML structure and adding it to Table Mapping. There can only be one table mapping per XML data set.
+wizard.defaultMessage.selectXPath=Define data set row mapping by selecting an element from the XML structure.\nEach occurrence of the selected XML element in the XML document is mapped to a data set row.
wizard.title.selectColumn=Define Column Mapping
-wizard.title.defineColumnMapping=Define column mapping by selecting an element or attribute in XML Structure and adding it to Column Mapping.
+wizard.title.defineColumnMapping=Create data set columns by selecting and adding items from the XML structure.\nEach added XML element or attribute is mapped to a data set column.
#preference
designer.preview.preference.numberOfElementPassedToGetSchema=Number of elements accessed in XML Schema tree parsing.
designer.preview.preference.numberOfElementPassedToGetSchema.errormessage=Please enter a number between 0 and {0}.
designer.preview.preference.columnMappingPage.group.title=Column Mapping Page
-#table mapping page messages
-xPathChoosePage.messages.rowMapping=Table Mapping
+#row mapping page messages
+xPathChoosePage.messages.elementSelection.label=XML Element Selection
+xPathChoosePage.messages.elementSelection.item.absolutePath=XML elements named "{0}" at fixed absolute path\n( {1} )\n
+xPathChoosePage.messages.elementSelection.item.anyLocation=XML elements named "{0}" at any location\n( {1} )\n
+xPathChoosePage.messages.elementSelection.disable.absolutePath=XML elements at fixed absolute path\n
+xPathChoosePage.messages.elementSelection.disable.anyLocation=XML elements at any location\n
+xPathChoosePage.messages.elementSelection.item.custom=C&ustom XPath Expression
xPathChoosePage.messages.xPathExpression=&XPath Expression
xPathChoosePage.messages.xmlStructure=XML Structure
xPathChoosePage.messages.xmlColumnMapping=Column Mapping
xPathChoosePage.messages.xpathChange=Make sure the changed table mapping is compatible with the column mapping if applicable
+xPathChoosePage.FileNameIcon=File Name Icon
+xPathChoosePage.XMLElementIcon=XML Element Icon
+xPathChoosePage.ColumnIcon=Column Icon
#sample xml data file page messages
xmlDataSetSelectionPage.messages.lineofdata=lines of source data
@@ -40,20 +48,30 @@
button.refresh=Refresh
menu.menuItem.removeAll=Remove All
menu.menuItem.remove=Remove
+menu.button.edit=&Edit...
+menu.button.remove=&Remove
+menu.button.up=&Up
+menu.button.down=&Down
+menu.button.preview=&Show Sample Data
lable.selectXmlFile=Enter the URL of the &XML source or browse to the file containing the data:
label.selectEncoding=Select &encoding for the XML source and schema specified above:
lable.selectXmlSchmaFile=Enter the URL of the X&ML schema or browse to the file containing the\n schema. Leave this empty if no schema is available:
label.preview=&Preview first
-label.useXMLFileFromDataSource=Use the XML file defined in data source
+label.useXMLFileFromDataSource=&Use the XML file defined in data source
RowMappingDialog.title=Select or edit the XPath expression.
RowMappingDialog.info=Select one of the predefined XPath expressions for the node you selected or\n enter another expression:
-ColumnMappingDialog.info.columnName=Column Name:
-ColumnMappingDialog.info.xPath=XPath Expression:
-ColumnMappingDialog.info.dataType=Data Type:
-ColumnMappingDialog.info.dataPreview=Table Preview
-ColumnMappingDialog.prompt.new=New Mapping here...
+ColumnMappingPage.AddSingleButton.tooltip=Use the selected node as column mapping
+ColumnMappingPage.AddAllButton.tooltip=Use all the children columns of the selected node as column mapping
+ColumnMappingTable.upButton.tooltip=Move column mapping Up
+ColumnMappingTable.downButton.tooltip=Move column mapping Down
+ColumnMappingTable.removeButton.tooltip=Remove column mapping
+ColumnMappingTable.editButton.tooltip=Edit column mapping
+ColumnMappingTable.previewButton.tooltip=Preview the sample XML data
+ColumnMappingDialog.info.columnName=&Column Name:
+ColumnMappingDialog.info.xPath=&XPath Expression:
+ColumnMappingDialog.info.dataType=&Data Type:
ColumnMappingDialog.prompt.maxRow=The source data is more than 500 lines. Only the first 500 lines can be previewed in this page.
-ColumnMappingDialog.prompt.dialog.title=Result Preview
+XMLDataPreviewDialog.title=Sample XML Data
dataset.editor.columnName=Name
dataset.editor.xpathexpression=XPath
@@ -65,7 +83,13 @@
error.selectFolder=The selected file URL is invalid or the file doesn't exist.
error.emptyPath=The file URL is empty.
error.xpath.canNotContainAttribute=The XPath expression cannot map to an XML attribute.
+error.xpath.getPathList=Error occurred when getting the XPath list by the selected XML tree item.
error.dataset.maxRowNumberError=The max row should be a non-negative number.
+error.columnMapping.createPage=Error occurred in column mapping page.
+error.columnMapping.columnElement.create=Error occurred when mapping a column mapping element.
+error.columnMapping.columnElement.edit=Error occurred when editing the mapping column element.
+error.columnMapping.ATreeNode.getChildren=Error occurs when fetching the children nodes of the selected XML element.
+error.columnMapping.SelectedTreeItem.notNull=No tree item is selected to create column mapping element. Please select one or more.
error.columnMapping.noMappingColumn=Please map at least one column.
error.columnMapping.tableMappingXPathNotExist=The table mapping XPath does not exist.
error.file.null=All the URLs are empty, it means you haven't select any data source. Are you sure you want to keep it?
diff --git a/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/ColumnMappingDialog.java b/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/ColumnMappingDialog.java
index 65bf2a7..08041e4 100644
--- a/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/ColumnMappingDialog.java
+++ b/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/ColumnMappingDialog.java
@@ -12,22 +12,29 @@
package org.eclipse.datatools.enablement.oda.xml.ui.wizards;
import java.util.Arrays;
+import java.util.List;
import org.eclipse.datatools.enablement.oda.xml.ui.i18n.Messages;
import org.eclipse.datatools.enablement.oda.xml.ui.utils.IHelpConstants;
import org.eclipse.datatools.enablement.oda.xml.ui.utils.XMLRelationInfoUtil;
+import org.eclipse.datatools.enablement.oda.xml.util.ui.XPathPopulationUtil;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TrayDialog;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
@@ -44,31 +51,51 @@
private String columnName;
private String xpath;
private String type;
-
- private Text columnNameText ;
- private Text xPathExpressionText;
-
- private static String[] dataTypeDisplayNames = new String[] {
- Messages.getString("datatypes.dateTime"), //$NON-NLS-1$
- Messages.getString("datatypes.decimal"), //$NON-NLS-1$
- Messages.getString("datatypes.float"), //$NON-NLS-1$
- Messages.getString("datatypes.integer"), //$NON-NLS-1$
- Messages.getString("datatypes.date"),
- Messages.getString("datatypes.time"),
- Messages.getString("datatypes.string"),
- Messages.getString("datatypes.boolean")
- };
- public ColumnMappingDialog( Shell parent, String title, String selectedItem, String xpath, int dataType )
+ private Text columnNameText;
+
+ private Button absolutePathButton;
+ private Button anyLocationButton;
+ private Button customButton;
+
+ private Label absoluteLabel;
+ private Label anyLocationLabel;
+
+ private Combo xmlPathCombo;
+ private Text xmlPathText;
+ private List xpathList;
+ private boolean isEditMode;
+
+ private static String[] dataTypeDisplayNames = new String[]{
+ Messages.getString( "datatypes.dateTime" ), //$NON-NLS-1$
+ Messages.getString( "datatypes.decimal" ), //$NON-NLS-1$
+ Messages.getString( "datatypes.float" ), //$NON-NLS-1$
+ Messages.getString( "datatypes.integer" ), //$NON-NLS-1$
+ Messages.getString( "datatypes.date" ),
+ Messages.getString( "datatypes.time" ),
+ Messages.getString( "datatypes.string" ),
+ Messages.getString( "datatypes.boolean" )
+ };
+
+ public ColumnMappingDialog( Shell parent, String title,
+ String selectedItem, String xpath, int dataType, boolean editMode )
{
super( parent );
this.title = title;
this.columnName = ( selectedItem == null ? "" : selectedItem );
this.xpath = ( xpath == null ? "" : xpath );
this.type = DataTypeUtil.getDataTypeDisplayName( dataType );
+ this.isEditMode = editMode;
+ this.xpathList = editMode ? null
+ : XPathPopulationUtil.getPathList( xpath );
Arrays.sort( dataTypeDisplayNames );
}
+ protected boolean isResizable( )
+ {
+ return true;
+ }
+
/*
* (non-Javadoc)
*
@@ -79,58 +106,83 @@
getShell( ).setText( title );
Composite composite = new Composite( parent, SWT.NONE );
GridLayout layout = new GridLayout( );
- layout.numColumns = 4;
composite.setLayout( layout );
- Label label = new Label( composite, SWT.NONE );
- label.setText( Messages.getString( "ColumnMappingDialog.info.columnName" ) ); //$NON-NLS-1$
- columnNameText = new Text( composite, SWT.BORDER );
- GridData data = new GridData( GridData.FILL_BOTH );
- data.horizontalSpan = 3;
- data.widthHint = 300;
- columnNameText.setLayoutData( data );
+ setupTopComposite( composite );
+ if ( isEditMode )
+ {
+ setupCustomExprArea( composite );
+ }
+ else
+ {
+ setupButtonComposite( composite );
+ }
+
+ return composite;
+ }
+
+ /**
+ * @param parent
+ * @return
+ */
+ private void setupTopComposite( Composite parent )
+ {
+ Composite topComposite = new Composite( parent, SWT.NONE );
+ GridLayout layout = new GridLayout( );
+ layout.numColumns = 2;
+ layout.marginWidth = 20;
+ layout.marginBottom = 10;
+ layout.verticalSpacing = 8;
+ topComposite.setLayout( layout );
+
+ GridData gridData = new GridData( );
+ topComposite.setLayoutData( gridData );
+
+ GridData labelData = new GridData( );
+ labelData.widthHint = 70;
+
+ GridData comboData = new GridData( );
+ comboData.widthHint = 300;
+
+ Label label = new Label( topComposite, SWT.NONE );
+ label.setText( Messages.getString( "ColumnMappingDialog.info.columnName" ) ); //$NON-NLS-1$
+ label.setLayoutData( labelData );
+
+ columnNameText = new Text( topComposite, SWT.BORDER );
+ columnNameText.setLayoutData( comboData );
columnNameText.setText( columnName );
- Label label2 = new Label( composite, SWT.NONE );
- label2.setText( Messages.getString( "ColumnMappingDialog.info.xPath" ) ); //$NON-NLS-1$
+ Label label2 = new Label( topComposite, SWT.NONE );
+ label2.setText( Messages.getString( "ColumnMappingDialog.info.dataType" ) ); //$NON-NLS-1$
+ label2.setLayoutData( labelData );
- data = new GridData( GridData.FILL_BOTH );
- data.horizontalSpan = 3;
- xPathExpressionText = new Text( composite, SWT.BORDER );
- xPathExpressionText.setLayoutData( data );
- xPathExpressionText.setText(xpath);
+ typeCombo = new Combo( topComposite, SWT.DROP_DOWN | SWT.READ_ONLY );
- Label label3 = new Label( composite, SWT.NONE );
- label3.setText( Messages.getString( "ColumnMappingDialog.info.dataType" ) ); //$NON-NLS-1$
-
- data = new GridData( GridData.FILL_BOTH );
- data.horizontalSpan = 3;
- typeCombo = new Combo( composite, SWT.DROP_DOWN|SWT.READ_ONLY );
-
int typeIndex = -1;
int stringIndex = -1;
-
+
for ( int i = 0; i < dataTypeDisplayNames.length; i++ )
{
typeCombo.add( dataTypeDisplayNames[i] );
if ( dataTypeDisplayNames[i].equals( this.type ) )
{
typeIndex = i;
-
}
else if ( dataTypeDisplayNames[i].equals( Messages.getString( "datatypes.string" ) ) )
{
stringIndex = i;
}
-
+
}
- if( typeIndex == -1 )
+ if ( typeIndex == -1 )
typeIndex = stringIndex;
-
- typeCombo.setLayoutData( data );
-
+
+ columnNameText.setLayoutData( comboData );
+
+ typeCombo.setLayoutData( comboData );
+
typeCombo.select( typeIndex );
-
+
typeCombo.addSelectionListener( new SelectionAdapter( ) {
public void widgetSelected( SelectionEvent e )
@@ -139,37 +191,265 @@
columnName = typeCombo.getItem( index );
}
} );
-
- XMLRelationInfoUtil.setSystemHelp( composite,
+
+ XMLRelationInfoUtil.setSystemHelp( topComposite,
IHelpConstants.CONEXT_ID_DATASET_XML_COLUMNMAPPING_DIALOG );
-
- return composite;
+ }
+
+ /**
+ * if it's edit mode, use this method to create a Text field to let the user
+ * modify the xpath's value
+ *
+ * @param parent
+ */
+ private void setupCustomExprArea( Composite parent )
+ {
+ Composite customComposite = new Composite( parent, SWT.NONE );
+ GridLayout layout = new GridLayout( );
+ layout.marginWidth = 20;
+ layout.marginBottom = 10;
+ layout.verticalSpacing = 8;
+ customComposite.setLayout( layout );
+
+ GridData gridData = new GridData( );
+ customComposite.setLayoutData( gridData );
+
+ GridData labelData = new GridData( );
+ labelData.horizontalAlignment = 10;
+ Label customLabel = new Label( customComposite, SWT.WRAP );
+ customLabel.setText( Messages.getString( "ColumnMappingDialog.info.xPath" ) );
+ customLabel.setLayoutData( labelData );
+ GridData textData = new GridData( );
+ textData.widthHint = 300;
+ textData.horizontalAlignment = 10;
+ xmlPathText = new Text( customComposite, SWT.BORDER );
+ xmlPathText.setText( xpath );
+ xmlPathText.setLayoutData( textData );
+ xmlPathText.addModifyListener( new ModifyListener( ) {
+
+ public void modifyText( ModifyEvent e )
+ {
+ xpath = xmlPathText.getText( );
+ }
+ } );
}
/**
* get the new column mapping element
+ *
* @return
*/
- ColumnMappingElement getColumnMapping()
+ ColumnMappingElement getColumnMapping( )
{
- ColumnMappingElement columnEle = new ColumnMappingElement();
- columnEle.setColumnName( this.columnName);
+ ColumnMappingElement columnEle = new ColumnMappingElement( );
+ columnEle.setColumnName( this.columnName );
columnEle.setXPath( this.xpath );
columnEle.setType( this.type );
- return columnEle;
+ return columnEle;
}
-
- /*
- * (non-Javadoc) Method declared on Dialog.
- */
- protected void buttonPressed(int buttonId) {
- if ( buttonId == IDialogConstants.OK_ID )
+
+ /*
+ * (non-Javadoc) Method declared on Dialog.
+ */
+ protected void buttonPressed( int buttonId )
+ {
+ if ( buttonId == IDialogConstants.OK_ID )
{
this.columnName = columnNameText.getText( );
- this.xpath = xPathExpressionText.getText( );
- this.type = typeCombo.getItem(typeCombo.getSelectionIndex());
+ this.type = typeCombo.getItem( typeCombo.getSelectionIndex( ) );
}
- super.buttonPressed(buttonId);
- }
+ super.buttonPressed( buttonId );
+ }
+
+ /**
+ * Setup the radio button composite
+ *
+ * @param composite
+ */
+ private void setupButtonComposite( Composite composite )
+ {
+ Composite exprBtnGroup = new Composite( composite, SWT.NONE );
+
+ GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
+ exprBtnGroup.setLayoutData( gridData );
+
+ GridLayout layout = new GridLayout( );
+ layout.numColumns = 2;
+ layout.marginLeft = 20;
+ layout.verticalSpacing = 8;
+ exprBtnGroup.setLayout( layout );
+
+ GridData buttonGd = new GridData( GridData.HORIZONTAL_ALIGN_BEGINNING
+ | GridData.VERTICAL_ALIGN_BEGINNING );
+
+ GridData labelData = new GridData( GridData.FILL_HORIZONTAL );
+
+ absolutePathButton = new Button( exprBtnGroup, SWT.RADIO );
+ absolutePathButton.setLayoutData( buttonGd );
+ absolutePathButton.addSelectionListener( new SelectionAdapter( ) {
+
+ public void widgetSelected( SelectionEvent e )
+ {
+ if ( absolutePathButton.getSelection( ) )
+ {
+ xpath = xpathList.get( 0 ).toString( );
+ xmlPathCombo.setVisible( false );
+ }
+ }
+ } );
+
+ absoluteLabel = new Label( exprBtnGroup, SWT.WRAP );
+ absoluteLabel.setLayoutData( labelData );
+ absoluteLabel.addListener( SWT.MouseDown, new Listener( ) {
+
+ public void handleEvent( Event event )
+ {
+ absolutePathButton.setSelection( true );
+ anyLocationButton.setSelection( false );
+ customButton.setSelection( false );
+ xmlPathCombo.setVisible( false );
+ }
+ } );
+
+ anyLocationButton = new Button( exprBtnGroup, SWT.RADIO );
+ anyLocationButton.setLayoutData( buttonGd );
+ anyLocationButton.addSelectionListener( new SelectionAdapter( ) {
+
+ public void widgetSelected( SelectionEvent e )
+ {
+ if ( anyLocationButton.getSelection( ) )
+ {
+ xpath = xpathList.get( 1 ).toString( );
+ xmlPathCombo.setVisible( false );
+ }
+ }
+ } );
+ anyLocationLabel = new Label( exprBtnGroup, SWT.WRAP );
+ anyLocationLabel.setLayoutData( labelData );
+ anyLocationLabel.addListener( SWT.MouseDown, new Listener( ) {
+
+ public void handleEvent( Event event )
+ {
+ anyLocationButton.setSelection( true );
+ absolutePathButton.setSelection( false );
+ customButton.setSelection( false );
+ xmlPathCombo.setVisible( false );
+ }
+ } );
+ setLabelValues( exprBtnGroup );
+
+ GridData customData = new GridData( GridData.FILL_HORIZONTAL );
+ customData.horizontalSpan = 2;
+ customData.widthHint = 400;
+ customButton = new Button( exprBtnGroup, SWT.RADIO );
+ customButton.setLayoutData( customData );
+ customButton.setText( Messages.getString( "xPathChoosePage.messages.elementSelection.item.custom" ) );
+ customButton.setSelection( true );
+ customButton.addSelectionListener( new SelectionAdapter( ) {
+
+ public void widgetSelected( SelectionEvent e )
+ {
+ if ( customButton.getSelection( ) )
+ {
+ xmlPathCombo.setVisible( true );
+ }
+ }
+ } );
+
+ GridData blankButtonGd = new GridData( );
+ blankButtonGd.verticalAlignment = SWT.BEGINNING;
+ blankButtonGd.horizontalSpan = 1;
+
+ GridData blankButtonData = new GridData( );
+ blankButtonData.horizontalSpan = 1;
+ Button blankButton = new Button( exprBtnGroup, SWT.NONE );
+ blankButton.setData( blankButtonData );
+ blankButton.setVisible( false );
+
+ GridData txtGridData = new GridData( );
+ txtGridData.horizontalSpan = 1;
+ txtGridData.widthHint = 260;
+ xmlPathCombo = new Combo( exprBtnGroup, SWT.DROP_DOWN );
+ xmlPathCombo.setLayoutData( txtGridData );
+ xmlPathCombo.setVisible( true );
+ setupCustomXMLPathField( );
+ xmlPathCombo.addSelectionListener( new SelectionAdapter( ) {
+
+ public void widgetSelected( SelectionEvent e )
+ {
+ }
+ } );
+ xmlPathCombo.addModifyListener( new ModifyListener( ) {
+
+ public void modifyText( ModifyEvent e )
+ {
+ xpath = xmlPathCombo.getText( );
+ }
+ } );
+ }
+
+ /**
+ *
+ */
+ private void setLabelValues( Composite composite )
+ {
+ if ( xpathList == null )
+ {
+ absoluteLabel.setText( Messages.getString( "xPathChoosePage.messages.elementSelection.disable.absolutePath" ) );
+ anyLocationLabel.setText( Messages.getString( "xPathChoosePage.messages.elementSelection.disable.anyLocation" ) );
+ setButtonsEnabled( false );
+ return;
+ }
+
+ if ( xpathList.size( ) >= 2 )
+ {
+ absoluteLabel.setText( Messages.getFormattedString( "xPathChoosePage.messages.elementSelection.item.absolutePath",
+ new String[]{
+ columnName, (String) xpathList.get( 0 )
+ } ) );
+ anyLocationLabel.setText( Messages.getFormattedString( "xPathChoosePage.messages.elementSelection.item.anyLocation",
+ new String[]{
+ columnName, (String) xpathList.get( 1 )
+ } ) );
+ setButtonsEnabled( true );
+ }
+ else
+ {
+ absoluteLabel.setText( Messages.getString( "xPathChoosePage.messages.elementSelection.disable.absolutePath" ) );
+ anyLocationLabel.setText( Messages.getString( "xPathChoosePage.messages.elementSelection.disable.anyLocation" ) );
+ setButtonsEnabled( false );
+ }
+ composite.layout( );
+ }
+
+ /**
+ * Enable or disable the buttons
+ *
+ */
+ private void setButtonsEnabled( boolean enabled )
+ {
+ absolutePathButton.setEnabled( enabled );
+ anyLocationButton.setEnabled( enabled );
+ }
+
+ /**
+ * Setup custom XML path field
+ */
+ private void setupCustomXMLPathField( )
+ {
+ if ( xpathList != null && xpathList.size( ) >= 2 )
+ {
+ xmlPathCombo.setText( xpathList.get( 0 ).toString( ) );
+ xmlPathCombo.add( xpathList.get( 0 ).toString( ) );
+ xmlPathCombo.add( xpathList.get( 1 ).toString( ) );
+ }
+ else
+ {
+ xmlPathCombo.setText( "" );
+ setButtonsEnabled( false );
+ return;
+ }
+ xpath = xmlPathCombo.getText( );
+ }
}
diff --git a/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/ColumnMappingPage.java b/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/ColumnMappingPage.java
index e7724a1..7546ba5 100644
--- a/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/ColumnMappingPage.java
+++ b/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/ColumnMappingPage.java
@@ -17,6 +17,8 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.datatools.connectivity.oda.OdaException;
@@ -33,10 +35,12 @@
import org.eclipse.datatools.enablement.oda.xml.util.ui.ATreeNode;
import org.eclipse.datatools.enablement.oda.xml.util.ui.SchemaPopulationUtil;
import org.eclipse.datatools.enablement.oda.xml.util.ui.XPathPopulationUtil;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ComboBoxCellEditor;
-import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
@@ -73,22 +77,21 @@
* Column mapping page to define the colum mapping with xml data set
*/
-public class ColumnMappingPage extends DataSetWizardPage implements ITableLabelProvider
+public class ColumnMappingPage extends DataSetWizardPage
+ implements
+ ITableLabelProvider
{
- private final int DEFAULT_WIDTH = 300;
- private final int DEFAULT_HEIGHT = 200;
private Tree availableXmlTree;
- private Button btnAdd;
+ private Button btnAddOne;
+ private Button btnAddAll;
+ private Button btnPreview;
private Composite btnComposite;
private ColumnMappingTableViewer columnMappingTable;
private Group treeGroup;
- private Group rightGroup;
+ private Group tableViewerGroup;
private ATreeNode treeNode;
- private TreeItem selectedItem;
-
- private ResultSetTableViewer previewViewer;
private String tableName;
private String xsdFileName;
@@ -96,7 +99,6 @@
private String xmlEncoding;
private Map columnMap;
private List columnMappingList = new ArrayList( );
- private ColumnMappingElement newColumn;
private String selectedTreeItemText;
@@ -105,6 +107,7 @@
private static String TYPE_NAME = Messages.getString( "dataset.editor.datatype" );
private static String DEFAULT_PAGE_NAME = Messages.getString( "xPathChoosePage.messages.xmlColumnMapping" );
private static String DEFAULT_PAGE_Message = Messages.getString( "wizard.title.defineColumnMapping" );
+ private static String PATH_SEPERATOR = "/";
private static String[] dataTypeDisplayNames = new String[]{
Messages.getString( "datatypes.dateTime" ), //$NON-NLS-1$
@@ -117,6 +120,8 @@
Messages.getString( "datatypes.boolean" )
};
+ private static Logger logger = Logger.getLogger( ColumnMappingPage.class.getName( ) );
+
/**
* @param string
*/
@@ -148,7 +153,7 @@
public void createPageCustomControl( Composite parent )
{
setControl( createPageControl( parent ) );
- if( XMLInformationHolder.hasDestroyed() )
+ if( XMLInformationHolder.hasDestroyed( ) )
XMLInformationHolder.start( this.getInitializationDesign( ) );
initializeControl( );
if ( selectedTreeItemText != null )
@@ -181,8 +186,9 @@
}
catch ( OdaException e )
{
- // TODO Auto-generated catch block
- e.printStackTrace( );
+ setMessage( Messages.getString( "error.columnMapping.createPage" ),
+ ERROR );
+ logger.log( Level.INFO, e.getMessage( ), e );
}
this.columnMap = new HashMap( );
@@ -214,7 +220,6 @@
xsdFileName = XMLInformationHolder.getPropertyValue( Constants.CONST_PROP_FILELIST );*/
if ( selectedTreeItemText != null )
{
- selectedItem = null;
populateXMLTree( );
}
setPageProperties( );
@@ -245,23 +250,19 @@
Composite composite = new Composite( parent, SWT.NONE );
GridLayout layout = new GridLayout( );
- layout.numColumns = 1;
composite.setLayout( layout );
- createTopComposite( composite );
- createBottomComposite( composite );
-
- setPageProperties( );
+ createPageComposite( composite );
+ setPageProperties( );
return composite;
-
}
/**
- * create the top composite
+ * create the column mapping page composite
*
* @param parent
*/
- private void createTopComposite( Composite parent )
+ private void createPageComposite( Composite parent )
{
Composite composite = new Composite( parent, SWT.NONE );
@@ -280,11 +281,12 @@
btnLayout.spacing = 5;
btnComposite.setLayout( btnLayout );
- btnAdd = new Button( btnComposite, SWT.NONE );
- btnAdd.setText( ">" ); //$NON-NLS-1$
- //TODO to externalize into message file
- btnAdd.setToolTipText( "Use the selected node as column mapping" );
- btnAdd.addSelectionListener( new SelectionAdapter( ) {
+ btnAddOne = new Button( btnComposite, SWT.NONE );
+ btnAddOne.setText( ">" ); //$NON-NLS-1$
+ // TODO to externalize into message file
+ btnAddOne.setToolTipText( Messages.getString( "ColumnMappingPage.AddSingleButton.tooltip" ) );
+ btnAddOne.setEnabled( false );
+ btnAddOne.addSelectionListener( new SelectionAdapter( ) {
/*
* (non-Javadoc)
@@ -293,6 +295,16 @@
*/
public void widgetSelected( SelectionEvent e )
{
+ TreeItem[] selectedMultiItems = availableXmlTree.getSelection( );
+ if ( selectedMultiItems == null
+ || selectedMultiItems.length != 1 )
+ {
+ setMessage( Messages.getString( "error.columnMapping.SelectedTreeItem.notNull" ),
+ ERROR );
+ btnAddOne.setEnabled( false );
+ return;
+ }
+ TreeItem selectedItem = selectedMultiItems[0];
String pathStr = createXPath( selectedItem );
String name = selectedItem.getText( );
int type = -1;
@@ -305,7 +317,8 @@
name = (String) node.getTreeNode( ).getValue( );
try
{
- type = DataTypes.getType( node.getTreeNode( ).getDataType( ) );
+ type = DataTypes.getType( node.getTreeNode( )
+ .getDataType( ) );
}
catch ( OdaException e1 )
{
@@ -315,67 +328,119 @@
ColumnMappingDialog columnDialog = new ColumnMappingDialog( getShell( ),
DEFAULT_PAGE_NAME,
name,
- pathStr, type );
- String relationInfo;
+ pathStr,
+ type,
+ false );
if ( columnDialog.open( ) == Window.OK )
{
ColumnMappingElement columnElement = columnDialog.getColumnMapping( );
- if ( isUniqueName( columnElement.getColumnName( ),
- columnElement ) )
- {
- columnMap.put( columnElement.getColumnName( ),
- columnElement );
- columnMappingList.add( columnElement );
-
- refreshColumnMappingViewer( );
-
- relationInfo = XMLInformationHolder.getPropertyValue( Constants.CONST_PROP_RELATIONINFORMATION );
- if ( relationInfo != null
- && relationInfo.trim( ).length( ) > 0 )
- {
- String tableInfo = XMLRelationInfoUtil.getTableRelationInfo( relationInfo,
- tableName );
- if ( tableInfo != null
- && tableInfo.trim( ).length( ) > 0 )
- XMLInformationHolder.setPropertyValue( Constants.CONST_PROP_RELATIONINFORMATION,
- XMLRelationInfoUtil.replaceInfo( tableName,
- saveQueryString( ),
- relationInfo ) );
- else
- XMLInformationHolder.setPropertyValue( Constants.CONST_PROP_RELATIONINFORMATION,
- XMLRelationInfoUtil.concatRelationInfo( relationInfo,
- saveQueryString( ) ) );
- }
- else
- XMLInformationHolder.setPropertyValue( Constants.CONST_PROP_RELATIONINFORMATION,
- saveQueryString( ) );
- }
- setPageProperties( );
+ updateColumnMappingElement( columnElement );
+ selectedItem = null;
+ btnAddOne.setEnabled( false );
+ btnAddAll.setEnabled( false );
}
}
} );
-
+ btnAddAll = new Button( btnComposite, SWT.NONE );
+ btnAddAll.setText( ">>" ); //$NON-NLS-1$
+ // TODO to externalize into message file
+ btnAddAll.setToolTipText( Messages.getString( "ColumnMappingPage.AddAllButton.tooltip" ) );
+ btnAddAll.setEnabled( false );
+ btnAddAll.addSelectionListener( new SelectionAdapter( ) {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetSelected( SelectionEvent e )
+ {
+ TreeItem[] selectedMultiItems = availableXmlTree.getSelection( );
+ if ( selectedMultiItems == null
+ || selectedMultiItems.length == 0 )
+ {
+ btnAddAll.setEnabled( false );
+ setMessage( Messages.getString( "error.columnMapping.SelectedTreeItem.notNull" ),
+ ERROR );
+ }
+ if ( selectedMultiItems.length == 1 )
+ {
+ /* Only one node is selected at a time */
+ if ( !handleSelectedItem( selectedMultiItems[0] ) )
+ {
+ setMessage( Messages.getString( "error.columnMapping.columnElement.create" ),
+ ERROR );
+ }
+ }
+ else
+ {
+ /* Multiple nodes are selected at the same time */
+ for ( int i = 0; i < selectedMultiItems.length; i++ )
+ {
+ TreeItem selectedItem = selectedMultiItems[i];
+ if ( !handleSelectedItem( selectedItem ) )
+ {
+ setMessage( Messages.getString( "error.columnMapping.columnElement.create" ),
+ ERROR );
+ break;
+ }
+ }
+ }
+ selectedMultiItems = null;
+ btnAddOne.setEnabled( false );
+ btnAddAll.setEnabled( false );
+ }
+ } );
+ // create the right table viewer group
createRightGroup( composite );
}
/**
- * create bottom composite
+ * create preview button
*
* @param parent
*/
- private void createBottomComposite( Composite parent )
+ private void createPreviewButton( Composite parent )
{
- Group previewGroup = new Group( parent, SWT.VERTICAL );
- GridData data = new GridData( GridData.FILL_BOTH );
- data.heightHint = 80;
- previewGroup.setLayoutData( data );
- previewGroup.setText( Messages.getString( "ColumnMappingDialog.info.dataPreview" ) );
- previewGroup.setLayout( new FillLayout( ) );
- previewViewer = new ResultSetTableViewer( previewGroup,
- true,
- true,
- true );
- previewViewer.getViewer( ).setHeaderVisible( true );
+ btnPreview = new Button( parent, SWT.PUSH );
+ btnPreview.setText( Messages.getString( "menu.button.preview" ) );
+ btnPreview.setToolTipText( Messages.getString( "ColumnMappingTable.previewButton.tooltip" ) );
+ btnPreview.addSelectionListener( new SelectionAdapter( ) {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetSelected( SelectionEvent e )
+ {
+ XMLDataPreviewDialog previewDialog = new XMLDataPreviewDialog( getShell( ) );
+ if ( previewDialog.open( ) == IDialogConstants.CLOSE_ID )
+ {
+ previewDialog.close( );
+ }
+ }
+ } );
+
+ GridData gd = new GridData( );
+ gd.horizontalAlignment = SWT.END;
+ btnPreview.setLayoutData( gd );
+ }
+
+ private void createRightGroup( Composite composite )
+ {
+ Composite rightComposite = new Composite( composite, SWT.NONE );
+ FormData data = new FormData( );
+ data.top = new FormAttachment( 0, 5 );
+ data.left = new FormAttachment( btnComposite, 5 );
+ data.right = new FormAttachment( 100, -5 );
+ data.bottom = new FormAttachment( 100, -5 );
+ rightComposite.setLayoutData( data );
+
+ rightComposite.setLayout( new GridLayout( ) );
+ rightComposite.setEnabled( true );
+ createTableViewerGroup( rightComposite );
+ createPreviewButton( rightComposite );
}
/**
@@ -383,25 +448,20 @@
*
* @param composite2
*/
- private void createRightGroup( Composite composite2 )
+ private void createTableViewerGroup( Composite composite2 )
{
- FormData data = new FormData( );
- data.top = new FormAttachment( 0, 5 );
- data.left = new FormAttachment( btnComposite, 5 );
- data.right = new FormAttachment( 100, -5 );
- data.bottom = new FormAttachment( 100, -5 );
- data.width = DEFAULT_WIDTH;
- rightGroup = new Group( composite2, SWT.NONE );
+ tableViewerGroup = new Group( composite2, SWT.NONE
+ | SWT.H_SCROLL | SWT.V_SCROLL );
+ tableViewerGroup.setLayout( new GridLayout( ) );
+ tableViewerGroup.setText( Messages.getString( "xPathChoosePage.messages.xmlColumnMapping" ) );
+ tableViewerGroup.setLayoutData( new GridData( GridData.FILL_BOTH ) );
- rightGroup.setLayout( new FillLayout( ) );
- rightGroup.setText( Messages.getString( "xPathChoosePage.messages.xmlColumnMapping" ) );
- rightGroup.setLayoutData( data );
-
- rightGroup.setEnabled( true );
- columnMappingTable = new ColumnMappingTableViewer( rightGroup,
+ tableViewerGroup.setEnabled( true );
+ columnMappingTable = new ColumnMappingTableViewer( tableViewerGroup,
true,
true,
true );
+ columnMappingTable.getControl( ).setLayoutData( new GridData( GridData.FILL_BOTH ) );
columnMappingTable.getViewer( ).getTable( ).setHeaderVisible( true );
columnMappingTable.getViewer( ).getTable( ).setLinesVisible( true );
@@ -428,16 +488,8 @@
{
ArrayList inputList = new ArrayList( 10 );
inputList.addAll( columnMappingList );
-
- if ( newColumn == null )
- {
- newColumn = new ColumnMappingElement( );
- }
-
- inputList.add( newColumn );
return inputList.toArray( );
}
-
return new Object[0];
}
@@ -460,9 +512,44 @@
}
/**
+ * Map all the children elements of the specific TreeItem to be the columns
+ * If the TreeItem has no child, it itself is mapped to be a column
+ *
+ * @param aTreeNode
+ * @param treeItem
+ */
+ private void addChildrenElements( ATreeNode aTreeNode, TreeItem treeItem )
+ {
+ try
+ {
+ if ( aTreeNode.getType( ) == ATreeNode.ATTRIBUTE_TYPE
+ || ( aTreeNode.getType( ) == ATreeNode.ELEMENT_TYPE && aTreeNode.getChildren( ).length == 0 ) )
+ {
+ String pathStr = createXPath( treeItem );
+ updateColumnMappingElement( createSingleElement( aTreeNode,
+ pathStr ) );
+ }
+ else
+ {
+ Object[] children = aTreeNode.getChildren( );
+ for ( int i = 0; i < children.length; i++ )
+ {
+ addChildrenElements( (ATreeNode)children[i], treeItem.getItems( )[i] );
+ }
+ }
+ }
+ catch ( OdaException e )
+ {
+ logger.log( Level.INFO, e.getMessage( ), e );
+ setMessage( Messages.getString( "error.columnMapping.ATreeNode.getChildren" ),
+ ERROR );
+ }
+ }
+
+ /**
* check whether the column is duplicated
*
- * @param newColumn1
+ * @param columnName
* @return
*/
private boolean isUniqueName( String columnName, ColumnMappingElement actualElement )
@@ -470,14 +557,9 @@
boolean success = true;
if ( columnMap != null )
{
- if ( columnMap.get( columnName ) != actualElement
+ if ( columnMap.containsKey( columnName )
&& columnMap.get( columnName ) != null )
- {
- setDetailsMessage( Messages.getFormattedString( "error.columnMapping.sameColumnName",
- new Object[]{
- columnName
- } ),
- IMessageProvider.ERROR );
+ {
success = false;
}
else
@@ -532,17 +614,19 @@
{
treeItem = treeItem.getParentItem( );
- if ( ( (TreeNodeData) treeItem.getData( ) ).getTreeNode( ).getType( ) == ATreeNode.ELEMENT_TYPE
+ if ( ( (TreeNodeData) treeItem.getData( ) ).getTreeNode( )
+ .getType( ) == ATreeNode.ELEMENT_TYPE
&& columnPath.trim( ).length( ) > 0 )
- columnPath = treeItem.getText( ) + "/" + columnPath;
- else if ( ( (TreeNodeData) treeItem.getData( ) ).getTreeNode( ).getType( ) == ATreeNode.ATTRIBUTE_TYPE )
- columnPath = columnPath + "/" + treeItem.getText( );
+ columnPath = treeItem.getText( ) + PATH_SEPERATOR + columnPath;
+ else if ( ( (TreeNodeData) treeItem.getData( ) ).getTreeNode( )
+ .getType( ) == ATreeNode.ATTRIBUTE_TYPE )
+ columnPath = columnPath + PATH_SEPERATOR + treeItem.getText( );
}
- if ( !columnPath.startsWith( "/" ) )
- columnPath = "/" + columnPath;
+ if ( !columnPath.startsWith( PATH_SEPERATOR ) )
+ columnPath = PATH_SEPERATOR + columnPath;
return columnPath;
}
-
+
/**
* create the left group composite
*
@@ -556,8 +640,7 @@
data.left = new FormAttachment( 0, 5 );
data.right = new FormAttachment( 40, -5 );
data.bottom = new FormAttachment( 100, -5 );
- data.height = DEFAULT_HEIGHT;
- treeGroup = new Group( composite2, SWT.NONE );
+ treeGroup = new Group( composite2, SWT.VERTICAL );
treeGroup.setLayout( new FillLayout( ) );
treeGroup.setLayoutData( data );
availableXmlTree = new Tree( treeGroup, SWT.MULTI
@@ -566,23 +649,46 @@
public void widgetSelected( SelectionEvent e )
{
- TreeItem items[] = availableXmlTree.getSelection( );
- for ( int i = 0; i < items.length; i++ )
+ TreeItem[] selectedMultiItems = availableXmlTree.getSelection( );
+ if ( selectedMultiItems.length > 1 )
{
- selectedItem = items[0];
- if ( items[i].getGrayed( ) )
+ for ( int i = 0; i < selectedMultiItems.length; i++ )
+ {
+ if ( selectedMultiItems[i].getGrayed( ) )
+ {
+ availableXmlTree.setRedraw( false );
+ availableXmlTree.deselectAll( );
+ availableXmlTree.setRedraw( true );
+ availableXmlTree.redraw( );
+ }
+ }
+ setMessage( DEFAULT_PAGE_Message );
+ btnAddAll.setEnabled( true );
+ btnAddOne.setEnabled( false );
+ }
+ else if ( selectedMultiItems.length == 1 )
+ {
+ TreeItem selectedItem = selectedMultiItems[0];
+ selectedMultiItems = null;
+ if ( selectedItem.getGrayed( ) )
{
availableXmlTree.setRedraw( false );
availableXmlTree.deselectAll( );
availableXmlTree.setRedraw( true );
availableXmlTree.redraw( );
}
+ if ( selectedItem != null )
+ {
+ setMessage( DEFAULT_PAGE_Message );
+ btnAddOne.setEnabled( true );
+ btnAddAll.setEnabled( true );
+ }
+ else
+ {
+ btnAddOne.setEnabled( false );
+ btnAddAll.setEnabled( false );
+ }
}
- if ( selectedItem != null )
- btnAdd.setEnabled( true );
- else
- btnAdd.setEnabled( false );
-
}
} );
@@ -607,19 +713,54 @@
{
if ( e.keyCode == SWT.DEL )
{
- removeSelectedItem( );
+ removeSelectedItems( );
setPageProperties( );
}
}
} );
+ columnMappingTable.getViewer( ).getTable( ).addListener( SWT.MouseDown,
+ new Listener( ) {
+
+ public void handleEvent( Event event )
+ {
+ if ( columnMappingTable.getViewer( )
+ .getTable( )
+ .getSelectionIndices( ).length > 1 )
+ {
+ columnMappingTable.getEditButton( )
+ .setEnabled( false );
+ columnMappingTable.getUpButton( )
+ .setEnabled( false );
+ columnMappingTable.getDownButton( )
+ .setEnabled( false );
+ }
+ }
+ } );
+
+ columnMappingTable.getEditButton( )
+ .addSelectionListener( new SelectionListener( ) {
+
+ public void widgetSelected( SelectionEvent e )
+ {
+ doEdit( );
+ }
+
+ public void widgetDefaultSelected( SelectionEvent e )
+ {
+ }
+
+ } );
+ columnMappingTable.getEditButton( )
+ .setToolTipText( Messages.getString( "ColumnMappingTable.editButton.tooltip" ) );
+
columnMappingTable.getRemoveButton( )
.addSelectionListener( new SelectionListener( ) {
public void widgetSelected( SelectionEvent e )
{
- removeSelectedItem( );
+ removeSelectedItems( );
setPageProperties( );
}
@@ -628,16 +769,16 @@
}
} );
- //TODO to externalize into message file
+ // TODO to externalize into message file
columnMappingTable.getRemoveButton( )
- .setToolTipText( "Remove column mapping" );
+ .setToolTipText( Messages.getString( "ColumnMappingTable.removeButton.tooltip" ) );
columnMappingTable.getRemoveMenuItem( )
.addSelectionListener( new SelectionListener( ) {
public void widgetSelected( SelectionEvent e )
{
- removeSelectedItem( );
+ removeSelectedItems( );
setPageProperties( );
}
@@ -675,9 +816,9 @@
}
} );
- //TODO to externalize into message file
+ // TODO to externalize into message file
columnMappingTable.getUpButton( )
- .setToolTipText( "Move column mappping Up" );
+ .setToolTipText( Messages.getString( "ColumnMappingTable.upButton.tooltip" ) );
columnMappingTable.getDownButton( )
.addSelectionListener( new SelectionListener( ) {
@@ -692,83 +833,135 @@
}
} );
- //TODO to externalize into message file
+ // TODO to externalize into message file
columnMappingTable.getDownButton( )
- .setToolTipText("Move column mapping Down" );
+ .setToolTipText( Messages.getString( "ColumnMappingTable.downButton.tooltip" ) );
}
-
+
/**
- * remove the selected item in the table
+ * Edit the single table viewer element
*
*/
- private void removeSelectedItem( )
+ private void doEdit( )
{
int index = columnMappingTable.getViewer( )
.getTable( )
.getSelectionIndex( );
- int count = columnMappingTable.getViewer( ).getTable( ).getItemCount( );
+ if ( index == -1 )
+ return;
- if ( index > -1 && index < count )
+ ColumnMappingElement columnMappingElement = (ColumnMappingElement) columnMappingTable.getViewer( )
+ .getTable( )
+ .getItem( index )
+ .getData( );
+ String originColumnName = columnMappingElement.getColumnName( );
+ try
{
- TableItem item = columnMappingTable.getViewer( )
- .getTable( )
- .getItem( index );
- Object element = item.getData( );
- String elementName = "";
- if ( element instanceof ColumnMappingElement
- && element != newColumn )
+ ColumnMappingDialog columnDialog = new ColumnMappingDialog( getShell( ),
+ DEFAULT_PAGE_NAME,
+ columnMappingElement.getColumnName( ),
+ columnMappingElement.getXPath( ),
+ DataTypes.getType( columnMappingElement.getTypeStandardString( ) ),
+ true );
+ if ( columnDialog.open( ) == Window.OK )
{
- ColumnMappingElement entry = (ColumnMappingElement) element;
- elementName = (String) entry.getColumnName( );
-
- columnMappingTable.getViewer( ).getTable( ).select( index );
-
- this.columnMap.remove( elementName );
- this.columnMappingList.remove( index );
-
- String str = XMLRelationInfoUtil.replaceInfo( this.tableName,
- saveQueryString( ),
- XMLInformationHolder.getPropertyValue( Constants.CONST_PROP_RELATIONINFORMATION ) );
- XMLInformationHolder.setPropertyValue( Constants.CONST_PROP_RELATIONINFORMATION,
- str );
+ columnMap.remove( columnMappingElement.getColumnName( ) );
+ ColumnMappingElement columnElement = columnDialog.getColumnMapping( );
+ String editedColumnName = columnElement.getColumnName( );
+ if( !originColumnName.equalsIgnoreCase( editedColumnName ) )
+ {
+ int appendix = 0;
+ while ( !isUniqueName( editedColumnName, columnElement ) )
+ {
+ appendix++;
+ break;
+ }
+ if ( appendix > 0 )
+ {
+ editedColumnName = editedColumnName + "_" + appendix;
+ }
+ columnElement.setColumnName( editedColumnName );
+ }
+ columnMappingElement.setColumnName( editedColumnName );
+ columnMappingElement.setType( columnElement.getType( ) );
+ columnMappingElement.setXPath( columnElement.getXPath( ) );
+ columnMap.put( editedColumnName, columnMappingElement );
+ if( columnMappingList.size( ) > index )
+ {
+ columnMappingList.set( index, columnMappingElement );
+ }
+ setXMLInformationHolderProps( );
+ refreshColumnMappingViewer( );
+ setPageProperties( );
+ refreshXMLConnection( );
}
}
- if ( columnMappingList.size( ) <= 0 )
+ catch ( OdaException e1 )
{
- String str = XMLRelationInfoUtil.replaceInfo( this.tableName,
- "",
- XMLInformationHolder.getPropertyValue( Constants.CONST_PROP_RELATIONINFORMATION ) );
- XMLInformationHolder.setPropertyValue( Constants.CONST_PROP_RELATIONINFORMATION,
- str );
+ logger.log( Level.INFO, e1.getMessage( ), e1 );
+ setMessage( Messages.getString( "error.columnMapping.columnElement.edit" ),
+ ERROR );
+ }
+ }
+
+ /**
+ * To remove all the selected column mapping items from table
+ *
+ */
+ private void removeSelectedItems( )
+ {
+ int[] indices = columnMappingTable.getViewer( )
+ .getTable( )
+ .getSelectionIndices( );
+ for( int i = 0; i < indices.length; i ++ )
+ {
+ removeSingleColumnItem( indices[i] - i );
}
refreshColumnMappingViewer( );
}
/**
- * remove all items of the table
+ * Remove single table item by the specific item index
+ *
+ * @param items
+ * @param index
+ */
+ private void removeSingleColumnItem( int index )
+ {
+ Object element = columnMappingTable.getViewer( )
+ .getTable( )
+ .getItem( index )
+ .getData( );
+ String elementName = "";
+ if ( element instanceof ColumnMappingElement )
+ {
+ ColumnMappingElement entry = (ColumnMappingElement) element;
+ elementName = (String) entry.getColumnName( );
+
+ columnMappingTable.getViewer( ).getTable( ).remove( index );
+
+ this.columnMap.remove( elementName );
+ this.columnMappingList.remove( index );
+
+ String str = XMLRelationInfoUtil.replaceInfo( this.tableName,
+ saveQueryString( ),
+ XMLInformationHolder.getPropertyValue( Constants.CONST_PROP_RELATIONINFORMATION ) );
+ XMLInformationHolder.setPropertyValue( Constants.CONST_PROP_RELATIONINFORMATION,
+ str );
+ }
+ }
+
+ /**
+ * Remove all of the column mapping items from the table
*
*/
private void removeAllItem( )
{
int count = columnMappingTable.getViewer( ).getTable( ).getItemCount( );
- for ( int index = 0; index < count - 1; index++ )
+ for ( int index = 0; index < count ; index++ )
{
- TableItem item = columnMappingTable.getViewer( )
- .getTable( )
- .getItem( 0 );
-
- Object element = item.getData( );
- String elementName = "";
- if ( element instanceof ColumnMappingElement )
- {
- ColumnMappingElement entry = (ColumnMappingElement) element;
- elementName = (String) entry.getColumnName( );
- }
- columnMappingTable.getViewer( ).getTable( ).remove( 0 );
- this.columnMap.remove( elementName );
- this.columnMappingList.remove( 0 );
+ removeSingleColumnItem( 0 );
}
-
String str = XMLRelationInfoUtil.replaceInfo( this.tableName,
"",
XMLInformationHolder.getPropertyValue( Constants.CONST_PROP_RELATIONINFORMATION ) );
@@ -865,43 +1058,55 @@
populateTreeItems( availableXmlTree, childs, 0 );
availableXmlTree.addListener(SWT.Expand, new Listener(){
- public void handleEvent(Event event) {
- TreeItem currentItem = (TreeItem)event.item;
-
- if ( ((TreeNodeData)currentItem.getData()).hasBeenExpandedOnce())
+ public void handleEvent( Event event )
+ {
+ TreeItem currentItem = (TreeItem) event.item;
+
+ if ( ( (TreeNodeData) currentItem.getData( ) ).hasBeenExpandedOnce( ) )
return;
-
- ((TreeNodeData)currentItem.getData()).setHasBeenExpandedOnce();
- currentItem.removeAll();
+
+ ( (TreeNodeData) currentItem.getData( ) ).setHasBeenExpandedOnce( );
+ currentItem.removeAll( );
try
{
- if ( (((TreeNodeData)currentItem.getData()).getTreeNode()).getChildren( ) != null
- && ((TreeNodeData)currentItem.getData()).getTreeNode().getChildren( ).length > 0 )
- TreePopulationUtil.populateTreeItems( currentItem, ((TreeNodeData)currentItem.getData()).getTreeNode().getChildren( ), true );
+ if ( ( ( (TreeNodeData) currentItem.getData( ) ).getTreeNode( ) ).getChildren( ) != null
+ && ( (TreeNodeData) currentItem.getData( ) ).getTreeNode( )
+ .getChildren( ).length > 0 )
+ TreePopulationUtil.populateTreeItems( currentItem,
+ ( (TreeNodeData) currentItem.getData( ) ).getTreeNode( )
+ .getChildren( ),
+ true );
}
catch ( OdaException e )
{
- // TODO Auto-generated catch block
- e.printStackTrace();
+ setMessage( Messages.getString( "error.columnMapping.createPage" ),
+ ERROR );
}
- }});
-
- if ( selectedItem == null )
+ }
+ } );
+
+ TreeItem[] selectedMultiItems = availableXmlTree.getSelection( );
+ if ( selectedMultiItems == null ||
+ selectedMultiItems.length == 0 )
{
- btnAdd.setEnabled( false );
+ btnAddOne.setEnabled( false );
+ btnAddAll.setEnabled( false );
this.setMessage( Messages.getString( "error.columnMapping.tableMappingXPathNotExist" ),
ERROR );
}
else
{
- btnAdd.setEnabled( true );
+ btnAddOne.setEnabled( true );
+ btnAddAll.setEnabled( true );
this.setMessage( DEFAULT_PAGE_Message );
}
}
catch ( Exception e )
{
- e.printStackTrace( );
+ logger.log( Level.INFO, e.getMessage( ), e );
+ setMessage( Messages.getString( "error.columnMapping.createPage" ),
+ ERROR );
}
}
@@ -909,9 +1114,10 @@
*
* @param tree
* @param node
- * @throws OdaException
+ * @throws OdaException
*/
- private void populateTreeItems( Object tree, Object[] node, int level ) throws OdaException
+ private void populateTreeItems( Object tree, Object[] node, int level )
+ throws OdaException
{
level ++;
@@ -930,11 +1136,30 @@
treeItem.setData( data );
int type = treeNode.getType( );
if ( type == ATreeNode.ATTRIBUTE_TYPE )
+ {
+ treeItem.setImage( TreeNodeDataUtil.getColumnImage( ) );
treeItem.setText( "@" + treeNode.getValue( ).toString( ) );
- else
+ }
+ else if ( type == ATreeNode.ELEMENT_TYPE )
+ {
+ if ( treeNode.getParent( ).getValue( ).equals( "ROOT" ) )
+ {
+ treeItem.setImage( TreeNodeDataUtil.getSourceFileImage( ) );
+ }
+ else if ( treeNode.getChildren( ).length == 0 )
+ {
+ treeItem.setImage( TreeNodeDataUtil.getColumnImage( ) );
+ }
+ else
+ {
+ treeItem.setImage( TreeNodeDataUtil.getXmlElementImage( ) );
+ }
treeItem.setText( treeNode.getValue( ).toString( ) );
-
-
+ }
+ else
+ {
+ treeItem.setText( treeNode.getValue( ).toString( ) );
+ }
String populateString = XPathPopulationUtil.populateColumnPath( getRootPathWithOutFilter( ),
generateXpathFromTreeItem( treeItem ) );
if ( populateString != null )
@@ -948,7 +1173,7 @@
treeItem
} );
availableXmlTree.setFocus();
- selectedItem = treeItem;
+ availableXmlTree.setSelection( treeItem );
}
setExpanded( treeItem );
@@ -1006,124 +1231,16 @@
XPATH_NAME, //$NON-NLS-1$
TYPE_NAME, //$NON-NLS-1$
} );
+
+ columnMappingTable.getViewer( )
+ .addDoubleClickListener( new IDoubleClickListener( ) {
- columnMappingTable.getViewer( ).setCellModifier( new ICellModifier( ) {
-
- public boolean canModify( Object element, String property )
- {
-
- if ( element == newColumn && !property.equals( COLUMN_NAME ) )
- return false;
- else
- return true;
- }
-
- public Object getValue( Object element, String property )
- {
- Object value = null;
- try
- {
- if ( property.equals( COLUMN_NAME ) )
- value = ( (ColumnMappingElement) element ).getColumnName( );
- else if ( property.equals( XPATH_NAME ) )
- value = ( (ColumnMappingElement) element ).getXPath( );
- else if ( property.equals( TYPE_NAME ) )
+ public void doubleClick( DoubleClickEvent e )
{
- String temp = ( (ColumnMappingElement) element ).getType();
- if ( temp == null )
- {
- value = new Integer( 0 );
- }
- else
- {
- for ( int i = 0; i < dataTypeDisplayNames.length; i++ )
- {
- if ( temp.equals( dataTypeDisplayNames[i] ) )
- {
- value = new Integer( i );
- break;
- }
- }
- }
+ doEdit( );
}
-
- }
- catch ( Exception ex )
- {
- ExceptionHandler.showException( getShell( ),
- Messages.getString( "error.label" ),
- ex.getMessage( ),
- ex );
- }
- if ( value == null )
- {
- value = ""; //$NON-NLS-1$
- }
- return value;
- }
+ } );
- public void modify( Object element, String property, Object value )
- {
- Object actualElement = ( (TableItem) element ).getData( );
- if ( value != null )
- {
- if ( property.equals( COLUMN_NAME ) )
- {
- if ( isUniqueName( (String) value,
- (ColumnMappingElement) actualElement ) )
- {
- if ( columnMap.get( ( (ColumnMappingElement) actualElement ).getColumnName( ) ) != null )
- {
- columnMap.remove( ( (ColumnMappingElement) actualElement ).getColumnName( ) );
- ( (ColumnMappingElement) actualElement ).setColumnName( (String) value );
- columnMap.put( (String) value, actualElement );
- }
- else
- ( (ColumnMappingElement) actualElement ).setColumnName( (String) value );
- }
- else
- return;
- }
- else if ( property.equals( XPATH_NAME ) )
- {
- if( !isXpathValid(((String)value)) )
- {
- setDetailsMessage( Messages.getFormattedString( "error.invalidXpath",
- new Object[]{
- value
- } ),
- IMessageProvider.ERROR );
- return;
- }
- else
- ( (ColumnMappingElement) actualElement ).setXPath( (String) value );
- }
- else if ( property.equals( TYPE_NAME ) )
- {
- int selectedType = ((Integer)value).intValue();
-
- ( (ColumnMappingElement) actualElement ).setType( dataTypeDisplayNames[selectedType] );
- }
- columnMappingTable.getViewer( )
- .update( ( (TableItem) element ).getData( ), null );
- if ( actualElement instanceof ColumnMappingElement )
- {
- if ( newColumn != null
- && newColumn.getColumnName( ) != null
- && newColumn.getColumnName( ).trim( ).length( ) > 0 )
- {
- columnMap.put( newColumn.getColumnName( ), newColumn );
- columnMappingList.add( newColumn );
- clearNewColumnMapping( );
- columnMappingTable.getViewer( ).refresh( );
- setPageProperties( );
- }
-
- refreshXMLConnection( );
- }
- }
- }
- } );
}
/**
@@ -1156,12 +1273,6 @@
str );
}
- private void clearNewColumnMapping( )
- {
- newColumn = null;
- }
-
-
/**
*
* @return
@@ -1272,7 +1383,6 @@
ti.setText( 1, c2 );
ti.setText( 2, c3 );
}
- clearNewColumnMapping( );
columnMappingTable.getViewer( ).refresh( );
}
@@ -1308,34 +1418,28 @@
String value = null;
try
{
- if ( element != newColumn )
+ switch ( columnIndex )
{
- switch ( columnIndex )
+ case 0 :
{
- case 0 :
- {
- value = (String) ( (ColumnMappingElement) element ).getColumnName( ); //$NON-NLS-1$
- break;
- }
- case 1 :
- {
- value = (String) ( (ColumnMappingElement) element ).getXPath( );
- break;
- }
- case 2 :
- {
- value = (String) ( (ColumnMappingElement) element ).getType( ); //$NON-NLS-1$
- break;
- }
+ value = (String) ( (ColumnMappingElement) element ).getColumnName( ); //$NON-NLS-1$
+ break;
}
- }
- else if ( columnIndex == 0 )
- {
- value = Messages.getString( "ColumnMappingDialog.prompt.new" );
+ case 1 :
+ {
+ value = (String) ( (ColumnMappingElement) element ).getXPath( );
+ break;
+ }
+ case 2 :
+ {
+ value = (String) ( (ColumnMappingElement) element ).getType( ); //$NON-NLS-1$
+ break;
+ }
}
}
catch ( Exception ex )
{
+ logger.log( Level.INFO, ex.getMessage( ), ex );
ExceptionHandler.showException( getShell( ),
Messages.getString( "error.label" ),
ex.getMessage( ),
@@ -1364,17 +1468,15 @@
if( (!dataFileExist)&&(dataSourceXmlDataFile != null && dataSourceXmlDataFile.toString( ).trim( ).length( ) > 0) )
dataFileExist = true;
-
+
columnMappingExist = ( columnMappingList != null && columnMappingList.size( ) > 0 );
- boolean active = columnMappingExist && dataFileExist;
+ columnMappingTable.getEditButton( ).setEnabled( columnMappingExist );
columnMappingTable.getDownButton( ).setEnabled( columnMappingExist );
columnMappingTable.getUpButton( ).setEnabled( columnMappingExist );
columnMappingTable.getRemoveButton( ).setEnabled( columnMappingExist );
columnMappingTable.getRemoveMenuItem( ).setEnabled( columnMappingExist );
columnMappingTable.getRemoveAllMenuItem( )
.setEnabled( columnMappingExist );
- previewViewer.getRefreshButton( ).setEnabled( active );
- previewViewer.getRefreshMenu( ).setEnabled( active );
setPageComplete( columnMappingExist );
}
@@ -1390,6 +1492,7 @@
}
catch ( OdaException e )
{
+ logger.log( Level.INFO, e.getMessage( ), e );
}
return design;
}
@@ -1476,4 +1579,114 @@
{
XMLInformationHolder.destory( );
}
+
+ /**
+ * Create a single column mapping element by the specific ATreeNode object and its path
+ *
+ * @param node
+ * @param path
+ * @return
+ */
+ private ColumnMappingElement createSingleElement( ATreeNode node, String path )
+ {
+ ColumnMappingElement columnElement = new ColumnMappingElement( );
+ columnElement.setColumnName( node.getValue( ).toString( ) );
+ columnElement.setXPath( path );
+ String type = null;
+ try
+ {
+ type = node.getDataType( );
+ if( type == null )
+ {
+ type = dataTypeDisplayNames[6];
+ }
+ }
+ catch ( OdaException e )
+ {
+ type = dataTypeDisplayNames[6];
+ }
+ columnElement.setType( type );
+ return columnElement;
+ }
+
+ /**
+ * @param columnElement
+ */
+ private void updateColumnMappingElement( ColumnMappingElement columnElement )
+ {
+ addNewColumnElement( columnElement );
+ refreshColumnMappingViewer( );
+ setPageProperties( );
+ }
+
+ /**
+ * @param columnElement
+ */
+ private void addNewColumnElement( ColumnMappingElement columnElement )
+ {
+ int index = 0;
+ String columnName = columnElement.getColumnName( );
+ while ( !isUniqueName( columnName, columnElement ) )
+ {
+ index++;
+ String alias = columnName + "_" + index;
+ if ( isUniqueName( alias, columnElement ) )
+ {
+ columnElement.setColumnName( alias );
+ columnMap.put( alias, columnElement );
+ break;
+ }
+ }
+ if ( index == 0 )
+ {
+ columnMap.put( columnName, columnElement );
+ }
+ columnMappingList.add( columnElement );
+ setXMLInformationHolderProps( );
+ }
+
+ /**
+ * Set the XMLInformationHolder properties
+ *
+ */
+ private void setXMLInformationHolderProps( )
+ {
+ String relationInfo = XMLInformationHolder.getPropertyValue( Constants.CONST_PROP_RELATIONINFORMATION );
+ if ( relationInfo != null && relationInfo.trim( ).length( ) > 0 )
+ {
+ String tableInfo = XMLRelationInfoUtil.getTableRelationInfo( relationInfo,
+ tableName );
+ if ( tableInfo != null && tableInfo.trim( ).length( ) > 0 )
+ XMLInformationHolder.setPropertyValue( Constants.CONST_PROP_RELATIONINFORMATION,
+ XMLRelationInfoUtil.replaceInfo( tableName,
+ saveQueryString( ),
+ relationInfo ) );
+ else
+ XMLInformationHolder.setPropertyValue( Constants.CONST_PROP_RELATIONINFORMATION,
+ XMLRelationInfoUtil.concatRelationInfo( relationInfo,
+ saveQueryString( ) ) );
+ }
+ else
+ {
+ XMLInformationHolder.setPropertyValue( Constants.CONST_PROP_RELATIONINFORMATION,
+ saveQueryString( ) );
+ }
+ }
+
+ /**
+ * Handler for selecting a tree item
+ *
+ */
+ private boolean handleSelectedItem( TreeItem selectedItem )
+ {
+ if ( selectedItem.getData( ) != null
+ && selectedItem.getData( ) instanceof TreeNodeData )
+ {
+ ATreeNode aTreeNode = ( (TreeNodeData) selectedItem.getData( ) ).getTreeNode( );
+ addChildrenElements( aTreeNode, selectedItem );
+ return true;
+ }
+ return false;
+ }
+
}
diff --git a/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/ColumnMappingTableViewer.java b/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/ColumnMappingTableViewer.java
index b1ef8e5..d811b1d 100644
--- a/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/ColumnMappingTableViewer.java
+++ b/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/ColumnMappingTableViewer.java
@@ -31,20 +31,20 @@
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
/**
* Table viewer of column mapping
*
- * @version $Revision: 1.1 $ $Date: 2007/06/25 16:33:23 $
+ * @version $Revision: 1.5 $ $Date: 2007/09/12 18:49:43 $
*/
public final class ColumnMappingTableViewer
{
private TableViewer viewer;
private Composite mainControl;
+ private Button btnEdit;
private Button btnRemove;
private Button btnUp;
private Button btnDown;
@@ -52,7 +52,7 @@
private MenuItem itmRemoveAll;
/**
- * column mapping table viewer. it supplys the button of remove, up , down
+ * column mapping table viewer. it supplies the button of remove, up , down
* and the menu of remove,removeAll....
*/
public ColumnMappingTableViewer( Composite parent, boolean showMenus,
@@ -64,7 +64,8 @@
mainControl.setLayout( layout );
GridData data = null;
- viewer = new TableViewer( mainControl, SWT.FULL_SELECTION );
+ viewer = new TableViewer( mainControl, SWT.MULTI
+ | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER );
data = new GridData( GridData.FILL_BOTH );
viewer.getControl( ).setLayoutData( data );
@@ -81,19 +82,30 @@
layout.verticalSpacing = 20;
btnComposite.setLayout( btnLayout );
- GridData btnData = new GridData( GridData.CENTER );
- btnData.widthHint = 20;
+ GridData btnData = new GridData( );
+ btnData.widthHint = 50;
btnData.heightHint = 20;
- btnUp = new Button( btnComposite, SWT.ARROW | SWT.UP );
- btnUp.setLayoutData( btnData );
+ btnEdit = new Button( btnComposite, SWT.WRAP );
+ btnEdit.setText( Messages.getString( "menu.button.edit" ) );
+ btnEdit.setLayoutData( btnData );
+ btnEdit.setEnabled( false );
+ btnEdit.addSelectionListener( new SelectionListener( ) {
+
+ public void widgetSelected( SelectionEvent e )
+ {
+ }
+
+ public void widgetDefaultSelected( SelectionEvent e )
+ {
+ }
+
+ } );
btnData = new GridData( GridData.CENTER );
- btnData.widthHint = 20;
+ btnData.widthHint = 50;
btnData.heightHint = 20;
- btnRemove = new Button( btnComposite, SWT.PUSH );
- btnRemove.setImage( PlatformUI.getWorkbench( )
- .getSharedImages( )
- .getImage( ISharedImages.IMG_TOOL_DELETE ) );
+ btnRemove = new Button( btnComposite, SWT.WRAP );
+ btnRemove.setText( Messages.getString( "menu.button.remove" ) );
btnRemove.setLayoutData( btnData );
btnRemove.addSelectionListener( new SelectionListener( ) {
@@ -107,16 +119,20 @@
} );
- btnData = new GridData( GridData.CENTER );
- btnData.widthHint = 20;
- btnData.heightHint = 20;
- btnDown = new Button( btnComposite, SWT.ARROW | SWT.DOWN );
+ Label blankLabel = new Label( btnComposite, SWT.WRAP );
+ blankLabel.setLayoutData( btnData );
+
+ btnUp = new Button( btnComposite, SWT.WRAP );
+ btnUp.setText( Messages.getString( "menu.button.up" ) );
+ btnUp.setLayoutData( btnData );
+
+ btnDown = new Button( btnComposite, SWT.WRAP );
+ btnDown.setText( Messages.getString( "menu.button.down" ) );
btnDown.setLayoutData( btnData );
btnDown.addSelectionListener( new SelectionListener( ) {
public void widgetSelected( SelectionEvent e )
{
-
}
public void widgetDefaultSelected( SelectionEvent e )
@@ -215,6 +231,16 @@
}
/**
+ * get the edit button
+ *
+ * @return
+ */
+ public Button getEditButton( )
+ {
+ return btnEdit;
+ }
+
+ /**
* get the remove menu item
*
* @return
@@ -235,7 +261,7 @@
}
/**
- * Accoring to the relation infomation of the query, refresh the table items
+ * According to the relation information of the query, refresh the table items
*
* @param info
* @param tableName
diff --git a/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/ResultSetTableViewer.java b/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/ResultSetTableViewer.java
index 62f2a71..b96e6b5 100644
--- a/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/ResultSetTableViewer.java
+++ b/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/ResultSetTableViewer.java
@@ -26,35 +26,25 @@
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
/**
* Table viewer of result set, it contains refresh action to get the results of
* xml file.
*
- * @version $Revision: 1.2 $ $Date: 2007/07/13 02:50:52 $
+ * @version $Revision: 1.7 $ $Date: 2007/09/12 18:49:43 $
*/
public final class ResultSetTableViewer
{
private Table viewer;
private Composite mainControl;
- private Button btnRefresh;
- private MenuItem itmRefresh;
private String[][] resultSet;
private TableColumn column;
private final int MAX_ROW = 500;
@@ -72,82 +62,14 @@
GridData data = null;
viewer = new Table( mainControl, SWT.FULL_SELECTION );
- data = new GridData( GridData.FILL_BOTH );
+ data = new GridData( );
+ data.widthHint = 600;
+ data.heightHint = 400;
viewer.setLayoutData( data );
viewer.setHeaderVisible( true );
viewer.setLinesVisible( true );
-
- if ( showButtons )
- {
- Composite btnComposite = new Composite( mainControl, SWT.NONE );
- data = new GridData( );
- data.verticalAlignment = SWT.CENTER;
- btnComposite.setLayoutData( data );
- GridLayout btnLayout = new GridLayout( );
- layout.verticalSpacing = 20;
- btnComposite.setLayout( btnLayout );
-
- GridData btnData = new GridData( GridData.CENTER );
- btnData.widthHint = 20;
- btnData.heightHint = 20;
- btnRefresh = new Button( btnComposite, SWT.PUSH );
- //TODO to externalize into message file
- btnRefresh.setToolTipText( "Preview the result set" );
- btnRefresh.setImage( PlatformUI.getWorkbench( )
- .getSharedImages( )
- .getImage( ISharedImages.IMG_DEF_VIEW ) );
- btnRefresh.setLayoutData( btnData );
- btnRefresh.addSelectionListener( new SelectionListener( ) {
-
- public void widgetSelected( SelectionEvent e )
- {
- btnRefresh.setEnabled( false );
- retrieveResult();
- btnRefresh.setEnabled( true );
- }
-
- public void widgetDefaultSelected( SelectionEvent e )
- {
- }
-
- } );
- }
-
- if ( showMenus )
- {
- Menu menu = new Menu( viewer );
-
- itmRefresh = new MenuItem( menu, SWT.NONE );
- itmRefresh.setText( Messages.getString( "button.refresh" ) ); //$NON-NLS-1$
- itmRefresh.addSelectionListener( new SelectionAdapter( ) {
-
- public void widgetSelected( SelectionEvent e )
- {
- retrieveResult( );
- }
-
- } );
- viewer.setMenu( menu );
- }
- if ( enableKeyStrokes )
- {
- viewer.addKeyListener( new KeyListener( ) {
-
- public void keyPressed( KeyEvent e )
- {
- }
-
- public void keyReleased( KeyEvent e )
- {
- if ( e.keyCode == SWT.ALT )
- {
- retrieveResult( );
- }
- }
-
- } );
- }
+ retrieveResult( );
}
private void retrieveResult( )
@@ -466,22 +388,4 @@
{
return mainControl;
}
-
- /**
- * get refresh button
- * @return
- */
- public Button getRefreshButton( )
- {
- return btnRefresh;
- }
-
- /**
- * get refresh menuItem
- * @return
- */
- public MenuItem getRefreshMenu( )
- {
- return itmRefresh;
- }
}
diff --git a/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/TreeNodeDataUtil.java b/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/TreeNodeDataUtil.java
new file mode 100644
index 0000000..af69c06
--- /dev/null
+++ b/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/TreeNodeDataUtil.java
@@ -0,0 +1,76 @@
+
+package org.eclipse.datatools.enablement.oda.xml.ui.wizards;
+
+import org.eclipse.datatools.enablement.oda.xml.ui.UiPlugin;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * This is a utility class that serves for the Tree Node.
+ *
+ */
+public class TreeNodeDataUtil
+{
+
+ private static Image sourceFileImage, xmlElementImage, columnImage;
+ private static String SOURCE_FILE_ICON = "xPathChoosePage.FileNameIcon";
+ private static String XML_ELEMENT_ICON = "xPathChoosePage.XMLElementIcon";
+ private static String COLUMN_ICON = "xPathChoosePage.ColumnIcon";
+
+ static
+ {
+ try
+ {
+ ImageRegistry reg = JFaceResources.getImageRegistry( );
+ reg.put( SOURCE_FILE_ICON,
+ ImageDescriptor.createFromFile( UiPlugin.class,
+ "icons/XML_file.gif" ) );//$NON-NLS-1$
+ reg.put( XML_ELEMENT_ICON,
+ ImageDescriptor.createFromFile( UiPlugin.class,
+ "icons/XML_element.gif" ) );//$NON-NLS-1$
+ reg.put( COLUMN_ICON,
+ ImageDescriptor.createFromFile( UiPlugin.class,
+ "icons/XML_column.gif" ) );//$NON-NLS-1$
+ sourceFileImage = JFaceResources.getImage( SOURCE_FILE_ICON );
+ xmlElementImage = JFaceResources.getImage( XML_ELEMENT_ICON );
+ columnImage = JFaceResources.getImage( COLUMN_ICON );
+ }
+ catch ( Exception e )
+ {
+
+ }
+ }
+
+ /**
+ * Return source file icon image
+ *
+ * @return Image
+ */
+ public static Image getSourceFileImage( )
+ {
+ return sourceFileImage;
+ }
+
+ /**
+ * Return XML element icon image
+ *
+ * @return Image
+ */
+ public static Image getXmlElementImage( )
+ {
+ return xmlElementImage;
+ }
+
+ /**
+ * Return column icon image
+ *
+ * @return Image
+ */
+ public static Image getColumnImage( )
+ {
+ return columnImage;
+ }
+
+}
diff --git a/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/TreePopulationUtil.java b/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/TreePopulationUtil.java
index 1aa333e..8ac9255 100644
--- a/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/TreePopulationUtil.java
+++ b/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/TreePopulationUtil.java
@@ -13,6 +13,7 @@
import org.eclipse.datatools.connectivity.oda.OdaException;
import org.eclipse.datatools.enablement.oda.xml.util.ui.ATreeNode;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
@@ -43,7 +44,24 @@
treeItem = new TreeItem( (TreeItem)tree, 0 );
else
treeItem = new TreeItem((Tree)tree,0);
- TreeNodeData treeNode = new TreeNodeData((ATreeNode) node[i]);
+ ATreeNode aTreeNode = (ATreeNode) node[i];
+ TreeNodeData treeNode = new TreeNodeData( aTreeNode );
+ if( aTreeNode.getType( ) == ATreeNode.ELEMENT_TYPE )
+ {
+ if ( aTreeNode.getParent( ).getValue( ).equals( "ROOT" ) )
+ {
+ treeItem.setImage( TreeNodeDataUtil.getSourceFileImage( ) );
+ }
+ else if ( aTreeNode.getChildren( ).length == 0 )
+ {
+ treeItem.setImage( TreeNodeDataUtil.getColumnImage( ) );
+ }
+ else
+ {
+ treeItem.setImage( TreeNodeDataUtil.getXmlElementImage( ) );
+ }
+
+ }
treeItem.setData( treeNode );
int type = treeNode.getTreeNode().getType( );
diff --git a/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/XMLDataPreviewDialog.java b/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/XMLDataPreviewDialog.java
new file mode 100644
index 0000000..aeb49fb
--- /dev/null
+++ b/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/XMLDataPreviewDialog.java
@@ -0,0 +1,98 @@
+
+package org.eclipse.datatools.enablement.oda.xml.ui.wizards;
+
+import org.eclipse.datatools.enablement.oda.xml.ui.i18n.Messages;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.TrayDialog;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * This dialog displays the sample XML data for the purpose of preview
+ *
+ */
+public class XMLDataPreviewDialog extends TrayDialog
+{
+
+ private ResultSetTableViewer previewViewer;
+
+ /**
+ * The constructor of XMLDataPreviewDialog
+ *
+ * @param shell
+ */
+ protected XMLDataPreviewDialog( Shell shell )
+ {
+ super( shell );
+ }
+
+ /**
+ * Create table viewer composite
+ *
+ * @param parent
+ */
+ public void createTableViewer( Composite parent )
+ {
+ previewViewer = new ResultSetTableViewer( parent, true, true, true );
+ previewViewer.getViewer( ).setHeaderVisible( true );
+ previewViewer.getControl( )
+ .setLayoutData( new GridData( GridData.FILL_BOTH ) );
+ }
+
+ /**
+ * Create dialog area composite
+ *
+ * @param parent
+ */
+ protected Control createDialogArea( Composite parent )
+ {
+ Composite control = (Composite) super.createDialogArea( parent );
+ createTableViewer( control );
+ return control;
+
+ }
+
+ /**
+ * Create the button bar of the dialog, which only contains one "close"
+ * button
+ *
+ * @param parent
+ */
+ protected void createButtonsForButtonBar( Composite parent )
+ {
+ createButton( parent,
+ IDialogConstants.CLOSE_ID,
+ IDialogConstants.CLOSE_LABEL,
+ true );
+
+ }
+
+ /**
+ * Configure the shell
+ *
+ * @param parent
+ */
+ protected void configureShell( Shell shell )
+ {
+ super.configureShell( shell );
+ shell.setText( Messages.getString( "XMLDataPreviewDialog.title" ) );
+ }
+
+ /**
+ * Add listener to the "close" button
+ *
+ * @param parent
+ */
+ protected void buttonPressed( int buttonId )
+ {
+ if ( buttonId == IDialogConstants.CLOSE_ID )
+ {
+ getShell( ).close( );
+ }
+ else
+ super.buttonPressed( buttonId );
+ }
+
+}
diff --git a/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/XPathChoosePage.java b/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/XPathChoosePage.java
index 723f253..85064ac 100644
--- a/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/XPathChoosePage.java
+++ b/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/XPathChoosePage.java
@@ -27,7 +27,6 @@
import org.eclipse.datatools.enablement.oda.xml.util.ui.SchemaPopulationUtil;
import org.eclipse.datatools.enablement.oda.xml.util.ui.XPathPopulationUtil;
import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -38,17 +37,18 @@
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.PlatformUI;
/**
* Root xpath choose page. It expands the xml tree list to choose the prefered
@@ -58,11 +58,14 @@
public class XPathChoosePage extends DataSetWizardPage
{
private static String DEFAULT_MESSAGE = Messages.getString( "wizard.defaultMessage.selectXPath" );
+ private static final String PATH_SEPERATOR = "/";
private transient Tree availableXmlTree;
- private transient Button btnAdd;
- private transient Composite btnComposite;
- private transient Text xmlPathText;
+ private transient Composite centerComposite;
+ private Button absolutePathButton;
+ private Button anyLocationButton;
+ private Button customButton;
+ private Combo xmlPathField;
private transient Group treeGroup;
private transient Group rightGroup;
@@ -75,6 +78,12 @@
private String rootPath;
private String initRootPath;
+ private Label absolutePathLabel;
+ private Label anyLocationLabel;
+ private Label customPathLabel;
+
+ private List xpathList;
+
/**
* @param string
*/
@@ -133,7 +142,8 @@
backupRootPath( );
if ( rootPath != null && rootPath.length( ) > 0 )
- xmlPathText.setText( rootPath );
+ xmlPathField.setText( rootPath );
+ xpathList = XPathPopulationUtil.getPathList( rootPath );
}
private void backupRootPath( )
@@ -148,7 +158,7 @@
*/
protected void refresh( DataSetDesign dataSetDesign )
{
- DEFAULT_MESSAGE = Messages.getString( "xPathChoosePage.messages.rowMapping" );
+ DEFAULT_MESSAGE = Messages.getString( "xPathChoosePage.messages.elementSelection.label" );
if ( XMLInformationHolder.hasDestroyed( ) )
XMLInformationHolder.start( dataSetDesign );
@@ -184,43 +194,12 @@
FormData data = new FormData( );
data.left = new FormAttachment( treeGroup, 5 );
data.bottom = new FormAttachment( 50 );
+ data.width = 20;
- btnComposite = new Composite( composite, SWT.NONE );
- btnComposite.setLayoutData( data );
- FillLayout btnLayout = new FillLayout( SWT.VERTICAL );
- btnLayout.spacing = 3;
- btnComposite.setLayout( btnLayout );
-
- btnAdd = new Button( btnComposite, SWT.NONE );
- btnAdd.setText( ">" ); //$NON-NLS-1$
- btnAdd.setEnabled( false );
-
- //TODO To externalize into messages
- btnAdd.setToolTipText( "Use the selected node as XPath expression" );
- btnAdd.addSelectionListener( new SelectionAdapter( ) {
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- public void widgetSelected( SelectionEvent e )
- {
-
- List xpathList = getSelectedXPath( );
- if ( xpathList != null )
- {
- RowMappingDialog dialog = new RowMappingDialog( PlatformUI.getWorkbench( )
- .getDisplay( )
- .getActiveShell( ),
- Messages.getString( "RowMappingDialog.title" ),
- xpathList ); //$NON-NLS-1$
- if ( dialog.open( ) == Window.OK )
- {
- rootPath = dialog.getSelectedPath( );
- xmlPathText.setText( rootPath );
- }
- }
- }
- } );
+ centerComposite = new Composite( composite, SWT.NONE );
+ centerComposite.setLayoutData( data );
+ FillLayout centerLayout = new FillLayout( );
+ centerComposite.setLayout( centerLayout );
createRightGroup( composite );
return composite;
@@ -261,10 +240,18 @@
}
}
if ( selectedItem != null )
- btnAdd.setEnabled( true );
+ {
+ xpathList = getSelectedXPathList( );
+ if( customButton.getSelection( ) )
+ {
+ resetCustomXMLPathField( );
+ }
+ resetButtonsAndLabels( true );
+ }
else
- btnAdd.setEnabled( false );
-
+ {
+ resetButtonsAndLabels( false);
+ }
}
} );
@@ -280,60 +267,240 @@
{
FormData data = new FormData( );
data.top = new FormAttachment( 0, 5 );
- data.left = new FormAttachment( btnComposite, 5 );
+ data.left = new FormAttachment( centerComposite, 5 );
data.right = new FormAttachment( 100, -5 );
data.bottom = new FormAttachment( 100, -5 );
+
rightGroup = new Group( composite2, SWT.NONE );
-
- rightGroup.setLayout( new FormLayout( ) );
- rightGroup.setText( Messages.getString( "xPathChoosePage.messages.rowMapping" ) );
+ GridLayout layout = new GridLayout( );
+ layout.numColumns = 2;
+ rightGroup.setLayout( layout );
+ rightGroup.setText( Messages.getString( "xPathChoosePage.messages.elementSelection.label" ) );
rightGroup.setLayoutData( data );
+
+ GridData buttonGd = new GridData( );
+ buttonGd.verticalAlignment = SWT.BEGINNING;
+ buttonGd.verticalIndent = 10;
+
+ GridData labelGd = new GridData( GridData.FILL_HORIZONTAL );
+ labelGd.verticalIndent = 10;
- data = new FormData( );
- data.top = new FormAttachment( 0, 5 );
- data.left = new FormAttachment( 0, 5 );
- data.right = new FormAttachment( 100, -5 );
+ absolutePathButton = new Button( rightGroup, SWT.RADIO | SWT.WRAP );
+ absolutePathButton.setLayoutData( buttonGd );
+ absolutePathLabel = new Label( rightGroup, SWT.WRAP );
+ absolutePathLabel.setLayoutData( labelGd );
+ anyLocationButton = new Button( rightGroup, SWT.RADIO | SWT.WRAP );
+ anyLocationButton.setLayoutData( buttonGd );
+ anyLocationLabel = new Label( rightGroup, SWT.WRAP );
+ anyLocationLabel.setLayoutData( labelGd );
+ customButton = new Button( rightGroup, SWT.RADIO | SWT.WRAP );
+ customButton.setLayoutData( buttonGd );
+ customButton.setSelection( true );
+ customPathLabel = new Label( rightGroup, SWT.WRAP );
+ customPathLabel.setLayoutData( labelGd );
+ customPathLabel.setText( Messages.getString( "xPathChoosePage.messages.elementSelection.item.custom" ) );
+
+ setLabelValuesAndListeners( rightGroup );
+
+ Label blankLabel = new Label( rightGroup, SWT.NONE );
+ GridData txtGridData = new GridData();
+ txtGridData.widthHint = 200;
+ xmlPathField = new Combo( rightGroup, SWT.DROP_DOWN );
+ xmlPathField.setLayoutData( txtGridData );
+ xmlPathField.setVisible( true );
+ xmlPathField.addSelectionListener( new SelectionAdapter( ) {
- final Label label = new Label( rightGroup, SWT.NONE );
- label.setText( Messages.getString( "xPathChoosePage.messages.xPathExpression" ) );
- label.setLayoutData( data );
-
- data = new FormData( );
- data.top = new FormAttachment( 0, 25 );
- data.left = new FormAttachment( 0, 5 );
- data.right = new FormAttachment( 100, -5 );
- xmlPathText = new Text( rightGroup, SWT.BORDER );
- xmlPathText.setLayoutData( data );
-
- xmlPathText.addModifyListener( new ModifyListener( ) {
+ public void widgetSelected( SelectionEvent e )
+ {
+ }
+ } );
+ xmlPathField.addModifyListener( new ModifyListener( ) {
public void modifyText( ModifyEvent e )
{
- rootPath = xmlPathText.getText( );
+ rootPath = xmlPathField.getText( );
+ resetXPathPropInHandle( rootPath );
setPageStatus( );
}
} );
}
/**
+ * reset the custom xpath expression field
+ *
+ */
+ private void resetCustomXMLPathField( )
+ {
+ xmlPathField.removeAll( );
+ if ( xpathList != null )
+ {
+ if ( xpathList.size( ) < 2 )
+ {
+
+ }
+ xmlPathField.setText( xpathList.get( 0 ).toString( ) );
+ xmlPathField.add( xpathList.get( 0 ).toString( ) );
+ xmlPathField.add( xpathList.get( 1 ).toString( ) );
+ }
+ rootPath = xmlPathField.getText( );
+ resetXPathPropInHandle( rootPath );
+ setPageStatus( );
+ }
+
+ /**
+ *
+ */
+ private void setLabelValuesAndListeners( Composite composite )
+ {
+ if ( this.selectedItem != null )
+ {
+ xpathList = getSelectedXPathList( );
+ if ( xpathList.size( ) < 2 )
+ {
+ setMessage( Messages.getString( "error.xpath.getPathList" ), ERROR );
+ }
+ resetButtonsAndLabels( true );
+ }
+ else
+ {
+ resetButtonsAndLabels( false );
+ }
+ absolutePathLabel.addListener( SWT.MouseDown, new Listener(){
+
+ public void handleEvent( Event event )
+ {
+ absolutePathButton.setSelection( true );
+ anyLocationButton.setSelection( false );
+ customButton.setSelection( false );
+ xmlPathField.setVisible( false );
+ }
+ });
+ anyLocationLabel.addListener( SWT.MouseDown, new Listener(){
+
+ public void handleEvent( Event event )
+ {
+ anyLocationButton.setSelection( true );
+ absolutePathButton.setSelection( false );
+ customButton.setSelection( false );
+ xmlPathField.setVisible( false );
+ }
+ });
+ customPathLabel.addListener( SWT.MouseDown, new Listener(){
+
+ public void handleEvent( Event event )
+ {
+ customButton.setSelection( true );
+ xmlPathField.setVisible( true );
+ absolutePathButton.setSelection( false );
+ anyLocationButton.setSelection( false );
+ xpathList = getSelectedXPathList( );
+ resetCustomXMLPathField( );
+ setPageStatus( );
+ }
+ });
+ absolutePathButton.addSelectionListener( new SelectionAdapter( ) {
+
+ public void widgetSelected( SelectionEvent e )
+ {
+ if ( absolutePathButton.getSelection( ) )
+ {
+ rootPath = xpathList.get( 0 ).toString( );
+ xmlPathField.setVisible( false );
+ }
+ }
+ } );
+ anyLocationButton.addSelectionListener( new SelectionAdapter( ) {
+
+ public void widgetSelected( SelectionEvent e )
+ {
+ if ( anyLocationButton.getSelection( ) )
+ {
+ rootPath = xpathList.get( 1 ).toString( );
+ xmlPathField.setVisible( false );
+ }
+ }
+ } );
+ customButton.addSelectionListener( new SelectionAdapter( ) {
+
+ public void widgetSelected( SelectionEvent e )
+ {
+ if ( customButton.getSelection( ) )
+ {
+ xmlPathField.setVisible( true );
+ xpathList = getSelectedXPathList( );
+ resetCustomXMLPathField( );
+ }
+ setPageStatus( );
+ }
+ } );
+ composite.layout( );
+ }
+
+ /**
+ *
+ */
+ private void resetButtonsAndLabels( boolean visible )
+ {
+ if ( visible )
+ {
+ absolutePathLabel.setText( Messages.getFormattedString( "xPathChoosePage.messages.elementSelection.item.absolutePath",
+ new String[]{
+ selectedItem.getText( ),
+ (String) xpathList.get( 0 )
+ } ) );
+ anyLocationLabel.setText( Messages.getFormattedString( "xPathChoosePage.messages.elementSelection.item.anyLocation",
+ new String[]{
+ selectedItem.getText( ),
+ (String) xpathList.get( 1 )
+ } ) );
+ }
+ else
+ {
+ absolutePathLabel.setText( Messages.getString( "xPathChoosePage.messages.elementSelection.disable.absolutePath" ) );
+ anyLocationLabel.setText( Messages.getString( "xPathChoosePage.messages.elementSelection.disable.anyLocation" ) );
+ }
+ absolutePathButton.setEnabled( visible );
+ absolutePathLabel.setEnabled( visible );
+ anyLocationButton.setEnabled( visible );
+ anyLocationLabel.setEnabled( visible );
+ }
+
+ /**
* get the standby XPath expression
*
* @return
*/
- protected List getSelectedXPath( )
+ protected List getSelectedXPathList( )
+ {
+ String path;
+ if ( this.selectedItem == null )
+ {
+ path = PATH_SEPERATOR + initRootPath;
+ }
+ else
+ {
+ path = getRootPath( );
+ }
+ return XPathPopulationUtil.getPathList( path );
+ }
+
+ /**
+ * @return root path string
+ */
+ private String getRootPath( )
{
TreeItem selected = this.selectedItem;
-
+
if ( selected.getData( ) instanceof TreeNodeData )
{
- ATreeNode node = ((TreeNodeData) selected.getData( )).getTreeNode();
+ ATreeNode node = ( (TreeNodeData) selected.getData( ) ).getTreeNode( );
if ( node.getType( ) == ATreeNode.ATTRIBUTE_TYPE )
{
return null;
}
else
{
- rootPath = "/" + selected.getText( );
+ rootPath = PATH_SEPERATOR + selected.getText( );
}
}
@@ -342,14 +509,14 @@
selected = selected.getParentItem( );
if ( selected.getData( ) instanceof TreeNodeData )
{
- ATreeNode node = ((TreeNodeData) selected.getData( )).getTreeNode();
+ ATreeNode node = ( (TreeNodeData) selected.getData( ) ).getTreeNode( );
if ( node.getType( ) == ATreeNode.ELEMENT_TYPE )
{
- rootPath = "/" + selected.getText( ) + rootPath;
+ rootPath = PATH_SEPERATOR + selected.getText( ) + rootPath;
}
}
}
- return XPathPopulationUtil.populateRootPath( rootPath );
+ return rootPath;
}
/**
@@ -387,9 +554,16 @@
// ).findResource( fileName,IResourceLocator.LIBRARY );
//
// if( url != null )
- treeNode = SchemaPopulationUtil.getSchemaTree( xsdFileName, xmlFileName,xmlEncoding, numberOfElement );
+ treeNode = SchemaPopulationUtil.getSchemaTree( xsdFileName,
+ xmlFileName,
+ xmlEncoding,
+ numberOfElement );
if ( treeNode == null || treeNode.getChildren( ).length == 0 )
{
+ if( treeNode.getValue( ).equals( "ROOT" ) )
+ {
+ initRootPath = (String)( (ATreeNode)treeNode.getChildren( )[0] ).getValue( );
+ }
OdaException ex = new OdaException( Messages.getString( "dataset.error.populateXMLTree" ) );
ExceptionHandler.showException( getShell( ),
Messages.getString( "error.label" ),
@@ -399,31 +573,42 @@
else
{
Object[] childs = treeNode.getChildren( );
- availableXmlTree.addListener(SWT.Expand, new Listener(){
+ initRootPath = (String)( (ATreeNode)childs[0] ).getValue( );
+ availableXmlTree.addListener( SWT.Expand, new Listener( ) {
- public void handleEvent(Event event) {
- TreeItem currentItem = (TreeItem)event.item;
-
- if ( ((TreeNodeData)currentItem.getData()).hasBeenExpandedOnce())
+ public void handleEvent( Event event )
+ {
+ TreeItem currentItem = (TreeItem) event.item;
+
+ if ( ( (TreeNodeData) currentItem.getData( ) ).hasBeenExpandedOnce( ) )
return;
-
- ((TreeNodeData)currentItem.getData()).setHasBeenExpandedOnce();
- currentItem.removeAll();
+
+ ( (TreeNodeData) currentItem.getData( ) ).setHasBeenExpandedOnce( );
+ currentItem.removeAll( );
try
{
- if ( (((TreeNodeData)currentItem.getData()).getTreeNode()).getChildren( ) != null
- && ((TreeNodeData)currentItem.getData()).getTreeNode().getChildren( ).length > 0 )
- TreePopulationUtil.populateTreeItems( currentItem, ((TreeNodeData)currentItem.getData()).getTreeNode().getChildren( ), false );
+ if ( ( ( (TreeNodeData) currentItem.getData( ) ).getTreeNode( ) ).getChildren( ) != null
+ && ( (TreeNodeData) currentItem.getData( ) ).getTreeNode( )
+ .getChildren( ).length > 0 )
+ TreePopulationUtil.populateTreeItems( currentItem,
+ ( (TreeNodeData) currentItem.getData( ) ).getTreeNode( )
+ .getChildren( ),
+ false );
}
catch ( OdaException e )
{
- // TODO Auto-generated catch block
- e.printStackTrace();
+ ExceptionHandler.showException( getShell( ),
+ Messages.getString( "error.label" ),
+ e.getMessage( ),
+ e );
}
- }});
-
- TreePopulationUtil.populateTreeItems( availableXmlTree, childs, false );
+ }
+ } );
+
+ TreePopulationUtil.populateTreeItems( availableXmlTree,
+ childs,
+ false );
}
}
}
@@ -435,10 +620,10 @@
e );
}
}
-
+
/**
* set page status based on row number
- *
+ *
*/
private void setPageStatus( )
{
@@ -446,7 +631,9 @@
{
setPageComplete( false );
this.setMessage( Messages.getFormattedString( "error.invalidXpath",
- new Object[]{rootPath == null ? "" : rootPath} ), IMessageProvider.ERROR );
+ new Object[]{
+ rootPath == null ? "" : rootPath
+ } ), IMessageProvider.ERROR );
}
else
{
@@ -479,7 +666,7 @@
* when XPath text has changed, reset the dataSetHandle.CONST_PROP_XPATH
*
*/
- private void resetXPathText( String pathStr )
+ private void resetXPathPropInHandle( String pathStr )
{
if ( pathStr != null && pathStr.trim( ).length( ) > 0 )
{
@@ -547,16 +734,18 @@
*/
private boolean isValid( )
{
- rootPath = xmlPathText.getText( );
+ rootPath = xmlPathField.getText( );
if ( !isRootPathValid( ) )
{
this.setMessage( Messages.getFormattedString( "error.invalidXpath",
- new Object[]{rootPath == null ? "" : rootPath} ), IMessageProvider.ERROR );
+ new Object[]{
+ rootPath == null ? "" : rootPath
+ } ), IMessageProvider.ERROR );
return false;
}
else
{
- resetXPathText( rootPath );
+ resetXPathPropInHandle( rootPath );
return true;
}
}
@@ -570,7 +759,7 @@
{
try
{
- resetXPathText( rootPath );
+ resetXPathPropInHandle( rootPath );
savePage( design );
}
catch ( OdaException e )
diff --git a/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/XmlDataSetSelectionPage.java b/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/XmlDataSetSelectionPage.java
index b34efd8..d57c374 100644
--- a/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/XmlDataSetSelectionPage.java
+++ b/plugins/org.eclipse.datatools.enablement.oda.xml.ui/src/org/eclipse/datatools/enablement/oda/xml/ui/wizards/XmlDataSetSelectionPage.java
@@ -54,8 +54,8 @@
private static final int ERROR_EMPTY_PATH = 2;
private transient Text folderLocation;
- private transient Button previewNumCheckBox;
- private transient Button useDataSourceXMLDataCheckBox;
+ private transient Button useXMLDataSourceButton;
+ private transient Button enterXMLSourceButton;
private transient Text numberText;
private transient Button browseFolderButton;
private boolean selected = false;
@@ -109,25 +109,13 @@
public Control createPageControl( Composite parent )
{
initializeDialogUnits( parent );
-
+
Composite composite = new Composite( parent, SWT.NONE );
- GridLayout layout = new GridLayout( 3, false );
+ GridLayout layout = new GridLayout( );
composite.setLayout( layout );
- GridData data = new GridData( GridData.HORIZONTAL_ALIGN_FILL
- | GridData.VERTICAL_ALIGN_FILL );
- data.horizontalSpan = 3;
- final Label label1 = new Label( composite, SWT.NONE );
- label1.setText( Messages.getString( "lable.selectXmlFile" ) ); //$NON-NLS-1$
- label1.setLayoutData( data );
-
- //GridData data;
- setupXMLFolderLocation( composite );
-
- setUseDataSourceXMLDataSelection( composite );
-
- setRowSelection( composite );
-
+ createRadioButtons( composite );
+ createNumOfLinesGroup( composite );
return composite;
}
@@ -158,7 +146,7 @@
this.folderLocation.setText( xmlFile );
enableFolderLocation( true );
}
- useDataSourceXMLDataCheckBox.setSelection( this.useDataSourceXMLDataSelected );
+ useXMLDataSourceButton.setSelection( this.useDataSourceXMLDataSelected );
String rowNumber = XMLInformationHolder.getPropertyValue( Constants.CONST_PROP_MAX_ROW );
try
@@ -171,7 +159,6 @@
else
{
selected = true;
- previewNumCheckBox.setSelection( selected );
numberText.setEnabled( selected );
numberText.setText( rowNumber );
}
@@ -187,38 +174,48 @@
}
/**
- * create row selection group
+ * Create radio button group
+ *
* @param composite
*/
- private void setRowSelection( Composite composite )
+ private void createRadioButtons( Composite composite )
{
- Composite rowSelectionGroup = new Composite( composite, SWT.NONE );
+ Composite radioGroup = new Composite( composite, SWT.NONE );
+ GridLayout gridLayout = new GridLayout( );
+ gridLayout.numColumns = 3;
+ radioGroup.setLayout( gridLayout );
+ GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
+ radioGroup.setLayoutData( gridData );
+ setupSourceSelectionButtons( radioGroup );
+ setupXMLFolderLocation( radioGroup );
+ }
+ /**
+ * Create number of lines' group
+ *
+ * @param composite
+ */
+ private void createNumOfLinesGroup( Composite composite )
+ {
+ Composite numOfLinesGroup = new Composite( composite, SWT.NONE );
GridLayout layout = new GridLayout( );
layout.numColumns = 3;
- layout.marginWidth = 0;
- layout.marginHeight = 3;
- layout.horizontalSpacing = 3;
- layout.verticalSpacing = 0;
+ numOfLinesGroup.setLayout( layout );
+ GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
+ gridData.verticalIndent = 8;
+ numOfLinesGroup.setLayoutData( gridData );
- rowSelectionGroup.setLayout( layout );
- rowSelectionGroup.setLayoutData( new GridData( GridData.HORIZONTAL_ALIGN_FILL
- | GridData.VERTICAL_ALIGN_FILL ) );
-
- previewNumCheckBox = new Button( rowSelectionGroup, SWT.CHECK );
GridData data = new GridData( );
- data.horizontalSpan = 1;
- previewNumCheckBox.setLayoutData( data );
- previewNumCheckBox.setText( Messages.getString( "label.preview" ) );
-
- numberText = new Text( rowSelectionGroup, SWT.BORDER );
- numberText.setEnabled( false );
+ Label previewLabel = new Label( numOfLinesGroup, SWT.NONE );
+ previewLabel.setText( Messages.getString( "label.preview" ) );
+ previewLabel.setData( data );
+
+ numberText = new Text( numOfLinesGroup, SWT.BORDER );
+ numberText.setEnabled( true );
data = new GridData( );
- data.horizontalSpan = 1;
Point minSize = numberText.computeSize( SWT.DEFAULT, SWT.DEFAULT, true );
- data.widthHint = Math.max( 50, minSize.x );
+ data.widthHint = Math.max( 60, minSize.x );
numberText.setLayoutData( data );
-
numberText.addModifyListener( new ModifyListener( ) {
public void modifyText( ModifyEvent e )
@@ -230,37 +227,8 @@
}
}
} );
- final Label label = new Label( rowSelectionGroup, SWT.BEGINNING );
+ final Label label = new Label( numOfLinesGroup, SWT.BEGINNING );
label.setText( Messages.getString( "xmlDataSetSelectionPage.messages.lineofdata" ) );
-
- previewNumCheckBox.addSelectionListener( new SelectionAdapter( ) {
-
- public void widgetSelected( SelectionEvent e )
- {
- selected = !selected;
- numberText.setEnabled( selected );
- if ( !selected )
- {
- maxRow = UNUSED_ROW_CACHE;
- setPageComplete( true );
- XMLInformationHolder.setPropertyValue( Constants.CONST_PROP_MAX_ROW,
- Integer.toString( maxRow ) );
- setPageStatus( );
- }
- else
- {
- if ( numberText.getText( ) != null
- && numberText.getText( ).trim( ).length( ) > 0 )
- {
- setPageStatus( );
- }
- }
- }
-
- public void widgetDefaultSelected( SelectionEvent e )
- {
- }
- } );
}
/**
@@ -269,27 +237,20 @@
*
* @param composite
*/
- private void setUseDataSourceXMLDataSelection( Composite composite )
+ private void setupSourceSelectionButtons( Composite composite )
{
- Composite rowSelectionGroup = new Composite( composite, SWT.NONE );
-
- GridLayout layout = new GridLayout( );
- layout.numColumns = 3;
- layout.marginWidth = 0;
- layout.marginHeight = 1;
- layout.horizontalSpacing = 0;
- layout.verticalSpacing = 0;
- GridData data = new GridData( GridData.HORIZONTAL_ALIGN_FILL
+ GridData data = new GridData( GridData.FILL_HORIZONTAL
| GridData.VERTICAL_ALIGN_FILL );
data.horizontalSpan = 3;
- rowSelectionGroup.setLayout( layout );
- rowSelectionGroup.setLayoutData( data );
-
- useDataSourceXMLDataCheckBox = new Button( rowSelectionGroup, SWT.CHECK );
-
- useDataSourceXMLDataCheckBox.setLayoutData( data );
- useDataSourceXMLDataCheckBox.setText( Messages.getString( "label.useXMLFileFromDataSource" ) );
- useDataSourceXMLDataCheckBox.addSelectionListener( new SelectionAdapter( ) {
+
+ useXMLDataSourceButton = new Button( composite, SWT.RADIO );
+
+ useXMLDataSourceButton.setSelection( true );
+ useXMLDataSourceButton.setText( Messages.getString( "label.useXMLFileFromDataSource" ) );
+
+ useXMLDataSourceButton.setLayoutData( data );
+
+ useXMLDataSourceButton.addSelectionListener( new SelectionAdapter( ) {
public void widgetSelected( SelectionEvent e )
{
@@ -313,6 +274,14 @@
{
}
} );
+
+ GridData sourceData = new GridData( GridData.FILL_HORIZONTAL
+ | GridData.VERTICAL_ALIGN_FILL );
+ sourceData.horizontalSpan = 3;
+ sourceData.verticalIndent = 8;
+ enterXMLSourceButton = new Button( composite, SWT.RADIO );
+ enterXMLSourceButton.setLayoutData( sourceData );
+ enterXMLSourceButton.setText( Messages.getString( "lable.selectXmlFile" ) );
}
/**
@@ -330,7 +299,7 @@
*/
private void setPageStatus( )
{
- if ( numberText == null || !this.previewNumCheckBox.getSelection( ) )
+ if ( numberText == null )
{
setMessage( DEFAULT_MESSAGE );
return;
@@ -361,6 +330,9 @@
*/
private int validateRowNumber( String maxRow )
{
+ if( maxRow.trim( ).length( ) == 0 )
+ return UNUSED_ROW_CACHE;
+
int rowNumber = 0;
try
{
@@ -386,12 +358,21 @@
*/
private void setupXMLFolderLocation( Composite composite )
{
+ GridData gridData = new GridData( );
+ composite.setLayoutData( gridData );
- GridData data = new GridData( GridData.FILL_HORIZONTAL
- | GridData.VERTICAL_ALIGN_FILL );
- data.horizontalSpan = 2;
- folderLocation = new Text( composite, SWT.BORDER | SWT.SINGLE );
- folderLocation.setLayoutData( data );
+ Button blankButton = new Button( composite, SWT.RADIO );
+ GridData blankBtnData = new GridData( );
+ blankBtnData.horizontalSpan = 1;
+ blankBtnData.horizontalAlignment = SWT.BEGINNING;
+ blankButton.setLayoutData( blankBtnData );
+ blankButton.setVisible( false );
+
+ GridData txtGridData = new GridData( );
+ txtGridData.horizontalSpan = 1;
+ txtGridData.widthHint = 450;
+ folderLocation = new Text( composite, SWT.BORDER );
+ folderLocation.setLayoutData( txtGridData );
setPageComplete( false );
folderLocation.addModifyListener( new ModifyListener( ) {
@@ -401,8 +382,11 @@
}
} );
+
+ GridData browseBtnData = new GridData( );
+ browseBtnData.horizontalSpan = 1;
browseFolderButton = new Button( composite, SWT.NONE );
- browseFolderButton.setText( Messages.getString( "file.choose" ) ); //$NON-NLS-1$
+ browseFolderButton.setText( Messages.getString( "file.choose" ) ); //$NON-NLS-1$
browseFolderButton.addSelectionListener( new SelectionAdapter( ) {
/*
@@ -648,6 +632,7 @@
*/
protected boolean canLeave( )
{
+ setPageStatus( );
return isValid( );
}
diff --git a/plugins/org.eclipse.datatools.enablement.oda.xml/META-INF/MANIFEST.MF b/plugins/org.eclipse.datatools.enablement.oda.xml/META-INF/MANIFEST.MF
index a9ade48..3be210b 100644
--- a/plugins/org.eclipse.datatools.enablement.oda.xml/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.datatools.enablement.oda.xml/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %plugin.name
Bundle-SymbolicName: org.eclipse.datatools.enablement.oda.xml;singleton:=true
-Bundle-Version: 1.0.3.200712262
+Bundle-Version: 1.0.3.200712291
Bundle-ClassPath: .
Bundle-Vendor: Eclipse.org
Bundle-Localization: plugin
diff --git a/plugins/org.eclipse.datatools.enablement.oda.xml/src/org/eclipse/datatools/enablement/oda/xml/util/ui/XPathPopulationUtil.java b/plugins/org.eclipse.datatools.enablement.oda.xml/src/org/eclipse/datatools/enablement/oda/xml/util/ui/XPathPopulationUtil.java
index fb6e7c4..9eb53e6 100644
--- a/plugins/org.eclipse.datatools.enablement.oda.xml/src/org/eclipse/datatools/enablement/oda/xml/util/ui/XPathPopulationUtil.java
+++ b/plugins/org.eclipse.datatools.enablement.oda.xml/src/org/eclipse/datatools/enablement/oda/xml/util/ui/XPathPopulationUtil.java
@@ -52,6 +52,35 @@
}
/**
+ * This method is used to populate the possible root path expressions List
+ *
+ * @param absolutePath
+ * must be the absolute path of root path
+ * @return List
+ */
+ public static List getPathList( String absolutePath )
+ {
+ if ( absolutePath == null )
+ return null;
+
+ List result = new ArrayList( );
+ result.add( absolutePath );
+ if ( absolutePath.startsWith( UtilConstants.XPATH_SLASH ) )
+ absolutePath = absolutePath.replaceFirst( UtilConstants.XPATH_SLASH,
+ "" );
+ String[] xPathFrags = absolutePath.split( UtilConstants.XPATH_SLASH );
+ if ( xPathFrags.length > 0 )
+ {
+ String temp = UtilConstants.XPATH_DOUBLE_SLASH;
+ temp = addXPathFragsToAString( xPathFrags,
+ xPathFrags.length - 1,
+ temp );
+ result.add( temp );
+ }
+ return result;
+ }
+
+ /**
* This method appends the items starting from certain index
* in an array to a String to build an XPath expression
*