private Map<String, AlignFrame> afMap;
+ private Map<String, List<StructureViewer>> svMap;
+
private boolean commandArgsProvided = false;
private boolean argsWereParsed = false;
headless = h;
desktop = d;
afMap = new HashMap<>();
- if (argparser != null)
- {
- processArgs(argparser, headless);
- }
}
- private boolean processArgs(ArgParser argparser, boolean h)
+ protected boolean processArgs()
{
- argParser = argparser;
- headless = h;
+ if (argParser == null)
+ {
+ return true;
+ }
+
boolean theseArgsWereParsed = false;
if (argParser != null && argParser.getLinkedIds() != null)
{
ArgValuesMap avm = argParser.getLinkedArgs(id);
theseArgsWereParsed = true;
- theseArgsWereParsed &= processLinked(id);
+ boolean processLinkedOkay = processLinked(id);
+ theseArgsWereParsed &= processLinkedOkay;
+
processGroovyScript(id);
- boolean processLinkedOkay = theseArgsWereParsed;
// wait around until alignFrame isn't busy
AlignFrame af = afMap.get(id);
}
theseArgsWereParsed &= processImages(id);
+
if (processLinkedOkay)
+ {
theseArgsWereParsed &= processOutput(id);
+ }
// close ap
if (avm.getBoolean(Arg.CLOSE))
return argsWereParsed;
}
- protected boolean processUnlinked(String id)
- {
- return processLinked(id);
- }
-
protected boolean processLinked(String id)
{
boolean theseArgsWereParsed = false;
Console.warn("Exception whilst waiting for structure viewer "
+ structureFilepath, x);
}
+
+ // add StructureViewer to svMap list
+ if (svMap == null)
+ {
+ svMap = new HashMap<>();
+ }
+ if (svMap.get(id) == null)
+ {
+ svMap.put(id, new ArrayList<>());
+ }
+ svMap.get(id).add(sv);
+
Console.debug(
"Successfully opened viewer for " + structureFilepath);
String structureImageFilename = ArgParser.getValueFromSubValOrArg(
switch (StructureViewer.getViewerType())
{
case JMOL:
- try
- {
- Thread.sleep(1000); // WHY ???
- } catch (InterruptedException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
JalviewStructureDisplayI sview = sv
.getJalviewStructureDisplay();
if (sview instanceof AppJmol)
}
return seq;
}
+
+ public AlignFrame[] getAlignFrames()
+ {
+ AlignFrame[] afs = null;
+ if (afMap != null)
+ {
+ afs = (AlignFrame[]) afMap.values().toArray();
+ }
+
+ return afs;
+ }
+
+ public List<StructureViewer> getStructureViewers()
+ {
+ List<StructureViewer> svs = null;
+ if (svMap != null)
+ {
+ for (List<StructureViewer> svList : svMap.values())
+ {
+ if (svs == null)
+ {
+ svs = new ArrayList<>();
+ }
+ svs.addAll(svList);
+ }
+ }
+ return svs;
+ }
}
}
} catch (Exception e)
{
- e.printStackTrace();
+ Console.debugPrintStackTrace(e);
errors.add(e.getMessage());
continue;
}
{
errorMsg.append(error).append("\n");
}
- JvOptionPane.showMessageDialog(this, errorMsg.toString(),
- MessageManager.getString("label.pdb_web-service_error"),
- JvOptionPane.ERROR_MESSAGE);
+ if (!Jalview.isHeadlessMode())
+ {
+ JvOptionPane.showMessageDialog(this, errorMsg.toString(),
+ MessageManager.getString("label.pdb_web-service_error"),
+ JvOptionPane.ERROR_MESSAGE);
+ }
+ else
+ {
+ Console.error(
+ MessageManager.getString("label.pdb_web-service_error"));
+ Console.debug(errorMsg.toString());
+ }
}
}
}
} catch (Exception e)
{
- e.printStackTrace();
+ Console.debugPrintStackTrace(e);
errors.add(e.getMessage());
continue;
}
boolean superimpose = chk_superpose.isSelected();
theViewer.setSuperpose(superimpose);
+ // if we're running in --headless mode make this viewer synchronous
+ if (Jalview.isHeadlessMode())
+ {
+ theViewer.setAsync(false);
+ }
+
/*
* remember user's choice of superimpose or not
*/
// for moment, it will work fine as is because it is self-contained
String searchTerm = text.toLowerCase(Locale.ROOT);
searchTerm = searchTerm.split(":")[0];
- // jalview.bin.Console.outPrintln(">>>>> search term : " + searchTerm);
+ // jalview.bin.Console.outPrintln(">>>>> search term : " +
+ // searchTerm);
List<FTSDataColumnI> wantedFields = new ArrayList<>();
FTSRestRequest pdbRequest = new FTSRestRequest();
pdbRequest.setAllowEmptySeq(false);
import java.awt.Color;
import java.awt.Font;
-import java.awt.FontMetrics;
import java.awt.Rectangle;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
import jalview.bin.Console;
+import jalview.bin.Jalview;
import jalview.datamodel.AlignedCodonFrame;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
}
if (unresolved > 0)
{
- jalview.bin.Console.errPrintln("Jalview Project Import: There were " + unresolved
+ jalview.bin.Console.errPrintln("Jalview Project Import: There were "
+ + unresolved
+ " forward references left unresolved on the stack.");
}
if (failedtoresolve > 0)
* only view *should* be coped with sensibly.
*/
// This must have been loaded, is it still visible?
- JInternalFrame[] frames = Desktop.desktop.getAllFrames();
+ JInternalFrame[] frames = null;
+ if (Desktop.desktop != null)
+ {
+ frames = Desktop.desktop.getAllFrames();
+ }
+ else if (Jalview.isHeadlessMode()
+ && Jalview.getInstance().getCommands() != null)
+ {
+ // TODO
+ }
+ else
+ {
+ frames = null;
+ }
String matchedFile = null;
- for (int f = frames.length - 1; f > -1; f--)
+ if (frames != null)
{
- if (frames[f] instanceof StructureViewerBase)
+ for (int f = frames.length - 1; f > -1; f--)
{
- StructureViewerBase viewFrame = (StructureViewerBase) frames[f];
- matchedFile = saveStructureViewer(ap, jds, pdb, entry,
- viewIds, matchedFile, viewFrame);
- /*
- * Only store each structure viewer's state once in the project
- * jar. First time through only (storeDS==false)
- */
- String viewId = viewFrame.getViewId();
- String viewerType = viewFrame.getViewerType().toString();
- if (!storeDS && !viewIds.contains(viewId))
+ if (frames[f] instanceof StructureViewerBase)
{
- viewIds.add(viewId);
- File viewerState = viewFrame.saveSession();
- if (viewerState != null)
+ StructureViewerBase viewFrame = (StructureViewerBase) frames[f];
+ matchedFile = saveStructureViewer(ap, jds, pdb, entry,
+ viewIds, matchedFile, viewFrame);
+ /*
+ * Only store each structure viewer's state once in the project
+ * jar. First time through only (storeDS==false)
+ */
+ String viewId = viewFrame.getViewId();
+ String viewerType = viewFrame.getViewerType().toString();
+ if (!storeDS && !viewIds.contains(viewId))
{
- copyFileToJar(jout, viewerState.getPath(),
- getViewerJarEntryName(viewId), viewerType);
- }
- else
- {
- Console.error(
- "Failed to save viewer state for " + viewerType);
+ viewIds.add(viewId);
+ File viewerState = viewFrame.saveSession();
+ if (viewerState != null)
+ {
+ copyFileToJar(jout, viewerState.getPath(),
+ getViewerJarEntryName(viewId), viewerType);
+ }
+ else
+ {
+ Console.error("Failed to save viewer state for "
+ + viewerType);
+ }
}
}
}
return BitSet.valueOf(newlongvals);
}
+
private CalcIdParam createCalcIdParam(String calcId, AlignViewport av)
{
AutoCalcSetting settings = av.getCalcIdSettingsFor(calcId);
});
} catch (Exception x)
{
- jalview.bin.Console.errPrintln("Error loading alignment: " + x.getMessage());
+ jalview.bin.Console
+ .errPrintln("Error loading alignment: " + x.getMessage());
}
}
return af;
{
if (bytes != null)
{
- // jalview.bin.Console.outPrintln("Jalview2XML: opening byte jarInputStream for
+ // jalview.bin.Console.outPrintln("Jalview2XML: opening byte
+ // jarInputStream for
// bytes.length=" + bytes.length);
return new JarInputStream(new ByteArrayInputStream(bytes));
}
if (_url != null)
{
- // jalview.bin.Console.outPrintln("Jalview2XML: opening url jarInputStream for "
+ // jalview.bin.Console.outPrintln("Jalview2XML: opening url
+ // jarInputStream for "
// + _url);
return new JarInputStream(_url.openStream());
}
else
{
- // jalview.bin.Console.outPrintln("Jalview2XML: opening file jarInputStream for
+ // jalview.bin.Console.outPrintln("Jalview2XML: opening file
+ // jarInputStream for
// " + file);
return new JarInputStream(new FileInputStream(file));
}
"Exception whilst loading jalview XML file : " + ex + "\n");
} catch (Exception ex)
{
- jalview.bin.Console.errPrintln("Parsing as Jalview Version 2 file failed.");
+ jalview.bin.Console
+ .errPrintln("Parsing as Jalview Version 2 file failed.");
ex.printStackTrace(System.err);
if (attemptversion1parse)
{
{
// Don't use the OOM Window here
errorMessage = "Out of memory loading jalview XML file";
- jalview.bin.Console.errPrintln("Out of memory whilst loading jalview XML file");
+ jalview.bin.Console
+ .errPrintln("Out of memory whilst loading jalview XML file");
e.printStackTrace();
}
Desktop.addInternalFrame(af, view.getTitle(),
safeInt(view.getWidth()), safeInt(view.getHeight()));
af.setMenusForViewport();
- jalview.bin.Console.errPrintln("Failed to restore view " + view.getTitle()
- + " to split frame");
+ jalview.bin.Console.errPrintln("Failed to restore view "
+ + view.getTitle() + " to split frame");
}
}
}
else
{
- jalview.bin.Console.errPrintln("Problem loading Jalview file: " + errorMessage);
+ jalview.bin.Console.errPrintln(
+ "Problem loading Jalview file: " + errorMessage);
}
}
errorMessage = null;
{
if (tree.isColumnWise())
{
- AlignmentAnnotation aa = (AlignmentAnnotation) annotationIds
+ AlignmentAnnotation aa = annotationIds
.get(tree.getColumnReference());
if (aa == null)
{
}
if (matchedAnnotation == null)
{
- jalview.bin.Console.errPrintln("Failed to match annotation colour scheme for "
- + annotationId);
+ jalview.bin.Console
+ .errPrintln("Failed to match annotation colour scheme for "
+ + annotationId);
return null;
}
// belt-and-braces create a threshold line if the
}
else
{
- jalview.bin.Console.errPrintln("Malformed compound filter condition");
+ jalview.bin.Console
+ .errPrintln("Malformed compound filter condition");
}
}
}