[Ds-java-dev] svn commit r17113 - in trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide: dialog wizard

svn at wso2.org svn at wso2.org
Fri May 16 02:50:18 PDT 2008


Author: samindaw
Date: Fri May 16 02:50:18 2008
New Revision: 17113

Log:
validating data and confirm delete msgs for query and i/o mappings

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	Fri May 16 02:50:18 2008
@@ -25,8 +25,10 @@
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.MessageBox;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.events.*;
 import org.wso2.ws.dataservice.ide.util.FontUtil;
 import org.wso2.ws.dataservice.ide.wizard.WSO2DataserviceWizardStepTwo;
 
@@ -117,7 +119,7 @@
 		gd.horizontalSpan = 1;
 		label.setLayoutData(gd);
 
-		sqlTypeCombo = new Combo(container,SWT.NULL);
+		sqlTypeCombo = new Combo(container,SWT.READ_ONLY);
 		loadSQLTypeCombo();
 		sqlTypeCombo.select(0);
 		gd = new GridData(GridData.FILL_HORIZONTAL);
@@ -135,7 +137,7 @@
 		gd.horizontalSpan = 1;
 		label.setLayoutData(gd);
 
-		inOutTypeCombo = new Combo(container,SWT.NULL);
+		inOutTypeCombo = new Combo(container,SWT.READ_ONLY);
 		loadInOutTypeCombo();
 		inOutTypeCombo.select(0);
 		gd = new GridData(GridData.FILL_HORIZONTAL);
@@ -186,7 +188,8 @@
 		if (i>=0) inOutTypeCombo.select(i);
 
 		nameText.setText(data.get(WSO2DataserviceWizardStepTwo.SQLQUERY_IMAP_NAME).toString());
-		ordinalText.setText(data.get(WSO2DataserviceWizardStepTwo.SQLQUERY_IMAP_ORDINAL).toString());
+		ordinalText.setText(data.get
+				(WSO2DataserviceWizardStepTwo.SQLQUERY_IMAP_ORDINAL).toString());
 	}
 	
 	private void pathChanged() {
@@ -235,6 +238,38 @@
 		return mappingData;
 	}
 	
+	protected void okPressed(){
+		if (isAllDataValid()){
+			super.okPressed();
+		}
+	}
+	
+	private boolean isAllDataValid(){
+		if (mappingData.get
+				(WSO2DataserviceWizardStepTwo.SQLQUERY_IMAP_NAME).toString().equals("")){
+			showMsg("Name cannot be empty");
+			return false;
+		}
+
+		if (!mappingData.get
+				(WSO2DataserviceWizardStepTwo.SQLQUERY_IMAP_ORDINAL).toString().equals("")){
+			try{
+				Integer.parseInt(mappingData.get
+						(WSO2DataserviceWizardStepTwo.SQLQUERY_IMAP_ORDINAL).toString());
+			}catch(Exception e){
+				showMsg("Ordinal needs to be a numerical value");
+				return false;
+			}
+		}
+
+		return true;
+	}
+	
+	private void showMsg(String msg){
+		MessageBox messageBox =new MessageBox(getShell(),SWT.OK);
+		 messageBox.setMessage(msg);
+		 messageBox.open();
+	}
 }
 
 

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	Fri May 16 02:50:18 2008
@@ -28,6 +28,7 @@
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.MessageBox;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
 import org.wso2.ws.dataservice.ide.util.FontUtil;
@@ -99,7 +100,7 @@
 		gd.horizontalSpan = 1;
 		label.setLayoutData(gd);
 
-		mappingTypeCombo = new Combo(container,SWT.NULL);
+		mappingTypeCombo = new Combo(container,SWT.READ_ONLY);
 		loadMappingTypeCombo();
 		mappingTypeCombo.select(0);
 		gd = new GridData(GridData.FILL_HORIZONTAL);
@@ -191,4 +192,34 @@
 		outputFieldNameText.setText(data.get(
 				WSO2DataserviceWizardStepTwo.SQLQUERY_OMAP_OUT_FIELD).toString());
 	}
+	
+	protected void okPressed(){
+		if (isAllDataValid()){
+			super.okPressed();
+		}
+	}
+	
+	private boolean isAllDataValid(){
+		if (mappingData.get
+				(WSO2DataserviceWizardStepTwo.SQLQUERY_OMAP_OUT_FIELD).toString().equals("")){
+			showMsg("Output field name cannot be empty.");
+			return false;
+		}
+
+		if (mappingData.get
+				(WSO2DataserviceWizardStepTwo.SQLQUERY_OMAP_SQL_COL).toString().equals("")){
+			showMsg("SQL column name cannot be empty.");
+			return false;
+		}
+
+		return true;
+	}
+	
+	private void showMsg(String msg){
+		MessageBox messageBox =new MessageBox(getShell(),SWT.OK);
+		 messageBox.setMessage(msg);
+		 messageBox.open();
+	}
+	
+	
 }
