import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
+import java.awt.Window;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.ClipboardOwner;
import java.awt.datatransfer.DataFlavor;
import java.io.File;
import java.io.FileOutputStream;
import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.net.URL;
import java.util.ArrayList;
import java.util.Hashtable;
this.delegate = delegate;
}
+ @Override
public void activateFrame(JInternalFrame f)
{
try
}
}
+ @Override
public void beginDraggingFrame(JComponent f)
{
delegate.beginDraggingFrame(f);
}
+ @Override
public void beginResizingFrame(JComponent f, int direction)
{
delegate.beginResizingFrame(f, direction);
}
+ @Override
public void closeFrame(JInternalFrame f)
{
delegate.closeFrame(f);
}
+ @Override
public void deactivateFrame(JInternalFrame f)
{
delegate.deactivateFrame(f);
}
+ @Override
public void deiconifyFrame(JInternalFrame f)
{
delegate.deiconifyFrame(f);
}
+ @Override
public void dragFrame(JComponent f, int newX, int newY)
{
if (newY < 0)
delegate.dragFrame(f, newX, newY);
}
+ @Override
public void endDraggingFrame(JComponent f)
{
delegate.endDraggingFrame(f);
}
+ @Override
public void endResizingFrame(JComponent f)
{
delegate.endResizingFrame(f);
}
+ @Override
public void iconifyFrame(JInternalFrame f)
{
delegate.iconifyFrame(f);
}
+ @Override
public void maximizeFrame(JInternalFrame f)
{
delegate.maximizeFrame(f);
}
+ @Override
public void minimizeFrame(JInternalFrame f)
{
delegate.minimizeFrame(f);
}
+ @Override
public void openFrame(JInternalFrame f)
{
delegate.openFrame(f);
delegate.resizeFrame(f, newX, newY, newWidth, newHeight);
}
+ @Override
public void setBoundsForFrame(JComponent f, int newX, int newY,
int newWidth, int newHeight)
{
this.addWindowListener(new WindowAdapter()
{
+ @Override
public void windowClosing(WindowEvent evt)
{
quit();
MouseAdapter ma;
this.addMouseListener(ma = new MouseAdapter()
{
+ @Override
public void mousePressed(MouseEvent evt)
{
- if (SwingUtilities.isRightMouseButton(evt))
+ if (evt.isPopupTrigger())
{
showPasteMenu(evt.getX(), evt.getY());
}
// Spawn a thread that shows the splashscreen
SwingUtilities.invokeLater(new Runnable()
{
+ @Override
public void run()
{
new SplashScreen();
// takes to open it later on.
new Thread(new Runnable()
{
+ @Override
public void run()
{
Cache.log.debug("Filechooser init thread started.");
// reselected again.
boolean refresh = true;
+ @Override
public void menuCanceled(MenuEvent e)
{
refresh = true;
}
+ @Override
public void menuDeselected(MenuEvent e)
{
refresh = true;
}
+ @Override
public void menuSelected(MenuEvent e)
{
if (refresh)
MessageManager.getString("label.paste_new_window"));
item.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent evt)
{
paste();
final JMenuItem menuItem = new JMenuItem(title);
frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
{
+ @Override
public void internalFrameActivated(
javax.swing.event.InternalFrameEvent evt)
{
}
+ @Override
public void internalFrameClosed(
javax.swing.event.InternalFrameEvent evt)
{
menuItem.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
try
}
}
+ @Override
public void lostOwnership(Clipboard clipboard, Transferable contents)
{
if (!internalCopy)
internalCopy = false;
}
+ @Override
public void dragEnter(DropTargetDragEvent evt)
{
}
+ @Override
public void dragExit(DropTargetEvent evt)
{
}
+ @Override
public void dragOver(DropTargetDragEvent evt)
{
}
* @param evt
* DOCUMENT ME!
*/
+ @Override
public void drop(DropTargetDropEvent evt)
{
boolean success = true;
{
new FileLoader().LoadFile(viewport, choice, FormatAdapter.FILE,
format);
- // viewport.setShowSequenceFeatures(JSONFile.isSeqFeaturesEnabled());
- // AlignFrame af = viewport.getAlignPanel().alignFrame;
- // if (af != null)
- // {
- // af.changeColour(JSONFile.getColourScheme());
- // af.setMenusForViewport();
- // }
}
else
{
// message.toString(), "About Jalview", JOptionPane.INFORMATION_MESSAGE);
new Thread(new Runnable()
{
+ @Override
public void run()
{
new SplashScreen(true);
new Thread(new Runnable()
{
+ @Override
public void run()
{
// TODO: refactor to Jalview desktop session controller action.
selectedFile.getParent());
new Thread(new Runnable()
{
+ @Override
public void run()
{
setProgressBar(
sessit.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
if (dsktp.v_client == null)
Thread rthr = new Thread(new Runnable()
{
+ @Override
public void run()
{
dsktp.v_client = new VamsasApplication(dsktp, mysesid);
return showMemoryUsage;
}
+ @Override
public void run()
{
df = java.text.NumberFormat.getNumberInstance();
groovyShell.setText(MessageManager.getString("label.groovy_console"));
groovyShell.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
groovyShell_actionPerformed();
*/
public void groovyShell_actionPerformed()
{
- // use reflection to avoid creating compilation dependency.
if (!jalview.bin.Cache.groovyJarsPresent())
{
throw new Error(
}
try
{
- Class<?> gcClass = Desktop.class.getClassLoader().loadClass(
- "groovy.ui.Console");
- Constructor<?> gccons = gcClass.getConstructor();
- java.lang.reflect.Method setvar = gcClass.getMethod("setVariable",
- new Class[] { String.class, Object.class });
- java.lang.reflect.Method run = gcClass.getMethod("run");
- Object gc = gccons.newInstance();
- setvar.invoke(gc, new Object[] { "Jalview", this });
- run.invoke(gc);
+ openGroovyConsole();
} catch (Exception ex)
{
jalview.bin.Cache.log.error("Groovy Shell Creation failed.", ex);
}
/**
+ * Open the Groovy console, using reflection to avoid creating compile-time
+ * dependency on Groovy libraries
+ *
+ * @throws ClassNotFoundException
+ * @throws NoSuchMethodException
+ * @throws InstantiationException
+ * @throws IllegalAccessException
+ * @throws InvocationTargetException
+ */
+ void openGroovyConsole() throws ClassNotFoundException,
+ NoSuchMethodException, InstantiationException,
+ IllegalAccessException, InvocationTargetException
+ {
+ Class<?> gcClass = Desktop.class.getClassLoader().loadClass(
+ "groovy.ui.Console");
+ Constructor<?> gccons = gcClass.getConstructor();
+ groovyConsole = gccons.newInstance();
+
+ /*
+ * bind groovy variable 'Jalview' to the Desktop object
+ */
+ Method setvar = gcClass.getMethod("setVariable", new Class[] {
+ String.class, Object.class });
+ setvar.invoke(groovyConsole, new Object[] { "Jalview", this });
+
+ /*
+ * start the console
+ */
+ Method run = gcClass.getMethod("run");
+ run.invoke(groovyConsole);
+
+ /*
+ * Allow only one console at a time, so that the AlignFrame menu option
+ * 'Calculate | Run Groovy script' is unambiguous.
+ * Disable 'new console', and enable 'Run script', when the console is
+ * opened, and the reverse when it is closed
+ */
+ Method getFrame = gcClass.getMethod("getFrame");
+ Window window = (Window) getFrame.invoke(groovyConsole);
+ window.addWindowListener(new WindowAdapter()
+ {
+ @Override
+ public void windowClosed(WindowEvent e)
+ {
+ groovyShell.setEnabled(true);
+ enableExecuteGroovy(false);
+ }
+ });
+
+ /*
+ * if we got this far, enable 'Run Groovy' in AlignFrame menus
+ * and disable opening a second console
+ */
+ groovyShell.setEnabled(false);
+ enableExecuteGroovy(true);
+ }
+
+ /**
+ * Enable or disable 'Run Groovy script' in AlignFrame calculate menus
+ *
+ * @param enabled
+ */
+ public void enableExecuteGroovy(boolean enabled)
+ {
+ AlignFrame[] alignFrames = getAlignFrames();
+ if (alignFrames != null)
+ {
+ for (AlignFrame af : alignFrames)
+ {
+ af.setGroovyEnabled(enabled);
+ }
+ }
+ }
+
+ /**
* Progress bars managed by the IProgressIndicator method.
*/
private Hashtable<Long, JPanel> progressBars;
*
* @see jalview.gui.IProgressIndicator#setProgressBar(java.lang.String, long)
*/
+ @Override
public void setProgressBar(String message, long id)
{
if (progressBars == null)
* @see jalview.gui.IProgressIndicator#registerHandler(long,
* jalview.gui.IProgressIndicatorHandler)
*/
+ @Override
public void registerHandler(final long id,
final IProgressIndicatorHandler handler)
{
cancel.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
handler.cancelActivity(id);
// only run if we aren't already displaying one of these.
addDialogThread(serviceChangedDialog = new Runnable()
{
+ @Override
public void run()
{
{
new Thread(new Runnable()
{
+ @Override
public void run()
{
try
*/
private java.util.concurrent.Semaphore block = new Semaphore(0);
+ /*
+ * groovy.ui.Console object - if Groovy jars are present and the
+ * user has activated the Groovy console. Use via reflection to
+ * avoid compile-time dependency on Groovy libraries.
+ */
+ private static Object groovyConsole;
+
/**
* add another dialog thread to the queue
*
{
dialogExecutor.submit(new Runnable()
{
+ @Override
public void run()
{
if (dialogPause)
ImageMaker im = new jalview.util.ImageMaker(this, ImageMaker.TYPE.EPS,
"View of Desktop", getWidth(), getHeight(), of = new File(
"Jalview_snapshot" + System.currentTimeMillis()
- + ".eps"), "View of desktop");
+ + ".eps"), "View of desktop", null, 0, false);
try
{
paintAll(im.getGraphics());
Desktop.currentAlignFrame = currentAlignFrame;
}
+ public static Object getGroovyConsole()
+ {
+ return groovyConsole;
+ }
+
}