blob: 05d81aeebcc68b86291ba9adb400d50d200c6f87 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
package org.eclipse.emf.cdo.internal.ui.actions;
import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.internal.ui.bundle.OM;
import org.eclipse.emf.cdo.internal.ui.dialogs.OpenSessionDialog;
import org.eclipse.emf.cdo.internal.ui.views.CDOSessionsView;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
import org.eclipse.emf.internal.cdo.CDOSessionFactory;
import org.eclipse.net4j.util.container.IPluginContainer;
import org.eclipse.net4j.util.ui.actions.LongRunningAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.IWorkbenchPage;
/**
* @author Eike Stepper
*/
public final class OpenSessionAction extends LongRunningAction
{
private String description;
public OpenSessionAction(IWorkbenchPage page)
{
super(page, OpenSessionDialog.TITLE, "Open a new CDO session", CDOSessionsView.getAddImageDescriptor());
}
@Override
protected void preRun() throws Exception
{
OpenSessionDialog dialog = new OpenSessionDialog(getPage());
if (dialog.open() == OpenSessionDialog.OK)
{
description = dialog.getServerDescription() + "/" + dialog.getRepositoryName();
if (!dialog.isLegacySupport())
{
description += "?disableLegacyObjects=true";
}
}
else
{
cancel();
}
}
@Override
protected void doRun() throws Exception
{
CDOSession session = null;
try
{
String productGroup = CDOSessionFactory.PRODUCT_GROUP;
String type = CDOProtocolConstants.PROTOCOL_NAME;
session = (CDOSession)IPluginContainer.INSTANCE.getElement(productGroup, type, description);
}
catch (RuntimeException ex)
{
OM.LOG.error(ex);
}
if (session == null)
{
try
{
getShell().getDisplay().syncExec(new Runnable()
{
public void run()
{
try
{
MessageDialog.openError(getShell(), getText(), "Unable to open a session on the specified repository.\n"
+ description);
}
catch (RuntimeException ignoe)
{
}
}
});
}
catch (RuntimeException ignoe)
{
}
}
}
}
|