Skip to content

Commit

Permalink
improves project files management (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
bowring authored May 24, 2017
1 parent 84b55e8 commit 105a006
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 13 deletions.
2 changes: 1 addition & 1 deletion common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ apply plugin: 'java'
apply plugin: 'maven'

String mavenGroupId = 'org.cirdles'
String mavenVersion = '0.0.3'
String mavenVersion = '0.0.4'


sourceCompatibility = '1.8'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,24 @@ private void launchProjectManager() {
private void newSquidProjectAction(ActionEvent event) {
squidProject = new SquidProject();

CalamariFileManager.initProjectFiles(squidProject.getPrawnFileHandler(), "1.4.5");
CalamariFileManager.initProjectFiles(squidProject.getPrawnFileHandler());

try {
if (squidProject.selectPrawnFile(primaryStageWindow)) {
launchProjectManager();
}
} catch (IOException | JAXBException | SAXException anException) {
String message = anException.getMessage();
if (message == null){
try {
message = anException.getCause().getMessage();
} catch (Exception e) {
}
}

SquidMessageDialog.showWarningDialog(
"Squid encountered an error while trying to open the selected file.",
"Squid encountered an error while trying to open the selected file:\n\n"
+ message,
primaryStageWindow);
}
}
Expand All @@ -158,15 +167,24 @@ private void newSquidProjectByMergeAction(ActionEvent event) {

squidProject = new SquidProject();

CalamariFileManager.initProjectFiles(squidProject.getPrawnFileHandler(), "1.4.5");
CalamariFileManager.initProjectFiles(squidProject.getPrawnFileHandler());

try {
if (squidProject.selectAndMergeTwoPrawnFile(primaryStageWindow)) {
launchProjectManager();
}
} catch (IOException | JAXBException | SAXException anException) {
String message = anException.getMessage();
if (message == null){
try {
message = anException.getCause().getMessage();
} catch (Exception e) {
}
}

SquidMessageDialog.showWarningDialog(
"Squid encountered an error while trying to open and join the selected files.",
"Squid encountered an error while trying to open and join the selected files:\n\n"
+ message,
primaryStageWindow);
}

Expand Down
2 changes: 1 addition & 1 deletion squidCore/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repositories {

dependencies {
compile "com.github.cirdles:Commons:-SNAPSHOT"
compile 'com.github.bowring.Calamari:core:v1.4.5'
compile 'com.github.bowring.Calamari:core:v1.4.8'

antlr "org.antlr:antlr4:4.6"
compile 'org.antlr:antlr4-runtime:4.6'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ public static void initExamplePrawnFiles() {
}
}

public static void initProjectFiles(PrawnFileHandler prawnFileHandler, String calamariVersion) {
public static void initProjectFiles(PrawnFileHandler prawnFileHandler) {
try {
// point to directory, but no default choice
prawnFileHandler.setCurrentPrawnFileLocation(exampleFolder.getCanonicalPath());
} catch (IOException iOException) {
}

File defaultCalamariReportsFolder = new File("CalamariReports_v" + calamariVersion);
File defaultCalamariReportsFolder = new File("CalamariReports_v" + PrawnFileHandler.VERSION);

prawnFileHandler.getReportsEngine()
.setFolderToWriteCalamariReports(defaultCalamariReportsFolder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,14 @@ public boolean selectPrawnFile(Window ownerWindow)
File prawnXMLFileNew = fileChooser.showOpenDialog(ownerWindow);

if (prawnXMLFileNew != null) {
retVal = true;
prawnXMLFile = prawnXMLFileNew;
updatePrawnFileHandlerWithFileLocation();
prawnFile = prawnFileHandler.unmarshallCurrentPrawnFileXML();
if (prawnXMLFileNew.getName().toLowerCase(Locale.US).endsWith(".xml")) {
retVal = true;
prawnXMLFile = prawnXMLFileNew;
updatePrawnFileHandlerWithFileLocation();
prawnFile = prawnFileHandler.unmarshallCurrentPrawnFileXML();
} else {
throw new IOException("Filename does not end with '.xml'");
}
}

return retVal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ public static Object GetSerializedObjectFromFile(String filename) {
"The file you are attempting to open does not exist:\n"
+ " " + filename, null);
}
} catch (IOException | ClassNotFoundException ex) {
} catch (IOException ex) {
SquidMessageDialog.showWarningDialog(
"The file you are attempting to open is not a valid '*.squid' file.", null);
} catch (ClassNotFoundException ex) {
SquidMessageDialog.showWarningDialog(
"The file you are attempting to open is not compatible with this version of Squid3.", null);
}
Expand Down

0 comments on commit 105a006

Please sign in to comment.