use of org.eclipse.ecf.example.collab.share.EclipseCollabSharedObject in project ecf by eclipse.
the class CollabClient method createAndConnectClient.
/**
* Create a new container instance, and connect to a remote server or group.
*
* @param containerType
* the container type used to create the new container instance.
* Must not be null.
* @param uri
* the uri that is used to create a targetID for connection. Must
* not be null.
* @param nickname
* an optional String nickname. May be null.
* @param connectData
* optional connection data. May be null.
* @param resource
* the resource that this container instance is associated with.
* Must not be null.
* @throws Exception
*/
public void createAndConnectClient(final String containerType, String uri, String nickname, final Object connectData, final IResource resource) throws Exception {
// First create the new container instance
final IContainer newClient = ContainerFactory.getDefault().createContainer(containerType);
// Create the targetID instance
ID targetID = IDFactory.getDefault().createID(newClient.getConnectNamespace(), uri);
// Setup username
String username = setupUsername(targetID, nickname);
// Create a new container entry to hold onto container once created
final ClientEntry newClientEntry = new ClientEntry(containerType, newClient);
// Setup sharedobject container if the new instance supports
// this
ISharedObjectContainer sharedObjectContainer = (ISharedObjectContainer) newClient.getAdapter(ISharedObjectContainer.class);
SharedObjectContainerUI socui = new SharedObjectContainerUI(this, sharedObjectContainer);
socui.setup(sharedObjectContainer, newClientEntry, resource, username);
// Now connect
try {
newClient.connect(targetID, ConnectContextFactory.createUsernamePasswordConnectContext(username, connectData));
} catch (ContainerConnectException e) {
// If we have a connect exception then we remove any previously
// added shared object
EclipseCollabSharedObject so = newClientEntry.getSharedObject();
if (so != null)
so.destroySelf();
throw e;
}
// only add container if the connect was successful
addClientForResource(newClientEntry, resource);
}
use of org.eclipse.ecf.example.collab.share.EclipseCollabSharedObject in project ecf by eclipse.
the class EditorCompoundContributionItem method getContributionItems.
protected IContributionItem[] getContributionItems() {
final ITextSelection textSelection = getSelection();
if (textSelection == null)
return EMPTY;
final IEditorPart editorPart = getEditorPart();
if (editorPart == null)
return EMPTY;
final IFile file = getFileForPart(editorPart);
if (file == null)
return EMPTY;
final IProject project = file.getProject();
if (isConnected(project.getWorkspace().getRoot()) == null)
return EMPTY;
final IAction action = new Action() {
public void run() {
final ClientEntry entry = isConnected(project.getWorkspace().getRoot());
if (entry == null) {
MessageDialog.openInformation(PlatformUI.getWorkbench().getDisplay().getActiveShell(), Messages.EditorCompoundContributionItem_EXCEPTION_NOT_CONNECTED_TITLE, Messages.EditorCompoundContributionItem_EXCEPTION_NOT_CONNECTED_MESSAGE);
return;
}
final EclipseCollabSharedObject collabsharedobject = entry.getSharedObject();
if (collabsharedobject != null) {
// $NON-NLS-1$
collabsharedobject.sendOpenAndSelectForFile(null, project.getName() + "/" + file.getProjectRelativePath().toString(), textSelection.getOffset(), textSelection.getLength());
}
}
};
final ClientEntry entry = isConnected(project.getWorkspace().getRoot());
if (entry == null)
return EMPTY;
final EclipseCollabSharedObject collabsharedobject = entry.getSharedObject();
if (collabsharedobject == null)
return EMPTY;
action.setText(NLS.bind(Messages.EditorCompoundContributionItem_SHARE_SELECTION_MENU_ITEM_NAME, collabsharedobject.getWindowTitle()));
if (menuImageDescriptor != null)
action.setImageDescriptor(menuImageDescriptor);
// action.setAccelerator(SWT.CTRL | SWT.SHIFT | '1');
return new IContributionItem[] { new Separator(), new ActionContributionItem(action) };
}
use of org.eclipse.ecf.example.collab.share.EclipseCollabSharedObject in project ecf by eclipse.
the class JoinGroupWizardAction method run.
public void run(IAction action) {
if (!connected) {
JoinGroupWizard wizard = new JoinGroupWizard(resource, PlatformUI.getWorkbench(), connectID);
Shell shell = null;
if (targetPart == null) {
shell = (window == null) ? null : window.getShell();
} else {
shell = targetPart.getSite().getShell();
}
// Create the wizard dialog
WizardDialog dialog = new WizardDialog(shell, wizard);
// Open the wizard dialog
dialog.open();
} else {
ClientEntry client = isConnected(resource);
if (client == null) {
connected = false;
action.setText(CONNECT_PROJECT_MENU_TEXT);
} else {
EclipseCollabSharedObject collab = client.getSharedObject();
if (collab != null) {
collab.chatGUIDestroy();
}
}
}
}
Aggregations