Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3903897
commit 837047d
Showing
8 changed files
with
299 additions
and
44 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
...ell.ui/src/net/sf/eclipsefp/haskell/ui/internal/views/worksheet/EvalExpressionDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/** | ||
* Copyright (c) 2014 by JP Moresmau | ||
* This code is made available under the terms of the Eclipse Public License, | ||
* version 1.0 (EPL). See http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package net.sf.eclipsefp.haskell.ui.internal.views.worksheet; | ||
|
||
import net.sf.eclipsefp.haskell.ui.internal.util.UITexts; | ||
import org.eclipse.jface.dialogs.IInputValidator; | ||
import org.eclipse.jface.dialogs.InputDialog; | ||
import org.eclipse.jface.viewers.ArrayContentProvider; | ||
import org.eclipse.jface.viewers.ComboViewer; | ||
import org.eclipse.jface.viewers.ISelectionChangedListener; | ||
import org.eclipse.jface.viewers.IStructuredSelection; | ||
import org.eclipse.jface.viewers.LabelProvider; | ||
import org.eclipse.jface.viewers.SelectionChangedEvent; | ||
import org.eclipse.jface.viewers.StructuredSelection; | ||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.layout.GridData; | ||
import org.eclipse.swt.layout.GridLayout; | ||
import org.eclipse.swt.widgets.Composite; | ||
import org.eclipse.swt.widgets.Control; | ||
import org.eclipse.swt.widgets.Label; | ||
import org.eclipse.swt.widgets.Shell; | ||
import org.eclipse.ui.model.WorkbenchViewerComparator; | ||
|
||
|
||
/** | ||
* Input dialog for expressions and their rendering type | ||
* @author JP Moresmau | ||
* | ||
*/ | ||
public class EvalExpressionDialog extends InputDialog { | ||
private ResultType resultType=ResultType.TEXT; | ||
|
||
/** | ||
* @param parentShell | ||
* @param dialogTitle | ||
* @param dialogMessage | ||
* @param initialValue | ||
* @param validator | ||
*/ | ||
public EvalExpressionDialog( final Shell parentShell, final String dialogTitle, | ||
final String dialogMessage, final EvalExpression initialValue) { | ||
super( parentShell, dialogTitle, dialogMessage, initialValue.getExpression(), new EvalExpressionValidator() ); | ||
this.resultType=initialValue.getResultType(); | ||
} | ||
|
||
/* (non-Javadoc) | ||
* @see org.eclipse.jface.dialogs.InputDialog#createDialogArea(org.eclipse.swt.widgets.Composite) | ||
*/ | ||
@Override | ||
protected Control createDialogArea( final Composite parent ) { | ||
Composite c=(Composite)super.createDialogArea( parent ); | ||
|
||
Composite typeC=new Composite(c,SWT.NONE); | ||
typeC.setLayoutData( new GridData(GridData.FILL_HORIZONTAL) ); | ||
typeC.setLayout( new GridLayout(2,false) ); | ||
Label typeL=new Label(typeC,SWT.NONE); | ||
typeL.setText( UITexts.worksheet_expression_type ); | ||
|
||
ComboViewer cv=new ComboViewer( typeC,SWT.READ_ONLY | SWT.SINGLE); | ||
cv.setContentProvider( new ArrayContentProvider() ); | ||
cv.setLabelProvider( new LabelProvider() ); | ||
cv.setComparator( new WorkbenchViewerComparator() ); | ||
|
||
cv.setInput( ResultType.values() ); | ||
cv.setSelection( new StructuredSelection(resultType) ); | ||
cv.addSelectionChangedListener( new ISelectionChangedListener() { | ||
|
||
@Override | ||
public void selectionChanged( final SelectionChangedEvent event ) { | ||
resultType=(ResultType)((IStructuredSelection)event.getSelection()).getFirstElement(); | ||
} | ||
} ); | ||
return c; | ||
} | ||
|
||
|
||
/** | ||
* @return the resultType | ||
*/ | ||
public ResultType getResultType() { | ||
return resultType; | ||
} | ||
|
||
private static class EvalExpressionValidator implements IInputValidator { | ||
/* (non-Javadoc) | ||
* @see org.eclipse.jface.dialogs.IInputValidator#isValid(java.lang.String) | ||
*/ | ||
@Override | ||
public String isValid( final String newText ) { | ||
if (newText==null || newText.trim().length()==0){ | ||
return UITexts.worksheet_expression_empty; | ||
} | ||
return null; | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...psefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/views/worksheet/ResultType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Copyright (c) 2014 by JP Moresmau | ||
* This code is made available under the terms of the Eclipse Public License, | ||
* version 1.0 (EPL). See http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package net.sf.eclipsefp.haskell.ui.internal.views.worksheet; | ||
|
||
|
||
/** | ||
* Type of result we know how to render in an EvalComposite | ||
* @author JP Moresmau | ||
* | ||
*/ | ||
public enum ResultType { | ||
TEXT, | ||
HTML, | ||
JSON, | ||
// SVG, | ||
// IMAGE | ||
} |
Oops, something went wrong.