[Ds-java-dev] svn commit r17074 - in
trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide:
dialog wizard
svn at wso2.org
svn at wso2.org
Thu May 15 22:44:15 PDT 2008
Author: samindaw
Date: Thu May 15 22:44:15 2008
New Revision: 17074
Log:
adding the edit/delete for input/output mappings in query and showing current mappings in tables
Modified:
trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddInputParamDialog.java
trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddOutputMappingDialog.java
trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddQueryDialog.java
trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepTwo.java
Modified: trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddInputParamDialog.java
==============================================================================
--- trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddInputParamDialog.java (original)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddInputParamDialog.java Thu May 15 22:44:15 2008
@@ -45,9 +45,14 @@
private Text nameText;
private Text ordinalText;
- public AddInputParamDialog(Shell parentShell) {
+ private boolean isEditMode=false;
+ private List tmpData;
+
+ public AddInputParamDialog(Shell parentShell, List data) {
super(parentShell);
- mappingData=new ArrayList();
+ isEditMode=(data!=null);
+ tmpData=data;
+ mappingData=new ArrayList();
resetMappingData();
}
@@ -58,6 +63,8 @@
mappingData.add("");
mappingData.add("");
}
+
+
/**
* Create the dialog area with the controls
*/
@@ -162,9 +169,26 @@
gd.horizontalSpan = 3;
label.setLayoutData(gd);
comboChanged();
+ if (isEditMode){
+ updateMappingData(tmpData);
+ mappingData=tmpData;
+ }
return super.createDialogArea(parent);
}
+ private void updateMappingData(List data){
+ int i=sqlTypeCombo.indexOf(
+ data.get(WSO2DataserviceWizardStepTwo.SQLQUERY_IMAP_SQL_TYPE).toString());
+ if (i>=0) sqlTypeCombo.select(i);
+
+ i=inOutTypeCombo.indexOf(
+ data.get(WSO2DataserviceWizardStepTwo.SQLQUERY_IMAP_INOUT_TYPE).toString());
+ if (i>=0) inOutTypeCombo.select(i);
+
+ nameText.setText(data.get(WSO2DataserviceWizardStepTwo.SQLQUERY_IMAP_NAME).toString());
+ ordinalText.setText(data.get(WSO2DataserviceWizardStepTwo.SQLQUERY_IMAP_ORDINAL).toString());
+ }
+
private void pathChanged() {
mappingData.set(WSO2DataserviceWizardStepTwo.SQLQUERY_IMAP_NAME,
nameText.getText().trim());
Modified: trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddOutputMappingDialog.java
==============================================================================
--- trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddOutputMappingDialog.java (original)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddOutputMappingDialog.java Thu May 15 22:44:15 2008
@@ -43,9 +43,14 @@
private Text sqlColumnNameText;
private Text outputFieldNameText;
+
+ private boolean isEditMode=false;
+ private List tmpData;
- public AddOutputMappingDialog(Shell parentShell) {
+ public AddOutputMappingDialog(Shell parentShell, List data) {
super(parentShell);
+ isEditMode=(data!=null);
+ tmpData=data;
mappingData=new ArrayList();
resetMappingData();
}
@@ -139,6 +144,10 @@
}
});
comboChanged();
+ if (isEditMode){
+ updateMappingData(tmpData);
+ mappingData=tmpData;
+ }
return super.createDialogArea(parent);
}
@@ -171,4 +180,15 @@
public List getMappingData(){
return mappingData;
}
+
+ private void updateMappingData(List data){
+ int i=mappingTypeCombo.indexOf(
+ data.get(WSO2DataserviceWizardStepTwo.SQLQUERY_OMAP_TYPE).toString());
+ if (i>=0) mappingTypeCombo.select(i);
+
+ sqlColumnNameText.setText(data.get(
+ WSO2DataserviceWizardStepTwo.SQLQUERY_OMAP_SQL_COL).toString());
+ outputFieldNameText.setText(data.get(
+ WSO2DataserviceWizardStepTwo.SQLQUERY_OMAP_OUT_FIELD).toString());
+ }
}
\ No newline at end of file
Modified: trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddQueryDialog.java
==============================================================================
--- trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddQueryDialog.java (original)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddQueryDialog.java Thu May 15 22:44:15 2008
@@ -39,6 +39,9 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.wso2.ws.dataservice.ide.WSO2DataservicePlugin;
import org.wso2.ws.dataservice.ide.constant.WSO2DataserviceWizardConstant;
@@ -46,7 +49,6 @@
import org.wso2.ws.dataservice.ide.util.FontUtil;
import org.wso2.ws.dataservice.ide.wizard.WSO2DataserviceWizardStepTwo;
-
/**
* Dialog represent the Add Query configuration UI
*/
@@ -60,6 +62,15 @@
private Text groupByElementText;
private Text rowNameText;
private Text rowNamespaceText;
+ private Table tableInputMaps;
+ private Button editButtonInputMap;
+ private Button deleteButtonInputMap;
+
+ private Table tableOutputMaps;
+ private Button editButtonOutputMap;
+ private Button deleteButtonOutputMap;
+
+
private PersistentDSContext dsContext;
private WSO2DataserviceWizardStepTwo parentPage;
private List configList;
@@ -137,12 +148,6 @@
label.setLayoutData(gd);
label = new Label(container, SWT.NULL);
- label.setText("");
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 3;
- label.setLayoutData(gd);
-
- label = new Label(container, SWT.NULL);
label.setFont(fontUtil.getArealBoldFont());
label.setText("SQL");
gd = new GridData();
@@ -172,6 +177,27 @@
}
});
+ tableInputMaps = new Table(container,
+ SWT.SINGLE|SWT.FULL_SELECTION|SWT.V_SCROLL|SWT.H_SCROLL);
+ tableInputMaps.setLinesVisible(true);
+ tableInputMaps.setHeaderVisible(true);
+ tableInputMaps.setLayoutData(gd);
+ declareColumn(tableInputMaps,100,"Name");
+ declareColumn(tableInputMaps,75,"SQL Type");
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 3;
+ gd.heightHint = 100;
+ tableInputMaps.setLayoutData(gd);
+ tableInputMaps.setVisible(false);
+ tableInputMaps.addSelectionListener(new SelectionAdapter(){
+ public void widgetSelected(SelectionEvent e) {
+ handleInputMapTableItemSelected();
+ }
+ });
+ tableInputMaps.redraw();
+ tableInputMaps.setVisible(true);
+ setTableVisibleStatus(tableInputMaps, false);
+
inputMappingButton = new Button(container, SWT.NULL);
inputMappingButton.setText("Add New Input Mapping");
gd = new GridData();
@@ -183,13 +209,31 @@
}
});
- label = new Label(container, SWT.HORIZONTAL | SWT.SEPARATOR);
+ editButtonInputMap = new Button(container, SWT.PUSH);
+ editButtonInputMap.setText("Edit Selected Mapping");
+ editButtonInputMap.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleInputMapEditQuery();
+ }
+ });
+ editButtonInputMap.setEnabled(false);
+
gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 3;
- label.setLayoutData(gd);
+ gd.horizontalSpan = 1;
+ editButtonInputMap.setLayoutData(gd);
- label = new Label(container, SWT.NULL);
- label.setText("");
+ deleteButtonInputMap= new Button(container, SWT.PUSH);
+ deleteButtonInputMap.setText("Delete Selected Mapping");
+ deleteButtonInputMap.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleInputMapDeleteQuery();
+ }
+ });
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 1;
+ deleteButtonInputMap.setLayoutData(gd);
+ deleteButtonInputMap.setEnabled(false);
+ label = new Label(container, SWT.HORIZONTAL | SWT.SEPARATOR);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 3;
label.setLayoutData(gd);
@@ -254,6 +298,28 @@
}
});
+ tableOutputMaps = new Table(container,
+ SWT.SINGLE|SWT.FULL_SELECTION|SWT.V_SCROLL|SWT.H_SCROLL);
+ tableOutputMaps.setLinesVisible(true);
+ tableOutputMaps.setHeaderVisible(true);
+ tableOutputMaps.setLayoutData(gd);
+ declareColumn(tableOutputMaps,100,"Mapping type");
+ declareColumn(tableOutputMaps,100,"Output Field Name");
+ declareColumn(tableOutputMaps,100,"Result column");
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 3;
+ gd.heightHint = 100;
+ tableOutputMaps.setLayoutData(gd);
+ tableOutputMaps.setVisible(false);
+ tableOutputMaps.addSelectionListener(new SelectionAdapter(){
+ public void widgetSelected(SelectionEvent e) {
+ handleOutputMapTableItemSelected();
+ }
+ });
+ tableOutputMaps.redraw();
+ tableOutputMaps.setVisible(true);
+ setTableVisibleStatus(tableOutputMaps, false);
+
outMappingButton = new Button(container, SWT.NULL);
outMappingButton.setText("Add New Output Mapping");
gd = new GridData();
@@ -265,6 +331,31 @@
}
});
+ editButtonOutputMap = new Button(container, SWT.PUSH);
+ editButtonOutputMap.setText("Edit Selected Mapping");
+ editButtonOutputMap.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleOutputMapEditQuery();
+ }
+ });
+ editButtonOutputMap.setEnabled(false);
+
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 1;
+ editButtonOutputMap.setLayoutData(gd);
+
+ deleteButtonOutputMap= new Button(container, SWT.PUSH);
+ deleteButtonOutputMap.setText("Delete Selected Mapping");
+ deleteButtonOutputMap.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleOutputMapDeleteQuery();
+ }
+ });
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 1;
+ deleteButtonOutputMap.setLayoutData(gd);
+ deleteButtonOutputMap.setEnabled(false);
+
label = new Label(container, SWT.NULL);
label.setText("");
gd = new GridData(GridData.FILL_HORIZONTAL);
@@ -295,6 +386,10 @@
rowNamespaceText.setText((String)tmpConfigList.get(2));
groupByElementText.setText((String)tmpConfigList.get(3));
rowNameText.setText((String)tmpConfigList.get(4));
+ inputMapList=(List)tmpConfigList.get(5);
+ outputMapList=(List)tmpConfigList.get(6);
+ updateTable(tableInputMaps, inputMapList);
+ updateTable(tableOutputMaps, outputMapList);
}
}
/**
@@ -302,12 +397,13 @@
*/
private void handleNewOutputMapping() {
//New Output Mapping
- AddOutputMappingDialog addOutputMappingDialog = new AddOutputMappingDialog(getShell());
+ AddOutputMappingDialog addOutputMappingDialog = new AddOutputMappingDialog(getShell(),null);
addOutputMappingDialog.create();
addOutputMappingDialog.getShell().setSize(500, 350);
addOutputMappingDialog.open();
if (addOutputMappingDialog.getReturnCode()==org.eclipse.jface.window.Window.OK){
- outputMapList.add(addOutputMappingDialog.getMappingData());
+ setMappingData(outputMapList, -1, addOutputMappingDialog.getMappingData());
+ updateTable(tableOutputMaps,outputMapList);
}
}
@@ -316,12 +412,13 @@
*/
private void handleNewInputMapping() {
//New Input Mapping
- AddInputParamDialog addInputParamDialog = new AddInputParamDialog(getShell());
+ AddInputParamDialog addInputParamDialog = new AddInputParamDialog(getShell(),null);
addInputParamDialog.create();
addInputParamDialog.getShell().setSize(500, 350);
addInputParamDialog.open();
if (addInputParamDialog.getReturnCode()==org.eclipse.jface.window.Window.OK){
- inputMapList.add(addInputParamDialog.getMappingData());
+ setMappingData(inputMapList, -1, addInputParamDialog.getMappingData());
+ updateTable(tableInputMaps,inputMapList);
}
}
@@ -413,8 +510,144 @@
showMsg("Row name is required.");
return false;
}
-
-
return true;
}
+
+ private void declareColumn(Table table, int width,String colName){
+ TableColumn column = new TableColumn(table,SWT.NONE);
+ column.setWidth(width);
+ column.setText(colName);
+ }
+
+ /**
+ * Handle when an item in the query table is selected
+ */
+ private void handleInputMapTableItemSelected(){
+ editButtonInputMap.setEnabled(tableInputMaps.getSelectionIndex()!=-1);
+ deleteButtonInputMap.setEnabled(tableInputMaps.getSelectionIndex()!=-1);
+ }
+
+ /**
+ * Handle when an item in the query table is selected
+ */
+ private void handleOutputMapTableItemSelected(){
+ editButtonOutputMap.setEnabled(tableOutputMaps.getSelectionIndex()!=-1);
+ deleteButtonOutputMap.setEnabled(tableOutputMaps.getSelectionIndex()!=-1);
+ }
+
+ private void updateTable(Table tbl,List fillItems) {
+ if (fillItems != null) {
+ int queryCount = fillItems.size();
+ int indexSelected=tbl.getSelectionIndex();
+ tbl.removeAll();
+ if (queryCount > 0) {
+ TableItem[] items = new TableItem[queryCount]; // An item for each field
+ for (int i = 0; i < queryCount; i++) {
+ items[i] = new TableItem(tbl, SWT.NONE);
+ //Get the Query ID
+ List iMapItem = (List)fillItems.get(i);
+ if (tbl==tableInputMaps){
+ items[i].setText(new String[]{
+ iMapItem.get(WSO2DataserviceWizardStepTwo.SQLQUERY_IMAP_NAME).toString()
+ ,iMapItem.get(
+ WSO2DataserviceWizardStepTwo.SQLQUERY_IMAP_SQL_TYPE).toString()
+ });
+ }else{
+ items[i].setText(new String[]{
+ iMapItem.get(WSO2DataserviceWizardStepTwo.SQLQUERY_OMAP_TYPE).toString()
+ ,iMapItem.get(
+ WSO2DataserviceWizardStepTwo.SQLQUERY_OMAP_OUT_FIELD).toString()
+ ,iMapItem.get(
+ WSO2DataserviceWizardStepTwo.SQLQUERY_OMAP_SQL_COL).toString()
+ });
+
+ }
+ }
+ if (indexSelected>(queryCount-1)){
+ indexSelected=queryCount-1;
+ }
+ tbl.setSelection(indexSelected);
+ //updateStatus(null);
+ }
+ tbl.redraw();
+ }
+ setTableVisibleStatus(tbl, fillItems.size()>0);
+ }
+
+ /**
+ * Handle edit Query
+ */
+ private void handleInputMapEditQuery() {
+ if (tableInputMaps.getSelectionIndex()>=0){
+ AddInputParamDialog addInputParamDialog = new AddInputParamDialog(getShell(),
+ (List)inputMapList.get(tableInputMaps.getSelectionIndex()));
+ addInputParamDialog.create();
+ addInputParamDialog.getShell().setSize(500, 350);
+ addInputParamDialog.open();
+ if (addInputParamDialog.getReturnCode()==org.eclipse.jface.window.Window.OK){
+ updateTable(tableInputMaps,inputMapList);
+ }
+ }
+ }
+
+ /**
+ * Handle edit Query
+ */
+ private void handleOutputMapEditQuery() {
+ if (tableOutputMaps.getSelectionIndex()>=0){
+ AddOutputMappingDialog addOutputMappingDialog = new AddOutputMappingDialog(getShell(),
+ (List)outputMapList.get(tableOutputMaps.getSelectionIndex()));
+ addOutputMappingDialog.create();
+ addOutputMappingDialog.getShell().setSize(500, 350);
+ addOutputMappingDialog.open();
+ if (addOutputMappingDialog.getReturnCode()==org.eclipse.jface.window.Window.OK){
+ updateTable(tableOutputMaps,outputMapList);
+ }
+ }
+ }
+
+ /**
+ * Handle delete Query
+ */
+ private void handleInputMapDeleteQuery() {
+ removeQueryData(inputMapList, tableInputMaps.getSelectionIndex());
+ updateTable(tableInputMaps,inputMapList);
+ handleInputMapTableItemSelected();
+ }
+
+ /**
+ * Handle delete Query
+ */
+ private void handleOutputMapDeleteQuery() {
+ removeQueryData(outputMapList, tableOutputMaps.getSelectionIndex());
+ updateTable(tableOutputMaps,outputMapList);
+ handleOutputMapTableItemSelected();
+ }
+
+ private void setTableVisibleStatus(Table tbl,boolean visible){
+ visible=true;
+ tbl.setVisible(visible);
+ if (visible){
+ ((GridData)tbl.getLayoutData()).heightHint=80;
+ }else{
+ ((GridData)tbl.getLayoutData()).heightHint=0;
+ }
+ }
+
+ public int setMappingData(List mapList,int index, List data){
+ if ((index<0) ||(index>(mapList.size()-1))){
+ mapList.add(data);
+ index=mapList.size()-1;
+ }else{
+ mapList.set(index, data);
+ }
+ return index;
+ }
+
+ public void removeQueryData(List mapList,int index){
+ if ((index>=0) &&(index<mapList.size())){
+ mapList.remove(index);
+ }
+ }
+
}
\ No newline at end of file
Modified: trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepTwo.java
==============================================================================
--- trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepTwo.java (original)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepTwo.java Thu May 15 22:44:15 2008
@@ -60,22 +60,22 @@
private Table table;
private PersistentDSContext dsContext;
- public static int SQLQUERY_QUERYID=0;
- public static int SQLQUERY_QUERY=1;
- public static int SQLQUERY_NAME_SPACE=2;
- public static int SQLQUERY_ELEMENT=3;
- public static int SQLQUERY_ROW_NAME=4;
- public static int SQLQUERY_INPUT_MAPS=5;
- public static int SQLQUERY_OUTPUT_MAPS=6;
-
- public static int SQLQUERY_IMAP_NAME=0;
- public static int SQLQUERY_IMAP_SQL_TYPE=1;
- public static int SQLQUERY_IMAP_INOUT_TYPE=2;
- public static int SQLQUERY_IMAP_ORDINAL=3;
-
- public static int SQLQUERY_OMAP_TYPE=0;
- public static int SQLQUERY_OMAP_OUT_FIELD=1;
- public static int SQLQUERY_OMAP_SQL_COL=2;
+ public static final int SQLQUERY_QUERYID=0;
+ public static final int SQLQUERY_QUERY=1;
+ public static final int SQLQUERY_NAME_SPACE=2;
+ public static final int SQLQUERY_ELEMENT=3;
+ public static final int SQLQUERY_ROW_NAME=4;
+ public static final int SQLQUERY_INPUT_MAPS=5;
+ public static final int SQLQUERY_OUTPUT_MAPS=6;
+
+ public static final int SQLQUERY_IMAP_NAME=0;
+ public static final int SQLQUERY_IMAP_SQL_TYPE=1;
+ public static final int SQLQUERY_IMAP_INOUT_TYPE=2;
+ public static final int SQLQUERY_IMAP_ORDINAL=3;
+
+ public static final int SQLQUERY_OMAP_TYPE=0;
+ public static final int SQLQUERY_OMAP_OUT_FIELD=1;
+ public static final int SQLQUERY_OMAP_SQL_COL=2;
/**
* Constructor for WSO2DataserviceWizardStepTwo.
* @param pageName
@@ -208,22 +208,22 @@
private void updateTable(List fillItems) {
if (fillItems != null) {
int queryCount = fillItems.size();
+ String selectedId=null;
+ int indexSelected=table.getSelectionIndex();
+ if (table.getSelectionIndex()>-1){
+ selectedId=table.getItem(table.getSelectionIndex()).getText();
+ }
table.removeAll();
if (queryCount > 0) {
- String selectedId=null;
- int indexSelected=table.getSelectionIndex();
- if (table.getSelectionIndex()>-1){
- selectedId=table.getItem(table.getSelectionIndex()).getText();
- }
TableItem[] items = new TableItem[queryCount]; // An item for each field
for (int i = 0; i < queryCount; i++) {
items[i] = new TableItem(table, SWT.NONE);
//Get the Query ID
List iQueryItem = (List)fillItems.get(i);
- items[i].setText(iQueryItem.get(0).toString());
+ items[i].setText(iQueryItem.get(SQLQUERY_QUERYID).toString());
items[i].setChecked(true);//check them all by default
if (selectedId!=null){
- if (iQueryItem.get(0).toString().equals(selectedId)){
+ if (iQueryItem.get(SQLQUERY_QUERYID).toString().equals(selectedId)){
indexSelected=i;
}
}
@@ -330,7 +330,7 @@
AddQueryDialog addQueryDialog = new AddQueryDialog(getShell(),
WSO2DataserviceWizardConstant.addTag, this);
addQueryDialog.create();
- addQueryDialog.getShell().setSize(500, 700);
+ addQueryDialog.getShell().setSize(500, 800);
addQueryDialog.open();
if (addQueryDialog.getReturnCode()==org.eclipse.jface.window.Window.OK){
noOfLoadedQuery++;
@@ -346,7 +346,7 @@
AddQueryDialog addQueryDialog = new AddQueryDialog(getShell(),
WSO2DataserviceWizardConstant.editTag, this);
addQueryDialog.create();
- addQueryDialog.getShell().setSize(500, 700);
+ addQueryDialog.getShell().setSize(500, 800);
addQueryDialog.open();
}
More information about the Ds-java-dev
mailing list