Defect 42686Add Images to cut, copy, paste menu item and refine the enable/disable
mechanism
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 2671a9c..d78d2f0 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
@@ -1090,8 +1090,12 @@
"selectionStatusListener", //$NON-NLS-1$
"current selection is=" + richTextSelection); //$NON-NLS-1$
}
-
- hasSelection = true;
+ if(strings[4].length() == 0) {
+ hasSelection = false;
+ } else {
+ hasSelection = true;
+ }
+
if (hasFocus())
notifyListeners(SWT.SELECTED, new Event());
} else {
@@ -1194,6 +1198,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(RichText.this);
@@ -1202,6 +1207,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(RichText.this);
@@ -1210,6 +1216,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(RichText.this);
@@ -1233,7 +1240,6 @@
}
public void menuShown(MenuEvent e) {
- getSelectedText();
cutItem.setEnabled(editable && hasSelection);
copyItem.setEnabled(hasSelection);
pasteItem.setEnabled(editable);