]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.tests.modelled.ui/src/org/simantics/tests/modelled/ui/STSCounterPanel.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.tests.modelled.ui / src / org / simantics / tests / modelled / ui / STSCounterPanel.java
index 8b04f2f1183d4584955032a6fdeed257cb56f2b1..e93c793e74aa90e94362392770edb0440a61b5fe 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2000, 2013 IBM Corporation and others.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     IBM Corporation - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.tests.modelled.ui;\r
-\r
-\r
-import java.text.MessageFormat;\r
-\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.events.DisposeEvent;\r
-import org.eclipse.swt.events.DisposeListener;\r
-import org.eclipse.swt.graphics.Image;\r
-import org.eclipse.swt.layout.GridData;\r
-import org.eclipse.swt.layout.GridLayout;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Label;\r
-import org.eclipse.swt.widgets.Text;\r
-\r
-/**\r
- * A panel with counters for the number of Runs, Errors and Failures.\r
- */\r
-public class STSCounterPanel extends Composite {\r
-    protected Text numberOfErrors;\r
-    protected Text numberOfFailures;\r
-    protected Text numberOfRuns;\r
-    protected int total;\r
-    protected int ignoredCount;\r
-    protected int assumptionFailedCount;\r
-\r
-    private final Image fErrorIcon = null;\r
-    private final Image fFailureIcon = null;\r
-\r
-    public STSCounterPanel(Composite parent) {\r
-        super(parent, SWT.WRAP);\r
-        GridLayout gridLayout= new GridLayout();\r
-        gridLayout.numColumns= 9;\r
-        gridLayout.makeColumnsEqualWidth= false;\r
-        gridLayout.marginWidth= 0;\r
-        setLayout(gridLayout);\r
-\r
-        numberOfRuns= createLabel("Runs:", null, " 0/0  "); //$NON-NLS-1$\r
-        numberOfErrors= createLabel("Errors:", fErrorIcon, " 0 "); //$NON-NLS-1$\r
-        numberOfFailures= createLabel("Failures:", fFailureIcon, " 0 "); //$NON-NLS-1$\r
-\r
-        addDisposeListener(new DisposeListener() {\r
-            public void widgetDisposed(DisposeEvent e) {\r
-                disposeIcons();\r
-            }\r
-        });\r
-    }\r
-\r
-    private void disposeIcons() {\r
-        if (fErrorIcon != null)\r
-            fErrorIcon.dispose();\r
-        if (fFailureIcon != null)\r
-            fFailureIcon.dispose();\r
-    }\r
-\r
-    private Text createLabel(String name, Image image, String init) {\r
-        Label label= new Label(this, SWT.NONE);\r
-        if (image != null) {\r
-            image.setBackground(label.getBackground());\r
-            label.setImage(image);\r
-        }\r
-        label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));\r
-\r
-        label = new Label(this, SWT.NONE);\r
-        label.setText(name);\r
-        label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));\r
-        //label.setFont(JFaceResources.getBannerFont());\r
-\r
-        Text value = new Text(this, SWT.READ_ONLY);\r
-        value.setText(init);\r
-        // bug: 39661 Junit test counters do not repaint correctly [JUnit]\r
-//        SWTUtil.fixReadonlyTextBackground(value);\r
-        value.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING));\r
-        return value;\r
-    }\r
-\r
-    public void reset() {\r
-        setErrorValue(0);\r
-        setFailureValue(0);\r
-        setRunValue(0, 0, 0);\r
-        total= 0;\r
-    }\r
-\r
-    public void setTotal(int value) {\r
-        total= value;\r
-    }\r
-\r
-    public int getTotal(){\r
-        return total;\r
-    }\r
-\r
-    public void setRunValue(int value, int ignoredCount, int assumptionFailureCount) {\r
-        String runString;\r
-        String runStringTooltip;\r
-        if (ignoredCount == 0 && assumptionFailureCount == 0) {\r
-            runString= Messages.format("{0}/{1}", new String[] { Integer.toString(value), Integer.toString(total) });\r
-            runStringTooltip= runString;\r
-        } else if (ignoredCount != 0 && assumptionFailureCount == 0) {\r
-            runString= Messages.format("Skipped", new String[] { Integer.toString(value), Integer.toString(total), Integer.toString(ignoredCount) });\r
-            runStringTooltip= Messages.format("Ignored", new String[] { Integer.toString(value), Integer.toString(total), Integer.toString(ignoredCount) });\r
-        } else if (ignoredCount == 0 && assumptionFailureCount != 0) {\r
-            runString= Messages.format("Skipped", new String[] { Integer.toString(value), Integer.toString(total), Integer.toString(assumptionFailureCount) });\r
-            runStringTooltip= Messages.format("Failed", new String[] { Integer.toString(value), Integer.toString(total), Integer.toString(assumptionFailureCount) });\r
-        } else {\r
-            runString= Messages.format("Skipped", new String[] { Integer.toString(value), Integer.toString(total), Integer.toString(ignoredCount + assumptionFailureCount) });\r
-            runStringTooltip= Messages.format("Failed", new String[] { Integer.toString(value), Integer.toString(total), Integer.toString(ignoredCount), Integer.toString(assumptionFailureCount) });\r
-        }\r
-        numberOfRuns.setText(runString);\r
-        numberOfRuns.setToolTipText(runStringTooltip);\r
-\r
-        if (ignoredCount == 0 && ignoredCount > 0  || ignoredCount != 0 && ignoredCount == 0) {\r
-            layout();\r
-        } else if (assumptionFailedCount == 0 && assumptionFailureCount > 0 || assumptionFailedCount != 0 && assumptionFailureCount == 0) {\r
-            layout();\r
-        } else {\r
-            numberOfRuns.redraw();\r
-            redraw();\r
-        }\r
-        assumptionFailedCount= assumptionFailureCount;\r
-    }\r
-\r
-    public void setErrorValue(int value) {\r
-        numberOfErrors.setText(Integer.toString(value));\r
-        redraw();\r
-    }\r
-\r
-    public void setFailureValue(int value) {\r
-        numberOfFailures.setText(Integer.toString(value));\r
-        redraw();\r
-    }\r
-    \r
-    private static class Messages {\r
-\r
-        public static String format(String message, Object object) {\r
-            return MessageFormat.format(message, new Object[] { object});\r
-        }\r
-\r
-        public static String format(String message, Object[] objects) {\r
-            return MessageFormat.format(message, objects);\r
-        }\r
-\r
-        private Messages() {\r
-            // Not for instantiation\r
-        }\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.simantics.tests.modelled.ui;
+
+
+import java.text.MessageFormat;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * A panel with counters for the number of Runs, Errors and Failures.
+ */
+public class STSCounterPanel extends Composite {
+    protected Text numberOfErrors;
+    protected Text numberOfFailures;
+    protected Text numberOfRuns;
+    protected int total;
+    protected int ignoredCount;
+    protected int assumptionFailedCount;
+
+    private final Image fErrorIcon = null;
+    private final Image fFailureIcon = null;
+
+    public STSCounterPanel(Composite parent) {
+        super(parent, SWT.WRAP);
+        GridLayout gridLayout= new GridLayout();
+        gridLayout.numColumns= 9;
+        gridLayout.makeColumnsEqualWidth= false;
+        gridLayout.marginWidth= 0;
+        setLayout(gridLayout);
+
+        numberOfRuns= createLabel("Runs:", null, " 0/0  "); //$NON-NLS-1$
+        numberOfErrors= createLabel("Errors:", fErrorIcon, " 0 "); //$NON-NLS-1$
+        numberOfFailures= createLabel("Failures:", fFailureIcon, " 0 "); //$NON-NLS-1$
+
+        addDisposeListener(new DisposeListener() {
+            public void widgetDisposed(DisposeEvent e) {
+                disposeIcons();
+            }
+        });
+    }
+
+    private void disposeIcons() {
+        if (fErrorIcon != null)
+            fErrorIcon.dispose();
+        if (fFailureIcon != null)
+            fFailureIcon.dispose();
+    }
+
+    private Text createLabel(String name, Image image, String init) {
+        Label label= new Label(this, SWT.NONE);
+        if (image != null) {
+            image.setBackground(label.getBackground());
+            label.setImage(image);
+        }
+        label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+
+        label = new Label(this, SWT.NONE);
+        label.setText(name);
+        label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+        //label.setFont(JFaceResources.getBannerFont());
+
+        Text value = new Text(this, SWT.READ_ONLY);
+        value.setText(init);
+        // bug: 39661 Junit test counters do not repaint correctly [JUnit]
+//        SWTUtil.fixReadonlyTextBackground(value);
+        value.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING));
+        return value;
+    }
+
+    public void reset() {
+        setErrorValue(0);
+        setFailureValue(0);
+        setRunValue(0, 0, 0);
+        total= 0;
+    }
+
+    public void setTotal(int value) {
+        total= value;
+    }
+
+    public int getTotal(){
+        return total;
+    }
+
+    public void setRunValue(int value, int ignoredCount, int assumptionFailureCount) {
+        String runString;
+        String runStringTooltip;
+        if (ignoredCount == 0 && assumptionFailureCount == 0) {
+            runString= Messages.format("{0}/{1}", new String[] { Integer.toString(value), Integer.toString(total) });
+            runStringTooltip= runString;
+        } else if (ignoredCount != 0 && assumptionFailureCount == 0) {
+            runString= Messages.format("Skipped", new String[] { Integer.toString(value), Integer.toString(total), Integer.toString(ignoredCount) });
+            runStringTooltip= Messages.format("Ignored", new String[] { Integer.toString(value), Integer.toString(total), Integer.toString(ignoredCount) });
+        } else if (ignoredCount == 0 && assumptionFailureCount != 0) {
+            runString= Messages.format("Skipped", new String[] { Integer.toString(value), Integer.toString(total), Integer.toString(assumptionFailureCount) });
+            runStringTooltip= Messages.format("Failed", new String[] { Integer.toString(value), Integer.toString(total), Integer.toString(assumptionFailureCount) });
+        } else {
+            runString= Messages.format("Skipped", new String[] { Integer.toString(value), Integer.toString(total), Integer.toString(ignoredCount + assumptionFailureCount) });
+            runStringTooltip= Messages.format("Failed", new String[] { Integer.toString(value), Integer.toString(total), Integer.toString(ignoredCount), Integer.toString(assumptionFailureCount) });
+        }
+        numberOfRuns.setText(runString);
+        numberOfRuns.setToolTipText(runStringTooltip);
+
+        if (ignoredCount == 0 && ignoredCount > 0  || ignoredCount != 0 && ignoredCount == 0) {
+            layout();
+        } else if (assumptionFailedCount == 0 && assumptionFailureCount > 0 || assumptionFailedCount != 0 && assumptionFailureCount == 0) {
+            layout();
+        } else {
+            numberOfRuns.redraw();
+            redraw();
+        }
+        assumptionFailedCount= assumptionFailureCount;
+    }
+
+    public void setErrorValue(int value) {
+        numberOfErrors.setText(Integer.toString(value));
+        redraw();
+    }
+
+    public void setFailureValue(int value) {
+        numberOfFailures.setText(Integer.toString(value));
+        redraw();
+    }
+    
+    private static class Messages {
+
+        public static String format(String message, Object object) {
+            return MessageFormat.format(message, new Object[] { object});
+        }
+
+        public static String format(String message, Object[] objects) {
+            return MessageFormat.format(message, objects);
+        }
+
+        private Messages() {
+            // Not for instantiation
+        }
+    }
+}