|
From: <de...@us...> - 2012-11-14 10:19:28
|
Revision: 7881
http://fudaa.svn.sourceforge.net/fudaa/?rev=7881&view=rev
Author: deniger
Date: 2012-11-14 10:19:17 +0000 (Wed, 14 Nov 2012)
Log Message:
-----------
Modified Paths:
--------------
trunk/framework/ctulu-bu/src/main/java/com/memoire/bu/BuDialog.java
trunk/framework/ctulu-bu/src/main/java/com/memoire/bu/BuSplashScreen.java
trunk/framework/ctulu-bu/src/main/java/com/memoire/bu/BuToolButton.java
Modified: trunk/framework/ctulu-bu/src/main/java/com/memoire/bu/BuDialog.java
===================================================================
--- trunk/framework/ctulu-bu/src/main/java/com/memoire/bu/BuDialog.java 2012-11-14 08:38:46 UTC (rev 7880)
+++ trunk/framework/ctulu-bu/src/main/java/com/memoire/bu/BuDialog.java 2012-11-14 10:19:17 UTC (rev 7881)
@@ -1,14 +1,13 @@
/**
* @modification $Date: 2007-03-09 08:37:38 $
- * @statut unstable
- * @file BuDialog.java
- * @version 0.43
- * @author Guillaume Desnoix
- * @email gui...@de...
- * @license GNU General Public License 2 (GPL2)
- * @copyright 1998-2005 Guillaume Desnoix
+ * @statut unstable
+ * @file BuDialog.java
+ * @version 0.43
+ * @author Guillaume Desnoix
+ * @email gui...@de...
+ * @license GNU General Public License 2 (GPL2)
+ * @copyright 1998-2005 Guillaume Desnoix
*/
-
package com.memoire.bu;
import java.awt.Color;
@@ -34,84 +33,83 @@
import com.memoire.fu.FuLog;
/**
- * An abstract class for dialogs.
- * Better to use than JOptionPane.
+ * An abstract class for dialogs. Better to use than JOptionPane.
*/
public abstract class BuDialog
- extends JDialog
- implements ActionListener, BuBorders
-{
- private static final int GAP=
- BuPreferences.BU.getIntegerProperty("layout.gap",5);
+ extends JDialog
+ implements ActionListener, BuBorders {
- protected Frame frame_;
- protected JComponent content_;
- protected JComponent lbMessage_;
- protected BuScrollPane scrollpane_;
+ private static final int GAP =
+ BuPreferences.BU.getIntegerProperty("layout.gap", 5);
+ protected Frame frame_;
+ protected JComponent content_;
+ protected JComponent lbMessage_;
+ protected BuScrollPane scrollpane_;
protected BuBorderLayout layout_;
- protected int reponse_;
- protected Object message_;
+ protected int reponse_;
+ protected Object message_;
- public BuDialog(BuCommonInterface _parent,
- BuInformationsSoftware _isoft,
- String _titre)
- {
- this(_parent,_isoft,_titre,null);
+ public BuDialog(BuCommonInterface _parent,
+ BuInformationsSoftware _isoft,
+ String _titre) {
+ this(_parent, _isoft, _titre, null);
}
- public BuDialog(BuCommonInterface _parent,
- BuInformationsSoftware _isoft,
- String _titre,
- Object _message)
- {
- super(_parent==null ? BuLib.HELPER : _parent.getFrame());
+ public BuDialog(BuCommonInterface _parent,
+ BuInformationsSoftware _isoft,
+ String _titre,
+ Object _message) {
+ super(_parent == null ? BuLib.HELPER : _parent.getFrame());
- if(_parent!=null) frame_=_parent.getFrame();
- reponse_=JOptionPane.CANCEL_OPTION;
+ if (_parent != null) {
+ frame_ = _parent.getFrame();
+ }
+ reponse_ = JOptionPane.CANCEL_OPTION;
- BuBorderLayout mlo=new BuBorderLayout();
+ BuBorderLayout mlo = new BuBorderLayout();
- JComponent mct=(JComponent)getContentPane();
+ JComponent mct = (JComponent) getContentPane();
mct.setLayout(mlo);
- BuInformationsSoftware isoft=_isoft;
+ BuInformationsSoftware isoft = _isoft;
/*if((_parent!=null)&&(isoft==null))
- isoft=_parent.getInformationsSoftware();*/
+ isoft=_parent.getInformationsSoftware();*/
- if(isoft!=null)
- {
- BuPanel mpi=new BuPanel();
+ if (isoft != null) {
+ BuPanel mpi = new BuPanel();
mpi.setLayout(new BuVerticalLayout(GAP));
mpi.setBorder(BuLib.getEmptyBorder(GAP)); //10,10,10,10));
- Color bg=BuLib.getColor(mpi.getBackground().darker());
- Color fg=BuLib.getColor(Color.white);
- if(bg.equals(fg)) fg=BuLib.getColor(Color.black);
+ Color bg = BuLib.getColor(mpi.getBackground().darker());
+ Color fg = BuLib.getColor(Color.white);
+ if (bg.equals(fg)) {
+ fg = BuLib.getColor(Color.black);
+ }
mpi.setBackground(bg);
mpi.setForeground(fg);
-
- BuPicture ml_logo=null;
- if(isoft.logo!=null)
- {
- ml_logo=new BuPicture(isoft.logo);
- // setIconImage(BuResource.BU.getImage("dialog"));
+
+ BuPicture ml_logo = null;
+ if (isoft.logo != null) {
+ ml_logo = new BuPicture(isoft.logo);
+ // setIconImage(BuResource.BU.getImage("dialog"));
}
-
- BuLabelMultiLine ml_isoft=new BuLabelMultiLine
- (isoft.name+"\nversion: "+isoft.version+"\ndate: "+isoft.date);
- ml_isoft.setFont(BuLib.deriveFont("Label",Font.PLAIN,-2));
+
+ BuLabelMultiLine ml_isoft = new BuLabelMultiLine(isoft.name + "\nversion: " + isoft.version + "\ndate: " + isoft.date);
+ ml_isoft.setFont(BuLib.deriveFont("Label", Font.PLAIN, -2));
ml_isoft.setForeground(fg);//Color.white);
- if(ml_logo!=null) mpi.add(ml_logo);
+ if (ml_logo != null) {
+ mpi.add(ml_logo);
+ }
mpi.add(ml_isoft);
- mct.add(mpi,BuBorderLayout.WEST);
+ mct.add(mpi, BuBorderLayout.WEST);
}
- layout_=new BuBorderLayout();
+ layout_ = new BuBorderLayout();
layout_.setHgap(GAP);
layout_.setVgap(GAP);
- content_=new BuPanel();
+ content_ = new BuPanel();
content_.setBorder(BuLib.getEmptyBorder(GAP));//BuBorders.EMPTY5555);
content_.setLayout(layout_);
- mct.add(content_,BuBorderLayout.CENTER);
+ mct.add(content_, BuBorderLayout.CENTER);
setMessage(_message);
setResizable(false);
@@ -121,160 +119,163 @@
addWindowListener(new WAD());
}
- public void setMessage(Object _message)
- {
- if((lbMessage_!=null)&&(lbMessage_.getParent()==content_))
+ public void setMessage(Object _message) {
+ if ((lbMessage_ != null) && (lbMessage_.getParent() == content_)) {
content_.remove(lbMessage_);
- if((scrollpane_!=null)&&(scrollpane_.getParent()==content_))
+ }
+ if ((scrollpane_ != null) && (scrollpane_.getParent() == content_)) {
content_.remove(scrollpane_);
- Object message=_message;
- if(message==null)
- message=getComponent();
- if(message==null)
- message="Please overload getComponent() in BuDialog.";
+ }
+ Object message = _message;
+ if (message == null) {
+ message = getComponent();
+ }
+ if (message == null) {
+ message = "Please overload getComponent() in BuDialog.";
+ }
- message_=message;
+ message_ = message;
- if(message instanceof JComponent)
- lbMessage_=(JComponent)message;
- else
- {
- String text=message.toString();
- if(text.startsWith("<HTML>"))
- {
- BuEditorPane html=new BuEditorPane();
+ if (message instanceof JComponent) {
+ lbMessage_ = (JComponent) message;
+ } else {
+ String text = message.toString();
+ if (text.startsWith("<HTML>") || text.startsWith("<html>")) {
+ BuEditorPane html = new BuEditorPane();
/*GCJ-BEGIN*/
- EditorKit ek =html.getEditorKitForContentType("text/html");
- Document dk =ek.createDefaultDocument();
+ EditorKit ek = html.getEditorKitForContentType("text/html");
+ Document dk = ek.createDefaultDocument();
- try { ek.read(new StringReader(text),dk,0); }
- catch(Exception ex) { FuLog.warning(ex); }
+ try {
+ ek.read(new StringReader(text), dk, 0);
+ } catch (Exception ex) {
+ FuLog.warning(ex);
+ }
- html.setOpaque(false);
- html.setBorder(EMPTY0000);
- html.setEditable(false);
- html.setEditorKit(ek);
- html.setDocument(dk);
+ html.setOpaque(false);
+ html.setBorder(EMPTY0000);
+ html.setEditable(false);
+ html.setEditorKit(ek);
+ html.setDocument(dk);
/*GCJ-END*/
- lbMessage_=html;
+ lbMessage_ = html;
+ } else {
+ lbMessage_ = new BuLabelMultiLine(text);
+ ((BuLabelMultiLine) lbMessage_).setPreferredWidth(440);
+ ((BuLabelMultiLine) lbMessage_).setWrapMode(BuLabelMultiLine.WORD);
+ lbMessage_.setFont(BuLib.deriveFont("Label", Font.PLAIN, 0));
+ lbMessage_.setBorder(EMPTY5555);
}
- else
- {
- lbMessage_=new BuLabelMultiLine(text);
- ((BuLabelMultiLine)lbMessage_).setPreferredWidth(440);
- ((BuLabelMultiLine)lbMessage_).setWrapMode(BuLabelMultiLine.WORD);
- lbMessage_.setFont(BuLib.deriveFont("Label",Font.PLAIN, 0));
- lbMessage_.setBorder(EMPTY5555);
- }
}
- if(needsScrollPane())
- {
- scrollpane_=new BuScrollPane(lbMessage_);
- int h=lbMessage_.getFont().getSize();
- scrollpane_.getHorizontalScrollBar().setUnitIncrement (150);
- scrollpane_.getVerticalScrollBar() .setUnitIncrement (h+1);
+ if (needsScrollPane()) {
+ scrollpane_ = new BuScrollPane(lbMessage_);
+ int h = lbMessage_.getFont().getSize();
+ scrollpane_.getHorizontalScrollBar().setUnitIncrement(150);
+ scrollpane_.getVerticalScrollBar().setUnitIncrement(h + 1);
- if((lbMessage_ instanceof BuLabelMultiLine)&&
- (((BuLabelMultiLine)lbMessage_).getWrapMode()
- !=BuLabelMultiLine.NONE))
- {
- scrollpane_.setHorizontalScrollBarPolicy
- (ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
- scrollpane_.setVerticalScrollBarPolicy
- (ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
- scrollpane_.setPreferredSize(scrollpane_.getPreferredSize());
- scrollpane_.setVerticalScrollBarPolicy
- (ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
+ if ((lbMessage_ instanceof BuLabelMultiLine)
+ && (((BuLabelMultiLine) lbMessage_).getWrapMode()
+ != BuLabelMultiLine.NONE)) {
+ scrollpane_.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
+ scrollpane_.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
+ scrollpane_.setPreferredSize(scrollpane_.getPreferredSize());
+ scrollpane_.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
}
- content_.add(scrollpane_,BuBorderLayout.CENTER);
+ content_.add(scrollpane_, BuBorderLayout.CENTER);
+ } else {
+ content_.add(lbMessage_, BuBorderLayout.CENTER);
}
- else
- {
- content_.add(lbMessage_,BuBorderLayout.CENTER);
- }
- if(lbMessage_.isFocusable())
+ if (lbMessage_.isFocusable()) {
lbMessage_.requestFocus();
- else
+ } else {
transferFocus();
+ }
//if(content_.isShowing()) content_.revalidate();
}
- class WAD extends WindowAdapter
- {
- public void windowActivated(WindowEvent _evt)
- {
+ class WAD extends WindowAdapter {
+
+ public void windowActivated(WindowEvent _evt) {
//System.err.println("Dialog.Activated");
- JButton db=getRootPane().getDefaultButton();
+ JButton db = getRootPane().getDefaultButton();
//System.err.println("Dialog.defaultButton="+db);
//System.err.println("Dialog.focusOwner="+getFocusOwner());
- if((getFocusOwner()==null)&&(db!=null)) db.requestFocus();
+ if ((getFocusOwner() == null) && (db != null)) {
+ db.requestFocus();
+ }
}
}
// Resource
-
- protected String _(String _s)
- {
+ protected String _(String _s) {
return BuResource.BU.getString(_s);
}
- protected static final String __(String _s)
- {
+ protected static final String __(String _s) {
return BuResource.BU.getString(_s);
}
// Anti-aliasing
-
- public final void paint(Graphics _g)
- {
- BuLib.setAntialiasing(this,_g);
+ public final void paint(Graphics _g) {
+ BuLib.setAntialiasing(this, _g);
super.paint(_g);
}
public abstract JComponent getComponent();
+
public abstract void actionPerformed(ActionEvent _evt);
- public boolean needsScrollPane()
- {
+ public boolean needsScrollPane() {
return true;
}
- public final int activate()
- {
- reponse_=JOptionPane.CANCEL_OPTION;
+ public final int activate() {
+ reponse_ = JOptionPane.CANCEL_OPTION;
- JComponent mct=(JComponent)getContentPane();
+ JComponent mct = (JComponent) getContentPane();
- Dimension d=mct.getPreferredSize();
- Dimension ecran=getToolkit().getScreenSize();
+ Dimension d = mct.getPreferredSize();
+ Dimension ecran = getToolkit().getScreenSize();
//d.width+=30; d.height+=30;
- if(!(message_ instanceof JComponent))
- {
- if(d.width <450) d.width =450;
- if(d.width >550) d.width =550;
- if(d.height<150) d.height=150;
- if(d.height>250) d.height=250;
+ if (!(message_ instanceof JComponent)) {
+ if (d.width < 450) {
+ d.width = 450;
+ }
+ if (d.width > 550) {
+ d.width = 550;
+ }
+ if (d.height < 150) {
+ d.height = 150;
+ }
+ if (d.height > 250) {
+ d.height = 250;
+ }
}
- if(d.width >ecran.width *3/4) d.width=ecran.width *3/4;
- if(d.height>ecran.height*3/4) d.height=ecran.height*3/4;
+ if (d.width > ecran.width * 3 / 4) {
+ d.width = ecran.width * 3 / 4;
+ }
+ if (d.height > ecran.height * 3 / 4) {
+ d.height = ecran.height * 3 / 4;
+ }
- boolean resizable=isResizable();
+ boolean resizable = isResizable();
setResizable(true);
//setSize(d);
mct.setPreferredSize(d);
pack();
//setSize(getPreferredSize());
- Point p=getLocation();
- if((p.x==0)&&(p.y==0))
- setLocation((ecran.width-d.width)/2,(ecran.height-d.height)/2);
+ Point p = getLocation();
+ if ((p.x == 0) && (p.y == 0)) {
+ setLocation((ecran.width - d.width) / 2, (ecran.height - d.height) / 2);
+ }
setResizable(resizable);
@@ -284,14 +285,15 @@
show();
// release native resources
- if(isModal()) dispose();
+ if (isModal()) {
+ dispose();
+ }
return reponse_;
}
- public void show()
- {
- BuLib.computeMnemonics(getRootPane(),this);
+ public void show() {
+ BuLib.computeMnemonics(getRootPane(), this);
super.show();
}
}
Modified: trunk/framework/ctulu-bu/src/main/java/com/memoire/bu/BuSplashScreen.java
===================================================================
--- trunk/framework/ctulu-bu/src/main/java/com/memoire/bu/BuSplashScreen.java 2012-11-14 08:38:46 UTC (rev 7880)
+++ trunk/framework/ctulu-bu/src/main/java/com/memoire/bu/BuSplashScreen.java 2012-11-14 10:19:17 UTC (rev 7881)
@@ -1,14 +1,13 @@
/**
* @modification $Date: 2006-09-19 14:35:07 $
- * @statut unstable
- * @file BuSplashScreen.java
- * @version 0.43
- * @author Guillaume Desnoix
- * @email gui...@de...
- * @license GNU General Public License 2 (GPL2)
- * @copyright 1998-2005 Guillaume Desnoix
+ * @statut unstable
+ * @file BuSplashScreen.java
+ * @version 0.43
+ * @author Guillaume Desnoix
+ * @email gui...@de...
+ * @license GNU General Public License 2 (GPL2)
+ * @copyright 1998-2005 Guillaume Desnoix
*/
-
package com.memoire.bu;
import java.awt.Color;
@@ -30,7 +29,7 @@
* An easy-to-use splash screen which takes a list of classes to load.
*/
public class BuSplashScreen extends JWindow // BuPopupWindow
- implements BuBorders // Runnable
+ implements BuBorders // Runnable
{
/*
* class XLabel extends BuLabel { protected void paintComponent(Graphics _g) { Color old=getForeground();
@@ -43,15 +42,12 @@
* old=getForeground(); setForeground(Color.white); for(int i=-1;i<=1;i++) for(int j=-1;j<=1;j++) { _g.translate(i,j);
* super.paintComponent(_g); _g.translate(-i,-j); } setForeground(old); super.paintComponent(_g); } }
*/
-
private ClassLoader loader_;
private BuInformationsSoftware info_;
private long delai_;
private String[][] classes_;
// private String base_;
-
protected JComponent content_;
-
protected JPanel panel_;
protected BuPanel left_;
protected BuProgressBar progression_;
@@ -63,7 +59,6 @@
* this(_info,_delai,new String[][]{_classes}); } public BuSplashScreen(BuInformationsSoftware _info, long _delai,
* String[][] _classes, String _base) { this(_info,_delai,_classes); }
*/
-
public BuSplashScreen(BuInformationsSoftware _info, long _delai, String[][] _classes) {
this(_info, _delai, _classes, null);
}
@@ -77,7 +72,9 @@
// base_ =_base;
loader_ = _loader;
- if (loader_ == null) loader_ = getClass().getClassLoader();
+ if (loader_ == null) {
+ loader_ = getClass().getClassLoader();
+ }
content_ = new BuPanel();
content_.setLayout(new BuBorderLayout());
@@ -92,7 +89,9 @@
panel_.setLayout(new BuBorderLayout());
BuPicture ml_logo = null;
- if (info_.logo != null) ml_logo = new BuPicture(info_.logo);
+ if (info_.logo != null) {
+ ml_logo = new BuPicture(info_.logo);
+ }
BuVerticalLayout leftlo = new BuVerticalLayout();
leftlo.setVfilled(false);
@@ -106,7 +105,9 @@
Color bg = BuLib.getColor(left_.getBackground().darker());
left_.setBackground(bg);
- if (ml_logo != null) left_.add(ml_logo);
+ if (ml_logo != null) {
+ left_.add(ml_logo);
+ }
BuLabel l1 = new BuLabel();
BuLabel l2 = new BuLabel();
@@ -117,7 +118,9 @@
l1.setText(info_.name + " " + info_.version);
l2.setText(info_.date);
- l3.setText(info_.authors[0]);
+ if (info_.authors != null) {
+ l3.setText(info_.authors[0]);
+ }
l4.setText(info_.contact + "\n" + info_.http);
l1.setHorizontalAlignment(SwingConstants.CENTER);
@@ -221,7 +224,8 @@
if (!SwingUtilities.isEventDispatchThread()) {
try {
Thread.sleep(200L);
- } catch (InterruptedException ex) {}
+ } catch (InterruptedException ex) {
+ }
}
run();
@@ -243,22 +247,29 @@
pp = -1;
l = 0;
- for (i = 0; i < classes_.length; i++)
+ for (i = 0; i < classes_.length; i++) {
l += classes_[i].length;
+ }
m = 0;
- for (i = 0; i < classes_.length; i++)
+ for (i = 0; i < classes_.length; i++) {
for (j = 0; j < classes_[i].length; j++) {
String n = classes_[i][j];
// int k=n.lastIndexOf('.');
// setText(k>=0 ? n.substring(k+1) : n);
String t = n;
int k = t.indexOf('$');
- if (k >= 0) t = t.substring(0, k);
+ if (k >= 0) {
+ t = t.substring(0, k);
+ }
k = t.lastIndexOf('.');
- if (k >= 0) t = t.substring(0, k);
+ if (k >= 0) {
+ t = t.substring(0, k);
+ }
k = t.lastIndexOf('.');
- if (k >= 0) t = t.substring(k + 1);
+ if (k >= 0) {
+ t = t.substring(k + 1);
+ }
if (!t.equals(ps)) {
setText(t);
ps = t;
@@ -266,9 +277,11 @@
// if(k<0) n=paquet+n;
try {
- if (loader_ == null) Class.forName(n);
- else loader_.loadClass(n); // Class.forName(n,false,loader_);
-
+ if (loader_ == null) {
+ Class.forName(n);
+ } else {
+ loader_.loadClass(n); // Class.forName(n,false,loader_);
+ }
// Class c=Class.forName(n);
// FuClassLoaderDedicated.putGlobal(c);
} catch (Exception ex) {
@@ -288,6 +301,7 @@
pp = p;
}
}
+ }
setText("");
setProgression(100);
@@ -298,7 +312,8 @@
do {
try {
Thread.sleep(50);
- } catch (Exception ex) {}
+ } catch (Exception ex) {
+ }
diff = System.currentTimeMillis() - avant;
p = (int) (diff * 100 / delai_);
@@ -319,7 +334,8 @@
// BuUpdateGUI.repaintNow(message_);
}
});
- } catch (InterruptedException ex) {} catch (InvocationTargetException ex) {
+ } catch (InterruptedException ex) {
+ } catch (InvocationTargetException ex) {
FuLog.error(ex);
}
}
@@ -341,7 +357,8 @@
// BuUpdateGUI.repaintNow(progression_);
}
});
- } catch (InterruptedException ex) {} catch (InvocationTargetException ex) {
+ } catch (InterruptedException ex) {
+ } catch (InvocationTargetException ex) {
FuLog.error(ex);
}
}
Modified: trunk/framework/ctulu-bu/src/main/java/com/memoire/bu/BuToolButton.java
===================================================================
--- trunk/framework/ctulu-bu/src/main/java/com/memoire/bu/BuToolButton.java 2012-11-14 08:38:46 UTC (rev 7880)
+++ trunk/framework/ctulu-bu/src/main/java/com/memoire/bu/BuToolButton.java 2012-11-14 10:19:17 UTC (rev 7881)
@@ -21,12 +21,9 @@
import java.awt.Point;
import java.awt.event.MouseEvent;
-import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JComponent;
-import javax.swing.UIManager;
-import javax.swing.border.Border;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.FontUIResource;
import javax.swing.plaf.InsetsUIResource;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|