Lines 556-563
Link Here
|
556 |
public void run() { |
556 |
public void run() { |
557 |
try { |
557 |
try { |
558 |
doc.removeDocumentListener(getListener()); |
558 |
doc.removeDocumentListener(getListener()); |
|
|
559 |
doc.putProperty ("beforeModificationListener", null); // NOI18N |
559 |
doc.remove(0, doc.getLength()); // remove all text |
560 |
doc.remove(0, doc.getLength()); // remove all text |
560 |
doc.addDocumentListener(getListener()); |
561 |
doc.addDocumentListener(getListener()); |
|
|
562 |
doc.putProperty ("beforeModificationListener", getListener ()); // NOI18N |
561 |
} catch(BadLocationException ble) { |
563 |
} catch(BadLocationException ble) { |
562 |
ErrorManager.getDefault().notify( |
564 |
ErrorManager.getDefault().notify( |
563 |
ErrorManager.INFORMATIONAL, ble); |
565 |
ErrorManager.INFORMATIONAL, ble); |
Lines 1323-1337
Link Here
|
1323 |
} |
1325 |
} |
1324 |
|
1326 |
|
1325 |
/** Conditionally calls notifyModified |
1327 |
/** Conditionally calls notifyModified |
|
|
1328 |
* @return true if the modification was allowed, false if it should be prohibited |
1326 |
*/ |
1329 |
*/ |
1327 |
private final void callNotifyModified () { |
1330 |
private final boolean callNotifyModified () { |
1328 |
if (!alreadyModified) { |
1331 |
if (!alreadyModified) { |
1329 |
alreadyModified = true; |
1332 |
alreadyModified = true; |
1330 |
if (!notifyModified ()) { |
1333 |
if (!notifyModified ()) { |
1331 |
revertUpcomingUndo (); |
1334 |
revertUpcomingUndo (); |
1332 |
alreadyModified = false; |
1335 |
alreadyModified = false; |
|
|
1336 |
return false; |
1333 |
} |
1337 |
} |
1334 |
} |
1338 |
} |
|
|
1339 |
return true; |
1335 |
} |
1340 |
} |
1336 |
|
1341 |
|
1337 |
/** Called when the document is being modified. |
1342 |
/** Called when the document is being modified. |
Lines 1425-1430
Link Here
|
1425 |
} |
1430 |
} |
1426 |
UndoRedo ur = getUndoRedo(); |
1431 |
UndoRedo ur = getUndoRedo(); |
1427 |
sd.removeDocumentListener(getListener()); |
1432 |
sd.removeDocumentListener(getListener()); |
|
|
1433 |
sd.putProperty ("beforeModificationListener", null); // NOI18N |
1428 |
try { |
1434 |
try { |
1429 |
if(ur.canUndo()) { |
1435 |
if(ur.canUndo()) { |
1430 |
Toolkit.getDefaultToolkit().beep(); |
1436 |
Toolkit.getDefaultToolkit().beep(); |
Lines 1435-1440
Link Here
|
1435 |
ErrorManager.INFORMATIONAL, cne); |
1441 |
ErrorManager.INFORMATIONAL, cne); |
1436 |
} finally { |
1442 |
} finally { |
1437 |
sd.addDocumentListener(getListener()); |
1443 |
sd.addDocumentListener(getListener()); |
|
|
1444 |
sd.putProperty ("beforeModificationListener", getListener ()); // NOI18N |
1438 |
} |
1445 |
} |
1439 |
} |
1446 |
} |
1440 |
}; |
1447 |
}; |
Lines 1494-1531
Link Here
|
1494 |
} |
1501 |
} |
1495 |
|
1502 |
|
1496 |
|
1503 |
|
1497 |
// other public methods ................................................................ |
|
|
1498 |
|
1499 |
|
1500 |
/* JST: Commented out |
1501 |
* Set actions for toolbar. |
1502 |
* @param actions list of actions |
1503 |
* |
1504 |
public void setActions (SystemAction[] actions) { |
1505 |
this.actions = actions; |
1506 |
} |
1507 |
|
1508 |
/** Utility method which enables or disables listening to modifications |
1509 |
* on asociated document. |
1510 |
* <P> |
1511 |
* Could be useful if we have to modify document, but do not want the |
1512 |
* Save and Save All actions to be enabled/disabled automatically. |
1513 |
* Initially modifications are listened to. |
1514 |
* @param listenToModifs whether to listen to modifications |
1515 |
* |
1516 |
public void setModificationListening (final boolean listenToModifs) { |
1517 |
if (this.listenToModifs == listenToModifs) return; |
1518 |
this.listenToModifs = listenToModifs; |
1519 |
if (doc == null) return; |
1520 |
if (listenToModifs) |
1521 |
doc.addi(getModifL()); |
1522 |
else |
1523 |
doc.removeDocumentListener(getModifL()); |
1524 |
} |
1525 |
*/ |
1526 |
|
1527 |
|
1528 |
|
1529 |
/** Loads the document for this object. |
1504 |
/** Loads the document for this object. |
1530 |
* @param kit kit to use |
1505 |
* @param kit kit to use |
1531 |
* @param d original document to load data into |
1506 |
* @param d original document to load data into |
Lines 1617-1622
Link Here
|
1617 |
if (doc != null) { |
1592 |
if (doc != null) { |
1618 |
doc.removeUndoableEditListener (getUndoRedo ()); |
1593 |
doc.removeUndoableEditListener (getUndoRedo ()); |
1619 |
doc.removeDocumentListener(getListener()); |
1594 |
doc.removeDocumentListener(getListener()); |
|
|
1595 |
doc.putProperty ("beforeModificationListener", null); |
1620 |
} |
1596 |
} |
1621 |
|
1597 |
|
1622 |
if (positionManager != null) { |
1598 |
if (positionManager != null) { |
Lines 1949-1957
Link Here
|
1949 |
* document, environment and also temporarilly on undoredo. |
1925 |
* document, environment and also temporarilly on undoredo. |
1950 |
*/ |
1926 |
*/ |
1951 |
private final class Listener extends Object |
1927 |
private final class Listener extends Object |
1952 |
implements ChangeListener, DocumentListener, PropertyChangeListener, Runnable { |
1928 |
implements ChangeListener, DocumentListener, PropertyChangeListener, |
|
|
1929 |
Runnable, java.beans.VetoableChangeListener { |
1953 |
|
1930 |
|
1954 |
Listener() {} |
1931 |
Listener() {} |
1955 |
|
1932 |
|
1956 |
/** Stores exception from loadDocument, can be set in run method */ |
1933 |
/** Stores exception from loadDocument, can be set in run method */ |
1957 |
private IOException loadExc; |
1934 |
private IOException loadExc; |
Lines 1993-1998
Link Here
|
1993 |
//modified(); (bugfix #1492) |
1970 |
//modified(); (bugfix #1492) |
1994 |
} |
1971 |
} |
1995 |
|
1972 |
|
|
|
1973 |
public void vetoableChange (PropertyChangeEvent evt) throws java.beans.PropertyVetoException { |
1974 |
if ("modified".equals (evt.getPropertyName ())) { // NOI18N |
1975 |
if (Boolean.TRUE.equals (evt.getNewValue ())) { |
1976 |
if (!callNotifyModified ()) { |
1977 |
throw new java.beans.PropertyVetoException ("Not allowed", evt); // NOI18N |
1978 |
} |
1979 |
} else { |
1980 |
notifyUnmodified (); |
1981 |
} |
1982 |
} |
1983 |
} |
1984 |
|
1996 |
/** Gives notification that there was an insert into the document. |
1985 |
/** Gives notification that there was an insert into the document. |
1997 |
* @param ev event describing the action |
1986 |
* @param ev event describing the action |
1998 |
*/ |
1987 |
*/ |
Lines 2054-2059
Link Here
|
2054 |
* which can prevent dedloks that sometimes occured during file reload. |
2043 |
* which can prevent dedloks that sometimes occured during file reload. |
2055 |
*/ |
2044 |
*/ |
2056 |
doc.removeDocumentListener(getListener()); |
2045 |
doc.removeDocumentListener(getListener()); |
|
|
2046 |
doc.putProperty ("beforeModificationListener", null); // NOI18N |
2057 |
try { |
2047 |
try { |
2058 |
loadExc = null; |
2048 |
loadExc = null; |
2059 |
LOCAL_LOAD_TASK.set(Boolean.TRUE); |
2049 |
LOCAL_LOAD_TASK.set(Boolean.TRUE); |
Lines 2079-2085
Link Here
|
2079 |
|
2069 |
|
2080 |
// Start listening on changes in document |
2070 |
// Start listening on changes in document |
2081 |
doc.addDocumentListener(getListener()); |
2071 |
doc.addDocumentListener(getListener()); |
|
|
2072 |
doc.putProperty ("beforeModificationListener", getListener ()); // NOI18N // NOI18N |
2082 |
} |
2073 |
} |
|
|
2074 |
|
2083 |
// } |
2075 |
// } |
2084 |
} |
2076 |
} |
2085 |
|
2077 |
|
Lines 2286-2292
Link Here
|
2286 |
public void undo() { |
2278 |
public void undo() { |
2287 |
super.undo(); |
2279 |
super.undo(); |
2288 |
|
2280 |
|
2289 |
if (saveTime == lastSaveTime) { |
2281 |
if (saveTime == lastSaveTime && alreadyModified) { |
2290 |
notifyUnmodified(); |
2282 |
notifyUnmodified(); |
2291 |
} |
2283 |
} |
2292 |
} |
2284 |
} |