Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Implementing the "Display As Array" action

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/ChangeLog,v
retrieving revision 1.109
diff -u -r1.109 ChangeLog
--- ChangeLog 9 Mar 2003 22:51:22 -0000 1.109
+++ ChangeLog 10 Mar 2003 23:06:43 -0000
@@ -1,3 +1,9 @@
+2003-03-10 Mikhail Khodjaiants
+ Implementing the "Display As Array" action.
+ * plugin.xml
+ * plugin.propeties
+ * CastToArrayActionDelegate.java: new
+
 2003-03-09 Mikhail Khodjaiants
  The implementation of the "Cast To Type" and "Restore Default Type" actions.
  * plugin.xml
Index: plugin.properties
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/plugin.properties,v
retrieving revision 1.38
diff -u -r1.38 plugin.properties
--- plugin.properties 9 Mar 2003 22:51:22 -0000 1.38
+++ plugin.properties 10 Mar 2003 23:06:43 -0000
@@ -66,3 +66,5 @@
 CastToTypeAction.tooltip=Cast Varibale To Type
 RestoreDefaultTypeAction.label=Restore Default Type
 RestoreDefaultTypeAction.tooltip=Restore Default Type Of Variable
+CastToArrayAction.label=Display As Array...
+CastToArrayAction.tooltip=Display Variable As Array
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/plugin.xml,v
retrieving revision 1.57
diff -u -r1.57 plugin.xml
--- plugin.xml 9 Mar 2003 22:51:22 -0000 1.57
+++ plugin.xml 10 Mar 2003 23:06:45 -0000
@@ -816,8 +816,8 @@
                id="org.eclipse.cdt.debug.internal.ui.actions.RestoreDefaultTypeActionDelegate">
             <enablement>
                <pluginState
-                     id="org.eclipse.cdt.debug.ui"
-                     value="activated">
+                     value="activated"
+                     id="org.eclipse.cdt.debug.ui">
                </pluginState>
             </enablement>
          </action>
@@ -834,6 +834,22 @@
                <pluginState
                      value="activated"
                      id="org.eclipse.cdt.debug.ui">
+               </pluginState>
+            </enablement>
+         </action>
+         <action
+               label="%CastToArrayAction.label"
+               icon="icons/full/clcl16/showasarray_co.gif"
+               helpContextId="cast_to_array_action_context"
+               tooltip="%CastToArrayAction.tooltip"
+               class="org.eclipse.cdt.debug.internal.ui.actions.CastToArrayActionDelegate"
+               menubarPath="additions"
+               enablesFor="1"
+               id="org.eclipse.cdt.debug.internal.ui.actions.CastToArrayActionDelegate">
+            <enablement>
+               <pluginState
+                     id="org.eclipse.cdt.debug.ui"
+                     value="activated">
                </pluginState>
             </enablement>
          </action>
Index: src/org/eclipse/cdt/debug/internal/ui/actions/CastToArrayActionDelegate.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/internal/ui/actions/CastToArrayActionDelegate.java
diff -N src/org/eclipse/cdt/debug/internal/ui/actions/CastToArrayActionDelegate.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/debug/internal/ui/actions/CastToArrayActionDelegate.java 10 Mar 2003 23:06:46 -0000
@@ -0,0 +1,127 @@
+/*
+ *(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.ICastToArray;
+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 10, 2003
+ */
+public class CastToArrayActionDelegate extends ActionDelegate implements IObjectActionDelegate
+{
+ private ICastToArray fCastToArray = null;
+ private IStatus fStatus = null;
+
+ public CastToArrayActionDelegate()
+ {
+  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 ( getCastToArray() == null )
+   return;
+  BusyIndicator.showWhile( Display.getCurrent(),
+         new Runnable()
+          {
+           public void run()
+           {
+            try
+            {
+             doAction( getCastToArray() );
+             setStatus( null );
+            }
+            catch( DebugException e )
+            {
+            setStatus( e.getStatus() );
+            }
+           }
+          } );
+  if ( getStatus() != null && !getStatus().isOK() )
+  {
+   IWorkbenchWindow window= CDebugUIPlugin.getActiveWorkbenchWindow();
+   if ( window != null )
+   {
+    CDebugUIPlugin.errorDialog( "Unable to display this variable as an array.", 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 ICastToArray )
+   {
+    boolean enabled = ((ICastToArray)element).supportsCastToArray();
+    action.setEnabled( enabled );
+    if ( enabled )
+    {
+     setCastToArray( (ICastToArray)element );
+     return;
+    }
+   }
+  }
+  action.setEnabled( false );
+  setCastToArray( null );
+ }
+
+ protected ICastToArray getCastToArray()
+ {
+  return fCastToArray;
+ }
+
+ protected void setCastToArray( ICastToArray castToArray )
+ {
+  fCastToArray = castToArray;
+ }
+
+ public IStatus getStatus()
+ {
+  return fStatus;
+ }
+
+ public void setStatus( IStatus status )
+ {
+  fStatus = status;
+ }
+
+ protected void doAction( ICastToArray castToArray ) throws DebugException
+ {
+ }
+}

Back to the top