Changeset 1295 for branches/3.0-Beta1/components/bioformats-omero
- Timestamp:
- 02/28/07 11:02:43 (21 months ago)
- Location:
- branches/3.0-Beta1/components/bioformats-omero/src/ome/formats/importer
- Files:
-
- 1 added
- 1 removed
- 13 modified
-
FileQueueTable.java (modified) (1 diff)
-
ImportDialog.java (modified) (2 diffs)
-
ImportHandler.java (modified) (3 diffs)
-
ImportLibrary.java (modified) (3 diffs)
-
LoginDialog.java (modified) (11 diffs)
-
LoginHandler.java (modified) (9 diffs)
-
Main.java (modified) (10 diffs)
-
ServerDialog.java (modified) (3 diffs)
-
SplashWindow.java (modified) (9 diffs)
-
Splasher.java (modified) (1 diff)
-
StatusBar.java (modified) (1 diff)
-
about.txt (modified) (1 diff)
-
gfx/icon.png (added)
-
util/Actions.java (modified) (1 diff)
-
util/GuiCommonElements.java (deleted)
Legend:
- Unmodified
- Added
- Removed
-
branches/3.0-Beta1/components/bioformats-omero/src/ome/formats/importer/FileQueueTable.java
r1205 r1295 214 214 { 215 215 table.setValueAt("archiving", row, 2); 216 } 217 218 public void setProgressFailed(int index) 219 { 220 table.setValueAt("failed", row, 2); 216 221 } 217 222 -
branches/3.0-Beta1/components/bioformats-omero/src/ome/formats/importer/ImportDialog.java
r1196 r1295 104 104 ImportDialog(JFrame owner, String title, boolean modal, OMEROMetadataStore store) 105 105 { 106 super(); 106 107 this.store = store; 107 108 … … 171 172 archiveImage = addCheckBox(this, "Also archive the original image file(s)", c); 172 173 archiveImage.setSelected(false); 173 archiveImage.setVisible( false);174 archiveImage.setVisible(true); 174 175 175 176 cancelBtn = addButton(this, "Cancel", c, 1, 1, 1.0f, null); -
branches/3.0-Beta1/components/bioformats-omero/src/ome/formats/importer/ImportHandler.java
r1196 r1295 17 17 import java.io.File; 18 18 import java.io.IOException; 19 import java.io.PrintWriter; 20 import java.io.StringWriter; 19 21 import java.text.SimpleDateFormat; 20 22 import java.util.Date; … … 213 215 qTable.setProgressInfo(index, count); 214 216 217 try { 215 218 //viewer.appendToOutput("> Importing plane: "); 216 219 library.importData(pixId, fileName, new ImportLibrary.Step() … … 227 230 }); 228 231 232 } catch (FormatException e) 233 { 234 StringWriter sw = new StringWriter(); 235 PrintWriter pw = new PrintWriter(sw); 236 e.printStackTrace(pw); 237 qTable.setProgressFailed(index); 238 log.info(sw); 239 } catch (IOException e) 240 { 241 StringWriter sw = new StringWriter(); 242 PrintWriter pw = new PrintWriter(sw); 243 e.printStackTrace(pw); 244 qTable.setProgressFailed(index); 245 log.info(sw); 246 } 247 229 248 viewer.appendToOutputLn("> Successfully stored with pixels id \"" 230 249 + pixId + "\"."); -
branches/3.0-Beta1/components/bioformats-omero/src/ome/formats/importer/ImportLibrary.java
r1205 r1295 27 27 import loci.formats.IFormatReader; 28 28 import loci.formats.ReaderWrapper; 29 import loci.formats.TiffTools;30 29 import loci.formats.in.Bits; 31 30 import ome.conditions.ApiUsageException; … … 240 239 * completed. 241 240 */ 242 public void importData(long pixId, String fileName, Step step) 241 public void importData(long pixId, String fileName, Step step) 242 throws FormatException, IOException 243 243 { 244 244 int i = 1; 245 try {246 245 int bytesPerPixel = getBytesPerPixel(reader.getPixelType(fileName)); 247 246 byte[] buffer = null; … … 270 269 } 271 270 } 272 } catch (FormatException e)273 {274 StringWriter sw = new StringWriter();275 PrintWriter pw = new PrintWriter(sw);276 e.printStackTrace(pw);277 log.info(sw);278 return;279 } catch (IOException e)280 {281 StringWriter sw = new StringWriter();282 PrintWriter pw = new PrintWriter(sw);283 e.printStackTrace(pw);284 log.info(sw);285 return;286 }287 271 } 288 272 -
branches/3.0-Beta1/components/bioformats-omero/src/ome/formats/importer/LoginDialog.java
r1204 r1295 16 16 import java.awt.Color; 17 17 import java.awt.Dimension; 18 import java.awt.Frame; 18 19 import java.awt.Insets; 19 20 import java.util.ArrayList; … … 24 25 import java.awt.event.WindowAdapter; 25 26 import java.awt.event.WindowEvent; 27 import java.awt.event.WindowFocusListener; 26 28 import java.beans.PropertyChangeEvent; 27 29 import java.beans.PropertyChangeListener; … … 44 46 import javax.swing.text.StyleContext; 45 47 48 import ome.formats.importer.util.Actions; 46 49 import ome.formats.importer.util.GuiCommonElements; 47 50 … … 52 55 { 53 56 boolean debug = false; 57 58 JFrame main; 54 59 55 60 GuiCommonElements gui; … … 98 103 .userNodeForPackage(LoginDialog.class); 99 104 100 LoginDialog(JFrame owner, String title, boolean modal, boolean center) 101 { 105 LoginDialog (Frame owner, JFrame main, String title, boolean modal, boolean center) 106 { 107 super(owner); 108 this.main = main; 109 102 110 ImageIcon top = getImageIcon(Main.splash); 103 111 String laf = UIManager.getLookAndFeel().toString(); … … 107 115 setModal(modal); 108 116 setResizable(false); 117 toFront(); 118 // Nasty cludge to make dialog work with linux 119 //if (System.getProperty("os.name").toUpperCase().indexOf("LINUX") == 1) { 120 // setAlwaysOnTop(true); 121 //} 109 122 setSize(new Dimension(loginWidth, loginHeight)); 110 setLocationRelativeTo( owner);123 setLocationRelativeTo(main); 111 124 //get the amount to offset the login by 112 125 if (!center) … … 118 131 119 132 // Get the preference file options 120 username = userPrefs.get("username", username).trim(); 133 username = userPrefs.get("username", username); 134 if (username != null) username = username.trim(); 135 136 121 137 // password = userPrefs.get("password", password); 122 123 currentServer = userPrefs.get("server", currentServer).trim(); 138 currentServer = userPrefs.get("server", currentServer); 139 if (currentServer != null) currentServer = currentServer.trim(); 140 124 141 serverList = getServerList(); 125 142 126 port = userPrefs.get("port", port).trim(); 127 if (port == null) port = "1099"; 143 port = userPrefs.get("port", port); 144 if (port != null) port = port.trim(); 145 else port = "1099"; 128 146 129 147 gui = new GuiCommonElements(); … … 224 242 } 225 243 }); 226 244 227 245 // Add the tab panel to the main panel 228 246 mainPanel.add(topPanel, "0, 0, 3, 0"); … … 327 345 //port = prt.getText(); 328 346 cancelled = false; 347 firePropertyChange(Actions.LOGIN, false, true); 329 348 this.dispose(); 330 349 } … … 332 351 { 333 352 cancelled = true; 353 firePropertyChange(Actions.LOGIN_CANCELLED, false, true); 334 354 this.dispose(); 335 355 } … … 403 423 404 424 JFrame f = new JFrame(); 405 LoginDialog loginDialog = new LoginDialog(f, "", false, true);425 LoginDialog loginDialog = new LoginDialog(f, f, "", false, true); 406 426 f.setVisible(false); 407 427 f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); -
branches/3.0-Beta1/components/bioformats-omero/src/ome/formats/importer/LoginHandler.java
r1204 r1295 14 14 package ome.formats.importer; 15 15 16 import java.awt.event.WindowEvent; 17 import java.awt.event.WindowFocusListener; 18 import java.beans.PropertyChangeEvent; 19 import java.beans.PropertyChangeListener; 16 20 import java.io.PrintWriter; 17 21 import java.io.StringWriter; … … 19 23 20 24 import javax.ejb.EJBAccessException; 25 import javax.swing.ImageIcon; 26 import javax.swing.JFrame; 21 27 import javax.swing.JOptionPane; 22 28 23 29 import ome.formats.OMEROMetadataStore; 30 import ome.formats.importer.util.Actions; 24 31 25 32 import org.apache.commons.logging.Log; … … 37 44 * @basedOnCodeFrom Curtis Rueden ctrueden at wisc.edu 38 45 */ 39 public class LoginHandler 46 public class LoginHandler implements PropertyChangeListener 40 47 { 48 49 public JFrame f; 50 41 51 private boolean center; 52 53 private boolean modal; 42 54 43 55 private String username; … … 58 70 59 71 private OMEROMetadataStore store; 60 61 LoginHandler(Main viewer, boolean center) 62 { 72 73 public LoginDialog dialog; 74 75 LoginHandler(Main viewer, boolean modal, boolean center) 76 { 77 this.viewer = viewer; 78 this.modal = modal; 63 79 this.center = center; 64 tryLogin(viewer); 65 viewer.setVisible(true); 66 } 67 68 public void tryLogin(Main v) 69 { 70 this.viewer = v; 80 71 81 viewer.enableMenus(false); 72 73 // Display the initial login dialog 74 boolean cancelled = displayLoginDialog(viewer); 75 if (cancelled == true) 76 { 77 viewer.loggedIn = false; 78 viewer.enableMenus(true); 79 return; 80 } 81 82 boolean cancelled = displayLoginDialog(viewer, modal); 83 84 if (modal == true && cancelled == true) 85 { 86 loginCancelled(); 87 } 88 89 if (modal == true && cancelled == false) 90 { 91 tryLogin(); 92 } 93 94 } 95 96 public void tryLogin() 97 { 98 username = dialog.username; 99 password = dialog.password; 100 server = dialog.currentServer; 101 port = dialog.port; 102 dialog.updateServerList(server); 103 104 userPrefs.put("username", username); 105 // userPrefs.put("password", password); // save the password 106 userPrefs.put("server", server); 107 userPrefs.put("port", port); 108 82 109 viewer.statusBar.setStatusIcon("gfx/server_trying16.png", 83 110 "Trying to connect."); … … 88 115 viewer.statusBar.setStatusIcon("gfx/error_msg16.png", 89 116 "Incorrect username/password. Server login failed, please try to " 90 + "log in again.");117 + "log in again."); 91 118 92 119 JOptionPane.showMessageDialog(viewer, 93 120 "Incorrect username/password. Server login \nfailed, please " 94 + "try to log in again.");121 + "try to log in again."); 95 122 viewer.appendToOutput("> Login failed. Try to relog.\n"); 96 123 viewer.enableMenus(true); … … 106 133 107 134 viewer.statusBar.setStatusIcon("gfx/error_msg16.png", 108 "Server connection failure. Please try to login again.");135 "Server connection failure. Please try to login again."); 109 136 110 137 JOptionPane 111 .showMessageDialog(112 viewer,113 "The application failed to log in. The server "114 + "\nhostname or port may be wrong or the server "115 + "\nmay be offline.\n\nPlease try again.");138 .showMessageDialog( 139 viewer, 140 "The application failed to log in. The server " 141 + "\nhostname or port may be wrong or the server " 142 + "\nmay be offline.\n\nPlease try again."); 116 143 viewer.appendToOutput("> Login failed. Try to relog.\n"); 117 144 viewer.enableMenus(true); … … 120 147 } 121 148 149 SplashWindow.disposeSplash(); 150 viewer.setVisible(true); 151 122 152 viewer.appendToOutput("> Login Successful.\n"); 123 153 viewer.enableMenus(true); … … 125 155 viewer.loggedIn = true; 126 156 viewer.statusBar.setStatusIcon("gfx/server_connect16.png", 127 "Server connected."); 128 129 } 130 131 private boolean displayLoginDialog(Main viewer) 132 { 133 LoginDialog dialog = new LoginDialog(viewer, "Login", true, center); 157 "Server connected."); 158 } 159 160 void loginCancelled() { 161 viewer.loggedIn = false; 162 viewer.enableMenus(true); 163 SplashWindow.disposeSplash(); 164 viewer.setVisible(true); 165 } 166 167 private boolean displayLoginDialog(Main viewer, boolean modal) 168 { 169 if (modal == true) 170 { 171 dialog = new LoginDialog(viewer, viewer, "Login", modal, center); 172 dialog.setAlwaysOnTop(true); 173 } else { 174 175 f = new JFrame(); 176 f.setTitle("Login"); 177 f.setIconImage(getImageIcon(Main.ICON).getImage()); 178 f.setUndecorated(true); 179 f.setSize(0,0); 180 f.setVisible(true); 181 182 dialog = new LoginDialog(f, viewer, "Login", modal, center); 183 dialog.addPropertyChangeListener(this); 184 185 f.addWindowFocusListener(new WindowFocusListener() { 186 public void windowGainedFocus(WindowEvent e) 187 { 188 try { 189 dialog.toFront(); 190 } catch (NullPointerException ex) {} 191 } 192 193 public void windowLostFocus(WindowEvent e) {} 194 }); 195 196 } 197 198 134 199 if (dialog.cancelled == true) return true; 135 200 136 username = dialog.username;137 password = dialog.password;138 server = dialog.currentServer;139 port = dialog.port;140 dialog.updateServerList(server);141 142 userPrefs.put("username", username);143 // userPrefs.put("password", password); // save the password144 userPrefs.put("server", server);145 userPrefs.put("port", port);146 147 201 return false; 148 202 } … … 167 221 return store; 168 222 } 223 224 private ImageIcon getImageIcon(String path) 225 { 226 java.net.URL imgURL = Main.class.getResource(path); 227 if (imgURL != null) { return new ImageIcon(imgURL); } 228 else { System.err.println("Couldn't find icon: " + imgURL); } 229 return null; 230 } 231 232 public void propertyChange(PropertyChangeEvent ev) 233 { 234 String prop = ev.getPropertyName(); 235 if (prop.equals(Actions.LOGIN)) 236 { 237 tryLogin(); 238 f.dispose(); 239 } 240 if (prop.equals(Actions.LOGIN_CANCELLED)) 241 { 242 loginCancelled(); 243 f.dispose(); 244 } 245 } 246 169 247 } -
branches/3.0-Beta1/components/bioformats-omero/src/ome/formats/importer/Main.java
r1277 r1295 25 25 import java.awt.event.WindowEvent; 26 26 import java.awt.event.WindowListener; 27 import java.lang.reflect.InvocationTargetException; 28 27 28 import javax.swing.ImageIcon; 29 29 import javax.swing.JFrame; 30 30 import javax.swing.JMenu; … … 36 36 import javax.swing.JTabbedPane; 37 37 import javax.swing.JTextPane; 38 import javax.swing.SwingUtilities;39 38 import javax.swing.UIManager; 40 39 import javax.swing.text.BadLocationException; … … 56 55 /** The data of the last release date. */ 57 56 public static String releaseDate 58 = "200 6-12-20 11:36:25 +0000 (Wed, 20 Dec 2006)";57 = "2007-02-13 14:51:59 +0000 (Tue, 13 Feb 2007)"; 59 58 60 59 /** The repository revision. */ … … 73 72 // -- Constants -- 74 73 75 p rivate final static String TITLE = "OMERO Importer";74 public final static String TITLE = "OMERO.importer"; 76 75 public final static String splash = "gfx/importer_splash.png"; 77 76 private final static boolean useSplashScreenAbout = false; … … 79 78 private final static int width = 980; 80 79 private final static int height = 580; 80 81 public static final String ICON = "gfx/icon.png"; 81 82 82 83 public LoginHandler loginHandler; … … 122 123 setLocationRelativeTo(null); 123 124 addWindowListener(this); 125 126 setTitle(TITLE); 127 setIconImage(getImageIcon(Main.ICON).getImage()); 124 128 125 129 // menu bar … … 235 239 appendToOutputLn("> Release date: " + releaseDate); 236 240 237 loginHandler = new LoginHandler(this, false );241 loginHandler = new LoginHandler(this, false, false); 238 242 } 239 243 … … 305 309 } else 306 310 { 307 loginHandler = new LoginHandler(this, true );311 loginHandler = new LoginHandler(this, true, true); 308 312 //store = loginHandler.getMetadataStore(); 309 313 //loginHandler.tryLogin(this); … … 431 435 public void windowOpened(WindowEvent e) {} 432 436 437 438 private ImageIcon getImageIcon(String path) 439 { 440 java.net.URL imgURL = Main.class.getResource(path); 441 if (imgURL != null) { return new ImageIcon(imgURL); } 442 else { System.err.println("Couldn't find icon: " + imgURL); } 443 return null; 444 } 445 433 446 /** 434 447 * @param args Start up the application, display the main window and the … … 459 472 UIManager.setLookAndFeel(laf); 460 473 } catch (Exception e) 461 { System.err.println(laf + " not supported."); } 462 } 463 464 try { 465 SwingUtilities.invokeAndWait(new Runnable() { 466 public void run() { 467 new Main(); 468 } 469 }); 470 } catch (InterruptedException e) { 471 // Ignore: If this exception occurs, we return too early, which 472 // makes the splash window go away too early. 473 // Nothing to worry about. Maybe we should write a log message. 474 } catch (InvocationTargetException e) { 475 // Error: Startup has failed badly. 476 // We can not continue running our application. 477 InternalError error = new InternalError(); 478 error.initCause(e); 479 throw error; 480 } 474 { System.err.println(laf + " not supported."); } 475 } 476 new Main(); 477 } 478 479 public static Main returnMain(String[] args) 480 { 481 482 String laf = UIManager.getSystemLookAndFeelClassName() ; 483 484 //laf = "ch.randelshofer.quaqua.QuaquaLookAndFeel"; 485 //laf = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; 486 //laf = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"; 487 //laf = "com.sun.java.swing.plaf.motif.MotifLookAndFeel"; 488 //laf = "javax.swing.plaf.metal.MetalLookAndFeel"; 489 490 if (laf.equals("apple.laf.AquaLookAndFeel")) 491 { 492
