• Views
  • Iteration Report
  • My Iteration Report
  •  
OMERO.server
  • Login
  • Help/Guide
  • About Trac
  • Preferences
  • Wiki
  • Timeline
  • Roadmap
  • Browse Source
  • View Tickets
  • Search

Context Navigation

  • ← Previous Change
  • Next Change →

Changeset 1295 for branches/3.0-Beta1/components/bioformats-omero

Show
Ignore:
Timestamp:
02/28/07 11:02:43 (21 months ago)
Author:
TheBrain
Message:

Fixes a number of bugs:

  • off by one errors
  • modal dialog box problems with the login
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  
    214214    { 
    215215        table.setValueAt("archiving", row, 2); 
     216    } 
     217     
     218    public void setProgressFailed(int index) 
     219    { 
     220        table.setValueAt("failed", row, 2); 
    216221    } 
    217222     
  • branches/3.0-Beta1/components/bioformats-omero/src/ome/formats/importer/ImportDialog.java

    r1196 r1295  
    104104    ImportDialog(JFrame owner, String title, boolean modal, OMEROMetadataStore store) 
    105105    { 
     106        super(); 
    106107        this.store = store; 
    107108         
    … …  
    171172        archiveImage = addCheckBox(this, "Also archive the original image file(s)", c); 
    172173        archiveImage.setSelected(false); 
    173         archiveImage.setVisible(false); 
     174        archiveImage.setVisible(true); 
    174175         
    175176        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  
    1717import java.io.File; 
    1818import java.io.IOException; 
     19import java.io.PrintWriter; 
     20import java.io.StringWriter; 
    1921import java.text.SimpleDateFormat; 
    2022import java.util.Date; 
    … …  
    213215        qTable.setProgressInfo(index, count); 
    214216         
     217        try { 
    215218        //viewer.appendToOutput("> Importing plane: "); 
    216219        library.importData(pixId, fileName, new ImportLibrary.Step() 
    … …  
    227230        }); 
    228231 
     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         
    229248        viewer.appendToOutputLn("> Successfully stored with pixels id \"" 
    230249                + pixId + "\"."); 
  • branches/3.0-Beta1/components/bioformats-omero/src/ome/formats/importer/ImportLibrary.java

    r1205 r1295  
    2727import loci.formats.IFormatReader; 
    2828import loci.formats.ReaderWrapper; 
    29 import loci.formats.TiffTools; 
    3029import loci.formats.in.Bits; 
    3130import ome.conditions.ApiUsageException; 
    … …  
    240239     * completed. 
    241240     */ 
    242     public void importData(long pixId, String fileName, Step step) 
     241    public void importData(long pixId, String fileName, Step step)  
     242        throws FormatException, IOException 
    243243    { 
    244244        int i = 1; 
    245         try { 
    246245            int bytesPerPixel = getBytesPerPixel(reader.getPixelType(fileName)); 
    247246            byte[] buffer = null; 
    … …  
    270269                } 
    271270            } 
    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         } 
    287271    } 
    288272     
  • branches/3.0-Beta1/components/bioformats-omero/src/ome/formats/importer/LoginDialog.java

    r1204 r1295  
    1616import java.awt.Color; 
    1717import java.awt.Dimension; 
     18import java.awt.Frame; 
    1819import java.awt.Insets; 
    1920import java.util.ArrayList; 
    … …  
    2425import java.awt.event.WindowAdapter; 
    2526import java.awt.event.WindowEvent; 
     27import java.awt.event.WindowFocusListener; 
    2628import java.beans.PropertyChangeEvent; 
    2729import java.beans.PropertyChangeListener; 
    … …  
    4446import javax.swing.text.StyleContext; 
    4547 
     48import ome.formats.importer.util.Actions; 
    4649import ome.formats.importer.util.GuiCommonElements; 
    4750 
    … …  
    5255{ 
    5356    boolean debug = false; 
     57 
     58    JFrame                  main; 
    5459     
    5560    GuiCommonElements       gui; 
    … …  
    98103                                             .userNodeForPackage(LoginDialog.class); 
    99104     
    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         
    102110        ImageIcon top = getImageIcon(Main.splash); 
    103111        String laf = UIManager.getLookAndFeel().toString(); 
    … …  
    107115        setModal(modal); 
    108116        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        //} 
    109122        setSize(new Dimension(loginWidth, loginHeight)); 
    110         setLocationRelativeTo(owner); 
     123        setLocationRelativeTo(main); 
    111124        //get the amount to offset the login by 
    112125        if (!center) 
    … …  
    118131                 
    119132        // 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         
    121137        // 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         
    124141        serverList = getServerList(); 
    125142         
    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"; 
    128146                 
    129147        gui = new GuiCommonElements(); 
    … …  
    224242            } 
    225243        }); 
    226  
     244         
    227245        // Add the tab panel to the main panel 
    228246        mainPanel.add(topPanel, "0, 0, 3, 0"); 
    … …  
    327345            //port = prt.getText(); 
    328346            cancelled = false; 
     347            firePropertyChange(Actions.LOGIN, false, true); 
    329348            this.dispose(); 
    330349        } 
    … …  
    332351        { 
    333352            cancelled = true; 
     353            firePropertyChange(Actions.LOGIN_CANCELLED, false, true); 
    334354            this.dispose(); 
    335355        } 
    … …  
    403423         
    404424        JFrame f = new JFrame();    
    405         LoginDialog loginDialog = new LoginDialog(f, "", false, true);  
     425        LoginDialog loginDialog = new LoginDialog(f, f, "", false, true);  
    406426        f.setVisible(false); 
    407427        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
  • branches/3.0-Beta1/components/bioformats-omero/src/ome/formats/importer/LoginHandler.java

    r1204 r1295  
    1414package ome.formats.importer; 
    1515 
     16import java.awt.event.WindowEvent; 
     17import java.awt.event.WindowFocusListener; 
     18import java.beans.PropertyChangeEvent; 
     19import java.beans.PropertyChangeListener; 
    1620import java.io.PrintWriter; 
    1721import java.io.StringWriter; 
    … …  
    1923 
    2024import javax.ejb.EJBAccessException; 
     25import javax.swing.ImageIcon; 
     26import javax.swing.JFrame; 
    2127import javax.swing.JOptionPane; 
    2228 
    2329import ome.formats.OMEROMetadataStore; 
     30import ome.formats.importer.util.Actions; 
    2431 
    2532import org.apache.commons.logging.Log; 
    … …  
    3744 * @basedOnCodeFrom Curtis Rueden ctrueden at wisc.edu 
    3845 */ 
    39 public class LoginHandler 
     46public class LoginHandler implements PropertyChangeListener 
    4047{ 
     48     
     49    public JFrame              f; 
     50     
    4151    private boolean            center; 
     52     
     53    private boolean            modal; 
    4254     
    4355    private String             username; 
    … …  
    5870 
    5971    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; 
    6379        this.center = center; 
    64         tryLogin(viewer); 
    65         viewer.setVisible(true); 
    66     } 
    67  
    68     public void tryLogin(Main v) 
    69     { 
    70         this.viewer = v; 
     80         
    7181        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         
    82109        viewer.statusBar.setStatusIcon("gfx/server_trying16.png", 
    83110        "Trying to connect."); 
    … …  
    88115                viewer.statusBar.setStatusIcon("gfx/error_msg16.png", 
    89116                        "Incorrect username/password. Server login failed, please try to " 
    90                                 + "log in again."); 
     117                        + "log in again."); 
    91118 
    92119                JOptionPane.showMessageDialog(viewer, 
    93120                        "Incorrect username/password. Server login \nfailed, please " 
    94                                 + "try to log in again."); 
     121                        + "try to log in again."); 
    95122                viewer.appendToOutput("> Login failed. Try to relog.\n"); 
    96123                viewer.enableMenus(true); 
    … …  
    106133 
    107134            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."); 
    109136 
    110137            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."); 
    116143            viewer.appendToOutput("> Login failed. Try to relog.\n"); 
    117144            viewer.enableMenus(true); 
    … …  
    120147        } 
    121148 
     149        SplashWindow.disposeSplash(); 
     150        viewer.setVisible(true); 
     151         
    122152        viewer.appendToOutput("> Login Successful.\n"); 
    123153        viewer.enableMenus(true); 
    … …  
    125155        viewer.loggedIn = true; 
    126156        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 
    134199        if (dialog.cancelled == true) return true; 
    135200 
    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 password 
    144         userPrefs.put("server", server); 
    145         userPrefs.put("port", port); 
    146          
    147201        return false; 
    148202    } 
    … …  
    167221        return store; 
    168222    } 
     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     
    169247} 
  • branches/3.0-Beta1/components/bioformats-omero/src/ome/formats/importer/Main.java

    r1277 r1295  
    2525import java.awt.event.WindowEvent; 
    2626import java.awt.event.WindowListener; 
    27 import java.lang.reflect.InvocationTargetException; 
    28  
     27 
     28import javax.swing.ImageIcon; 
    2929import javax.swing.JFrame; 
    3030import javax.swing.JMenu; 
    … …  
    3636import javax.swing.JTabbedPane; 
    3737import javax.swing.JTextPane; 
    38 import javax.swing.SwingUtilities; 
    3938import javax.swing.UIManager; 
    4039import javax.swing.text.BadLocationException; 
    … …  
    5655    /** The data of the last release date. */ 
    5756    public static String        releaseDate       
    58          = "2006-12-20 11:36:25 +0000 (Wed, 20 Dec 2006)"; 
     57         = "2007-02-13 14:51:59 +0000 (Tue, 13 Feb 2007)"; 
    5958 
    6059    /** The repository revision. */ 
    … …  
    7372    // -- Constants -- 
    7473 
    75     private final static String TITLE            = "OMERO Importer"; 
     74    public final static String TITLE            = "OMERO.importer"; 
    7675    public final static String splash           = "gfx/importer_splash.png"; 
    7776    private final static boolean useSplashScreenAbout   = false; 
    … …  
    7978    private final static int width = 980; 
    8079    private final static int height = 580; 
     80 
     81    public static final String ICON = "gfx/icon.png"; 
    8182     
    8283    public LoginHandler        loginHandler; 
    … …  
    122123        setLocationRelativeTo(null); 
    123124        addWindowListener(this); 
     125         
     126        setTitle(TITLE); 
     127        setIconImage(getImageIcon(Main.ICON).getImage()); 
    124128 
    125129        // menu bar 
    … …  
    235239        appendToOutputLn("> Release date: " + releaseDate); 
    236240         
    237         loginHandler = new LoginHandler(this, false); 
     241        loginHandler = new LoginHandler(this, false, false); 
    238242    } 
    239243 
    … …  
    305309            } else  
    306310            {                 
    307                 loginHandler = new LoginHandler(this, true); 
     311                loginHandler = new LoginHandler(this, true, true); 
    308312                //store = loginHandler.getMetadataStore(); 
    309313                //loginHandler.tryLogin(this); 
    … …  
    431435    public void windowOpened(WindowEvent e) {} 
    432436 
     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     
    433446    /** 
    434447     * @param args Start up the application, display the main window and the 
    … …  
    459472                UIManager.setLookAndFeel(laf); 
    460473            } 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