summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxwu2013-05-24 03:08:49 (EDT)
committer mwu2013-05-24 03:08:49 (EDT)
commit03ea14e69190ca86c8b06217d5892f93934cf48c (patch)
tree6078c8698d988c763cf641a1adc3dd46d10ad8e6
parenta8bc27738c349b39ed650e550c768d1b8ef9f9ec (diff)
downloadorg.eclipse.datatools.enablement.oda-03ea14e69190ca86c8b06217d5892f93934cf48c.zip
org.eclipse.datatools.enablement.oda-03ea14e69190ca86c8b06217d5892f93934cf48c.tar.gz
org.eclipse.datatools.enablement.oda-03ea14e69190ca86c8b06217d5892f93934cf48c.tar.bz2
Fix bugzilla bug [408929] - Support Undo and Redo functions for editingv201305241508
SOAP request template in web service data set.
-rw-r--r--plugins/org.eclipse.datatools.enablement.oda.ws.ui/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.datatools.enablement.oda.ws.ui/src/org/eclipse/datatools/enablement/oda/ws/ui/wizards/SOAPRequestPage.java95
2 files changed, 80 insertions, 18 deletions
diff --git a/plugins/org.eclipse.datatools.enablement.oda.ws.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.datatools.enablement.oda.ws.ui/META-INF/MANIFEST.MF
index 4ec7b1a..ed4dbf3 100644
--- a/plugins/org.eclipse.datatools.enablement.oda.ws.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.datatools.enablement.oda.ws.ui/META-INF/MANIFEST.MF
@@ -12,7 +12,8 @@ Require-Bundle: org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
org.eclipse.datatools.enablement.oda.ws;bundle-version="[1.2.1,2.0.0)",
org.eclipse.datatools.enablement.oda.xml.ui;bundle-version="[1.2.0,2.0.0)",
javax.wsdl;bundle-version="[1.5.0,1.6.0)",
- org.apache.xerces;bundle-version="[2.8.0,3.0.0)";resolution:=optional
+ org.apache.xerces;bundle-version="[2.8.0,3.0.0)";resolution:=optional,
+ org.eclipse.jface.text;bundle-version="3.8.2"
Eclipse-LazyStart: true
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/plugins/org.eclipse.datatools.enablement.oda.ws.ui/src/org/eclipse/datatools/enablement/oda/ws/ui/wizards/SOAPRequestPage.java b/plugins/org.eclipse.datatools.enablement.oda.ws.ui/src/org/eclipse/datatools/enablement/oda/ws/ui/wizards/SOAPRequestPage.java
index a0d2e31..2712562 100644
--- a/plugins/org.eclipse.datatools.enablement.oda.ws.ui/src/org/eclipse/datatools/enablement/oda/ws/ui/wizards/SOAPRequestPage.java
+++ b/plugins/org.eclipse.datatools.enablement.oda.ws.ui/src/org/eclipse/datatools/enablement/oda/ws/ui/wizards/SOAPRequestPage.java
@@ -27,6 +27,13 @@ import org.eclipse.datatools.enablement.oda.ws.util.WSUtil;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.StatusDialog;
import org.eclipse.jface.dialogs.TrayDialog;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.ITextOperationTarget;
+import org.eclipse.jface.text.IUndoManager;
+import org.eclipse.jface.text.TextViewerUndoManager;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
@@ -39,6 +46,9 @@ import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.MouseAdapter;
@@ -65,7 +75,6 @@ import org.eclipse.ui.PlatformUI;
public class SOAPRequestPage extends DataSetWizardPage
{
- private transient Text queryText;
// parameters for page, different from soapParameters
private SOAPParameter[] parameters;
private static String DEFAULT_MESSAGE = Messages.getString( "soapRequestPage.message.defaultTitle" );//$NON-NLS-1$
@@ -75,9 +84,12 @@ public class SOAPRequestPage extends DataSetWizardPage
protected final String COLUMN_DATATYPE = Messages.getString( "parameterInputDialog.column.type" );//$NON-NLS-1$
protected final String COLUMN_DEFAULTVALUE = Messages.getString( "parameterInputDialog.column.defaultValue" );//$NON-NLS-1$
- private Button editBtn, paramBtn;
+ private Button paramBtn;
private SOAPRequest soapRequest;
+
+ private SourceViewer templateSourceViewer;
+ private StyledText templateText;
public SOAPRequestPage( String pageName )
@@ -121,7 +133,7 @@ public class SOAPRequestPage extends DataSetWizardPage
labelGd.horizontalSpan = 2;
prompt.setLayoutData( labelGd );
- setupQueryTextComposite( composite );
+ setupTemplateTextArea( composite );
setupButtonComposite( composite );
Point size = composite.computeSize( SWT.DEFAULT, SWT.DEFAULT );
@@ -133,13 +145,17 @@ public class SOAPRequestPage extends DataSetWizardPage
return sComposite;
}
- private void setupQueryTextComposite( Composite parent )
+ private void setupTemplateTextArea( Composite parent )
{
- queryText = new Text( parent, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.LEFT_TO_RIGHT );
- GridData layoutData = new GridData( GridData.FILL_BOTH );
+ templateSourceViewer = new SourceViewer( parent, null, SWT.BORDER
+ | SWT.LEFT_TO_RIGHT | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL );
+ templateSourceViewer.configure( new SourceViewerConfiguration( ) );
+ templateText = templateSourceViewer.getTextWidget( );
+ GridData layoutData = new GridData( SWT.FILL, SWT.FILL, true, true );
layoutData.heightHint = 400;
- queryText.setLayoutData( layoutData );
- queryText.addModifyListener( new ModifyListener( ){
+ templateText.setLayoutData( layoutData );
+ templateText.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT ));
+ templateText.addModifyListener( new ModifyListener( ){
public void modifyText( ModifyEvent arg0 )
{
@@ -147,6 +163,43 @@ public class SOAPRequestPage extends DataSetWizardPage
}
});
+
+ templateSourceViewer.setDocument( new Document( ) );
+
+ IUndoManager undoManager = new TextViewerUndoManager( 10 );
+ undoManager.connect( templateSourceViewer );
+ templateSourceViewer.setUndoManager( undoManager );
+
+ templateText.addKeyListener( new KeyAdapter( ) {
+
+ private boolean isRedoKeyPress( KeyEvent e )
+ {
+ return ( ( e.stateMask & SWT.CONTROL ) > 0 )
+ && ( ( e.keyCode == 'y' ) || ( e.keyCode == 'Y' ) );
+ }
+
+ private boolean isUndoKeyPress( KeyEvent e )
+ {
+ return ( ( e.stateMask & SWT.CONTROL ) > 0 )
+ && ( ( e.keyCode == 'z' ) || ( e.keyCode == 'Z' ) );
+ }
+
+ public void keyPressed( KeyEvent e )
+ {
+ if ( isUndoKeyPress( e ) )
+ {
+ templateSourceViewer.doOperation( ITextOperationTarget.UNDO );
+ validatePageStatus( );
+ }
+ else if ( isRedoKeyPress( e ) )
+ {
+ templateSourceViewer.doOperation( ITextOperationTarget.REDO );
+ validatePageStatus( );
+ }
+ }
+
+ } );
+
}
private void setupButtonComposite( Composite parent )
@@ -215,8 +268,9 @@ public class SOAPRequestPage extends DataSetWizardPage
public void widgetSelected( SelectionEvent e )
{
- queryText.setText( WSUtil.EMPTY_STRING );
+ templateText.setText( WSUtil.EMPTY_STRING );
validatePageStatus( );
+ templateText.setFocus( );
}
} );
@@ -238,7 +292,7 @@ public class SOAPRequestPage extends DataSetWizardPage
private void regenerateTemplate( ) throws OdaException
{
- queryText.setText( WSConsole.getInstance( ).getTemplate( ) );
+ templateText.setText( WSConsole.getInstance( ).getTemplate( ) );
parameters = WSConsole.getInstance( ).getParameters( );
saved = false;
}
@@ -264,14 +318,16 @@ public class SOAPRequestPage extends DataSetWizardPage
String wsQueryText = WSConsole.getInstance( )
.getPropertyValue( Constants.WS_QUERYTEXT );
if ( wsQueryText != null )
- queryText.setText( wsQueryText );
+ templateText.setText( wsQueryText );
+
parameters = WSConsole.getInstance( ).getParameters( );
+ initParameters( );
saved = false;
}
private void initParameters( )
{
- soapRequest = new SOAPRequest( queryText.getText( ) );
+ soapRequest = new SOAPRequest( templateText.getText( ) );
mergeParameters( );
SOAPParameter[] params = soapRequest.getParameters( );
paramBtn.setEnabled( params != null && params.length > 0 );
@@ -353,7 +409,8 @@ public class SOAPRequestPage extends DataSetWizardPage
{
String value = WSConsole.getInstance( ).manipulateTemplate( );
if ( value != null )
- queryText.setText( value );
+ templateText.setText( value );
+
parameters = WSConsole.getInstance( ).getParameters( );
initParameters( );
saved = false;
@@ -393,10 +450,14 @@ public class SOAPRequestPage extends DataSetWizardPage
private void saveToModel( )
{
- if( this.queryText == null )
+ if( this.templateText == null )
return;
+
+ String templateContent = templateText.getText( ) == null
+ ? WSUtil.EMPTY_STRING : templateText.getText( );
WSConsole.getInstance( ).setPropertyValue( Constants.WS_QUERYTEXT,
- queryText.getText( ) );
+ templateContent );
+
WSConsole.getInstance( ).updateParameters( parameters );
saved = true;
}
@@ -414,7 +475,7 @@ public class SOAPRequestPage extends DataSetWizardPage
private void validatePageStatus( )
{
boolean valid = true;
- if ( queryText.getText( ).trim( ).length( ) == 0 )
+ if ( templateText.getText( ).trim( ).length( ) == 0 )
{
valid = false;
}
@@ -425,7 +486,7 @@ public class SOAPRequestPage extends DataSetWizardPage
{
private TableViewer viewer;
-
+ private Button editBtn;
/**
*
*/