Hi Thomas, If you use this notation
NewVersionCheck NVC = new NewVersionCheck(NewVersionCheck.CheckType.MENU); then you don't need to import NewVersionCheck.CheckType. But if you want to use CheckType directly, you need to import it. In Java, enum is a special type of class. If the enum is declared within the NewVersionCheck class, it becomes a kind of inner class and must be imported to be visible. Cheers, Tomas On Nov 19, 2014, at 16:27, TFRD (Thomas Franck Dyrlund) <t...@steno.dk> wrote: > Thanks for all your help and explanation! I have committed an update - r3477. > > Can you please explain why I now have to import: > import net.sf.mzmine.main.NewVersionCheck.CheckType; > > And not only: > import net.sf.mzmine.main.NewVersionCheck; > > When I want to call the version check: > NewVersionCheck NVC = new NewVersionCheck(CheckType.MENU); > > I was expecting that the CheckType enum values would be available just by > importing the NewVersionCheck class. > > Please let me know if you have any other comments to the updated version > check. > > Cheers, > > Thomas > > From: Tomas Pluskal [mailto:plus...@oist.jp] > Sent: 19. november 2014 01:34 > To: Developer discussion > Subject: Re: [Mzmine-devel] MZmine version url > > Hi Thomas, > > You can define e.g. > > public enum CheckType { DESKTOP, MENU}; > > then you define your constructor > > public NewVersionCheck(CheckType type) { ... > > then you make a new class > > NewVersionCheck check = new NewVersionCheck(CheckType.DESKTOP); > > Note the naming conventions (enum values are usually capitialized). > > About your question: yes, you will need to use something like info = val, > because the class needs to remember its state. > > Cheers, > > Tomas > > > > > On Nov 18, 2014, at 18:14, TFRD (Thomas Franck Dyrlund) <t...@steno.dk> wrote: > > > Thanks for your reply and your help! > > I have changed so that the parameter is passed to the constructor: > NewVersionCheck NVC = new NewVersionCheck("menu"); > > Is this then the right way of making the class or can I make it in a way > where I don't have to use info = val? > public class NewVersionCheck implements Runnable { > String info; > public NewVersionCheck(String val) { > info = val; > } > > Also, I don't know the enum type but it seems to be a better solution based > on: > https://docs.oracle.com/javase/tutorial/java/javaOO/enum.html > > However, if I set the predefined constants using: > enum info {desktop, menu}; > > How do I then get the NewVersionCheck() class to set the value based on the > parameter passed to the constructor? > > /Thomas > > -----Original Message----- > From: Tomas Pluskal [mailto:plus...@oist.jp] > Sent: 18. november 2014 09:20 > To: Developer discussion > Subject: Re: [Mzmine-devel] MZmine version url > > I see, sorry for the confusion. > > The reason why it hangs is because you explicitly call the method > NVC.run("menu"). This line should be removed. > When you call Thread.start(), it will automatically call the run() method on > the newly created thread. > > You should remove the run(String info) method and move the actual code to the > run() method. > If you want to change the behavior of NewVersionCheck depending on situation, > you should pass a parameter to its constructor (not to the run() method). > > A few other comments: > - enum would be better than String for the info parameter > - comparing Strings using == operator does not necessarily do what you > expected, you should use .equals() > (seehttp://perso.ensta-paristech.fr/~diam/java/online/notes-java/data/expressions/22compareobjects.html) > - please copy the header (copyright info) to all new classes that you create > - please set your IDE to follow the Java formatting guidelines (if you're > using Eclipse, it's in Preferences -> Java -> Code Style -> Formatter -> > select Java Conventions as Active profile. > - when handling exceptions, please do not consume the exception completely > (without reporting its error message). As a minimum effort, you can call > e.printStackTrace() when exception occurs. > > Cheers, > > Tomas > > > On Nov 18, 2014, at 17:05, TFRD (Thomas Franck Dyrlund) <t...@steno.dk> wrote: > > > There should have been a patch file in the email. Anyway, I have committed > the changes: r3476. > > The new implementation uses a new thread for the version check in the > MainMenu also, however it still makes the GUI hang: > if (src == checkUpdate) { // Check for updated version > NewVersionCheck NVC = new NewVersionCheck(); > new Thread(NVC).start(); > NVC.run("menu"); > } > > /Thomas > > -----Original Message----- > From: Tomas Pluskal [mailto:plus...@oist.jp] > Sent: 18. november 2014 01:40 > To: Developer discussion > Subject: Re: [Mzmine-devel] MZmine version url > > Hi Thomas, > > You have to commit the changes to the SVN first, otherwise I cannot > comment on them :) > > As for the version check in MainMenu.java - the problem is the same as in the > MZmineCore. Menus are activated by GUI events (e.g. user clicking the mouse > button), therefore handled on the Swing thread. As long as the event is being > processed, no other GUI activity can happen, that's why MZmine freezes > (actually, the GUI freezes, other threads are still running). You have to > move the check to another thread (make a new Runnable class for it). > For more reading about the subject, check here: > http://www.javaworld.com/article/2077754/core-java/swing-threading-and > -the-event-dispatch-thread.html?page=3#resources > > By the way, please use MZmineCore.getDesktop().displayMessage() instead of > JOptionPane.showMessageDialog(). Thanks! > > Cheers, > > Tomas > > > On Nov 17, 2014, at 22:36, TFRD (Thomas Franck Dyrlund) <t...@steno.dk> wrote: > > > You are right, I hadn't realised that it halts the main thread :( I have now > moved it to a separate class: NewVersionCheck under net.sf.mzmine.main - I'm > not sure if this is the right place for the class. Please let me know if you > want it somewhere else. > > Also, the change solved the problem when opening MZmine. However, MZmine > still halts when running the check update through the help menu and I have no > idea why. Can you see what I'm doing wrong? > > Best, > > Thomas > > -----Original Message----- > From: Tomas Pluskal [mailto:plus...@oist.jp] > Sent: 13. november 2014 04:32 > To: Developer discussion > Subject: Re: [Mzmine-devel] MZmine version url > > Hi Thomas, > > I have a comment to the version check in MZmineCore that you implemented. The > implementation has one problem - it runs on the main thread. It will cause a > long timeout on MZmine start If the target URL > (http://mzmine.sourceforge.net/version.txt) is not accessible due to network > problem, sf.net downtime, firewall settings, etc. > Can you move the check to a separate class (e.g. NewerVersionCheck.java) that > implements Runnable, and simply create a new Thread for it in MZmineCore? > > Best regards, > > Tomas > > > On Oct 27, 2014, at 12:31, Tomáš Pluskal <plus...@oist.jp> wrote: > > > Hi Thomas, > > Good idea. I added the version file: > http://mzmine.sourceforge.net/version.txt > > I think it is useful to check the version at startup and let the user know if > a new version is available. However, please make sure the announcement of the > new version is not annoying for the user (i.e. does not require a specific > action like clicking on a button). > > By the way, I also added your name to the list of developers at the > website: http://mzmine.sourceforge.net/development.shtml > > Cheers, > > Tomas > > > > On Oct 24, 2014, at 23:27, TFRD (Thomas Franck Dyrlund) <t...@steno.dk> wrote: > > > Hi Tomas > > Can you please add a page on the MZmine 2 webpage, e.g. > http://mzmine.sourceforge.net/version.html or version.txt > > Which only has the latest version on the page, e.g. > 2.11 > > I want to use this to add an option to check for an updated version of MZmine > in the help menu and possibly also at start-up of MZmine. Please let me know > if anyone does not think it is a good idea to check for updates at start up. > > /Thomas > > ____________________________ > > Thomas F. Dyrlund > Post Doctoral Researcher > Research, Systems Medicine > > Steno Diabetes Center A/S > Niels Steensens Vej 2-4 > DK-2820 Gentofte > Denmark > +45 3968 0800 (phone) > +45 3079 9290 (mobile) > t...@steno.dk > > This e-mail (including any attachments) is intended for the addressee(s) > stated above only and may contain confidential information protected by law. > You are hereby notified that any unauthorized reading, disclosure, copying or > distribution of this e-mail or use of information contained herein is > strictly prohibited and may violate rights to proprietary information. If you > are not an intended recipient, please return this e-mail to the sender and > delete it immediately hereafter. Thank you. > ------------------------------------------------------------------- > - > - > --------- _______________________________________________ > Mzmine-devel mailing list > Mzmine-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mzmine-devel > > =============================================== > Tomas Pluskal > G0 Cell Unit, Okinawa Institute of Science and Technology Graduate > University > 1919-1 Tancha, Onna-son, Okinawa 904-0495, Japan > WWW: https://groups.oist.jp/g0 > TEL: +81-98-966-8684 > Fax: +81-98-966-2890 > > > =============================================== > Tomas Pluskal > G0 Cell Unit, Okinawa Institute of Science and Technology Graduate > University > 1919-1 Tancha, Onna-son, Okinawa 904-0495, Japan > WWW: https://groups.oist.jp/g0 > TEL: +81-98-966-8684 > Fax: +81-98-966-2890 > > > --------------------------------------------------------------------- > - > -------- Comprehensive Server Monitoring with Site24x7. > Monitor 10 servers for $9/Month. > Get alerted through email, SMS, voice calls or mobile push notifications. > Take corrective actions from your mobile device. > http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg. > clktrk _______________________________________________ > Mzmine-devel mailing list > Mzmine-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mzmine-devel > <MZmine > 2.patch>------------------------------------------------------------- > - > ---------------- Download BIRT iHub F-Type - The Free > Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your > Business Reports and Dashboards with Interactivity, Sharing, Native > Excel Exports, App Integration & more Get technology previously > reserved for billion-dollar corporations, FREE > http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg. > clktrk_______________________________________________ > Mzmine-devel mailing list > Mzmine-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mzmine-devel > > =============================================== > Tomas Pluskal > G0 Cell Unit, Okinawa Institute of Science and Technology Graduate > University > 1919-1 Tancha, Onna-son, Okinawa 904-0495, Japan > WWW: https://groups.oist.jp/g0 > TEL: +81-98-966-8684 > Fax: +81-98-966-2890 > > > ---------------------------------------------------------------------- > -------- Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT > Server from Actuate! Instantly Supercharge Your Business Reports and > Dashboards with Interactivity, Sharing, Native Excel Exports, App > Integration & more Get technology previously reserved for > billion-dollar corporations, FREE > http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg. > clktrk _______________________________________________ > Mzmine-devel mailing list > Mzmine-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mzmine-devel > > ---------------------------------------------------------------------- > -------- Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT > Server from Actuate! Instantly Supercharge Your Business Reports and > Dashboards with Interactivity, Sharing, Native Excel Exports, App > Integration & more Get technology previously reserved for > billion-dollar corporations, FREE > http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg. > clktrk _______________________________________________ > Mzmine-devel mailing list > Mzmine-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mzmine-devel > > =============================================== > Tomas Pluskal > G0 Cell Unit, Okinawa Institute of Science and Technology Graduate University > 1919-1 Tancha, Onna-son, Okinawa 904-0495, Japan > WWW: https://groups.oist.jp/g0 > TEL: +81-98-966-8684 > Fax: +81-98-966-2890 > > > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from > Actuate! Instantly Supercharge Your Business Reports and Dashboards with > Interactivity, Sharing, Native Excel Exports, App Integration & more Get > technology previously reserved for billion-dollar corporations, FREE > http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk > _______________________________________________ > Mzmine-devel mailing list > Mzmine-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mzmine-devel > > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & more > Get technology previously reserved for billion-dollar corporations, FREE > http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk > _______________________________________________ > Mzmine-devel mailing list > Mzmine-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mzmine-devel > > =============================================== > Tomas Pluskal > G0 Cell Unit, Okinawa Institute of Science and Technology Graduate University > 1919-1 Tancha, Onna-son, Okinawa 904-0495, Japan > WWW: https://groups.oist.jp/g0 > TEL: +81-98-966-8684 > Fax: +81-98-966-2890 > > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & more > Get technology previously reserved for billion-dollar corporations, FREE > http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk_______________________________________________ > Mzmine-devel mailing list > Mzmine-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mzmine-devel =============================================== Tomas Pluskal G0 Cell Unit, Okinawa Institute of Science and Technology Graduate University 1919-1 Tancha, Onna-son, Okinawa 904-0495, Japan WWW: https://groups.oist.jp/g0 TEL: +81-98-966-8684 Fax: +81-98-966-2890 ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk _______________________________________________ Mzmine-devel mailing list Mzmine-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mzmine-devel