Skip to content

Commit

Permalink
fix several crashes, updated known formats
Browse files Browse the repository at this point in the history
- fix crash when trying to load 23MB document into textbox -> now test
how big it is, and don't do that ...
- fix crash when looking at description element without description
- added boatloads of format alternatives for SBML / SEDML and the like
...
  • Loading branch information
fbergmann committed Nov 2, 2014
1 parent c6b9102 commit 68c4915
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 13 deletions.
14 changes: 12 additions & 2 deletions FormsCombineArchive/ControlPlainTextEdit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,25 @@ public void Copy()
{
textBox1.Copy();
}

public void InitializeFromFile(string filename)
{
InitializeFrom(File.ReadAllText(filename), true);
FileName = filename;
var info = new FileInfo(filename);
if (info.Length > 1*1024*1024)
{
InitializeFrom("File is too big to be displayed");
}
else
{
InitializeFrom(File.ReadAllText(filename), true);
}
FileName = filename;
}

public void InitializeFrom(string content, bool saveVisible = false)
{
FileName = null;

textBox1.Text = content.Replace("\n", Environment.NewLine).Replace("\r\r", "\r");
menuStrip1.Visible = saveVisible;
}
Expand Down
2 changes: 1 addition & 1 deletion FormsCombineArchive/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ private void OnSelectionChanged(object sender, EventArgs e)
if (entry == null)
return;

if (entry.Description != null) lblMessage.Text = entry.Description.Description.Trim();
if (entry.Description != null && entry.Description.Description != null) lblMessage.Text = entry.Description.Description.Trim();

