[Ds-java-dev] svn commit r14504 -
trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard
svn at wso2.org
svn at wso2.org
Tue Mar 4 19:28:48 PST 2008
Author: sandakith
Date: Tue Mar 4 19:28:44 2008
New Revision: 14504
Log:
adding the wizard pages for the adding editing and deleting operations and queries
Added:
trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepThree.java
trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepTwo.java
Added: trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepThree.java
==============================================================================
--- (empty file)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepThree.java Tue Mar 4 19:28:44 2008
@@ -0,0 +1,245 @@
+/*
+ * Copyright 2005,2006 WSO2, Inc. http://www.wso2.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.wso2.ws.dataservice.ide.wizard;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+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.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.wso2.ws.dataservice.ide.dialog.AddOperationDialog;
+
+/**
+ * The Wizard page that involves the configuration of Operations for DS
+ */
+public class WSO2DataserviceWizardStepThree extends WizardPage {
+
+ private int noOfLoadedOperations;
+ private Button newButton;
+ private Button editButton;
+ private Button deleteButton;
+ private List operationToUIMapping;
+ private StyledText previewConfig;
+ private Table table;
+ private Label label;
+ private GridData gd;
+
+
+ /**
+ * Constructor for WSO2DataserviceWizardStepThree.
+ * @param pageName
+ */
+ public WSO2DataserviceWizardStepThree(ISelection selection) {
+ super("WSO2 Dataservice Wizard Step Three : Add Operation");
+ setTitle("WSO2 Dataservice Wizard Step Three : Add Operation");
+ setDescription("This wizard creates a new data service with the provided configuration.");
+ }
+
+ /**
+ * @see IDialogPage#createControl(Composite)
+ */
+ public void createControl(Composite parent) {
+
+ final Composite container = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ container.setLayout(layout);
+ layout.numColumns = 7;
+ layout.verticalSpacing = 10;
+
+ label = new Label(container, SWT.HORIZONTAL | SWT.SEPARATOR);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 7;
+ label.setLayoutData(gd);
+
+ table = new Table(container,SWT.SINGLE|SWT.FULL_SELECTION|SWT.CHECK);
+ table.setLinesVisible(true);
+ table.setHeaderVisible(true);
+ table.setLayoutData(gd);
+ declareColumn(table,20,"");
+ declareColumn(table,200,"Current Operations");
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 7;
+ gd.heightHint = 100;
+ table.setLayoutData(gd);
+ table.setVisible(false);
+
+ label = new Label(container, SWT.NULL);
+ label.setText("");
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 7;
+ label.setLayoutData(gd);
+
+ newButton = new Button(container, SWT.PUSH);
+ newButton.setText("Click to add New Operation");
+ newButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleAddOperation();
+ }
+ });
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ newButton.setLayoutData(gd);
+
+ editButton = new Button(container, SWT.PUSH);
+ editButton.setText("Edit Selected Operation");
+ editButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleEditOperation();
+ }
+ });
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ editButton.setLayoutData(gd);
+
+ deleteButton= new Button(container, SWT.PUSH);
+ deleteButton.setText("Delete Selected Operation");
+ deleteButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleDeleteOperation();
+ }
+ });
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ deleteButton.setLayoutData(gd);
+
+ label = new Label(container, SWT.NULL);
+ label.setText("");
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 4;
+ label.setLayoutData(gd);
+
+ label = new Label(container, SWT.HORIZONTAL | SWT.SEPARATOR);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 7;
+ label.setLayoutData(gd);
+
+ label = new Label(container, SWT.NULL);
+ label.setText("");
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 7;
+ label.setLayoutData(gd);
+
+ label = new Label(container, SWT.HORIZONTAL);
+ label.setText("Preview of the Data Service Configuration");
+ gd.horizontalSpan = 7;
+ label.setLayoutData(gd);
+
+ previewConfig = new StyledText(container,SWT.V_SCROLL);
+ //previewConfig.setText(loadDefaultConfig());
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 7;
+ gd.heightHint = 200;
+ previewConfig.setLayoutData(gd);
+
+ operationToUIMapping = new ArrayList();
+ updateTable(operationToUIMapping);
+ initialize();
+ setControl(container);
+ }
+
+ /**
+ * Update the operation table with the new items
+ * @param fillItems : operation list to load to the table
+ */
+ private void updateTable(List fillItems) {
+ if (fillItems != null) {
+ int operationCount = fillItems.size();
+ if (operationCount > 0) {
+ table.removeAll();
+ TableItem[] items = new TableItem[operationCount]; // An item for each field
+ for (int i = 0; i < operationCount; i++) {
+ items[i] = new TableItem(table, SWT.NONE);
+ items[i].setText(1, fillItems.get(i).toString());
+ items[i].setChecked(true);//check them all by default
+ }
+ updateStatus(null);
+ }
+ }
+ table.setVisible(true);
+ }
+
+
+ private void declareColumn(Table table, int width,String colName){
+ TableColumn column = new TableColumn(table,SWT.NONE);
+ column.setWidth(width);
+ column.setText(colName);
+ }
+
+ /**
+ * Tests if the current workbench selection is a suitable
+ * container to use.
+ */
+ private void initialize() {
+ //Initialize the plug-in
+ }
+
+ /**
+ * Handle add new operation
+ */
+ private void handleAddOperation() {
+ //Add Operation Selection
+ AddOperationDialog addOperationDialog
+ = new AddOperationDialog(getShell());
+ addOperationDialog.create();
+ addOperationDialog.getShell().setSize(500, 200);
+ addOperationDialog.open();
+
+ noOfLoadedOperations++;
+ operationToUIMapping.add("Test"+noOfLoadedOperations);
+ updateTable(operationToUIMapping);
+ }
+
+ /**
+ * Handle edit operation
+ */
+ private void handleEditOperation() {
+ //Add Operation Selection
+ AddOperationDialog addOperationDialog = new AddOperationDialog(getShell());
+ addOperationDialog.create();
+ addOperationDialog.getShell().setSize(500, 200);
+ addOperationDialog.open();
+
+ }
+
+ /**
+ * Handle delete operation
+ */
+ private void handleDeleteOperation() {
+ operationToUIMapping.remove("Test"+noOfLoadedOperations);
+ noOfLoadedOperations--;
+ updateTable(operationToUIMapping);
+ }
+
+
+ private void updateStatus(String message) {
+ setErrorMessage(message);
+ setPageComplete(message == null);
+ }
+
+}
\ No newline at end of file
Added: trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepTwo.java
==============================================================================
--- (empty file)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepTwo.java Tue Mar 4 19:28:44 2008
@@ -0,0 +1,241 @@
+/*
+ * Copyright 2005,2006 WSO2, Inc. http://www.wso2.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.wso2.ws.dataservice.ide.wizard;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+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.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.wso2.ws.dataservice.ide.dialog.AddQueryDialog;
+
+/**
+ * The Wizard page that involves the configuration of Queries for DS.
+ */
+public class WSO2DataserviceWizardStepTwo extends WizardPage {
+
+ private int noOfLoadedQuery;
+ private Button newButton;
+ private Button editButton;
+ private Button deleteButton;
+ private List queryToUIMapping;
+ private StyledText previewConfig;
+ private Table table;
+
+ /**
+ * Constructor for WSO2DataserviceWizardStepTwo.
+ * @param pageName
+ */
+ public WSO2DataserviceWizardStepTwo(ISelection selection) {
+ super("WSO2 Dataservice Wizard Step Two : Add Query");
+ setTitle("WSO2 Dataservice Wizard Step Two : Add Query");
+ setDescription("This wizard creates a new data service with the provided configuration.");
+ }
+
+ /**
+ * @see IDialogPage#createControl(Composite)
+ */
+ public void createControl(Composite parent) {
+
+ final Composite container = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ container.setLayout(layout);
+ layout.numColumns = 7;
+ layout.verticalSpacing = 10;
+
+ Label label = new Label(container, SWT.HORIZONTAL | SWT.SEPARATOR);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 7;
+ label.setLayoutData(gd);
+
+ table = new Table(container,SWT.SINGLE|SWT.FULL_SELECTION|SWT.CHECK);
+ table.setLinesVisible(true);
+ table.setHeaderVisible(true);
+ table.setLayoutData(gd);
+ declareColumn(table,20,"");
+ declareColumn(table,200,"Current Queries");
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 7;
+ gd.heightHint = 100;
+ table.setLayoutData(gd);
+ table.setVisible(false);
+
+ label = new Label(container, SWT.NULL);
+ label.setText("");
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 7;
+ label.setLayoutData(gd);
+
+ newButton = new Button(container, SWT.PUSH);
+ newButton.setText("Click to add New Query");
+ newButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleAddQuery();
+ }
+ });
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ newButton.setLayoutData(gd);
+
+ editButton = new Button(container, SWT.PUSH);
+ editButton.setText("Edit Selected Query");
+ editButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleEditQuery();
+ }
+ });
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ editButton.setLayoutData(gd);
+
+ deleteButton= new Button(container, SWT.PUSH);
+ deleteButton.setText("Delete Selected Query");
+ deleteButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleDeleteQuery();
+ }
+ });
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ deleteButton.setLayoutData(gd);
+
+ label = new Label(container, SWT.NULL);
+ label.setText("");
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 4;
+ label.setLayoutData(gd);
+
+ label = new Label(container, SWT.HORIZONTAL | SWT.SEPARATOR);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 7;
+ label.setLayoutData(gd);
+
+ label = new Label(container, SWT.NULL);
+ label.setText("");
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 7;
+ label.setLayoutData(gd);
+
+
+ label = new Label(container, SWT.HORIZONTAL);
+ label.setText("Preview of the Data Service Configuration");
+ gd.horizontalSpan = 7;
+ label.setLayoutData(gd);
+
+ previewConfig = new StyledText(container,SWT.V_SCROLL);
+ //previewConfig.setText(loadDefaultConfig());
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 7;
+ gd.heightHint = 200;
+ previewConfig.setLayoutData(gd);
+
+ queryToUIMapping = new ArrayList();
+ updateTable(queryToUIMapping);
+ initialize();
+ setControl(container);
+ }
+
+
+ /**
+ * Update the query table with the new items
+ * @param fillItems : query list to load to the table
+ */
+ private void updateTable(List fillItems) {
+ if (fillItems != null) {
+ int queryCount = fillItems.size();
+ if (queryCount > 0) {
+ table.removeAll();
+ TableItem[] items = new TableItem[queryCount]; // An item for each field
+ for (int i = 0; i < queryCount; i++) {
+ items[i] = new TableItem(table, SWT.NONE);
+ items[i].setText(1, fillItems.get(i).toString());
+ items[i].setChecked(true);//check them all by default
+ }
+ updateStatus(null);
+ }
+ }
+ table.setVisible(true);
+ }
+
+
+ private void declareColumn(Table table, int width,String colName){
+ TableColumn column = new TableColumn(table,SWT.NONE);
+ column.setWidth(width);
+ column.setText(colName);
+ }
+
+ /**
+ * Tests if the current workbench selection is a suitable
+ * container to use.
+ */
+ private void initialize() {
+ //Initialize the plug-in
+ }
+
+ /**
+ * Handle add new Query
+ */
+ private void handleAddQuery() {
+ //Add Query Selection
+ AddQueryDialog addQueryDialog = new AddQueryDialog(getShell());
+ addQueryDialog.create();
+ addQueryDialog.getShell().setSize(500, 200);
+ addQueryDialog.open();
+
+ noOfLoadedQuery++;
+ queryToUIMapping.add("Test"+noOfLoadedQuery);
+ updateTable(queryToUIMapping);
+ }
+
+ /**
+ * Handle edit Query
+ */
+ private void handleEditQuery() {
+ //Add Query Selection
+ AddQueryDialog addQueryDialog = new AddQueryDialog(getShell());
+ addQueryDialog.create();
+ addQueryDialog.getShell().setSize(500, 200);
+ addQueryDialog.open();
+ }
+
+ /**
+ * Handle delete Query
+ */
+ private void handleDeleteQuery() {
+ queryToUIMapping.remove("Test"+noOfLoadedQuery);
+ noOfLoadedQuery--;
+ updateTable(queryToUIMapping);
+ }
+
+ private void updateStatus(String message) {
+ setErrorMessage(message);
+ setPageComplete(message == null);
+ }
+
+}
\ No newline at end of file
More information about the Ds-java-dev
mailing list