public class JalviewAppLoader
{
- private JalviewApp app;
+ private JalviewApp app; // Jalview or JalviewJS or JalviewLite
private boolean debug;
loadAnnotations();
loadJnetFile();
loadPdbFiles();
+ callInitCallback();
}
/**
* <param name="PDBfile3" value="1q0o Q45135_9MICO">
*/
- int pdbFileCount = 0;
// Accumulate pdbs here if they are heading for the same view (if
// alignPdbStructures is true)
Vector<Object[]> pdbs = new Vector<>();
.getSequencesArray())
: null;
+ int pdbFileCount = 0;
String param;
do
{
chains = tmp2.toArray(new String[tmp2.size()]);
}
}
+ pdb.setId(param);
ret[0] = param;
- DataSourceType protocol = resolveFileProtocol(app,
- ret);
+ DataSourceType protocol = resolveFileProtocol(app, ret);
// TODO check JAL-357 for files in a jar (CLASSLOADER)
pdb.setFile(ret[0]);
try
{
ret[0] = param;
- DataSourceType protocol = resolveFileProtocol(app,
- ret);
+ DataSourceType protocol = resolveFileProtocol(app, ret);
JPredFile predictions = new JPredFile(ret[0], protocol);
JnetAnnotationMaker.add_annotation(predictions,
app.getViewport().getAlignment(), 0, false);
// false == do not add sequence profile from concise output
app.getViewport().getAlignment().setupJPredAlignment();
- app.updateForLoader();
+ app.updateForAnnotations();
result = true;
} catch (Exception ex)
{
if (param != null)
{
ret[0] = param;
- DataSourceType protocol = resolveFileProtocol(app,
- ret);
+ DataSourceType protocol = resolveFileProtocol(app, ret);
param = ret[0];
if (new AnnotationFile().annotateAlignmentView(app.getViewport(),
param, protocol))
{
- app.updateForLoader();
+ app.updateForAnnotations();
result = true;
}
else
String param = app.getParameter("hidefeaturegroups");
if (param != null)
{
- app.setFeatureGroupState(
- separatorListToArray(param, separator), false);
+ app.setFeatureGroupState(separatorListToArray(param, separator),
+ false);
// app.setFeatureGroupStateOn(newAlignFrame, param, false);
}
// show specific groups
if (param != null)
{
ret[0] = param;
- DataSourceType protocol = resolveFileProtocol(app,
- ret);
+ DataSourceType protocol = resolveFileProtocol(app, ret);
- result = app.parseFeaturesFile(param, protocol);
+ result = app.parseFeaturesFile(ret[0], protocol);
}
param = app.getParameter("showFeatureSettings");
}
String[] ret = new String[1];
+
/**
* Load a tree for the alignment if specified by parameter. Returns true if a
* tree was loaded, else false.
{
if (debug)
{
- System.out.println("Tree parameter did not resolve to a valid tree.");
+ System.out.println(
+ "Tree parameter did not resolve to a valid tree.");
}
}
} catch (Exception ex)
codebase.length() - localfile.length()) + targetPath;
return resolvedPath;
}
-
+
/*
* get URL path and strip off any trailing file e.g.
* www.jalview.org/examples/index.html#applets?a=b is trimmed to
{
directoryPath = directoryPath.substring(0, lastSeparator + 1);
}
-
+
if (targetPath.startsWith("/"))
{
/*
{
resolvedPath = directoryPath + targetPath;
}
- if (JalviewLite.debug)
- {
- System.err.println(
- "resolveUrlForLocalOrAbsolute returning " + resolvedPath);
- }
+ // if (debug)
+ // {
+ // System.err.println(
+ // "resolveUrlForLocalOrAbsolute returning " + resolvedPath);
+ // }
return resolvedPath;
}
retPath[0] = path.substring(5);
return DataSourceType.PASTE;
}
-
+
/*
* is it a URL?
*/
{
return DataSourceType.URL;
}
-
+
/*
* try relative to document root
*/
URL documentBase = app.getDocumentBase();
- String withDocBase = resolveUrlForLocalOrAbsolute(path,
- documentBase);
+ String withDocBase = resolveUrlForLocalOrAbsolute(path, documentBase);
if (HttpUtils.isValidUrl(withDocBase))
{
// if (debug)
retPath[0] = withDocBase;
return DataSourceType.URL;
}
-
+
/*
* try relative to codebase (if different to document base)
*/
URL codeBase = app.getCodeBase();
- String withCodeBase = resolveUrlForLocalOrAbsolute(path,
- codeBase);
+ String withCodeBase = resolveUrlForLocalOrAbsolute(path, codeBase);
if (!withCodeBase.equals(withDocBase)
&& HttpUtils.isValidUrl(withCodeBase))
{
}
}
-}
+ public void callInitCallback()
+ {
+ String initjscallback = app.getParameter("oninit");
+ if (initjscallback == null)
+ {
+ return;
+ }
+ initjscallback = initjscallback.trim();
+ if (initjscallback.length() > 0)
+ {
+ // TODO
+ }
+ }
+
+ /**
+ * read sequence1...sequenceN as a raw alignment
+ *
+ * @param jalviewApp
+ * @return
+ */
+ public String getPastedSequence(JalviewApp jalviewApp)
+ {
+ StringBuffer data = new StringBuffer("PASTE");
+ int i = 1;
+ String file = null;
+ while ((file = app.getParameter("sequence" + i)) != null)
+ {
+ data.append(file.toString() + "\n");
+ i++;
+ }
+ if (data.length() > 5)
+ {
+ file = data.toString();
+ }
+ return file;
+ }
+
+ /**
+ * concatenate the list with separator
+ *
+ * @param list
+ * @param separator
+ * @return concatenated string
+ */
+ public static String arrayToSeparatorList(String[] list, String separator)
+ {
+ // TODO use StringUtils version
+ StringBuffer v = new StringBuffer();
+ if (list != null && list.length > 0)
+ {
+ for (int i = 0, iSize = list.length; i < iSize; i++)
+ {
+ if (list[i] != null)
+ {
+ if (i > 0)
+ {
+ v.append(separator);
+ }
+ v.append(list[i]);
+ }
+ }
+ // if (debug)
+ // {
+ // System.err
+ // .println("Returning '" + separator + "' separated List:\n");
+ // System.err.println(v);
+ // }
+ return v.toString();
+ }
+ // if (debug)
+ // {
+ // System.err.println(
+ // "Returning empty '" + separator + "' separated List\n");
+ // }
+ return "" + separator;
+ }
+
+ public String arrayToSeparatorList(String[] array)
+ {
+ return arrayToSeparatorList(array, separator);
+ }
+
+}
\ No newline at end of file