Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] The implementation of the "Cast To Type" and "Restore Default Type" actions

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/ChangeLog,v
retrieving revision 1.108
diff -u -r1.108 ChangeLog
--- ChangeLog 6 Mar 2003 00:13:36 -0000 1.108
+++ ChangeLog 9 Mar 2003 22:48:55 -0000
@@ -1,3 +1,10 @@
+2003-03-09 Mikhail Khodjaiants
+ The implementation of the "Cast To Type" and "Restore Default Type" actions.
+ * plugin.xml
+ * plugin.propeties
+ * CastToTypeActionDelegate.java: new
+ * RestoreDefaultTypeActionDelegate.java: new
+
 2003-03-05 Mikhail Khodjaiants
  The extension of CEditor that displays the 'Source Not Found' form.
  * plugin.properties
Index: plugin.properties
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/plugin.properties,v
retrieving revision 1.37
diff -u -r1.37 plugin.properties
--- plugin.properties 6 Mar 2003 00:13:36 -0000 1.37
+++ plugin.properties 9 Mar 2003 22:48:55 -0000
@@ -62,3 +62,7 @@
 SignalAction.label=Resume With Signal
 SignalZeroAction.label=Resume Without Signal
 
+CastToTypeAction.label=Cast To Type...
+CastToTypeAction.tooltip=Cast Varibale To Type
+RestoreDefaultTypeAction.label=Restore Default Type
+RestoreDefaultTypeAction.tooltip=Restore Default Type Of Variable
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/plugin.xml,v
retrieving revision 1.56
diff -u -r1.56 plugin.xml
--- plugin.xml 6 Mar 2003 00:13:36 -0000 1.56
+++ plugin.xml 9 Mar 2003 22:48:58 -0000
@@ -803,6 +803,41 @@
             </enablement>
          </action>
       </objectContribution>
+      <objectContribution
+            objectClass="org.eclipse.cdt.debug.core.model.ICastToType"
+            id="org.eclipse.cdt.debug.ui.VariableActions">
+         <action
+               label="%RestoreDefaultTypeAction.label"
+               helpContextId="restore_default_type_action_context"
+               tooltip="%RestoreDefaultTypeAction.tooltip"
+               class="org.eclipse.cdt.debug.internal.ui.actions.RestoreDefaultTypeActionDelegate"
+               menubarPath="additions"
+               enablesFor="1"
+               id="org.eclipse.cdt.debug.internal.ui.actions.RestoreDefaultTypeActionDelegate">
+            <enablement>
+               <pluginState
+                     id="org.eclipse.cdt.debug.ui"
+                     value="activated">
+               </pluginState>
+            </enablement>
+         </action>
+         <action
+               label="%CastToTypeAction.label"
+               icon="icons/full/clcl16/casttotype_co.gif"
+               helpContextId="cast_to_type_action_context"
+               tooltip="%CastToTypeAction.tooltip"
+               class="org.eclipse.cdt.debug.internal.ui.actions.CastToTypeActionDelegate"
+               menubarPath="additions"
+               enablesFor="1"
+               id="org.eclipse.cdt.debug.internal.ui.actions.CastToTypeActionDelegate">
+            <enablement>
+               <pluginState
+                     value="activated"
+                     id="org.eclipse.cdt.debug.ui">
+               </pluginState>
+            </enablement>
+         </action>
+      </objectContribution>
    </extension>
    <extension
          point="org.eclipse.ui.viewActions">