\ 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	Fri May 16 02:50:18 2008
@@ -15,6 +15,8 @@
  */
 package org.wso2.ws.dataservice.ide.dialog;
 
+import java.awt.Color;
+import java.awt.Font;
 import java.io.ByteArrayOutputStream;
 import java.io.OutputStream;
 import java.util.ArrayList;
@@ -29,13 +31,17 @@
 import org.eclipse.swt.custom.StyledText;
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.internal.gtk.GdkColor;
 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.Control;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.MessageBox;
 import org.eclipse.swt.widgets.Shell;
@@ -58,6 +64,8 @@
 	private Button outMappingButton;
 	private String dialogHeadingPrefix;
 	private Text queryIDText;
+	private Label lblMsg;
+	
 	private StyledText sqlStatementText;
 	private Text groupByElementText;
 	private Text rowNameText;
@@ -76,6 +84,8 @@
 	private List configList;
 	private List inputMapList;
 	private List outputMapList;
+	private List tmpQIDList;
+	
 	private boolean isEditMode=false;
 	
 	public AddQueryDialog(Shell parentShell, String headingPrefix,
@@ -142,6 +152,18 @@
 			}
 		});
 		
+		label = new Label(container, SWT.NULL);
+		gd = new GridData(GridData.FILL_HORIZONTAL);
+		gd.horizontalSpan = 2;
+		label.setLayoutData(gd);
+
+		lblMsg = new Label(container, SWT.NULL);
+		lblMsg.setForeground(new org.eclipse.swt.graphics.Color(getShell().getDisplay(),255,0,0));
+		gd = new GridData();
+		gd.horizontalSpan = 1;
+		label.setLayoutData(gd);
+		lblMsg.setText("                                             ");
+
 		label = new Label(container, SWT.HORIZONTAL | SWT.SEPARATOR);
 		gd = new GridData(GridData.FILL_HORIZONTAL);
 		gd.horizontalSpan = 3;
@@ -194,6 +216,11 @@
 				handleInputMapTableItemSelected();
 			}
 		});
+		tableInputMaps.addMouseListener(new MouseAdapter(){
+			public void mouseDoubleClick(MouseEvent e){
+				handleInputMapEditQuery();
+			}
+		});
 		tableInputMaps.redraw();
 		tableInputMaps.setVisible(true);
 		setTableVisibleStatus(tableInputMaps, false);
@@ -208,6 +235,7 @@
 				handleNewInputMapping();
 			}
 		});
+		inputMappingButton.setEnabled(false);
 		
 		editButtonInputMap = new Button(container, SWT.PUSH);
 		editButtonInputMap.setText("Edit Selected Mapping");
@@ -316,6 +344,11 @@
 				handleOutputMapTableItemSelected();
 			}
 		});
+		tableOutputMaps.addMouseListener(new MouseAdapter(){
+			public void mouseDoubleClick(MouseEvent e){
+				handleOutputMapEditQuery();
+			}
+		});
 		tableOutputMaps.redraw();
 		tableOutputMaps.setVisible(true);
 		setTableVisibleStatus(tableOutputMaps, false);
@@ -330,6 +363,7 @@
 				handleNewOutputMapping();
 			}
 		});
+		outMappingButton.setEnabled(false);
 
 		editButtonOutputMap = new Button(container, SWT.PUSH);
 		editButtonOutputMap.setText("Edit Selected Mapping");
@@ -472,8 +506,32 @@
 		configList.set(WSO2DataserviceWizardStepTwo.SQLQUERY_NAME_SPACE,rowNamespaceText.getText());
 		configList.set(WSO2DataserviceWizardStepTwo.SQLQUERY_ELEMENT,groupByElementText.getText());
 		configList.set(WSO2DataserviceWizardStepTwo.SQLQUERY_ROW_NAME,rowNameText.getText());
+		if (isQueryIDAlreadyPresent(
+				configList.get(WSO2DataserviceWizardStepTwo.SQLQUERY_QUERYID).toString())){
+			inputMappingButton.setEnabled(isEditMode);
+			if (isEditMode) lblMsg.setText(""); else lblMsg.setText("Query ID already exists.");
+			outMappingButton.setEnabled(isEditMode && (!configList.get
+					(WSO2DataserviceWizardStepTwo.SQLQUERY_ELEMENT).toString().equals("")));
+		}else{
+			lblMsg.setText("");
+			if (configList.get(WSO2DataserviceWizardStepTwo.SQLQUERY_QUERYID).toString().equals(""))
+			{
+				inputMappingButton.setEnabled(false);
+				outMappingButton.setEnabled(false);
+			}else{
+				inputMappingButton.setEnabled(true);
+				outMappingButton.setEnabled(!configList.get
+						(WSO2DataserviceWizardStepTwo.SQLQUERY_ELEMENT).toString().equals(""));
+			}
+		}
+		
 	}
 	
