Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/internal/presence/ui/Messages.java9
-rw-r--r--framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/internal/presence/ui/dialogs/AddContactDialog.java158
-rw-r--r--framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/internal/presence/ui/messages.properties5
-rw-r--r--framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/presence/ui/MultiRosterView.java33
4 files changed, 196 insertions, 9 deletions
diff --git a/framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/internal/presence/ui/Messages.java b/framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/internal/presence/ui/Messages.java
index 535cd3bc2..94974ea46 100644
--- a/framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/internal/presence/ui/Messages.java
+++ b/framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/internal/presence/ui/Messages.java
@@ -18,10 +18,8 @@ public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.ecf.internal.presence.ui.messages"; //$NON-NLS-1$
public static String ChatRoomManagerUI_EXCEPTION_CHAT_ROOM_VIEW_INITIALIZATION;
-
public static String ChatRoomManagerUI_EXCEPTION_NO_ROOT_CHAT_ROOM_MANAGER;
- public static String MultiRosterView_ShowOffline;
public static String MultiRosterView_SendIM;
public static String MultiRosterView_Remove;
public static String MultiRosterView_SetStatusAs;
@@ -30,11 +28,18 @@ public class Messages extends NLS {
public static String MultiRosterView_SetDoNotDisturb;
public static String MultiRosterView_SetInvisible;
public static String MultiRosterView_SetOffline;
+ public static String MultiRosterView_ShowOffline;
+ public static String MultiRosterView_AddContact;
public static String MessagesView_ShowTimestamps;
public static String MessagesView_CouldNotSendMessage;
public static String MessagesView_TypingNotification;
+ public static String AddContactDialog_DialogTitle;
+ public static String AddContactDialog_UserID;
+ public static String AddContactDialog_Alias;
+ public static String AddContactDialog_Account;
+
public static String RosterWorkbenchAdapterFactory_Mode;
public static String RosterWorkbenchAdapterFactory_Type;
public static String RosterWorkbenchAdapterFactory_Account;
diff --git a/framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/internal/presence/ui/dialogs/AddContactDialog.java b/framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/internal/presence/ui/dialogs/AddContactDialog.java
new file mode 100644
index 000000000..e05283024
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/internal/presence/ui/dialogs/AddContactDialog.java
@@ -0,0 +1,158 @@
+/****************************************************************************
+ * Copyright (c) 2007 Remy Suen and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Remy Suen <remy.suen@gmail.com> - initial API and implementation
+ *****************************************************************************/
+package org.eclipse.ecf.internal.presence.ui.dialogs;
+
+import java.util.List;
+
+import org.eclipse.ecf.internal.presence.ui.Messages;
+import org.eclipse.ecf.presence.IPresenceContainerAdapter;
+import org.eclipse.ecf.presence.ui.MultiRosterAccount;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class AddContactDialog extends Dialog {
+
+ private ComboViewer accountsViewer;
+
+ private Text accountText;
+
+ private Text aliasText;
+
+ private Button okBtn;
+
+ private IPresenceContainerAdapter selection;
+
+ private String accountID;
+
+ private String alias;
+
+ private Object input;
+
+ public AddContactDialog(Shell parentShell) {
+ super(parentShell);
+ }
+
+ private void addListeners() {
+ accountText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ okBtn.setEnabled(selection != null
+ && !accountText.getText().equals("")); //$NON-NLS-1$
+ }
+ });
+
+ accountsViewer
+ .addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent e) {
+ IStructuredSelection iss = (IStructuredSelection) e
+ .getSelection();
+ selection = ((MultiRosterAccount) iss.getFirstElement())
+ .getPresenceContainerAdapter();
+ okBtn.setEnabled(!accountText.getText().equals("")); //$NON-NLS-1$
+ }
+ });
+ }
+
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(Messages.AddContactDialog_DialogTitle);
+ }
+
+ protected void createButtonsForButtonBar(Composite parent) {
+ super.createButtonsForButtonBar(parent);
+ okBtn = getButton(IDialogConstants.OK_ID);
+ okBtn.setEnabled(false);
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ parent = (Composite) super.createDialogArea(parent);
+ parent.setLayout(new GridLayout(1, true));
+ GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
+
+ new Label(parent, SWT.BEGINNING)
+ .setText(Messages.AddContactDialog_UserID);
+ accountText = new Text(parent, SWT.SINGLE);
+ accountText.setLayoutData(data);
+
+ new Label(parent, SWT.BEGINNING)
+ .setText(Messages.AddContactDialog_Alias);
+ aliasText = new Text(parent, SWT.SINGLE);
+ aliasText.setLayoutData(data);
+
+ new Label(parent, SWT.BEGINNING)
+ .setText(Messages.AddContactDialog_Account);
+ accountsViewer = new ComboViewer(parent, SWT.READ_ONLY | SWT.BORDER);
+ accountsViewer.getControl().setLayoutData(data);
+ accountsViewer.setContentProvider(new IStructuredContentProvider() {
+ public Object[] getElements(Object inputElement) {
+ return ((List) inputElement).toArray();
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput,
+ Object newInput) {
+ }
+ });
+ accountsViewer.setLabelProvider(new LabelProvider() {
+ public String getText(Object element) {
+ MultiRosterAccount account = (MultiRosterAccount) element;
+ return account.getContainer().getConnectedID().getName();
+ }
+ });
+ accountsViewer.setInput(input);
+
+ addListeners();
+
+ return parent;
+ }
+
+ protected void okPressed() {
+ accountID = accountText.getText();
+ alias = accountText.getText();
+ super.okPressed();
+ }
+
+ public IPresenceContainerAdapter getSelection() {
+ return selection;
+ }
+
+ public String getAccountID() {
+ return accountID;
+ }
+
+ public String getAlias() {
+ return alias;
+ }
+
+ public void setInput(Object input) {
+ this.input = input;
+ }
+
+}
diff --git a/framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/internal/presence/ui/messages.properties b/framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/internal/presence/ui/messages.properties
index 871cf2827..9d03ae3e5 100644
--- a/framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/internal/presence/ui/messages.properties
+++ b/framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/internal/presence/ui/messages.properties
@@ -13,15 +13,16 @@
# Messages for EN locale #
##########################
-MultiRosterView_ShowOffline = Show &Offline Contacts
-MultiRosterView_SendIM = Send &IM to {0}
+MultiRosterView_SendIM = Send &IM
MultiRosterView_Remove = &Remove
+MultiRosterView_ShowOffline = Show &Offline Contacts
MultiRosterView_SetStatusAs = Set Status As...
MultiRosterView_SetAvailable = &Available
MultiRosterView_SetAway = A&way
MultiRosterView_SetDoNotDisturb = &Do Not Disturb
MultiRosterView_SetInvisible = &Invisible
MultiRosterView_SetOffline = &Offline
+MultiRosterView_AddContact = &Add Contact
MessagesView_ShowTimestamps = &Show Timestamps
MessagesView_CouldNotSendMessage = The message could not be sent: {0}
diff --git a/framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/presence/ui/MultiRosterView.java b/framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/presence/ui/MultiRosterView.java
index 765817a09..5d497be71 100644
--- a/framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/presence/ui/MultiRosterView.java
+++ b/framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/presence/ui/MultiRosterView.java
@@ -21,6 +21,7 @@ import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.util.ECFException;
import org.eclipse.ecf.internal.presence.ui.Activator;
import org.eclipse.ecf.internal.presence.ui.Messages;
+import org.eclipse.ecf.internal.presence.ui.dialogs.AddContactDialog;
import org.eclipse.ecf.presence.IPresence;
import org.eclipse.ecf.presence.IPresenceContainerAdapter;
import org.eclipse.ecf.presence.IPresenceListener;
@@ -33,6 +34,7 @@ import org.eclipse.ecf.presence.roster.IRosterEntry;
import org.eclipse.ecf.presence.roster.IRosterGroup;
import org.eclipse.ecf.presence.roster.IRosterManager;
import org.eclipse.ecf.presence.roster.IRosterSubscriptionListener;
+import org.eclipse.ecf.presence.roster.IRosterSubscriptionSender;
import org.eclipse.ecf.ui.SharedImages;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
@@ -48,6 +50,7 @@ import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.window.ToolTip;
+import org.eclipse.jface.window.Window;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
@@ -236,6 +239,7 @@ public class MultiRosterView extends ViewPart implements IMultiRosterViewPart {
subscriptionListener);
treeViewer.remove(account);
}
+ rosterAccounts.clear();
refreshTreeViewer(null, false);
setStatusMenu.setVisible(false);
getViewSite().getActionBars().getMenuManager()
@@ -281,8 +285,7 @@ public class MultiRosterView extends ViewPart implements IMultiRosterViewPart {
if (element instanceof IRosterEntry) {
IRosterEntry entry = (IRosterEntry) element;
manager.add(imAction);
- imAction.setText(NLS.bind(Messages.MultiRosterView_SendIM, entry
- .getName()));
+ imAction.setText(Messages.MultiRosterView_SendIM);
// if the person is not online, we'll disable the action
imAction
.setEnabled(entry.getPresence().getType() == IPresence.Type.AVAILABLE);
@@ -359,6 +362,7 @@ public class MultiRosterView extends ViewPart implements IMultiRosterViewPart {
setStatusMenu.add(setOfflineAction);
setStatusMenu.setVisible(false);
manager.add(setStatusMenu);
+
manager.add(new Separator());
final ViewerFilter filter = new ViewerFilter() {
public boolean select(Viewer viewer, Object parentElement,
@@ -370,7 +374,7 @@ public class MultiRosterView extends ViewPart implements IMultiRosterViewPart {
}
}
};
- IAction filterAction = new Action(Messages.MultiRosterView_ShowOffline,
+ manager.add(new Action(Messages.MultiRosterView_ShowOffline,
IAction.AS_CHECK_BOX) {
public void run() {
if (isChecked()) {
@@ -379,8 +383,27 @@ public class MultiRosterView extends ViewPart implements IMultiRosterViewPart {
treeViewer.removeFilter(filter);
}
}
- };
- manager.add(filterAction);
+ });
+
+ manager.add(new Separator());
+ manager.add(new Action(Messages.MultiRosterView_AddContact) {
+ public void run() {
+ AddContactDialog dialog = new AddContactDialog(treeViewer
+ .getControl().getShell());
+ dialog.setInput(rosterAccounts);
+ if (Window.OK == dialog.open()) {
+ IPresenceContainerAdapter ipca = dialog.getSelection();
+ IRosterSubscriptionSender sender = ipca.getRosterManager()
+ .getRosterSubscriptionSender();
+ try {
+ sender.sendRosterAdd(dialog.getAccountID(), dialog
+ .getAlias(), null);
+ } catch (ECFException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ });
}
/*

Back to the top