Index: src/org/eclipse/cdt/debug/internal/ui/actions/CastToTypeActionDelegate.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/internal/ui/actions/CastToTypeActionDelegate.java
diff -N src/org/eclipse/cdt/debug/internal/ui/actions/CastToTypeActionDelegate.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/debug/internal/ui/actions/CastToTypeActionDelegate.java 9 Mar 2003 22:48:59 -0000
@@ -0,0 +1,165 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+
+package org.eclipse.cdt.debug.internal.ui.actions;
+
+import org.eclipse.cdt.debug.core.model.ICastToType;
+import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.actions.ActionDelegate;
+
+/**
+ * Enter type comment.
+ *
+ * @since Mar 7, 2003
+ */
+public class CastToTypeActionDelegate extends ActionDelegate
+           implements IObjectActionDelegate
+{
+ protected class CastToTypeInputValidator implements IInputValidator
+ {
+  public CastToTypeInputValidator()
+  {
+  }
+
+  public String isValid( String newText )
+  {
+   if ( newText.trim().length() == 0 )
+   {
+    return "Type field must not be empty.";
+   }
+   return null;
+  }
+
+ }
+
+ protected class CastToTypeDialog extends InputDialog
+ {
+  public CastToTypeDialog( Shell parentShell, String initialValue )
+  {
+   super( parentShell, "Cast To Type", "Enter type:", initialValue, new CastToTypeInputValidator() );
+  }
+ }
+
+ private ICastToType fCastToType = null;
+ private IStatus fStatus = null;
+
+ public CastToTypeActionDelegate()
+ {
+  super();
+ }
+
+ /* (non-Javadoc)
+  * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
+  */
+ public void setActivePart( IAction action, IWorkbenchPart targetPart )
+ {
+ }
+
+ /* (non-Javadoc)
+  * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+  */
+ public void run( IAction action )
+ {
+  if ( getCastToType() == null )
+   return;
+  BusyIndicator.showWhile( Display.getCurrent(),
+         new Runnable()
+          {
+           public void run()
+           {
+            try
+            {
+             doAction( getCastToType() );
+             setStatus( null );
+            }
+            catch( DebugException e )
+            {
+            setStatus( e.getStatus() );
+            }
+           }
+          } );
+  if ( getStatus() != null && !getStatus().isOK() )
+  {
+   IWorkbenchWindow window= CDebugUIPlugin.getActiveWorkbenchWindow();
+   if ( window != null )
+   {
+    CDebugUIPlugin.errorDialog( "Unable to cast to type.", getStatus() );
+   }
+   else
+   {
+    CDebugUIPlugin.log( getStatus() );
+   }
+  }  
+ }
+
+ /* (non-Javadoc)
+  * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+  */
+ public void selectionChanged( IAction action, ISelection selection )
+ {
+  if ( selection instanceof IStructuredSelection )
+  {
+   Object element = ((IStructuredSelection)selection).getFirstElement();
+   if ( element instanceof ICastToType )
+   {
+    boolean enabled = ((ICastToType)element).supportsCasting();
+    action.setEnabled( enabled );
+    if ( enabled )
+    {
+     setCastToType( (ICastToType)element );
+     return;
+    }
+   }
+  }
+  action.setEnabled( false );
+  setCastToType( null );
+ }
+
+ protected ICastToType getCastToType()
+ {
+  return fCastToType;
+ }
+
+ protected void setCastToType( ICastToType castToType )
+ {
+  fCastToType = castToType;
+ }
+
+ public IStatus getStatus()
+ {
+  return fStatus;
+ }
+
+ public void setStatus( IStatus status )
+ {
+  fStatus = status;
+ }

+ protected void doAction( ICastToType castToType ) throws DebugException
+ {
+  String currentType = castToType.getCurrentType().trim();
+  CastToTypeDialog dialog = new CastToTypeDialog( CDebugUIPlugin.getActiveWorkbenchShell(), currentType );
+  if ( dialog.open() == Window.OK )
+  {
+   String newType = dialog.getValue().trim();
+   castToType.cast( newType );
+  }
+ }
+}
Index: src/org/eclipse/cdt/debug/internal/ui/actions/RestoreDefaultTypeActionDelegate.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/internal/ui/actions/RestoreDefaultTypeActionDelegate.java
diff -N src/org/eclipse/cdt/debug/internal/ui/actions/RestoreDefaultTypeActionDelegate.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/debug/internal/ui/actions/RestoreDefaultTypeActionDelegate.java 9 Mar 2003 22:48:59 -0000
@@ -0,0 +1,133 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+
+package org.eclipse.cdt.debug.internal.ui.actions;
+
+import org.eclipse.cdt.debug.core.model.ICastToType;
+import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.actions.ActionDelegate;
+
+/**
+ * Enter type comment.
+ *
+ * @since Mar 9, 2003
+ */
+public class RestoreDefaultTypeActionDelegate extends ActionDelegate
+             implements IObjectActionDelegate
+{
+ private ICastToType fCastToType = null;
+ private IStatus fStatus = null;
+
+ /**
+  *
+  */
+ public RestoreDefaultTypeActionDelegate()
+ {
+  super();
+ }
+
+ /* (non-Javadoc)
+  * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
+  */
+ public void setActivePart( IAction action, IWorkbenchPart targetPart )
+ {
+ }
+
+ protected ICastToType getCastToType()
+ {
+  return fCastToType;
+ }
+
+ protected void setCastToType( ICastToType castToType )
+ {
+  fCastToType = castToType;
+ }
+
+ /* (non-Javadoc)
+  * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+  */
+ public void run( IAction action )
+ {
+  if ( getCastToType() == null )
+   return;
+  BusyIndicator.showWhile( Display.getCurrent(),
+         new Runnable()
+          {
+           public void run()
+           {
+            try
+            {
+             doAction( getCastToType() );
+             setStatus( null );
+            }
+            catch( DebugException e )
+            {
+            setStatus( e.getStatus() );
+            }
+           }
+          } );
+  if ( getStatus() != null && !getStatus().isOK() )
+  {
+   IWorkbenchWindow window= CDebugUIPlugin.getActiveWorkbenchWindow();
+   if ( window != null )
+   {
+    CDebugUIPlugin.errorDialog( "Unable to cast to type.", getStatus() );
+   }
+   else
+   {
+    CDebugUIPlugin.log( getStatus() );
+   }
+  }  
+ }
+
+ /* (non-Javadoc)
+  * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+  */
+ public void selectionChanged( IAction action, ISelection selection )
+ {
+  if ( selection instanceof IStructuredSelection )
+  {
+   Object element = ((IStructuredSelection)selection).getFirstElement();
+   if ( element instanceof ICastToType )
+   {
+    boolean enabled = ((ICastToType)element).supportsCasting() && ((ICastToType)element).isCasted();
+    action.setEnabled( enabled );
+    if ( enabled )
+    {
+     setCastToType( (ICastToType)element );
+     return;
+    }
+   }
+  }
+  action.setEnabled( false );
+  setCastToType( null );
+ }
+
+ public IStatus getStatus()
+ {
+  return fStatus;
+ }
+
+ public void setStatus( IStatus status )
+ {
+  fStatus = status;
+ }
+
+ protected void doAction( ICastToType castToType ) throws DebugException
+ {
+  castToType.restoreDefault();
+ }
+}
Index: src/org/eclipse/cdt/debug/ui/object1.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/ui/object1.java
diff -N src/org/eclipse/cdt/debug/ui/object1.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/debug/ui/object1.java 9 Mar 2003 22:49:00 -0000
@@ -0,0 +1,12 @@
+package org.eclipse.cdt.debug.ui;
+
+/**
+ * TODO: Provide description for "object1".
+ */
+public class object1 {
+ /**
+  * TODO: Implement the "object1" constructor.
+  */
+ public object1() {
+ }
+}

Back to the top