Skip to content

Commit

Permalink
#62 (#66)
Browse files Browse the repository at this point in the history
* #29 ProgressIndicator in MainSceneController class

* #29 Tasks and ProgressIndicators work now

* Fix: Alert works again

* #62 resources can only be added once

Co-authored-by: Yawen Liu <[email protected]>
  • Loading branch information
jsobbe and Yawen Liu authored Dec 8, 2020
1 parent 4ab51de commit c48868d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/main/java/backend/TopicManagerImpl.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package backend;


import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
Expand Down Expand Up @@ -58,7 +59,9 @@ public class TopicManagerImpl implements TopicManager {
* @throws InvalidUriInputException if the provided resource is not specified in DBPedia
*/
@Override
public String addResourceToTopics(final String resourceUrl) throws InvalidUriInputException {
public String addResourceToTopics(final String resourceUrl) throws InvalidUriInputException, InvalidParameterException {
if(previousResources.contains(resourceUrl))
throw new InvalidParameterException("Cannot add a topic more than once.");
final Query constructSubjectQuery = QueryFactory.create(SPARQL_PREFIXES
+ "CONSTRUCT { <" + resourceUrl + "> ?p ?o . ?o rdf:type ?type }"
+ "WHERE { <" + resourceUrl + "> ?p ?o . "
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/ui/controller/MainSceneController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ui.controller;

import java.net.URL;
import java.security.InvalidParameterException;
import java.util.List;
import java.util.ResourceBundle;

Expand Down Expand Up @@ -136,14 +137,14 @@ public void setResult(String s) {
this.acceptedTopicList.addTopic(info);
});

} catch (InvalidUriInputException e) {
} catch (InvalidUriInputException | InvalidParameterException e) {
Platform.runLater(() -> {
Alert a = new Alert(Alert.AlertType.ERROR,
"If you have trouble entering a topic, check its Wikipedia-Url and copy everything after 'https://en.wikipedia.org/wiki/'.");
a.initStyle(StageStyle.UNIFIED);
a.getDialogPane().getStylesheets()
.add(SWTApplication.class.getResource("/css/general.css").toExternalForm());
a.setHeaderText("The resource could not be found. ");
a.setHeaderText(e.getMessage());
a.showAndWait();
});
}
Expand Down

0 comments on commit c48868d

Please sign in to comment.