+	private boolean isQueryIDAlreadyPresent(String qid){
+		if (qid.equals("")) return false;
+		if (tmpQIDList==null) tmpQIDList=parentPage.getQueryIdList();
+		return (tmpQIDList.indexOf(qid)>=0);
+	}
 	/**
 	 * Return the current Config List
 	 * @return
@@ -610,18 +668,30 @@
 	 * Handle delete Query
 	 */
 	private void handleInputMapDeleteQuery() {
-		removeQueryData(inputMapList, tableInputMaps.getSelectionIndex());
-		updateTable(tableInputMaps,inputMapList);
-		handleInputMapTableItemSelected();
+		if (tableInputMaps.getSelectionIndex()>=0){
+			MessageBox messageBox =new MessageBox(getShell(),SWT.YES|SWT.NO);
+			messageBox.setMessage("Are you sure you want to remove the selected input mapping?");
+			if (messageBox.open()==SWT.YES){
+				removeQueryData(inputMapList, tableInputMaps.getSelectionIndex());
+				updateTable(tableInputMaps,inputMapList);
+				handleInputMapTableItemSelected();
+			}
+		}
 	}
 	
 	/**
 	 * Handle delete Query
 	 */
 	private void handleOutputMapDeleteQuery() {
-		removeQueryData(outputMapList, tableOutputMaps.getSelectionIndex());
-		updateTable(tableOutputMaps,outputMapList);
-		handleOutputMapTableItemSelected();
+		if (tableOutputMaps.getSelectionIndex()>=0){
+			MessageBox messageBox =new MessageBox(getShell(),SWT.YES|SWT.NO);
+			messageBox.setMessage("Are you sure you want to remove the selected output mapping?");
+			if (messageBox.open()==SWT.YES){
+				removeQueryData(outputMapList, tableOutputMaps.getSelectionIndex());
+				updateTable(tableOutputMaps,outputMapList);
+				handleOutputMapTableItemSelected();
+			}
+		}
 	}
 	
 	private void setTableVisibleStatus(Table tbl,boolean visible){

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	Fri May 16 02:50:18 2008
@@ -40,6 +40,8 @@
 import org.eclipse.swt.widgets.TableColumn;
 import org.eclipse.swt.widgets.TableItem;
 import org.eclipse.swt.widgets.Dialog;
+import org.eclipse.swt.events.*;
+
 import org.wso2.ws.dataservice.ide.WSO2DataservicePlugin;
 import org.wso2.ws.dataservice.ide.constant.WSO2DataserviceWizardConstant;
 import org.wso2.ws.dataservice.ide.context.PersistentDSContext;
@@ -120,6 +122,11 @@
 				handleTableItemSelected();
 			}
 		});
+		table.addMouseListener(new MouseAdapter(){
+			public void mouseDoubleClick(MouseEvent e){
+				handleEditQuery();
+			}
+		});
 
 		label = new Label(container, SWT.NULL);
 		label.setText("");
@@ -343,23 +350,30 @@
 	 */
 	private void handleEditQuery() {
 		//Add Query Selection
-		AddQueryDialog addQueryDialog = new AddQueryDialog(getShell(), 
+		if (table.getSelectionIndex()>=0){
+			AddQueryDialog addQueryDialog = new AddQueryDialog(getShell(), 
 				WSO2DataserviceWizardConstant.editTag, this);
-		addQueryDialog.create();
-		addQueryDialog.getShell().setSize(500, 800);
-		addQueryDialog.open();
+			addQueryDialog.create();
+			addQueryDialog.getShell().setSize(500, 800);
+			addQueryDialog.open();
+		}
 	}
 
 	/**
 	 * Handle delete Query
 	 */
 	private void handleDeleteQuery() {
-		removeQueryData(getSelectedQueryId());
-		//queryToUIMapping.remove("Test"+noOfLoadedQuery);
-		noOfLoadedQuery--;
-		updateTable(queryToUIMapping);
-		configChanged();
-		handleTableItemSelected();
+		if (table.getSelectionIndex()>=0){
+			MessageBox messageBox =new MessageBox(getShell(),SWT.YES|SWT.NO);
+			messageBox.setMessage("Are you sure you want to remove the selected query?");
+			if (messageBox.open()==SWT.YES){
+				removeQueryData(getSelectedQueryId());
+				noOfLoadedQuery--;
+				updateTable(queryToUIMapping);
+				configChanged();
+				handleTableItemSelected();
+			}
+		}
 	}
 
 	private void updateStatus(String message) {



More information about the Ds-java-dev mailing list