package org.forester.archaeopteryx;
+import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Font;
JMenuItem _phyloxml_website_item;
JMenuItem _phyloxml_ref_item;
JMenuItem _aptx_ref_item;
+ // process menu:
+ JMenu _process_menu;
// Handy pointers to child components:
MainPanel _mainpanel;
Container _contentpane;
_jmenubar.add( _help_jmenu );
}
+ public void updateProcessMenu() {
+ System.out.println( "pool size " + _process_pool.size() );
+ if ( _process_pool.size() > 0 ) {
+ if ( _process_menu == null ) {
+ _process_menu = createMenu( "", getConfiguration() );
+ _process_menu.setForeground( Color.RED );
+ }
+ final String text = "processes running: " + _process_pool.size();
+ _process_menu.setText( text );
+ _jmenubar.add( _process_menu );
+ }
+ else {
+ if ( _process_menu != null ) {
+ _jmenubar.remove( _process_menu );
+ }
+ }
+ _jmenubar.validate();
+ _jmenubar.repaint();
+ repaint();
+ // _help_jmenu.add( _help_item = new JMenuItem( "Help" ) );
+ // _help_jmenu.add( _website_item = new JMenuItem( "Archaeopteryx Home" ) );
+ // _aptx_ref_item = new JMenuItem( "Archaeopteryx Reference" );
+ // _help_jmenu.add( _phyloxml_website_item = new JMenuItem( "phyloXML Home" ) );
+ // _help_jmenu.add( _phyloxml_ref_item = new JMenuItem( "phyloXML Reference" ) );
+ // _help_jmenu.addSeparator();
+ // _help_jmenu.add( _about_item = new JMenuItem( "About" ) );
+ // customizeJMenuItem( _help_item );
+ // customizeJMenuItem( _website_item );
+ // customizeJMenuItem( _phyloxml_website_item );
+ // customizeJMenuItem( _aptx_ref_item );
+ // customizeJMenuItem( _phyloxml_ref_item );
+ // customizeJMenuItem( _about_item );
+ // _phyloxml_ref_item.setToolTipText( PHYLOXML_REF_TOOL_TIP );
+ // _aptx_ref_item.setToolTipText( APTX_REF_TOOL_TIP );
+ // _jmenubar.add( _help_jmenu );
+ }
+
void buildTypeMenu() {
_type_menu = createMenu( TYPE_MENU_HEADER, getConfiguration() );
_type_menu.add( _rectangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.RECTANGULAR_TYPE_CBMI_LABEL ) );
return _label_direction_cbmi;
}
- MainPanel getMainPanel() {
+ public MainPanel getMainPanel() {
return _mainpanel;
}
}
@Override
- MainPanel getMainPanel() {
+ public MainPanel getMainPanel() {
return _mainpanel;
}
import org.forester.analysis.AncestralTaxonomyInference;
import org.forester.analysis.AncestralTaxonomyInferenceException;
-import org.forester.archaeopteryx.Constants;
import org.forester.archaeopteryx.MainFrameApplication;
import org.forester.archaeopteryx.TreePanel;
import org.forester.phylogeny.Phylogeny;
-import org.forester.util.ForesterUtil;
import org.forester.ws.uniprot.UniProtWsTools;
-public class AncestralTaxonomyInferrer implements Runnable {
+public class AncestralTaxonomyInferrer extends RunnableProcess {
private final Phylogeny _phy;
private final MainFrameApplication _mf;
private final TreePanel _treepanel;
- private long _process_id;
-
- private long getProcessId() {
- return _process_id;
- }
-
- private void setProcessId( final long process_id ) {
- _process_id = process_id;
- }
public AncestralTaxonomyInferrer( final MainFrameApplication mf, final TreePanel treepanel, final Phylogeny phy ) {
_phy = phy;
return UniProtWsTools.BASE_URL;
}
- private void start() {
- _mf.getMainPanel().getCurrentTreePanel().setWaitCursor();
- setProcessId( _mf.getProcessPool().addProcess( "ancestral taxonomy" ) );
- }
-
- private void end() {
- final boolean removed = _mf.getProcessPool().removeProcess( getProcessId() );
- if ( !removed ) {
- ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not remove process " + getProcessId()
- + " from process pool" );
- }
- _mf.getMainPanel().getCurrentTreePanel().setArrowCursor();
- }
-
private void inferTaxonomies() {
- start();
+ start( _mf, "ancestral taxonomy" );
try {
AncestralTaxonomyInference.inferTaxonomyFromDescendents( _phy );
}
catch ( final AncestralTaxonomyInferenceException e ) {
- end();
+ end( _mf );
JOptionPane.showMessageDialog( _mf,
e.getMessage(),
"Error during ancestral taxonomy inference",
return;
}
catch ( final UnknownHostException e ) {
- end();
+ end( _mf );
JOptionPane.showMessageDialog( _mf,
"Could not connect to \"" + getBaseUrl() + "\"",
"Network error during ancestral taxonomy inference",
return;
}
catch ( final Exception e ) {
- end();
+ end( _mf );
e.printStackTrace();
JOptionPane.showMessageDialog( _mf,
e.toString(),
return;
}
catch ( final Error e ) {
- end();
- e.printStackTrace();
+ end( _mf );
JOptionPane.showMessageDialog( _mf,
e.toString(),
"Unexpected error during ancestral taxonomy inference",
_treepanel.setTree( _phy );
_mf.showWhole();
_treepanel.setEdited( true );
- end();
+ end( _mf );
try {
JOptionPane.showMessageDialog( _mf,
"Ancestral taxonomy inference successfully completed",
import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
import org.forester.util.ForesterUtil;
-public class GoAnnotation implements Runnable {
+public class GoAnnotation extends RunnableProcess {
private static final String SYMBOL = "Symbol";
private static final String ASPECT = "Aspect";
}
private void annotate() {
- _mf.getMainPanel().getCurrentTreePanel().setWaitCursor();
+ start( _mf, "GO annotate" );
for( final PhylogenyNodeIterator iter = _phy.iteratorPostorder(); iter.hasNext(); ) {
final PhylogenyNode node = iter.next();
if ( ( node.getNodeData().getSequences() != null ) && !node.getNodeData().getSequences().isEmpty() ) {
}
}
}
+ end( _mf );
_treepanel.repaint();
_treepanel.setEdited( true );
}
--- /dev/null
+
+package org.forester.archaeopteryx.tools;
+
+import org.forester.archaeopteryx.Constants;
+import org.forester.archaeopteryx.MainFrame;
+import org.forester.util.ForesterUtil;
+
+public abstract class RunnableProcess implements Runnable {
+
+ long _process_id;
+
+ long getProcessId() {
+ return _process_id;
+ }
+
+ void setProcessId( final long process_id ) {
+ _process_id = process_id;
+ }
+
+ void start( final MainFrame mf, final String name ) {
+ mf.getMainPanel().getCurrentTreePanel().setWaitCursor();
+ setProcessId( mf.getProcessPool().addProcess( name ) );
+ mf.updateProcessMenu();
+ }
+
+ void end( final MainFrame mf ) {
+ final boolean removed = mf.getProcessPool().removeProcess( getProcessId() );
+ if ( !removed ) {
+ ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not remove process " + getProcessId()
+ + " from process pool" );
+ }
+ mf.getMainPanel().getCurrentTreePanel().setArrowCursor();
+ mf.updateProcessMenu();
+ }
+}