summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java
diff options
context:
space:
mode:
authorJakob Heher <jakob.heher@iaik.tugraz.at>2022-08-04 11:30:17 +0200
committerJakob Heher <jakob.heher@iaik.tugraz.at>2022-08-04 11:30:17 +0200
commit2624ca21244979af6118879dd4fd818f9c0b7383 (patch)
tree511ecae7b6e4e27b50cd1d30250234f429ac335c /pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java
parent3addc990ae79aaf17d9eda9b5967d9cb94fa79e1 (diff)
downloadpdf-over-2624ca21244979af6118879dd4fd818f9c0b7383.tar.gz
pdf-over-2624ca21244979af6118879dd4fd818f9c0b7383.tar.bz2
pdf-over-2624ca21244979af6118879dd4fd818f9c0b7383.zip
SWT helper refactor:
- move out of StateComposite to its own SWTUtils class - refactor to reflection (better than one overload for each SWT type...)
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java80
1 files changed, 0 insertions, 80 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java
index 65ca274a..833669ff 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java
@@ -15,19 +15,9 @@
*/
package at.asit.pdfover.gui.composites;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.widgets.Button;
// Imports
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.swt.widgets.Label;
-import at.asit.pdfover.commons.Messages;
import at.asit.pdfover.gui.workflow.states.State;
/**
@@ -62,74 +52,4 @@ public abstract class StateComposite extends Composite {
* Reloads the localizeable resources
*/
public abstract void reloadResources();
-
- public static void disableEventDefault(Control c, int event)
- {
- c.addListener(event, (Event e) -> { e.doit = false; });
- }
-
- public static void setLocalizedText(Item i, String messageKey) { i.setText(Messages.getString(messageKey)); }
- public static void setLocalizedText(Item i, String formatMessageKey, Object... formatArgs) { i.setText(String.format(Messages.getString(formatMessageKey), formatArgs)); }
- public static void setLocalizedText(Label l, String messageKey) { l.setText(Messages.getString(messageKey)); l.requestLayout(); }
- public static void setLocalizedText(Label l, String formatMessageKey, Object... formatArgs) { l.setText(String.format(Messages.getString(formatMessageKey), formatArgs)); l.requestLayout(); }
- public static void setLocalizedText(Button b, String messageKey) { b.setText(Messages.getString(messageKey)); b.requestLayout(); }
- public static void setLocalizedText(Button b, String formatMessageKey, Object... formatArgs) { b.setText(String.format(Messages.getString(formatMessageKey), formatArgs)); b.requestLayout(); }
-
- public static void setFontHeight(Control c, int height)
- {
- FontData[] fD = c.getFont().getFontData();
- fD[0].setHeight(height);
- Font font = new Font(c.getDisplay(), fD[0]);
- c.setFont(font);
- }
-
- public static void setFontStyle(Control c, int style)
- {
- FontData[] fD = c.getFont().getFontData();
- fD[0].setStyle(style);
- Font font = new Font(c.getDisplay(), fD[0]);
- c.setFont(font);
- }
-
- public static class AnchorSetter
- {
- private final Control c;
- private final FormData fd = new FormData();
- public AnchorSetter(Control c) { this.c = c; }
-
- public void set() { this.c.setLayoutData(this.fd); }
-
- public AnchorSetter height(int h) { fd.height = h; return this; }
- public AnchorSetter width(int w) { fd.width = w; return this; }
-
- public AnchorSetter top(FormAttachment a) { fd.top = a; return this; }
- public AnchorSetter left(FormAttachment a) { fd.left = a; return this; }
- public AnchorSetter right(FormAttachment a) { fd.right = a; return this; }
- public AnchorSetter bottom(FormAttachment a) { fd.bottom = a; return this; }
-
- public AnchorSetter top(Control control, int offset, int alignment) { return top(new FormAttachment(control, offset, alignment)); }
- public AnchorSetter top(Control control, int offset) { return top(new FormAttachment(control, offset)); }
- public AnchorSetter top(Control control) { return top(new FormAttachment(control)); }
- public AnchorSetter top(int num, int offset) { return top(new FormAttachment(num, offset)); }
- public AnchorSetter top(int num) { return top(new FormAttachment(num)); }
-
- public AnchorSetter left(Control control, int offset, int alignment) { return left(new FormAttachment(control, offset, alignment)); }
- public AnchorSetter left(Control control, int offset) { return left(new FormAttachment(control, offset)); }
- public AnchorSetter left(Control control) { return left(new FormAttachment(control)); }
- public AnchorSetter left(int num, int offset) { return left(new FormAttachment(num, offset)); }
- public AnchorSetter left(int num) { return left(new FormAttachment(num)); }
-
- public AnchorSetter right(Control control, int offset, int alignment) { return right(new FormAttachment(control, offset, alignment)); }
- public AnchorSetter right(Control control, int offset) { return right(new FormAttachment(control, offset)); }
- public AnchorSetter right(Control control) { return right(new FormAttachment(control)); }
- public AnchorSetter right(int num, int offset) { return right(new FormAttachment(num, offset)); }
- public AnchorSetter right(int num) { return right(new FormAttachment(num)); }
-
- public AnchorSetter bottom(Control control, int offset, int alignment) { return bottom(new FormAttachment(control, offset, alignment)); }
- public AnchorSetter bottom(Control control, int offset) { return bottom(new FormAttachment(control, offset)); }
- public AnchorSetter bottom(Control control) { return bottom(new FormAttachment(control)); }
- public AnchorSetter bottom(int num, int offset) { return bottom(new FormAttachment(num, offset)); }
- public AnchorSetter bottom(int num) { return bottom(new FormAttachment(num)); }
- }
- public static AnchorSetter anchor(Control c) { return new AnchorSetter(c); }
}