summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorKrzysztof Daniel2010-09-08 08:45:21 (EDT)
committer Dani Megert2011-10-06 08:39:34 (EDT)
commit77bb45f025683db565bd54bf4553d6449d8447cf (patch)
treed738896c8725e5974420ab66a444655de993ab6e
parenta80fd086807478cec45eed23248979fcf93dfa5c (diff)
downloadeclipse.platform.ui-77bb45f025683db565bd54bf4553d6449d8447cf.zip
eclipse.platform.ui-77bb45f025683db565bd54bf4553d6449d8447cf.tar.gz
eclipse.platform.ui-77bb45f025683db565bd54bf4553d6449d8447cf.tar.bz2
bug 324138 - [ErrorHandling] Copy action from error dialog causes invalid argument exception
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/statushandlers/DefaultDetailsArea.java36
1 files changed, 27 insertions, 9 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/statushandlers/DefaultDetailsArea.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/statushandlers/DefaultDetailsArea.java
index 872025d..d5f7f48 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/statushandlers/DefaultDetailsArea.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/statushandlers/DefaultDetailsArea.java
@@ -37,6 +37,7 @@ import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
@@ -77,6 +78,8 @@ public class DefaultDetailsArea extends AbstractStatusAreaProvider {
private Map dialogState;
+ private MenuItem copyAction;
+
/**
* @param dialogState
*/
@@ -170,6 +173,25 @@ public class DefaultDetailsArea extends AbstractStatusAreaProvider {
// no op
}
});
+ text.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent e) {
+ if (text.getSelectionText().length() == 0) {
+ if (copyAction != null && !copyAction.isDisposed()) {
+ copyAction.setEnabled(false);
+ }
+ } else {
+ if (copyAction != null && !copyAction.isDisposed()) {
+ copyAction.setEnabled(true);
+ }
+ }
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+
+ });
createDNDSource();
createCopyAction(parent);
Dialog.applyDialogFont(parent);
@@ -233,7 +255,7 @@ public class DefaultDetailsArea extends AbstractStatusAreaProvider {
public void dragSetData(DragSourceEvent event) {
if (TextTransfer.getInstance().isSupportedType(event.dataType)) {
- event.data = prepareCopyString();
+ event.data = text.getSelectionText();
}
}
@@ -244,7 +266,7 @@ public class DefaultDetailsArea extends AbstractStatusAreaProvider {
private void createCopyAction(final Composite parent) {
Menu menu = new Menu(parent.getShell(), SWT.POP_UP);
- MenuItem copyAction = new MenuItem(menu, SWT.PUSH);
+ copyAction = new MenuItem(menu, SWT.PUSH);
copyAction.setText(JFaceResources.getString("copy")); //$NON-NLS-1$
copyAction.addSelectionListener(new SelectionAdapter() {
@@ -262,13 +284,9 @@ public class DefaultDetailsArea extends AbstractStatusAreaProvider {
});
text.setMenu(menu);
- }
-
- private String prepareCopyString() {
- if (text == null || text.isDisposed()) {
- return ""; //$NON-NLS-1$
+ if (text.getSelectionText().length() == 0) {
+ copyAction.setEnabled(false);
}
- return text.getSelectionText();
}
private void populateList(StyledText text, IStatus status, int nesting,
@@ -317,7 +335,7 @@ public class DefaultDetailsArea extends AbstractStatusAreaProvider {
Clipboard clipboard = null;
try {
clipboard = new Clipboard(text.getDisplay());
- clipboard.setContents(new Object[] { prepareCopyString() },
+ clipboard.setContents(new Object[] { text.getSelectionText() },
new Transfer[] { TextTransfer.getInstance() });
} finally {
if (clipboard != null) {