-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(pom): Java-Version 1.8.0_421 (Oracle Corporation)
/Library/Java/JavaVirtualMachines/jdk-1.8.jdk/Contents/Home/jre
- Loading branch information
1 parent
5175eb1
commit bf98556
Showing
7 changed files
with
215 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 49 additions & 49 deletions
98
src/main/java/de/danielluedecke/zettelkasten/tasks/export/ExportToTexTask.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/test/java/de/danielluedecke/zettelkasten/ListSelectionBugTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package de.danielluedecke.zettelkasten; | ||
|
||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.Test; | ||
|
||
import javax.swing.*; | ||
import javax.swing.event.ListSelectionEvent; | ||
import javax.swing.event.ListSelectionListener; | ||
|
||
public class ListSelectionBugTest { | ||
|
||
private JList<String> jListQuickInputAuthor; | ||
private JList<String> jListKeywords; | ||
private JList<String> jListLinks; | ||
private JList<String> jListQuickInputKeywords; | ||
private boolean listUpdateActive; | ||
|
||
@BeforeMethod | ||
public void setUp() { | ||
jListQuickInputAuthor = new JList<>(new String[]{"Author1", "Author2"}); | ||
jListKeywords = new JList<>(new String[]{"Keyword1", "Keyword2"}); | ||
jListLinks = new JList<>(new String[]{"Link1", "Link2"}); | ||
jListQuickInputKeywords = new JList<>(new String[]{"KeywordA", "KeywordB"}); | ||
listUpdateActive = false; | ||
} | ||
|
||
@Test(expectedExceptions = ClassCastException.class) | ||
public void testValueChangedThrowsClassCastException() { | ||
ListSelectionListener listener = new ListSelectionListener() { | ||
@Override | ||
public void valueChanged(ListSelectionEvent e) { | ||
if (listUpdateActive) { | ||
return; | ||
} | ||
ListSelectionModel lsm = ((JList<?>) e.getSource()).getSelectionModel(); // This will throw ClassCastException | ||
lsm.setValueIsAdjusting(true); | ||
} | ||
}; | ||
|
||
ListSelectionModel selectionModel = jListQuickInputAuthor.getSelectionModel(); | ||
selectionModel.addListSelectionListener(listener); | ||
|
||
// Simulate selection change | ||
selectionModel.setSelectionInterval(0, 0); | ||
} | ||
} | ||
|
92 changes: 92 additions & 0 deletions
92
src/test/java/de/danielluedecke/zettelkasten/ListSelectionFixTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package de.danielluedecke.zettelkasten; | ||
|
||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.Test; | ||
|
||
import javax.swing.*; | ||
import javax.swing.event.ListSelectionEvent; | ||
import javax.swing.event.ListSelectionListener; | ||
|
||
import static org.testng.Assert.assertFalse; | ||
import static org.testng.Assert.assertTrue; | ||
|
||
public class ListSelectionFixTest { | ||
|
||
private JList<String> jListQuickInputAuthor; | ||
private JList<String> jListKeywords; | ||
private JList<String> jListLinks; | ||
private JList<String> jListQuickInputKeywords; | ||
private boolean listUpdateActive; | ||
private boolean authorSelected; | ||
private boolean keywordSelected; | ||
private boolean attachmentSelected; | ||
private boolean quickKeywordSelected; | ||
|
||
@BeforeMethod | ||
public void setUp() { | ||
jListQuickInputAuthor = new JList<>(new String[]{"Author1", "Author2"}); | ||
jListKeywords = new JList<>(new String[]{"Keyword1", "Keyword2"}); | ||
jListLinks = new JList<>(new String[]{"Link1", "Link2"}); | ||
jListQuickInputKeywords = new JList<>(new String[]{"KeywordA", "KeywordB"}); | ||
listUpdateActive = false; | ||
authorSelected = false; | ||
keywordSelected = false; | ||
attachmentSelected = false; | ||
quickKeywordSelected = false; | ||
} | ||
|
||
private void setAuthorSelected(boolean selected) { | ||
authorSelected = selected; | ||
} | ||
|
||
private void setKeywordSelected(boolean selected) { | ||
keywordSelected = selected; | ||
} | ||
|
||
private void setAttachmentSelected(boolean selected) { | ||
attachmentSelected = selected; | ||
} | ||
|
||
private void setQuickKeywordSelected(boolean selected) { | ||
quickKeywordSelected = selected; | ||
} | ||
|
||
@Test | ||
public void testValueChangedNoClassCastException() { | ||
ListSelectionListener listener = new ListSelectionListener() { | ||
@Override | ||
public void valueChanged(ListSelectionEvent e) { | ||
if (listUpdateActive) { | ||
return; | ||
} | ||
|
||
Object source = e.getSource(); | ||
if (source instanceof ListSelectionModel) { | ||
ListSelectionModel lsm = (ListSelectionModel) source; | ||
lsm.setValueIsAdjusting(true); | ||
|
||
if (jListQuickInputAuthor.getSelectionModel() == lsm) { | ||
setAuthorSelected(jListQuickInputAuthor.getSelectedIndex() != -1); | ||
} else if (jListKeywords.getSelectionModel() == lsm) { | ||
setKeywordSelected(jListKeywords.getSelectedIndex() != -1); | ||
} else if (jListLinks.getSelectionModel() == lsm) { | ||
setAttachmentSelected(jListLinks.getSelectedIndex() != -1); | ||
} else if (jListQuickInputKeywords.getSelectionModel() == lsm) { | ||
setQuickKeywordSelected(jListQuickInputKeywords.getSelectedIndex() != -1); | ||
} | ||
} | ||
} | ||
}; | ||
|
||
ListSelectionModel selectionModel = jListQuickInputAuthor.getSelectionModel(); | ||
selectionModel.addListSelectionListener(listener); | ||
|
||
// Simulate selection change | ||
selectionModel.setSelectionInterval(0, 0); | ||
assertTrue(authorSelected); | ||
assertFalse(keywordSelected); | ||
assertFalse(attachmentSelected); | ||
assertFalse(quickKeywordSelected); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 0 additions & 73 deletions
73
src/test/java/playground/swing/SwingAppWithJavaFXAndJEditorPaneTest.java
This file was deleted.
Oops, something went wrong.