[Ds-java-dev] svn commit r16534 - in
trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide:
constant context wizard
svn at wso2.org
svn at wso2.org
Mon May 5 06:14:46 PDT 2008
Author: sandakith
Date: Mon May 5 06:14:35 2008
New Revision: 16534
Log:
Adding the Carbon Home as a field in the first page of the Wizard
Adding carbon home variable to the persistence context of the wizard
Implement the Finish Wizard
- Write the persisted dbs file to the Carbon home service deploying location
Modified:
trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/constant/WSO2DataserviceWizardConstant.java
trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/context/DSContext.java
trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/context/DSPreferencesDefaults.java
trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/context/PersistentDSContext.java
trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizard.java
trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepOnePage.java
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
Modified: trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/constant/WSO2DataserviceWizardConstant.java
==============================================================================
--- trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/constant/WSO2DataserviceWizardConstant.java (original)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/constant/WSO2DataserviceWizardConstant.java Mon May 5 06:14:35 2008
@@ -27,6 +27,7 @@
public static final String dataSourceComboJNDI = "JNDI Data Source";
public static final String defaultDataServiceConfig = "<data><config /></data>";
+ public static final String defaultCarbonHOme = "<CARBON_HOME>";
public static final String databaseTypeMySQL = "MySQL";
public static final String databaseTypeApacheDerby = "Apache Derby";
Modified: trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/context/DSContext.java
==============================================================================
--- trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/context/DSContext.java (original)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/context/DSContext.java Mon May 5 06:14:35 2008
@@ -21,9 +21,15 @@
public interface DSContext {
public final String PREFERENCE_DS_CONFIG = "dataServiceConfig";
+
+ public final String PREFERENCE_CARBON_HOME = "carbonHome";
public String getDSConfig();
public void setDSConfig(String dsConfig);
+
+ public String getCarbonHome();
+
+ public void setCarbonHome(String carbonHome);
}
Modified: trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/context/DSPreferencesDefaults.java
==============================================================================
--- trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/context/DSPreferencesDefaults.java (original)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/context/DSPreferencesDefaults.java Mon May 5 06:14:35 2008
@@ -25,6 +25,10 @@
// Default value of Configuration
public static final String PREFERENCE_DS_CONFIG_DEFAULT
= WSO2DataserviceWizardConstant.defaultDataServiceConfig;
+
+ // Default value of Carbon Home
+ public static final String PREFERENCE_CARBON_HOME_DEFAULT
+ = WSO2DataserviceWizardConstant.defaultCarbonHOme;
/**
* @return returns the default setting for data service configuration.
@@ -32,5 +36,12 @@
public static String getDSConfiguration() {
return PREFERENCE_DS_CONFIG_DEFAULT;
}
+
+ /**
+ * @return returns the default setting for Carbon Home.
+ */
+ public static String getCarbonHome() {
+ return PREFERENCE_CARBON_HOME_DEFAULT;
+ }
}
Modified: trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/context/PersistentDSContext.java
==============================================================================
--- trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/context/PersistentDSContext.java (original)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/context/PersistentDSContext.java Mon May 5 06:14:35 2008
@@ -42,10 +42,10 @@
//Load the defaults
public void load() {
- setDefault(PREFERENCE_DS_CONFIG, DSPreferencesDefaults
- .getDSConfiguration());
- setValue(PREFERENCE_DS_CONFIG, DSPreferencesDefaults
- .getDSConfiguration());
+ setDefault(PREFERENCE_DS_CONFIG, DSPreferencesDefaults.getDSConfiguration());
+ setValue(PREFERENCE_DS_CONFIG, DSPreferencesDefaults.getDSConfiguration());
+ setDefault(PREFERENCE_CARBON_HOME, DSPreferencesDefaults.getCarbonHome());
+ setValue(PREFERENCE_CARBON_HOME, DSPreferencesDefaults.getCarbonHome());
}
/**
@@ -61,5 +61,20 @@
public void setDSConfig(String dsConfig) {
setValue(PREFERENCE_DS_CONFIG, dsConfig);
}
+
+ /**
+ * receive the data service configuration as String from context
+ */
+ public String getCarbonHome() {
+ return getValueAsString(PREFERENCE_CARBON_HOME);
+ }
+
+ /**
+ * set the data service configuration in to the context
+ */
+ public void setCarbonHome(String dsConfig) {
+ setValue(PREFERENCE_CARBON_HOME, dsConfig);
+ }
+
}
Modified: trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizard.java
==============================================================================
--- trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizard.java (original)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizard.java Mon May 5 06:14:35 2008
@@ -15,6 +15,9 @@
*/
package org.wso2.ws.dataservice.ide.wizard;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.runtime.CoreException;
@@ -29,6 +32,8 @@
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWizard;
+import org.wso2.ws.dataservice.ide.WSO2DataservicePlugin;
+import org.wso2.ws.dataservice.ide.context.PersistentDSContext;
/**
* This WSO2 Data services creation wizard.
@@ -39,6 +44,7 @@
private WSO2DataserviceWizardStepTwo stepTwo;
private WSO2DataserviceWizardStepThree stepThree;
private ISelection selection;
+ private PersistentDSContext dsContext;
/**
* Constructor for WSO2DataserviceWizard.
@@ -46,6 +52,8 @@
public WSO2DataserviceWizard() {
super();
setNeedsProgressMonitor(true);
+ //Obtain the current context from eclipse preferences.
+ dsContext = WSO2DataservicePlugin.getDefault().getPersistentDSContext();
}
/**
@@ -66,11 +74,10 @@
* using wizard as execution context.
*/
public boolean performFinish() {
- final String containerName = stepOne.getContainerName();
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
- doFinish(containerName, monitor);
+ doFinish(monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
} finally {
@@ -93,8 +100,21 @@
/**
* The worker method for finishing the data service creation wizard
*/
- private void doFinish(String containerName, IProgressMonitor monitor)
- throws CoreException {
+ private void doFinish(IProgressMonitor monitor) throws CoreException {
+ //Get the carbon home
+ String carbonHome = dsContext.getCarbonHome();
+ System.out.println(carbonHome);
+ //Flush the data service configuration service hosting environment
+ File dsCongigFile = new File(carbonHome+File.separator+"testdb.txt");
+ try {
+ dsCongigFile.createNewFile();
+ FileWriter out = new FileWriter(dsCongigFile);
+ out.write(dsContext.getDSConfig());
+ out.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
}
/**
Modified: trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepOnePage.java
==============================================================================
--- trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepOnePage.java (original)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepOnePage.java Mon May 5 06:14:35 2008
@@ -30,7 +30,9 @@
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -48,6 +50,7 @@
*/
public class WSO2DataserviceWizardStepOnePage extends AbstractWSO2DataserviceWizardPage {
+ private Text carbonHomeText;
private Text serviceNameText;
private Combo dataSource;
private StyledText previewConfig;
@@ -61,12 +64,14 @@
super("WSO2 Data service Wizard Step One : Data Service Configuration");
setTitle("WSO2 Data service Wizard Step One : Data Service Configuration");
setDescription(WSO2DataserviceWizardConstant.pageDiscription);
+ //Obtain the current context from eclipse preferences.
+ dsContext = WSO2DataservicePlugin.getDefault().getPersistentDSContext();
}
/**
* @see IDialogPage#createControl(Composite)
*/
- public void createControl(Composite parent) {
+ public void createControl(final Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
@@ -75,10 +80,31 @@
layout.verticalSpacing = 9;
Label label = new Label(container, SWT.NULL);
+ label.setText("Carbon Home *");
+
+ carbonHomeText = new Text(container, SWT.BORDER | SWT.SINGLE);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ carbonHomeText.setLayoutData(gd);
+ loadDefaultCarbonHome();
+ carbonHomeText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ carbonHomeChanged();
+ }
+ });
+
+ Button button = new Button(container, SWT.PUSH);
+ button.setText("Browse");
+ button.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleBrowse(parent.getShell());
+ }
+ });
+
+ label = new Label(container, SWT.NULL);
label.setText("Service Name :");
serviceNameText = new Text(container, SWT.BORDER | SWT.SINGLE);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
serviceNameText.setLayoutData(gd);
@@ -103,9 +129,9 @@
}
});
- Button button = new Button(container, SWT.PUSH);
- button.setText("Edit");
- button.addSelectionListener(new SelectionAdapter() {
+ Button browseButton = new Button(container, SWT.PUSH);
+ browseButton.setText(" Edit ");
+ browseButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
handleEdit();
}
@@ -136,7 +162,14 @@
setControl(container);
setPageComplete(false);
}
-
+
+ /**
+ * Load the default carbon home
+ */
+ private void loadDefaultCarbonHome() {
+ carbonHomeText.setText(dsContext.getCarbonHome());
+ }
+
/**
* Add the content to the data source combo.
*/
@@ -157,6 +190,25 @@
}
/**
+ * Update the context with carbon home
+ */
+ private void carbonHomeChanged() {
+ dsContext.setCarbonHome(carbonHomeText.getText());
+ updateStatus(null);
+ }
+
+ /**
+ * Handle the carbon home edit.
+ */
+ private void handleBrowse(Shell parent) {
+ DirectoryDialog dirDialog = new DirectoryDialog(parent);
+ dirDialog.open();
+ dirDialog.setText("Open");
+ String selected = dirDialog.open();
+ carbonHomeText.setText(selected);
+ }
+
+ /**
* Uses the standard container selection dialog to
* choose the new value for the container field.
*/
@@ -225,20 +277,24 @@
* @param message : message to display
*/
private void updateStatus(String message) {
- if ((message == null) && !(serviceNameText.getText().equals(""))
- && (dataSource.getSelectionIndex() != 0) ) {
- setErrorMessage(message);
- setPageComplete(message == null);
- }else {
- setErrorMessage("Please select a Data Service Name and Configure the Data Source");
+ if (!(carbonHomeText.getText().equals("")||
+ carbonHomeText.getText().equals(WSO2DataserviceWizardConstant.defaultCarbonHOme))){
+ //TODO : Validate Carbon Home
+ if ((message == null) && !(serviceNameText.getText().equals(""))
+ && (dataSource.getSelectionIndex() != 0)) {
+ setErrorMessage(message);
+ setPageComplete(message == null);
+ } else {
+ setErrorMessage("Please select a Data Service Name and Configure the Data Source");
+ }
+ }else{
+ setErrorMessage("Please select a valid Carbon Home");
}
}
public String loadPreviousConfig(){
String defaultConfig = null;
try {
- //Obtain the current context from eclipse preferences.
- dsContext = WSO2DataservicePlugin.getDefault().getPersistentDSContext();
defaultConfig = DataServiceXMLUtil.prettyPrintDSConfig(
WSO2DataserviceWizardConstant.defaultDataServiceConfig).toString();
refreshConfig(defaultConfig);
@@ -255,8 +311,4 @@
dsContext.setDSConfig(config);
}
- public String getContainerName() {
- return serviceNameText.getText();
- }
-
}
\ No newline at end of file
Modified: 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/WSO2DataserviceWizardStepThree.java (original)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepThree.java Mon May 5 06:14:35 2008
@@ -63,6 +63,8 @@
super("WSO2 Data service Wizard Step Three : Add Operation");
setTitle("WSO2 Data service Wizard Step Three : Add Operation");
setDescription(WSO2DataserviceWizardConstant.pageDiscription);
+ //Obtain the current context from eclipse preferences.
+ dsContext = WSO2DataservicePlugin.getDefault().getPersistentDSContext();
}
/**
@@ -250,8 +252,6 @@
public String loadPreviousConfig(){
String defaultConfig = null;
try {
- //Obtain the current context from eclipse preferences.
- dsContext = WSO2DataservicePlugin.getDefault().getPersistentDSContext();
defaultConfig = DataServiceXMLUtil.prettyPrintDSConfig(dsContext.getDSConfig()).toString();
refreshConfig(defaultConfig);
} catch (Exception e) {
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 Mon May 5 06:14:35 2008
@@ -60,6 +60,8 @@
super("WSO2 Data service Wizard Step Two : Add Query");
setTitle("WSO2 Data service Wizard Step Two : Add Query");
setDescription(WSO2DataserviceWizardConstant.pageDiscription);
+ //Obtain the current context from eclipse preferences.
+ dsContext = WSO2DataservicePlugin.getDefault().getPersistentDSContext();
}
/**
@@ -247,8 +249,6 @@
public String loadPreviousConfig(){
String defaultConfig = null;
try {
- //Obtain the current context from eclipse preferences.
- dsContext = WSO2DataservicePlugin.getDefault().getPersistentDSContext();
defaultConfig = DataServiceXMLUtil.prettyPrintDSConfig(dsContext.getDSConfig()).toString();
refreshConfig(defaultConfig);
} catch (Exception e) {
More information about the Ds-java-dev
mailing list