diff --git a/.gitignore b/.gitignore index 4801179..762fb53 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /.project /.settings/ **/nbactions.xml +**/nb-configuration.xml diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..7159faa --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,117 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] +### `scitos` +#### Added +- capability to generate basic macOS `.app` bundle alternative for future releases + +#### Changed +- BREAKING CHANGE: Minimum Java version is now `9` (and no longer `8`)! + +#### Fixed +- show error if closing of connection to saved file encounters one +- re-instate macOS specific handlers for About/Preferences/Quit actions (necessitated by changes in Java 9) + +## [2.3.1] - 2020-03-09 +### `scitos-ais` +#### Fixed +- improve error handling for import of interviews from ODS spreadsheet #29 + +## [2.3.0] - 2020-03-08 +### `scitos` +#### Changed +- BREAKING CHANGE: Minimum Java version is now `8` (and no longer `6`)! + +### `scitos-ais` +#### Added +- allow importing multiple unscored interviews at once from an ODS spreadsheet + +## [2.2.0] - 2017-09-27 +### `scitos-hmx` +#### Added +- allow showing both translations (syntactical/semantical) at the same time #16 +- single analysis view with toggles for showing/hiding separate parts #17 + +#### Fixed +- translation in SVG export of semantical analysis #11 +- data loss in specific situation for "Split Proposition" action #21 + +## [2.1.0] - 2017-09-15 +### `scitos-hmx` +#### Added +- offering new menu items for hiding the proposition labels and translations, allowing you to focus on the analysis part at hand (and to cater for uses of HermeneutiX where one of those fields is not being used) #9 + +#### Changed +- If the translation fields are hidden, the height of each displayed proposition is reduced. Therefore, more propositions can be shown at once. In case of the Semantical Analysis this also required a slight change in the way how the roles within relations are being displayed, in order to fit into the smaller available space. +The SVG export however is not affected by these changes. Labels and translations are still always included there. + +#### Fixed +- now enabling the usage of undo/redo also on the Analysis view (and not just on the initial Text Input view) #7 + +## [2.0.0] - 2016-07-29 +### `scitos-hmx` (HermeneutiX) +#### Added +- new Module – a graphical tool for syntactic and semantic structure analysis of complex (foreign language) texts with a number of changes in comparison to the standalone HermeneutiX v1.12. #4 +- configurability of available relations for Semantical Analysis: assignable roles in relations +- configurability of available origin languages for Syntactical Analysis including the assignable functions for Clause Items and Propositions +- allow saving of project in text input mode +- new more self-contained file structure for saving +- maintaining backwards compatible opening of old file structure +- allow project creation without requiring a target file path + +#### Fixed +- various (minor) bug fixes, in comparison to the standalone predecessor HermeneutiX v1.12 + +### `scitos-ais` +#### Fixed +- for some cases when assigning a detail category to tokens that already have a specific constellation of detail categories assigned to them + +## [1.2.0] - 2015-09-14 +### `scitos` +#### Added +- allow specific setting of the UI translation via the 'Preferences' dialog. +- increasing/decreasing the global content font size via the new 'View' menu. #2 +- hide/show project tree via the new 'View' menu, to maximize usable space. #3 + +### `scitos-ais` +#### Changed +- added the result table Spreadsheet export to the 'File' > 'Export' menu entry. + +#### Fixed +- adjust width of result table columns to fit their contents, enabling a horizontal scroll bar if necessary. #5 +- added missing error message, for the 'selected Project file is already open' case. + +## [1.1.0] - 2015-09-06 +### `scitos-ais` +#### Added +- 'Export' entry in the 'File' menu, allowing the generation of a HTML representation, which can be displayed in any modern browser out-of-the-box. + +## [1.0.0] - 2015-09-04 +### `scitos` +#### Added +- General framework for adding different types of tools with some common/shared (technical) features + +### `scitos-ais` (Autobiographical Interview Scoring +#### Added +- Scoring via mouse and/or keyboard short cuts +- Use of a configurable category model (i.e. specific aspects of internal and external details) +- Automatic tallying +- Result export to ODS Spreadsheet +- XML based file format, that can also be viewed in modern Web Browsers (and printed there) + - Firefox does this out-of-the-box, + - other browsers (e.g. Chrome) might prevent this by default for local files (for security reasons), as this feature is realised via an embedded XSLT stylesheet (i.e. a script) + + +[Unreleased]: https://github.com/scientific-tool-set/scitos/compare/v2.3.1...HEAD +[2.3.1]: https://github.com/scientific-tool-set/scitos/compare/v2.3.0...v2.3.1 +[2.3.0]: https://github.com/scientific-tool-set/scitos/compare/v2.2.0...v2.3.0 +[2.2.0]: https://github.com/scientific-tool-set/scitos/compare/v2.1.0...v2.2.0 +[2.1.0]: https://github.com/scientific-tool-set/scitos/compare/v2.0.0...v2.1.0 +[2.0.0]: https://github.com/scientific-tool-set/scitos/compare/v1.2.0...v2.0.0 +[1.2.0]: https://github.com/scientific-tool-set/scitos/compare/v1.1.0...v1.2.0 +[1.1.0]: https://github.com/scientific-tool-set/scitos/compare/v1.0.0...v1.1.0 +[1.0.0]: https://github.com/scientific-tool-set/scitos/releases/tag/v1.0.0 diff --git a/README.md b/README.md index 0ef6dcb..dbcfed4 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ Input of any kind is appreciated. --- +## Modules ### 1. AIS – Autobiographical Interview Scoring #### 1.1 Background Autobiographical Interviews (AI) are a method to tease apart the forms of memory that contribute to a participant's description of a remembered past event. @@ -69,3 +70,15 @@ The main advantage of the newer/ported version - besides better test coverage an - Adding/Changing/Rearranging/Removing selectable **syntactical functions**. - Adding/Changing/Rearranging/Removing selectable **semantical relations**. - The applied origin text language (including the associated syntactical functions) is being stored as part of a .hmx save file and therefore portable. + +--- + +## F.A.Q. +### 1. How to exchange configurations? +When using the `scitos.jar` directly, you can find various `.xml` files beside it (generated once the respective configuration was made). +Those files contain all the configurations made inside the application (through the "Preferences" menu) and can simply be copy-pasted. + +### 2. Where are the configuration files in the macOS `SciToS.app`? +In case of macOS, you have to right-click on the `SciToS.app` and select "Show Package Contents". +In there, you'll find the configuration files under `Contents/Resources/`. +The configuration files between the two distributions are the same, i.e. they can be shared regardless of the operating system. diff --git a/pom.xml b/pom.xml index c32b5f2..fcadfa8 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.hmx scitos - 2.3.1 + 2.4.0-SNAPSHOT pom scitos parent project of SciToS @@ -27,11 +27,11 @@ scm:git:ssh://git@github.com/scientific-tool-set/scitos.git scm:git:ssh://git@github.com/scientific-tool-set/scitos.git https://github.com/scientific-tool-set/scitos - v2.3.1 + HEAD - 2.3.1 + 2.4.0-SNAPSHOT UTF-8 @@ -41,8 +41,8 @@ maven-compiler-plugin 3.8.1 - 1.8 - 1.8 + 1.9 + 1.9 diff --git a/scitos.ais/pom.xml b/scitos.ais/pom.xml index 8ff9143..df3cc8b 100644 --- a/scitos.ais/pom.xml +++ b/scitos.ais/pom.xml @@ -3,7 +3,7 @@ org.hmx scitos - 2.3.1 + 2.4.0-SNAPSHOT scitos.ais pom diff --git a/scitos.ais/scitos.ais.core/pom.xml b/scitos.ais/scitos.ais.core/pom.xml index 975ab81..f35fa94 100644 --- a/scitos.ais/scitos.ais.core/pom.xml +++ b/scitos.ais/scitos.ais.core/pom.xml @@ -3,7 +3,7 @@ org.hmx scitos.ais - 2.3.1 + 2.4.0-SNAPSHOT scitos.ais.core scitos.ais.core diff --git a/scitos.ais/scitos.ais.core/src/main/java/org/hmx/scitos/ais/core/ModelHandlerImpl.java b/scitos.ais/scitos.ais.core/src/main/java/org/hmx/scitos/ais/core/ModelHandlerImpl.java index 55e4463..fd56ee2 100644 --- a/scitos.ais/scitos.ais.core/src/main/java/org/hmx/scitos/ais/core/ModelHandlerImpl.java +++ b/scitos.ais/scitos.ais.core/src/main/java/org/hmx/scitos/ais/core/ModelHandlerImpl.java @@ -752,7 +752,7 @@ public Map, AtomicLong>> extractDetailPatter AtomicLong currentValue = patternOccurences.get(singlePattern); if (currentValue == null) { currentValue = new AtomicLong(0); - patternOccurences.put(new ArrayList(singlePattern), currentValue); + patternOccurences.put(new ArrayList<>(singlePattern), currentValue); } // increase counter for the correct sized pattern by one currentValue.incrementAndGet(); diff --git a/scitos.ais/scitos.ais.core/src/main/java/org/hmx/scitos/ais/core/ModelParseServiceImpl.java b/scitos.ais/scitos.ais.core/src/main/java/org/hmx/scitos/ais/core/ModelParseServiceImpl.java index 020eed6..61fd7a4 100644 --- a/scitos.ais/scitos.ais.core/src/main/java/org/hmx/scitos/ais/core/ModelParseServiceImpl.java +++ b/scitos.ais/scitos.ais.core/src/main/java/org/hmx/scitos/ais/core/ModelParseServiceImpl.java @@ -121,7 +121,7 @@ public Document parseXmlFromModel(final IModel model, final List openViewE doc.getDocumentElement().appendChild(this.parseXmlFromDetailCategories(doc, project)); // include scored interviews final Element interviewRoot = doc.createElementNS(ModelParseServiceImpl.NAMESPACE, ModelParseServiceImpl.TAG_INTERVIEW_ROOT); - final List interviews = new ArrayList(project.getInterviews()); + final List interviews = new ArrayList<>(project.getInterviews()); // add interviews in sorted order - just for a user who opens the file in a text editor Collections.sort(interviews); for (final Interview singleInterview : interviews) { @@ -188,13 +188,13 @@ public Entry> parseModelFromXml(final Document doc, final Fi // retrieve interviews from document final Element interviewRoot = DomUtil.getChildElement(doc.getDocumentElement(), ModelParseServiceImpl.TAG_INTERVIEW_ROOT); if (interviewRoot != null) { - final List containedInterviews = new LinkedList(); + final List containedInterviews = new LinkedList<>(); for (final Element singleInterview : DomUtil.getChildElements(interviewRoot, ModelParseServiceImpl.TAG_INTERVIEW)) { containedInterviews.add(this.parseInterviewFromXml(singleInterview, categories)); } project.setInterviews(containedInterviews); } - return new SimpleEntry>(project, this.parseOpenViewElementsFromXml(doc, project)); + return new SimpleEntry<>(project, this.parseOpenViewElementsFromXml(doc, project)); } /** @@ -287,7 +287,7 @@ MutableDetailCategoryModel parseDetailCategoriesFromXml(final Document doc) thro */ private List parseDetailCategoriesFromXmlRecursively(final List categories, final DetailCategory parentCategory) throws HmxException { - final List result = new LinkedList(); + final List result = new LinkedList<>(); for (final Element singleCategoryElement : categories) { // parse mandatory category attributes final String code = singleCategoryElement.getAttribute(ModelParseServiceImpl.ATTR_CATEGORY_CODE); @@ -421,7 +421,7 @@ private Entry parseXmlFromTokenRange(final Document doc, fin // include last token of this range detailElement.appendChild(this.parseXmlFromTokenText(doc, currentToken)); // return create wrapper element (including its tokens) and the token where to continue the parsing - return new SimpleEntry(detailElement, currentToken.getFollowingToken()); + return new SimpleEntry<>(detailElement, currentToken.getFollowingToken()); } /** @@ -458,7 +458,7 @@ private Interview parseInterviewFromXml(final Element interviewElement, final Mu throw new HmxException(Message.ERROR_FILE_INVALID, new IllegalArgumentException("invalid " + ModelParseServiceImpl.TAG_INTERVIEW + " definition")); } - final List text = new LinkedList(); + final List text = new LinkedList<>(); for (final Element singleParagraph : DomUtil.getChildElements(interviewElement, ModelParseServiceImpl.TAG_INTERVIEW_PARAGRAPH)) { text.add(this.parseTextParagraphFromXml(singleParagraph, categories)); } @@ -556,7 +556,7 @@ private Element parseXmlFromOpenViewElements(final Document doc, final List o * @return successfully parsed list of model elements that were open in the view, when the document was created */ private List parseOpenViewElementsFromXml(final Document doc, final AisProject parsedProject) { - final List openViewElements = new LinkedList(); + final List openViewElements = new LinkedList<>(); final Element viewsRoot = DomUtil.getChildElement(doc.getDocumentElement(), ModelParseServiceImpl.TAG_VIEWS); if (viewsRoot != null) { for (final Element singleView : DomUtil.getChildElements(viewsRoot)) { diff --git a/scitos.ais/scitos.ais.core/src/test/java/org/hmx/scitos/ais/core/ModelHandlerTest.java b/scitos.ais/scitos.ais.core/src/test/java/org/hmx/scitos/ais/core/ModelHandlerTest.java index c797a41..05477d3 100644 --- a/scitos.ais/scitos.ais.core/src/test/java/org/hmx/scitos/ais/core/ModelHandlerTest.java +++ b/scitos.ais/scitos.ais.core/src/test/java/org/hmx/scitos/ais/core/ModelHandlerTest.java @@ -137,7 +137,7 @@ public void testReplaceCategoryModel() throws HmxException { this.assertTokenState(text.get(10), true, oldSelectableCategories.get(3), true); this.assertTokenState(text.get(11), true, null, false); final MutableDetailCategoryModel newModel = new MutableDetailCategoryModel(); - final Map mappedOldToNew = new HashMap(); + final Map mappedOldToNew = new HashMap<>(); final DetailCategory firstCategory = new DetailCategory(null, "A", "Category A", true, Color.BLACK, null); final DetailCategory parent = new DetailCategory(null, "B", "Parent", false, Color.BLUE, null); final DetailCategory secondCategory = new DetailCategory(parent, "C", "", true, null, KeyStroke.getKeyStroke(KeyEvent.VK_C, 0, true)); @@ -1125,7 +1125,7 @@ private void assertTokenState(final TextToken token, final boolean firstOfDetail * @return list of all following tokens (including given start token) */ private List getFlatTokenList(final TextToken startToken) { - final List list = new ArrayList(20); + final List list = new ArrayList<>(20); TextToken currentToken = startToken; do { list.add(currentToken); @@ -1265,7 +1265,7 @@ public void testExtractDetailSequence() throws HmxException { final DetailCategory thirdDetail = selectables.get(2); final DetailCategory fourthDetail = selectables.get(3); final List text = this.getFlatTokenList(this.paragraphStartToken); - final List expectedSequence = new ArrayList(11); + final List expectedSequence = new ArrayList<>(11); this.modelHandler.assignDetailCategory(this.interview, text.subList(1, 4), firstDetail); expectedSequence.add(firstDetail); this.modelHandler.assignDetailCategory(this.interview, text.subList(5, 6), secondDetail); @@ -1306,7 +1306,7 @@ public void testValidateEquality_1() { @Test public void testValidateEquality_2() { final AisProject clone = this.project.clone(); - final List categories = new ArrayList(this.project.provide()); + final List categories = new ArrayList<>(this.project.provide()); categories.remove(categories.size() - 1); this.modelHandler.replaceCategoryModel(new MutableDetailCategoryModel().reset(categories), Collections.emptyMap()); diff --git a/scitos.ais/scitos.ais.core/src/test/java/org/hmx/scitos/ais/core/ModelParseServiceTest.java b/scitos.ais/scitos.ais.core/src/test/java/org/hmx/scitos/ais/core/ModelParseServiceTest.java index 60b1987..0f2b9b0 100644 --- a/scitos.ais/scitos.ais.core/src/test/java/org/hmx/scitos/ais/core/ModelParseServiceTest.java +++ b/scitos.ais/scitos.ais.core/src/test/java/org/hmx/scitos/ais/core/ModelParseServiceTest.java @@ -67,7 +67,7 @@ public void testParseModelToAndFromXml_1() throws HmxException { modelHandler.setInterviewText(modelHandler.createInterview("a"), "1 2 3\n4 5 6 7 8 9\n10"); modelHandler.createInterview("b"); // all interview views open, and a sub model group - final List openViewElements = new LinkedList(model.getInterviews()); + final List openViewElements = new LinkedList<>(model.getInterviews()); openViewElements.add("a"); final Document xml = this.service.parseXmlFromModel(model, openViewElements); final Entry> parsed = this.service.parseModelFromXml(xml, new File("test.aisp")); diff --git a/scitos.ais/scitos.ais.core/src/test/java/org/hmx/scitos/ais/core/i18n/AisMessageTest.java b/scitos.ais/scitos.ais.core/src/test/java/org/hmx/scitos/ais/core/i18n/AisMessageTest.java index aa3a22b..83a344f 100644 --- a/scitos.ais/scitos.ais.core/src/test/java/org/hmx/scitos/ais/core/i18n/AisMessageTest.java +++ b/scitos.ais/scitos.ais.core/src/test/java/org/hmx/scitos/ais/core/i18n/AisMessageTest.java @@ -25,8 +25,8 @@ public class AisMessageTest { public void testMessageAvailability() { final ResourceBundle bundle = ResourceBundle.getBundle(AisMessage.class.getName(), Locale.ENGLISH, new XmlResourceBundleControl()); Assert.assertNotNull(bundle); - final List unusedMessages = new LinkedList(); - final List unavailableMessages = new LinkedList(); + final List unusedMessages = new LinkedList<>(); + final List unavailableMessages = new LinkedList<>(); final Enumeration availableKeys = bundle.getKeys(); while (availableKeys.hasMoreElements()) { unusedMessages.add(availableKeys.nextElement()); diff --git a/scitos.ais/scitos.ais.domain/pom.xml b/scitos.ais/scitos.ais.domain/pom.xml index 7d4d097..69fb782 100644 --- a/scitos.ais/scitos.ais.domain/pom.xml +++ b/scitos.ais/scitos.ais.domain/pom.xml @@ -3,7 +3,7 @@ org.hmx scitos.ais - 2.3.1 + 2.4.0-SNAPSHOT scitos.ais.domain domain project of the SciToS module AIS diff --git a/scitos.ais/scitos.ais.domain/src/main/java/org/hmx/scitos/ais/domain/model/AisProject.java b/scitos.ais/scitos.ais.domain/src/main/java/org/hmx/scitos/ais/domain/model/AisProject.java index 9666c8f..c95d530 100644 --- a/scitos.ais/scitos.ais.domain/src/main/java/org/hmx/scitos/ais/domain/model/AisProject.java +++ b/scitos.ais/scitos.ais.domain/src/main/java/org/hmx/scitos/ais/domain/model/AisProject.java @@ -40,7 +40,7 @@ public final class AisProject implements IMultiObjectModel categories; /** The contained interviews. */ - private final List interviews = new LinkedList(); + private final List interviews = new LinkedList<>(); /** * Main constructor. @@ -52,7 +52,7 @@ public final class AisProject implements IMultiObjectModel categories) { this.setLabel(label); - this.categories = new ArrayList(categories); + this.categories = new ArrayList<>(categories); } /** @@ -120,8 +120,8 @@ public String getGroupKey(final Object interview) { @Override public Map> getSubModelObjects() { - final Map> subModelMap = new HashMap>(); - final List sortedInterviews = new ArrayList(this.interviews); + final Map> subModelMap = new HashMap<>(); + final List sortedInterviews = new ArrayList<>(this.interviews); Collections.sort(sortedInterviews); for (final Interview singleInterview : sortedInterviews) { final String groupKey = this.getGroupKey(singleInterview); @@ -129,7 +129,7 @@ public Map> getSubModelObjects() { if (subModelMap.containsKey(groupKey)) { groupedInterviews = subModelMap.get(groupKey); } else { - groupedInterviews = new LinkedList(); + groupedInterviews = new LinkedList<>(); subModelMap.put(groupKey, groupedInterviews); } groupedInterviews.add(singleInterview); @@ -144,7 +144,7 @@ public List provide() { @Override public List provideSelectables() { - final List selectables = new LinkedList(); + final List selectables = new LinkedList<>(); for (final DetailCategory singleCategory : this.categories) { if (singleCategory.isSelectable()) { selectables.add(singleCategory); @@ -155,7 +155,7 @@ public List provideSelectables() { @Override public AisProject clone() { - final List clonedInterviews = new LinkedList(); + final List clonedInterviews = new LinkedList<>(); for (final Interview singleInterview : this.getInterviews()) { clonedInterviews.add(singleInterview.clone()); } diff --git a/scitos.ais/scitos.ais.domain/src/main/java/org/hmx/scitos/ais/domain/model/Interview.java b/scitos.ais/scitos.ais.domain/src/main/java/org/hmx/scitos/ais/domain/model/Interview.java index 401da0c..39d78f8 100644 --- a/scitos.ais/scitos.ais.domain/src/main/java/org/hmx/scitos/ais/domain/model/Interview.java +++ b/scitos.ais/scitos.ais.domain/src/main/java/org/hmx/scitos/ais/domain/model/Interview.java @@ -36,7 +36,7 @@ public final class Interview implements IModel, Comparable /** The index (i.e. number) of this interview in the project containing it. */ private int index; /** The actual interview including assigned details (i.e. applied scoring). */ - private final List text = new LinkedList(); + private final List text = new LinkedList<>(); /** * Main constructor. @@ -127,7 +127,7 @@ public Interview setText(final List text) { public Interview reset(final Interview replacingState) { this.setParticipantId(replacingState.getParticipantId()); this.setIndex(replacingState.getIndex()); - final List copiedParagraphs = new LinkedList(); + final List copiedParagraphs = new LinkedList<>(); for (final TextToken singleParagraph : replacingState.getText()) { copiedParagraphs.add(singleParagraph.clone()); } diff --git a/scitos.ais/scitos.ais.domain/src/main/java/org/hmx/scitos/ais/domain/model/MutableDetailCategoryModel.java b/scitos.ais/scitos.ais.domain/src/main/java/org/hmx/scitos/ais/domain/model/MutableDetailCategoryModel.java index ccbff3b..14a5d03 100644 --- a/scitos.ais/scitos.ais.domain/src/main/java/org/hmx/scitos/ais/domain/model/MutableDetailCategoryModel.java +++ b/scitos.ais/scitos.ais.domain/src/main/java/org/hmx/scitos/ais/domain/model/MutableDetailCategoryModel.java @@ -40,7 +40,7 @@ public class MutableDetailCategoryModel implements IDetailCategoryProvider { /** Main constructor: initializes an empty category model. */ public MutableDetailCategoryModel() { - this.categoryByCode = new LinkedHashMap(); + this.categoryByCode = new LinkedHashMap<>(); } /** @@ -89,12 +89,12 @@ public MutableDetailCategoryModel reset(final List categories) { */ @Override public List provide() { - return new ArrayList(this.categoryByCode.values()); + return new ArrayList<>(this.categoryByCode.values()); } @Override public List provideSelectables() { - final List selectables = new LinkedList(); + final List selectables = new LinkedList<>(); for (final DetailCategory singleCategory : this.categoryByCode.values()) { if (singleCategory.isSelectable()) { selectables.add(singleCategory); @@ -120,7 +120,7 @@ public List getRootCategories() { * @return detail category that have the given one as their parent */ public List getChildCategories(final DetailCategory parent) { - final List children = new LinkedList(); + final List children = new LinkedList<>(); for (final DetailCategory singleCategory : this.categoryByCode.values()) { if (ComparisonUtil.isNullAwareEqual(singleCategory.getParent(), parent)) { children.add(singleCategory); diff --git a/scitos.ais/scitos.ais.view/pom.xml b/scitos.ais/scitos.ais.view/pom.xml index e93a7a8..eff2eb1 100644 --- a/scitos.ais/scitos.ais.view/pom.xml +++ b/scitos.ais/scitos.ais.view/pom.xml @@ -3,7 +3,7 @@ org.hmx scitos.ais - 2.3.1 + 2.4.0-SNAPSHOT scitos.ais.view scitos.ais.view diff --git a/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/CategoryModelChangeDialog.java b/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/CategoryModelChangeDialog.java index af5855b..4b7a0f1 100644 --- a/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/CategoryModelChangeDialog.java +++ b/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/CategoryModelChangeDialog.java @@ -135,7 +135,7 @@ void okButtonPressed() { final Map> detailsInUse = this.modelHandler.countDetailOccurrences(this.modelHandler.getModel().getInterviews()); // sum up and ignore unused detail categories - final Map oldDetailOccurences = new HashMap(); + final Map oldDetailOccurences = new HashMap<>(); for (final Map singleInterviewDetails : detailsInUse.values()) { for (final Entry singleOldDetailCount : singleInterviewDetails.entrySet()) { if (singleOldDetailCount.getKey().isSelectable() && singleOldDetailCount.getValue().get() > 0) { @@ -257,7 +257,7 @@ private class CategoryModelMatchSubDialog extends JDialog { final Border rightColumnBorder = BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(1, 1, 0, 0, Color.BLACK), BorderFactory.createEmptyBorder(1, 10, 1, 10)); - this.mapping = new HashMap(); + this.mapping = new HashMap<>(); for (final Entry singleEntry : oldDetailOccurences.entrySet()) { constraints.gridy++; constraints.gridx = 0; diff --git a/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/DetailCategoryTreeModel.java b/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/DetailCategoryTreeModel.java index 507a425..132e6cf 100644 --- a/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/DetailCategoryTreeModel.java +++ b/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/DetailCategoryTreeModel.java @@ -61,8 +61,8 @@ final class DetailCategoryTreeModel extends AbstractTreeTableModel { super(new Object()); final MutableDetailCategoryModel model = new MutableDetailCategoryModel(); model.addAll(categoryProvider.provide()); - this.rootCategories = new LinkedList(); - this.categoryChildren = new HashMap>(); + this.rootCategories = new LinkedList<>(); + this.categoryChildren = new HashMap<>(); for (final DetailCategory singleRoot : model.getRootCategories()) { this.rootCategories.add(this.addCategoryTreeToMap(model, singleRoot)); } @@ -79,7 +79,7 @@ final class DetailCategoryTreeModel extends AbstractTreeTableModel { * @return row object representing the given category */ private DetailCategoryRow addCategoryTreeToMap(final MutableDetailCategoryModel model, final DetailCategory detail) { - final List children = new LinkedList(); + final List children = new LinkedList<>(); for (final DetailCategory singleChild : model.getChildCategories(detail)) { children.add(this.addCategoryTreeToMap(model, singleChild)); } @@ -106,7 +106,7 @@ TreePath addChildCategoryRow(final TreePath parent) { } else { final Object parentRow = parent.getLastPathComponent(); if (!this.categoryChildren.containsKey(parentRow)) { - this.categoryChildren.put((DetailCategoryRow) parentRow, new LinkedList()); + this.categoryChildren.put((DetailCategoryRow) parentRow, new LinkedList<>()); } parentsChildren = this.categoryChildren.get(parentRow); // inherit color from parent @@ -313,7 +313,7 @@ public void setValueAt(final Object value, final Object node, final int column) * @return all detail categories in unsorted list */ private List getFlatCategoryList() { - final List categories = new LinkedList(this.rootCategories); + final List categories = new LinkedList<>(this.rootCategories); for (final List childCategories : this.categoryChildren.values()) { categories.addAll(childCategories); } @@ -329,7 +329,7 @@ private List getFlatCategoryList() { * @return full tree path from root to given category row */ private TreePath buildPathToRow(final DetailCategoryRow row) { - final Deque pathElements = new LinkedList(); + final Deque pathElements = new LinkedList<>(); DetailCategoryRow currentElement = row; // traverse the tree path from the given leaf upwards outer: do { @@ -353,7 +353,7 @@ private TreePath buildPathToRow(final DetailCategoryRow row) { * @return all categories have unique, non-empty codes */ boolean isValid() { - final Set codesInUse = new HashSet(); + final Set codesInUse = new HashSet<>(); for (final DetailCategoryRow singleRoot : this.rootCategories) { if (singleRoot.code.isEmpty() || codesInUse.contains(singleRoot.code)) { return false; @@ -379,11 +379,11 @@ boolean isValid() { */ SimpleEntry> toModelWithMapping() { final MutableDetailCategoryModel model = new MutableDetailCategoryModel(); - final Map mapping = new HashMap(); + final Map mapping = new HashMap<>(); for (final DetailCategoryRow singleRoot : this.rootCategories) { this.addDetailCategoryToModel(null, singleRoot, model, mapping); } - return new SimpleEntry>(model, mapping); + return new SimpleEntry<>(model, mapping); } /** diff --git a/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/InterviewPanel.java b/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/InterviewPanel.java index f1f6a1b..1dd9b89 100644 --- a/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/InterviewPanel.java +++ b/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/InterviewPanel.java @@ -227,7 +227,7 @@ final boolean containsValidSelection() { * @return selected text token ui components */ final List getSelection() { - final List selection = new LinkedList(); + final List selection = new LinkedList<>(); for (final Component singleParagraph : this.getViewPortView().getComponents()) { for (final Component singleToken : ((Container) singleParagraph).getComponents()) { if (((TextTokenComponent) singleToken).isSelected()) { @@ -246,7 +246,7 @@ final List getSelection() { */ final List getSelectedTokens() { final List components = this.getSelection(); - final List selection = new ArrayList(components.size()); + final List selection = new ArrayList<>(components.size()); for (final TextTokenComponent selectedComponent : components) { selection.add(selectedComponent.getModel()); } diff --git a/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/InterviewScoringPanel.java b/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/InterviewScoringPanel.java index ba058c1..7a2f653 100644 --- a/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/InterviewScoringPanel.java +++ b/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/InterviewScoringPanel.java @@ -71,7 +71,7 @@ public final class InterviewScoringPanel extends InterviewPanel implements IUndo public InterviewScoringPanel(final InterviewView parentView) { super(parentView, parentView.getProject().getModelHandler()); this.parentView = parentView; - this.undoManager = new UndoManager(parentView.getModel()); + this.undoManager = new UndoManager<>(parentView.getModel()); this.dragHandler = new MouseDragListener(); this.getViewPortView().setFocusable(true); this.getViewPortView().addMouseListener(this.dragHandler); diff --git a/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/InterviewView.java b/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/InterviewView.java index 195c150..10d5f81 100644 --- a/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/InterviewView.java +++ b/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/InterviewView.java @@ -50,7 +50,7 @@ public final class InterviewView extends AbstractAisProjectView { */ private IUndoManagedView viewPanel; /** The main tool bar items that belong to this view – in order to enable/disable them according to the current selection. */ - private final List detailToolBarItems = new LinkedList(); + private final List detailToolBarItems = new LinkedList<>(); /** * Main constructor. diff --git a/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/ParticipantInterviewGroupView.java b/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/ParticipantInterviewGroupView.java index d9ce0a5..b3df9bd 100644 --- a/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/ParticipantInterviewGroupView.java +++ b/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/ParticipantInterviewGroupView.java @@ -115,7 +115,7 @@ public void refresh() { final GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.BOTH; constraints.weightx = 1; - final List interviews = new ArrayList(this.getProject().getModelObject().getSubModelObjects().get(this.getModel())); + final List interviews = new ArrayList<>(this.getProject().getModelObject().getSubModelObjects().get(this.getModel())); final int interviewCount = interviews.size(); for (int listIndex = 0; listIndex < interviewCount; listIndex++) { constraints.gridy = listIndex; diff --git a/scitos.core/pom.xml b/scitos.core/pom.xml index 8567908..253556d 100644 --- a/scitos.core/pom.xml +++ b/scitos.core/pom.xml @@ -3,7 +3,7 @@ org.hmx scitos - 2.3.1 + 2.4.0-SNAPSHOT scitos.core scitos.core diff --git a/scitos.core/src/main/java/org/hmx/scitos/core/AbstractModelHandler.java b/scitos.core/src/main/java/org/hmx/scitos/core/AbstractModelHandler.java index 1e93e19..657b6f4 100644 --- a/scitos.core/src/main/java/org/hmx/scitos/core/AbstractModelHandler.java +++ b/scitos.core/src/main/java/org/hmx/scitos/core/AbstractModelHandler.java @@ -48,7 +48,7 @@ public abstract class AbstractModelHandler> implements IMode */ protected AbstractModelHandler(final M model) { this.model = model; - this.listeners = new LinkedList(); + this.listeners = new LinkedList<>(); } @Override @@ -87,7 +87,7 @@ public void removeModelChangeListener(final ModelChangeListener listener) { */ protected void notifyListeners(final O changedElement, final boolean updated) { // create generic model event - final ModelEvent event = new ModelEvent(changedElement, updated); + final ModelEvent event = new ModelEvent<>(changedElement, updated); // notify all currently registered ModelChangeListeners for (final ModelChangeListener singleListener : this.listeners) { singleListener.modelChanged(event); diff --git a/scitos.core/src/main/java/org/hmx/scitos/core/UndoManager.java b/scitos.core/src/main/java/org/hmx/scitos/core/UndoManager.java index fb6fec2..4628394 100644 --- a/scitos.core/src/main/java/org/hmx/scitos/core/UndoManager.java +++ b/scitos.core/src/main/java/org/hmx/scitos/core/UndoManager.java @@ -37,11 +37,11 @@ public final class UndoManager> { /** * The collection of previous model object states, available for {@link #undo()}. */ - private final Deque availableUndos = new LinkedList(); + private final Deque availableUndos = new LinkedList<>(); /** * The collection of previous model object states, which were rolled back and are available for {@link #redo()}. */ - private final Deque availableRedos = new LinkedList(); + private final Deque availableRedos = new LinkedList<>(); /** The maximum of stored undo-able model changes. */ private int limit; diff --git a/scitos.core/src/main/java/org/hmx/scitos/core/i18n/Translator.java b/scitos.core/src/main/java/org/hmx/scitos/core/i18n/Translator.java index 0c318f4..cc6a6b2 100644 --- a/scitos.core/src/main/java/org/hmx/scitos/core/i18n/Translator.java +++ b/scitos.core/src/main/java/org/hmx/scitos/core/i18n/Translator.java @@ -81,7 +81,7 @@ public String getLocalizedMessage(final M message) { */ public static List getAvailableLocales(final Class messageType) { final List messageFiles = ClassPathUtil.getFileResourcePaths(messageType, messageType.getSimpleName() + "_.+[.]xml"); - final List availableLocales = new ArrayList(messageFiles.size()); + final List availableLocales = new ArrayList<>(messageFiles.size()); // the full file path starts like the full class name, plus a leading slash '/' and the trailing underscore '_' final int prefixLength = messageType.getName().length() + 2; for (final String messageFilePath : messageFiles) { diff --git a/scitos.core/src/main/java/org/hmx/scitos/core/option/OptionHandler.java b/scitos.core/src/main/java/org/hmx/scitos/core/option/OptionHandler.java index 8d9794b..b667124 100644 --- a/scitos.core/src/main/java/org/hmx/scitos/core/option/OptionHandler.java +++ b/scitos.core/src/main/java/org/hmx/scitos/core/option/OptionHandler.java @@ -66,7 +66,7 @@ public static & IOptionSetting> Option if (OptionHandler.instances.containsKey(optionImplClass)) { singleton = (OptionHandler) OptionHandler.instances.get(optionImplClass); } else { - singleton = new OptionHandler(optionImplClass); + singleton = new OptionHandler<>(optionImplClass); OptionHandler.instances.put(optionImplClass, singleton); } return singleton; diff --git a/scitos.core/src/main/java/org/hmx/scitos/core/util/ClassPathUtil.java b/scitos.core/src/main/java/org/hmx/scitos/core/util/ClassPathUtil.java index 62b9654..ebbdd30 100644 --- a/scitos.core/src/main/java/org/hmx/scitos/core/util/ClassPathUtil.java +++ b/scitos.core/src/main/java/org/hmx/scitos/core/util/ClassPathUtil.java @@ -45,7 +45,7 @@ public final class ClassPathUtil { * @see Class#getResourceAsStream(String) */ public static List getFileResourcePaths(final Class clazz, final String fileNameRegex) { - final List paths = new LinkedList(); + final List paths = new LinkedList<>(); // check if this is being executed from within a jar file final Pattern pattern = Pattern.compile(fileNameRegex); final File jarFile = new File(clazz.getProtectionDomain().getCodeSource().getLocation().getPath()); diff --git a/scitos.core/src/main/java/org/hmx/scitos/core/util/DomUtil.java b/scitos.core/src/main/java/org/hmx/scitos/core/util/DomUtil.java index 025408b..5459ad0 100644 --- a/scitos.core/src/main/java/org/hmx/scitos/core/util/DomUtil.java +++ b/scitos.core/src/main/java/org/hmx/scitos/core/util/DomUtil.java @@ -128,7 +128,7 @@ public static Element getChildElement(final Node parentNode, final String childN * @return all child elements with the given name */ public static List getChildElements(final Node parentNode, final String... childNodeNames) { - final List children = new LinkedList(); + final List children = new LinkedList<>(); final NodeList candidates = parentNode.getChildNodes(); final int childCount = candidates.getLength(); final List targetNodeNames = Arrays.asList(childNodeNames); diff --git a/scitos.core/src/test/java/org/hmx/scitos/core/UndoManagerTest.java b/scitos.core/src/test/java/org/hmx/scitos/core/UndoManagerTest.java index 981967c..c10dda9 100644 --- a/scitos.core/src/test/java/org/hmx/scitos/core/UndoManagerTest.java +++ b/scitos.core/src/test/java/org/hmx/scitos/core/UndoManagerTest.java @@ -34,7 +34,7 @@ public static void setUp() { @Before public void prepareManager() { this.managedModel = UndoManagerTest.MODEL_CLONE.clone(); - this.undoManager = new UndoManager(this.managedModel); + this.undoManager = new UndoManager<>(this.managedModel); this.undoManager.setLimit(2); } @@ -87,13 +87,13 @@ public void testUndo() { public void testUndoMultipleTimes() { final int iterationCount = 3; this.undoManager.setLimit(iterationCount); - final List oldStates = new LinkedList(); + final List oldStates = new LinkedList<>(); for (int iteration = 0; iteration < iterationCount; iteration++) { oldStates.add(this.managedModel.clone()); this.managedModel.changeState(); this.undoManager.undoableEditHappened(this.managedModel); } - final Deque undoStates = new LinkedList(); + final Deque undoStates = new LinkedList<>(); for (int iteration = 0; iteration < iterationCount; iteration++) { undoStates.addFirst(this.undoManager.undo()); } @@ -116,7 +116,7 @@ public void testRedo() { public void testRedoMultipleTimes() { final int iterationCount = 3; this.undoManager.setLimit(iterationCount); - final List originalStates = new LinkedList(); + final List originalStates = new LinkedList<>(); for (int iteration = 0; iteration < iterationCount; iteration++) { this.managedModel.changeState(); originalStates.add(this.managedModel.clone()); @@ -125,7 +125,7 @@ public void testRedoMultipleTimes() { for (int iteration = 0; iteration < iterationCount; iteration++) { this.undoManager.undo(); } - final List redoStates = new LinkedList(); + final List redoStates = new LinkedList<>(); for (int iteration = 0; iteration < iterationCount; iteration++) { redoStates.add(this.undoManager.redo()); } diff --git a/scitos.core/src/test/java/org/hmx/scitos/core/i18n/MessageTest.java b/scitos.core/src/test/java/org/hmx/scitos/core/i18n/MessageTest.java index c5d35f8..6d01733 100644 --- a/scitos.core/src/test/java/org/hmx/scitos/core/i18n/MessageTest.java +++ b/scitos.core/src/test/java/org/hmx/scitos/core/i18n/MessageTest.java @@ -25,8 +25,8 @@ public class MessageTest { public void testMessageAvailability() { final ResourceBundle bundle = ResourceBundle.getBundle(Message.class.getName(), Locale.ENGLISH, new XmlResourceBundleControl()); Assert.assertNotNull(bundle); - final List unusedMessages = new LinkedList(); - final List unavailableMessages = new LinkedList(); + final List unusedMessages = new LinkedList<>(); + final List unavailableMessages = new LinkedList<>(); final Enumeration availableKeys = bundle.getKeys(); while (availableKeys.hasMoreElements()) { unusedMessages.add(availableKeys.nextElement()); diff --git a/scitos.distribution/build-mac-app.sh b/scitos.distribution/build-mac-app.sh new file mode 100755 index 0000000..40c2884 --- /dev/null +++ b/scitos.distribution/build-mac-app.sh @@ -0,0 +1,66 @@ +#!/bin/sh +# +# Special script for creating a Mac .app Bundle. +# This is not portable, needs to be triggered manually and the following parameters need to be adjusted accordingly. +# +VERSION="2.4.0" +JDK_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home +JRE_MODULES="java.base,java.compiler,java.desktop,java.prefs,java.scripting,java.sql.rowset,jdk.unsupported" + +# collect dependencies to mention them in the classpath one-by-one +LIBS=`ls -md target/lib/* | tr -d ','` +java -jar src/main/resources/packr/packr-all-2.7.0.jar \ + --platform mac \ + --jdk $JDK_HOME \ + --executable SciToS \ + --classpath target/scitos.jar \ + $LIBS \ + --mainclass org.hmx.scitos.view.swing.ScitosApp \ + --bundle org.hmx.scitos.swing \ + --icon src/main/resources/icons/scitos_application.icns \ + --vmargs Xmx256M \ + --output target/SciToS.app + +echo "Removing the (ca. 300MB) JRE being included by default..." +rm -rf target/SciToS.app/Contents/Resources/jre + +echo "Adding only the (ca. 43MB) JRE parts that are required..." +$JDK_HOME/bin/jlink \ + --module-path . \ + --add-modules $JRE_MODULES \ + --output target/SciToS.app/Contents/Resources/jre \ + --no-header-files \ + --no-man-pages \ + --strip-debug \ + --compress=2 + +echo "Overriding the generated Info.plist to include the correct version number..." +echo " +<\!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"> + + + CFBundleGetInfoString + SciToS + CFBundleExecutable + SciToS + CFBundleIdentifier + org.hmx.scitos.swing + CFBundleName + SciToS + CFBundleIconFile + icons.icns + CFBundleShortVersionString + $VERSION + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + NSHighResolutionCapable + + +" > target/SciToS.app/Contents/Info.plist + +echo "Packaging as SciTos-macOS-Bundle.tar.gz..." +tar cJf target/SciTos-macOS-Bundle.tar.gz target/SciToS.app + +echo "SciToS.app creation completed!" diff --git a/scitos.distribution/pom.xml b/scitos.distribution/pom.xml index da7fce7..a41ae35 100644 --- a/scitos.distribution/pom.xml +++ b/scitos.distribution/pom.xml @@ -3,7 +3,7 @@ org.hmx scitos - 2.3.1 + 2.4.0-SNAPSHOT scitos.distribution @@ -48,6 +48,18 @@ + + lib-dir-assembly + package + + single + + + lib + src/main/resources/assembly/assembly-descriptor-libdir.xml + false + + distribution-zip-assembly package diff --git a/scitos.distribution/src/main/resources/assembly/assembly-descriptor-libdir.xml b/scitos.distribution/src/main/resources/assembly/assembly-descriptor-libdir.xml new file mode 100644 index 0000000..5df497c --- /dev/null +++ b/scitos.distribution/src/main/resources/assembly/assembly-descriptor-libdir.xml @@ -0,0 +1,20 @@ + + + dir + + dir + + + + + + false + + org.hmx:scitos* + + + + diff --git a/scitos.distribution/src/main/resources/assembly/assembly-descriptor-zip.xml b/scitos.distribution/src/main/resources/assembly/assembly-descriptor-zip.xml index 1c7b6af..f4ad6c9 100644 --- a/scitos.distribution/src/main/resources/assembly/assembly-descriptor-zip.xml +++ b/scitos.distribution/src/main/resources/assembly/assembly-descriptor-zip.xml @@ -8,21 +8,13 @@ zip scitos - - - lib - false - - org.hmx:scitos* - - - target scitos*.jar + lib/*.jar diff --git a/scitos.distribution/src/main/resources/icons/scitos_application.icns b/scitos.distribution/src/main/resources/icons/scitos_application.icns new file mode 100644 index 0000000..1895fe8 Binary files /dev/null and b/scitos.distribution/src/main/resources/icons/scitos_application.icns differ diff --git a/scitos.distribution/src/main/resources/packr/packr-all-2.7.0.jar b/scitos.distribution/src/main/resources/packr/packr-all-2.7.0.jar new file mode 100644 index 0000000..d36a517 Binary files /dev/null and b/scitos.distribution/src/main/resources/packr/packr-all-2.7.0.jar differ diff --git a/scitos.domain/pom.xml b/scitos.domain/pom.xml index 0b1ea1c..875ae20 100644 --- a/scitos.domain/pom.xml +++ b/scitos.domain/pom.xml @@ -3,7 +3,7 @@ org.hmx scitos - 2.3.1 + 2.4.0-SNAPSHOT scitos.domain scitos.domain diff --git a/scitos.domain/src/main/java/org/hmx/scitos/domain/util/CollectionUtil.java b/scitos.domain/src/main/java/org/hmx/scitos/domain/util/CollectionUtil.java index e63187d..ac4ba94 100644 --- a/scitos.domain/src/main/java/org/hmx/scitos/domain/util/CollectionUtil.java +++ b/scitos.domain/src/main/java/org/hmx/scitos/domain/util/CollectionUtil.java @@ -94,7 +94,7 @@ public static int indexOfInstance(final Collection collection, * @return mapping of contained instances to their respective count of occurrences */ public static Map countOccurrences(final Collection collection) { - final Map map = new HashMap(); + final Map map = new HashMap<>(); for (final T instance : collection) { final AtomicInteger counter = map.get(instance); if (counter == null) { @@ -128,7 +128,7 @@ public static Map countOccurrences(final Collection col */ public static void moveEntryInInsertSortedMap(final Map insertSortedMap, final K entryKey, final boolean increaseIndexByOne) { // #1 create a copy of the original key order as list (to make it accessible via index) - final List keyList = new ArrayList(insertSortedMap.keySet()); + final List keyList = new ArrayList<>(insertSortedMap.keySet()); // #2 determine the designated entry's current position final int index = keyList.indexOf(entryKey); // #3 determine the entry's new position @@ -144,7 +144,7 @@ public static void moveEntryInInsertSortedMap(final Map insertSorte throw new IllegalArgumentException(); } // #4 create a copy of the unchanged relation template groups map - final Map groupsCopy = new LinkedHashMap(insertSortedMap); + final Map groupsCopy = new LinkedHashMap<>(insertSortedMap); // #5 remove all mapping from the original relation template groups map, starting at the affected groups' indices insertSortedMap.keySet().retainAll(keyList.subList(0, Math.min(index, indexToSwitchWith))); final K entryToSwitchWith = keyList.get(indexToSwitchWith); diff --git a/scitos.domain/src/test/java/org/hmx/scitos/domain/util/CollectionUtilTest.java b/scitos.domain/src/test/java/org/hmx/scitos/domain/util/CollectionUtilTest.java index 94990a8..41d3bc5 100644 --- a/scitos.domain/src/test/java/org/hmx/scitos/domain/util/CollectionUtilTest.java +++ b/scitos.domain/src/test/java/org/hmx/scitos/domain/util/CollectionUtilTest.java @@ -59,7 +59,7 @@ public void testIndexOfInstance_4() { /** Test: for moveEntryInInsertSortedMap method (expect failure: move first entry up) */ @Test(expected = IllegalArgumentException.class) public void testMoveEntryInInsertSortedMap_First_Up() { - final Map map = new LinkedHashMap(3); + final Map map = new LinkedHashMap<>(3); map.put("1", 1); map.put("2", 2); CollectionUtil.moveEntryInInsertSortedMap(map, "1", false); @@ -68,103 +68,103 @@ public void testMoveEntryInInsertSortedMap_First_Up() { /** Test: for moveEntryInInsertSortedMap method (move first entry up) */ @Test public void testMoveEntryInInsertSortedMap_First_Down() { - final Map map = new LinkedHashMap(3); + final Map map = new LinkedHashMap<>(3); map.put("1", 1); map.put("2", 2); map.put("3", 3); CollectionUtil.moveEntryInInsertSortedMap(map, "1", true); - Assert.assertEquals(Arrays.asList("2", "1", "3"), new ArrayList(map.keySet())); + Assert.assertEquals(Arrays.asList("2", "1", "3"), new ArrayList<>(map.keySet())); } /** Test: for moveEntryInInsertSortedMap method (move second entry up) */ @Test public void testMoveEntryInInsertSortedMap_Second_Up() { - final Map map = new LinkedHashMap(3); + final Map map = new LinkedHashMap<>(3); map.put("1", 1); map.put("2", 2); map.put("3", 3); map.put("4", 4); CollectionUtil.moveEntryInInsertSortedMap(map, "2", false); - Assert.assertEquals(Arrays.asList("2", "1", "3", "4"), new ArrayList(map.keySet())); + Assert.assertEquals(Arrays.asList("2", "1", "3", "4"), new ArrayList<>(map.keySet())); } /** Test: for moveEntryInInsertSortedMap method (move second entry down) */ @Test public void testMoveEntryInInsertSortedMap_Second_Down() { - final Map map = new LinkedHashMap(3); + final Map map = new LinkedHashMap<>(3); map.put("1", 1); map.put("2", 2); map.put("3", 3); map.put("4", 4); CollectionUtil.moveEntryInInsertSortedMap(map, "2", true); - Assert.assertEquals(Arrays.asList("1", "3", "2", "4"), new ArrayList(map.keySet())); + Assert.assertEquals(Arrays.asList("1", "3", "2", "4"), new ArrayList<>(map.keySet())); } /** Test: for moveEntryInInsertSortedMap method (move middle entry up) */ @Test public void testMoveEntryInInsertSortedMap_Mid_Up() { - final Map map = new LinkedHashMap(3); + final Map map = new LinkedHashMap<>(3); map.put("1", 1); map.put("2", 2); map.put("3", 3); map.put("4", 4); map.put("5", 5); CollectionUtil.moveEntryInInsertSortedMap(map, "3", false); - Assert.assertEquals(Arrays.asList("1", "3", "2", "4", "5"), new ArrayList(map.keySet())); + Assert.assertEquals(Arrays.asList("1", "3", "2", "4", "5"), new ArrayList<>(map.keySet())); } /** Test: for moveEntryInInsertSortedMap method (move middle entry down) */ @Test public void testMoveEntryInInsertSortedMap_Mid_Down() { - final Map map = new LinkedHashMap(3); + final Map map = new LinkedHashMap<>(3); map.put("1", 1); map.put("2", 2); map.put("3", 3); map.put("4", 4); map.put("5", 5); CollectionUtil.moveEntryInInsertSortedMap(map, "3", true); - Assert.assertEquals(Arrays.asList("1", "2", "4", "3", "5"), new ArrayList(map.keySet())); + Assert.assertEquals(Arrays.asList("1", "2", "4", "3", "5"), new ArrayList<>(map.keySet())); } /** Test: for moveEntryInInsertSortedMap method (move second to last entry up) */ @Test public void testMoveEntryInInsertSortedMap_SecondToLast_Up() { - final Map map = new LinkedHashMap(3); + final Map map = new LinkedHashMap<>(3); map.put("1", 1); map.put("2", 2); map.put("3", 3); map.put("4", 4); CollectionUtil.moveEntryInInsertSortedMap(map, "3", false); - Assert.assertEquals(Arrays.asList("1", "3", "2", "4"), new ArrayList(map.keySet())); + Assert.assertEquals(Arrays.asList("1", "3", "2", "4"), new ArrayList<>(map.keySet())); } /** Test: for moveEntryInInsertSortedMap method (move second to last entry down) */ @Test public void testMoveEntryInInsertSortedMap_SecondToLast_Down() { - final Map map = new LinkedHashMap(3); + final Map map = new LinkedHashMap<>(3); map.put("1", 1); map.put("2", 2); map.put("3", 3); map.put("4", 4); CollectionUtil.moveEntryInInsertSortedMap(map, "3", true); - Assert.assertEquals(Arrays.asList("1", "2", "4", "3"), new ArrayList(map.keySet())); + Assert.assertEquals(Arrays.asList("1", "2", "4", "3"), new ArrayList<>(map.keySet())); } /** Test: for moveEntryInInsertSortedMap method (move first entry up) */ @Test public void testMoveEntryInInsertSortedMap_Last_Up() { - final Map map = new LinkedHashMap(3); + final Map map = new LinkedHashMap<>(3); map.put("1", 1); map.put("2", 2); map.put("3", 3); CollectionUtil.moveEntryInInsertSortedMap(map, "3", false); - Assert.assertEquals(Arrays.asList("1", "3", "2"), new ArrayList(map.keySet())); + Assert.assertEquals(Arrays.asList("1", "3", "2"), new ArrayList<>(map.keySet())); } /** Test: for moveEntryInInsertSortedMap method (expect failure: move last entry down) */ @Test(expected = IllegalArgumentException.class) public void testMoveEntryInInsertSortedMap_Last_Down() { - final Map map = new LinkedHashMap(3); + final Map map = new LinkedHashMap<>(3); map.put("1", 1); map.put("2", 2); CollectionUtil.moveEntryInInsertSortedMap(map, "2", true); diff --git a/scitos.hmx/pom.xml b/scitos.hmx/pom.xml index 95b9c74..254f8cb 100644 --- a/scitos.hmx/pom.xml +++ b/scitos.hmx/pom.xml @@ -3,7 +3,7 @@ org.hmx scitos - 2.3.1 + 2.4.0-SNAPSHOT scitos.hmx pom diff --git a/scitos.hmx/scitos.hmx.core/pom.xml b/scitos.hmx/scitos.hmx.core/pom.xml index c0aef41..f13de5a 100644 --- a/scitos.hmx/scitos.hmx.core/pom.xml +++ b/scitos.hmx/scitos.hmx.core/pom.xml @@ -3,7 +3,7 @@ org.hmx scitos.hmx - 2.3.1 + 2.4.0-SNAPSHOT scitos.hmx.core scitos.hmx.core diff --git a/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/LookupLanguageModel.java b/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/LookupLanguageModel.java index 2214cee..9c512fc 100644 --- a/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/LookupLanguageModel.java +++ b/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/LookupLanguageModel.java @@ -46,7 +46,7 @@ public class LookupLanguageModel extends LanguageModel { */ public LookupLanguageModel(final String name, final boolean leftToRightOriented) { super(name, leftToRightOriented); - this.functionsByCode = new HashMap(); + this.functionsByCode = new HashMap<>(); } @Override diff --git a/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/ModelHandlerImpl.java b/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/ModelHandlerImpl.java index bfd159c..1874be6 100755 --- a/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/ModelHandlerImpl.java +++ b/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/ModelHandlerImpl.java @@ -206,7 +206,7 @@ public void removeOneIndentation(final Proposition target) throws HmxException { * case: target is a prior child */ // removes the indentation of all other prior children before and finally the target itself - for (final Proposition singleChild : new ArrayList(priorChildren).subList(0, + for (final Proposition singleChild : new ArrayList<>(priorChildren).subList(0, CollectionUtil.indexOfInstance(priorChildren, target) + 1)) { parent.removeChildProposition(singleChild); // adding child in front of its former parent in the list @@ -429,7 +429,7 @@ private void mergeConnectedPropositions(final Proposition prop1Part, final Propo * indented under another enclosed child of prop2 and its partBeforeArrow */ prop1Part.getParent().removeChildProposition(prop1Part); - final List priorChildren = new ArrayList(prop2Part.getPriorChildren()); + final List priorChildren = new ArrayList<>(prop2Part.getPriorChildren()); priorChildren.addAll(prop1Part.getPriorChildren()); prop1Part.setPriorChildren(priorChildren); prop1Part.setFunction(null); @@ -450,7 +450,7 @@ private void mergeConnectedPropositions(final Proposition prop1Part, final Propo */ private void mergeConnectedPropositionsIntoOne(final Proposition firstPart, final Proposition secondPart) { // merge ClauseItems - final List items = new ArrayList(firstPart.getItems()); + final List items = new ArrayList<>(firstPart.getItems()); items.addAll(secondPart.getItems()); firstPart.setItems(items); if (firstPart.getLabel() == null || firstPart.getLabel().isEmpty()) { @@ -468,7 +468,7 @@ private void mergeConnectedPropositionsIntoOne(final Proposition firstPart, fina firstPart.setPartAfterArrow(secondPart.getPartAfterArrow()); final Relation superOrdinated = secondPart.getSuperOrdinatedRelation(); if (firstPart.getSuperOrdinatedRelation() == null && superOrdinated != null) { - final List associates = new ArrayList(superOrdinated.getAssociates()); + final List associates = new ArrayList<>(superOrdinated.getAssociates()); associates.set(CollectionUtil.indexOfInstance(associates, secondPart), firstPart); firstPart.setSuperOrdinatedRelation(superOrdinated, secondPart.getRole()); superOrdinated.setAssociates(associates); @@ -537,7 +537,7 @@ private void mergePropositionsWithEnclosedChildren(final Proposition firstPart, secondPart.setPriorChildren(firstLaterChildren); } else { // make sure all enclosed children are in the same list to keep the ability to merge and indent of enclosed - final List combinedChildren = new LinkedList(firstLaterChildren); + final List combinedChildren = new LinkedList<>(firstLaterChildren); combinedChildren.addAll(secondPriorChildren); secondPart.setPriorChildren(combinedChildren); } @@ -557,7 +557,7 @@ public void splitProposition(final Proposition target, final ClauseItem lastItem } final int lastItemIndex = CollectionUtil.indexOfInstance(firstPartItems, lastItemInFirstPart); if (lastItemIndex + 1 < firstPartItems.size()) { - final List secondPartItems = new ArrayList(firstPartItems.subList(lastItemIndex + 1, firstPartItems.size())); + final List secondPartItems = new ArrayList<>(firstPartItems.subList(lastItemIndex + 1, firstPartItems.size())); // removes the duplicates of the secondPart from the firstPart target.removeClauseItems(secondPartItems); // make sure the propositions are still in the right order, transfer target's later children to the new proposition @@ -628,7 +628,7 @@ private void handleRelationsWhenSplittingProposition(final Proposition firstPart Relation superOrdinated = firstPart.getSuperOrdinatedRelation(); if (firstPart == superOrdinated.getAssociates().get(0)) { // move relation to the new proposition in order to preserve its validity - final List newAssociates = new ArrayList(superOrdinated.getAssociates()); + final List newAssociates = new ArrayList<>(superOrdinated.getAssociates()); newAssociates.set(0, secondPart); superOrdinated.setAssociates(newAssociates); final AssociateRole role = firstPart.getRole(); diff --git a/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/ModelParseServiceImpl.java b/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/ModelParseServiceImpl.java index 8ee4fb5..aee9076 100644 --- a/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/ModelParseServiceImpl.java +++ b/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/ModelParseServiceImpl.java @@ -446,7 +446,7 @@ public Entry> parseModelFromXml(final Document xml, final File languageModel = this.parseLanguageModelFromXml(systemModelNode, systemModelNode.getAttribute(ModelParseServiceImpl.ATT_LANGMODEL_NAME), textOrientation); - compatibleRoleTranslator = new Translator(CompatibleRelationRole.class); + compatibleRoleTranslator = new Translator<>(CompatibleRelationRole.class); } else { final String textOrientation = pericopeNode.getAttribute(ModelParseServiceImpl.ATT_ROOT_ORIENTATION); languageModel = this.parseLanguageModelFromXml(syntacticalModelNode, language, textOrientation); @@ -467,7 +467,7 @@ public Entry> parseModelFromXml(final Document xml, final File newPericope.setComment(DomUtil.getNullableAttribute(pericopeNode, ModelParseServiceImpl.ATT_ROOT_COMMENT)); // Creates an List of Propositions for the rootPropositions - final List text = new LinkedList(); + final List text = new LinkedList<>(); // all top level children, including the root Propositions for (final Element topLevelProposition : DomUtil.getChildElements(pericopeNode, ModelParseServiceImpl.TAG_PROPOSITION)) { text.add(this.parsePropositionFromXml(topLevelProposition, languageModel)); @@ -478,7 +478,7 @@ public Entry> parseModelFromXml(final Document xml, final File final Element connectablesTree = DomUtil.getChildElement(pericopeNode, ModelParseServiceImpl.TAG_RELATION_SUB_TREE); if (connectablesTree != null && !text.isEmpty()) { // gets a list of all Propositions contained in the pericope in order of appearence - final Deque propositionsInOrder = new LinkedList(); + final Deque propositionsInOrder = new LinkedList<>(); Proposition nextProposition = newPericope.getPropositionAt(0); while (nextProposition != null) { propositionsInOrder.addLast(nextProposition); @@ -488,7 +488,7 @@ public Entry> parseModelFromXml(final Document xml, final File this.parseConnectableFromXml(topLevelConnectable, propositionsInOrder, compatibleRoleTranslator); } } - return new SimpleEntry>(newPericope, Collections.singletonList(newPericope)); + return new SimpleEntry<>(newPericope, Collections.singletonList(newPericope)); } /** @@ -500,7 +500,7 @@ public Entry> parseModelFromXml(final Document xml, final File */ public List getSystemLanguageModels() throws HmxException { final Map systemModelNodes = this.getSystemLanguageModelNodes(); - final List result = new ArrayList(systemModelNodes.size()); + final List result = new ArrayList<>(systemModelNodes.size()); for (final Element modelNode : systemModelNodes.values()) { final LookupLanguageModel model = this.parseLanguageModelFromXml(modelNode, modelNode.getAttribute(ModelParseServiceImpl.ATT_LANGMODEL_NAME), @@ -527,7 +527,7 @@ public List getSystemLanguageModels() throws HmxException { private List removeBackwardCompatibilityInfo( final List possibleCompatibleFunctions) { final List result = - new ArrayList(possibleCompatibleFunctions.size()); + new ArrayList<>(possibleCompatibleFunctions.size()); for (final AbstractSyntacticalFunctionElement singleFunction : possibleCompatibleFunctions) { if (singleFunction instanceof SyntacticalFunction) { result.add(new SyntacticalFunction(((SyntacticalFunction) singleFunction).getCode(), singleFunction.getName(), @@ -576,7 +576,7 @@ private Map getSystemLanguageModelNodes() throws HmxException { } } final String userLanguage = Option.TRANSLATION.getValueAsLocale().getLanguage(); - final Map availableModels = new TreeMap(); + final Map availableModels = new TreeMap<>(); for (final Element modelNode : systemModelNodes) { // get the user language independent name of this model final String compatibleName = modelNode.getAttribute(ModelParseServiceImpl.ATT_LANGMODEL_NAME_COMPATIBLE); @@ -600,7 +600,7 @@ private Map getSystemLanguageModelNodes() throws HmxException { */ public List parseLanguageModelsFromXml(final Document xml) throws HmxException { final List modelNodes = DomUtil.getChildElements(xml.getDocumentElement(), ModelParseServiceImpl.TAG_LANGMODEL); - final List models = new ArrayList(modelNodes.size()); + final List models = new ArrayList<>(modelNodes.size()); for (final Element singleModelNode : modelNodes) { final String modelName = singleModelNode.getAttribute(ModelParseServiceImpl.ATT_LANGMODEL_NAME); final String modelOrientation = singleModelNode.getAttribute(ModelParseServiceImpl.ATT_LANGMODEL_ORIENTATION); @@ -651,7 +651,7 @@ private LookupLanguageModel parseLanguageModelFromXml(final Element syntacticalM * @return successfully parsed functions */ private List parseSyntacticalFunctionsFromXml(final Element parentNode) { - final LinkedList result = new LinkedList(); + final LinkedList result = new LinkedList<>(); for (final Element singleFunctionNode : DomUtil.getChildElements(parentNode, ModelParseServiceImpl.TAG_LANGMODEL_FUNCTION, ModelParseServiceImpl.TAG_LANGMODEL_FUNCTIONGROUP)) { if (ModelParseServiceImpl.TAG_LANGMODEL_FUNCTION.equals(singleFunctionNode.getTagName())) { @@ -761,9 +761,9 @@ public RelationModel parseRelationModelFromXml(final Document xml) throws HmxExc private RelationModel parseRelationModelFromXml(final Element semanticalModelNode) throws HmxException { final RelationModel model = new RelationModel(); for (final Element singleGroupNode : DomUtil.getChildElements(semanticalModelNode, ModelParseServiceImpl.TAG_RELMODEL_GROUP)) { - final List group = new LinkedList(); + final List group = new LinkedList<>(); for (final Element singleTemplateNode : DomUtil.getChildElements(singleGroupNode, ModelParseServiceImpl.TAG_RELMODEL_RELATION)) { - final List roles = new ArrayList(3); + final List roles = new ArrayList<>(3); for (final Element singleRoleNode : DomUtil.getChildElements(singleTemplateNode, ModelParseServiceImpl.TAG_RELMODEL_ASSOCIATE)) { final String roleName = singleRoleNode.getAttribute(ModelParseServiceImpl.ATT_RELMODEL_ASSOCIATE_ROLE); final boolean isHighWeight = @@ -816,7 +816,7 @@ private Proposition parsePropositionFromXml(final Element propositionNode, final throw new HmxException(Message.ERROR_FILE_INVALID); } // collect the contained ClauseItems - final List itemList = new LinkedList(); + final List itemList = new LinkedList<>(); for (final Element singleClauseItem : DomUtil.getChildElements(tempItemElement, ModelParseServiceImpl.TAG_CLAUSE_ITEM)) { itemList.add(this.parseClauseItemFromXml(singleClauseItem, languageModel)); } @@ -835,7 +835,7 @@ private Proposition parsePropositionFromXml(final Element propositionNode, final // adds prior propositions to the Proposition according to the xml code final Element priorPropositionsElement = DomUtil.getChildElement(propositionNode, ModelParseServiceImpl.TAG_PRIOR_PROP_SUB_TREE); if (priorPropositionsElement != null) { - final List priorChildren = new LinkedList(); + final List priorChildren = new LinkedList<>(); // calls itself to add every prior Proposition contained in the Proposition for (final Element singlePriorChild : DomUtil.getChildElements(priorPropositionsElement, ModelParseServiceImpl.TAG_PROPOSITION)) { priorChildren.add(this.parsePropositionFromXml(singlePriorChild, languageModel)); @@ -845,7 +845,7 @@ private Proposition parsePropositionFromXml(final Element propositionNode, final // adds later propositions to the proposition according to the xml code final Element laterPropositionsElement = DomUtil.getChildElement(propositionNode, ModelParseServiceImpl.TAG_LATER_PROP_SUB_TREE); if (laterPropositionsElement != null) { - final List laterChildren = new LinkedList(); + final List laterChildren = new LinkedList<>(); // calls itself to add every later Proposition contained in the Proposition for (final Element singleLaterChild : DomUtil.getChildElements(laterPropositionsElement, ModelParseServiceImpl.TAG_PROPOSITION)) { laterChildren.add(this.parsePropositionFromXml(singleLaterChild, languageModel)); @@ -912,8 +912,8 @@ private AbstractConnectable parseConnectableFromXml(final Element connectableEle return propositionsInOrder.removeFirst(); } // Connectable to retrieve is a Relation - iterate through all subordinated Connectables - final List associates = new ArrayList(associateNodes.size()); - final List rolesAndWeights = new ArrayList(associateNodes.size()); + final List associates = new ArrayList<>(associateNodes.size()); + final List rolesAndWeights = new ArrayList<>(associateNodes.size()); for (final Element singleAssociateNode : associateNodes) { // recursively handle contained nodes representing a connectable model element associates.add(this.parseConnectableFromXml(singleAssociateNode, propositionsInOrder, compatibleRoleTranslator)); diff --git a/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/export/AbstractSvgCreator.java b/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/export/AbstractSvgCreator.java index b1abd7f..0453b7e 100644 --- a/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/export/AbstractSvgCreator.java +++ b/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/export/AbstractSvgCreator.java @@ -181,7 +181,7 @@ protected Document createSvgDocument(final String exportTypeTitle) throws HmxExc * @see SvgConstants#VAL_ID_ARROW_DOWNWARD */ protected List createArrowDefinition(final Document xml, final double arrowHeight) { - final List result = new ArrayList(2); + final List result = new ArrayList<>(2); // determine the preferred color final String arrowColor = HmxExportOption.ARROW_COLOR.getValue(); // prepare scaling diff --git a/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/export/SemanticalSvgCreator.java b/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/export/SemanticalSvgCreator.java index 3118f79..605b5ca 100644 --- a/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/export/SemanticalSvgCreator.java +++ b/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/export/SemanticalSvgCreator.java @@ -156,7 +156,7 @@ protected synchronized Document generateSvg(final boolean includeComments) throw final Element contentGroup = xml.createElementNS(SvgConstants.NAMESPACE_SVG, SvgConstants.TAG_GROUP); // begin with the propositions final int propositionCount = flatText.size(); - final List propositionElements = new ArrayList(propositionCount); + final List propositionElements = new ArrayList<>(propositionCount); // create the single propositions for (int i = 0; i < propositionCount; i++) { propositionElements.add(this.createSemanticalProposition(xml, flatText, i)); @@ -243,7 +243,7 @@ private void prepareConstraints(final List flatPropositions, final // height needed for the relation labels this.roleHeight = 0; // maximum width of each column created by the relation tree - this.semColumnWidths = new ArrayList(texts.size() - 3); + this.semColumnWidths = new ArrayList<>(texts.size() - 3); // texts[3..n] semantical roles separated by line breaks for (final String rolesInThisColumn : texts.subList(3, texts.size())) { this.roleHeight = Math.max(this.roleHeight, this.getTextBounds(rolesInThisColumn.replace('\n', ' '), this.labelFontPlain).getHeight()); @@ -298,11 +298,11 @@ private List collectTexts(final List flatPropositions, fina translations.append(singleProposition.getSemTranslation()); translations.append(' '); } - final List cachedTexts = new ArrayList(3 + maxTreeDepth); + final List cachedTexts = new ArrayList<>(3 + maxTreeDepth); cachedTexts.add(originTexts.toString().trim()); cachedTexts.add(labels.toString().trim()); cachedTexts.add(translations.toString().trim()); - final List rolesInColumns = new ArrayList(maxTreeDepth); + final List rolesInColumns = new ArrayList<>(maxTreeDepth); for (int i = 0; i < maxTreeDepth; i++) { rolesInColumns.add(new StringBuilder()); } @@ -484,12 +484,12 @@ protected Element createRelation(final Document xml, final Relation target, fina } // add a count on the end, if there are equal roles final List associates = target.getAssociates(); - final List roles = new ArrayList(associates.size()); + final List roles = new ArrayList<>(associates.size()); for (final AbstractConnectable singleAssociate : associates) { roles.add(singleAssociate.getRole()); } final Map occurrences = CollectionUtil.countOccurrences(roles); - final Map indices = new HashMap(); + final Map indices = new HashMap<>(); boolean insertComment = this.commentsIncluded && target.getComment() != null && !target.getComment().isEmpty(); final StringBuffer bufferedPoints = new StringBuffer(); for (final AbstractConnectable singleAssociate : associates) { diff --git a/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/export/SyntacticalSvgCreator.java b/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/export/SyntacticalSvgCreator.java index 1885787..a28a8b6 100644 --- a/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/export/SyntacticalSvgCreator.java +++ b/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/export/SyntacticalSvgCreator.java @@ -159,8 +159,8 @@ protected synchronized Document generateSvg(final boolean includeComments) throw root.appendChild(defsElement); final Element contentGroup = xml.createElementNS(SvgConstants.NAMESPACE_SVG, SvgConstants.TAG_GROUP); final int propositionCount = flatText.size(); - this.arrowPartIndentation = new HashMap(); - final List propositionElements = new ArrayList(propositionCount); + this.arrowPartIndentation = new HashMap<>(); + final List propositionElements = new ArrayList<>(propositionCount); for (int i = 0; i < propositionCount; i++) { propositionElements.add(this.createSyntacticalProposition(xml, flatText, i)); } diff --git a/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/option/HmxLanguageOption.java b/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/option/HmxLanguageOption.java index d03b3e2..da60818 100644 --- a/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/option/HmxLanguageOption.java +++ b/scitos.hmx/scitos.hmx.core/src/main/java/org/hmx/scitos/hmx/core/option/HmxLanguageOption.java @@ -84,7 +84,7 @@ public HmxLanguageOption(final ModelParseServiceImpl modelParseService) { // apply general option file naming convention this.filePath = OptionHandler.buildOptionFilePath(HmxLanguageOption.class); // initialize user defined language models - this.userModels = new LinkedList(); + this.userModels = new LinkedList<>(); // retrieve settings from persistent storage (i.e. file) final File targetFile = new File(this.filePath); if (targetFile.exists() && targetFile.canRead()) { @@ -133,7 +133,7 @@ public void setUserModels(final List userModels) { @Override public Map provideLanguageModels() { // avoid duplicates (two models with same name) and sort the models lexicographically by their names - final Map models = new TreeMap(); + final Map models = new TreeMap<>(); for (final LanguageModel singleModel : this.systemModels) { models.put(singleModel.getName(), singleModel); } diff --git a/scitos.hmx/scitos.hmx.core/src/test/java/org/hmx/scitos/hmx/core/ModelHandlerImplTest.java b/scitos.hmx/scitos.hmx.core/src/test/java/org/hmx/scitos/hmx/core/ModelHandlerImplTest.java index 9b9af5f..6fb9138 100644 --- a/scitos.hmx/scitos.hmx.core/src/test/java/org/hmx/scitos/hmx/core/ModelHandlerImplTest.java +++ b/scitos.hmx/scitos.hmx.core/src/test/java/org/hmx/scitos/hmx/core/ModelHandlerImplTest.java @@ -57,7 +57,7 @@ public class ModelHandlerImplTest { */ @BeforeClass public static void setUp() { - final List functions = new LinkedList(); + final List functions = new LinkedList<>(); functions.add(new SyntacticalFunction("A", "A Function", false, null)); functions.add(new SyntacticalFunction("B", "Second Function", true, "some description")); functions.add(new SyntacticalFunctionGroup("Group", null, Arrays.asList(new SyntacticalFunction("C", "Nested Function", false, null), diff --git a/scitos.hmx/scitos.hmx.core/src/test/java/org/hmx/scitos/hmx/core/ModelParseServiceImplTest.java b/scitos.hmx/scitos.hmx.core/src/test/java/org/hmx/scitos/hmx/core/ModelParseServiceImplTest.java index f68743f..7de5283 100644 --- a/scitos.hmx/scitos.hmx.core/src/test/java/org/hmx/scitos/hmx/core/ModelParseServiceImplTest.java +++ b/scitos.hmx/scitos.hmx.core/src/test/java/org/hmx/scitos/hmx/core/ModelParseServiceImplTest.java @@ -178,7 +178,7 @@ private void assertPericopeEquals(final Pericope expected, final Pericope actual this.assertStringEqualsNullOrEmptyAware("Title differs", expected.getTitle(), actual.getTitle()); this.assertStringEqualsNullOrEmptyAware("Comment differs", expected.getComment(), actual.getComment()); // iterate over the contained Propositions and their super ordinated Relations, thereby producing helpful output in case of an error - this.assertPropositionListEquals(expected.getText(), actual.getText(), new HashSet()); + this.assertPropositionListEquals(expected.getText(), actual.getText(), new HashSet<>()); // this covers the whole model but does not provide a helpful error message Assert.assertEquals(expected, actual); } @@ -297,11 +297,11 @@ public void testGetSystemLanguageModels() throws HmxException { model.add(Arrays.asList(new SyntacticalFunction("GenO", "Genitive Object", false, null), new SyntacticalFunction("DatO", "Dative Object", false, null), new SyntacticalFunction("AccO", "Accusative Object", false, null), new SyntacticalFunction("PrepO", "Prepositional Object", false, null))); - final List groups = new ArrayList(2); + final List groups = new ArrayList<>(2); for (final String[] groupedType : new String[][] { new String[] { "Complement", "necessary" }, new String[] { "Adjunct", "erasable" } }) { final String type = groupedType[0]; final char firstChar = type.charAt(0); - final List subTypes = new ArrayList(8); + final List subTypes = new ArrayList<>(8); subTypes.add(new SyntacticalFunction("SId" + firstChar, "Subject-Indentification-" + type, false, null)); subTypes.add(new SyntacticalFunction("SMan" + firstChar, "Subject-Manner-" + type, false, null)); subTypes.add(new SyntacticalFunction("OId" + firstChar, "Object-Indentification-" + type, false, null)); @@ -309,7 +309,7 @@ public void testGetSystemLanguageModels() throws HmxException { subTypes.add(new SyntacticalFunction("Loc" + firstChar, "Locale-" + type, false, null)); subTypes.add(new SyntacticalFunction("Time" + firstChar, "Time-" + type, false, null)); subTypes.add(new SyntacticalFunction("Mod" + firstChar, "Modal-" + type, false, null)); - final List subSubTypes = new ArrayList(7); + final List subSubTypes = new ArrayList<>(7); subSubTypes.add(new SyntacticalFunction("Caus" + firstChar, "causal", false, null)); subSubTypes.add(new SyntacticalFunction("Cond" + firstChar, "conditional", false, null)); subSubTypes.add(new SyntacticalFunction("Cons" + firstChar, "consecutiv", false, null)); @@ -388,7 +388,7 @@ public void testGetSystemRelationModel() throws HmxException { final AssociateRole nucleus = new AssociateRole("Nucleus", true); model.add(Arrays.asList(new RelationTemplate(sequentialNucleus, sequentialNucleus, sequentialNucleus, null), new RelationTemplate( simultaneousNucleus, simultaneousNucleus, simultaneousNucleus, null), new RelationTemplate(nucleus, nucleus, nucleus, null))); - final List secondGroup = new LinkedList(); + final List secondGroup = new LinkedList<>(); secondGroup.add(new RelationTemplate(new AssociateRole("Orienter", false), null, new AssociateRole("Content", true), null)); secondGroup.add(new RelationTemplate(new AssociateRole("Circumstance", false), null, nucleus, null)); secondGroup.add(new RelationTemplate(new AssociateRole("Move", false), null, new AssociateRole("Goal", true), null)); diff --git a/scitos.hmx/scitos.hmx.core/src/test/java/org/hmx/scitos/hmx/core/i18n/HmxMessageTest.java b/scitos.hmx/scitos.hmx.core/src/test/java/org/hmx/scitos/hmx/core/i18n/HmxMessageTest.java index b45faf2..5ee2554 100644 --- a/scitos.hmx/scitos.hmx.core/src/test/java/org/hmx/scitos/hmx/core/i18n/HmxMessageTest.java +++ b/scitos.hmx/scitos.hmx.core/src/test/java/org/hmx/scitos/hmx/core/i18n/HmxMessageTest.java @@ -44,8 +44,8 @@ public class HmxMessageTest { public void testMessageAvailability() { final ResourceBundle bundle = ResourceBundle.getBundle(HmxMessage.class.getName(), Locale.ENGLISH, new XmlResourceBundleControl()); Assert.assertNotNull(bundle); - final List unusedMessages = new LinkedList(); - final List unavailableMessages = new LinkedList(); + final List unusedMessages = new LinkedList<>(); + final List unavailableMessages = new LinkedList<>(); final Enumeration availableKeys = bundle.getKeys(); while (availableKeys.hasMoreElements()) { unusedMessages.add(availableKeys.nextElement()); diff --git a/scitos.hmx/scitos.hmx.domain/pom.xml b/scitos.hmx/scitos.hmx.domain/pom.xml index 1b89b7f..9e5bc0c 100644 --- a/scitos.hmx/scitos.hmx.domain/pom.xml +++ b/scitos.hmx/scitos.hmx.domain/pom.xml @@ -3,7 +3,7 @@ org.hmx scitos.hmx - 2.3.1 + 2.4.0-SNAPSHOT scitos.hmx.domain domain project of the SciToS module HmX diff --git a/scitos.hmx/scitos.hmx.domain/src/main/java/org/hmx/scitos/hmx/domain/model/LanguageModel.java b/scitos.hmx/scitos.hmx.domain/src/main/java/org/hmx/scitos/hmx/domain/model/LanguageModel.java index 350b2da..0e8662f 100644 --- a/scitos.hmx/scitos.hmx.domain/src/main/java/org/hmx/scitos/hmx/domain/model/LanguageModel.java +++ b/scitos.hmx/scitos.hmx.domain/src/main/java/org/hmx/scitos/hmx/domain/model/LanguageModel.java @@ -51,8 +51,8 @@ public class LanguageModel implements ISyntacticalFunctionProvider, Serializable public LanguageModel(final String name, final boolean leftToRightOriented) { this.name = name; this.leftToRightOriented = leftToRightOriented; - this.recommendedFonts = new LinkedList(); - this.functionGroups = new LinkedList>(); + this.recommendedFonts = new LinkedList<>(); + this.functionGroups = new LinkedList<>(); } /** diff --git a/scitos.hmx/scitos.hmx.domain/src/main/java/org/hmx/scitos/hmx/domain/model/Pericope.java b/scitos.hmx/scitos.hmx.domain/src/main/java/org/hmx/scitos/hmx/domain/model/Pericope.java index 5af40aa..01f252d 100755 --- a/scitos.hmx/scitos.hmx.domain/src/main/java/org/hmx/scitos/hmx/domain/model/Pericope.java +++ b/scitos.hmx/scitos.hmx.domain/src/main/java/org/hmx/scitos/hmx/domain/model/Pericope.java @@ -41,7 +41,7 @@ public final class Pericope implements IModel, IPropositionParent, ICo /** The origin text language's syntactical model. */ private LanguageModel languageModel; /** The top level propositions, that in turn can contain more subordinated propositions. */ - private final List text = new LinkedList(); + private final List text = new LinkedList<>(); /** * The origin text's font, to allow the analysis of languages that require a special {@link Font} in order to be displayed properly. */ @@ -121,13 +121,13 @@ public void addNewPropositions(final List originText, final boolean * @return represented text */ private List buildPropositionsFromText(final String originText) { - final List propositions = new ArrayList(); + final List propositions = new ArrayList<>(); for (final String originTextPart : originText.split(System.getProperty("line.separator"))) { if (originTextPart.trim().isEmpty()) { // empty lines should be ignored continue; } - final List items = new ArrayList(); + final List items = new ArrayList<>(); for (String singleItemText : originTextPart.split("\t")) { // empty items should be ignored singleItemText = singleItemText.trim().replaceAll("\\s+", " "); @@ -156,7 +156,7 @@ public List getText() { * @return ordered list of all {@code Proposition}s */ public List getFlatText() { - final List result = new LinkedList(); + final List result = new LinkedList<>(); for (final Proposition singleTopLevelProposition : this.text) { // recursively fill result list this.collectFlatText(singleTopLevelProposition, result); @@ -198,7 +198,7 @@ private void collectFlatText(final Proposition target, final List f * @return ordered list of all relations */ public List getFlatRelations() { - final List result = new LinkedList(); + final List result = new LinkedList<>(); // get the first Proposition AbstractConnectable currentFocus = this.getPropositionAt(0); while (currentFocus != null) { @@ -435,7 +435,7 @@ public Pericope clone() { */ final List originRelations = this.getFlatRelations(); if (originRelations != null) { - final List clonedRelations = new ArrayList(originRelations.size()); + final List clonedRelations = new ArrayList<>(originRelations.size()); for (final Relation singleRelation : originRelations) { clonedRelations.add(singleRelation.clone()); } @@ -472,7 +472,7 @@ public Pericope clone() { private void cloneAssociations(final Relation subTreeHead, final List originRelations, final Pericope clonedPericope, final List clonedRelations) { final List topAssociates = subTreeHead.getAssociates(); - final List clonedAssociates = new ArrayList(topAssociates.size()); + final List clonedAssociates = new ArrayList<>(topAssociates.size()); final Relation clonedSubTreeHead = clonedRelations.get(CollectionUtil.indexOfInstance(originRelations, subTreeHead)); for (final AbstractConnectable originAssociate : topAssociates) { final AbstractConnectable clonedAssociate; diff --git a/scitos.hmx/scitos.hmx.domain/src/main/java/org/hmx/scitos/hmx/domain/model/Proposition.java b/scitos.hmx/scitos.hmx.domain/src/main/java/org/hmx/scitos/hmx/domain/model/Proposition.java index a346414..65ffe8b 100755 --- a/scitos.hmx/scitos.hmx.domain/src/main/java/org/hmx/scitos/hmx/domain/model/Proposition.java +++ b/scitos.hmx/scitos.hmx.domain/src/main/java/org/hmx/scitos/hmx/domain/model/Proposition.java @@ -45,7 +45,7 @@ public final class Proposition extends AbstractConnectable implements Cloneable, /** * The included {@link ClauseItem}s containing the represented origin text part. */ - private final List items = new LinkedList(); + private final List items = new LinkedList<>(); /** The identifying label. */ private String label; /** The syntactical indentation function. */ @@ -228,7 +228,7 @@ public void setPriorChildren(final List priorChildren) { if (priorChildren == null || priorChildren.isEmpty()) { this.priorChildren = null; } else { - this.priorChildren = new ArrayList(priorChildren); + this.priorChildren = new ArrayList<>(priorChildren); for (final Proposition singleChild : this.priorChildren) { singleChild.setParent(this); } @@ -257,7 +257,7 @@ public void setLaterChildren(final List laterChildren) { if (laterChildren == null || laterChildren.isEmpty()) { this.laterChildren = null; } else { - this.laterChildren = new ArrayList(laterChildren); + this.laterChildren = new ArrayList<>(laterChildren); for (final Proposition singleChild : this.laterChildren) { singleChild.setParent(this); } @@ -390,7 +390,7 @@ public void addLastPriorChild(final Proposition childProposition) { */ private void addPriorChild(final Proposition childProposition, final boolean asLeadingChild) { if (this.priorChildren == null) { - this.priorChildren = new LinkedList(); + this.priorChildren = new LinkedList<>(); } childProposition.setParent(this); if (asLeadingChild) { @@ -430,7 +430,7 @@ public void addLastLaterChild(final Proposition childProposition) { */ private void addLaterChild(final Proposition childProposition, final boolean asLeadingChild) { if (this.laterChildren == null) { - this.laterChildren = new LinkedList(); + this.laterChildren = new LinkedList<>(); } childProposition.setParent(this); if (asLeadingChild) { @@ -511,7 +511,7 @@ public Iterator iterator() { */ @Override public Proposition clone() { - final List clonedItems = new ArrayList(this.items.size()); + final List clonedItems = new ArrayList<>(this.items.size()); for (final ClauseItem singleItem : this.items) { clonedItems.add(singleItem.clone()); } @@ -522,7 +522,7 @@ public Proposition clone() { cloned.synTranslation = this.synTranslation; cloned.setComment(this.getComment()); if (this.priorChildren != null) { - cloned.priorChildren = new ArrayList(this.priorChildren.size()); + cloned.priorChildren = new ArrayList<>(this.priorChildren.size()); for (final Proposition singlePriorChild : this.priorChildren) { final Proposition clonedChild = singlePriorChild.clone(); clonedChild.setParent(cloned); @@ -530,7 +530,7 @@ public Proposition clone() { } } if (this.laterChildren != null) { - cloned.laterChildren = new ArrayList(this.laterChildren.size()); + cloned.laterChildren = new ArrayList<>(this.laterChildren.size()); for (final Proposition singleLaterChild : this.laterChildren) { final Proposition clonedChild = singleLaterChild.clone(); clonedChild.setParent(cloned); diff --git a/scitos.hmx/scitos.hmx.domain/src/main/java/org/hmx/scitos/hmx/domain/model/Relation.java b/scitos.hmx/scitos.hmx.domain/src/main/java/org/hmx/scitos/hmx/domain/model/Relation.java index c4b2ed8..3332203 100755 --- a/scitos.hmx/scitos.hmx.domain/src/main/java/org/hmx/scitos/hmx/domain/model/Relation.java +++ b/scitos.hmx/scitos.hmx.domain/src/main/java/org/hmx/scitos/hmx/domain/model/Relation.java @@ -34,7 +34,7 @@ public final class Relation extends AbstractConnectable implements Cloneable, Iterable { /** The subordinated elements forming this relation. */ - private final List associates = new LinkedList(); + private final List associates = new LinkedList<>(); /** * Constructor: for a {@code Relation} between the specified associates with the respective role and weight. diff --git a/scitos.hmx/scitos.hmx.domain/src/main/java/org/hmx/scitos/hmx/domain/model/RelationModel.java b/scitos.hmx/scitos.hmx.domain/src/main/java/org/hmx/scitos/hmx/domain/model/RelationModel.java index a0013cb..c7904f6 100644 --- a/scitos.hmx/scitos.hmx.domain/src/main/java/org/hmx/scitos/hmx/domain/model/RelationModel.java +++ b/scitos.hmx/scitos.hmx.domain/src/main/java/org/hmx/scitos/hmx/domain/model/RelationModel.java @@ -37,7 +37,7 @@ public class RelationModel implements ISemanticalRelationProvider, Serializable, * Constructor: initializing an empty set of template groups. */ public RelationModel() { - this.relationTemplateGroups = new LinkedList>(); + this.relationTemplateGroups = new LinkedList<>(); } /** @@ -73,7 +73,7 @@ public void addAll(final List> groups) { * single group of relation templates to add to this model */ public void add(final List group) { - this.relationTemplateGroups.add(Collections.unmodifiableList(new ArrayList(group))); + this.relationTemplateGroups.add(Collections.unmodifiableList(new ArrayList<>(group))); } @Override diff --git a/scitos.hmx/scitos.hmx.domain/src/main/java/org/hmx/scitos/hmx/domain/model/RelationTemplate.java b/scitos.hmx/scitos.hmx.domain/src/main/java/org/hmx/scitos/hmx/domain/model/RelationTemplate.java index ac437a1..8615fd6 100644 --- a/scitos.hmx/scitos.hmx.domain/src/main/java/org/hmx/scitos/hmx/domain/model/RelationTemplate.java +++ b/scitos.hmx/scitos.hmx.domain/src/main/java/org/hmx/scitos/hmx/domain/model/RelationTemplate.java @@ -78,7 +78,7 @@ public List getAssociateRoles(final int associateCount) { if (associateCount < 1 || associateCount > 2 && !this.canHaveMoreThanTwoAssociates()) { throw new IllegalArgumentException(); } - final List result = new ArrayList(associateCount); + final List result = new ArrayList<>(associateCount); result.add(this.leadingAssociate); final int repetitiveAssociatesToAdd = associateCount - 2; for (int count = 0; count < repetitiveAssociatesToAdd; count++) { diff --git a/scitos.hmx/scitos.hmx.view/pom.xml b/scitos.hmx/scitos.hmx.view/pom.xml index 88e11da..ddee5c0 100644 --- a/scitos.hmx/scitos.hmx.view/pom.xml +++ b/scitos.hmx/scitos.hmx.view/pom.xml @@ -3,7 +3,7 @@ org.hmx scitos.hmx - 2.3.1 + 2.4.0-SNAPSHOT scitos.hmx.view scitos.hmx.view diff --git a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/ContextMenuFactory.java b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/ContextMenuFactory.java index 9c24500..a008e93 100755 --- a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/ContextMenuFactory.java +++ b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/ContextMenuFactory.java @@ -333,7 +333,7 @@ public void processSelectEvent() throws HmxException { private static void addHighlightClauseItemEntry(final ContextMenuBuilder popupMenu, final IPericopeView viewReference, final ClauseItem item) { final CMenu highlightEntry = popupMenu.addMenu(HmxMessage.MENU_HIGHLIGHT_ITEM.get()); // set PLAIN - final Map styles = new LinkedHashMap(); + final Map styles = new LinkedHashMap<>(); styles.put(Style.PLAIN, HmxMessage.MENU_HIGHLIGHT_ITEM_PLAIN); styles.put(Style.BOLD, HmxMessage.MENU_HIGHLIGHT_ITEM_BOLD); styles.put(Style.ITALIC, HmxMessage.MENU_HIGHLIGHT_ITEM_ITALIC); @@ -618,7 +618,7 @@ private static String buildRelationLabel(final List roles, final itemLabel.append(" - ..."); } } else { - final Map indices = new HashMap(); + final Map indices = new HashMap<>(); for (final AssociateRole singleRole : roles) { Integer index = indices.get(singleRole); if (itemLabel.length() > 0) { diff --git a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/components/AnalysisPanel.java b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/components/AnalysisPanel.java index b7ac348..1b0f83b 100644 --- a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/components/AnalysisPanel.java +++ b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/components/AnalysisPanel.java @@ -132,7 +132,7 @@ public void updateUI() { * The indices of currently collapsed {@link Relation} columns, i.e. where the associate roles are currently hidden to reduce required horizontal * space. */ - private final Set foldedLevels = new HashSet(); + private final Set foldedLevels = new HashSet<>(); /** * Complete list of currently contained view components representing the {@link Pericope}'s {@link Proposition}s. */ @@ -159,7 +159,7 @@ protected AnalysisPanel(final HmxModelHandler modelHandler, final ISemanticalRel this.modelHandler = modelHandler; this.relationProvider = relationProvider; this.viewSettings = viewSettings; - this.undoManager = new UndoManager(modelHandler.getModel()); + this.undoManager = new UndoManager<>(modelHandler.getModel()); this.scrollPane = this.initScrollableContent(); // initialize the commentArea to be reachable by commentable components @@ -330,7 +330,7 @@ public void refresh() { this.rightContentSpacing.setVisible(!showingRelations); this.contentArea.removeAll(); // get the currently used origin text font - this.propositionList = new ArrayList(); + this.propositionList = new ArrayList<>(); // fill the propositionList int propositionIndexOffset = 0; for (final Proposition singleTopLevelProposition : this.getModelHandler().getModel().getText()) { @@ -339,7 +339,7 @@ public void refresh() { // show pericope this.levels = this.calculateLevels(); this.displayPropositions(); - this.relationMap = new HashMap(); + this.relationMap = new HashMap<>(); if (this.viewSettings.isShowingRelations()) { this.displayRelations(); } @@ -532,7 +532,7 @@ public void submitChangesToModel() { @Override public List getSelectedPropositions(final Proposition defaultSelected) { - final List result = new LinkedList(); + final List result = new LinkedList<>(); for (ViewProposition singleProposition : this.propositionList) { if (singleProposition.isChecked() || singleProposition.getRepresented() == defaultSelected) { result.add(singleProposition.getRepresented()); @@ -543,7 +543,7 @@ public List getSelectedPropositions(final Proposition defaultSelect @Override public List getSelectedConnectables(final AbstractConnectable defaultSelected) { - final List list = new LinkedList(); + final List list = new LinkedList<>(); // REQUIREMENT: whole model is represented in the view AbstractConnectable nextToCheck = this.propositionList.get(0).getRepresented(); while (nextToCheck != null) { @@ -675,7 +675,7 @@ void resetHeaders() { return; } // calculate width of each column - final Map maxColumnSize = new HashMap(); + final Map maxColumnSize = new HashMap<>(); final GridBagLayout contentLayout = (GridBagLayout) this.contentArea.getLayout(); // check each component for its width and determine maximum per column for (final Component singleComponent : this.contentArea.getComponents()) { diff --git a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/components/SingleProjectView.java b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/components/SingleProjectView.java index 029854c..d8bf06b 100644 --- a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/components/SingleProjectView.java +++ b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/components/SingleProjectView.java @@ -22,8 +22,6 @@ import java.awt.BorderLayout; import java.awt.Component; import java.awt.Font; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.io.File; import java.util.Arrays; import java.util.List; @@ -329,44 +327,26 @@ public void redo() { @Override public List createEditMenuItems() { this.addTextItem = new JMenuItem(HmxMessage.MENUBAR_ORIGINTEXT_ADD.get(), ScitosIcon.ADD.create()); - this.addTextItem.addActionListener(new ActionListener() { - @Override - public void actionPerformed(final ActionEvent event) { - SingleProjectView.this.goToTextInputView(); - } - }); + this.addTextItem.addActionListener(event -> this.goToTextInputView()); this.removeTextItem = new JMenuItem(HmxMessage.MENUBAR_ORIGINTEXT_REMOVE.get(), ScitosIcon.DELETE.create()); - this.removeTextItem.addActionListener(new ActionListener() { - @Override - public void actionPerformed(final ActionEvent event) { - if (SingleProjectView.this.activeView instanceof IPericopeView - && MessageHandler.Choice.YES == MessageHandler.showConfirmDialog(HmxMessage.MENUBAR_ORIGINTEXT_REMOVE_CONFIRM.get(), - HmxMessage.MENUBAR_ORIGINTEXT_REMOVE.get())) { - final List selection = ((IPericopeView) SingleProjectView.this.activeView).getSelectedPropositions(null); - try { - SingleProjectView.this.getProject().getModelHandler().removePropositions(selection); - } catch (final HmxException expected) { - // illegal selection of Propositions - MessageHandler.showException(expected); - } + this.removeTextItem.addActionListener(event -> { + if (this.activeView instanceof IPericopeView + && MessageHandler.Choice.YES == MessageHandler.showConfirmDialog(HmxMessage.MENUBAR_ORIGINTEXT_REMOVE_CONFIRM.get(), + HmxMessage.MENUBAR_ORIGINTEXT_REMOVE.get())) { + final List selection = ((IPericopeView) this.activeView).getSelectedPropositions(null); + try { + this.getProject().getModelHandler().removePropositions(selection); + } catch (final HmxException expected) { + // illegal selection of Propositions + MessageHandler.showException(expected); } } }); this.mergeProjectItem = new JMenuItem(HmxMessage.MENUBAR_PROJECT_MERGE.get(), ScitosIcon.PROJECT_OPEN.create()); - this.mergeProjectItem.addActionListener(new ActionListener() { - @Override - public void actionPerformed(final ActionEvent event) { - SingleProjectView.this.mergeWithOtherPericope(); - } - }); + this.mergeProjectItem.addActionListener(event -> this.mergeWithOtherPericope()); final JMenuItem projectInfoItem = new JMenuItem(HmxMessage.MENUBAR_PROJECTINFO.get(), ScitosIcon.CLIPBOARD.create()); - projectInfoItem.addActionListener(new ActionListener() { - @Override - public void actionPerformed(final ActionEvent event) { - final boolean alreadyInProgress = SingleProjectView.this.activeView instanceof AnalysisPanel; - new ProjectInfoDialog(SingleProjectView.this.getProject(), alreadyInProgress).setVisible(true); - } - }); + projectInfoItem.addActionListener(event -> new ProjectInfoDialog(this.getProject(), + this.activeView instanceof AnalysisPanel).setVisible(true)); this.manageEditMenuOptions(); return Arrays.asList(this.addTextItem, this.removeTextItem, this.mergeProjectItem, null, projectInfoItem); } @@ -375,52 +355,22 @@ public void actionPerformed(final ActionEvent event) { public List createViewMenuItems() { this.viewPropositionLabelMenuItem = new JCheckBoxMenuItem(HmxMessage.MENUBAR_TOGGLE_PROPOSITION_LABELS.get(), ScitosIcon.ATTRIBUTES_DISPLAY.create()); - this.viewPropositionLabelMenuItem.addActionListener(new ActionListener() { - @Override - public void actionPerformed(final ActionEvent event) { - SingleProjectView.this.togglePropositionLabelVisibility(); - } - }); + this.viewPropositionLabelMenuItem.addActionListener(event -> this.togglePropositionLabelVisibility()); this.viewPropositionIndentationMenuItem = new JCheckBoxMenuItem(HmxMessage.MENUBAR_TOGGLE_PROPOSITION_INDENTATIONS.get(), ScitosIcon.TREE.create()); - this.viewPropositionIndentationMenuItem.addActionListener(new ActionListener() { - @Override - public void actionPerformed(final ActionEvent event) { - SingleProjectView.this.togglePropositionIndentationVisibility(); - } - }); + this.viewPropositionIndentationMenuItem.addActionListener(event -> this.togglePropositionIndentationVisibility()); this.viewRelationMenuItem = new JCheckBoxMenuItem(HmxMessage.MENUBAR_TOGGLE_RELATIONS.get(), ScitosIcon.RELATIONS.create()); - this.viewRelationMenuItem.addActionListener(new ActionListener() { - @Override - public void actionPerformed(final ActionEvent event) { - SingleProjectView.this.toggleRelationVisibility(); - } - }); + this.viewRelationMenuItem.addActionListener(event -> this.toggleRelationVisibility()); this.viewClauseItemMenuItem = new JCheckBoxMenuItem(HmxMessage.MENUBAR_TOGGLE_CLAUSE_ITEMS.get(), ScitosIcon.GRID.create()); - this.viewClauseItemMenuItem.addActionListener(new ActionListener() { - @Override - public void actionPerformed(final ActionEvent event) { - SingleProjectView.this.toggleClauseItemVisibility(); - } - }); + this.viewClauseItemMenuItem.addActionListener(event -> this.toggleClauseItemVisibility()); this.viewSyntacticTranslationMenuItem = new JCheckBoxMenuItem(HmxMessage.MENUBAR_TOGGLE_SYNTACTIC_TRANSLATIONS.get(), ScitosIcon.HORIZONTAL_RULE.create()); - this.viewSyntacticTranslationMenuItem.addActionListener(new ActionListener() { - @Override - public void actionPerformed(final ActionEvent event) { - SingleProjectView.this.toggleSyntacticTranslationVisibility(); - } - }); + this.viewSyntacticTranslationMenuItem.addActionListener(event -> this.toggleSyntacticTranslationVisibility()); this.viewSemanticTranslationMenuItem = new JCheckBoxMenuItem(HmxMessage.MENUBAR_TOGGLE_SEMANTIC_TRANSLATIONS.get(), ScitosIcon.HORIZONTAL_RULE.create()); - this.viewSemanticTranslationMenuItem.addActionListener(new ActionListener() { - @Override - public void actionPerformed(final ActionEvent event) { - SingleProjectView.this.toggleSemanticTranslationVisibility(); - } - }); + this.viewSemanticTranslationMenuItem.addActionListener(event -> this.toggleSemanticTranslationVisibility()); this.manageViewMenuOptions(); return Arrays.asList(this.viewPropositionLabelMenuItem, this.viewPropositionIndentationMenuItem, this.viewRelationMenuItem, this.viewClauseItemMenuItem, this.viewSyntacticTranslationMenuItem, this.viewSemanticTranslationMenuItem); @@ -431,30 +381,15 @@ public List createToolBarItems() { this.allViewDetailsToolBarItem = new JToggleButton(HmxMessage.ANALYSIS_PRESET_SHOW_ALL.get(), ScitosIcon.ATTRIBUTES_DISPLAY.create()); this.allViewDetailsToolBarItem.setFocusable(false); this.allViewDetailsToolBarItem.setName("Preset: All"); - this.allViewDetailsToolBarItem.addActionListener(new ActionListener() { - @Override - public void actionPerformed(final ActionEvent event) { - SingleProjectView.this.applyViewPreset(IAnalysisViewSettings.SHOW_ALL); - } - }); + this.allViewDetailsToolBarItem.addActionListener(event -> this.applyViewPreset(IAnalysisViewSettings.SHOW_ALL)); this.syntacticalAnalysisToolBarItem = new JToggleButton(HmxMessage.ANALYSIS_PRESET_SYNTACTICAL.get(), ScitosIcon.GRID.create()); this.syntacticalAnalysisToolBarItem.setFocusable(false); this.syntacticalAnalysisToolBarItem.setName("Preset: Syntactical"); - this.syntacticalAnalysisToolBarItem.addActionListener(new ActionListener() { - @Override - public void actionPerformed(final ActionEvent event) { - SingleProjectView.this.applyViewPreset(IAnalysisViewSettings.SYNTACTICAL_ANALYSIS); - } - }); + this.syntacticalAnalysisToolBarItem.addActionListener(event -> this.applyViewPreset(IAnalysisViewSettings.SYNTACTICAL_ANALYSIS)); this.semanticalAnalysisToolBarItem = new JToggleButton(HmxMessage.ANALYSIS_PRESET_SEMANTICAL.get(), ScitosIcon.RELATIONS.create()); this.semanticalAnalysisToolBarItem.setFocusable(false); this.semanticalAnalysisToolBarItem.setName("Preset: Semantical"); - this.semanticalAnalysisToolBarItem.addActionListener(new ActionListener() { - @Override - public void actionPerformed(final ActionEvent event) { - SingleProjectView.this.applyViewPreset(IAnalysisViewSettings.SEMANTICAL_ANALYSIS); - } - }); + this.semanticalAnalysisToolBarItem.addActionListener(event -> this.applyViewPreset(IAnalysisViewSettings.SEMANTICAL_ANALYSIS)); this.manageToolBarItems(); return Arrays.asList(this.allViewDetailsToolBarItem, this.syntacticalAnalysisToolBarItem, this.semanticalAnalysisToolBarItem); } diff --git a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/components/TextInputPanel.java b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/components/TextInputPanel.java index d5f9275..c809770 100755 --- a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/components/TextInputPanel.java +++ b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/components/TextInputPanel.java @@ -147,7 +147,7 @@ public void actionPerformed(final ActionEvent event) { } }); } else { - this.languageModels = new HashMap(); + this.languageModels = new HashMap<>(); final String language = parentView.getModel().getLanguage(); final LanguageModel currentModel = new LanguageModel(language, parentView.getModel().isLeftToRightOriented()); currentModel.addAll(parentView.getModel().provideFunctions()); @@ -461,7 +461,7 @@ void manageSettingVisibility() { * @return created {@link JPanel} */ private JPanel createLanguageComboBox() { - this.languageBox = new JComboBox(this.languageModels.keySet().toArray(new String[this.languageModels.size()])); + this.languageBox = new JComboBox<>(this.languageModels.keySet().toArray(new String[this.languageModels.size()])); this.languageBox.setName("Language Selection"); this.languageBox.setEditable(false); if (this.languageModels.size() < 2) { @@ -504,7 +504,7 @@ void setOriginTextPaneOrientation() { private JPanel createFontTypeComboBox() { this.fontFamilyNames = Arrays.asList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()); Collections.sort(this.fontFamilyNames); - this.fontTypeBox = new JComboBox(this.fontFamilyNames.toArray(new String[this.fontFamilyNames.size()])); + this.fontTypeBox = new JComboBox<>(this.fontFamilyNames.toArray(new String[this.fontFamilyNames.size()])); this.fontTypeBox.setName("Font Type Selection"); this.fontTypeBox.setEditable(false); this.fontTypeBox.addActionListener(new ActionListener() { diff --git a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/elements/ViewProposition.java b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/elements/ViewProposition.java index 7f01f45..a24f26e 100644 --- a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/elements/ViewProposition.java +++ b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/elements/ViewProposition.java @@ -222,7 +222,7 @@ public ViewProposition(final IPericopeView viewReference, final Proposition repr this.functionLabel = this.initFunctionLabel(); if (viewSettings.isShowingClauseItems()) { this.originText = null; - this.items = new LinkedList(); + this.items = new LinkedList<>(); } else { this.originText = new ScaledTextField(); this.items = null; diff --git a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/elements/ViewRelation.java b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/elements/ViewRelation.java index cc3906c..c045953 100755 --- a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/elements/ViewRelation.java +++ b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/elements/ViewRelation.java @@ -117,7 +117,7 @@ public ViewRelation(final AnalysisPanel analysisPanel, final Relation represente final List modelAssociates = represented.getAssociates(); this.showRoleAboveLine = analysisPanel.getViewSettings().isShowingSemanticTranslations() || analysisPanel.getViewSettings().isShowingSyntacticTranslations(); - this.viewAssociates = new ArrayList>(modelAssociates.size()); + this.viewAssociates = new ArrayList<>(modelAssociates.size()); for (final AbstractConnectable singleAssociate : modelAssociates) { this.viewAssociates.add(this.analysisPanel.getRepresentative(singleAssociate)); } @@ -132,7 +132,7 @@ public ViewRelation(final AnalysisPanel analysisPanel, final Relation represente this.roleFields = null; } else { final int associateCount = modelAssociates.size(); - this.roleFields = new ArrayList(associateCount); + this.roleFields = new ArrayList<>(associateCount); final Border outsideBorder; if (this.showRoleAboveLine) { outsideBorder = BorderFactory.createLoweredBevelBorder(); @@ -226,7 +226,7 @@ protected void paintComponent(final Graphics graphics) { final int topBorder = ViewRelation.COMMENT_BORDER.getBorderInsets(this).top; final int lineLeftEnd; final int lineWidth; - final List horizontalLines = new ArrayList(this.viewAssociates.size()); + final List horizontalLines = new ArrayList<>(this.viewAssociates.size()); if (this.leftAligned) { lineLeftEnd = startX; lineWidth = this.getSize().width - startX; diff --git a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/FontChooser.java b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/FontChooser.java index d6c70d5..d04f446 100644 --- a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/FontChooser.java +++ b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/FontChooser.java @@ -60,7 +60,7 @@ public final class FontChooser extends JPanel { public FontChooser() { final String[] fontFamilyNames = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); Arrays.sort(fontFamilyNames); - this.fontTypeBox = new JComboBox(fontFamilyNames); + this.fontTypeBox = new JComboBox<>(fontFamilyNames); AutoCompleteDecorator.decorate(this.fontTypeBox); this.fontTypeBox.addActionListener(new ActionListener() { diff --git a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/HmxLanguageOptionPanel.java b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/HmxLanguageOptionPanel.java index 03742cb..aa7d56f 100644 --- a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/HmxLanguageOptionPanel.java +++ b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/HmxLanguageOptionPanel.java @@ -133,7 +133,7 @@ public boolean areChosenSettingsValid() { return false; } for (final LanguageModel singleModel : this.languagePanel.getUserModels()) { - final Set codes = new HashSet(); + final Set codes = new HashSet<>(); for (final List singleTopLevelGroup : singleModel.provideFunctions()) { if (this.containsDuplicateFunctionCode(singleTopLevelGroup, codes)) { final String message = MessageFormat.format(HmxMessage.PREFERENCES_LANGUAGEFUNCTIONS_CODE_UNIQUE.get(), singleModel.getName()); diff --git a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/LanguageConfigPanel.java b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/LanguageConfigPanel.java index b5ff149..5d0f5ba 100644 --- a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/LanguageConfigPanel.java +++ b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/LanguageConfigPanel.java @@ -65,7 +65,7 @@ public final class LanguageConfigPanel extends JPanel { /** Button to disable the language form without applying the changes made. */ private final JButton discardFormChangesButton = new JButton(HmxMessage.PREFERENCES_LANGUAGE_DISCARD.get()); /** Labels associated with form fields that should be enabled/disabled with their respective inputs. */ - private final List formLabels = new ArrayList(3); + private final List formLabels = new ArrayList<>(3); /** Form input field: name of a language model. */ private final JTextField languageNameInput = new JTextField(new Validation(128), null, 0); /** Form input field: indication whether the origin text is left-to-right oriented. */ @@ -77,7 +77,7 @@ public final class LanguageConfigPanel extends JPanel { /** Form input field: list of recommended origin text fonts. */ private final JTextField recommendedFontsInput = new JTextField(new Validation(512), null, 0); /** Registered external listeners for changes to the language model selection. */ - private final List actionListeners = new ArrayList(1); + private final List actionListeners = new ArrayList<>(1); /** * Constructor. @@ -273,7 +273,7 @@ void applyFormChanges() { } final boolean leftToRightOriented = this.leftToRightButton.isSelected(); final String[] recommendedFonts = this.recommendedFontsInput.getText().trim().split("([\\s]*[;][\\s]*)+"); - final List fontList = new ArrayList(Arrays.asList(recommendedFonts)); + final List fontList = new ArrayList<>(Arrays.asList(recommendedFonts)); // remove empty entry if there is one fontList.remove(""); final LanguageModel model = this.getSelectedModel(); diff --git a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/LanguageTreeModel.java b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/LanguageTreeModel.java index 8ac0f00..6579fb5 100644 --- a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/LanguageTreeModel.java +++ b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/LanguageTreeModel.java @@ -52,7 +52,7 @@ final class LanguageTreeModel extends AbstractTreeTableModel { /** The read-only system-defined language models. */ - private final Map languageModels = new LinkedHashMap(); + private final Map languageModels = new LinkedHashMap<>(); /** The number of unchangeable system defined language models (at the top of the table). */ private final int systemModelCount; @@ -253,7 +253,7 @@ void fireModelRowUpdated(final LanguageModel model) { if (index < this.systemModelCount) { throw new IllegalArgumentException(); } - final UUID node = new ArrayList(this.languageModels.keySet()).get(index); + final UUID node = new ArrayList<>(this.languageModels.keySet()).get(index); this.modelSupport.fireChildChanged(new TreePath(this.getRoot()), index, node); } @@ -263,6 +263,6 @@ void fireModelRowUpdated(final LanguageModel model) { * @return the user-defined language-models */ List getUserLanguageModels() { - return new ArrayList(this.languageModels.values()).subList(this.systemModelCount, this.languageModels.size()); + return new ArrayList<>(this.languageModels.values()).subList(this.systemModelCount, this.languageModels.size()); } } diff --git a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/RelationTreeModel.java b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/RelationTreeModel.java index fb43f77..40d9b3c 100644 --- a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/RelationTreeModel.java +++ b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/RelationTreeModel.java @@ -57,11 +57,11 @@ final class RelationTreeModel extends AbstractTreeTableModel implements ISemanti * The groups of relation templates – directly under the root of the tree structure - identified by a UUID and mapping to the list of contained * relation templates' UUIDs. */ - private final Map> relationGroups = new LinkedHashMap>(); + private final Map> relationGroups = new LinkedHashMap<>(); /** * The individual relation template associated with their respective UUID. */ - private final Map relationTemplates = new HashMap(); + private final Map relationTemplates = new HashMap<>(); /** * Constructor. @@ -73,7 +73,7 @@ final class RelationTreeModel extends AbstractTreeTableModel implements ISemanti super(new Object()); // setup delegate structure (as the TreeModel cannot handle the mutable data objects as immediate nodes) for (final List singleGroup : relationProvider.provideRelationTemplates()) { - final List relationTemplatesInGroup = new LinkedList(); + final List relationTemplatesInGroup = new LinkedList<>(); for (final RelationTemplate singleTemplate : singleGroup) { // map each relation template to a random UUID final UUID templateId = UUID.randomUUID(); @@ -87,9 +87,9 @@ final class RelationTreeModel extends AbstractTreeTableModel implements ISemanti @Override public List> provideRelationTemplates() { - final List> result = new ArrayList>(this.relationGroups.size()); + final List> result = new ArrayList<>(this.relationGroups.size()); for (final List templateIdsInSingleGroup : this.relationGroups.values()) { - final List resultGroup = new ArrayList(templateIdsInSingleGroup.size()); + final List resultGroup = new ArrayList<>(templateIdsInSingleGroup.size()); for (final UUID singleTemplateId : templateIdsInSingleGroup) { resultGroup.add(this.relationTemplates.get(singleTemplateId)); } @@ -105,7 +105,7 @@ public Object getChild(final Object parent, final int index) { return this.relationGroups.get(parent).get(index); } // the parent is the root, return the relation template group's id at the given index - return new ArrayList(this.relationGroups.keySet()).get(index); + return new ArrayList<>(this.relationGroups.keySet()).get(index); } @Override @@ -135,7 +135,7 @@ public int getIndexOfChild(final Object parent, final Object child) { return this.relationGroups.get(parent).indexOf(child); } // the parent is the root, find the index of the designated relation template group - return new ArrayList(this.relationGroups.keySet()).indexOf(child); + return new ArrayList<>(this.relationGroups.keySet()).indexOf(child); } @Override @@ -193,7 +193,7 @@ private List getSiblings(final Object node) { List result = null; if (this.relationGroups.containsKey(node)) { // the node is a relation template group, return list of all group ids - result = new ArrayList(this.relationGroups.keySet()); + result = new ArrayList<>(this.relationGroups.keySet()); } else { // the node is a relation template, return list of all relation template ids in the same group for (final List singleGroup : this.relationGroups.values()) { @@ -282,7 +282,7 @@ public void setValueAt(final Object value, final Object node, final int column) */ public TreePath addGroupEntry() { final UUID groupId = UUID.randomUUID(); - this.relationGroups.put(groupId, new LinkedList()); + this.relationGroups.put(groupId, new LinkedList<>()); final TreePath rootPath = new TreePath(this.getRoot()); this.modelSupport.fireChildAdded(rootPath, this.relationGroups.size() - 1, groupId); return rootPath.pathByAddingChild(groupId); diff --git a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/RelationTreeTable.java b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/RelationTreeTable.java index ac1e779..6a8115b 100644 --- a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/RelationTreeTable.java +++ b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/RelationTreeTable.java @@ -72,7 +72,7 @@ public final class RelationTreeTable extends JPanel { /** Button to disable the relation template form without applying the changes made. */ private final JButton discardFormChangesButton = new JButton(HmxMessage.PREFERENCES_RELATION_DISCARD.get()); /** Labels indicating the expected type of value in form fields. */ - private final List formLabels = new ArrayList(4); + private final List formLabels = new ArrayList<>(4); /** Input field for the role with high weight in the relation template (maximum of 32 characters length). */ private final JTextField highWeightRoleInput = new JTextField(new Validation(32), null, 0); /** Input field for the role with low weight in the relation template (maximum of 32 characters length). */ diff --git a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/SynFunctionConfigPanel.java b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/SynFunctionConfigPanel.java index b785a63..c1546dc 100644 --- a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/SynFunctionConfigPanel.java +++ b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/SynFunctionConfigPanel.java @@ -91,7 +91,7 @@ private enum ActionMode { /** Form input for the optional description/tooltip text associated with a function/group (maximum of 512 characters length). */ private final JTextArea descriptionArea = new JTextArea(new Validation(512)); /** Registered external listeners for changes to the language model. */ - private final List actionListeners = new ArrayList(1); + private final List actionListeners = new ArrayList<>(1); /** Constructor. */ public SynFunctionConfigPanel() { diff --git a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/SynFunctionTreeModel.java b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/SynFunctionTreeModel.java index 9d03c17..7c1fb50 100644 --- a/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/SynFunctionTreeModel.java +++ b/scitos.hmx/scitos.hmx.view/src/main/java/org/hmx/scitos/hmx/view/swing/option/SynFunctionTreeModel.java @@ -62,11 +62,11 @@ final class SynFunctionTreeModel extends AbstractTreeTableModel implements ISynt /** * Representation of the lists of {@link AbstractSyntacticalFunctionElement}s on the top level. */ - private final Map> topLevelGrouping = new LinkedHashMap>(); + private final Map> topLevelGrouping = new LinkedHashMap<>(); /** * Collection of all {@link AbstractSyntacticalFunctionElement}s represented here - regardless of their positions in the hierarchy. */ - private final Map rowMapping = new HashMap(); + private final Map rowMapping = new HashMap<>(); /** Constructor. */ public SynFunctionTreeModel() { @@ -84,7 +84,7 @@ public void reset(final ISyntacticalFunctionProvider provider) { this.rowMapping.clear(); for (final List singleTopLevelGroup : provider.provideFunctions()) { final UUID reference = UUID.randomUUID(); - final List topLevelChildren = new ArrayList(singleTopLevelGroup.size()); + final List topLevelChildren = new ArrayList<>(singleTopLevelGroup.size()); for (final AbstractSyntacticalFunctionElement singleTopLevelChild : singleTopLevelGroup) { topLevelChildren.add(this.addTreeTableRow(reference, singleTopLevelChild)); } @@ -120,9 +120,9 @@ private UUID addTreeTableRow(final UUID parent, final AbstractSyntacticalFunctio @Override public List> provideFunctions() { final List> result; - result = new ArrayList>(this.topLevelGrouping.size()); + result = new ArrayList<>(this.topLevelGrouping.size()); for (final List singleGroup : this.topLevelGrouping.values()) { - final List topLevelList = new ArrayList(singleGroup.size()); + final List topLevelList = new ArrayList<>(singleGroup.size()); for (final UUID singleTopLevelReference : singleGroup) { topLevelList.add(this.deriveModelInstance(singleTopLevelReference)); } @@ -142,7 +142,7 @@ private AbstractSyntacticalFunctionElement deriveModelInstance(final UUID rowRef final TreeTableRow row = this.rowMapping.get(rowReference); if (row instanceof GroupRow) { final List subFunctions; - subFunctions = new ArrayList(((GroupRow) row).subEntries.size()); + subFunctions = new ArrayList<>(((GroupRow) row).subEntries.size()); for (final UUID singleSubEntry : ((GroupRow) row).subEntries) { subFunctions.add(this.deriveModelInstance(singleSubEntry)); } @@ -295,7 +295,7 @@ private List getChildren(final Object parentReference) { children = this.topLevelGrouping.get(parentReference); } else if (parentReference == this.getRoot()) { // make it unmodifiable to ensure that an exception is being thrown if this case is not treated specifically - children = Collections.unmodifiableList(new ArrayList(this.topLevelGrouping.keySet())); + children = Collections.unmodifiableList(new ArrayList<>(this.topLevelGrouping.keySet())); } else { throw new IllegalArgumentException(); } @@ -368,7 +368,7 @@ private TreePath addRow(final TreePath parentPath, final TreeTableRow newRow) { */ public TreePath addTopLevelGroup() { final UUID childReference = UUID.randomUUID(); - this.topLevelGrouping.put(childReference, new ArrayList(3)); + this.topLevelGrouping.put(childReference, new ArrayList<>(3)); final TreePath rootPath = new TreePath(this.getRoot()); this.modelSupport.fireChildAdded(rootPath, this.topLevelGrouping.size() - 1, childReference); return rootPath.pathByAddingChild(childReference); @@ -553,7 +553,7 @@ public void setDescription(final String description) { static class GroupRow extends TreeTableRow { /** The references to sub ordinated rows. */ - final List subEntries = new ArrayList(3); + final List subEntries = new ArrayList<>(3); /** * Constructor. diff --git a/scitos.hmx/scitos.hmx.view/src/test/java/org/hmx/scitos/hmx/view/swing/option/LanguageTreeModelTest.java b/scitos.hmx/scitos.hmx.view/src/test/java/org/hmx/scitos/hmx/view/swing/option/LanguageTreeModelTest.java index 8ffeef5..cc85416 100644 --- a/scitos.hmx/scitos.hmx.view/src/test/java/org/hmx/scitos/hmx/view/swing/option/LanguageTreeModelTest.java +++ b/scitos.hmx/scitos.hmx.view/src/test/java/org/hmx/scitos/hmx/view/swing/option/LanguageTreeModelTest.java @@ -62,10 +62,10 @@ public class LanguageTreeModelTest { */ @BeforeClass public static void initFunctionProvider() { - final List functionsB = new ArrayList(3); + final List functionsB = new ArrayList<>(3); functionsB.add(new SyntacticalFunction("B1", "Function B1", false, null)); functionsB.add(new SyntacticalFunction("B2", "Function B2", true, "Some extra information")); - final List groupB3 = new ArrayList(2); + final List groupB3 = new ArrayList<>(2); groupB3.add(new SyntacticalFunction("B31", "Function B31", true, "some hint")); groupB3.add(new SyntacticalFunction("B32", "Function B32", false, null)); functionsB.add(new SyntacticalFunctionGroup("Group B3", "Group B3's hint", groupB3)); diff --git a/scitos.hmx/scitos.hmx.view/src/test/java/org/hmx/scitos/hmx/view/swing/option/RelationTreeModelTest.java b/scitos.hmx/scitos.hmx.view/src/test/java/org/hmx/scitos/hmx/view/swing/option/RelationTreeModelTest.java index 9d5a9bc..3fd7c1d 100644 --- a/scitos.hmx/scitos.hmx.view/src/test/java/org/hmx/scitos/hmx/view/swing/option/RelationTreeModelTest.java +++ b/scitos.hmx/scitos.hmx.view/src/test/java/org/hmx/scitos/hmx/view/swing/option/RelationTreeModelTest.java @@ -57,7 +57,7 @@ public class RelationTreeModelTest { @BeforeClass public static void initRelationProvider() { // build the relation template groups to test - final List> providedModel = new ArrayList>(3); + final List> providedModel = new ArrayList<>(3); /* first group: one relation template with all the same high weight roles */ final AssociateRole singleRoleA1 = new AssociateRole("a1", true); final RelationTemplate templateA1 = new RelationTemplate(singleRoleA1, singleRoleA1, singleRoleA1, "a comment"); diff --git a/scitos.hmx/scitos.hmx.view/src/test/java/org/hmx/scitos/hmx/view/swing/option/SynFunctionTreeModelTest.java b/scitos.hmx/scitos.hmx.view/src/test/java/org/hmx/scitos/hmx/view/swing/option/SynFunctionTreeModelTest.java index c372a5f..3871e0c 100644 --- a/scitos.hmx/scitos.hmx.view/src/test/java/org/hmx/scitos/hmx/view/swing/option/SynFunctionTreeModelTest.java +++ b/scitos.hmx/scitos.hmx.view/src/test/java/org/hmx/scitos/hmx/view/swing/option/SynFunctionTreeModelTest.java @@ -73,19 +73,19 @@ public class SynFunctionTreeModelTest { */ @BeforeClass public static void initFunctionProvider() { - final List groupA = new ArrayList(3); + final List groupA = new ArrayList<>(3); groupA.add(new SyntacticalFunction("A1", "Function A1", false, null)); groupA.add(new SyntacticalFunction("A2", "Function A2", true, "Some extra information")); groupA.add(new SyntacticalFunction("A3", "Function A3", false, "Other description")); final List groupB = Collections.emptyList(); - final List groupC = new ArrayList(4); - final List groupC1 = new ArrayList(2); + final List groupC = new ArrayList<>(4); + final List groupC1 = new ArrayList<>(2); groupC1.add(new SyntacticalFunction("C11", "Function C11", true, "some hint")); groupC1.add(new SyntacticalFunction("C12", "Function C12", false, null)); groupC.add(new SyntacticalFunctionGroup("Group C1", "Group C1's hint", groupC1)); groupC.add(new SyntacticalFunction("C2", "Function C2", false, "text")); groupC.add(new SyntacticalFunctionGroup("Group C3", "", Collections.emptyList())); - final List groupC41 = new ArrayList(2); + final List groupC41 = new ArrayList<>(2); groupC41.add(new SyntacticalFunction("C411", "Function C411", false, "...")); groupC41.add(new SyntacticalFunction("C412", "Function C412", true, "")); final List groupC4 = Collections.singletonList(new SyntacticalFunctionGroup("Group C41", "Something", groupC41)); diff --git a/scitos.view/pom.xml b/scitos.view/pom.xml index ff44436..bc0a991 100644 --- a/scitos.view/pom.xml +++ b/scitos.view/pom.xml @@ -3,7 +3,7 @@ org.hmx scitos - 2.3.1 + 2.4.0-SNAPSHOT scitos.view scitos.view diff --git a/scitos.view/src/main/java/org/hmx/scitos/view/ContextMenuBuilder.java b/scitos.view/src/main/java/org/hmx/scitos/view/ContextMenuBuilder.java index 056545c..741aa42 100644 --- a/scitos.view/src/main/java/org/hmx/scitos/view/ContextMenuBuilder.java +++ b/scitos.view/src/main/java/org/hmx/scitos/view/ContextMenuBuilder.java @@ -33,7 +33,7 @@ public class ContextMenuBuilder implements Iterable { /** The menu's entries - menu items, separators and/or submenus. */ - private final List entryList = new LinkedList(); + private final List entryList = new LinkedList<>(); /** The menu's title/caption. */ private final String caption; diff --git a/scitos.view/src/main/java/org/hmx/scitos/view/swing/MainView.java b/scitos.view/src/main/java/org/hmx/scitos/view/swing/MainView.java index a598361..994ccd4 100644 --- a/scitos.view/src/main/java/org/hmx/scitos/view/swing/MainView.java +++ b/scitos.view/src/main/java/org/hmx/scitos/view/swing/MainView.java @@ -86,7 +86,7 @@ public class MainView extends JPanel { /** The client instance containing this view. */ final ScitosClient client; /** The currently open view projects. */ - private final List> openProjects = new LinkedList>(); + private final List> openProjects = new LinkedList<>(); /** The divided pane containing the project tree on the left and the tab stack on the right. */ private final JSplitPane splitPane; @@ -277,9 +277,9 @@ public void revalidateClient(final boolean refreshToolBarItems) { * Clear the tree structure and rebuild it with the currently open projects. This re-applies the single selected node. */ public void resetTreeStructure() { - final List> expandedProjectNodes = new LinkedList>(); - final Map, Set> expandedModelGroupNodes = new HashMap, Set>(); - final List> expandedSubModelNodes = new LinkedList>(); + final List> expandedProjectNodes = new LinkedList<>(); + final Map, Set> expandedModelGroupNodes = new HashMap<>(); + final List> expandedSubModelNodes = new LinkedList<>(); this.collectExpandedNodeObjects(expandedProjectNodes, expandedModelGroupNodes, expandedSubModelNodes); this.rootNode.removeAllChildren(); // iterate all currently open projects @@ -351,7 +351,7 @@ private void collectExpandedNodeObjects(final List> expandedProj if (expandedModelGroupNodes.containsKey(project)) { modelGroupsInProject = expandedModelGroupNodes.get(project); } else { - modelGroupsInProject = new HashSet(); + modelGroupsInProject = new HashSet<>(); expandedModelGroupNodes.put(project, modelGroupsInProject); } expandedModelGroupNodes.get(project).add((String) ((DefaultMutableTreeNode) singlePath[2]).getUserObject()); @@ -373,7 +373,7 @@ private void collectExpandedNodeObjects(final List> expandedProj */ private void expandObjectNodes(final List> projects, final Map, Set> modelGroups, final List> subModels) { - final List nodes = new LinkedList(); + final List nodes = new LinkedList<>(); for (final IViewProject singleProject : projects) { nodes.add(this.getProjectNode(singleProject)); } @@ -417,9 +417,9 @@ void selectNodeForCurrentTab() { * tree node to refresh */ void refreshElement(final ScitosTreeNode node) { - final List> expandedProjectNodes = new LinkedList>(); - final Map, Set> expandedModelGroupNodes = new HashMap, Set>(); - final List> expandedSubModelNodes = new LinkedList>(); + final List> expandedProjectNodes = new LinkedList<>(); + final Map, Set> expandedModelGroupNodes = new HashMap<>(); + final List> expandedSubModelNodes = new LinkedList<>(); this.collectExpandedNodeObjects(expandedProjectNodes, expandedModelGroupNodes, expandedSubModelNodes); ((DefaultTreeModel) this.projectTree.getModel()).reload(node); this.expandObjectNodes(expandedProjectNodes, expandedModelGroupNodes, expandedSubModelNodes); @@ -838,7 +838,7 @@ boolean closeProject(final IViewProject project) { if (!CollectionUtil.containsInstance(this.openProjects, project)) { return Collections.emptyList(); } - final List> openTabs = new LinkedList>(); + final List> openTabs = new LinkedList<>(); for (final Component singleTab : this.tabStack.getComponents()) { if (singleTab instanceof AbstractProjectView) { final AbstractProjectView associatedTab = (AbstractProjectView) singleTab; @@ -859,7 +859,7 @@ boolean closeProject(final IViewProject project) { */ void updateOpenTabElementsForProject(final IViewProject project) { if (project != null) { - final List tabElements = new LinkedList(); + final List tabElements = new LinkedList<>(); for (final AbstractProjectView singleTab : this.getOpenTabsForProject(project)) { singleTab.submitChangesToModel(); tabElements.add(singleTab.getModel()); @@ -882,7 +882,7 @@ boolean closeAllProjects() { } } // close all other projects - for (final IViewProject singleProject : new ArrayList>(this.openProjects)) { + for (final IViewProject singleProject : new ArrayList<>(this.openProjects)) { if (!this.closeProject(singleProject)) { // user aborted the closing process return false; diff --git a/scitos.view/src/main/java/org/hmx/scitos/view/swing/ScitosApp.java b/scitos.view/src/main/java/org/hmx/scitos/view/swing/ScitosApp.java index fd1a7e4..15d6469 100644 --- a/scitos.view/src/main/java/org/hmx/scitos/view/swing/ScitosApp.java +++ b/scitos.view/src/main/java/org/hmx/scitos/view/swing/ScitosApp.java @@ -19,7 +19,10 @@ package org.hmx.scitos.view.swing; +import java.awt.Desktop; import java.awt.EventQueue; +import java.awt.Taskbar; +import java.lang.reflect.InvocationTargetException; import java.io.File; import java.util.LinkedHashSet; import java.util.Set; @@ -31,7 +34,6 @@ import org.hmx.scitos.view.FileType; import org.hmx.scitos.view.ScitosIcon; import org.hmx.scitos.view.swing.option.OptionView; -import org.hmx.scitos.view.swing.util.MacAppEventAdapter; import org.hmx.scitos.view.swing.util.MultiLineToolTipUI; import dagger.ObjectGraph; @@ -58,51 +60,54 @@ private ScitosApp() { * arguments that are currently ignored */ public static void main(final String[] args) { + EventQueue.invokeLater(ScitosApp::run); + } + + /** + * Start and show the ScitosClient. + */ + private static void run() { if (ScitosApp.IS_MAC) { // set the application name in screen menu bar System.setProperty("com.apple.mrj.application.apple.menu.about.name", "SciToS"); // transfer the frame menu bar to screen menu bar System.setProperty("apple.laf.useScreenMenuBar", "true"); // initialize apple event listeners for screen menu bar - try { - MacAppEventAdapter.setAboutHandler(null, ScitosApp.class.getDeclaredMethod("showAbout")); - MacAppEventAdapter.setFileHandler(null, ScitosApp.class.getDeclaredMethod("openFile", File.class)); - MacAppEventAdapter.setPreferencesHandler(null, ScitosApp.class.getDeclaredMethod("showPreferences")); - MacAppEventAdapter.setQuitHandler(null, ScitosApp.class.getDeclaredMethod("quit")); - MacAppEventAdapter.setDockIconImage(ScitosIcon.APPLICATION.getResourcePath()); - } catch (final SecurityException sec) { - // ignore reflection error - } catch (final NoSuchMethodException nsm) { - // ignore reflection error + final Desktop desktop = Desktop.getDesktop(); + desktop.setAboutHandler(event -> showAbout()); + desktop.setPreferencesHandler(event -> showPreferences()); + desktop.setOpenFileHandler(event -> event.getFiles().forEach(ScitosApp::openFile)); + desktop.disableSuddenTermination(); + desktop.setQuitHandler((event, response) -> { + if (quit()) { + System.exit(0); + } + }); + if (Taskbar.isTaskbarSupported()) { + Taskbar.getTaskbar().setIconImage(ScitosIcon.APPLICATION.create().getImage()); } } - EventQueue.invokeLater(new Runnable() { - - @Override - public void run() { - try { - // default: NATIVE Look and Feel - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - /* - * set the look and feel regarding to the options file entry; may throw an exception, when there is no valid entry - */ - final String chosenLaF = Option.LOOK_AND_FEEL.getValue(); - if (chosenLaF != null) { - UIManager.setLookAndFeel(chosenLaF); - } - } catch (final Exception expected) { - // ignore - } - MultiLineToolTipUI.setMaximumWidth(400); - MultiLineToolTipUI.initialize(); - ToolTipManager.sharedInstance().setDismissDelay(20000); - try { - ScitosApp.loadModulesAndShowClient(); - } catch (final Exception ex) { - MessageHandler.showException(ex); - } + try { + // default: NATIVE Look and Feel + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + /* + * set the look and feel regarding to the options file entry; may throw an exception, when there is no valid entry + */ + final String chosenLaF = Option.LOOK_AND_FEEL.getValue(); + if (chosenLaF != null) { + UIManager.setLookAndFeel(chosenLaF); } - }); + } catch (final Exception expected) { + // ignore + } + MultiLineToolTipUI.setMaximumWidth(400); + MultiLineToolTipUI.initialize(); + ToolTipManager.sharedInstance().setDismissDelay(20000); + try { + ScitosApp.loadModulesAndShowClient(); + } catch (final Exception ex) { + MessageHandler.showException(ex); + } } /** @@ -119,8 +124,8 @@ public void run() { */ static ScitosClient loadModulesAndShowClient() throws ClassNotFoundException, InstantiationException, IllegalAccessException { // collect dependency injection modules - final Set modules = new LinkedHashSet(); - final Set> initializerClasses = new LinkedHashSet>(); + final Set modules = new LinkedHashSet<>(); + final Set> initializerClasses = new LinkedHashSet<>(); // add main module modules.add(new ScitosModule()); // add all sub modules @@ -128,8 +133,13 @@ static ScitosClient loadModulesAndShowClient() throws ClassNotFoundException, In if (singleType.isSupportedByDistribution()) { final Class moduleClass = Class.forName(singleType.getModuleClassName()); final Class moduleInitializerClass = Class.forName(singleType.getModuleInitializerClassName()); - modules.add(moduleClass.newInstance()); - initializerClasses.add(moduleInitializerClass); + try { + modules.add(moduleClass.getConstructor().newInstance()); + initializerClasses.add(moduleInitializerClass); + } catch (final NoSuchMethodException | SecurityException | InvocationTargetException ex) { + System.err.println("Failed to load " + singleType.getModuleClassName()); + ex.printStackTrace(); + } } } // create dependency injection graph from combined modules diff --git a/scitos.view/src/main/java/org/hmx/scitos/view/swing/ScitosClient.java b/scitos.view/src/main/java/org/hmx/scitos/view/swing/ScitosClient.java index 23cae49..61b153c 100644 --- a/scitos.view/src/main/java/org/hmx/scitos/view/swing/ScitosClient.java +++ b/scitos.view/src/main/java/org/hmx/scitos/view/swing/ScitosClient.java @@ -231,36 +231,18 @@ private JMenu createFileMenu() { // create the "open" entry in the "file" menu final JMenuItem openItem = new JMenuItem(Message.MENUBAR_FILE_OPEN.get(), ScitosIcon.FOLDER_OPEN.create()); openItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ScitosClient.SHORTCUT_MASK)); - openItem.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(final ActionEvent event) { - ScitosClient.this.open(); - } - }); + openItem.addActionListener(event -> this.open()); fileMenu.add(openItem); fileMenu.addSeparator(); // create the "save" entry in the "file" menu this.saveMenuItem = new JMenuItem(Message.MENUBAR_FILE_SAVE.get(), ScitosIcon.SAVE_FILE.create()); this.saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ScitosClient.SHORTCUT_MASK)); - this.saveMenuItem.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(final ActionEvent event) { - ScitosClient.this.save(); - } - }); + this.saveMenuItem.addActionListener(event -> this.save()); fileMenu.add(this.saveMenuItem); // create the "save to" entry in the "file" menu this.saveAsMenuItem = new JMenuItem(Message.MENUBAR_FILE_SAVEAS.get(), ScitosIcon.SAVEAS_FILE.create()); - this.saveAsMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.SHIFT_MASK | ScitosClient.SHORTCUT_MASK)); - this.saveAsMenuItem.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(final ActionEvent event) { - ScitosClient.this.saveAs(); - } - }); + this.saveAsMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.SHIFT_DOWN_MASK | ScitosClient.SHORTCUT_MASK)); + this.saveAsMenuItem.addActionListener(event -> this.saveAs()); fileMenu.add(this.saveAsMenuItem); this.exportMenu = new JMenu(Message.MENUBAR_FILE_EXPORT.get()); this.exportMenu.setIcon(ScitosIcon.EXPORT_FILE.create()); @@ -270,34 +252,16 @@ public void actionPerformed(final ActionEvent event) { if (!ScitosApp.IS_MAC) { fileMenu.addSeparator(); final JMenuItem aboutItem = new JMenuItem(Message.MENUBAR_ABOUT.get()); - aboutItem.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(final ActionEvent event) { - new AboutDialog(ScitosClient.this.getFrame()).setVisible(true); - } - }); + aboutItem.addActionListener(event -> new AboutDialog(this.getFrame()).setVisible(true)); fileMenu.add(aboutItem); // create the "preferences" entry in the "file" menu final JMenuItem preferencesItem = new JMenuItem(Message.MENUBAR_PREFERENCES.get(), ScitosIcon.CONFIG.create()); - preferencesItem.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(final ActionEvent event) { - OptionView.showPreferenceDialog(ScitosClient.this, ScitosClient.this.optionPanelProvider); - } - }); + preferencesItem.addActionListener(event -> OptionView.showPreferenceDialog(this, this.optionPanelProvider)); fileMenu.add(preferencesItem); fileMenu.addSeparator(); // create the "exit" entry in the "file" menu final JMenuItem exitItem = new JMenuItem(Message.MENUBAR_QUIT.get()); - exitItem.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(final ActionEvent event) { - ScitosClient.this.quit(); - } - }); + exitItem.addActionListener(event -> this.quit()); fileMenu.add(exitItem); } return fileMenu; @@ -313,23 +277,11 @@ private JMenu createEditMenu() { this.undoMenuItem = this.editMenu.add(new JMenuItem(Message.MENUBAR_EDIT_UNDO.get(), ScitosIcon.UNDO_EDIT.create())); this.undoMenuItem.setEnabled(false); this.undoMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, ScitosClient.SHORTCUT_MASK)); - this.undoMenuItem.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(final ActionEvent event) { - ScitosClient.this.undo(); - } - }); + this.undoMenuItem.addActionListener(event -> this.undo()); this.redoMenuItem = this.editMenu.add(new JMenuItem(Message.MENUBAR_EDIT_REDO.get(), ScitosIcon.REDO_EDIT.create())); this.redoMenuItem.setEnabled(false); this.redoMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, ScitosClient.SHORTCUT_MASK)); - this.redoMenuItem.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(final ActionEvent event) { - ScitosClient.this.redo(); - } - }); + this.redoMenuItem.addActionListener(event -> this.redo()); return this.editMenu; } @@ -347,33 +299,19 @@ private JMenu createViewMenu() { scaleDownFontItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, ScitosClient.SHORTCUT_MASK | InputEvent.SHIFT_DOWN_MASK)); // allow the scaling only in the given range, with 10% change per step: 1.1^(-2 to +8) final AtomicInteger range = new AtomicInteger(0); - scaleUpFontItem.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(final ActionEvent event) { - scaleUpFontItem.setEnabled(range.incrementAndGet() < 8); - scaleDownFontItem.setEnabled(true); - ScitosClient.this.setContentScaleFactor((float) Math.pow(1.1, range.get())); - } + scaleUpFontItem.addActionListener(event -> { + scaleUpFontItem.setEnabled(range.incrementAndGet() < 8); + scaleDownFontItem.setEnabled(true); + this.setContentScaleFactor((float) Math.pow(1.1, range.get())); }); - scaleDownFontItem.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(final ActionEvent event) { - scaleUpFontItem.setEnabled(true); - scaleDownFontItem.setEnabled(range.decrementAndGet() > -2); - ScitosClient.this.setContentScaleFactor((float) Math.pow(1.1, range.get())); - } + scaleDownFontItem.addActionListener(event -> { + scaleUpFontItem.setEnabled(true); + scaleDownFontItem.setEnabled(range.decrementAndGet() > -2); + this.setContentScaleFactor((float) Math.pow(1.1, range.get())); }); final JMenuItem toggleTreeItem = this.viewMenu.add(new JMenuItem(Message.MENUBAR_VIEW_TOGGLE_PROJECT_TREE.get(), ScitosIcon.SIDEBAR.create())); - toggleTreeItem.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(final ActionEvent event) { - ScitosClient.this.mainView.toggleProjectTreeVisibility(); - } - }); + toggleTreeItem.addActionListener(event -> this.mainView.toggleProjectTreeVisibility()); return this.viewMenu; } @@ -420,51 +358,27 @@ public void popupMenuCanceled(final PopupMenuEvent event) { // nothing to do } }); - newFileButton.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(final ActionEvent event) { - menu.show(newFileButton, 0, newFileButton.getHeight()); - } - }); + newFileButton.addActionListener(event -> menu.show(newFileButton, 0, newFileButton.getHeight())); } bar.add(newFileButton); this.saveToolItem = new JButton(ScitosIcon.SAVE_FILE.create()); this.saveToolItem.setToolTipText(Message.MENUBAR_FILE_SAVE.get()); this.saveToolItem.setFocusable(false); this.saveToolItem.setEnabled(false); - this.saveToolItem.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(final ActionEvent event) { - ScitosClient.this.save(); - } - }); + this.saveToolItem.addActionListener(event -> this.save()); bar.add(this.saveToolItem); bar.addSeparator(); this.undoToolItem = new JButton(ScitosIcon.UNDO_EDIT.create()); this.undoToolItem.setToolTipText(Message.MENUBAR_EDIT_UNDO.get()); this.undoToolItem.setFocusable(false); this.undoToolItem.setEnabled(false); - this.undoToolItem.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(final ActionEvent event) { - ScitosClient.this.undo(); - } - }); + this.undoToolItem.addActionListener(event -> this.undo()); bar.add(this.undoToolItem); this.redoToolItem = new JButton(ScitosIcon.REDO_EDIT.create()); this.redoToolItem.setToolTipText(Message.MENUBAR_EDIT_REDO.get()); this.redoToolItem.setFocusable(false); this.redoToolItem.setEnabled(false); - this.redoToolItem.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(final ActionEvent event) { - ScitosClient.this.redo(); - } - }); + this.redoToolItem.addActionListener(event -> this.redo()); bar.add(this.redoToolItem); return bar; } @@ -491,7 +405,7 @@ void redo() { * @return supported file types and associated new file actions */ Map createNewFileActions() { - final Map result = new LinkedHashMap(); + final Map result = new LinkedHashMap<>(); for (final FileType singleType : FileType.values()) { if (!singleType.isSupportedByDistribution() || singleType.getLocalizableName() == null) { // skip file types that are associated with modules not contained in this distribution or only exist for compatibility purposes diff --git a/scitos.view/src/main/java/org/hmx/scitos/view/swing/option/AbstractSimpleOptionPanel.java b/scitos.view/src/main/java/org/hmx/scitos/view/swing/option/AbstractSimpleOptionPanel.java index e2b63c0..32b8a0e 100644 --- a/scitos.view/src/main/java/org/hmx/scitos/view/swing/option/AbstractSimpleOptionPanel.java +++ b/scitos.view/src/main/java/org/hmx/scitos/view/swing/option/AbstractSimpleOptionPanel.java @@ -53,7 +53,7 @@ public abstract class AbstractSimpleOptionPanel chosenSettings = new HashMap(); + private final Map chosenSettings = new HashMap<>(); /** * Main constructor. diff --git a/scitos.view/src/main/java/org/hmx/scitos/view/swing/option/GeneralOptionPanel.java b/scitos.view/src/main/java/org/hmx/scitos/view/swing/option/GeneralOptionPanel.java index e0b6a05..de24cb6 100644 --- a/scitos.view/src/main/java/org/hmx/scitos/view/swing/option/GeneralOptionPanel.java +++ b/scitos.view/src/main/java/org/hmx/scitos/view/swing/option/GeneralOptionPanel.java @@ -82,7 +82,7 @@ public GeneralOptionPanel(final JDialog optionDialog, final JFrame viewParent) { // get all available look and feels final LookAndFeelInfo[] installedUIs = UIManager.getInstalledLookAndFeels(); - this.lookAndFeels = new TreeMap(); + this.lookAndFeels = new TreeMap<>(); for (final LookAndFeelInfo singleLaF : installedUIs) { final String shortName = singleLaF.getName(); if (!"Nimbus".equals(shortName)) { diff --git a/scitos.view/src/main/java/org/hmx/scitos/view/swing/option/OptionView.java b/scitos.view/src/main/java/org/hmx/scitos/view/swing/option/OptionView.java index c0d028a..3f4c11c 100644 --- a/scitos.view/src/main/java/org/hmx/scitos/view/swing/option/OptionView.java +++ b/scitos.view/src/main/java/org/hmx/scitos/view/swing/option/OptionView.java @@ -69,7 +69,7 @@ public void actionPerformed(final ActionEvent event) { } }); this.dialog.setModal(true); - this.optionNodes = new LinkedList(); + this.optionNodes = new LinkedList<>(); DefaultMutableTreeNode firstNode = null; for (final IOptionPanelService singleService : optionPanelProvider.getServices()) { // adding node to the category tree diff --git a/scitos.view/src/main/java/org/hmx/scitos/view/swing/service/ModelParseServiceProviderImpl.java b/scitos.view/src/main/java/org/hmx/scitos/view/swing/service/ModelParseServiceProviderImpl.java index 3e4e45d..fd079c8 100644 --- a/scitos.view/src/main/java/org/hmx/scitos/view/swing/service/ModelParseServiceProviderImpl.java +++ b/scitos.view/src/main/java/org/hmx/scitos/view/swing/service/ModelParseServiceProviderImpl.java @@ -69,8 +69,8 @@ public final class ModelParseServiceProviderImpl implements IModelParseServiceRe */ @Inject public ModelParseServiceProviderImpl() { - this.modelClasses = Collections.synchronizedMap(new HashMap>>()); - this.modelParseServices = Collections.synchronizedMap(new HashMap>()); + this.modelClasses = Collections.synchronizedMap(new HashMap<>()); + this.modelParseServices = Collections.synchronizedMap(new HashMap<>()); } @Override @@ -97,12 +97,9 @@ public Entry, List> open(final File target) throws HmxExc try { // parse file into xml structure xml = factory.newDocumentBuilder().parse(target); - } catch (final ParserConfigurationException pcex) { + } catch (final ParserConfigurationException | IOException ex) { // error while creating a DocumentBuilder instance from factory or while accessing file - throw new HmxException(Message.ERROR_UNKNOWN, pcex); - } catch (final IOException ioex) { - // error while creating a DocumentBuilder instance from factory or while accessing file - throw new HmxException(Message.ERROR_UNKNOWN, ioex); + throw new HmxException(Message.ERROR_UNKNOWN, ex); } catch (final SAXException se) { // error while interpreting (invalid) xml structure throw new HmxException(Message.ERROR_FILE_INVALID, se); @@ -133,12 +130,9 @@ public void save(final Document xml, final File target) throws HmxException { transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "3"); this.save(xml, transformer, target); - } catch (final TransformerFactoryConfigurationError tfce) { - // error while instantiating the transformer factory - throw new HmxException(Message.ERROR_UNKNOWN, tfce); - } catch (final TransformerConfigurationException tce) { - // error while initializing the transformer instance - throw new HmxException(Message.ERROR_UNKNOWN, tce); + } catch (final TransformerFactoryConfigurationError | TransformerConfigurationException ex) { + // error while instantiating the transformer factory or initializing an instance + throw new HmxException(Message.ERROR_UNKNOWN, ex); } } @@ -157,23 +151,24 @@ public void save(final Document xml, final File target) throws HmxException { private void save(final Document xml, final Transformer transformer, final File target) throws HmxException { // create target file output stream FileOutputStream output = null; + boolean errorOccurred = false; try { output = new FileOutputStream(target); // write the xml structure to the output stream transformer.transform(new DOMSource(xml), new StreamResult(output)); output.flush(); - } catch (final IOException ioe) { - // error while initializing the FileOutputStream - throw new HmxException(Message.ERROR_UNKNOWN, ioe); - } catch (final TransformerException te) { - // error while transferring the xml document through the output stream - throw new HmxException(Message.ERROR_UNKNOWN, te); + } catch (final IOException | TransformerException ex) { + errorOccurred = true; + // error while initializing the FileOutputStream or transferring the xml document through the output stream + throw new HmxException(Message.ERROR_UNKNOWN, ex); } finally { if (output != null) { try { output.close(); - } catch (final IOException ioex) { - // at least we tried + } catch (final IOException ex) { + if (!errorOccurred) { + throw new HmxException(Message.ERROR_UNKNOWN, ex); + } } } } @@ -186,12 +181,9 @@ public void export(final IModel model, final String stylesheetPath, final Fil try { final Transformer transformer = TransformerFactory.newInstance().newTransformer(stylesheet); this.save(xml, transformer, target); - } catch (final TransformerFactoryConfigurationError tfce) { - // error while instantiating the transformer factory - throw new HmxException(Message.ERROR_UNKNOWN, tfce); - } catch (final TransformerConfigurationException tce) { - // error while initializing the transformer instance - throw new HmxException(Message.ERROR_UNKNOWN, tce); + } catch (final TransformerFactoryConfigurationError | TransformerConfigurationException ex) { + // error while instantiating the transformer factory and initializing an instance + throw new HmxException(Message.ERROR_UNKNOWN, ex); } } diff --git a/scitos.view/src/main/java/org/hmx/scitos/view/swing/service/OptionPanelServiceProviderImpl.java b/scitos.view/src/main/java/org/hmx/scitos/view/swing/service/OptionPanelServiceProviderImpl.java index 058821c..5db2ba3 100644 --- a/scitos.view/src/main/java/org/hmx/scitos/view/swing/service/OptionPanelServiceProviderImpl.java +++ b/scitos.view/src/main/java/org/hmx/scitos/view/swing/service/OptionPanelServiceProviderImpl.java @@ -48,7 +48,7 @@ public final class OptionPanelServiceProviderImpl implements IOptionPanelService /** Main constructor. */ @Inject public OptionPanelServiceProviderImpl() { - this.optionPanelServices = new LinkedHashMap, IOptionPanelService>(); + this.optionPanelServices = new LinkedHashMap<>(); // register main application preferences service this.registerOptionPanelService(Option.class, new IOptionPanelService() { diff --git a/scitos.view/src/main/java/org/hmx/scitos/view/swing/service/ProjectViewServiceProviderImpl.java b/scitos.view/src/main/java/org/hmx/scitos/view/swing/service/ProjectViewServiceProviderImpl.java index 43f20b9..9b7a178 100644 --- a/scitos.view/src/main/java/org/hmx/scitos/view/swing/service/ProjectViewServiceProviderImpl.java +++ b/scitos.view/src/main/java/org/hmx/scitos/view/swing/service/ProjectViewServiceProviderImpl.java @@ -52,8 +52,8 @@ public class ProjectViewServiceProviderImpl implements IProjectViewServiceRegist /** Main constructor. */ @Inject public ProjectViewServiceProviderImpl() { - this.modelViewServices = Collections.synchronizedMap(new HashMap>, IProjectViewService>()); - this.projectViewServices = Collections.synchronizedMap(new HashMap>, IProjectViewService>()); + this.modelViewServices = Collections.synchronizedMap(new HashMap<>()); + this.projectViewServices = Collections.synchronizedMap(new HashMap<>()); } @Override diff --git a/scitos.view/src/main/java/org/hmx/scitos/view/swing/util/MacAppEventAdapter.java b/scitos.view/src/main/java/org/hmx/scitos/view/swing/util/MacAppEventAdapter.java deleted file mode 100644 index bd13139..0000000 --- a/scitos.view/src/main/java/org/hmx/scitos/view/swing/util/MacAppEventAdapter.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - Copyright (C) 2016 HermeneutiX.org - - This file is part of SciToS. - - SciToS is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - SciToS is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with SciToS. If not, see . - */ - -package org.hmx.scitos.view.swing.util; - -import java.awt.Image; -import java.awt.Toolkit; -import java.io.File; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; - -/** Based on the OSXAdapter (Version: 2.0 – provided by Apple, Inc.). */ -public class MacAppEventAdapter implements InvocationHandler { - - /** The object to call the targetMethod on. */ - final Object targetObject; - /** The actual event handling method to execute. */ - final Method targetMethod; - /** The name of the designated application event handler to be. */ - final String proxySignature; - /** - * The actual {@code com.apple.eawt.Application} instance to register event handlers on. - */ - static Object macOSXApplication; - - /** - * Pass this method an Object and Method equipped to perform application shutdown logic. The method passed should return a boolean stating whether - * or not the quit should occur. - * - * @param target - * instance to invoke the quitHandler method on, for a handleQuit request (can be {@code null} if the quitHandler method is - * {@code static}) - * @param quitHandler - * actual method to invoke for a handleQuit request (returning a {@code boolean}) - */ - public static void setQuitHandler(final Object target, final Method quitHandler) { - MacAppEventAdapter.setHandler(new MacAppEventAdapter("handleQuit", target, quitHandler)); - } - - /** - * Pass this method an Object and Method equipped to display application info. They will be called when the About menu item is selected from the - * application menu. - * - * @param target - * instance to invoke the aboutHandler method on, for a handleAbout request (can be {@code null} if the aboutHandler method is - * {@code static}) - * @param aboutHandler - * actual method to invoke for a handleAbout request - */ - public static void setAboutHandler(final Object target, final Method aboutHandler) { - MacAppEventAdapter.setHandler(new MacAppEventAdapter("handleAbout", target, aboutHandler)); - try { - final Method enableAboutMethod = - MacAppEventAdapter.macOSXApplication.getClass().getDeclaredMethod("setEnabledAboutMenu", new Class[] { boolean.class }); - enableAboutMethod.invoke(MacAppEventAdapter.macOSXApplication, new Object[] { Boolean.valueOf(true) }); - } catch (final Exception ex) { - System.err.println("MacAppEventAdapter could not access the About Menu"); - ex.printStackTrace(); - } - } - - /** - * Pass this method an Object and a Method equipped to display application options. They will be called when the Preferences menu item is selected - * from the application menu - * - * @param target - * instance to invoke the prefsHandler method on, for a handlePreferences request (can be {@code null} if the prefsHandler method is - * {@code static}) - * @param prefsHandler - * actual method to invoke for a handlePreferences request - */ - public static void setPreferencesHandler(final Object target, final Method prefsHandler) { - MacAppEventAdapter.setHandler(new MacAppEventAdapter("handlePreferences", target, prefsHandler)); - try { - final Method enablePrefsMethod = - MacAppEventAdapter.macOSXApplication.getClass().getDeclaredMethod("setEnabledPreferencesMenu", new Class[] { boolean.class }); - enablePrefsMethod.invoke(MacAppEventAdapter.macOSXApplication, new Object[] { Boolean.valueOf(true) }); - } catch (final Exception ex) { - System.err.println("MacAppEventAdapter could not access the About Menu"); - ex.printStackTrace(); - } - } - - /** - * Pass this method an Object and a Method equipped to handle document events from the Finder. Documents are registered with the Finder via the - * CFBundleDocumentTypes dictionary in the application bundle's Info.plist. - * - * @param target - * instance to invoke the fileHandler method on, for a handleOpenFile request (can be {@code null} if the fileHandler method is - * {@code static}) - * @param fileHandler - * actual method to invoke for a handleOpenFile request - */ - public static void setFileHandler(final Object target, final Method fileHandler) { - MacAppEventAdapter.setHandler(new MacAppEventAdapter("handleOpenFile", target, fileHandler) { - - // Override MacAppEventAdapter.callTarget to send information on the file to be opened - @Override - public boolean callTarget(final Object appleEvent) { - if (appleEvent != null) { - try { - final Method getFilenameMethod = appleEvent.getClass().getDeclaredMethod("getFilename"); - final String filename = (String) getFilenameMethod.invoke(appleEvent); - this.targetMethod.invoke(this.targetObject, new Object[] { new File(filename) }); - } catch (final Exception ex) { - // ignore exceptions - } - } - return true; - } - }); - } - - /** - * Pass this method the classpath URL for the image to use the application's icon in the Dock. - * - * @param imageLocationInClassPath - * path to the targeted image on the classpath - */ - public static void setDockIconImage(final String imageLocationInClassPath) { - try { - final Class applicationClass = Class.forName("com.apple.eawt.Application"); - if (MacAppEventAdapter.macOSXApplication == null) { - MacAppEventAdapter.macOSXApplication = applicationClass.getDeclaredMethod("getApplication").invoke(null); - } - final Image icon = Toolkit.getDefaultToolkit().createImage(MacAppEventAdapter.class.getResource(imageLocationInClassPath)); - applicationClass.getDeclaredMethod("setDockIconImage", Image.class).invoke(MacAppEventAdapter.macOSXApplication, icon); - } catch (final ClassNotFoundException cnfe) { - System.err.println("This version of Mac OS X does not support the Apple EAWT. Dock Icon has not been set (" + cnfe + ")"); - } catch (final Exception ex) { // Likely a NoSuchMethodException or an IllegalAccessException loading/invoking eawt.Application methods - System.err.println("Mac OS X Adapter could not talk to EAWT:"); - ex.printStackTrace(); - } - } - - /** - * Create a Proxy object from the passed MacAppEventAdapter and add it as an ApplicationListener. - * - * @param adapter - * instance to register - */ - public static void setHandler(final MacAppEventAdapter adapter) { - try { - final Class applicationClass = Class.forName("com.apple.eawt.Application"); - if (MacAppEventAdapter.macOSXApplication == null) { - MacAppEventAdapter.macOSXApplication = applicationClass.getDeclaredMethod("getApplication").invoke(null); - } - final Class applicationListenerClass = Class.forName("com.apple.eawt.ApplicationListener"); - final Method addListenerMethod = - applicationClass.getDeclaredMethod("addApplicationListener", new Class[] { applicationListenerClass }); - // Create a proxy object around this handler that can be reflectively added as an Apple ApplicationListener - final Object osxAdapterProxy = - Proxy.newProxyInstance(MacAppEventAdapter.class.getClassLoader(), new Class[] { applicationListenerClass }, adapter); - addListenerMethod.invoke(MacAppEventAdapter.macOSXApplication, new Object[] { osxAdapterProxy }); - } catch (final ClassNotFoundException cnfe) { - System.err.println("This version of Mac OS X does not support the Apple EAWT. ApplicationEvent handling has been disabled (" + cnfe - + ")"); - } catch (final Exception ex) { // Likely a NoSuchMethodException or an IllegalAccessException loading/invoking eawt.Application methods - System.err.println("Mac OS X Adapter could not talk to EAWT:"); - ex.printStackTrace(); - } - } - - /** - * Each MacAppEventAdapter has the name of the EAWT method it intends to listen for (handleAbout, for example), the Object that will ultimately - * perform the task, and the Method to be called on that Object Main constructor. - * - * @param proxySignature - * name of the handled application event method (i.e. handleXXX) - * @param target - * instance to invoke the handler method on, for a handleXXX request (can be {@code null} if the handler method is {@code static}) - * @param handler - * actual method to invoke for a handleXXX request - */ - protected MacAppEventAdapter(final String proxySignature, final Object target, final Method handler) { - this.proxySignature = proxySignature; - this.targetObject = target; - this.targetMethod = handler; - } - - /** - * Override this method to perform any operations on the event that comes with the various callbacks. See setFileHandler above for an example. - * - * @param appleEvent - * application event to handle - * @return if the declared handler method returned {@code null} (incl. it being {@code void}) or not empty/{@code false} - * @throws InvocationTargetException - * error in the invoked handler method - * @throws IllegalAccessException - * declared handler method was not accessible from this class - */ - public boolean callTarget(final Object appleEvent) throws InvocationTargetException, IllegalAccessException { - final Object result = this.targetMethod.invoke(this.targetObject); - return result == null || Boolean.valueOf(result.toString()).booleanValue(); - } - - /** - * InvocationHandler implementation - This is the entry point for our proxy object; it is called every time an ApplicationListener method is - * invoked. - */ - @Override - public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { - if ((this.targetMethod != null && this.proxySignature.equals(method.getName()) && args.length == 1)) { - final Object event = args[0]; - final boolean handled = this.callTarget(event); - if (event != null) { - try { - final Method setHandledMethod = event.getClass().getDeclaredMethod("setHandled", new Class[] { boolean.class }); - // If the target method returns a boolean, use that as a hint - setHandledMethod.invoke(event, new Object[] { Boolean.valueOf(handled) }); - } catch (final Exception ex) { - System.err.println("MacAppEventAdapter was unable to handle an ApplicationEvent: " + event); - ex.printStackTrace(); - } - } - } - // All of the ApplicationListener methods are void; return null regardless of what happens - return null; - } -} \ No newline at end of file diff --git a/scitos.view/src/main/java/org/hmx/scitos/view/swing/util/table/TreeTable.java b/scitos.view/src/main/java/org/hmx/scitos/view/swing/util/table/TreeTable.java index 20c613a..6fd8b11 100644 --- a/scitos.view/src/main/java/org/hmx/scitos/view/swing/util/table/TreeTable.java +++ b/scitos.view/src/main/java/org/hmx/scitos/view/swing/util/table/TreeTable.java @@ -237,7 +237,7 @@ public void setSelectedPath(final TreePath path) { public List getExpandedChildren(final TreePath parentPath) { final Object parentNode = parentPath.getLastPathComponent(); final int childCount = this.getTreeTableModel().getChildCount(parentNode); - final List expandedChildren = new ArrayList(childCount); + final List expandedChildren = new ArrayList<>(childCount); for (int index = 0; index < childCount; index++) { final TreePath siblingPath = parentPath.pathByAddingChild(this.getTreeTableModel().getChild(parentNode, index)); if (this.isExpanded(siblingPath)) { diff --git a/scitos.view/src/test/java/org/hmx/scitos/view/swing/AbstractScitosUiTest.java b/scitos.view/src/test/java/org/hmx/scitos/view/swing/AbstractScitosUiTest.java index bbb7ca0..0c19f02 100644 --- a/scitos.view/src/test/java/org/hmx/scitos/view/swing/AbstractScitosUiTest.java +++ b/scitos.view/src/test/java/org/hmx/scitos/view/swing/AbstractScitosUiTest.java @@ -157,7 +157,7 @@ protected final JButtonFixture getButtonByText(ILocalizableMessage buttonText) { * @return the matched tool bar button */ protected final JButtonFixture getToolBarButtonByToolTip(ILocalizableMessage buttonToolTip) { - final ToolTipComponentMatcher matcher = new ToolTipComponentMatcher(JButton.class, buttonToolTip.get(), true); + final ToolTipComponentMatcher matcher = new ToolTipComponentMatcher<>(JButton.class, buttonToolTip.get(), true); return this.frame.toolBar().button(matcher); } diff --git a/scitos.view/src/test/java/org/hmx/scitos/view/swing/util/OrdinalComponentMatcher.java b/scitos.view/src/test/java/org/hmx/scitos/view/swing/util/OrdinalComponentMatcher.java index 2bbeeed..c7564a1 100644 --- a/scitos.view/src/test/java/org/hmx/scitos/view/swing/util/OrdinalComponentMatcher.java +++ b/scitos.view/src/test/java/org/hmx/scitos/view/swing/util/OrdinalComponentMatcher.java @@ -51,7 +51,7 @@ public OrdinalComponentMatcher(final @Nonnull Class supportedType, final int super(supportedType, requireShowing); this.targetOrdinal = ordinal; // avoid counting the same component multiple times if the matcher is being called repeatedly but preserve component order - this.checkedComponents = new ArrayList(ordinal + 1); + this.checkedComponents = new ArrayList<>(ordinal + 1); } @Override