();
+ progressBars = new Hashtable<>();
+ progressBarHandlers = new Hashtable<>();
}
- if (progressBars.get(new Long(id)) != null)
+ if (progressBars.get(Long.valueOf(id)) != null)
{
- JPanel panel = progressBars.remove(new Long(id));
- if (progressBarHandlers.contains(new Long(id)))
+ JPanel panel = progressBars.remove(Long.valueOf(id));
+ if (progressBarHandlers.contains(Long.valueOf(id)))
{
- progressBarHandlers.remove(new Long(id));
+ progressBarHandlers.remove(Long.valueOf(id));
}
removeProgressPanel(panel);
}
else
{
- progressBars.put(new Long(id), addProgressPanel(message));
+ progressBars.put(Long.valueOf(id), addProgressPanel(message));
}
}
@@ -2522,18 +2528,18 @@ public class Desktop extends jalview.jbgui.GDesktop implements
* @see jalview.gui.IProgressIndicator#registerHandler(long,
* jalview.gui.IProgressIndicatorHandler)
*/
+ @Override
public void registerHandler(final long id,
final IProgressIndicatorHandler handler)
{
if (progressBarHandlers == null
- || !progressBars.containsKey(new Long(id)))
+ || !progressBars.containsKey(Long.valueOf(id)))
{
- throw new Error(
- MessageManager
- .getString("error.call_setprogressbar_before_registering_handler"));
+ throw new Error(MessageManager.getString(
+ "error.call_setprogressbar_before_registering_handler"));
}
- progressBarHandlers.put(new Long(id), handler);
- final JPanel progressPanel = progressBars.get(new Long(id));
+ progressBarHandlers.put(Long.valueOf(id), handler);
+ final JPanel progressPanel = progressBars.get(Long.valueOf(id));
if (handler.canCancel())
{
JButton cancel = new JButton(
@@ -2542,11 +2548,12 @@ public class Desktop extends jalview.jbgui.GDesktop implements
cancel.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
handler.cancelActivity(id);
- us.setProgressBar(MessageManager.formatMessage(
- "label.cancelled_params", new Object[]
+ us.setProgressBar(MessageManager
+ .formatMessage("label.cancelled_params", new Object[]
{ ((JLabel) progressPanel.getComponent(0)).getText() }),
id);
}
@@ -2570,8 +2577,9 @@ public class Desktop extends jalview.jbgui.GDesktop implements
}
/**
- * This will return the first AlignFrame holding the given viewport instance. It
- * will break if there are more than one AlignFrames viewing a particular av.
+ * This will return the first AlignFrame holding the given viewport instance.
+ * It will break if there are more than one AlignFrames viewing a particular
+ * av.
*
* @param viewport
* @return alignFrame for viewport
@@ -2580,8 +2588,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements
{
if (desktop != null)
{
- AlignmentPanel[] aps = getAlignmentPanels(viewport
- .getSequenceSetId());
+ AlignmentPanel[] aps = getAlignmentPanels(
+ viewport.getSequenceSetId());
for (int panel = 0; aps != null && panel < aps.length; panel++)
{
if (aps[panel] != null && aps[panel].av == viewport)
@@ -2595,7 +2603,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements
public VamsasApplication getVamsasApplication()
{
- return v_client;
+ // TODO: JAL-3311 remove remaining code from Jalview relating to VAMSAS
+ return null;
}
@@ -2650,13 +2659,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements
if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
{
- if (jalview.ws.jws2.Jws2Discoverer.getDiscoverer().isRunning())
- {
- jalview.ws.jws2.Jws2Discoverer.getDiscoverer().setAborted(true);
- }
- t2 = jalview.ws.jws2.Jws2Discoverer.getDiscoverer().startDiscoverer(
- changeSupport);
-
+ t2 = jalview.ws.jws2.Jws2Discoverer.getDiscoverer()
+ .startDiscoverer(changeSupport);
}
Thread t3 = null;
{
@@ -2672,8 +2676,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
} catch (Exception e)
{
}
- alive = (t1 != null && t1.isAlive())
- || (t2 != null && t2.isAlive())
+ alive = (t1 != null && t1.isAlive()) || (t2 != null && t2.isAlive())
|| (t3 != null && t3.isAlive())
|| (t0 != null && t0.isAlive());
}
@@ -2700,6 +2703,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
// only run if we aren't already displaying one of these.
addDialogThread(serviceChangedDialog = new Runnable()
{
+ @Override
public void run()
{
@@ -2727,20 +2731,16 @@ public class Desktop extends jalview.jbgui.GDesktop implements
*
* jd.waitForInput();
*/
- JOptionPane
- .showConfirmDialog(
- Desktop.desktop,
- new JLabel(
- ""
- + "It may be that you have invalid JABA URLs
in your web service preferences,"
- + "
or as a command-line argument, or mis-configured HTTP proxy settings.
"
- + "Check the Connections and Web services tab
of the"
- + " Tools->Preferences dialog box to change them.
"),
- "Web Service Configuration Problem",
- JOptionPane.DEFAULT_OPTION,
- JOptionPane.ERROR_MESSAGE);
+ JvOptionPane.showConfirmDialog(Desktop.desktop,
+ new JLabel(""
+ + "It may be that you have invalid JABA URLs
in your web service preferences,"
+ + "
or as a command-line argument, or mis-configured HTTP proxy settings.
"
+ + "Check the Connections and Web services tab
of the"
+ + " Tools->Preferences dialog box to change them.
"),
+ "Web Service Configuration Problem",
+ JvOptionPane.DEFAULT_OPTION,
+ JvOptionPane.ERROR_MESSAGE);
serviceChangedDialog = null;
}
@@ -2749,8 +2749,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements
}
else
{
- Cache.log
- .error("Errors reported by JABA discovery service. Check web services preferences.\n"
+ Cache.log.error(
+ "Errors reported by JABA discovery service. Check web services preferences.\n"
+ ermsg);
}
}
@@ -2783,24 +2783,25 @@ public class Desktop extends jalview.jbgui.GDesktop implements
{
new Thread(new Runnable()
{
+ @Override
public void run()
{
try
{
if (progress != null)
{
- progress.setProgressBar(MessageManager.formatMessage(
- "status.opening_params", new Object[]
+ progress.setProgressBar(MessageManager
+ .formatMessage("status.opening_params", new Object[]
{ url }), this.hashCode());
}
jalview.util.BrowserLauncher.openURL(url);
} catch (Exception ex)
{
- JOptionPane.showInternalMessageDialog(Desktop.desktop,
+ JvOptionPane.showInternalMessageDialog(Desktop.desktop,
MessageManager
.getString("label.web_browser_not_found_unix"),
MessageManager.getString("label.web_browser_not_found"),
- JOptionPane.WARNING_MESSAGE);
+ JvOptionPane.WARNING_MESSAGE);
ex.printStackTrace();
}
@@ -2847,8 +2848,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements
}
else
{
- System.err.println("Couldn't handle string " + url
- + " as a URL.");
+ System.err.println(
+ "Couldn't handle string " + url + " as a URL.");
}
}
// ignore any exceptions due to dud links.
@@ -2872,6 +2873,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements
*/
private java.util.concurrent.Semaphore block = new Semaphore(0);
+ private static groovy.ui.Console groovyConsole;
+
/**
* add another dialog thread to the queue
*
@@ -2881,6 +2884,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
{
dialogExecutor.submit(new Runnable()
{
+ @Override
public void run()
{
if (dialogPause)
@@ -2891,7 +2895,6 @@ public class Desktop extends jalview.jbgui.GDesktop implements
} catch (InterruptedException x)
{
}
- ;
}
if (instance == null)
{
@@ -2916,31 +2919,47 @@ public class Desktop extends jalview.jbgui.GDesktop implements
block.release();
}
+ /**
+ * Outputs an image of the desktop to file in EPS format, after prompting the
+ * user for choice of Text or Lineart character rendering (unless a preference
+ * has been set). The file name is generated as
+ *
+ *
+ * Jalview_snapshot_nnnnn.eps where nnnnn is the current timestamp in milliseconds
+ *
+ */
@Override
protected void snapShotWindow_actionPerformed(ActionEvent e)
{
+ // currently the menu option to do this is not shown
invalidate();
- File of;
- 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");
- try
- {
- paintAll(im.getGraphics());
- im.writeImage();
- } catch (Exception q)
+
+ int width = getWidth();
+ int height = getHeight();
+ File of = new File(
+ "Jalview_snapshot_" + System.currentTimeMillis() + ".eps");
+ ImageWriterI writer = new ImageWriterI()
{
- Cache.log.error("Couldn't write snapshot to " + of.getAbsolutePath(),
- q);
- return;
- }
- Cache.log.info("Successfully written snapshot to file "
- + of.getAbsolutePath());
+ @Override
+ public void exportImage(Graphics g) throws Exception
+ {
+ paintAll(g);
+ Cache.log.info("Successfully written snapshot to file "
+ + of.getAbsolutePath());
+ }
+ };
+ String title = "View of desktop";
+ ImageExporter exporter = new ImageExporter(writer, null, TYPE.EPS,
+ title);
+ exporter.doExport(of, this, width, height, title);
}
/**
- * Explode the views in the given frame into separate AlignFrame windows.
+ * Explode the views in the given SplitFrame into separate SplitFrame windows.
+ * This respects (remembers) any previous 'exploded geometry' i.e. the size
+ * and location last time the view was expanded (if any). However it does not
+ * remember the split pane divider location - this is set to match the
+ * 'exploding' frame.
*
* @param sf
*/
@@ -2969,27 +2988,39 @@ public class Desktop extends jalview.jbgui.GDesktop implements
* AlignmentPanel objects, including their AlignmentViewports, so the
* cdna/protein relationships between the viewports is carried over to the
* new split frames.
+ *
+ * explodedGeometry holds the (x, y) position of the previously exploded
+ * SplitFrame, and the (width, height) of the AlignFrame component
*/
AlignmentPanel topPanel = (AlignmentPanel) topPanels.get(i);
AlignFrame newTopFrame = new AlignFrame(topPanel);
- newTopFrame.setSize(new Dimension(AlignFrame.DEFAULT_WIDTH,
- AlignFrame.DEFAULT_HEIGHT));
+ newTopFrame.setSize(oldTopFrame.getSize());
newTopFrame.setVisible(true);
+ Rectangle geometry = ((AlignViewport) topPanel.getAlignViewport())
+ .getExplodedGeometry();
+ if (geometry != null)
+ {
+ newTopFrame.setSize(geometry.getSize());
+ }
+
AlignmentPanel bottomPanel = (AlignmentPanel) bottomPanels.get(i);
AlignFrame newBottomFrame = new AlignFrame(bottomPanel);
- newBottomFrame.setSize(new Dimension(AlignFrame.DEFAULT_WIDTH,
- AlignFrame.DEFAULT_HEIGHT));
+ newBottomFrame.setSize(oldBottomFrame.getSize());
newBottomFrame.setVisible(true);
+ geometry = ((AlignViewport) bottomPanel.getAlignViewport())
+ .getExplodedGeometry();
+ if (geometry != null)
+ {
+ newBottomFrame.setSize(geometry.getSize());
+ }
+
topPanel.av.setGatherViewsHere(false);
bottomPanel.av.setGatherViewsHere(false);
JInternalFrame splitFrame = new SplitFrame(newTopFrame,
newBottomFrame);
- // either panel may hold previous exploded frame geometry
- Rectangle geometry = ((AlignViewport) topPanel.getAlignViewport())
- .getExplodedGeometry();
if (geometry != null)
{
- splitFrame.setBounds(geometry);
+ splitFrame.setLocation(geometry.getLocation());
}
Desktop.addInternalFrame(splitFrame, sf.getTitle(), -1, -1);
}
@@ -3012,15 +3043,23 @@ public class Desktop extends jalview.jbgui.GDesktop implements
*/
public void gatherViews(GSplitFrame source)
{
+ /*
+ * special handling of explodedGeometry for a view within a SplitFrame: - it
+ * holds the (x, y) position of the enclosing SplitFrame, and the (width,
+ * height) of the AlignFrame component
+ */
AlignFrame myTopFrame = (AlignFrame) source.getTopFrame();
AlignFrame myBottomFrame = (AlignFrame) source.getBottomFrame();
- myTopFrame.viewport.setExplodedGeometry(source.getBounds());
- myBottomFrame.viewport.setExplodedGeometry(source.getBounds());
+ myTopFrame.viewport.setExplodedGeometry(new Rectangle(source.getX(),
+ source.getY(), myTopFrame.getWidth(), myTopFrame.getHeight()));
+ myBottomFrame.viewport
+ .setExplodedGeometry(new Rectangle(source.getX(), source.getY(),
+ myBottomFrame.getWidth(), myBottomFrame.getHeight()));
myTopFrame.viewport.setGatherViewsHere(true);
myBottomFrame.viewport.setGatherViewsHere(true);
String topViewId = myTopFrame.viewport.getSequenceSetId();
String bottomViewId = myBottomFrame.viewport.getSequenceSetId();
-
+
JInternalFrame[] frames = desktop.getAllFrames();
for (JInternalFrame frame : frames)
{
@@ -3040,15 +3079,15 @@ public class Desktop extends jalview.jbgui.GDesktop implements
gatherThis = true;
topPanel.av.setGatherViewsHere(false);
bottomPanel.av.setGatherViewsHere(false);
- // both panels refer to the same split frame geometry
- Rectangle position = sf.getBounds();
- topPanel.av.setExplodedGeometry(position);
- bottomPanel.av.setExplodedGeometry(position);
+ topPanel.av.setExplodedGeometry(
+ new Rectangle(sf.getLocation(), topFrame.getSize()));
+ bottomPanel.av.setExplodedGeometry(
+ new Rectangle(sf.getLocation(), bottomFrame.getSize()));
myTopFrame.addAlignmentPanel(topPanel, false);
myBottomFrame.addAlignmentPanel(bottomPanel, false);
}
}
-
+
if (gatherThis)
{
topFrame.getAlignPanels().clear();
@@ -3062,18 +3101,313 @@ public class Desktop extends jalview.jbgui.GDesktop implements
* The dust settles...give focus to the tab we did this from.
*/
myTopFrame.setDisplayedView(myTopFrame.alignPanel);
+ }
+
+ public static groovy.ui.Console getGroovyConsole()
+ {
+ return groovyConsole;
+ }
+
+ /**
+ * handles the payload of a drag and drop event.
+ *
+ * TODO refactor to desktop utilities class
+ *
+ * @param files
+ * - Data source strings extracted from the drop event
+ * @param protocols
+ * - protocol for each data source extracted from the drop event
+ * @param evt
+ * - the drop event
+ * @param t
+ * - the payload from the drop event
+ * @throws Exception
+ */
+ public static void transferFromDropTarget(List