Skip to content

Commit

Permalink
fixes #38
Browse files Browse the repository at this point in the history
  • Loading branch information
sjPlot committed May 29, 2015
1 parent 1fd2c80 commit d69a24a
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 46 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Ausführliche Anleitungen zu den verschiedenen Funktionen gibt es [in der Wiki](
* Markdown-Zitat werden jetzt korrekt nach LaTeX exportiert ([#31](https://github.com/sjPlot/Zettelkasten/issues/31)).
* Doppelte Zeilenumbrüche entfernen bei Neueingabe wird jetzt nur auf Auswahl angewendet ([#16](https://github.com/sjPlot/Zettelkasten/issues/16)).
* Literaturangaben waren nicht bearbeitbar, wenn lediglich Groß- in Kleinbuchstaben oder umgekehrt geändert wurden. Fehler behoben, ändern von Groß-/Kleinschreibung in Literaturangaben jetzt über die Registerkarte _Literatur_ möglich ([#47](https://github.com/sjPlot/Zettelkasten/issues/47)).
* Querverweise auf einen gelöschten Zettel ließen sich nicht entfernen ([#38](https://github.com/sjPlot/Zettelkasten/issues/38)).

### Screenshots
Aktuelle Screenshots [gibt es hier](http://zettelkasten.danielluedecke.de/gallery.php).
2 changes: 1 addition & 1 deletion build/built-jar.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Tue, 26 May 2015 22:31:35 +0200
#Fri, 29 May 2015 14:15:14 +0200


/Users/danielludecke/Dropbox/NetBeans/Zettelkasten=
34 changes: 17 additions & 17 deletions nbproject/private/private.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,15 @@
</editor-bookmarks>
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0">
<file>
<url>src/zettelkasten/CDaten.java</url>
<url>src/zettelkasten/CImportDlg.java</url>
<bookmark id="0">
<name/>
<line>659</line>
<line>1050</line>
<key/>
</bookmark>
<bookmark id="0">
<name/>
<line>1292</line>
<key/>
</bookmark>
</file>
Expand All @@ -57,10 +62,10 @@
</bookmark>
</file>
<file>
<url>src/zettelkasten/CExport.java</url>
<url>src/zettelkasten/CSettingsDlg.java</url>
<bookmark id="0">
<name/>
<line>262</line>
<line>776</line>
<key/>
</bookmark>
</file>
Expand All @@ -73,39 +78,34 @@
</bookmark>
</file>
<file>
<url>src/zettelkasten/ZettelkastenView.java</url>
<url>src/zettelkasten/CDaten.java</url>
<bookmark id="0">
<name/>
<line>9302</line>
<line>659</line>
<key/>
</bookmark>
</file>
<file>
<url>src/zettelkasten/CImportDlg.java</url>
<bookmark id="0">
<name/>
<line>1050</line>
<key/>
</bookmark>
<url>src/zettelkasten/CExportDlg.java</url>
<bookmark id="0">
<name/>
<line>1292</line>
<line>2617</line>
<key/>
</bookmark>
</file>
<file>
<url>src/zettelkasten/CSettingsDlg.java</url>
<url>src/zettelkasten/ZettelkastenView.java</url>
<bookmark id="0">
<name/>
<line>776</line>
<line>9302</line>
<key/>
</bookmark>
</file>
<file>
<url>src/zettelkasten/CExportDlg.java</url>
<url>src/zettelkasten/CExport.java</url>
<bookmark id="0">
<name/>
<line>2617</line>
<line>262</line>
<key/>
</bookmark>
</file>
Expand Down
74 changes: 46 additions & 28 deletions src/de/danielluedecke/zettelkasten/database/Daten.java
Original file line number Diff line number Diff line change
Expand Up @@ -1904,7 +1904,7 @@ public boolean deleteZettel(int pos) {
// retrieve the entry-element at the given position
Element zettel = retrieveElement(zknFile, pos);
// if the entry-element exists...
if (zettel!=null) {
if (zettel != null) {
// remove this entry from the visible order
// therefore, the previous entry of this entry should point
// to the next entry of this entry
Expand All @@ -1913,32 +1913,32 @@ public boolean deleteZettel(int pos) {
// to the previous entry of this entry
setPrevZettel(getNextZettel(pos), getPrevZettel(pos));
// check whether deleted entry was first entry
if (pos==getFirstZettel()) {
if (pos == getFirstZettel()) {
setFirstZettel(getNextZettel(pos));
}
// check whether deleted entry was last entry
if (pos==getLastZettel()) {
if (pos == getLastZettel()) {
setLastZettel(getPrevZettel(pos));
}
// change zettelcounter
zettelPos = getNextZettel(pos);
// check whether it's out of bounds
if (zettelPos>getCount(ZKNCOUNT) || zettelPos==-1) {
zettelPos = getFirstZettel();
}
// change author-and keyword-frequencies
changeFrequencies(pos,-1);
// retrieve manual links, so we can delete the backlinks from other entries.
// each manual link from this entry to other entries creates a "backlink" from
// other entries to this one. if we delete the manual links from this entry,
// all backlinks to this entry are removed.
String[] manlinks = zettel.getChild(ELEMENT_MANLINKS).getText().split(",");
// delete manual links
deleteManualLinks(manlinks);
deleteManualLinks(manlinks, pos);
// change zettelcounter
zettelPos = getNextZettel(pos);
// check whether it's out of bounds
if (zettelPos > getCount(ZKNCOUNT) || zettelPos == -1) {
zettelPos = getFirstZettel();
}
// change author-and keyword-frequencies
changeFrequencies(pos, -1);
// ...delete entry's attributes
zettel.setAttribute(ATTRIBUTE_ZETTEL_ID, "");
zettel.setAttribute(ATTRIBUTE_RATINGCOUNT,"");
zettel.setAttribute(ATTRIBUTE_RATING,"");
zettel.setAttribute(ATTRIBUTE_RATINGCOUNT, "");
zettel.setAttribute(ATTRIBUTE_RATING, "");
zettel.setAttribute(ATTRIBUTE_NEXT_ZETTEL, "");
zettel.setAttribute(ATTRIBUTE_PREV_ZETTEL, "");
// ...delete entry's content
Expand Down Expand Up @@ -3733,27 +3733,32 @@ public boolean insertLuhmannNumber(int entry, int insertnr, int pos) {
}


/**
/**
* Removes one or more manual links from the current entry...
*
* @param manlinks an integer-array with the manual links that should be removed...
* @param zpos the entry index number of the entry, which manual links should
* be removed.
*/
public void deleteManualLinks(String[] manlinks) {
public void deleteManualLinks(String[] manlinks, int zpos) {
// get the current manual links...
int[] current_mls = getCurrentManualLinks();
int[] current_mls = getManualLinks(zpos);
// if no manual links available, leave...
if ((null==current_mls)||(current_mls.length<1)) return;
if ((null == current_mls) || (current_mls.length < 1)) return;
// if no manual links from parameter available, leave...
if ((null==manlinks)||(manlinks.length<1)) return;
if ((null == manlinks) || (manlinks.length < 1)) return;
// create linked list and copy all current manual links to that list
LinkedList<String> l = new LinkedList<>();
for (int ml : current_mls) l.add(String.valueOf(ml));
for (int ml : current_mls) {
l.add(String.valueOf(ml));
}
// go through all entries that should be removed from the manual links...
for (String mlparam : manlinks) {
// find the entry in the linked list
int pos = l.indexOf(mlparam);
// if it exists, remove it.
if (pos!=-1) {
if (pos != -1) {
l.remove(pos);
// we also have to remove the *current* entry from the referred entry
try {
Expand All @@ -3764,7 +3769,7 @@ public void deleteManualLinks(String[] manlinks) {
StringBuilder sb = new StringBuilder("");
// get current entry position as string. we need to remove this value
// from the referred entry's manual links, given in the array "backlinks"
String curentry = String.valueOf(zettelPos);
String curentry = String.valueOf(zpos);
// go through all manual links of the referred entry
for (String bl : backlinks) {
// if the manual link of the referred entry is *not* the current entry...
Expand All @@ -3775,12 +3780,13 @@ public void deleteManualLinks(String[] manlinks) {
}
}
// delete last comma
if (sb.length()>1) sb.setLength(sb.length()-1);
if (sb.length() > 1) {
sb.setLength(sb.length() - 1);
}
// and update manual links of the referred entry
setManualLinks(mlparamentry,sb.toString());
}
catch (NumberFormatException e) {
Constants.zknlogger.log(Level.WARNING,e.getLocalizedMessage());
setManualLinks(mlparamentry, sb.toString());
} catch (NumberFormatException e) {
Constants.zknlogger.log(Level.WARNING, e.getLocalizedMessage());
}
}
}
Expand All @@ -3797,9 +3803,21 @@ public void deleteManualLinks(String[] manlinks) {
sb.append(",");
}
// truncate last comma
if (sb.length()>1) sb.setLength((sb.length()-1));
if (sb.length() > 1) {
sb.setLength((sb.length() - 1));
}
// update manual links of current entry
setManualLinks(zettelPos,sb.toString());
setManualLinks(zpos, sb.toString());
}


/**
* Removes one or more manual links from the current entry...
*
* @param manlinks an integer-array with the manual links that should be removed...
*/
public void deleteManualLinks(String[] manlinks) {
deleteManualLinks(manlinks, zettelPos);
}


Expand Down

0 comments on commit d69a24a

Please sign in to comment.