mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
Prevent Workshop always prompting to save right away
This commit is contained in:
@@ -42,6 +42,7 @@ public enum CCardScript implements ICDoc {
|
|||||||
private CardScriptInfo currentScriptInfo;
|
private CardScriptInfo currentScriptInfo;
|
||||||
private boolean isTextDirty;
|
private boolean isTextDirty;
|
||||||
private boolean switchInProgress;
|
private boolean switchInProgress;
|
||||||
|
private boolean refreshing;
|
||||||
|
|
||||||
private CCardScript() {
|
private CCardScript() {
|
||||||
VCardScript.SINGLETON_INSTANCE.getTxtScript().getDocument().addDocumentListener(new DocumentListener() {
|
VCardScript.SINGLETON_INSTANCE.getTxtScript().getDocument().addDocumentListener(new DocumentListener() {
|
||||||
@@ -70,7 +71,7 @@ public enum CCardScript implements ICDoc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateDirtyFlag() {
|
private void updateDirtyFlag() {
|
||||||
boolean isTextNowDirty = currentScriptInfo != null && !VCardScript.SINGLETON_INSTANCE.getTxtScript().getText().equals(currentScriptInfo.getText());
|
boolean isTextNowDirty = !refreshing && currentScriptInfo != null && !VCardScript.SINGLETON_INSTANCE.getTxtScript().getText().equals(currentScriptInfo.getText());
|
||||||
if (isTextDirty == isTextNowDirty) { return; }
|
if (isTextDirty == isTextNowDirty) { return; }
|
||||||
isTextDirty = isTextNowDirty;
|
isTextDirty = isTextNowDirty;
|
||||||
VCardDesigner.SINGLETON_INSTANCE.getBtnSaveCard().setEnabled(isTextNowDirty);
|
VCardDesigner.SINGLETON_INSTANCE.getBtnSaveCard().setEnabled(isTextNowDirty);
|
||||||
@@ -96,6 +97,8 @@ public enum CCardScript implements ICDoc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
|
if (refreshing) { return; }
|
||||||
|
refreshing = true;
|
||||||
final JTextPane txtScript = VCardScript.SINGLETON_INSTANCE.getTxtScript();
|
final JTextPane txtScript = VCardScript.SINGLETON_INSTANCE.getTxtScript();
|
||||||
txtScript.setText(currentScriptInfo != null ? currentScriptInfo.getText() : "");
|
txtScript.setText(currentScriptInfo != null ? currentScriptInfo.getText() : "");
|
||||||
txtScript.setEditable(currentScriptInfo != null ? currentScriptInfo.canEdit() : false);
|
txtScript.setEditable(currentScriptInfo != null ? currentScriptInfo.canEdit() : false);
|
||||||
@@ -108,6 +111,7 @@ public enum CCardScript implements ICDoc {
|
|||||||
doc.setCharacterAttributes(region.getKey(), region.getValue(), error, true);
|
doc.setCharacterAttributes(region.getKey(), region.getValue(), error, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
refreshing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasChanges() {
|
public boolean hasChanges() {
|
||||||
|
|||||||
Reference in New Issue
Block a user