/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2b1)
* Copyright (C) 2014 The Jalview Authors
*
* This file is part of Jalview.
import jalview.io.IdentifyFile;
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
+import jalview.jbgui.GStructureViewer;
+import jalview.structure.StructureSelectionManager;
import jalview.util.ImageMaker;
import jalview.util.MessageManager;
import jalview.ws.params.ParamManager;
import javax.swing.JProgressBar;
import javax.swing.SwingUtilities;
import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkEvent.EventType;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
-import javax.swing.event.HyperlinkEvent.EventType;
/**
* Jalview Desktop
*/
private BlogReader jvnews = null;
+ private File projectFile;
+
/**
* @param listener
* @see jalview.gui.JalviewChangeSupport#addJalviewPropertyChangeListener(java.beans.PropertyChangeListener)
instance = this;
doVamsasClientCheck();
doGroovyCheck();
-
+ doConfigureStructurePrefs();
setTitle("Jalview " + jalview.bin.Cache.getProperty("VERSION"));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
boolean selmemusage = jalview.bin.Cache.getDefault("SHOW_MEMUSAGE",
else
{
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- setBounds((int) (screenSize.width - 900) / 2,
- (int) (screenSize.height - 650) / 2, 900, 650);
+ setBounds((screenSize.width - 900) / 2,
+ (screenSize.height - 650) / 2, 900, 650);
}
jconsole = new Console(this, showjconsole);
// add essential build information
- jconsole.setHeader("Jalview Desktop "
+ jconsole.setHeader("Jalview Version: "
+ jalview.bin.Cache.getProperty("VERSION") + "\n"
+ + "Jalview Installation: "
+ + jalview.bin.Cache.getDefault("INSTALLATION", "unknown")
+ + "\n"
+ "Build Date: "
+ jalview.bin.Cache.getDefault("BUILD_DATE", "unknown") + "\n"
+ "Java version: " + System.getProperty("java.version") + "\n"
});
}
+ public void doConfigureStructurePrefs()
+ {
+ // configure services
+ StructureSelectionManager ssm = StructureSelectionManager
+ .getStructureSelectionManager(this);
+ if (jalview.bin.Cache.getDefault(Preferences.ADD_SS_ANN, true))
+ {
+ ssm.setAddTempFacAnnot(jalview.bin.Cache.getDefault(
+ Preferences.ADD_TEMPFACT_ANN, true));
+ ssm.setProcessSecondaryStructure(jalview.bin.Cache.getDefault(Preferences.STRUCT_FROM_PDB, true));
+ ssm.setSecStructServices(jalview.bin.Cache.getDefault(Preferences.USE_RNAVIEW,
+ true));
+ }
+ else
+ {
+ ssm.setAddTempFacAnnot(false);
+ ssm.setProcessSecondaryStructure(false);
+ ssm.setSecStructServices(false);
+ }
+ }
+
public void checkForNews()
{
final Desktop me = this;
* Adds and opens the given frame to the desktop
*
* @param frame
- * DOCUMENT ME!
+ * Frame to show
* @param title
- * DOCUMENT ME!
+ * Visible Title
* @param w
- * DOCUMENT ME!
+ * width
* @param h
- * DOCUMENT ME!
+ * height
*/
public static synchronized void addInternalFrame(
final JInternalFrame frame, String title, int w, int h)
{
- addInternalFrame(frame, title, w, h, true);
+ addInternalFrame(frame, title, true, w, h, true);
}
+
/**
- * DOCUMENT ME!
+ * Add an internal frame to the Jalview desktop
*
* @param frame
- * DOCUMENT ME!
+ * Frame to show
* @param title
- * DOCUMENT ME!
+ * Visible Title
+ * @param makeVisible
+ * When true, display frame immediately, otherwise, caller must call
+ * setVisible themselves.
* @param w
- * DOCUMENT ME!
+ * width
* @param h
- * DOCUMENT ME!
+ * height
+ */
+ public static synchronized void addInternalFrame(
+ final JInternalFrame frame, String title, boolean makeVisible,
+ int w, int h)
+ {
+ addInternalFrame(frame, title, makeVisible, w, h, true);
+ }
+
+ /**
+ * Add an internal frame to the Jalview desktop and make it visible
+ *
+ * @param frame
+ * Frame to show
+ * @param title
+ * Visible Title
+ * @param w
+ * width
+ * @param h
+ * height
* @param resizable
- * DOCUMENT ME!
+ * Allow resize
*/
public static synchronized void addInternalFrame(
final JInternalFrame frame, String title, int w, int h,
boolean resizable)
{
+ addInternalFrame(frame, title, true, w, h, resizable);
+ }
+
+ /**
+ * Add an internal frame to the Jalview desktop
+ *
+ * @param frame
+ * Frame to show
+ * @param title
+ * Visible Title
+ * @param makeVisible
+ * When true, display frame immediately, otherwise, caller must call
+ * setVisible themselves.
+ * @param w
+ * width
+ * @param h
+ * height
+ * @param resizable
+ * Allow resize
+ */
+ public static synchronized void addInternalFrame(
+ final JInternalFrame frame, String title, boolean makeVisible,
+ int w, int h, boolean resizable)
+ {
// TODO: allow callers to determine X and Y position of frame (eg. via
// bounds object).
openFrameCount++;
- frame.setVisible(true);
+ frame.setVisible(makeVisible);
frame.setClosable(true);
frame.setResizable(resizable);
frame.setMaximizable(resizable);
{
CutAndPasteTransfer cap = new CutAndPasteTransfer();
cap.setForInput(viewport);
- Desktop.addInternalFrame(cap, "Cut & Paste Alignment File", 600, 500);
+ Desktop.addInternalFrame(cap,
+ MessageManager.getString("label.cut_paste_alignmen_file"),
+ true, 600, 500);
}
/*
{
try
{
- ClassLoader cl = jalview.gui.Desktop.class.getClassLoader();
- java.net.URL url = javax.help.HelpSet.findHelpSet(cl, "help/help");
- javax.help.HelpSet hs = new javax.help.HelpSet(cl, url);
-
- javax.help.HelpBroker hb = hs.createHelpBroker();
- hb.setCurrentID("home");
- hb.setDisplayed(true);
+ Help.showHelpWindow();
} catch (Exception ex)
{
}
{
final Desktop me = this;
final java.io.File choice = chooser.getSelectedFile();
+ setProjectFile(choice);
+
+ // TODO or move inside the new Thread?
+ saveChimeraSessions(choice.getAbsolutePath());
+
new Thread(new Runnable()
{
public void run()
// TODO prevent user from messing with the Desktop whilst we're saving
try
{
- new Jalview2XML().SaveState(choice);
+ new Jalview2XML().saveState(choice);
} catch (OutOfMemoryError oom)
{
new OOMWarning("Whilst saving current state to "
}
/**
+ * Request any open, linked Chimera sessions to save their state.
+ *
+ * @param jalviewProjectFilename
+ * the filename of the Jalview project; Chimera session files should
+ * be given distinct, but obviously related, names.
+ */
+ public void saveChimeraSessions(String jalviewProjectFilename)
+ {
+ int i = 0;
+ for (JInternalFrame frame : getAllFrames())
+ {
+ if (frame instanceof ChimeraViewFrame)
+ {
+ /*
+ * Construct a filename for the Chimera session by append _chimera<n>.py
+ * to the Jalview project file name.
+ */
+ String chimeraPath = jalviewProjectFilename + "_chimera_" + i
+ + ".py";
+ ((ChimeraViewFrame) frame).saveSession(chimeraPath);
+ i++;
+ }
+ }
+ }
+
+ private void setProjectFile(File choice)
+ {
+ this.projectFile = choice;
+ }
+
+ public File getProjectFile()
+ {
+ return this.projectFile;
+ }
+
+ /**
* DOCUMENT ME!
*
* @param e
if (value == JalviewFileChooser.APPROVE_OPTION)
{
- final String choice = chooser.getSelectedFile().getAbsolutePath();
- jalview.bin.Cache.setProperty("LAST_DIRECTORY", chooser
- .getSelectedFile().getParent());
+ final File selectedFile = chooser.getSelectedFile();
+ setProjectFile(selectedFile);
+ final String choice = selectedFile.getAbsolutePath();
+ jalview.bin.Cache.setProperty("LAST_DIRECTORY", selectedFile.getParent());
new Thread(new Runnable()
{
public void run()
choice.hashCode());
try
{
- new Jalview2XML().LoadJalviewAlign(choice);
+ new Jalview2XML().loadJalviewAlign(choice);
} catch (OutOfMemoryError oom)
{
new OOMWarning("Whilst loading project from " + choice, oom);
if (showMemoryUsage && g != null && df != null)
{
if (percentUsage < 20)
+ {
g.setColor(Color.red);
+ }
FontMetrics fm = g.getFontMetrics();
if (fm != null)
{
return afs;
}
- public AppJmol[] getJmols()
+ public GStructureViewer[] getJmols()
{
JInternalFrame[] frames = Desktop.desktop.getAllFrames();
{
if (frames[i] instanceof AppJmol)
{
- AppJmol af = (AppJmol) frames[i];
+ GStructureViewer af = (GStructureViewer) frames[i];
avp.addElement(af);
}
}
{
return null;
}
- AppJmol afs[] = new AppJmol[avp.size()];
+ GStructureViewer afs[] = new GStructureViewer[avp.size()];
for (int i = 0, j = avp.size(); i < j; i++)
{
- afs[i] = (AppJmol) avp.elementAt(i);
+ afs[i] = (GStructureViewer) avp.elementAt(i);
}
avp.clear();
return afs;
throw new Error(MessageManager.getString("error.call_setprogressbar_before_registering_handler"));
}
progressBarHandlers.put(new Long(id), handler);
- final JPanel progressPanel = (JPanel) progressBars.get(new Long(id));
+ final JPanel progressPanel = progressBars.get(new Long(id));
if (handler.canCancel())
{
JButton cancel = new JButton(
+ ermsg
+ "</td></tr></table>"
+ "<p>It may be that you have invalid JABA URLs<br/>in your web service preferences,"
- + " or mis-configured HTTP proxy settings.</p>"
+ + "<br>or as a command-line argument, or mis-configured HTTP proxy settings.</p>"
+ "<p>Check the <em>Connections</em> and <em>Web services</em> tab<br/>of the"
+ " Tools->Preferences dialog box to change them.</p></html>"),
"Web Service Configuration Problem",
{
invalidate();
File of;
- ImageMaker im = new jalview.util.ImageMaker(this, ImageMaker.EPS, "View of Desktop", getWidth(), getHeight(), of=new File("Jalview_snapshot"+System.currentTimeMillis()+".eps"), "View of desktop");
+ 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();