Defect 42735¡¾RTE¡¿Action Paste/Paste as plain text is able to be clicked when nothing in clipboard
diff --git a/1.5/plugins/org.eclipse.epf.richtext/src/org/eclipse/epf/richtext/RichText.java b/1.5/plugins/org.eclipse.epf.richtext/src/org/eclipse/epf/richtext/RichText.java
index dcaef8b..4002b88 100644
--- a/1.5/plugins/org.eclipse.epf.richtext/src/org/eclipse/epf/richtext/RichText.java
+++ b/1.5/plugins/org.eclipse.epf.richtext/src/org/eclipse/epf/richtext/RichText.java
@@ -1303,15 +1303,15 @@
}
public void menuShown(MenuEvent e) {
-// Clipboard clipboard = new Clipboard(Display.getCurrent());
-// String html = (String) clipboard.getContents(HTMLTransfer
-// .getInstance());
-// String text = (String) clipboard.getContents(TextTransfer
-// .getInstance());
+ Clipboard clipboard = new Clipboard(Display.getCurrent());
+ String html = (String) clipboard.getContents(HTMLTransfer
+ .getInstance());
+ String text = (String) clipboard.getContents(TextTransfer
+ .getInstance());
cutItem.setEnabled(editable && hasSelection);
copyItem.setEnabled(hasSelection);
- pasteItem.setEnabled(editable);
- pastePlainTextItem.setEnabled(editable);
+ pasteItem.setEnabled(editable && (html != null));
+ pastePlainTextItem.setEnabled(editable && (text != null));
addRowItem.setEnabled(tableSelection);
addColumnItem.setEnabled(tableSelection);
deleteLastRowItem.setEnabled(tableSelection);
diff --git a/1.5/plugins/org.eclipse.epf.richtext/src/org/eclipse/epf/richtext/RichTextEditor.java b/1.5/plugins/org.eclipse.epf.richtext/src/org/eclipse/epf/richtext/RichTextEditor.java
index cbbd68c..3807293 100644
--- a/1.5/plugins/org.eclipse.epf.richtext/src/org/eclipse/epf/richtext/RichTextEditor.java
+++ b/1.5/plugins/org.eclipse.epf.richtext/src/org/eclipse/epf/richtext/RichTextEditor.java
@@ -57,6 +57,7 @@
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.custom.VerifyKeyListener;
import org.eclipse.swt.custom.ViewForm;
+import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTarget;
import org.eclipse.swt.dnd.DropTargetEvent;
@@ -1102,6 +1103,7 @@
protected void fillContextMenu(Menu contextMenu) {
final MenuItem cutItem = new MenuItem(contextMenu, SWT.PUSH);
cutItem.setText(RichTextResources.cutAction_text);
+ cutItem.setImage(RichTextImages.IMG_CUT);
cutItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
CutAction action = new CutAction(RichTextEditor.this);
@@ -1110,6 +1112,7 @@
});
final MenuItem copyItem = new MenuItem(contextMenu, SWT.PUSH);
copyItem.setText(RichTextResources.copyAction_text);
+ copyItem.setImage(RichTextImages.IMG_COPY);
copyItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
CopyAction action = new CopyAction(RichTextEditor.this);
@@ -1118,6 +1121,7 @@
});
final MenuItem pasteItem = new MenuItem(contextMenu, SWT.PUSH);
pasteItem.setText(RichTextResources.pasteAction_text);
+ pasteItem.setImage(RichTextImages.IMG_PASTE);
pasteItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
PasteAction action = new PasteAction(RichTextEditor.this);
@@ -1127,6 +1131,7 @@
final MenuItem pastePlainTextItem = new MenuItem(contextMenu, SWT.PUSH);
pastePlainTextItem.setText(RichTextResources.pastePlainTextAction_text);
+ pastePlainTextItem.setImage(RichTextImages.IMG_PASTE_PLAIN_TEXT);
pastePlainTextItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
PastePlainTextAction action = new PastePlainTextAction(RichTextEditor.this);
@@ -1139,12 +1144,17 @@
}
public void menuShown(MenuEvent e) {
+ Clipboard clipboard = new Clipboard(Display.getCurrent());
+ String html = (String) clipboard.getContents(HTMLTransfer
+ .getInstance());
+ String text = (String) clipboard.getContents(TextTransfer
+ .getInstance());
String selectedText = getSelected().getText();
boolean selection = selectedText.length() > 0;
cutItem.setEnabled(editable && selection);
copyItem.setEnabled(selection);
- pasteItem.setEnabled(editable);
- pastePlainTextItem.setEnabled(editable);
+ pasteItem.setEnabled(editable && (html != null));
+ pastePlainTextItem.setEnabled(editable && (text != null));
}
});
}