Fix for Linux display bugs in TimeGraphCombo.
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / dialogs / TabContents.java
CommitLineData
73005152 1/**********************************************************************
df0b8ff4
BH
2 * Copyright (c) 2005, 2008 IBM Corporation and others.
3 * Copyright (c) 2011, 2012 Ericsson.
4 *
73005152
BH
5 * All rights reserved. This program and the accompanying materials
6 * are made available under the terms of the Eclipse Public License v1.0
7 * which accompanies this distribution, and is available at
8 * http://www.eclipse.org/legal/epl-v10.html
73005152
BH
9 *
10 * Contributors:
11 * IBM - Initial API and implementation
12 * Bernd Hufmann - Updated for TMF
13 **********************************************************************/
df0b8ff4 14package org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs;
73005152
BH
15
16import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDGraphNodeSupporter;
17import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SDMessages;
18import org.eclipse.swt.SWT;
19import org.eclipse.swt.events.ModifyEvent;
20import org.eclipse.swt.events.ModifyListener;
21import org.eclipse.swt.events.SelectionEvent;
22import org.eclipse.swt.events.SelectionListener;
23import org.eclipse.swt.layout.GridData;
24import org.eclipse.swt.layout.GridLayout;
25import org.eclipse.swt.widgets.Button;
26import org.eclipse.swt.widgets.Combo;
27import org.eclipse.swt.widgets.Composite;
28import org.eclipse.swt.widgets.Group;
29import org.eclipse.swt.widgets.Label;
30
31/**
df0b8ff4
BH
32 * Class implementation contains the controls that allows to create or update a find or filter Criteria.
33 *
34 * @version 1.0
35 * @author sveyrier
73005152
BH
36 */
37public class TabContents extends Composite {
38
df0b8ff4
BH
39 // ------------------------------------------------------------------------
40 // Attributes
41 // ------------------------------------------------------------------------
42 /**
43 * A graph node type listener implementation.
44 */
eb63f5ff 45 protected GraphNodeTypeListener fGraphNodeTypeListener = null;
df0b8ff4
BH
46 /**
47 * A expression listener implementation.
48 */
eb63f5ff 49 protected ExpressionListener fExpressionListener = null;
df0b8ff4
BH
50 /**
51 * The button for lifelines.
52 */
eb63f5ff 53 protected Button fLifelineButton = null;
df0b8ff4
BH
54 /**
55 * The button for stops.
56 */
eb63f5ff 57 protected Button fStopButton = null;
df0b8ff4
BH
58 /**
59 * The button for synchronous messages
60 */
eb63f5ff 61 protected Button fSynMessageButton = null;
df0b8ff4
BH
62 /**
63 * The button for synchronous return messages
64 */
eb63f5ff 65 protected Button fSynMessageReturnButton = null;
df0b8ff4
BH
66 /**
67 * The button for asynchronous messages
68 */
eb63f5ff 69 protected Button fAsynMessageButton = null;
df0b8ff4
BH
70 /**
71 * The button for asynchronous return messages
72 */
eb63f5ff 73 protected Button fAsynMessageReturnButton = null;
df0b8ff4
BH
74 /**
75 * The search text combo box.
76 */
eb63f5ff 77 protected Combo fSearchText = null;
df0b8ff4
BH
78 /**
79 * The group for selection kind.
80 */
eb63f5ff 81 protected Group fKindSelection = null;
df0b8ff4
BH
82 /**
83 * The button for case sensitive expressions.
84 */
eb63f5ff 85 protected Button fCaseSensitive = null;
df0b8ff4
BH
86 /**
87 * The label for the result string.
88 */
eb63f5ff 89 protected Label fResult = null;
df0b8ff4
BH
90 /**
91 * The button for notifying parent about valid data.
92 */
eb63f5ff 93 protected Button fParentOkButton = null;
73005152 94
df0b8ff4
BH
95 // ------------------------------------------------------------------------
96 // Constructors
97 // ------------------------------------------------------------------------
98
73005152
BH
99 /**
100 * Creates the dialog contents
101 *
102 * @param parent the parent widget
103 * @param provider the provider which handle the action
104 * @param okButton of the dialog (to be enabled/disabled)
105 * @param expressionList list of strings already searched for
106 */
73005152
BH
107 public TabContents(Composite parent, ISDGraphNodeSupporter provider, Button okButton, String[] expressionList) {
108 super(parent, SWT.NONE);
109 setOkButton(okButton);
110 setLayout(new GridLayout());
111
eb63f5ff
BH
112 fGraphNodeTypeListener = new GraphNodeTypeListener();
113 fExpressionListener = new ExpressionListener();
73005152
BH
114
115 // Inform the user how to fill the string to search
116 Label searchTitle = new Label(this, SWT.LEFT);
117 searchTitle.setText(SDMessages._26);
118 Composite searchPart = new Composite(this, SWT.NONE);
119 GridData searchPartData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
120 GridLayout searchPartLayout = new GridLayout();
121 searchPartLayout.numColumns = 2;
122 searchPart.setLayout(searchPartLayout);
123 searchPart.setLayoutData(searchPartData);
124
125 // Create the user string input area
eb63f5ff 126 fSearchText = new Combo(searchPart, SWT.DROP_DOWN);
73005152
BH
127 GridData comboData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_FILL);
128 /*
129 * GridData tabLayoutData2 = new GridData(GridData.HORIZONTAL_ALIGN_FILL| GridData.VERTICAL_ALIGN_FILL);
130 */
eb63f5ff 131 fSearchText.setLayoutData(comboData);
73005152
BH
132 if (expressionList != null) {
133 for (int i = 0; i < expressionList.length; i++) {
eb63f5ff 134 fSearchText.add(expressionList[i]);
73005152
BH
135 }
136 }
eb63f5ff 137 fSearchText.addModifyListener(fExpressionListener);
73005152
BH
138
139 // Create the case sensitive check button
eb63f5ff
BH
140 fCaseSensitive = new Button(searchPart, SWT.CHECK);
141 fCaseSensitive.setText(SDMessages._27);
73005152
BH
142
143 // Create the group for searched graph node kind selection
eb63f5ff
BH
144 fKindSelection = new Group(this, SWT.SHADOW_NONE);
145 fKindSelection.setText(SDMessages._25);
73005152
BH
146 // kindSelection.setLayoutData(tabLayoutData2);
147 GridLayout kindSelectionLayout = new GridLayout();
148 kindSelectionLayout.numColumns = 1;
eb63f5ff 149 fKindSelection.setLayout(kindSelectionLayout);
73005152 150 GridData kindSelectionData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL);
eb63f5ff 151 fKindSelection.setLayoutData(kindSelectionData);
73005152
BH
152
153 // Create the lifeline check button
154 if (provider != null && provider.isNodeSupported(ISDGraphNodeSupporter.LIFELINE)) {
eb63f5ff 155 fLifelineButton = new Button(fKindSelection, SWT.CHECK);
73005152 156 String nodeName = provider.getNodeName(ISDGraphNodeSupporter.LIFELINE, null);
df0b8ff4 157 if (nodeName != null) {
eb63f5ff 158 fLifelineButton.setText(nodeName);
df0b8ff4 159 } else {
eb63f5ff 160 fLifelineButton.setText(SDMessages._28);
df0b8ff4 161 }
eb63f5ff
BH
162 fLifelineButton.setEnabled(true);
163 fLifelineButton.addSelectionListener(fGraphNodeTypeListener);
73005152
BH
164 }
165
166 if (provider != null && provider.isNodeSupported(ISDGraphNodeSupporter.STOP)) {
167 // Create the stop check button
eb63f5ff 168 fStopButton = new Button(fKindSelection, SWT.CHECK);
73005152 169 String nodeName = provider.getNodeName(ISDGraphNodeSupporter.STOP, null);
df0b8ff4 170 if (nodeName != null) {
eb63f5ff 171 fStopButton.setText(nodeName);
df0b8ff4 172 } else {
eb63f5ff 173 fStopButton.setText(SDMessages._29);
df0b8ff4
BH
174 }
175
eb63f5ff
BH
176 fStopButton.setEnabled(true);
177 fStopButton.addSelectionListener(fGraphNodeTypeListener);
73005152
BH
178 }
179
180 if (provider != null && provider.isNodeSupported(ISDGraphNodeSupporter.SYNCMESSAGE)) {
181 // Create the synchronous message check button
eb63f5ff 182 fSynMessageButton = new Button(fKindSelection, SWT.CHECK);
73005152 183 String nodeName = provider.getNodeName(ISDGraphNodeSupporter.SYNCMESSAGE, null);
df0b8ff4 184 if (nodeName != null) {
eb63f5ff 185 fSynMessageButton.setText(nodeName);
df0b8ff4 186 } else {
eb63f5ff 187 fSynMessageButton.setText(SDMessages._30);
df0b8ff4 188 }
eb63f5ff
BH
189 fSynMessageButton.setEnabled(true);
190 fSynMessageButton.addSelectionListener(fGraphNodeTypeListener);
73005152
BH
191 }
192
193 if (provider != null && provider.isNodeSupported(ISDGraphNodeSupporter.SYNCMESSAGERETURN)) {
194 // Create the synchronous message return check button
eb63f5ff 195 fSynMessageReturnButton = new Button(fKindSelection, SWT.CHECK);
73005152 196 String nodeName = provider.getNodeName(ISDGraphNodeSupporter.SYNCMESSAGERETURN, null);
df0b8ff4 197 if (nodeName != null) {
eb63f5ff 198 fSynMessageReturnButton.setText(nodeName);
df0b8ff4 199 } else {
eb63f5ff 200 fSynMessageReturnButton.setText(SDMessages._31);
df0b8ff4 201 }
eb63f5ff
BH
202 fSynMessageReturnButton.setEnabled(true);
203 fSynMessageReturnButton.addSelectionListener(fGraphNodeTypeListener);
73005152
BH
204 }
205
206 if (provider != null && provider.isNodeSupported(ISDGraphNodeSupporter.ASYNCMESSAGE)) {
207 // Create the asynchronous message check button
eb63f5ff 208 fAsynMessageButton = new Button(fKindSelection, SWT.CHECK);
73005152 209 String nodeName = provider.getNodeName(ISDGraphNodeSupporter.ASYNCMESSAGE, null);
df0b8ff4 210 if (nodeName != null) {
eb63f5ff 211 fAsynMessageButton.setText(nodeName);
df0b8ff4 212 } else {
eb63f5ff 213 fAsynMessageButton.setText(SDMessages._32);
df0b8ff4 214 }
eb63f5ff
BH
215 fAsynMessageButton.setEnabled(true);
216 fAsynMessageButton.addSelectionListener(fGraphNodeTypeListener);
73005152
BH
217 }
218
219 if (provider != null && provider.isNodeSupported(ISDGraphNodeSupporter.ASYNCMESSAGERETURN)) {
220 // Create the asynchronous message return check button
eb63f5ff 221 fAsynMessageReturnButton = new Button(fKindSelection, SWT.CHECK);
73005152 222 String nodeName = provider.getNodeName(ISDGraphNodeSupporter.ASYNCMESSAGERETURN, null);
df0b8ff4 223 if (nodeName != null) {
eb63f5ff 224 fAsynMessageReturnButton.setText(nodeName);
df0b8ff4 225 } else {
eb63f5ff 226 fAsynMessageReturnButton.setText(SDMessages._33);
df0b8ff4 227 }
eb63f5ff
BH
228 fAsynMessageReturnButton.setEnabled(true);
229 fAsynMessageReturnButton.addSelectionListener(fGraphNodeTypeListener);
73005152
BH
230 }
231
eb63f5ff
BH
232 fResult = new Label(this, SWT.LEFT);
233 fResult.setText(SDMessages._23);
234 fResult.setVisible(false);
73005152
BH
235 }
236
df0b8ff4
BH
237 // ------------------------------------------------------------------------
238 // Methods
239 // ------------------------------------------------------------------------
240
73005152 241 /**
df0b8ff4
BH
242 * Set result text visibility
243 * @param found <code>true</code> for found (enable visibility) else false
73005152
BH
244 */
245 public void setResult(boolean found) {
eb63f5ff 246 fResult.setVisible(!found);
73005152
BH
247 }
248
249 /**
df0b8ff4 250 * Updates parent OK button based on input data.
73005152
BH
251 */
252 public void updateOkButton() {
eb63f5ff 253 if (fParentOkButton == null) {
73005152
BH
254 return;
255 }
eb63f5ff
BH
256 boolean enabled = (fSearchText.getText() != null && !fSearchText.getText().equals("")) && //$NON-NLS-1$
257 (isLifelineButtonSelected() || isStopButtonSelected() || isSynMessageButtonSelected() || isSynMessageReturnButtonSelected() || isAsynMessageButtonSelected() || isAsynMessageReturnButtonSelected());
258 fParentOkButton.setEnabled(enabled);
73005152
BH
259 }
260
261 /**
df0b8ff4
BH
262 * Sets the parent OK button reference.
263 *
264 * @param okButton The parent OK button
73005152
BH
265 */
266 public void setOkButton(Button okButton) {
eb63f5ff 267 fParentOkButton = okButton;
73005152
BH
268 }
269
270 /**
271 * Returns the asynchronous message check button state
272 *
273 * @return true if check, false otherwise
274 */
eb63f5ff
BH
275 public boolean isAsynMessageButtonSelected() {
276 if (fAsynMessageButton != null) {
277 return fAsynMessageButton.getSelection();
df0b8ff4
BH
278 }
279 return false;
73005152
BH
280 }
281
282 /**
283 * Returns the asynchronous message return check button state
284 *
285 * @return true if check, false otherwise
286 */
eb63f5ff
BH
287 public boolean isAsynMessageReturnButtonSelected() {
288 if (fAsynMessageReturnButton != null) {
289 return fAsynMessageReturnButton.getSelection();
df0b8ff4
BH
290 }
291 return false;
73005152
BH
292 }
293
294 /**
295 * Returns the case sensitive check button state
296 *
297 * @return true if check, false otherwise
298 */
eb63f5ff
BH
299 public boolean isCaseSensitiveSelected() {
300 if (fCaseSensitive != null) {
301 return fCaseSensitive.getSelection();
df0b8ff4
BH
302 }
303 return false;
73005152
BH
304 }
305
306 /**
307 * Returns the lifeline check button state
308 *
309 * @return true if check, false otherwise
310 */
eb63f5ff
BH
311 public boolean isLifelineButtonSelected() {
312 if (fLifelineButton != null) {
313 return fLifelineButton.getSelection();
df0b8ff4
BH
314 }
315 return false;
73005152
BH
316 }
317
318 /**
319 * Returns the user input string
320 *
321 * @return the string to search for
322 */
323 public String getSearchText() {
eb63f5ff 324 return fSearchText.getText();
73005152
BH
325 }
326
327 /**
328 * Returns the stop check button state
329 *
330 * @return true if check, false otherwise
331 */
eb63f5ff
BH
332 public boolean isStopButtonSelected() {
333 if (fStopButton != null) {
334 return fStopButton.getSelection();
df0b8ff4
BH
335 }
336 return false;
73005152
BH
337 }
338
339 /**
340 * Returns the synchronous message check button state
341 *
342 * @return true if check, false otherwise
343 */
eb63f5ff
BH
344 public boolean isSynMessageButtonSelected() {
345 if (fSynMessageButton != null) {
346 return fSynMessageButton.getSelection();
df0b8ff4
BH
347 }
348 return false;
73005152
BH
349 }
350
351 /**
352 * Returns the synchronous message return check button state
353 *
354 * @return true if check, false otherwise
355 */
eb63f5ff
BH
356 public boolean isSynMessageReturnButtonSelected() {
357 if (fSynMessageReturnButton != null) {
358 return fSynMessageReturnButton.getSelection();
df0b8ff4
BH
359 }
360 return false;
73005152
BH
361 }
362
363 /**
364 * Set the asynchronous message check button state
365 */
366 public void setAsynMessageButtonSelection(boolean state) {
eb63f5ff
BH
367 if (fAsynMessageButton != null) {
368 fAsynMessageButton.setSelection(state);
df0b8ff4 369 }
73005152
BH
370 }
371
372 /**
373 * Set the asynchronous message return check button state
374 */
375 public void setAsynMessageReturnButtonSelection(boolean state) {
eb63f5ff
BH
376 if (fAsynMessageReturnButton != null) {
377 fAsynMessageReturnButton.setSelection(state);
df0b8ff4 378 }
73005152
BH
379 }
380
381 /**
382 * Set the case sensitive check button state
383 */
384 public void setCaseSensitiveSelection(boolean state) {
eb63f5ff
BH
385 if (fCaseSensitive != null) {
386 fCaseSensitive.setSelection(state);
df0b8ff4 387 }
73005152
BH
388 }
389
390 /**
391 * Set the lifeline check button state
392 */
393 public void setLifelineButtonSelection(boolean state) {
eb63f5ff
BH
394 if (fLifelineButton != null) {
395 fLifelineButton.setSelection(state);
df0b8ff4 396 }
73005152
BH
397 }
398
399 /**
400 * Set the user input string
401 */
402 public void setSearchText(String text) {
eb63f5ff 403 fSearchText.setText(text);
73005152
BH
404 }
405
406 /**
407 * Set the stop check button state
408 */
409 public void setStopButtonSelection(boolean state) {
eb63f5ff
BH
410 if (fStopButton != null) {
411 fStopButton.setSelection(state);
df0b8ff4 412 }
73005152
BH
413 }
414
415 /**
416 * Set the synchronous message check button state
417 */
418 public void setSynMessageButtonSelection(boolean state) {
eb63f5ff
BH
419 if (fSynMessageButton != null) {
420 fSynMessageButton.setSelection(state);
df0b8ff4 421 }
73005152
BH
422 }
423
424 /**
425 * Set the synchronous message return check button state
426 */
427 public void setSynMessageReturnButtonSelection(boolean state) {
eb63f5ff
BH
428 if (fSynMessageReturnButton != null) {
429 fSynMessageReturnButton.setSelection(state);
df0b8ff4
BH
430 }
431 }
432
433 // ------------------------------------------------------------------------
434 // Helper classes
435 // ------------------------------------------------------------------------
436
437 /**
438 * Selection listener implementation for graph node types.
439 * @version 1.0
440 */
441 protected class GraphNodeTypeListener implements SelectionListener {
442 /*
443 * (non-Javadoc)
444 * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
445 */
446 @Override
447 public void widgetDefaultSelected(SelectionEvent e) {
448 // Nothing to do
449 }
450
451 /*
452 * (non-Javadoc)
453 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
454 */
455 @Override
456 public void widgetSelected(SelectionEvent e) {
457 updateOkButton();
458 }
459 }
460
461 /**
462 * Modify listener implementation for the expression field.
463 *
464 * @version 1.0
465 */
466 protected class ExpressionListener implements ModifyListener {
467
468 /*
469 * (non-Javadoc)
470 * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
471 */
472 @Override
473 public void modifyText(ModifyEvent e) {
474 updateOkButton();
475 }
73005152
BH
476 }
477
478}
This page took 0.051809 seconds and 5 git commands to generate.