[MOBY-guts] biomoby commit
Paul Gordon
gordonp at dev.open-bio.org
Thu May 13 16:13:21 UTC 2010
gordonp
Thu May 13 12:13:21 EDT 2010
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui
In directory dev.open-bio.org:/tmp/cvs-serv29381/src/main/ca/ucalgary/seahawk/gui
Modified Files:
MobyContentGUI.java
Log Message:
UI fixes: splash screen, button bar layout, tab layout
moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentGUI.java,1.22,1.23
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2010/05/04 16:19:37 1.22
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2010/05/13 16:13:21 1.23
@@ -7,6 +7,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
+import java.util.concurrent.Semaphore;
import javax.swing.*;
import javax.swing.event.*;
@@ -19,6 +20,7 @@
import org.w3c.tidy.Tidy;
import org.biomoby.client.*;
+import org.biomoby.client.util.SplashScreenStatus;
import org.biomoby.registry.meta.*;
import org.biomoby.shared.*;
import org.biomoby.shared.data.*;
@@ -54,7 +56,7 @@
public final static String FILE_CHOOSER_OPEN_TITLE = "Load data from file";
public final static String WEB_ADDR_DIALOG_TITLE = "Load Data From A Web Address (URL)";
- public final static String DEFAULT_STATUS_MSG = "Click hyperlink to explore MOBY Web services";
+ public final static String DEFAULT_STATUS_MSG = "Click hyperlink to explore MOBY Web services ";
public final static String RESOURCE_SYSTEM_PROPERTY = "seahawk.stylesheet";
public final static String DEFAULT_STARTUP_PAGE_RESOURCE = "ca/ucalgary/seahawk/resources/startup.html";
public final static String DEFAULT_XSLT_CONVERTER_URL = "ca/ucalgary/seahawk/resources/moby2HTML.xsl";
@@ -108,7 +110,7 @@
public MobyContentGUI(MobyServicesGUI mgui){
super();
setTitle("Seahawk: MOBY Data Display");
- setSize(530, 400);
+ setPreferredSize(new Dimension(530, 400));
servicesGUI = mgui;
request2tab = new TreeMap<Integer,MobyContentPane>();
setup = false;
@@ -120,100 +122,110 @@
if(cl == null){
cl = ClassLoader.getSystemClassLoader();
}
- GridBagLayout gridbag = new GridBagLayout();
- GridBagConstraints c = new GridBagConstraints();
- statusPanel.setLayout(gridbag);
+ BoxLayout box = new BoxLayout(statusPanel, BoxLayout.LINE_AXIS);
+ statusPanel.setLayout(box);
Dimension buttonSize = new Dimension(20,20);
backwardButton = new JButton(new ImageIcon(cl.getResource("ca/ucalgary/seahawk/resources/images/back.gif")));
backwardButton.setDisabledIcon(new ImageIcon(cl.getResource("ca/ucalgary/seahawk/resources/images/back_d.gif")));
backwardButton.setToolTipText("Go to previous document in this tab's history");
+ backwardButton.setMinimumSize(buttonSize);
backwardButton.setPreferredSize(buttonSize);
+ backwardButton.setMaximumSize(buttonSize);
backwardButton.setEnabled(false);
backwardButton.addActionListener(this);
backwardButton.setName(BACK_BUTTON_NAME); // so test cases can find the component
- gridbag.setConstraints(backwardButton, c);
statusPanel.add(backwardButton);
forwardButton = new JButton(new ImageIcon(cl.getResource("ca/ucalgary/seahawk/resources/images/forward.gif")));
forwardButton.setDisabledIcon(new ImageIcon(cl.getResource("ca/ucalgary/seahawk/resources/images/forward_d.gif")));
forwardButton.setToolTipText(FORWARD_BUTTON_MSG);
+ forwardButton.setMinimumSize(buttonSize);
forwardButton.setPreferredSize(buttonSize);
+ forwardButton.setMaximumSize(buttonSize);
forwardButton.setEnabled(false);
forwardButton.addActionListener(this);
forwardButton.setName(FORWARD_BUTTON_NAME);
- gridbag.setConstraints(forwardButton, c);
statusPanel.add(forwardButton);
filterButton = new JButton(new ImageIcon(cl.getResource("ca/ucalgary/seahawk/resources/images/search.gif")));
filterButton.setDisabledIcon(new ImageIcon(cl.getResource("ca/ucalgary/seahawk/resources/images/search_d.gif")));
filterButton.setToolTipText("Search and filter the page contents");
+ filterButton.setMinimumSize(buttonSize);
filterButton.setPreferredSize(buttonSize);
+ filterButton.setMaximumSize(buttonSize);
filterButton.setEnabled(true);
filterButton.addActionListener(this);
filterButton.setName(FILTER_BUTTON_NAME);
- gridbag.setConstraints(filterButton, c);
statusPanel.add(filterButton);
openButton = new JButton(new ImageIcon(cl.getResource("ca/ucalgary/seahawk/resources/images/bookmarks.gif")));
openButton.setToolTipText("Open a document from file or the Web");
+ openButton.setMinimumSize(buttonSize);
openButton.setPreferredSize(buttonSize);
+ openButton.setMaximumSize(buttonSize);
openButton.setEnabled(true);
openButton.addActionListener(this);
openButton.addMouseListener(this);
openButton.setName(OPEN_BUTTON_NAME);
- gridbag.setConstraints(openButton, c);
statusPanel.add(openButton);
saveButton = new JButton(new ImageIcon(cl.getResource("ca/ucalgary/seahawk/resources/images/save.gif")));
saveButton.setDisabledIcon(new ImageIcon(cl.getResource("ca/ucalgary/seahawk/resources/images/save_d.gif")));
saveButton.setToolTipText("Save this tab's document to a file");
+ saveButton.setMinimumSize(buttonSize);
saveButton.setPreferredSize(buttonSize);
+ saveButton.setMaximumSize(buttonSize);
saveButton.setEnabled(true);
saveButton.addActionListener(this);
saveButton.setName(SAVE_BUTTON_NAME);
- gridbag.setConstraints(saveButton, c);
statusPanel.add(saveButton);
printButton = new JButton(new ImageIcon(cl.getResource("ca/ucalgary/seahawk/resources/images/print.gif")));
printButton.setToolTipText("Print this tab's document as shown");
+ printButton.setMinimumSize(buttonSize);
printButton.setPreferredSize(buttonSize);
+ printButton.setMaximumSize(buttonSize);
printButton.setEnabled(true);
printButton.addActionListener(this);
printButton.setName(PRINT_BUTTON_NAME);
- gridbag.setConstraints(printButton, c);
statusPanel.add(printButton);
helpButton = new JButton(new ImageIcon(cl.getResource("ca/ucalgary/seahawk/resources/images/help.gif")));
helpButton.setToolTipText("Show help on using this interface");
+ helpButton.setMinimumSize(buttonSize);
helpButton.setPreferredSize(buttonSize);
+ helpButton.setMaximumSize(buttonSize);
helpButton.setEnabled(true);
helpButton.addActionListener(this);
helpButton.setName(HELP_BUTTON_NAME);
- gridbag.setConstraints(helpButton, c);
statusPanel.add(helpButton);
settingsButton = new JButton(new ImageIcon(cl.getResource("ca/ucalgary/seahawk/resources/images/settings.gif")));
settingsButton.setToolTipText("Show program options");
+ settingsButton.setMinimumSize(buttonSize);
settingsButton.setPreferredSize(buttonSize);
+ settingsButton.setMaximumSize(buttonSize);
settingsButton.setEnabled(true);
settingsButton.addActionListener(this);
settingsButton.setName(SETTINGS_BUTTON_NAME);
- gridbag.setConstraints(settingsButton, c);
statusPanel.add(settingsButton);
+ statusPanel.add(Box.createRigidArea(new Dimension(5,0)));
+
status = new JLabel(DEFAULT_STATUS_MSG, SwingConstants.LEFT);
- JPanel labelPanel = new JPanel();
- labelPanel.setLayout(new BorderLayout());
- labelPanel.setPreferredSize(new Dimension(380, buttonSize.height));
- c.gridwidth = GridBagConstraints.REMAINDER; //end row
- gridbag.setConstraints(labelPanel, c);
- labelPanel.add(status, BorderLayout.WEST); //use a label panel to have a fixed size for the status message
- statusPanel.add(labelPanel);
+ //JPanel labelPanel = new JPanel();
+ //labelPanel.setLayout(new BorderLayout());
+ status.setPreferredSize(new Dimension(380, buttonSize.height));
+ //labelPanel.setPreferredSize(new Dimension(380, buttonSize.height));
+ //labelPanel.add(status, BorderLayout.WEST); //use a label panel to have a fixed size for the status message
+ //statusPanel.add(labelPanel);
+ statusPanel.add(status);
+ statusPanel.add(Box.createHorizontalGlue());
getContentPane().add(statusPanel, java.awt.BorderLayout.SOUTH);
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
- tabbedPane = new JTabbedPane(JTabbedPane.TOP, JTabbedPane.SCROLL_TAB_LAYOUT);
+ tabbedPane = new JTabbedPane(JTabbedPane.TOP, JTabbedPane.WRAP_TAB_LAYOUT);
tabbedPane.setName(TABBED_PANE_NAME);
// See OptionsTabbedPaneUI class definiton at the end of this file (overrides right-click behaviour)
tabbedPane.setUI(new OptionsTabbedPaneUI(this));
@@ -496,6 +508,7 @@
tce.printStackTrace();
}
+ pack();
setVisible(true);
//tabbedPane.add(clipboard);
int clipboardIndex = tabbedPane.indexOfComponent(clipboard);
@@ -562,6 +575,7 @@
public void setStatus(String msg){
status.setText(msg);
+ status.setToolTipText(msg);
}
public void componentHidden(ComponentEvent e){}
@@ -1156,7 +1170,41 @@
defaultCloseOperation = code;
}
+ private static void renderSplashFrame(Graphics2D g){
+ g.setComposite(AlphaComposite.Clear);
+ g.fillRect(140,140,220,40);
+ g.setPaintMode();
+ g.setColor(Color.BLACK);
+ g.drawString(SplashScreenStatus.getStatus(), 140, 150);
+ }
+
public static void main(String[] argv){
+ final SplashScreen splash = SplashScreen.getSplashScreen();
+ final Semaphore killSplash = new Semaphore(0);
+ final Graphics2D g = splash == null ? null : splash.createGraphics();
+ if (g == null || splash == null) {
+ logger.warn("Graphics object for splash screen is null");
+ }
+ else{
+ new Thread(){
+ public void run(){
+ for(;;) {
+ renderSplashFrame(g);
+ splash.update();
+ try {
+ Thread.sleep(100);
+ }
+ catch(InterruptedException e) {
+ }
+ if(killSplash.tryAcquire()){
+ splash.close();
+ return;
+ }
+ }
+ }}.start();
+ }
+
+ SplashScreenStatus.setStatus("Setting Java properties");
// This code is simply used to avoid the ClassLoader from searching for non-existent properties files,
// etc. by forcing resource loading for the only supported locale, _en
java.util.Locale.setDefault(java.util.Locale.ENGLISH);
@@ -1192,6 +1240,7 @@
// "ca/ucalgary/services/util/client-config.wsdd");
// First, restore any user preferences (uses default settings file location)
+ SplashScreenStatus.setStatus("Restoring user preferences");
try{
SeahawkOptions.restoreSettings();
} catch(Exception e){
@@ -1200,10 +1249,14 @@
SeahawkOptions.getDefaultsFile()+": "+ e);
}
// Asynchronously load up ontology data so it's ready when the user needs it.
+ SplashScreenStatus.setStatus("Loading interface");
MobyContentGUI gui = MobyUtils.getMobyContentGUI(new JLabel());
gui.setDefaultCloseOperation(defaultCloseOperation);
+ gui.pack();
gui.setVisible(true);
+
+ killSplash.release();
if(argv.length != 0 && argv[0] != null && argv[0].length() != 0){
try{
gui.loadPaneFromURL(new URL(argv[0]), true);
@@ -1223,7 +1276,7 @@
else{
gui.loadPaneFromURL(startURL, true);
}
- }
+ }
}
protected static void cacheOntologies(){
More information about the MOBY-guts
mailing list