import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerCell;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
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.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
protected Object result;
protected Shell shlInspectSessions;
- private Text text;
+ private Text txtDebugInfo;
private Label lblDebugInformation;
private final Cache cdmlibModelCache;
private final ICdmEntitySession activeSession;
private TreeViewer treeViewer;
+ private Button btnClose;
+ EntityCacherDebugResult ecdr;
+ private SashForm sashForm;
+ private Composite compositeDebug;
/**
* Create the dialog.
* @param parent
*/
public InspectSessionsDialog(Shell parent, int style) {
super(parent, style);
- setText("SWT Dialog");
+ setText("Inspect Active Session");
cdmlibModelCache = CdmRemoteCacheManager.getInstance().getCdmModelGetMethodsCache();
activeSession = CdmStore.getCurrentSessionManager().getActiveSession();
+ ecdr = activeSession.debug();
}
/**
* @return the result
*/
public Object open() {
+
createContents();
+ setDebugInfoText();
treeViewer.setContentProvider(new SessionsTreeContentProvider());
treeViewer.setLabelProvider(new SessionsTreeLabelProvider());
treeViewer.setInput(getRootElements());
* Create contents of the dialog.
*/
private void createContents() {
- shlInspectSessions = new Shell(getParent(), getStyle());
- shlInspectSessions.setSize(641, 529);
+ shlInspectSessions = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.RESIZE);
+ shlInspectSessions.setSize(641, 631);
shlInspectSessions.setText("Inspect Sessions");
shlInspectSessions.setLayout(new GridLayout(1, false));
- TreeViewer treeViewer = new TreeViewer(shlInspectSessions, SWT.BORDER);
- Tree tree = treeViewer.getTree();
- tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+ sashForm = new SashForm(shlInspectSessions, SWT.VERTICAL);
+ sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+
+ treeViewer = new TreeViewer(sashForm, SWT.BORDER);
+ Tree tree = treeViewer.getTree();
- lblDebugInformation = new Label(shlInspectSessions, SWT.NONE);
- lblDebugInformation.setFont(SWTResourceManager.getFont("Ubuntu", 10, SWT.NORMAL));
- lblDebugInformation.setText("Debug Information :");
+ compositeDebug = new Composite(sashForm, SWT.NONE);
+ compositeDebug.setLayout(new GridLayout(1, false));
- text = new Text(shlInspectSessions, SWT.BORDER);
- text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+ lblDebugInformation = new Label(compositeDebug, SWT.NONE);
+ lblDebugInformation.setAlignment(SWT.CENTER);
+ lblDebugInformation.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1));
+ lblDebugInformation.setFont(SWTResourceManager.getFont("Ubuntu", 10, SWT.NORMAL));
+ lblDebugInformation.setText("Debug Information");
+
+ txtDebugInfo = new Text(compositeDebug, SWT.BORDER | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
+ txtDebugInfo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+ sashForm.setWeights(new int[] {338, 184});
+
+ btnClose = new Button(shlInspectSessions, SWT.NONE);
+ btnClose.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ shlInspectSessions.dispose();
+ }
+ });
+ GridData gd_btnClose = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
+ gd_btnClose.widthHint = 70;
+ btnClose.setLayoutData(gd_btnClose);
+ btnClose.setText("Close");
}
+ private void setDebugInfoText() {
+ txtDebugInfo.setText(ecdr.toString());
+ }
private CdmEntityInfo[] getRootElements() {
- EntityCacherDebugResult ecdr = activeSession.debug();
- return (CdmEntityInfo[]) ecdr.getRootElements().toArray();
+
+ List<CdmEntityInfo> rootElemnts = ecdr.getRootElements();
+ return rootElemnts.toArray(new CdmEntityInfo[rootElemnts.size()]);
}
class SessionsTreeContentProvider implements ITreeContentProvider {