Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

editor to force variable evaluation

  • Loading branch information...
commit a74afe93456df8e97f12336a3847ea9a623589a8 1 parent 55f81b7
@JPMoresmau authored
View
62 ...java/src/net/sf/eclipsefp/haskell/debug/ui/internal/debug/HaskellVariableValueEditor.java
@@ -0,0 +1,62 @@
+package net.sf.eclipsefp.haskell.debug.ui.internal.debug;
+
+
+import net.sf.eclipsefp.haskell.core.HaskellCorePlugin;
+import net.sf.eclipsefp.haskell.debug.ui.internal.util.UITexts;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.debug.ui.actions.IVariableValueEditor;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * This editor only forces evaluation when clicking on OK
+ * @author JP Moresmau
+ *
+ */
+public class HaskellVariableValueEditor implements IVariableValueEditor {
+
+
+ public boolean editVariable( final IVariable variable, final Shell shell ) {
+
+ Dialog d=new Dialog(shell) {
+ @Override
+ protected Control createDialogArea( final Composite parent ) {
+ Composite c=(Composite)super.createDialogArea( parent );
+ Text l=new Text( c, SWT.MULTI | SWT.WRAP);
+ l.setEditable( false );
+ l.setLayoutData(new GridData(GridData.FILL_BOTH));
+ l.setText( UITexts.debug_editor_text );
+ return c;
+ }
+
+ @Override
+ protected void configureShell( final Shell newShell ) {
+ super.configureShell( newShell );
+ newShell.setText( UITexts.debug_editor_title );
+ newShell.setSize( 300, 200 );
+ }
+ };
+ int code=d.open();
+ if (code==Window.OK){
+ try {
+ variable.setValue( "force" ); //$NON-NLS-1$
+ } catch (DebugException de){
+ HaskellCorePlugin.log( de );
+ }
+ }
+ return true;
+ }
+
+ public boolean saveVariable( final IVariable variable, final String expression,
+ final Shell shell ) {
+ return false;
+ }
+
+}
View
3  ...l.debug.ui/INTERNAL/java/src/net/sf/eclipsefp/haskell/debug/ui/internal/util/UITexts.java
@@ -39,6 +39,9 @@
public static String error_read_configuration;
+ public static String debug_editor_title;
+ public static String debug_editor_text;
+
private static final String BUNDLE_NAME
= UITexts.class.getPackage().getName() + ".uitexts"; //$NON-NLS-1$
View
5 ...g.ui/INTERNAL/java/src/net/sf/eclipsefp/haskell/debug/ui/internal/util/uitexts.properties
@@ -28,4 +28,7 @@ launchOperation_title = Select Launch Configuration
error_read_configuration=Error reading Launch Configuration
-configuration_name={0} ({1} {2})
+configuration_name={0} ({1} {2})
+
+debug_editor_title=Force variable evaluation
+debug_editor_text=Haskell variables cannot have values assigned to them. But by clicking OK you can force evaluation of the variable. Be aware that forcing evaluation of a variable instead of leaving Haskell lazy evaluation system decide when to do it can change the behavior of your code.
View
7 net.sf.eclipsefp.haskell.debug.ui/plugin.xml
@@ -113,4 +113,11 @@
id="net.sf.eclipsefp.haskell.debug">
</debugModelPresentation>
</extension>
+ <extension
+ point="org.eclipse.debug.ui.variableValueEditors">
+ <variableValueEditor
+ class="net.sf.eclipsefp.haskell.debug.ui.internal.debug.HaskellVariableValueEditor"
+ modelId="net.sf.eclipsefp.haskell.debug">
+ </variableValueEditor>
+ </extension>
</plugin>
Please sign in to comment.
Something went wrong with that request. Please try again.