use of org.eclipse.ecf.core.util.ECFException in project ecf by eclipse.
the class AbstractRemoteService method getProxy.
@SuppressWarnings("unchecked")
public Object getProxy() throws ECFException {
List classes = new ArrayList();
ClassLoader cl = this.getClass().getClassLoader();
try {
// Get clazz from reference
final String[] clazzes = getInterfaceClassNames();
for (int i = 0; i < clazzes.length; i++) classes.add(loadInterfaceClass(cl, clazzes[i]));
} catch (final Exception e) {
// $NON-NLS-1$
ECFException except = new ECFException("Failed to create proxy", e);
// $NON-NLS-1$
logWarning("Exception in remote service getProxy", except);
throw except;
} catch (final NoClassDefFoundError e) {
// $NON-NLS-1$
ECFException except = new ECFException("Failed to load proxy interface class", e);
// $NON-NLS-1$
logWarning("Could not load class for getProxy", except);
throw except;
}
return getProxy(cl, (Class[]) classes.toArray(new Class[classes.size()]));
}
use of org.eclipse.ecf.core.util.ECFException in project ecf by eclipse.
the class SearchContactDialog method createDialogArea.
protected Control createDialogArea(Composite parent) {
final int editableColumn = 1;
try {
parent = (Composite) super.createDialogArea(parent);
parent.setLayout(new GridLayout(2, false));
String[] fields = null;
IUserSearchManager userManager = account.getPresenceContainerAdapter().getUserSearchManager();
fields = userManager.getUserPropertiesFields();
GridData searchButtonData = new GridData(SWT.RIGHT, GridData.FILL_HORIZONTAL, false, false, 1, 1);
GridData addContactData = new GridData(SWT.RIGHT, GridData.FILL_HORIZONTAL, true, false, 1, 1);
Group group = new Group(parent, SWT.SHADOW_ETCHED_IN);
group.setLayout(new GridLayout(2, false));
group.setText(Messages.SearchContactDialog_InfoSearchFields);
Group groupContact = new Group(parent, SWT.SHADOW_ETCHED_IN);
groupContact.setLayout(new GridLayout(2, false));
groupContact.setText(Messages.SearchContactDialog_InfoContactFields);
tableResult = new Table(groupContact, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
tableResult.setLinesVisible(true);
tableResult.setHeaderVisible(true);
GridData dataTable = new GridData(GridData.FILL_HORIZONTAL, GridData.FILL_VERTICAL, true, true, 2, 1);
dataTable.heightHint = 200;
tableResult.setLayoutData(dataTable);
new TableColumn(tableResult, SWT.NONE).setText(Messages.SearchContactDialog_TableResultColumnName);
new TableColumn(tableResult, SWT.NONE).setText(Messages.SearchContactDialog_TableResultColumnUsername);
new TableItem(tableResult, SWT.NONE);
for (int i = 0; i < 2; i++) {
tableResult.getColumn(i).setWidth(130);
}
addContactButton = new Button(groupContact, SWT.PUSH | SWT.RIGHT);
addContactButton.setText(Messages.SearchContactDialog_ButtonAddContact);
addContactButton.setLayoutData(addContactData);
tableFields = new Table(group, SWT.BORDER | SWT.MULTI | SWT.CHECK);
tableFields.setLinesVisible(true);
tableFields.setHeaderVisible(true);
dataTable = new GridData(GridData.FILL_HORIZONTAL, GridData.FILL_VERTICAL, true, true, 2, 1);
dataTable.heightHint = 200;
tableFields.setLayoutData(dataTable);
TableColumn colField = new TableColumn(tableFields, SWT.NONE);
colField.setText(Messages.SearchContactDialog_TableSearchColumnField);
TableColumn colValue = new TableColumn(tableFields, SWT.NONE);
colValue.setText(Messages.SearchContactDialog_TableSearchColumnValue);
colValue.setWidth(130);
for (int i = 0; i < fields.length; i++) {
TableItem item = new TableItem(tableFields, SWT.NONE);
// $NON-NLS-1$
item.setText(new String[] { fields[i], "" });
item.setChecked(true);
}
TableItem[] items = tableFields.getItems();
for (int i = 0; i < items.length; i++) {
final TableEditor editor = new TableEditor(tableFields);
Text text = new Text(tableFields, SWT.NONE);
text.setText(items[i].getText(editableColumn));
text.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
editor.getItem().setText(editableColumn, ((Text) editor.getEditor()).getText());
}
});
text.selectAll();
text.setFocus();
editor.grabHorizontal = true;
editor.setEditor(text, items[i], editableColumn);
}
colField.pack();
runInBackgroundButton = new Button(group, SWT.CHECK);
runInBackgroundButton.setText(Messages.SearchContactDialog_RunInBackground);
runInBackgroundButton.setToolTipText(Messages.SearchContactDialog_RunInBackGroundToolTip);
searchButton = new Button(group, SWT.PUSH | SWT.RIGHT);
searchButton.setText(Messages.SearchContactDialog_ButtonSearch);
searchButton.setLayoutData(searchButtonData);
} catch (ECFException e) {
Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, e.getLocalizedMessage(), e));
new Label(parent, SWT.LEFT).setText(e.getLocalizedMessage());
}
addListeners();
applyDialogFont(parent);
return parent;
}
use of org.eclipse.ecf.core.util.ECFException in project ecf by eclipse.
the class URLShareRosterContributionItem method createActionAdd.
private IAction[] createActionAdd(final ID containerID, final IChannelContainerAdapter channelAdapter) {
final IAction action = new Action() {
public void run() {
try {
URLShare.addURLShare(containerID, channelAdapter);
} catch (ECFException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};
action.setText(Messages.URLShareRosterContributionItem_ADD_URL_SHARE_MENU_TEXT);
action.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID, Messages.URLShareRosterContributionItem_BROWSER_ICON));
return new IAction[] { action };
}
use of org.eclipse.ecf.core.util.ECFException in project ecf by eclipse.
the class MultiRosterView method joinChatRoom.
/**
* For the given container, join the chat room specified by roomInfo. NOTE:
* this is to be considered provisional 'Gunner' API and may not be
* available in subsequent versions of this class.
*
* @param container
* the IContainer instance that exposes the chat room. Must not
* be <code>null</code>. Also must be the same container
* associated with one of the accounts managed by this
* MultiRosterView.
* @param roomInfo
* chat room information that will be used to join. Must not be
* <code>null</code>.
* @param password
* a password associated with chat room access. May be
* <code>null</code>.
* @throws ECFException
* if the given container is not connected, or if the given
* container is not managed by this MultiRosterView, or if
* {@link ChatRoomManagerView} cannot be initialized.
*/
protected void joinChatRoom(IContainer container, IChatRoomInfo roomInfo, String password) throws ECFException {
Assert.isNotNull(container);
Assert.isNotNull(roomInfo);
// Check to make sure given container is connected.
ID connectedID = container.getConnectedID();
if (connectedID == null)
throw new ECFException(Messages.MultiRosterView_EXCEPTION_JOIN_ROOM_NOT_CONNECTED);
// our accounts set
if (findAccountForContainer(container) == null)
throw new ECFException(Messages.MultiRosterView_EXCEPTION_JOIN_ROOM_INVALID_ACCOUNT);
IWorkbenchWindow ww = getViewSite().getPage().getWorkbenchWindow();
IWorkbenchPage wp = ww.getActivePage();
// Get existing roomView...if it's there
RoomWithAView roomView = (RoomWithAView) chatRooms.get(connectedID);
if (roomView != null) {
// We've already connected to this room, so just show it.
ChatRoomManagerView chatroommanagerview = roomView.getView();
wp.activate(chatroommanagerview);
chatroommanagerview.joinRoom(roomInfo, password);
return;
}
try {
IViewReference ref = wp.findViewReference(org.eclipse.ecf.presence.ui.chatroom.ChatRoomManagerView.VIEW_ID, connectedID.getName());
// Open view for given connectedID (secondaryID)
final ChatRoomManagerView chatroommanagerview = (ChatRoomManagerView) ((ref == null) ? wp.showView(org.eclipse.ecf.presence.ui.chatroom.ChatRoomManagerView.VIEW_ID, connectedID.getName(), IWorkbenchPage.VIEW_ACTIVATE) : ref.getView(true));
// initialize new view
chatroommanagerview.initializeWithoutManager(ChatRoomManagerView.getUsernameFromID(connectedID), ChatRoomManagerView.getHostnameFromID(connectedID), createChatRoomCommandListener(), createChatRoomViewCloseListener(connectedID));
// join room
chatroommanagerview.joinRoom(roomInfo, password);
roomView = new RoomWithAView(chatroommanagerview, connectedID);
chatRooms.put(roomView.getID(), roomView);
} catch (Exception e1) {
throw new ECFException(e1);
}
}
use of org.eclipse.ecf.core.util.ECFException in project ecf by eclipse.
the class ChatRoomBot method connect.
public synchronized void connect() throws ECFException {
fireInitBot();
try {
Namespace namespace = null;
if (container == null) {
container = ContainerFactory.getDefault().createContainer(bot.getContainerFactoryName());
namespace = container.getConnectNamespace();
} else
// $NON-NLS-1$
throw new ContainerConnectException("Already connected");
targetID = IDFactory.getDefault().createID(namespace, bot.getConnectID());
IChatRoomManager manager = (IChatRoomManager) container.getAdapter(IChatRoomManager.class);
if (manager == null)
// $NON-NLS-1$
throw new ECFException("No chat room manager available");
firePreConnect();
String password = bot.getPassword();
IConnectContext context = (password == null) ? null : ConnectContextFactory.createPasswordConnectContext(password);
container.connect(targetID, context);
String[] roomNames = bot.getChatRooms();
String[] roomPasswords = bot.getChatRoomPasswords();
for (int i = 0; i < roomNames.length; i++) {
IChatRoomInfo room = manager.getChatRoomInfo(roomNames[i]);
roomContainer = room.createChatRoomContainer();
roomID = room.getRoomID();
firePreRoomConnect();
roomContainer.addMessageListener(this);
IConnectContext roomContext = (roomPasswords[i] == null) ? null : ConnectContextFactory.createPasswordConnectContext(roomPasswords[i]);
roomContainer.connect(roomID, roomContext);
}
} catch (ECFException e) {
if (container != null) {
if (container.getConnectedID() != null) {
container.disconnect();
}
container.dispose();
}
container = null;
throw e;
}
}
Aggregations