}
else
{
+ // BH 2019.08.26 cannot pass null
System.setSecurityManager(null);
}
|| "true".equals(System.getProperty("java.awt.headless")))
{
headless = true;
+
+ System.out.println("Headless operation detected.");
+
}
// anything else!
try
{
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ UIManager.setLookAndFeel(
+ headless ? "javax.swing.plaf.metal.MetalLookAndFeel"
+ : UIManager.getSystemLookAndFeelClassName());
} catch (Exception ex)
{
System.err.println("Unexpected Look and Feel Exception");
{
if (!(new File(file)).exists())
{
- System.out.println("Can't find " + file);
+ System.out.println(
+ "Can't find " + new File(file).getAbsolutePath());
if (headless)
{
System.exit(1);
if (aparser.contains(ArgsParser.SHOWOVERVIEW))
{
- af.overviewMenuItem_actionPerformed(null);
+ if (!headless)
+ {
+ af.overviewMenuItem_actionPerformed(null);
+ }
System.out.println("CMD [showoverview] executed successfully!");
}
@Override
public void run()
{
- StructureSelectionManager
+ if (Desktop.getInstance() != null)
+ {
+ StructureSelectionManager
.getStructureSelectionManager(Desktop.getInstance())
.mouseOverVamsasSequence(sq, sq.findIndex(pos), null);
+ }
}
});
}
{
if (args.length == 0)
{
- args = new String[] { "open", "examples/uniref50.fa", "features",
+ args = new String[] { "headless", "open", "examples/uniref50.fa",
+ "features",
"examples/exampleFeatures.txt"
, "noannotation"
, "showoverview"
+ , "png", "ALIGN.png"
};
}
Jalview.main(args);
*/
private final int INTERVAL_STORE_MODE = (
// true || //
- true || Platform.isJS() ? //
+ Platform.isJS() ? //
INTERVAL_STORE_LINKED_LIST //
: INTERVAL_STORE_NCLIST//
);
import java.awt.print.PageFormat;
import java.awt.print.PrinterJob;
import java.beans.PropertyChangeEvent;
+import java.beans.PropertyVetoException;
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
IProgressIndicator, AlignViewControllerGuiI, ColourChangeListener
{
+ public class IFrame extends JInternalFrame
+ {
+ public AlignFrame alignframe;
+
+ IFrame(AlignFrame alignframe)
+ {
+ this.alignframe = alignframe;
+ }
+
+ }
+
public static final int DEFAULT_WIDTH = 700;
public static final int DEFAULT_HEIGHT = 500;
public AlignFrame(AlignmentI al, HiddenColumns hiddenColumns, int width,
int height, String sequenceSetId, String viewId)
{
+ super();
+
+ System.out.println("AlignFrame 1");
+
setSize(width, height);
+ System.out.println("GAlignFrame 2");
+
if (al.getDataset() == null)
{
al.setDataset(null);
}
+ System.out.println("GAlignFrame 3");
+
viewport = new AlignViewport(al, hiddenColumns, sequenceSetId, viewId);
+ System.out.println("GAlignFrame 4");
+
init();
}
*/
void init()
{
+
+ System.out.println("AlignFrame 8");
boolean newPanel = (alignPanel == null);
viewport.setShowAutocalculatedAbove(isShowAutoCalculatedAbove());
+
+ System.out.println("AlignFrame 9");
if (newPanel)
{
if (Platform.isJS())
boolean showAnnotation = Jalview.getInstance().getShowAnnotation();
viewport.setShowAnnotation(showAnnotation);
}
+ System.out.println("AlignFrame 11");
alignPanel = new AlignmentPanel(this, viewport);
+ System.out.println("GAlignFrame 12");
}
+ System.out.println("GAlignFrame 13");
addAlignmentPanel(alignPanel, newPanel);
+ System.out.println("GAlignFrame 14");
// setBackground(Color.white); // BH 2019
int aSize = alignPanels.size();
+ System.out.println("AlignFrame 21");
+
tabbedPane.setVisible(aSize > 1 || ap.av.getViewName() != null);
+ System.out.println("AlignFrame 23");
if (aSize == 1 && ap.av.getViewName() == null)
{
- this.getContentPane().add(ap, BorderLayout.CENTER);
+ getContentPane().add(ap, BorderLayout.CENTER);
}
else
{
tabbedPane.setVisible(true);
AlignmentPanel first = alignPanels.get(0);
tabbedPane.addTab(first.av.getViewName(), first);
- this.getContentPane().add(tabbedPane, BorderLayout.CENTER);
+ getContentPane().add(tabbedPane, BorderLayout.CENTER);
}
+
public AlignViewport getViewport()
{
return viewport;
}
}
});
- addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
+ iframe.addInternalFrameListener(
+ new javax.swing.event.InternalFrameAdapter()
{
@Override
public void internalFrameClosed(
// file is reloaded.
if (FileFormat.Jalview.equals(currentFileFormat))
{
- JInternalFrame[] frames = Desktop.getDesktopPane().getAllFrames();
+ AlignFrame[] frames = Desktop.getAlignFrames();
for (int i = 0; i < frames.length; i++)
{
if (frames[i] instanceof AlignFrame && frames[i] != this
- && ((AlignFrame) frames[i]).fileName != null
- && ((AlignFrame) frames[i]).fileName.equals(fileName))
+ && frames[i].fileName != null
+ && frames[i].fileName.equals(fileName))
{
try
{
}
Desktop.getInstance().closeAssociatedWindows();
- FileLoader loader = new FileLoader();
+ FileLoader loader = new FileLoader(!Jalview.isHeadlessMode());
DataSourceType protocol = fileName.startsWith("http:")
? DataSourceType.URL
: DataSourceType.FILE;
}
}
+
@Override
public void addFromText_actionPerformed(ActionEvent e)
{
if (FileFormat.Jalview.equals(format))
{
- String shortName = title;
+ String shortName = getTitle();
if (shortName.indexOf(File.separatorChar) > -1)
{
shortName = shortName.substring(
{
if (closeAllTabs)
{
- if (this.isClosed())
+ if (isClosed())
{
// really close all the windows - otherwise wait till
// setClosed(true) is called
* this will raise an INTERNAL_FRAME_CLOSED event and this method will
* be called recursively, with the frame now in 'closed' state
*/
- this.setClosed(true);
+ iframe.setClosed(true);
}
} catch (Exception ex)
{
// title a concatenation of operations.
if (!externalPaste)
{
- if (title.startsWith("Copied sequences"))
+ if (getTitle().startsWith("Copied sequences"))
{
- newtitle = title;
+ newtitle = getTitle();
}
else
{
- newtitle = newtitle.concat("- from " + title);
+ newtitle = newtitle.concat("- from " + getTitle());
}
}
else
// TODO: maintain provenance of an alignment, rather than just make the
// title a concatenation of operations.
{
- if (title.startsWith("Copied sequences"))
+ if (getTitle().startsWith("Copied sequences"))
{
- newtitle = title;
+ newtitle = getTitle();
}
else
{
- newtitle = newtitle.concat("- from " + title);
+ newtitle = newtitle.concat("- from " + getTitle());
}
}
- Desktop.addInternalFrame(af, newtitle, DEFAULT_WIDTH, DEFAULT_HEIGHT);
+ Desktop.addInternalFrame(af, newtitle, DEFAULT_WIDTH,
+ DEFAULT_HEIGHT);
} catch (Exception ex)
{
{
try
{
- AlignFrame.this.setClosed(true);
+ AlignFrame.this.getIFrame().setClosed(true);
} catch (Exception ex)
{
}
frameTitle += viewport.getViewName() + " of ";
}
- frameTitle += this.title;
+ frameTitle += this.getTitle();
Desktop.addInternalFrame(tp, frameTitle, 600, 500);
}
}
else
{
- new FileLoader().loadFile(viewport, file, sourceType, format);
+ new FileLoader(!Jalview.isHeadlessMode()).loadFile(viewport, file, sourceType, format);
}
}
}
}
AlignmentI cdna = new Alignment(
cdnaSeqs.toArray(new SequenceI[cdnaSeqs.size()]));
- GAlignFrame alignFrame = new AlignFrame(cdna, AlignFrame.DEFAULT_WIDTH,
+ AlignFrame alignFrame = new AlignFrame(cdna, AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
cdna.alignAs(alignment);
String newtitle = "cDNA " + MessageManager.getString("label.for") + " "
- + this.title;
- Desktop.addInternalFrame(alignFrame, newtitle, AlignFrame.DEFAULT_WIDTH,
+ + getTitle();
+ Desktop.addInternalFrame(alignFrame, newtitle,
+ AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
}
alignPanel.getSeqPanel().selection(sel, csel, hidden, null);
}
+ public void setSelected(boolean b) throws PropertyVetoException
+ {
+ if (iframe != null)
+ {
+ iframe.setSelected(b);
+ }
+ }
+
+ @Override
+ protected JInternalFrame getInternalFrame()
+ {
+ return new IFrame(this);
+ }
+
+ public void dispose()
+ {
+ if (iframe != null)
+ {
+ iframe.dispose();
+ }
+ }
+
+ public void setMaximum(boolean b) throws PropertyVetoException
+ {
+ if (iframe != null)
+ {
+ iframe.setMaximum(b);
+ }
+ }
+
+ public boolean isClosed()
+ {
+ return (iframe != null && iframe.isClosed());
+ }
+
}
class PrintThread extends Thread
*/
if (align != null)
{
- Desktop.getInstance().getStructureSelectionManager()
+ getStructureSelectionManager()
.registerMappings(align.getCodonFrames());
}
if (al != null)
{
List<AlignedCodonFrame> mappings = al.getCodonFrames();
- if (mappings != null)
+ if (mappings != null && Desktop.getInstance() != null)
{
- StructureSelectionManager ssm = Desktop.getInstance()
- .getStructureSelectionManager();
+ // StructureSelectionManager ssm = Desktop.getInstance()
+ // .getStructureSelectionManager();
+
+ // BH 2019.08.27 allows for null Desktop instance
+ StructureSelectionManager ssm = getStructureSelectionManager();
for (AlignedCodonFrame acf : mappings)
{
if (noReferencesTo(acf))
@Override
public void sendSelection()
{
- Desktop.getInstance().getStructureSelectionManager().sendSelection(
+ getStructureSelectionManager().sendSelection(
new SequenceGroup(getSelectionGroup()),
new ColumnSelection(getColumnSelection()),
new HiddenColumns(getAlignment().getHiddenColumns()), this);
@Override
public StructureSelectionManager getStructureSelectionManager()
{
- return Desktop.getInstance().getStructureSelectionManager();
+ // BH allows for null Desktop instance
+ return StructureSelectionManager
+ .getStructureSelectionManager(Desktop.getInstance());
}
@Override
*/
public AlignmentPanel(AlignFrame af, final AlignViewport av)
{
+
+ System.out.println("AP 1");
setBackground(Color.white); // BH 2019
setOpaque(true);
alignFrame = af;
this.av = av;
+
+ System.out.println("AP 2");
setSeqPanel(new SeqPanel(av, this));
+
+ System.out.println("AP 3");
setIdPanel(new IdPanel(av, this));
+ System.out.println("AP 4");
+
setScalePanel(new ScalePanel(av, this));
+ System.out.println("AP 5");
idPanelHolder.add(getIdPanel(), BorderLayout.CENTER);
idwidthAdjuster = new IdwidthAdjuster(this);
idSpaceFillerPanel1.add(idwidthAdjuster, BorderLayout.CENTER);
getIdPanel().getIdCanvas().setPreferredSize(d);
hscrollFillerPanel.setPreferredSize(d);
+ System.out.println("AP 99");
repaint();
+
+ System.out.println("AP 100");
}
/**
import jalview.datamodel.SequenceI;
import jalview.io.DataSourceType;
import jalview.io.StructureFile;
+import jalview.structure.StructureSelectionManager;
import jalview.util.MessageManager;
/**
{
PDBEntry entry = new PDBEntry();
StructureFile pdbfile = null;
- pdbfile = Desktop.getInstance().getStructureSelectionManager()
+ pdbfile = StructureSelectionManager
+ .getStructureSelectionManager(Desktop.getInstance())
.setMapping(false, new SequenceI[]
{ sequence }, null, fileName, type);
if (pdbfile == null)
import jalview.ext.ensembl.EnsemblInfo;
import jalview.ext.ensembl.EnsemblMap;
import jalview.io.gff.SequenceOntologyI;
+import jalview.structure.StructureSelectionManager;
import jalview.util.DBRefUtils;
import jalview.util.MapList;
import jalview.util.MappingUtils;
* register any new mappings for sequence mouseover etc
* (will not duplicate any previously registered mappings)
*/
- Desktop.getInstance().getStructureSelectionManager()
+ StructureSelectionManager
+ .getStructureSelectionManager(Desktop.getInstance())
.registerMappings(dataset.getCodonFrames());
if (copyAlignment.getHeight() <= 0)
public static MyDesktopPane getDesktopPane()
{
- Desktop desktop = Desktop.getInstance();
+ Desktop desktop = getInstance();
return desktop == null ? null : desktop.desktopPane;
}
FileFormatI format = new IdentifyFile().identify(file,
DataSourceType.PASTE);
- new FileLoader().loadFile(file, DataSourceType.PASTE, format);
+ new FileLoader(true).loadFile(file, DataSourceType.PASTE, format);
}
} catch (Exception ex)
// A HEADLESS STATE WHEN NO DESKTOP EXISTS. MUST RETURN
// IF JALVIEW IS RUNNING HEADLESS
// ///////////////////////////////////////////////
- if (Desktop.getInstance().instanceOnly || Jalview.isHeadlessMode())
+ if (Jalview.isHeadlessMode() || getInstance().instanceOnly)
{
return;
}
// The Alignment Frame window could be added from a number of places,
// hence,
// I did this here in order not to miss out on any Alignment frame.
- if (frame instanceof AlignFrame)
+ if (frame instanceof AlignFrame.IFrame)
{
frame.setMinimumSize(new Dimension(ALIGN_FRAME_DEFAULT_MIN_WIDTH,
ALIGN_FRAME_DEFAULT_MIN_HEIGHT));
JInternalFrame itf = getDesktopPane().getSelectedFrame();
if (itf != null)
{
- if (itf instanceof AlignFrame)
+ if (itf.getContentPane() instanceof AlignFrame)
{
- Jalview.setCurrentAlignFrame((AlignFrame) itf);
+ Jalview.setCurrentAlignFrame((AlignFrame) itf.getContentPane());
}
itf.requestFocus();
}
{
menuItem.removeActionListener(menuItem.getActionListeners()[0]);
}
- Desktop.getInstance().windowMenu.remove(menuItem);
+ getInstance().windowMenu.remove(menuItem);
}
});
getDesktopPane().add(frame);
- Desktop.getInstance().windowMenu.add(menuItem);
+ getInstance().windowMenu.add(menuItem);
frame.toFront();
try
{
if (!internalCopy)
{
- Desktop.getInstance().jalviewClipboard = null;
+ getInstance().jalviewClipboard = null;
}
internalCopy = false;
}
AlignmentViewport source = null, target = null;
- if (frames[0] instanceof AlignFrame)
+ if (frames[0] instanceof AlignFrame.IFrame)
{
- source = ((AlignFrame) frames[0]).getCurrentView();
+ source = ((AlignFrame.IFrame) frames[0]).alignframe.getCurrentView();
}
else if (frames[0] instanceof TreePanel)
{
{
continue;
}
- if (frames[i] instanceof AlignFrame)
+ if (frames[i] instanceof AlignFrame.IFrame)
{
- target = ((AlignFrame) frames[i]).getCurrentView();
+ target = ((AlignFrame.IFrame) frames[i]).alignframe
+ .getCurrentView();
}
else if (frames[i] instanceof TreePanel)
{
ap.av.setGatherViewsHere(false);
- addInternalFrame(newaf, af.getTitle(), AlignFrame.DEFAULT_WIDTH,
+ addInternalFrame(newaf, af.getTitle(),
+ AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
}
for (int t = 0; t < frames.length; t++)
{
- if (frames[t] instanceof AlignFrame && frames[t] != source)
+ if (frames[t] instanceof AlignFrame.IFrame
+ && ((AlignFrame.IFrame) frames[t]).alignframe != source)
{
- AlignFrame af = (AlignFrame) frames[t];
+ AlignFrame af = ((AlignFrame.IFrame) frames[t]).alignframe;
boolean gatherThis = false;
for (int a = 0; a < af.alignPanels.size(); a++)
{
}
}
}
+
}
/**
// REVERSE ORDER
for (int i = frames.length - 1; i > -1; i--)
{
- if (frames[i] instanceof AlignFrame)
+ if (frames[i].getContentPane() instanceof AlignFrame)
{
- avp.add((AlignFrame) frames[i]);
+ avp.add((AlignFrame) frames[i].getContentPane());
}
else if (frames[i] instanceof SplitFrame)
{
*/
public static void showUrl(final String url)
{
- showUrl(url, Desktop.getInstance());
+ showUrl(url, getInstance());
}
/**
public static ParamManager getUserParameterStore()
{
- Desktop d = Desktop.getInstance();
+ Desktop d = getInstance();
if (d.wsparamManager == null)
{
d.wsparamManager = new WsParamSetManager();
public static groovy.ui.Console getGroovyConsole()
{
- Desktop desktop = Desktop.getInstance();
+ Desktop desktop = getInstance();
return desktop == null ? null : desktop.groovyConsole;
}
return result;
}
+ public static void addInternalFrame(AlignFrame af, String title,
+ int width, int height)
+ {
+ addInternalFrame(af.getIFrame(), title, width, height);
+ }
+
}
}
// now checks further down the window stack to fix bug
// https://mantis.lifesci.dundee.ac.uk/view.php?id=36008
- JInternalFrame[] frames = Desktop.getDesktopPane().getAllFrames();
+ AlignFrame[] frames = Desktop.getAlignFrames();
for (int f = 0; f < frames.length; f++)
{
- JInternalFrame alignFrame = frames[f];
- if (alignFrame != null && alignFrame instanceof AlignFrame
- && !alignFrame.isIcon())
+ AlignFrame alignFrame = frames[f];
+ if (alignFrame != null && !alignFrame.getIFrame().isIcon())
{
- av = ((AlignFrame) alignFrame).viewport;
- ap = ((AlignFrame) alignFrame).alignPanel;
+ av = alignFrame.viewport;
+ ap = alignFrame.alignPanel;
return true;
}
}
import java.util.IdentityHashMap;
import java.util.Iterator;
-import javax.swing.JInternalFrame;
-
import uk.ac.vamsas.client.ClientHandle;
import uk.ac.vamsas.client.IClient;
import uk.ac.vamsas.client.IClientDocument;
*/
protected void updateJalviewGui()
{
- JInternalFrame[] frames = jdesktop.getAllFrames();
+ AlignFrame[] frames = Desktop.getAlignFrames();
if (frames == null)
{
// REVERSE ORDER
for (int i = frames.length - 1; i > -1; i--)
{
- if (frames[i] instanceof AlignFrame)
- {
- AlignFrame af = (AlignFrame) frames[i];
- af.alignPanel.alignmentChanged();
- }
+ frames[i].alignPanel.alignmentChanged();
}
} catch (Exception e)
{
VamsasAppDatastore vds = new VamsasAppDatastore(doc, vobj2jv, jv2vobj,
baseProvEntry(), alRedoState);
// wander through frames
- JInternalFrame[] frames = Desktop.getDesktopPane().getAllFrames();
+ AlignFrame[] frames = Desktop.getAlignFrames();
if (frames == null)
{
// REVERSE ORDER
for (int i = frames.length - 1; i > -1; i--)
{
- if (frames[i] instanceof AlignFrame)
- {
- AlignFrame af = (AlignFrame) frames[i];
+
+ AlignFrame af = frames[i];
if (!viewset.containsKey(af.getViewport().getSequenceSetId()))
{
// update alignment and root from frame.
viewset.put(af.getViewport().getSequenceSetId(), af);
}
}
- }
+
}
// REVERSE ORDER
// for (int i = frames.length - 1; i > -1; i--)
import jalview.json.binding.biojson.v1.ColourSchemeMapper;
import jalview.project.Jalview2XML;
import jalview.schemes.ColourSchemeI;
+import jalview.structure.StructureSelectionManager;
import jalview.util.MessageManager;
import jalview.util.Platform;
import jalview.ws.utils.UrlDownloadClient;
@Override
public void run()
{
+
+
String title = protocol == DataSourceType.PASTE
? "Copied From Clipboard"
: file;
format = new IdentifyFile().identify(source, false);
// identify stream and rewind rather than close
}
- else if (selectedFile != null) {
+ else if (selectedFile != null)
+ {
format = new IdentifyFile().identify(selectedFile, protocol);
}
else
}
return;
}
+
// TODO: cache any stream datasources as a temporary file (eg. PDBs
// retrieved via URL)
- if (Desktop.getDesktopPane() != null && Desktop.getDesktopPane().isShowMemoryUsage())
+ if (Desktop.getDesktopPane() != null
+ && Desktop.getDesktopPane().isShowMemoryUsage())
{
System.gc();
memused = (rt.maxMemory() - rt.totalMemory() + rt.freeMemory()); // free
}
// BH 2018 switch to File object here instead of filename
Platform.timeCheck(null, Platform.TIME_MARK);
- alignFrame = new Jalview2XML(raiseGUI).loadJalviewAlign(selectedFile == null ? file : selectedFile);
+ alignFrame = new Jalview2XML(raiseGUI).loadJalviewAlign(
+ selectedFile == null ? file : selectedFile);
Platform.timeCheck("JVP loaded", Platform.TIME_MARK);
}
file.lastIndexOf("."));
String tempStructureFileStr = createNamedJvTempFile(
urlLeafName, structExt);
-
+
// BH - switching to File object here so as to hold
// .秘bytes array directly
File tempFile = new File(tempStructureFileStr);
UrlDownloadClient.download(file, tempFile);
-
- al = fa.readFile(tempFile, DataSourceType.FILE,
- format);
+
+ al = fa.readFile(tempFile, DataSourceType.FILE, format);
source = fa.getAlignFile();
}
else
{
- if (selectedFile == null) {
+ if (selectedFile == null)
+ {
al = fa.readFile(file, protocol, format);
-
- } else {
+
+ }
+ else
+ {
al = fa.readFile(selectedFile, protocol, format);
- }
+ }
source = fa.getAlignFile(); // keep reference for later if
-
- // necessary.
+
+ // necessary.
}
}
} catch (java.io.IOException ex)
error = ex.getMessage();
}
+ System.out.println("OK1");
+
+
if ((al != null) && (al.getHeight() > 0) && al.hasValidSequence())
{
+
+
// construct and register dataset sequences
+
+ StructureSelectionManager ssm = StructureSelectionManager
+ .getStructureSelectionManager(Desktop.getInstance());
for (SequenceI sq : al.getSequences())
{
while (sq.getDatasetSequence() != null)
{
// register PDB entries with desktop's structure selection
// manager
- Desktop.getInstance().getStructureSelectionManager()
- .registerPDBEntry(pdbe);
+ ssm.registerPDBEntry(pdbe);
}
}
}
FeatureSettingsModelI proxyColourScheme = source
.getFeatureColourScheme();
+
if (viewport != null)
{
+
if (proxyColourScheme != null)
{
viewport.applyFeaturesStyle(proxyColourScheme);
}
else
{
+
+ System.out.println("OK9");
// otherwise construct the alignFrame
if (source instanceof ComplexAlignFile)
.getGlobalColourScheme();
FeaturesDisplayedI fd = ((ComplexAlignFile) source)
.getDisplayedFeatures();
+
alignFrame = new AlignFrame(al, hiddenSeqs, colSel,
AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
+
alignFrame.getViewport().setFeaturesDisplayed(fd);
alignFrame.getViewport().setShowSequenceFeatures(
((ComplexAlignFile) source).isShowSeqFeatures());
}
else
{
- alignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
- AlignFrame.DEFAULT_HEIGHT);
+
+ // Headless start fails here in Windows
+
+ // Sorry, no JInternalFrame when headless, at least in Windows.
+ // Not clear why that would be, since an InternalFrame is not a
+ // top-level component. But maybe it is
+
+ System.out.println("FileLoader test1");
+
+ try
+ {
+ //
+ alignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
+ AlignFrame.DEFAULT_HEIGHT);
+
+ System.out.println("FileLoader test2");
+
+ } catch (Throwable t)
+ {
+ System.out.println(t);
+ t.printStackTrace();
+ }
+
if (source instanceof FeaturesSourceI)
{
+
+ System.out.println("FileLoader test3");
+
alignFrame.getViewport().setShowSequenceFeatures(true);
}
}
// add metadata and update ui
+
+ System.out.println("FileLoader test4");
+
if (!(protocol == DataSourceType.PASTE))
{
+
+ System.out.println("FileLoader test5");
alignFrame.setFileName(file, format);
alignFrame.setFileObject(selectedFile); // BH 2018 SwingJS
}
+
+ System.out.println("FileLoader test6");
+
if (proxyColourScheme != null)
{
alignFrame.getViewport()
.applyFeaturesStyle(proxyColourScheme);
}
+
+ System.out.println("FileLoader test7");
+
alignFrame.setStatus(MessageManager.formatMessage(
"label.successfully_loaded_file", new String[]
{ title }));
+ System.out.println("FileLoader test8" + raiseGUI);
if (raiseGUI)
{
// add the window to the GUI
}
else
{
+
+ System.out.println("OK10");
+
if (Desktop.getInstance() != null)
{
Desktop.getInstance().stopLoading();
"label.couldnt_load_file") + " " + title + "\n" + error;
// TODO: refactor FileLoader to be independent of Desktop / Applet GUI
// bits ?
- if (raiseGUI && Desktop.getDesktopPane() != null)
+ if (raiseGUI)
{
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
@Override
public void run()
{
- JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
- errorMessage,
+ JvOptionPane.showInternalMessageDialog(
+ Desktop.getDesktopPane(), errorMessage,
MessageManager
.getString("label.error_loading_file"),
JvOptionPane.WARNING_MESSAGE);
}
}
+
updateRecentlyOpened();
} catch (Exception er)
}
loadtime += System.currentTimeMillis();
+
// TODO: Estimate percentage of memory used by a newly loaded alignment -
// warn if more memory will be needed to work with it
// System.gc();
// memory
// after
// load
- if (Desktop.getDesktopPane() != null && Desktop.getDesktopPane().isShowMemoryUsage())
+ if (Desktop.getDesktopPane() != null
+ && Desktop.getDesktopPane().isShowMemoryUsage())
{
if (alignFrame != null)
{
import java.awt.BorderLayout;
import java.awt.Color;
+import java.awt.Container;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import javax.swing.event.MenuListener;
@SuppressWarnings("serial")
-public class GAlignFrame extends JInternalFrame
+public abstract class GAlignFrame extends JPanel
{
+
+
+ protected abstract JInternalFrame getInternalFrame();
+
+ protected JInternalFrame iframe;
+
+ public JInternalFrame getIFrame()
+ {
+ return iframe;
+ }
+
protected JMenuBar alignFrameMenuBar = new JMenuBar();
protected JMenuItem closeMenuItem = new JMenuItem();
public GAlignFrame()
{
- try
- {
- // for Web-page embedding using id=align-frame-div
- setName(Jalview.getAppID("alignment"));
+ System.out.println("GAlignFrame init");
- jbInit();
- setJMenuBar(alignFrameMenuBar);
+ // for Web-page embedding using id=align-frame-div
+ setName(Jalview.getAppID("alignment"));
- // dynamically fill save as menu with available formats
- for (String ff : FileFormats.getInstance().getWritableFormats(true))
+ try
+ {
+ if (Jalview.isHeadlessMode())
+ {
+ jbInit();
+ }
+ else
{
- JMenuItem item = new JMenuItem(ff);
- item.addActionListener(new ActionListener()
+ iframe = getInternalFrame();
+ jbInit();
+ iframe.setJMenuBar(alignFrameMenuBar);
+ // dynamically fill save as menu with available formats
+ for (String ff : FileFormats.getInstance().getWritableFormats(true))
{
- @Override
- public void actionPerformed(ActionEvent e)
+ JMenuItem item = new JMenuItem(ff);
+
+ item.addActionListener(new ActionListener()
{
- outputText_actionPerformed(e.getActionCommand());
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ outputText_actionPerformed(e.getActionCommand());
+ }
+ });
+
+ outputTextboxMenu.add(item);
+
+ if (Platform.allowMnemonics()) // was "not mac and not JS"
+ {
+ closeMenuItem.setMnemonic('C');
+ outputTextboxMenu.setMnemonic('T');
+ undoMenuItem.setMnemonic('Z');
+ redoMenuItem.setMnemonic('0');
+ copy.setMnemonic('C');
+ cut.setMnemonic('U');
+ pasteMenu.setMnemonic('P');
+ reload.setMnemonic('R');
}
- });
- outputTextboxMenu.add(item);
+ }
+
}
} catch (Exception e)
{
System.err.println(e.toString());
}
- if (Platform.allowMnemonics()) // was "not mac and not JS"
- {
- closeMenuItem.setMnemonic('C');
- outputTextboxMenu.setMnemonic('T');
- undoMenuItem.setMnemonic('Z');
- redoMenuItem.setMnemonic('0');
- copy.setMnemonic('C');
- cut.setMnemonic('U');
- pasteMenu.setMnemonic('P');
- reload.setMnemonic('R');
- }
}
private void jbInit() throws Exception
pairwiseAlignmentMenuItem_actionPerformed(e);
}
});
+
- this.getContentPane().setLayout(new BorderLayout());
+ getContentPane().setLayout(new BorderLayout());
alignFrameMenuBar.setFont(new java.awt.Font("Verdana", 0, 11));
// statusBar.setBackground(Color.white); BH 2019.08.01 -- this does nothing,
// as the label is not opaque
addSequenceMenu.add(addFromFile);
addSequenceMenu.add(addFromText);
addSequenceMenu.add(addFromURL);
- this.getContentPane().add(statusPanel, java.awt.BorderLayout.SOUTH);
+ getContentPane().add(statusPanel, java.awt.BorderLayout.SOUTH);
statusPanel.add(statusBar, null);
- this.getContentPane().add(tabbedPane, java.awt.BorderLayout.CENTER);
+ getContentPane().add(tabbedPane, java.awt.BorderLayout.CENTER);
formatMenu.add(font);
formatMenu.addSeparator();
protected void showComplement_actionPerformed(boolean complement)
{
}
+
+ private JPanel headlessContentPane;
+
+ protected Container getContentPane()
+ {
+ if (iframe != null)
+ {
+ return iframe.getContentPane();
+ }
+ return (headlessContentPane == null
+ ? (headlessContentPane = new JPanel())
+ : headlessContentPane);
+ }
+
+ private String myTitle;
+
+ public void setTitle(String title)
+ {
+ myTitle = title;
+ if (iframe != null)
+ {
+ iframe.setTitle(title);
+ }
+ }
+
+ public String getTitle()
+ {
+ return myTitle;
+ }
}
*/
package jalview.jbgui;
+import jalview.bin.Jalview;
+
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
+import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.border.Border;
+import javax.swing.plaf.ScrollBarUI;
@SuppressWarnings("serial")
public class GAlignmentPanel extends JPanel
{
- protected JScrollBar vscroll = new JScrollBar();
+ protected JScrollBar vscroll;// = new JScrollBar();
- protected JScrollBar hscroll = new JScrollBar();
+ protected JScrollBar hscroll;// = new JScrollBar();
- BorderLayout borderLayout1 = new BorderLayout();
+ BorderLayout borderLayout1;// = new BorderLayout();
- BorderLayout borderLayout3 = new BorderLayout();
+ BorderLayout borderLayout3;// = new BorderLayout();
- BorderLayout borderLayout5 = new BorderLayout();
+ BorderLayout borderLayout5;// = new BorderLayout();
- BorderLayout borderLayout6 = new BorderLayout();
+ BorderLayout borderLayout6;// = new BorderLayout();
- ButtonGroup buttonGroup1 = new ButtonGroup();
+ ButtonGroup buttonGroup1;// = new ButtonGroup();
- BorderLayout borderLayout7 = new BorderLayout();
+ BorderLayout borderLayout7;// = new BorderLayout();
- BorderLayout borderLayout10 = new BorderLayout();
+ BorderLayout borderLayout10;// = new BorderLayout();
- BorderLayout borderLayout11 = new BorderLayout();
+ BorderLayout borderLayout11;// = new BorderLayout();
- public JScrollPane annotationScroller = new JScrollPane();
+ public JScrollPane annotationScroller;// = new JScrollPane();
Border border1;
- BorderLayout borderLayout4 = new BorderLayout();
+ BorderLayout borderLayout4;// = new BorderLayout();
static JPanel newJPanel() { // BH 2019
return p;
}
- protected JPanel sequenceHolderPanel = newJPanel();
- protected JPanel seqPanelHolder = newJPanel();
- protected JPanel scalePanelHolder = newJPanel();
- protected JPanel idPanelHolder = newJPanel();
- protected JPanel idSpaceFillerPanel1 = newJPanel();
- public JPanel annotationSpaceFillerHolder = newJPanel();
- protected JPanel hscrollFillerPanel = newJPanel();
- JPanel hscrollHolder = newJPanel();
+ static
+ {
+ System.out.println("GAP 1 static ");
+ }
+
+ protected JPanel sequenceHolderPanel;// = new JPanel();
+
+ protected JPanel seqPanelHolder;// = new JPanel();
+
+ protected JPanel scalePanelHolder;// = new JPanel();
+
+ protected JPanel idPanelHolder;// = new JPanel();
+
+ protected JPanel idSpaceFillerPanel1;// = new JPanel();
+ public JPanel annotationSpaceFillerHolder;// = new JPanel();
+
+ protected JPanel hscrollFillerPanel;// = new JPanel();
+
+ JPanel hscrollHolder;// = new JPanel();
+
+ static
+ {
+ System.out.println("GAP 2 static ");
+ }
public GAlignmentPanel()
{
+
+ System.out.println("GAP 3a");
+
+ System.out.println(Jalview.isHeadlessMode());
+
try
{
+ vscroll = newScrollBar();
+ } catch (Throwable t)
+ {
+ t.printStackTrace();
+ System.exit(1);
+ }
+
+ hscroll = newScrollBar();
+
+ System.out.println("GAP 3b");
+
+ borderLayout1 = new BorderLayout();
+
+ borderLayout3 = new BorderLayout();
+
+ borderLayout5 = new BorderLayout();
+
+ borderLayout6 = new BorderLayout();
+
+ buttonGroup1 = new ButtonGroup();
+
+ borderLayout7 = new BorderLayout();
+
+ borderLayout10 = new BorderLayout();
+
+ borderLayout11 = new BorderLayout();
+
+ System.out.println("GAP 3c");
+ annotationScroller = new JScrollPane() {
+
+ @Override
+ public void updateUI() {
+ System.out.println("JScrollPane updateUI");
+ }
+
+ @Override
+ public JScrollBar createVerticalScrollBar()
+ {
+ return newScrollBar();
+ }
+
+ @Override
+ public JScrollBar createHorizontalScrollBar()
+ {
+ return newScrollBar();
+ }
+
+
+ };
+ System.out.println("GAP 3d");
+
+ borderLayout4 = new BorderLayout();
+
+ System.out.println("GAP 3e");
+ sequenceHolderPanel = newJPanel();
+
+ seqPanelHolder = newJPanel();
+
+ scalePanelHolder = newJPanel();
+
+ idPanelHolder = newJPanel();
+
+ idSpaceFillerPanel1 = newJPanel();
+
+ annotationSpaceFillerHolder = newJPanel();
+
+ hscrollFillerPanel = newJPanel();
+
+ hscrollHolder = newJPanel();
+
+ System.out.println("GAP 3r");
+
+ try
+ {
+
+ System.out.println("GAP 3 ");
+
jbInit();
+
+ System.out.println("GAP 4 ");
+
} catch (Exception e)
{
e.printStackTrace();
}
}
+ private JScrollBar newScrollBar()
+ {
+ return new JScrollBar()
+ {
+
+ /**
+ * Overrides <code>JComponent.updateUI</code>.
+ *
+ * @see JComponent#updateUI
+ */
+ @Override
+ public void updateUI()
+ {
+
+ System.out.println("JScrollBar.updateUI");
+ setUI(new ScrollBarUI()
+ {
+
+ });
+ }
+
+ @Override
+ public void setUI(ScrollBarUI ui)
+ {
+ System.out.println("JScrollBar.setUI");
+ // setUI(ui);
+ }
+ };
+ }
+
private void jbInit() throws Exception
{
// annotationScroller.setBackground(Color.white); // BH 2019
*/
protected void addSplitPane()
{
- splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topFrame,
- bottomFrame);
+ splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topFrame.getIFrame(),
+ bottomFrame.getIFrame());
splitPane.setVisible(true);
/*
* set divider split at 50:50, or restore saved split if loading from
* project
*/
- int topFrameHeight = topFrame.getHeight();
+ int topFrameHeight = topFrame.getIFrame().getHeight();
splitPane.setDividerSize(DIVIDER_SIZE);
if (topFrameHeight == 0)
{
if (Platform.isAMacAndNotJS())
{
// this saves some space - but doesn't hide the title bar
- topFrame.putClientProperty("JInternalFrame.isPalette", true);
+ topFrame.getIFrame().putClientProperty("JInternalFrame.isPalette", true);
// topFrame.getRootPane().putClientProperty("Window.style", "small");
- bottomFrame.putClientProperty("JInternalFrame.isPalette", true);
+ bottomFrame.getIFrame().putClientProperty("JInternalFrame.isPalette",
+ true);
}
else
{
- ((BasicInternalFrameUI) topFrame.getUI()).setNorthPane(null);
- ((BasicInternalFrameUI) bottomFrame.getUI()).setNorthPane(null);
+ ((BasicInternalFrameUI) topFrame.getIFrame().getUI())
+ .setNorthPane(null);
+ ((BasicInternalFrameUI) bottomFrame.getIFrame().getUI())
+ .setNorthPane(null);
}
}
return classpath;
}
- private Worker getJalviewDesktopRunner(boolean withAwt, String cmd,
+ private Worker getJalviewDesktopRunner(boolean headless, String cmd,
int timeout)
{
// Note: JAL-3065 - don't include quotes for lib/* because the arguments are
// not expanded by the shell
String classpath = getClassPath();
String _cmd = "java "
- + (withAwt ? "-Djava.awt.headless=true" : "")
+ + (headless ? "-Djava.awt.headless=true" : "")
+ " -classpath " + classpath + " jalview.bin.Jalview ";
Process ls2_proc = null;
Worker worker = null;
+
+ System.out.println("Executing " + _cmd + cmd);
try
{
ls2_proc = Runtime.getRuntime().exec(_cmd + cmd);
} catch (Throwable e1)
{
e1.printStackTrace();
+
+ String path = "%Java_HOME%/bin/java " + _cmd + cmd;
+
+ try
+ {
+
+ ProcessBuilder builder = new ProcessBuilder(path);
+ builder.redirectErrorStream(true);
+ ls2_proc = builder.start();
+
+ } catch (IOException e)
+ {
+ String s = e.getMessage();
+ System.out.println(s);
+ }
+
}
if (ls2_proc != null)
{
return worker;
}
+ private void startProcess()
+ {
+
+
+ }
+
@BeforeTest(alwaysRun = true)
public void initialize()
{
@BeforeTest(alwaysRun = true)
public void setUpForCommandLineInputOperations() throws IOException
{
- String cmds = "-open examples/uniref50.fa -noquestionnaire -nousagestats";
+ String cmds = "headless -open examples/uniref50.fa -noquestionnaire -nousagestats";
Worker worker = getJalviewDesktopRunner(false, cmds, SETUP_TIMEOUT);
String ln = null;
int count = 0;
assertTrue(primaryDBRefs.isEmpty());
// empty dbrefs
- sq.setDBRefs(null);
+ sq.setDBRefs(null);
primaryDBRefs = sq.getPrimaryDBRefs();
assertTrue(primaryDBRefs.isEmpty());
// desktop
assertEquals(frames.length, 2,
"PCA and the tabbed alignment view should be the only two windows on the desktop");
- PCAPanel pcaPanel = (PCAPanel) frames[frames[0] == af ? 1 : 0];
+ PCAPanel pcaPanel = (PCAPanel) frames[frames[0] == af.getIFrame() ? 1
+ : 0];
AlignmentViewPanel restoredNewView = null;
for (AlignmentViewPanel alignpanel : Desktop.getAlignmentPanels(null))