if (Entry.IsFormat("sbml",entry.Format) && controlSBWAnalyzer1.IsAvailable)
{
Expand Down
56 changes: 49 additions & 7 deletions LibCombine/Entry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,50 @@ public static Dictionary<string, string> KnownFormats
/// Dictionary of known formats so that they will be recognized among tools
/// </summary>
public static Dictionary<string, List<string>> KnownFormatsList = new Dictionary<string, List<string>> {
{"sbml", new List<string>{"http://identifiers.org/combine.specifications/sbml" } },
{"sbml", new List<string>{
"http://identifiers.org/combine.specifications/sbml",
"http://identifiers.org/combine.specifications/sbml.level-1.version-1",
"http://identifiers.org/combine.specifications/sbml.level-1.version-2",
"http://identifiers.org/combine.specifications/sbml.level-2.version-1",
"http://identifiers.org/combine.specifications/sbml.level-2.version-2",
"http://identifiers.org/combine.specifications/sbml.level-2.version-3",
"http://identifiers.org/combine.specifications/sbml.level-2.version-4",
"http://identifiers.org/combine.specifications/sbml.level-2.version-5",
"http://identifiers.org/combine.specifications/sbml.level-3.version-1",
"http://identifiers.org/combine.specifications/sbml.level-3.version-2",
"http://identifiers.org/combine.specifications/sbml.level-1.version.1",
"http://identifiers.org/combine.specifications/sbml.level-1.version.2",
"http://identifiers.org/combine.specifications/sbml.level-2.version.1",
"http://identifiers.org/combine.specifications/sbml.level-2.version.2",
"http://identifiers.org/combine.specifications/sbml.level-2.version.3",
"http://identifiers.org/combine.specifications/sbml.level-2.version.4",
"http://identifiers.org/combine.specifications/sbml.level-2.version.5",
"http://identifiers.org/combine.specifications/sbml.level-3.version.1",
"http://identifiers.org/combine.specifications/sbml.level-3.version.2",
} },
{"sedml", new List<string>
{
"http://identifiers.org/combine.specifications/sed-ml", "http://identifiers.org/combine.specifications/sedml"
"http://identifiers.org/combine.specifications/sed-ml",
"http://identifiers.org/combine.specifications/sedml",
"http://identifiers.org/combine.specifications/sed-ml.level-1.version-1",
"http://identifiers.org/combine.specifications/sed-ml.level-1.version-2",
"http://identifiers.org/combine.specifications/sed-ml.level-1.version-3"
}},
{"cellml", new List<string>{"http://identifiers.org/combine.specifications/cellml" }},
{"sed-ml", new List<string>
{
"http://identifiers.org/combine.specifications/sed-ml", "http://identifiers.org/combine.specifications/sedml"
"http://identifiers.org/combine.specifications/sed-ml",
"http://identifiers.org/combine.specifications/sedml",
"http://identifiers.org/combine.specifications/sed-ml.level-1.version-1",
"http://identifiers.org/combine.specifications/sed-ml.level-1.version-2",
"http://identifiers.org/combine.specifications/sed-ml.level-1.version-3"
}},
{"sbgn", new List<string>{"http://identifiers.org/combine.specifications/sbgn" }},
{"omex", new List<string>{"http://identifiers.org/combine.specifications/omex-metadata" }},
{"manifest", new List<string>{"http://identifiers.org/combine.specifications/omex-manifest" }},
{"omex", new List<string>{"http://identifiers.org/combine.specifications/omex-metadata"}},
{"manifest", new List<string>{
"http://identifiers.org/combine.specifications/omex-manifest",
"http://identifiers.org/combine.specifications/omex.version-1",
"http://identifiers.org/combine.specifications/omex"}},
{"sedx", new List<string>{"application/x-sed-ml-archive" }},
{"png", new List<string>{"image/png" }},
{"csv", new List<string>{"text/csv" }},
Expand Down Expand Up @@ -301,9 +332,20 @@ public static string GuessFormat(string fileName)

public static bool IsFormat(string formatKey, string format)
{
if (KnownFormats.ContainsKey(formatKey))
return KnownFormats[formatKey].Contains(format);
if (KnownFormatsList.ContainsKey(formatKey))
{
var knownFormats = KnownFormatsList[formatKey];
return knownFormats.Contains(format);
}


if (formatKey == "sbml" && format.StartsWith("http://identifiers.org/combine.specifications/sbml"))
return true;
if (formatKey == "sedml" && format.StartsWith("http://identifiers.org/combine.specifications/sed"))
return true;
if (formatKey == "sbgn" && format.StartsWith("http://identifiers.org/combine.specifications/sbgn"))
return true;

return false;

}
Expand Down
2 changes: 1 addition & 1 deletion NSIS_CombineArchive.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "COMBINE archive"
!define PRODUCT_VERSION "1.5"
!define PRODUCT_VERSION "1.6"
!define PRODUCT_PUBLISHER "Frank T. Bergmann"
!define PRODUCT_WEB_SITE "http://fbergmann.github.io/CombineArchive/"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\FormsCombineArchive.exe"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Frequently we are faced with project spanning more than just one file. Be it exp

<?xml version="1.0" encoding="utf-8"?>
<omexManifest xmlns="http://identifiers.org/combine.specifications/omex-manifest">
<content location="./manifest.xml" format="http://identifiers.org/combine.specifications/omex-manifest"/>
<content location="." format="http://identifiers.org/combine.specifications/omex-manifest"/>
<content location="./model/model.xml" format="http://identifiers.org/combine.specifications/sbml"/>
<content location="./simulation.xml" format="http://identifiers.org/combine.specifications/sedml"/>
<content location="./article.pdf" format="application/pdf"/>
Expand All @@ -148,7 +148,7 @@ This project uses the following third party libraries:
## License
This project is open source and freely available under the [Simplified BSD](http://opensource.org/licenses/BSD-2-Clause) license. Should that license not meet your needs, please contact me.

Copyright (c) 2013, Frank T. Bergmann
Copyright (c) 2013-2014, Frank T. Bergmann
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
Binary file added Samples/JanaWolf.omex
Binary file not shown.

0 comments on commit 68c4915

Please sign in to comment.