| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2015 École Polytechnique de Montréal |
| 3 | * |
| 4 | * All rights reserved. This program and the accompanying materials are |
| 5 | * made available under the terms of the Eclipse Public License v1.0 which |
| 6 | * accompanies this distribution, and is available at |
| 7 | * http://www.eclipse.org/legal/epl-v10.html |
| 8 | * |
| 9 | * Contributors: |
| 10 | * Patrick-Jeffrey Pollo Guilbert - Initial API and implementation |
| 11 | *******************************************************************************/ |
| 12 | package org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers; |
| 13 | |
| 14 | import org.eclipse.jface.viewers.ArrayContentProvider; |
| 15 | import org.eclipse.jface.viewers.CheckboxTreeViewer; |
| 16 | import org.eclipse.jface.viewers.TreeViewer; |
| 17 | import org.eclipse.swt.widgets.Label; |
| 18 | import org.eclipse.ui.dialogs.FilteredTree; |
| 19 | import org.eclipse.ui.dialogs.PatternFilter; |
| 20 | import org.eclipse.jface.wizard.WizardPage; |
| 21 | import org.eclipse.swt.SWT; |
| 22 | //import org.eclipse.swt.custom.CTabFolder; |
| 23 | //import org.eclipse.swt.custom.CTabItem; |
| 24 | import org.eclipse.swt.graphics.Color; |
| 25 | import org.eclipse.swt.layout.GridData; |
| 26 | import org.eclipse.swt.layout.GridLayout; |
| 27 | import org.eclipse.swt.widgets.Button; |
| 28 | import org.eclipse.swt.widgets.Composite; |
| 29 | import org.eclipse.swt.widgets.Group; |
| 30 | //import org.eclipse.swt.widgets.Display; |
| 31 | import org.eclipse.swt.widgets.Shell; |
| 32 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs.INewConnectionDialog; |
| 33 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs.NewConnectionDialog; |
| 34 | |
| 35 | |
| 36 | public class NewConnectionWizard { |
| 37 | |
| 38 | static final int LABEL_WIDTH_CHARS = 4; |
| 39 | private NewConnectionDialog fNewConnectionDialog; |
| 40 | |
| 41 | static final int CONNECTIONTREE_HEIGHT_CHARS = 10; |
| 42 | static final int CONNECTIONTREE_WIDTH_CHARS = 40; |
| 43 | |
| 44 | TreeViewer fConnectionTree = null; |
| 45 | private CheckboxTreeViewer treeViewer; |
| 46 | |
| 47 | |
| 48 | |
| 49 | // TODO: refactor name of class and all classes associated with it |
| 50 | public NewConnectionWizard() |
| 51 | { |
| 52 | |
| 53 | Shell shell = new Shell(); |
| 54 | |
| 55 | shell.setLayout(new GridLayout()); |
| 56 | Composite composite = new Composite(shell, SWT.BORDER); |
| 57 | Composite compositeDescription = new Composite(shell, SWT.BORDER); |
| 58 | composite.setBackground(new Color(null, 255,255,255)); |
| 59 | compositeDescription.setBackground(new Color(null, 255,255,255)); |
| 60 | |
| 61 | GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false); |
| 62 | gridData = new GridData(SWT.FILL, SWT.FILL, true, false); |
| 63 | gridData.horizontalSpan = 2; |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | Group groupProfile = new Group(composite, SWT.SHADOW_ETCHED_IN); |
| 73 | groupProfile.setText("Profiles List"); |
| 74 | |
| 75 | |
| 76 | composite.setLayoutData(gridData); |
| 77 | composite.setLayout(new GridLayout(1, false)); |
| 78 | groupProfile.setLayoutData(gridData); |
| 79 | groupProfile.setLayout(new GridLayout()); |
| 80 | groupProfile.setBackground(new Color(null, 255,255,255)); |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | new FilteredTree(groupProfile, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, new PatternFilter(), true){ |
| 86 | @Override |
| 87 | protected TreeViewer doCreateTreeViewer(Composite aparent, int style) { |
| 88 | treeViewer = new CheckboxTreeViewer(aparent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); |
| 89 | //TODO: change string to one recorded in Messages class |
| 90 | treeViewer.getTree().setToolTipText("Select one or multiple profiles from the list below."); //$NON-NLS-1$ |
| 91 | ArrayContentProvider test = new ArrayContentProvider(); |
| 92 | |
| 93 | treeViewer.setContentProvider(test); |
| 94 | |
| 95 | test.inputChanged(treeViewer, null, new String[]{"allo", "bye"}); //$NON-NLS-1$ //$NON-NLS-2$ |
| 96 | |
| 97 | treeViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH)); |
| 98 | return treeViewer; |
| 99 | } |
| 100 | }; |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | // TODO: modify the checkbox addition to be based on availble profiles |
| 106 | Button b = new Button(groupProfile, SWT.CHECK); |
| 107 | b.setText("CPU Usage"); |
| 108 | b.setBackground(new Color(null, 255,255,255)); |
| 109 | |
| 110 | Button b2 = new Button(groupProfile, SWT.CHECK); |
| 111 | b2.setText("Memory usage"); |
| 112 | b2.setBackground(new Color(null, 255,255,255)); |
| 113 | |
| 114 | Button b3 = new Button(groupProfile, SWT.CHECK); |
| 115 | b3.setText("Disk Activity"); |
| 116 | b3.setBackground(new Color(null, 255,255,255)); |
| 117 | |
| 118 | |
| 119 | Group groupDescription = new Group(composite, SWT.SHADOW_ETCHED_IN); |
| 120 | groupDescription.setText("Description"); |
| 121 | |
| 122 | groupDescription.setLayoutData(gridData); |
| 123 | groupDescription.setLayout(new GridLayout()); |
| 124 | groupDescription.setBackground(new Color(null, 255,255,255)); |
| 125 | |
| 126 | |
| 127 | groupDescription.pack(); |
| 128 | |
| 129 | Label descriptionLabel = new Label(groupDescription, 0); |
| 130 | descriptionLabel.setText("No description available."); |
| 131 | descriptionLabel.setBackground(new Color(null, 255,255,255)); |
| 132 | |
| 133 | groupProfile.pack(); |
| 134 | |
| 135 | shell.open(); |
| 136 | |
| 137 | |
| 138 | } |
| 139 | |
| 140 | WizardPage wp = new ConnectionPage("Wizard"); |
| 141 | |
| 142 | protected void okPressed() |
| 143 | { |
| 144 | |
| 145 | } |
| 146 | |
| 147 | WizardPage testPage = new WizardPage("Kappa") |
| 148 | { |
| 149 | |
| 150 | @Override |
| 151 | public void createControl(Composite parent) { |
| 152 | // TODO Auto-generated method stub |
| 153 | Composite canvas = new Composite(parent, SWT.NONE); |
| 154 | canvas.setLayout(new GridLayout()); |
| 155 | this.setTitle("Session creation"); |
| 156 | |
| 157 | setControl(canvas); |
| 158 | Button b = new Button(canvas, SWT.RADIO); |
| 159 | b.setText("Local"); |
| 160 | |
| 161 | } |
| 162 | |
| 163 | }; |
| 164 | |
| 165 | public INewConnectionDialog getfNewConnectionDialog() { |
| 166 | return fNewConnectionDialog; |
| 167 | } |
| 168 | |
| 169 | public void setNewConnectionDialog(INewConnectionDialog fNewConnectionDialog) { |
| 170 | this.fNewConnectionDialog = (NewConnectionDialog) fNewConnectionDialog; |
| 171 | } |
| 172 | |
| 173 | public CheckboxTreeViewer getTreeViewer() { |
| 174 | return treeViewer; |
| 175 | } |
| 176 | |
| 177 | public void setTreeViewer(CheckboxTreeViewer treeViewer) { |
| 178 | this.treeViewer = treeViewer; |
| 179 | } |
| 180 | |
| 181 | } |