|
Lines 11-20
Link Here
|
| 11 |
|
11 |
|
| 12 |
package org.eclipse.ui.internal.statushandlers; |
12 |
package org.eclipse.ui.internal.statushandlers; |
| 13 |
|
13 |
|
|
|
14 |
import java.util.ArrayList; |
| 14 |
import java.util.Date; |
15 |
import java.util.Date; |
| 15 |
|
16 |
|
| 16 |
import org.eclipse.core.runtime.CoreException; |
17 |
import org.eclipse.core.runtime.CoreException; |
| 17 |
import org.eclipse.core.runtime.IStatus; |
18 |
import org.eclipse.core.runtime.IStatus; |
|
|
19 |
import org.eclipse.jface.bindings.TriggerSequence; |
| 20 |
import org.eclipse.jface.bindings.keys.KeySequence; |
| 21 |
import org.eclipse.jface.bindings.keys.KeyStroke; |
| 18 |
import org.eclipse.jface.dialogs.Dialog; |
22 |
import org.eclipse.jface.dialogs.Dialog; |
| 19 |
import org.eclipse.jface.resource.JFaceResources; |
23 |
import org.eclipse.jface.resource.JFaceResources; |
| 20 |
import org.eclipse.osgi.util.NLS; |
24 |
import org.eclipse.osgi.util.NLS; |
|
Lines 26-31
Link Here
|
| 26 |
import org.eclipse.swt.dnd.DragSourceListener; |
30 |
import org.eclipse.swt.dnd.DragSourceListener; |
| 27 |
import org.eclipse.swt.dnd.TextTransfer; |
31 |
import org.eclipse.swt.dnd.TextTransfer; |
| 28 |
import org.eclipse.swt.dnd.Transfer; |
32 |
import org.eclipse.swt.dnd.Transfer; |
|
|
33 |
import org.eclipse.swt.events.KeyEvent; |
| 34 |
import org.eclipse.swt.events.KeyListener; |
| 29 |
import org.eclipse.swt.events.SelectionAdapter; |
35 |
import org.eclipse.swt.events.SelectionAdapter; |
| 30 |
import org.eclipse.swt.events.SelectionEvent; |
36 |
import org.eclipse.swt.events.SelectionEvent; |
| 31 |
import org.eclipse.swt.layout.GridData; |
37 |
import org.eclipse.swt.layout.GridData; |
|
Lines 35-41
Link Here
|
| 35 |
import org.eclipse.swt.widgets.List; |
41 |
import org.eclipse.swt.widgets.List; |
| 36 |
import org.eclipse.swt.widgets.Menu; |
42 |
import org.eclipse.swt.widgets.Menu; |
| 37 |
import org.eclipse.swt.widgets.MenuItem; |
43 |
import org.eclipse.swt.widgets.MenuItem; |
|
|
44 |
import org.eclipse.ui.PlatformUI; |
| 45 |
import org.eclipse.ui.actions.ActionFactory; |
| 38 |
import org.eclipse.ui.internal.progress.ProgressMessages; |
46 |
import org.eclipse.ui.internal.progress.ProgressMessages; |
|
|
47 |
import org.eclipse.ui.keys.IBindingService; |
| 39 |
import org.eclipse.ui.statushandlers.AbstractStatusAreaProvider; |
48 |
import org.eclipse.ui.statushandlers.AbstractStatusAreaProvider; |
| 40 |
import org.eclipse.ui.statushandlers.IStatusAdapterConstants; |
49 |
import org.eclipse.ui.statushandlers.IStatusAdapterConstants; |
| 41 |
import org.eclipse.ui.statushandlers.StatusAdapter; |
50 |
import org.eclipse.ui.statushandlers.StatusAdapter; |
|
Lines 97-111
Link Here
|
| 97 |
gd.widthHint = 250; |
106 |
gd.widthHint = 250; |
| 98 |
gd.heightHint = 100; |
107 |
gd.heightHint = 100; |
| 99 |
list.setLayoutData(gd); |
108 |
list.setLayoutData(gd); |
| 100 |
list.addSelectionListener(new SelectionAdapter() { |
109 |
// There is no support for triggering commands in the dialogs. I am |
| 101 |
/* |
110 |
// trying to emulate the workbench behavior as exactly as possible. |
| 102 |
* (non-Javadoc) |
111 |
IBindingService binding = (IBindingService) PlatformUI.getWorkbench() |
| 103 |
* |
112 |
.getService(IBindingService.class); |
| 104 |
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) |
113 |
//find bindings for copy action |
| 105 |
*/ |
114 |
final TriggerSequence ts[] = binding |
| 106 |
public void widgetSelected(SelectionEvent e) { |
115 |
.getActiveBindingsFor(ActionFactory.COPY.getCommandId()); |
| 107 |
list.selectAll(); |
116 |
list.addKeyListener(new KeyListener() { |
| 108 |
super.widgetSelected(e); |
117 |
|
|
|
118 |
ArrayList keyList = new ArrayList(); |
| 119 |
|
| 120 |
public void keyPressed(KeyEvent e) { |
| 121 |
// get the character. reverse the ctrl modifier if necessary |
| 122 |
char character = e.character; |
| 123 |
boolean ctrlDown = (e.stateMask & SWT.CTRL) != 0; |
| 124 |
if (ctrlDown && e.character != e.keyCode && e.character < 0x20 |
| 125 |
&& (e.keyCode & SWT.KEYCODE_BIT) == 0) { |
| 126 |
character += 0x40; |
| 127 |
} |
| 128 |
// do not process modifier keys |
| 129 |
if((e.keyCode & (~SWT.MODIFIER_MASK)) == 0){ |
| 130 |
return; |
| 131 |
} |
| 132 |
// if there is a character, use it. if no character available, |
| 133 |
// try with key code |
| 134 |
KeyStroke ks = KeyStroke.getInstance(e.stateMask, |
| 135 |
character != 0 ? character : e.keyCode); |
| 136 |
keyList.add(ks); |
| 137 |
KeySequence sequence = KeySequence.getInstance(keyList); |
| 138 |
boolean partialMatch = false; |
| 139 |
for (int i = 0; i < ts.length; i++) { |
| 140 |
if (ts[i].equals(sequence)) { |
| 141 |
copyToClipboard(); |
| 142 |
keyList.clear(); |
| 143 |
break; |
| 144 |
} |
| 145 |
if (ts[i].startsWith(sequence, false)) { |
| 146 |
partialMatch = true; |
| 147 |
} |
| 148 |
for (int j = 0; j < ts[i].getTriggers().length; j++) { |
| 149 |
if (ts[i].getTriggers()[j].equals(ks)) { |
| 150 |
partialMatch = true; |
| 151 |
} |
| 152 |
} |
| 153 |
} |
| 154 |
if (!partialMatch) { |
| 155 |
keyList.clear(); |
| 156 |
} |
| 157 |
} |
| 158 |
|
| 159 |
public void keyReleased(KeyEvent e) { |
| 160 |
//no op |
| 109 |
} |
161 |
} |
| 110 |
}); |
162 |
}); |
| 111 |
createDNDSource(); |
163 |
createDNDSource(); |
|
Lines 165-180
Link Here
|
| 165 |
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) |
217 |
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) |
| 166 |
*/ |
218 |
*/ |
| 167 |
public void widgetSelected(SelectionEvent e) { |
219 |
public void widgetSelected(SelectionEvent e) { |
| 168 |
Clipboard clipboard = null; |
220 |
copyToClipboard(); |
| 169 |
try { |
|
|
| 170 |
clipboard = new Clipboard(parent.getDisplay()); |
| 171 |
clipboard.setContents(new Object[] { prepareCopyString() }, |
| 172 |
new Transfer[] { TextTransfer.getInstance() }); |
| 173 |
} finally { |
| 174 |
if (clipboard != null) { |
| 175 |
clipboard.dispose(); |
| 176 |
} |
| 177 |
} |
| 178 |
super.widgetSelected(e); |
221 |
super.widgetSelected(e); |
| 179 |
} |
222 |
} |
| 180 |
|
223 |
|
|
Lines 188-195
Link Here
|
| 188 |
} |
231 |
} |
| 189 |
StringBuffer sb = new StringBuffer(); |
232 |
StringBuffer sb = new StringBuffer(); |
| 190 |
String newLine = System.getProperty("line.separator"); //$NON-NLS-1$ |
233 |
String newLine = System.getProperty("line.separator"); //$NON-NLS-1$ |
| 191 |
for (int i = 0; i < list.getItemCount(); i++) { |
234 |
String selection[] = list.getSelection(); |
| 192 |
sb.append(list.getItem(i)); |
235 |
for (int i = 0; i < selection.length; i++) { |
|
|
236 |
sb.append(selection[i]); |
| 193 |
sb.append(newLine); |
237 |
sb.append(newLine); |
| 194 |
} |
238 |
} |
| 195 |
return sb.toString(); |
239 |
return sb.toString(); |
|
Lines 239-244
Link Here
|
| 239 |
return list; |
283 |
return list; |
| 240 |
} |
284 |
} |
| 241 |
|
285 |
|
|
|
286 |
private void copyToClipboard() { |
| 287 |
Clipboard clipboard = null; |
| 288 |
try { |
| 289 |
clipboard = new Clipboard(list.getDisplay()); |
| 290 |
clipboard.setContents(new Object[] { prepareCopyString() }, |
| 291 |
new Transfer[] { TextTransfer.getInstance() }); |
| 292 |
} finally { |
| 293 |
if (clipboard != null) { |
| 294 |
clipboard.dispose(); |
| 295 |
} |
| 296 |
} |
| 297 |
} |
| 298 |
|
| 242 |
private boolean isDialogHandlingOKStatuses() { |
299 |
private boolean isDialogHandlingOKStatuses() { |
| 243 |
return ((Boolean) workbenchStatusDialog |
300 |
return ((Boolean) workbenchStatusDialog |
| 244 |
.getProperty(IStatusDialogConstants.HANDLE_OK_STATUSES)) |
301 |
.getProperty(IStatusDialogConstants.HANDLE_OK_STATUSES)) |