Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/preferences/BinaryEncodedMChoiceFieldEditor.java')
-rw-r--r--extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/preferences/BinaryEncodedMChoiceFieldEditor.java52
1 files changed, 27 insertions, 25 deletions
diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/preferences/BinaryEncodedMChoiceFieldEditor.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/preferences/BinaryEncodedMChoiceFieldEditor.java
index 243fbc81143..f0889b96393 100644
--- a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/preferences/BinaryEncodedMChoiceFieldEditor.java
+++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/preferences/BinaryEncodedMChoiceFieldEditor.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* Copyright (c) 2012 CEA LIST.
*
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -21,25 +21,25 @@ import org.eclipse.swt.widgets.Composite;
* A class derived from the MultipleChoiceFieldEditor.
* It encodes a multiple choice value in a binary way, i.e. bit I is set in the result, if the i-th choice is active.
* This class can also be used outside a preference page
- *
+ *
* @author ansgar
- *
+ *
*/
public class BinaryEncodedMChoiceFieldEditor extends MultipleChoiceFieldEditor {
/**
* @param name
- * The preference ID
+ * The preference ID
* @param labeltext
- * the label text
+ * the label text
* @param numColumns
- * the number of columns
+ * the number of columns
* @param labelsAndValues
- * a two dimensional array containing the labels and values
+ * a two dimensional array containing the labels and values
* @param parent
- * the parent SWT composite (field editor parent)
+ * the parent SWT composite (field editor parent)
* @param useGroup
- * display contents within a group
+ * display contents within a group
*/
public BinaryEncodedMChoiceFieldEditor(String name, String labeltext, int numColumns, String[][] labelsAndValues, Composite parent, boolean useGroup) {
super(name, labeltext, numColumns, labelsAndValues, parent, useGroup);
@@ -48,17 +48,17 @@ public class BinaryEncodedMChoiceFieldEditor extends MultipleChoiceFieldEditor {
/**
* Convenience constructor, if used outside a preference page
- *
+ *
* @param labeltext
- * the label text
+ * the label text
* @param numColumns
- * the number of columns
+ * the number of columns
* @param labelsAndValues
- * a two dimensional array containing the labels and values
+ * a two dimensional array containing the labels and values
* @param parent
- * the parent SWT composite (field editor parent)
+ * the parent SWT composite (field editor parent)
* @param useGroup
- * display contents within a group
+ * display contents within a group
*/
public BinaryEncodedMChoiceFieldEditor(String labeltext, int numColumns, String[][] labelsAndValues, Composite parent, boolean useGroup) {
super("", labeltext, numColumns, labelsAndValues, parent, useGroup); //$NON-NLS-1$
@@ -67,7 +67,7 @@ public class BinaryEncodedMChoiceFieldEditor extends MultipleChoiceFieldEditor {
/**
* Use this function to initialize the set/non-set flags within the dialog from a binary encoded value,
* if you use the dialog outside a preference page
- *
+ *
* @param currentValue
*/
public void setupViaString(String currentValue) {
@@ -77,7 +77,7 @@ public class BinaryEncodedMChoiceFieldEditor extends MultipleChoiceFieldEditor {
/**
* Use this function to get the results,
* if you use the dialog outside a preference page
- *
+ *
* @return the result
*/
public String getResult() {
@@ -89,11 +89,11 @@ public class BinaryEncodedMChoiceFieldEditor extends MultipleChoiceFieldEditor {
* Convenience function returning an integer result instead of a String result
* (requires double conversion that is difficult to avoid, since calculateResults needs to return
* a string);
- *
+ *
* @return
*/
public int getIntResult() {
- if(getResult() == null) {
+ if (getResult() == null) {
return 0;
}
return Integer.parseInt(getResult());
@@ -103,13 +103,14 @@ public class BinaryEncodedMChoiceFieldEditor extends MultipleChoiceFieldEditor {
protected String calculateResult(String[][] settings) {
int traceActionValue = 0;
int index = 0;
- for(String setting[] : settings) {
+ for (String setting[] : settings) {
// [0] = name, [1] = value [2] = checked
- if(setting[2].equals("true")) { //$NON-NLS-1$
+ if (setting[2].equals("true")) { //$NON-NLS-1$
traceActionValue += 1 << index;
}
index++;
- };
+ }
+ ;
return String.valueOf(traceActionValue);
}
@@ -118,13 +119,14 @@ public class BinaryEncodedMChoiceFieldEditor extends MultipleChoiceFieldEditor {
try {
int value = new Integer(valueToSet);
int index = 0;
- for(String setting[] : labelsAndValues) {
+ for (String setting[] : labelsAndValues) {
// [0] = name, [1] = value [2] = checked
- if(setting[0].equals(fieldName)) {
+ if (setting[0].equals(fieldName)) {
return (value & (1 << index)) > 0;
}
index++;
- };
+ }
+ ;
} catch (NumberFormatException e) {
}
return false;

Back to the top