Index: com/servoyguy/plugins/busy/BusyScriptObject.java =================================================================== --- com/servoyguy/plugins/busy/BusyScriptObject.java (revision 47) +++ com/servoyguy/plugins/busy/BusyScriptObject.java (working copy) @@ -17,6 +17,7 @@ package com.servoyguy.plugins.busy; import java.awt.Color; +import java.awt.Font; import net.stuff.servoy.BusyAbstractProvider; import net.stuff.servoy.plugins.busy.wicket.BusyWicketProvider; @@ -59,6 +60,7 @@ private Object[] processArgs; private Color paneColor; private Color textColor; + private Font fontType; public BusyScriptObject(IClientPluginAccess application) { this.application = application; @@ -102,7 +104,7 @@ processFunction = null; //callBackFunction = null; float opacity = (showGlassPane) ? 0.5f : 0f; - getProvider().busy(msg, dialogName, opacity, showCancelButton, null); + getProvider().busy(msg, dialogName, opacity, showCancelButton, null, null); } } @@ -143,6 +145,9 @@ if (params.has("textColor", params)) { textColor = PersistHelper.createColor((String)params.get("textColor", params)); } + if (params.has("fontType", params)) { + fontType = PersistHelper.createFont((String)params.get("fontType", params)); + } if (params.has("showCancelButton", params)) { showCancelButton = Utils.getAsBoolean(params.get("showCancelButton", params)); } @@ -179,7 +184,7 @@ } } } - getProvider().busy(msg, dg, opacity, showCancelButton, cancelBtnText); + getProvider().busy(msg, dg, opacity, showCancelButton, cancelBtnText, fontType); } public void js_unblock() { @@ -367,6 +372,13 @@ */ public Color getTextColor() { return this.textColor; + } + + /** + * @return the fontType + */ + public Font getFontType() { + return this.fontType; } } Index: com/servoyguy/plugins/busy/swing/BusySwingProvider.java =================================================================== --- com/servoyguy/plugins/busy/swing/BusySwingProvider.java (revision 47) +++ com/servoyguy/plugins/busy/swing/BusySwingProvider.java (working copy) @@ -18,6 +18,7 @@ import java.awt.Component; import java.awt.Cursor; +import java.awt.Font; import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -52,7 +53,7 @@ } public void busy(String msg, String dialogName, float opacity, - boolean showCancelButton, String cancelBtnText) + boolean showCancelButton, String cancelBtnText, Font fontType) { this.dialogName = dialogName; if (!busy.get()) { @@ -82,6 +83,9 @@ if (cancelBtnText != null) { glassPane.setCancelBtnText(cancelBtnText); }; + if (fontType != null) { + glassPane.setFontType(fontType); + }; if (!isMain() && !is5OrMore()) { mainPane = glassPane.getCopy(); setMainGlassPane(mainPane); Index: com/servoyguy/plugins/busy/swing/GlassPane.java =================================================================== --- com/servoyguy/plugins/busy/swing/GlassPane.java (revision 47) +++ com/servoyguy/plugins/busy/swing/GlassPane.java (working copy) @@ -21,24 +21,26 @@ import java.awt.Dimension; import java.awt.Font; import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.RenderingHints; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import javax.swing.JButton; import javax.swing.JPanel; /** - * @author Scott Buttler - * http://www.servoyguy.com/ + * @author Scott Buttler http://www.servoyguy.com/ * - * modified by Servoy Stuff - * http://www.servoy-stuff.net/ + * modified by Servoy Stuff http://www.servoy-stuff.net/ */ public class GlassPane extends JPanel { private static final long serialVersionUID = 1L; - + private static final String DEFAULT_TEXT = null; private String text = DEFAULT_TEXT; private String[] lines; @@ -48,63 +50,80 @@ private String cancelBtnText = "Cancel"; private Color paneColor = Color.black; private Color textColor = Color.white; - + private Font fontType; + public GlassPane() { setOpaque(false); - addMouseListener(new MouseAdapter(){}); + addMouseListener(new MouseAdapter() { + }); setLayout(null); add(getCancel()); } - - public JButton getCancel() - { + + public JButton getCancel() { if (cancelButton == null) { cancelButton = new JButton(cancelBtnText); cancelButton.setOpaque(false); cancelButton.setCursor(Cursor.getDefaultCursor()); - cancelButton.addActionListener(new ActionListener(){ + cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { canceled = true; cancelButton.setEnabled(false); - }}); + } + }); cancelButton.setVisible(false); } return cancelButton; } - + protected void paintComponent(Graphics g) { - Color color = getPaneColor(); - float[] f = color.getComponents(null); - g.setColor(new Color(f[0], f[1], f[2], opacity)); - - g.fillRect(0,0,super.getWidth(),super.getHeight()); - Dimension size = cancelButton.getPreferredSize(); - - if (lines != null) { - g.setColor(getTextColor()); - g.setFont(g.getFont().deriveFont(Font.BOLD, 24)); - float totalLineHeights = 0f; - for (int i = 0; i < lines.length; i++) { - totalLineHeights += g.getFontMetrics().getLineMetrics(lines[i], g).getHeight() + 5; - } - float lineHeight = 0; - for (int i = 0; i < lines.length; i++) { - String line = lines[i]; - int width = g.getFontMetrics().stringWidth(line); - lineHeight += g.getFontMetrics().getLineMetrics(line, g).getAscent(); - g.drawString(line,(super.getWidth()/2) - (width/2), super.getHeight()/2 - (int)((totalLineHeights/2) - lineHeight) ); - lineHeight += g.getFontMetrics().getLineMetrics(line, g).getDescent() + g.getFontMetrics().getLineMetrics(line, g).getLeading(); - lineHeight += 5; - } - cancelButton.setBounds((super.getWidth()/2) - (size.width/2), (super.getHeight()/2) + (int)lineHeight-10,size.width, size.height); - } else { - cancelButton.setBounds((super.getWidth()/2) - (size.width/2), (super.getHeight()/2),size.width, size.height); - } + // Cast the Graphics object into Graphics2D in oder to get anti aliasing support + Graphics2D g2D = (Graphics2D) g; + g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + + Color color = getPaneColor(); + float[] f = color.getComponents(null); + g2D.setColor(new Color(f[0], f[1], f[2], opacity)); + + g2D.fillRect(0, 0, super.getWidth(), super.getHeight()); + Dimension size = cancelButton.getPreferredSize(); + + if (lines != null) { + g2D.setColor(getTextColor()); + + // Font management + if (fontType == null) { + fontType = g2D.getFont().deriveFont(Font.BOLD, 24); + } + g2D.setFont(fontType); + + float totalLineHeights = 0f; + for (int i = 0; i < lines.length; i++) { + totalLineHeights += g2D.getFontMetrics().getLineMetrics(lines[i], g2D).getHeight() + 5; + } + float lineHeight = 0; + for (int i = 0; i < lines.length; i++) { + String line = lines[i]; + int width = g2D.getFontMetrics().stringWidth(line); + lineHeight += g2D.getFontMetrics().getLineMetrics(line, g2D).getAscent(); + g2D.drawString(line, (super.getWidth() / 2) - (width / 2), super.getHeight() / 2 + - (int) ((totalLineHeights / 2) - lineHeight)); + lineHeight += g2D.getFontMetrics().getLineMetrics(line, g2D).getDescent() + + g2D.getFontMetrics().getLineMetrics(line, g2D).getLeading(); + lineHeight += 5; + } + cancelButton.setBounds((super.getWidth() / 2) - (size.width / 2), (super.getHeight() / 2) + + (int) lineHeight - 10, size.width, size.height); + + } else { + cancelButton.setBounds((super.getWidth() / 2) - (size.width / 2), (super.getHeight() / 2), size.width, + size.height); + } } - + public void setVisible(boolean aFlag) { - if(!aFlag) + if (!aFlag) setText(DEFAULT_TEXT); else setCanceled(false); @@ -121,12 +140,13 @@ lines = text.split("\\n"); } } + public boolean isCanceled() { return canceled; } public void setCanceled(boolean canceled) { - if(!canceled) + if (!canceled) cancelButton.setEnabled(true); this.canceled = canceled; } @@ -147,7 +167,8 @@ } /** - * @param opacity the opacity to set + * @param opacity + * the opacity to set */ public void setOpacity(float opacity) { this.opacity = opacity; @@ -161,7 +182,8 @@ } /** - * @param cancelBtnText the cancelBtnText to set + * @param cancelBtnText + * the cancelBtnText to set */ public void setCancelBtnText(String cancelBtnText) { this.cancelBtnText = cancelBtnText; @@ -179,7 +201,8 @@ } /** - * @param paneColor the paneColor to set + * @param paneColor + * the paneColor to set */ public void setPaneColor(Color paneColor) { this.paneColor = paneColor; @@ -209,12 +232,25 @@ } /** - * @param textColor the textColor to set + * @param textColor + * the textColor to set */ public void setTextColor(Color textColor) { this.textColor = textColor; } - - - + + /** + * @return the fontType + */ + public Color getFontType() { + return textColor; + } + + /** + * @param fontType + * + */ + public void setFontType(Font font) { + this.fontType = font; + } } Index: net/stuff/servoy/BusyAbstractProvider.java =================================================================== --- net/stuff/servoy/BusyAbstractProvider.java (revision 47) +++ net/stuff/servoy/BusyAbstractProvider.java (working copy) @@ -18,6 +18,7 @@ */ package net.stuff.servoy; +import java.awt.Font; import java.util.concurrent.atomic.AtomicBoolean; import com.servoy.j2db.plugins.IClientPluginAccess; @@ -43,7 +44,7 @@ } public abstract void busy(final String msg, final String dialogName, final float opacity, - final boolean showCancelButton, final String cancelBtnText); + final boolean showCancelButton, final String cancelBtnText, final Font fontType); public abstract void ready(); Index: net/stuff/servoy/plugins/busy/wicket/busy.js =================================================================== --- net/stuff/servoy/plugins/busy/wicket/busy.js (revision 47) +++ net/stuff/servoy/plugins/busy/wicket/busy.js (working copy) @@ -8,10 +8,11 @@ $j.unblockUI(); return false; }); - $j.busy = function(msg, transparency, btn, callback, paneColor, textColor, msgBtn) { + $j.busy = function(msg, transparency, btn, callback, paneColor, textColor, msgBtn, fontType) { if (!msg) msg = ''; $j('#questionDiv > h1').html(msg); if (textColor) $j('#questionDiv > h1').css('color', textColor); + if (fontType) $j('#questionDiv > h1').css('font-family', fontType); if (transparency < 0.5) $j('#questionDiv > h1').css('color', 'black'); if (btn) $j('#noBtn').css('display', 'inline'); if (callback) $j.blockUI.defaults.onUnblock = callback; Index: net/stuff/servoy/plugins/busy/wicket/BusyWicketProvider.java =================================================================== --- net/stuff/servoy/plugins/busy/wicket/BusyWicketProvider.java (revision 47) +++ net/stuff/servoy/plugins/busy/wicket/BusyWicketProvider.java (working copy) @@ -19,6 +19,7 @@ package net.stuff.servoy.plugins.busy.wicket; import java.awt.Color; +import java.awt.Font; import net.stuff.servoy.BusyAbstractProvider; import net.stuff.servoy.BusyServerPlugin; @@ -34,25 +35,24 @@ import com.servoyguy.plugins.busy.BusyScriptObject; /** - * @author Servoy Stuff - * http://www.servoy-stuff.net/ + * @author Servoy Stuff http://www.servoy-stuff.net/ */ public class BusyWicketProvider extends BusyAbstractProvider { private BusyScriptBehaviorCancel behaviorCancel; private BusyScriptBehaviorStart behaviorStart; - + public BusyWicketProvider(final IClientPluginAccess app, final BusyScriptObject parent) { super(app, parent); } - - public void busy(final String msg, final String dialogName, final float opacity, - final boolean showCancelButton, final String cancelBtnText) { - + + public void busy(final String msg, final String dialogName, final float opacity, final boolean showCancelButton, + final String cancelBtnText, final Font fontType) { + if (useAjax() && !busy.get()) { - + IPageContributor pc = initialize(); - + StringBuffer js = new StringBuffer("$j.busy("); if (msg == null) { js.append("null"); @@ -62,14 +62,13 @@ js.append("'"); } js.append(", "); - + js.append(opacity); js.append(", "); - + js.append(showCancelButton); js.append(", "); - - + String script = null; try { script = behaviorCancel.getScriptCallBack(); @@ -83,7 +82,7 @@ js.append(script); js.append("}"); } - + final Color paneColor = parent.getPaneColor(); if (paneColor == null) { js.append(", null"); @@ -93,7 +92,7 @@ js.append(color); js.append("'"); } - + final Color textColor = parent.getTextColor(); if (textColor == null) { js.append(", null"); @@ -103,21 +102,30 @@ js.append(color); js.append("'"); } - + + if (fontType == null) { + js.append(", null"); + } else { + final String font = PersistHelper.createFontCssString(parent.getFontType()); + js.append(", '"); + js.append(font); + js.append("'"); + } + if (cancelBtnText != null) { js.append(", '"); js.append(cancelBtnText); js.append("'"); } - + js.append(");\n"); js.append(behaviorStart.getScriptForCallback()); pc.addDynamicJavaScript(js.toString()); setCanceled(false); } - - //callProcess(); + + // callProcess(); } public void ready() { @@ -131,18 +139,20 @@ Debug.error(ex); } if (useAjax()) { - final IPageContributor pc = ((IWebClientPluginAccess)application).getPageContributor(); + final IPageContributor pc = ((IWebClientPluginAccess) application).getPageContributor(); final String js = "$j.unblockUI({ onUnblock: null });"; pc.addDynamicJavaScript(js); } setCanceled(true); } - + public void prepare() { initialize(); } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see com.servoyguy.plugins.busy.BusyAbstractScriptObject#dispose() */ public void dispose() { @@ -150,15 +160,15 @@ behaviorStart = null; behaviorCancel = null; } - + public String getClientID() { return application.getClientID(); } - + private IPageContributor initialize() { - final IPageContributor ipc = ((IWebClientPluginAccess)application).getPageContributor(); + final IPageContributor ipc = ((IWebClientPluginAccess) application).getPageContributor(); if (useAjax() && !busy.get()) { - + if (ipc.getBehavior(JQueryHeaderContributor.BEHAVIOR_TAG) == null) { ipc.addBehavior(JQueryHeaderContributor.BEHAVIOR_TAG, new JQueryHeaderContributor()); } @@ -168,7 +178,7 @@ if (ipc.getBehavior(BusyHeaderContributor.BEHAVIOR_TAG) == null) { ipc.addBehavior(BusyHeaderContributor.BEHAVIOR_TAG, new BusyHeaderContributor()); } - + if (ipc.getBehavior(BusyScriptBehaviorStart.BEHAVIOR_TAG) == null) { behaviorStart = new BusyScriptBehaviorStart(this); ipc.addBehavior(BusyScriptBehaviorStart.BEHAVIOR_TAG, behaviorStart); @@ -181,7 +191,9 @@ return ipc; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see net.stuff.servoy.BusyAbstractProvider#isCanceled() */ @Override