Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2005-02-21 06:24:11 +0000
committerslewis2005-02-21 06:24:11 +0000
commit4d2184fc1b89b14c9c10b135aa693a9ecb15568f (patch)
treeee6029d9964c507d35647eb981800132c9aea557
parentf9581fbd4c18d6e0a9c445b211da11fa1ef3c09a (diff)
downloadorg.eclipse.ecf-4d2184fc1b89b14c9c10b135aa693a9ecb15568f.tar.gz
org.eclipse.ecf-4d2184fc1b89b14c9c10b135aa693a9ecb15568f.tar.xz
org.eclipse.ecf-4d2184fc1b89b14c9c10b135aa693a9ecb15568f.zip
Added cut, copy, paste, select all to text output window. fixed context menus and action menu to allow arbitrary target IM receiver to be specified.
-rw-r--r--framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/RosterView.java58
-rw-r--r--framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/TextChatComposite.java107
2 files changed, 148 insertions, 17 deletions
diff --git a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/RosterView.java b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/RosterView.java
index 3d01a8773..93b797453 100644
--- a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/RosterView.java
+++ b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/RosterView.java
@@ -8,6 +8,7 @@ import java.util.Iterator;
import java.util.Map;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.identity.IDFactory;
import org.eclipse.ecf.core.user.IUser;
import org.eclipse.ecf.core.user.User;
import org.eclipse.ecf.ui.messaging.IMessageViewer;
@@ -23,6 +24,7 @@ import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
@@ -54,9 +56,9 @@ public class RosterView extends ViewPart implements ILocalUserSettable,
protected static final int TREE_EXPANSION_LEVELS = 1;
private TreeViewer viewer;
private Action chatAction;
+ private Action selectedChatAction;
private Action selectedDoubleClickAction;
private Action disconnectAction;
-
protected IUser localUser;
protected ITextInputHandler textInputHandler;
protected Hashtable chatThreads = new Hashtable();
@@ -205,9 +207,6 @@ public class RosterView extends ViewPart implements ILocalUserSettable,
TreeObject type = new TreeObject("Status: "
+ presence.getType().toString());
obj.addChild(type);
- TreeObject mode = new TreeObject("Mode: "
- + presence.getMode().toString());
- obj.addChild(mode);
String status = presence.getStatus();
if (status != null && !status.equals("")) {
TreeObject stat = new TreeObject("Status Details: " + status);
@@ -372,12 +371,20 @@ public class RosterView extends ViewPart implements ILocalUserSettable,
private void fillContextMenu(IMenuManager manager) {
TreeObject treeObject = getSelectedTreeObject();
+ final ID targetID = treeObject.getUserID();
if (treeObject != null) {
- chatAction.setText("IM with "+treeObject.getUserID().getName());
- manager.add(chatAction);
+ selectedChatAction = new Action() {
+ public void run() {
+ openChatWindowForTarget(targetID);
+ }
+ };
+ selectedChatAction.setText("Send IM to "+treeObject.getUserID().getName());
+ selectedChatAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
+ .getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
+ manager.add(selectedChatAction);
}
+
manager.add(new Separator());
- manager.add(disconnectAction);
// Other plug-ins can contribute there actions here
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
@@ -395,26 +402,42 @@ public class RosterView extends ViewPart implements ILocalUserSettable,
//manager.add(disconnectAction);
}
+ protected ID inputIMTarget() {
+ InputDialog dlg = new InputDialog(getSite().getShell(),"Send IM","Please enter the Jabber ID of the person you would like to IM","",null);
+ dlg.setBlockOnOpen(true);
+ int res = dlg.open();
+ if (res == InputDialog.OK) {
+ String strres = dlg.getValue();
+ if (strres != null && !strres.equals("")) {
+ ID target = null;
+ try {
+ target = IDFactory.makeStringID(strres);
+ } catch (Exception e) {
+ MessageDialog.openError(getSite().getShell(),"Error","Error in IM target");
+ return null;
+ }
+ return target;
+ }
+ }
+ return null;
+ }
private void makeActions() {
chatAction = new Action() {
public void run() {
- TreeObject treeObject = getSelectedTreeObject();
- if (treeObject != null) openChatWindowForTarget(treeObject.getUserID());
- else {
-
- }
+ ID targetID = inputIMTarget();
+ if (targetID != null) openChatWindowForTarget(targetID);
}
};
- chatAction.setText("IM");
- chatAction.setToolTipText("IM with selected user");
+ chatAction.setText("Send Instant Message...");
chatAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
.getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
selectedDoubleClickAction = new Action() {
public void run() {
- chatAction.run();
+ TreeObject treeObject = getSelectedTreeObject();
+ final ID targetID = treeObject.getUserID();
+ if (targetID != null) openChatWindowForTarget(targetID);
}
};
-
disconnectAction = new Action() {
public void run() {
// XXX disconnect from server and dispose everything here
@@ -426,6 +449,7 @@ public class RosterView extends ViewPart implements ILocalUserSettable,
}
+
protected ChatWindow openChatWindowForTarget(ID targetID) {
if (targetID == null)
return null;
@@ -542,7 +566,7 @@ public class RosterView extends ViewPart implements ILocalUserSettable,
protected String getWindowInitText(ID targetID) {
String result = "chat with " + targetID.getName() + " started "
- + getDateAndTime() + "\n";
+ + getDateAndTime() + "\n\n";
return result;
}
diff --git a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/TextChatComposite.java b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/TextChatComposite.java
index 699d0218a..07e3e7cc8 100644
--- a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/TextChatComposite.java
+++ b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/TextChatComposite.java
@@ -10,6 +10,12 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.ecf.core.user.IUser;
import org.eclipse.ecf.ui.Trace;
import org.eclipse.ecf.ui.UiPlugin;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.TextViewer;
import org.eclipse.jface.util.IPropertyChangeListener;
@@ -29,7 +35,11 @@ import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.PlatformUI;
public class TextChatComposite extends Composite {
@@ -60,6 +70,11 @@ public class TextChatComposite extends Composite {
protected IUser remoteUser;
protected boolean showTimestamp = true;
+ private Action outputClear = null;
+ private Action outputCopy = null;
+ private Action outputPaste = null;
+ private Action outputSelectAll = null;
+
public TextChatComposite(Composite parent, int style, String initText, ITextInputHandler handler, IUser localUser, IUser remoteUser) {
super(parent, style);
@@ -146,6 +161,9 @@ public class TextChatComposite extends Composite {
}
});
+ makeActions();
+ hookContextMenu();
+
UiPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(UiPlugin.PREF_DISPLAY_TIMESTAMP)) {
@@ -157,6 +175,95 @@ public class TextChatComposite extends Composite {
}
+ private void makeActions() {
+ outputSelectAll = new Action() {
+ public void run() {
+ outputSelectAll();
+ }
+ };
+ outputSelectAll.setText("Select All");
+ outputSelectAll.setAccelerator(SWT.CTRL | 'A');
+ outputCopy = new Action() {
+ public void run() {
+ outputCopy();
+ }
+ };
+ outputCopy.setText("Copy");
+ outputCopy.setAccelerator(SWT.CTRL | 'C');
+ outputCopy.setImageDescriptor(PlatformUI.getWorkbench()
+ .getSharedImages().getImageDescriptor(
+ ISharedImages.IMG_TOOL_COPY));
+
+ outputClear = new Action() {
+ public void run() {
+ outputClear();
+ }
+ };
+ outputClear.setText("Clear");
+
+ outputPaste = new Action() {
+ public void run() {
+ outputPaste();
+ }
+ };
+ outputPaste.setText("Paste");
+ outputCopy.setAccelerator(SWT.CTRL | 'V');
+ outputPaste.setImageDescriptor(PlatformUI.getWorkbench()
+ .getSharedImages().getImageDescriptor(
+ ISharedImages.IMG_TOOL_PASTE));
+
+ }
+
+ protected void outputClear() {
+ if (MessageDialog.openConfirm(null, "Confirm Clear Text Output",
+ "Are you sure you want to clear output?"))
+ textoutput.getTextWidget().setText("");
+ }
+
+ protected void outputCopy() {
+ String t = textoutput.getTextWidget().getSelectionText();
+ if (t == null || t.length() == 0) {
+ textoutput.getTextWidget().selectAll();
+ }
+ textoutput.getTextWidget().copy();
+ textoutput.getTextWidget().setSelection(
+ textoutput.getTextWidget().getText().length());
+ }
+
+ protected void outputPaste() {
+ textinput.paste();
+ }
+
+ protected void outputSelectAll() {
+ textoutput.getTextWidget().selectAll();
+ }
+
+ private void hookContextMenu() {
+ MenuManager menuMgr = new MenuManager("#PopupMenu");
+ menuMgr.setRemoveAllWhenShown(true);
+ menuMgr.addMenuListener(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager manager) {
+ fillContextMenu(manager);
+ }
+ });
+ Menu menu = menuMgr.createContextMenu(textoutput.getControl());
+ textoutput.getControl().setMenu(menu);
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite().registerContextMenu(menuMgr,textoutput);
+ //registerContextMenu(menuMgr, textoutput);
+ }
+
+ private void fillContextMenu(IMenuManager manager) {
+ manager.add(outputCopy);
+ manager.add(outputPaste);
+ manager.add(outputClear);
+ manager.add(new Separator());
+ manager.add(outputSelectAll);
+ manager.add(new Separator());
+ manager.add(new Separator());
+ // Other plug-ins can contribute there actions here
+ manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ }
+
public void setLocalUser(IUser newUser) {
this.localUser = newUser;
}

Back to the top