Skip to content

Commit

Permalink
refactor: rename method findParentlLuhmann to findParentLuhmann
Browse files Browse the repository at this point in the history
for consistency and clarity.

- Updated all references to `findParentlLuhmann` in various classes to `findParentLuhmann`.
- Fixed typo in comments from "stringbuffer" to "string buffer" and "searchresults" to "search results".
- Renamed method `goToFirstTopOfTopic` to `goToFirstParentEntry` to better reflect its functionality.
- Updated unit tests to reflect method name changes and ensured consistency across the code base.
  • Loading branch information
RalfBarkow committed Jun 7, 2024
1 parent 9f40773 commit 179f3c5
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6749,7 +6749,7 @@ public void run() {
private EntryID getRootEntryForLuhmannTree() {
int rootEntry = -1;
if (settings.getShowAllLuhmann()) {
rootEntry = data.findParentlLuhmann(data.getActivatedEntryNumber(), /* firstParent= */false);
rootEntry = data.findParentLuhmann(data.getActivatedEntryNumber(), /* firstParent= */false);

}
if (rootEntry == -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5072,8 +5072,8 @@ public void lastEntry() {
*
* It adds a the new entry (first parent entry) to the history.
*/
public void goToFirstTopOfTopic() { // was: goToFirstParentEntry ; cf. "Inhaltlich-logische Navigation" in https://niklas-luhmann-archiv.de/bestand/zettelkasten/tutorial
int firstParentEntry = findParentlLuhmann(activatedEntryNumber, /* firstParent= */true);
public void goToFirstParentEntry() { // See: "Inhaltlich-logische Navigation" in https://niklas-luhmann-archiv.de/bestand/zettelkasten/tutorial
int firstParentEntry = findParentLuhmann(activatedEntryNumber, /* firstParent= */true);
if (firstParentEntry == -1) {
// No valid parent entry, do nothing.
return;
Expand Down Expand Up @@ -7456,7 +7456,7 @@ public boolean isTopLevelLuhmann(int nr) {
if (!hasLuhmannNumbers(nr)) {
return false;
}
return (-1 == findParentlLuhmann(nr, true));
return (-1 == findParentLuhmann(nr, true));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class ShowTitleListTask extends org.jdesktop.application.Task<Object, Voi
/**
* Reference to the data class
*/
private final Daten dataObj;
private final Daten data;
/**
* the table model from the main window's jtable, passed as parameter
*/
Expand All @@ -69,7 +69,7 @@ public class ShowTitleListTask extends org.jdesktop.application.Task<Object, Voi
// doInBackground() depends on from parameters
// to ImportFileTask fields, here.
super(app);
dataObj = d;
data = d;
tableModel = tm;
parentDialog = parent;
msgLabel = label;
Expand All @@ -83,7 +83,7 @@ protected Object doInBackground() {
// the Swing GUI from here.

// check whether we have any keywords at all
if (dataObj.getCount(Daten.ZKNCOUNT) < 1) {
if (data.getCount(Daten.ZKNCOUNT) < 1) {
// reset list
list = null;
// leave thread
Expand All @@ -92,18 +92,18 @@ protected Object doInBackground() {
// create new instance of that variable
list = new LinkedList<>();
// reset progress counter
int total_count = dataObj.getCount(Daten.ZKNCOUNT);
int total_count = data.getCount(Daten.ZKNCOUNT);
// start loop
for (int cnt = 1; cnt <= dataObj.getCount(Daten.ZKNCOUNT); cnt++) {
for (int cnt = 1; cnt <= data.getCount(Daten.ZKNCOUNT); cnt++) {
// is entry deleted?
if (dataObj.isDeleted(cnt)) {
if (data.isDeleted(cnt)) {
// skip entry
continue;
}
// get zettel-title
String title = dataObj.getZettelTitle(cnt);
String title = data.getZettelTitle(cnt);
// get timestamp
String[] timestamp = dataObj.getTimestamp(cnt);
String[] timestamp = data.getTimestamp(cnt);
// init timestamp variables.
String created = "";
String edited = "";
Expand All @@ -118,10 +118,10 @@ protected Object doInBackground() {

// Make Note Sequences column sortable.
String luhmannindex = "0";
if (dataObj.isTopLevelLuhmann(cnt)) {
if (data.isTopLevelLuhmann(cnt)) {
luhmannindex = "3";
} else if (dataObj.findParentlLuhmann(cnt, true) != -1) {
if (dataObj.hasLuhmannNumbers(cnt)) {
} else if (data.findParentLuhmann(cnt, true) != -1) {
if (data.hasLuhmannNumbers(cnt)) {
luhmannindex = "2";
} else {
luhmannindex = "1";
Expand All @@ -134,7 +134,7 @@ protected Object doInBackground() {
ob[1] = title;
ob[2] = created;
ob[3] = edited;
ob[4] = dataObj.getZettelRating(cnt);
ob[4] = data.getZettelRating(cnt);
ob[5] = luhmannindex;
// and add it to the table
list.add(ob);
Expand Down Expand Up @@ -164,7 +164,7 @@ protected void succeeded(Object result) {
tableModel.setRowCount(0);
}
}
dataObj.setTitlelistUpToDate(true);
data.setTitlelistUpToDate(true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ private void doSearchForTopLevelLuhman() {
private void doSearchForLuhmanParent() {
// get the amount of entries
int len = searchEntries.length;
// init a stringbuffer that temporarily stores the found entry-numbers
// init a string buffer that temporarily stores the found entry-numbers
List<Integer> finalresults = new ArrayList<>();
// iterate all entries where the search should be applied to...
// this may differ. a search request from the main-window usually searches
Expand All @@ -687,19 +687,19 @@ private void doSearchForLuhmanParent() {
// get the number of the entry which we want to search through...
int searchnr = searchEntries[counter];
// find first parent
int lp = dataObj.findParentlLuhmann(searchnr, true);
int lp = dataObj.findParentLuhmann(searchnr, true);
// check whether entry is a follower and has a first-level parent
if (lp != -1) {
// check if entry is not already in searchresults
// check if entry is not already in search results
// if not, add search result
if (!finalresults.contains(searchnr)) {
finalresults.add(searchnr);
}
}
// update progressbar
// update progress bar
setProgress(counter, 0, len);
}
// finally, check whether we have any searchresults at all...
// finally, check whether we have any search results at all...
if (finalresults.size() > 0) {
// create search results array, create search description and
// add search results to the search-data-class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public Component getTableCellRendererComponent(
// get note
if (dataObj.isTopLevelLuhmann(nr)) {
returnLabel = this.iconLabelParentLuhmann;
} else if (dataObj.findParentlLuhmann(nr, true) != -1) {
} else if (dataObj.findParentLuhmann(nr, true) != -1) {
if (dataObj.hasLuhmannNumbers(nr)) {
returnLabel = this.iconLabelMiddleLuhmann;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ public void setUp() throws JDOMException, IOException {
}

@Test
void testGoToFirstTopOfTopic() {
void testGoToFirstParentEntry() {
// data by default has current entry == 1.
Daten data = new Daten(document);

// The first (and only) parent of entry 1 is entry 2.
data.goToFirstTopOfTopic();
data.goToFirstParentEntry();
assertEquals(data.getActivatedEntryNumber(), 2);

// Entry 2 doesn't have a parent. Keep at the same Zettel number.
data.goToFirstTopOfTopic();
data.goToFirstParentEntry();
assertEquals(data.getActivatedEntryNumber(), 2);
}

Expand Down

0 comments on commit 179f3c5

Please sign in to comment.