From: kjvdheide Date: Sat, 10 Feb 2018 17:34:50 +0000 (+0100) Subject: JAL-2797 standalone and embedded implementations of AptxFrame X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=5f423b8eb56b1d2763dceaceef8309ed1246e51b;p=jalview.git JAL-2797 standalone and embedded implementations of AptxFrame --- diff --git a/forester/java/src/org/forester/archaeopteryx/EmbeddedFrame.java b/forester/java/src/org/forester/archaeopteryx/EmbeddedFrame.java index 3bfe3ec..a82b12f 100644 --- a/forester/java/src/org/forester/archaeopteryx/EmbeddedFrame.java +++ b/forester/java/src/org/forester/archaeopteryx/EmbeddedFrame.java @@ -1,90 +1,92 @@ package org.forester.archaeopteryx; +import java.awt.Component; +import java.awt.Container; import java.awt.event.ActionEvent; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; +import java.util.EventListener; import javax.swing.JInternalFrame; +import javax.swing.event.InternalFrameAdapter; +import javax.swing.event.InternalFrameEvent; +import javax.swing.event.InternalFrameListener; -import org.forester.archaeopteryx.tools.InferenceManager; -import org.forester.archaeopteryx.tools.ProcessPool; public class EmbeddedFrame extends JInternalFrame implements AptxFrame{ - - MainFrame aptx; - - public EmbeddedFrame(MainFrame aptxInstance) { - aptx = aptxInstance; - } - - @Override - public void actionPerformed( ActionEvent e ) { - aptx.actionPerformed( e ); - - } - - @Override - public Configuration getConfiguration() { - return aptx.getConfiguration(); - } + @Override - public String getCurrentExternalNodesDataBuffer() { - return aptx.getCurrentExternalNodesDataBuffer(); + public Container getThisFrame() { + return this; } @Override - public int getCurrentExternalNodesDataBufferChangeCounter() { - return aptx.getCurrentExternalNodesDataBufferChangeCounter(); + public void addFrameListener( FrameListener frameListener ) { + InternalFrameListener actualListener = new InternalFrameListener() { + + @Override + public void internalFrameActivated( InternalFrameEvent e ) { + frameListener.FrameActivated( ); + + } + + @Override + public void internalFrameClosed( InternalFrameEvent e ) { + frameListener.FrameClosed(); + + } + + @Override + public void internalFrameClosing( InternalFrameEvent e ) { + frameListener.FrameClosing(); + + } + + @Override + public void internalFrameDeactivated( InternalFrameEvent e ) { + frameListener.FrameDeactivated(); + + } + + @Override + public void internalFrameDeiconified( InternalFrameEvent e ) { + frameListener.FrameDeiconified(); + + } + + @Override + public void internalFrameIconified( InternalFrameEvent e ) { + frameListener.FrameIconified(); + + } + + @Override + public void internalFrameOpened( InternalFrameEvent e ) { + frameListener.FrameOpened(); + + } + + }; + this.addInternalFrameListener( actualListener ); + } @Override - public int getCurrentExternalNodesDataBufferLength() { - return aptx.getCurrentExternalNodesDataBufferLength(); - } - - @Override - public InferenceManager getInferenceManager() { - return aptx.getInferenceManager(); - } - - @Override - public MainPanel getMainPanel() { - return aptx.getMainPanel(); - } - - @Override - public Options getOptions() { - return aptx.getOptions(); + public void setLocationRelativeTo( Component component ) { + //is this actually equivalent? + this.setLocation( component.getX(), component.getY() ); + } - @Override - public ProcessPool getProcessPool() { - return aptx.getProcessPool(); - } - @Override - public void showTextFrame( String s, String title ) { - aptx.showTextFrame( s, title ); - - } + - @Override - public void showWhole() { - aptx.showWhole(); - - } + - @Override - public void updateProcessMenu() { - aptx.updateProcessMenu(); - - } + - @Override - public void activateSaveAllIfNeeded() { - aptx.activateSaveAllIfNeeded(); - - } } diff --git a/forester/java/src/org/forester/archaeopteryx/StandaloneFrame.java b/forester/java/src/org/forester/archaeopteryx/StandaloneFrame.java index b3654b9..b9150aa 100644 --- a/forester/java/src/org/forester/archaeopteryx/StandaloneFrame.java +++ b/forester/java/src/org/forester/archaeopteryx/StandaloneFrame.java @@ -1,89 +1,73 @@ package org.forester.archaeopteryx; +import java.awt.Component; +import java.awt.Container; import java.awt.event.ActionEvent; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; import javax.swing.JFrame; -import org.forester.archaeopteryx.tools.InferenceManager; -import org.forester.archaeopteryx.tools.ProcessPool; public class StandaloneFrame extends JFrame implements AptxFrame{ - MainFrame aptx; - - public StandaloneFrame(MainFrame aptxInstance) { - aptx = aptxInstance; - } - @Override - public void actionPerformed( ActionEvent e ) { - aptx.actionPerformed( e ); - + public Container getThisFrame() { + return this; } @Override - public Configuration getConfiguration() { - return aptx.getConfiguration(); - } - - @Override - public String getCurrentExternalNodesDataBuffer() { - return aptx.getCurrentExternalNodesDataBuffer(); - } - - @Override - public int getCurrentExternalNodesDataBufferChangeCounter() { - return aptx.getCurrentExternalNodesDataBufferChangeCounter(); - } - - @Override - public int getCurrentExternalNodesDataBufferLength() { - return aptx.getCurrentExternalNodesDataBufferLength(); - } - - @Override - public InferenceManager getInferenceManager() { - return aptx.getInferenceManager(); - } - - @Override - public MainPanel getMainPanel() { - return aptx.getMainPanel(); - } - - @Override - public Options getOptions() { - return aptx.getOptions(); - } - - @Override - public ProcessPool getProcessPool() { - return aptx.getProcessPool(); - } - - @Override - public void showTextFrame( String s, String title ) { - aptx.showTextFrame( s, title ); - - } - - @Override - public void showWhole() { - aptx.showWhole(); - - } - - @Override - public void updateProcessMenu() { - aptx.updateProcessMenu(); + public void addFrameListener( FrameListener frameListener ) { + WindowListener actualListener = new WindowListener() { + + @Override + public void windowActivated( WindowEvent e ) { + frameListener.FrameActivated(); + + } + + @Override + public void windowClosed( WindowEvent e ) { + frameListener.FrameClosed(); + + } + + @Override + public void windowClosing( WindowEvent e ) { + frameListener.FrameClosing(); + + } + + @Override + public void windowDeactivated( WindowEvent e ) { + frameListener.FrameDeactivated(); + + } + + @Override + public void windowDeiconified( WindowEvent e ) { + frameListener.FrameDeiconified(); + + } + + @Override + public void windowIconified( WindowEvent e ) { + frameListener.FrameIconified(); + + } + + @Override + public void windowOpened( WindowEvent e ) { + frameListener.FrameOpened(); + + } + + }; + this.addWindowListener( actualListener ); - } - - @Override - public void activateSaveAllIfNeeded() { - aptx.activateSaveAllIfNeeded(); } - + + }