lami: synchronize getter for currentReport
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.lami.ui / src / org / eclipse / tracecompass / internal / provisional / analysis / lami / ui / views / LamiAxisCheckBoxOption.java
1 /*******************************************************************************
2 * Copyright (c) 2016 EfficiOS Inc., Jonathan Rajotte-Julien
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
10 package org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.views;
11
12 import java.util.function.Predicate;
13
14 import org.eclipse.jdt.annotation.Nullable;
15 import org.eclipse.swt.widgets.Button;
16 import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect;
17
18 /**
19 * Basic representation of a check box option for dialog.
20 *
21 * @author Jonathan Rajotte-Julien
22 */
23 class LamiAxisCheckBoxOption {
24
25 private final String fName;
26 private final boolean fDefaultValue;
27 private @Nullable Button fButton;
28 private boolean fValue;
29 private final Predicate<LamiTableEntryAspect> fAppliesToAspect;
30
31 /**
32 * Constructor
33 *
34 * @param name
35 * The name of the check box. The actual string shown to user.
36 * @param defaultValue
37 * The default value of the check box.
38 * @param validationPredicate
39 * The predicate to check if an option can be applied to an aspect
40 */
41 public LamiAxisCheckBoxOption(String name, boolean defaultValue, Predicate<LamiTableEntryAspect> validationPredicate) {
42 fName = name;
43 this.fDefaultValue = defaultValue;
44 this.fValue = defaultValue;
45 fButton = null;
46 fAppliesToAspect = validationPredicate;
47 }
48
49 public String getName() {
50 return fName;
51 }
52
53 public boolean getDefaultValue() {
54 return fDefaultValue;
55 }
56
57 public void setButton(Button button) {
58 fButton = button;
59 }
60
61 public boolean getValue() {
62 return fValue;
63 }
64
65 public void updateValue() {
66 if (fButton != null) {
67 fValue = fButton.getSelection();
68 }
69 }
70
71 public void setButtonEnabled(boolean enabled) {
72 @Nullable Button button = fButton;
73 if (button != null) {
74 /* Only change state when necessary */
75 if (button.getEnabled() != enabled) {
76 button.setEnabled(enabled);
77 button.setSelection(fDefaultValue);
78 }
79 }
80 }
81
82 public boolean getButtonEnabled() {
83 if (fButton != null) {
84 return fButton.getEnabled();
85 }
86 return false;
87 }
88
89 public Predicate<LamiTableEntryAspect> getPredicate() {
90 return fAppliesToAspect;
91 }
92 }
This page took 0.034248 seconds and 5 git commands to generate.