Permalink
Browse files

Hook up feedback for RGBExpressionViewer and disconnect listener whil…

…e refreshing the controls. Applied latest code formatting settings.

Signed-off-by: Jody Garnett <jody.garnett@gmail.com>
  • Loading branch information...
1 parent 0f1184c commit 1d429c47a74d2c776241522a1c05a01522bafa30 @jodygarnett jodygarnett committed Apr 12, 2012
@@ -52,19 +52,22 @@
public class DefaultExpressionViewer extends IExpressionViewer {
/**
* Factory used for the general purpose DefaultExpressionViewer.
+ *
* @author jody
* @since 1.2.0
*/
public static class Factory extends ExpressionViewerFactory {
@Override
- public int appropriate( SimpleFeatureType schema, Expression expression ) {
+ public int appropriate(SimpleFeatureType schema, Expression expression) {
return COMPLETE;
}
+
@Override
- public IExpressionViewer createViewer( Composite parent, int style ) {
+ public IExpressionViewer createViewer(Composite parent, int style) {
return new DefaultExpressionViewer(parent, style);
}
}
+
/**
* This is the expression we are working on here.
* <p>
@@ -89,8 +92,8 @@ public IExpressionViewer createViewer( Composite parent, int style ) {
*/
private SimpleFeatureType type;
- private KeyListener keyListener = new KeyListener(){
- public void keyReleased( KeyEvent e ) {
+ private KeyListener keyListener = new KeyListener() {
+ public void keyReleased(KeyEvent e) {
// we can try and parse this puppy; and issue a selection changed
// event when we actually have an expression that works
String before = expr != null ? CQL.toCQL(expr) : "(empty)";
@@ -101,17 +104,19 @@ public void keyReleased( KeyEvent e ) {
getSelection()));
}
}
- public void keyPressed( KeyEvent e ) {
+
+ public void keyPressed(KeyEvent e) {
}
};
private ControlDecoration feedback;
private FunctionContentProposalProvider proposalProvider;
- public DefaultExpressionViewer( Composite parent ) {
+ public DefaultExpressionViewer(Composite parent) {
this(parent, SWT.SINGLE);
}
+
/**
* Creates an ExpressionViewer using the provided style.
* <ul>
@@ -129,7 +134,7 @@ public DefaultExpressionViewer( Composite parent ) {
* @param parent
* @param none
*/
- public DefaultExpressionViewer( Composite parent, int style ) {
+ public DefaultExpressionViewer(Composite parent, int style) {
super(parent, style);
text = new Text(parent, style);
feedback = new ControlDecoration(text, SWT.TOP | SWT.LEFT);
@@ -154,6 +159,7 @@ public DefaultExpressionViewer( Composite parent, int style ) {
public Text getControl() {
return text;
}
+
/**
* The isRequired flag will be used to determine the default decoration to show (if there is no
* warning or error to take precedence).
@@ -164,7 +170,7 @@ public Text getControl() {
*
* @param isRequired true if this is a required field
*/
- public void setRequired( boolean isRequired ) {
+ public void setRequired(boolean isRequired) {
this.isRequired = isRequired;
}
@@ -246,6 +252,7 @@ public String getValidationMessage() {
}
return null; // all good then
}
+
/**
* Provides access to the Expression being used by this viewer.
* <p>
@@ -259,7 +266,8 @@ public Expression getInput() {
@Override
public ISelection getSelection() {
- if (expr == null) return null;
+ if (expr == null)
+ return null;
IStructuredSelection selection = new StructuredSelection(expr);
return selection;
@@ -268,9 +276,10 @@ public ISelection getSelection() {
@Override
public void refresh() {
if (text != null && !text.isDisposed()) {
- text.getDisplay().asyncExec(new Runnable(){
+ text.getDisplay().asyncExec(new Runnable() {
public void run() {
- if (text == null || text.isDisposed()) return;
+ if (text == null || text.isDisposed())
+ return;
String cql = CQL.toCQL(expr);
text.setText(cql);
}
@@ -292,7 +301,7 @@ public void run() {
* @param input Expression or String to use as the input for this viewer
*/
@Override
- public void setInput( Object input ) {
+ public void setInput(Object input) {
if (input instanceof Expression) {
expr = (Expression) input;
refresh();
@@ -304,7 +313,7 @@ public void setInput( Object input ) {
// feedback that things are bad
}
// use the text as provided
- text.getDisplay().asyncExec(new Runnable(){
+ text.getDisplay().asyncExec(new Runnable() {
public void run() {
text.setText(txt);
}
@@ -313,7 +322,7 @@ public void run() {
}
@Override
- public void setSelection( ISelection selection, boolean reveal ) {
+ public void setSelection(ISelection selection, boolean reveal) {
// do nothing by default
}
@@ -327,14 +336,15 @@ public void setSelection( ISelection selection, boolean reveal ) {
public void feedback() {
feedback.hide();
}
+
/**
* Provide the feedback that everything is fine.
* <p>
* This method will make use of an associated ControlDecoration if available; if not it will
* make use of a tooltip or something.
* </p>
*/
- public void feedback( String warning ) {
+ public void feedback(String warning) {
if (feedback != null) {
feedback.setDescriptionText(warning);
feedback.show();
@@ -344,30 +354,32 @@ public void feedback( String warning ) {
control.setToolTipText(warning);
}
}
+
/**
* Provide the feedback that everything is fine.
* <p>
* This method will make use of an associated ControlDecoration if available; if not it will
* make use of a tooltip or something.
* </p>
*/
- public void feedback( String error, Exception eek ) {
+ public void feedback(String error, Exception eek) {
Control control = getControl();
if (control != null && !control.isDisposed()) {
control.setToolTipText(error + ":" + eek);
}
}
+
/**
* Feature Type to use for attribute names.
*
* @param type
*/
- public void setSchema( SimpleFeatureType type ) {
+ public void setSchema(SimpleFeatureType type) {
if (type == null) {
return;
}
Set<String> names = new HashSet<String>();
- for( AttributeDescriptor attribute : type.getAttributeDescriptors() ) {
+ for (AttributeDescriptor attribute : type.getAttributeDescriptors()) {
names.add(attribute.getLocalName());
}
proposalProvider.setExtra(names);
@@ -380,12 +392,13 @@ public SimpleFeatureType getSchema() {
}
@Override
- public void setExpected( Class< ? > binding ) {
+ public void setExpected(Class<?> binding) {
// TODO Auto-generated method stub
}
+
@Override
- public Class< ? > getExpected() {
+ public Class<?> getExpected() {
// TODO Auto-generated method stub
return null;
}
Oops, something went wrong.

0 comments on commit 1d429c4

Please sign in to comment.