|
Lines 1-5
Link Here
|
| 1 |
/********************************************************************** |
1 |
/********************************************************************** |
| 2 |
* Copyright (c) 2005, 2007 IBM Corporation and others. |
2 |
* Copyright (c) 2005, 2008 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 9-21
Link Here
|
| 9 |
* Contributors: |
9 |
* Contributors: |
| 10 |
* IBM Corporation - initial API and implementation |
10 |
* IBM Corporation - initial API and implementation |
| 11 |
**********************************************************************/ |
11 |
**********************************************************************/ |
| 12 |
|
|
|
| 13 |
package org.eclipse.hyades.internal.execution.recorder.ui.views; |
12 |
package org.eclipse.hyades.internal.execution.recorder.ui.views; |
| 14 |
|
13 |
|
| 15 |
import org.eclipse.core.resources.IResourceStatus; |
14 |
import org.eclipse.core.resources.IResourceStatus; |
| 16 |
import org.eclipse.core.resources.ResourcesPlugin; |
15 |
import org.eclipse.core.resources.ResourcesPlugin; |
| 17 |
import org.eclipse.core.runtime.Status; |
16 |
import org.eclipse.core.runtime.Status; |
| 18 |
import org.eclipse.hyades.execution.recorder.IRecorderListenerFullFeedback; |
17 |
import org.eclipse.hyades.execution.recorder.IRecorderListenerFullFeedback; |
|
|
18 |
import org.eclipse.hyades.internal.execution.recorder.ui.CopyAction; |
| 19 |
import org.eclipse.hyades.internal.execution.recorder.ui.RecorderUIUtility; |
19 |
import org.eclipse.hyades.internal.execution.recorder.ui.RecorderUIUtility; |
| 20 |
import org.eclipse.hyades.internal.execution.recorder.ui.actions.StopRecordingAction; |
20 |
import org.eclipse.hyades.internal.execution.recorder.ui.actions.StopRecordingAction; |
| 21 |
import org.eclipse.hyades.test.core.internal.resources.TestCorePluginResourceBundle; |
21 |
import org.eclipse.hyades.test.core.internal.resources.TestCorePluginResourceBundle; |
|
Lines 25-30
Link Here
|
| 25 |
import org.eclipse.jface.action.ToolBarManager; |
25 |
import org.eclipse.jface.action.ToolBarManager; |
| 26 |
import org.eclipse.jface.dialogs.ErrorDialog; |
26 |
import org.eclipse.jface.dialogs.ErrorDialog; |
| 27 |
import org.eclipse.swt.SWT; |
27 |
import org.eclipse.swt.SWT; |
|
|
28 |
import org.eclipse.swt.dnd.Clipboard; |
| 29 |
import org.eclipse.swt.events.SelectionEvent; |
| 30 |
import org.eclipse.swt.events.SelectionListener; |
| 28 |
import org.eclipse.swt.graphics.FontMetrics; |
31 |
import org.eclipse.swt.graphics.FontMetrics; |
| 29 |
import org.eclipse.swt.graphics.GC; |
32 |
import org.eclipse.swt.graphics.GC; |
| 30 |
import org.eclipse.swt.layout.GridData; |
33 |
import org.eclipse.swt.layout.GridData; |
|
Lines 34-50
Link Here
|
| 34 |
import org.eclipse.swt.widgets.Canvas; |
37 |
import org.eclipse.swt.widgets.Canvas; |
| 35 |
import org.eclipse.swt.widgets.Composite; |
38 |
import org.eclipse.swt.widgets.Composite; |
| 36 |
import org.eclipse.swt.widgets.Display; |
39 |
import org.eclipse.swt.widgets.Display; |
|
|
40 |
import org.eclipse.swt.widgets.Event; |
| 37 |
import org.eclipse.swt.widgets.Label; |
41 |
import org.eclipse.swt.widgets.Label; |
| 38 |
import org.eclipse.swt.widgets.List; |
42 |
import org.eclipse.swt.widgets.List; |
|
|
43 |
import org.eclipse.swt.widgets.Listener; |
| 44 |
import org.eclipse.swt.widgets.Menu; |
| 45 |
import org.eclipse.swt.widgets.MenuItem; |
| 39 |
import org.eclipse.swt.widgets.Text; |
46 |
import org.eclipse.swt.widgets.Text; |
| 40 |
import org.eclipse.ui.IWorkbenchPage; |
47 |
import org.eclipse.ui.IWorkbenchPage; |
| 41 |
import org.eclipse.ui.IWorkbenchWindow; |
48 |
import org.eclipse.ui.IWorkbenchWindow; |
| 42 |
import org.eclipse.ui.PlatformUI; |
49 |
import org.eclipse.ui.PlatformUI; |
|
|
50 |
import org.eclipse.ui.actions.ActionFactory; |
| 43 |
import org.eclipse.ui.part.ViewPart; |
51 |
import org.eclipse.ui.part.ViewPart; |
| 44 |
|
52 |
|
| 45 |
/** |
53 |
/** |
| 46 |
* Recorder Control View for receiving feedback and controlling recorders during recording |
54 |
* Recorder Control View for receiving feedback and controlling recorders during recording. |
| 47 |
* @author Ernest Jessee |
55 |
* |
|
|
56 |
* |
| 57 |
* @author Ernest Jessee |
| 58 |
* @author Paul E. Slauenwhite |
| 59 |
* @author Paul Klicnik |
| 60 |
* @version February 20, 2008 |
| 61 |
* @since February 1, 2005 |
| 48 |
*/ |
62 |
*/ |
| 49 |
public class RecorderControlView extends ViewPart implements ITestgenListener, IRecorderListenerFullFeedback |
63 |
public class RecorderControlView extends ViewPart implements ITestgenListener, IRecorderListenerFullFeedback |
| 50 |
{ |
64 |
{ |
|
Lines 68-73
Link Here
|
| 68 |
*/ |
82 |
*/ |
| 69 |
public static RecorderControlView instance=null; |
83 |
public static RecorderControlView instance=null; |
| 70 |
|
84 |
|
|
|
85 |
/** |
| 86 |
* Setup the clipboard |
| 87 |
*/ |
| 88 |
private Clipboard clipboard = null; |
| 89 |
|
| 90 |
/** |
| 91 |
* Create the action for copying |
| 92 |
*/ |
| 93 |
private CopyAction copyAction = null; |
| 94 |
|
| 71 |
|
95 |
|
| 72 |
/** |
96 |
/** |
| 73 |
* the view's ID |
97 |
* the view's ID |
|
Lines 81-87
Link Here
|
| 81 |
/** |
105 |
/** |
| 82 |
* @see ViewPart#createPartControl |
106 |
* @see ViewPart#createPartControl |
| 83 |
*/ |
107 |
*/ |
| 84 |
public void createPartControl(Composite grandParent) |
108 |
public void createPartControl(final Composite grandParent) |
| 85 |
{ |
109 |
{ |
| 86 |
FontMetrics fm = new GC(grandParent).getFontMetrics(); |
110 |
FontMetrics fm = new GC(grandParent).getFontMetrics(); |
| 87 |
int heightHint = fm.getHeight() + fm.getAscent() + fm.getDescent(); |
111 |
int heightHint = fm.getHeight() + fm.getAscent() + fm.getDescent(); |
|
Lines 120-134
Link Here
|
| 120 |
recStatus.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
144 |
recStatus.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
| 121 |
|
145 |
|
| 122 |
|
146 |
|
| 123 |
statusList = new List(parent,SWT.V_SCROLL|SWT.H_SCROLL|SWT.READ_ONLY|SWT.BORDER); |
147 |
statusList = new List(parent,SWT.V_SCROLL|SWT.H_SCROLL|SWT.READ_ONLY|SWT.BORDER|SWT.MULTI); |
| 124 |
statusList.setLayoutData(new GridData(GridData.FILL_BOTH)); |
148 |
statusList.setLayoutData(new GridData(GridData.FILL_BOTH)); |
| 125 |
|
149 |
|
| 126 |
ToolBarManager toolbarManager = (ToolBarManager)getViewSite().getActionBars().getToolBarManager(); |
150 |
clipboard = new Clipboard(grandParent.getDisplay()); |
|
|
151 |
copyAction = new CopyAction( clipboard ); |
| 152 |
copyAction.setEnabled( false ); |
| 153 |
statusList.addSelectionListener( new SelectionListener() { |
| 154 |
public void widgetSelected(SelectionEvent e) { |
| 155 |
/* A new selection has been made in the Recorder Control ... |
| 156 |
* Update the selected lines */ |
| 157 |
setSelectedLines(); |
| 158 |
} |
| 159 |
public void widgetDefaultSelected(SelectionEvent e) {} |
| 160 |
}); |
| 161 |
|
| 162 |
/* Add the support for the context menu */ |
| 163 |
statusList.addListener( SWT.MenuDetect, new Listener () { |
| 164 |
public void handleEvent (Event event) { |
| 165 |
Menu menu = new Menu( grandParent.getShell(), SWT.POP_UP ); |
| 127 |
|
166 |
|
|
|
167 |
MenuItem copyItem = new MenuItem( menu, SWT.PUSH ); |
| 168 |
copyItem.setText( UiPluginResourceBundle.command_Copy ); |
| 169 |
copyItem.addListener( SWT.Selection, new Listener () { |
| 170 |
public void handleEvent (Event e) { |
| 171 |
setSelectedLines(); |
| 172 |
copyAction.run(); |
| 173 |
} |
| 174 |
}); |
| 175 |
menu.setLocation( event.x, event.y ); |
| 176 |
MenuItem selectAllItem = new MenuItem( menu, SWT.PUSH ); |
| 177 |
selectAllItem.setText( UiPluginResourceBundle.command_SelectAll ); |
| 178 |
selectAllItem.addListener( SWT.Selection, new Listener() { |
| 179 |
public void handleEvent (Event e) { |
| 180 |
statusList.selectAll(); |
| 181 |
setSelectedLines(); |
| 182 |
copyAction.setEnabled( true ); |
| 183 |
} |
| 184 |
}); |
| 185 |
if ( statusList.getSelection().length == 0 ) { |
| 186 |
copyAction.setEnabled( false ); |
| 187 |
copyItem.setEnabled( false ); |
| 188 |
} |
| 189 |
menu.setVisible( true ); |
| 190 |
} |
| 191 |
}); |
| 192 |
|
| 193 |
getViewSite().getActionBars().setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction); |
| 194 |
ToolBarManager toolbarManager = (ToolBarManager)getViewSite().getActionBars().getToolBarManager(); |
| 195 |
|
| 128 |
//add new items group |
196 |
//add new items group |
| 129 |
toolbarManager.add(new GroupMarker(STARTGROUP)); |
197 |
toolbarManager.add(new GroupMarker(STARTGROUP)); |
| 130 |
toolbarManager.add(new StopRecordingAction()); |
198 |
toolbarManager.add(new StopRecordingAction()); |
| 131 |
|
199 |
} |
|
|
200 |
|
| 201 |
private void setSelectedLines() { |
| 202 |
if ( statusList != null && copyAction != null ) { |
| 203 |
String[] statusLines = statusList.getSelection(); |
| 204 |
copyAction.setSelectedStatusItems( statusLines ); |
| 205 |
copyAction.setEnabled( statusLines.length == 0 ? false : true ); |
| 206 |
} |
| 132 |
} |
207 |
} |
| 133 |
|
208 |
|
| 134 |
/** |
209 |
/** |
|
Lines 166-175
Link Here
|
| 166 |
{ |
241 |
{ |
| 167 |
IWorkbenchPage page = window.getActivePage(); |
242 |
IWorkbenchPage page = window.getActivePage(); |
| 168 |
instance = (RecorderControlView)page.showView(ID); |
243 |
instance = (RecorderControlView)page.showView(ID); |
| 169 |
// |
|
|
| 170 |
// if(view != null){ |
| 171 |
//// ...do something |
| 172 |
// } |
| 173 |
} |
244 |
} |
| 174 |
catch(Exception e) |
245 |
catch(Exception e) |
| 175 |
{ |
246 |
{ |
|
Lines 257-263
Link Here
|
| 257 |
*/ |
328 |
*/ |
| 258 |
public void setFocus() |
329 |
public void setFocus() |
| 259 |
{ |
330 |
{ |
| 260 |
|
331 |
setSelectedLines(); |
|
|
332 |
copyAction.setEnabled( statusList.getSelection().length == 0 ? false : true ); |
| 261 |
} |
333 |
} |
| 262 |
|
334 |
|
| 263 |
/** |
335 |
/** |
|
Lines 320-326
Link Here
|
| 320 |
recStatus.setText(str); |
392 |
recStatus.setText(str); |
| 321 |
} |
393 |
} |
| 322 |
}); |
394 |
}); |
| 323 |
} |
395 |
} |
| 324 |
|
396 |
} |
| 325 |
} |
|
|
| 326 |
} |
397 |
} |