Skip to content

Commit f891d12

Browse files
authored
Merge pull request #367 from bjoernranft/form-gui-sync-fix
trac#34161 form-gui sync to document.
2 parents af9b0a1 + a5147ee commit f891d12

File tree

68 files changed

+364
-612
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+364
-612
lines changed

core/src/main/java/de/muenchen/allg/itd51/wollmux/db/ColumnTransformer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public String get(String columnName, Dataset ds) throws ColumnNotFoundException
134134
if (func == null) {
135135
return ds.get(columnName);
136136
}
137-
return func.getString(new DatasetValues(ds));
137+
return func.getResult(new DatasetValues(ds));
138138
}
139139

140140
/**

core/src/main/java/de/muenchen/allg/itd51/wollmux/document/DocumentManager.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,19 @@ public class DocumentManager
9898
private DocumentManager() {
9999
registeredDocumentEventListener = new ArrayList<>();
100100
}
101-
101+
102102
/**
103103
* Fügt compo den gemanageten Objekten hinzu, wobei die für Textdokumente
104104
* relevanten Informationen hinterlegt werden.
105105
*/
106-
public synchronized void addTextDocument(XTextDocument compo)
106+
public void addTextDocument(XTextDocument compo)
107107
{
108108
TextDocumentInfo docInfo = new TextDocumentInfo(compo);
109109
info.put(new HashableComponent(compo), docInfo);
110+
110111
new OnTextDocumentControllerInitialized(docInfo.getTextDocumentController()).emit();
111112
}
112-
113+
113114
public Map<HashableComponent, Info> getTextDocumentList() {
114115
return info;
115116
}

core/src/main/java/de/muenchen/allg/itd51/wollmux/document/TextDocumentController.java

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@
6969
import de.muenchen.allg.itd51.wollmux.form.control.FormController;
7070
import de.muenchen.allg.itd51.wollmux.form.model.FormModel;
7171
import de.muenchen.allg.itd51.wollmux.form.model.FormModelException;
72-
import de.muenchen.allg.itd51.wollmux.form.model.FormValueChangedListener;
73-
import de.muenchen.allg.itd51.wollmux.form.model.VisibilityChangedListener;
7472
import de.muenchen.allg.itd51.wollmux.func.Function;
7573
import de.muenchen.allg.itd51.wollmux.func.FunctionFactory;
7674
import de.muenchen.allg.itd51.wollmux.func.FunctionLibrary;
@@ -85,7 +83,7 @@
8583
/**
8684
* Controller of the document.
8785
*/
88-
public class TextDocumentController implements FormValueChangedListener, VisibilityChangedListener
86+
public class TextDocumentController
8987
{
9088

9189
private static final Logger LOGGER = LoggerFactory.getLogger(TextDocumentController.class);
@@ -465,7 +463,7 @@ public int evaluateDocumentActions(Iterator<Function> funcs)
465463
while (funcs.hasNext())
466464
{
467465
Function f = funcs.next();
468-
String res = f.getString(values);
466+
String res = f.getResult(values);
469467
if (res.length() > 0)
470468
{
471469
if ("noaction".equals(res))
@@ -790,7 +788,7 @@ public String getTransformedValue(String trafoName, String value)
790788
String[] pars = func.parameters();
791789
for (int i = 0; i < pars.length; i++)
792790
args.put(pars[i], value);
793-
transformed = func.getString(args);
791+
transformed = func.getResult(args);
794792
} else
795793
{
796794
transformed = L.m("<FEHLER: TRAFO '%1' nicht definiert>", trafoName);
@@ -819,7 +817,7 @@ private String getTransformedValue(String trafoName, Map<String, String> mapIdTo
819817
String[] pars = func.parameters();
820818
for (int i = 0; i < pars.length; i++)
821819
args.put(pars[i], mapIdToValues.get(pars[i]));
822-
return func.getString(args);
820+
return func.getResult(args);
823821
} else
824822
{
825823
LOGGER.error("Die TRAFO '{}' ist nicht definiert.", trafoName);
@@ -1091,7 +1089,7 @@ public void updateFormFields(String fieldId)
10911089
* @param visible
10921090
* If true shows the elements, otherwise hides the elements.
10931091
*/
1094-
public synchronized void setVisibleState(String groupId, boolean visible)
1092+
public void setVisibleState(String groupId, boolean visible)
10951093
{
10961094
try
10971095
{
@@ -1828,27 +1826,10 @@ public FormModel getFormModel() throws FormModelException
18281826
if (formModel == null)
18291827
{
18301828
formModel = new FormModel(getFormConfig(), getFunctionContext(), getFunctionLibrary(), getDialogLibrary(),
1831-
getIDToPresetValue());
1829+
getIDToPresetValue(), this);
18321830
boolean modified = model.isDocumentModified();
18331831
model.setDocumentModifiable(false);
1834-
formModel.notifyWithCurrentValues(new FormValueChangedListener()
1835-
{
1836-
1837-
@Override
1838-
public void valueChanged(String id, String value)
1839-
{
1840-
addFormFieldValue(id, value);
1841-
}
1842-
1843-
@Override
1844-
public void statusChanged(String id, boolean okay)
1845-
{
1846-
// nothing to do
1847-
}
1848-
});
18491832
formModel.notifyWithCurrentVisibilites(this::setVisibleState);
1850-
formModel.addFormModelChangedListener(this, false);
1851-
formModel.addVisibilityChangedListener(this, false);
18521833
model.setDocumentModified(modified);
18531834
model.setDocumentModifiable(true);
18541835
}
@@ -1949,15 +1930,12 @@ public void setDefaultWindowAttributes(String value)
19491930
* @param value
19501931
* The new value of the form field.
19511932
*/
1952-
@Override
1953-
public void valueChanged(String id, String value)
1954-
{
1933+
public void setValueChanged(String id, String value) {
19551934
if (!id.isEmpty())
19561935
{
19571936
new OnFormValueChanged(this, id, value).emit();
19581937
}
19591938
}
1960-
19611939
/**
19621940
* Set the visibility of a group.
19631941
*
@@ -1966,15 +1944,9 @@ public void valueChanged(String id, String value)
19661944
* @param visible
19671945
* True if the group should be visible, false otherwise.
19681946
*/
1969-
@Override
1970-
public void visibilityChanged(String groupId, boolean visible)
1947+
public void setVisibilityChanged(String groupId, boolean visible)
19711948
{
19721949
new OnSetVisibleState(this, groupId, visible, null).emit();
19731950
}
1974-
1975-
@Override
1976-
public void statusChanged(String id, boolean okay)
1977-
{
1978-
// nothing to do here, only for form gui.
1979-
}
1951+
19801952
}

core/src/main/java/de/muenchen/allg/itd51/wollmux/document/TextDocumentModel.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public class TextDocumentModel
175175
/**
176176
* Cache of fragment URLS of an openTemplate command.
177177
*/
178-
private volatile String[] fragUrls;
178+
private String[] fragUrls;
179179

180180
/**
181181
* True if this document is a template or should be treated as template.
@@ -197,12 +197,12 @@ public class TextDocumentModel
197197
/**
198198
* The print functions specified for the document.
199199
*/
200-
private volatile Set<String> printFunctions;
200+
private Set<String> printFunctions;
201201

202202
/**
203203
* The form description or null if not yet read.
204204
*/
205-
private volatile ConfigThingy formularConf;
205+
private ConfigThingy formularConf;
206206

207207
/**
208208
* Mapping from field id to form value.
@@ -217,7 +217,7 @@ public class TextDocumentModel
217217
/**
218218
* The document commands.
219219
*/
220-
private volatile DocumentCommands documentCommands;
220+
private DocumentCommands documentCommands;
221221

222222
/**
223223
* Mapping from visibility group names to their visibility state.
@@ -232,7 +232,7 @@ public class TextDocumentModel
232232
/**
233233
* Null or the configuration of a mail merge.
234234
*/
235-
private volatile ConfigThingy mailmergeConf;
235+
private ConfigThingy mailmergeConf;
236236

237237
/**
238238
* Has the version info been updated?
@@ -390,7 +390,7 @@ public synchronized DocumentCommands getDocumentCommands()
390390
return documentCommands;
391391
}
392392

393-
public synchronized void setIDToFormFields(Map<String, List<FormField>> idToFormFields)
393+
public void setIDToFormFields(Map<String, List<FormField>> idToFormFields)
394394
{
395395
this.idToFormFields = idToFormFields;
396396
}
@@ -551,15 +551,15 @@ public void importFormValues(File file) throws IOException
551551
String data = new String(Files.readAllBytes(file.toPath()));
552552
parseFormValues(data);
553553
}
554-
554+
555555
/**
556556
* Parses the string as {@link ConfigThingy} of the form "WM(FormularWerte(...))" and adds the
557557
* values to {@link #formFieldValues}.
558558
*
559559
* @param werteStr
560560
* The string defining the form values. If null nothing is done.
561561
*/
562-
private void parseFormValues(String werteStr)
562+
public void parseFormValues(String werteStr)
563563
{
564564
if (werteStr == null)
565565
{
@@ -695,7 +695,7 @@ public synchronized boolean hasURL()
695695
*
696696
* @return True if the document has a form description with a defined form GUI, false otherwise.
697697
*/
698-
public synchronized boolean hasFormGUIWindow()
698+
public boolean hasFormGUIWindow()
699699
{
700700
try
701701
{
@@ -842,7 +842,7 @@ public synchronized SetJumpMark getFirstJumpMark()
842842
*
843843
* @return A set of field IDs.
844844
*/
845-
public synchronized Set<String> getAllFieldIDs()
845+
public Set<String> getAllFieldIDs()
846846
{
847847
HashSet<String> ids = new HashSet<>();
848848
ids.addAll(idToFormFields.keySet());
@@ -908,7 +908,7 @@ public synchronized boolean hasSelection()
908908
*
909909
* @return The form description.
910910
*/
911-
public synchronized ConfigThingy getFormDescription()
911+
public ConfigThingy getFormDescription()
912912
{
913913
if (formularConf == null)
914914
{
@@ -984,7 +984,7 @@ public ConfigThingy getFunktionenConf()
984984
* @param fieldId
985985
* The ID of the field to focus.
986986
*/
987-
public synchronized void focusFormField(String fieldId)
987+
public void focusFormField(String fieldId)
988988
{
989989
FormField field;
990990
List<FormField> formFields = getIdToTextFieldFormFields().get(fieldId);
@@ -1512,7 +1512,7 @@ public static String getDocumentCommandByBookmarkName(String bookmarkName)
15121512
* Don't collect information about the fields with an ID in this set.
15131513
* @return Array of information per field ordered alphabetically.
15141514
*/
1515-
public synchronized ReferencedFieldID[] getReferencedFieldIDsThatAreNotInSchema(Set<String> blacklist)
1515+
public ReferencedFieldID[] getReferencedFieldIDsThatAreNotInSchema(Set<String> blacklist)
15161516
{
15171517
ArrayList<ReferencedFieldID> list = new ArrayList<>();
15181518

core/src/main/java/de/muenchen/allg/itd51/wollmux/document/commands/OnProcessTextDocument.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,27 +73,24 @@ public void onTextDocumentControllerInitialized(OnTextDocumentControllerInitiali
7373
// configuration for Fenster isn't mandatory
7474
}
7575

76-
DocumentCommandInterpreter dci = new DocumentCommandInterpreter(
77-
documentController, WollMuxFiles.isDebugMode());
76+
DocumentCommandInterpreter dci = new DocumentCommandInterpreter(documentController, WollMuxFiles.isDebugMode());
7877

7978
try
8079
{
8180
// scan global document commands
8281
dci.scanGlobalDocumentCommands();
8382

84-
int actions = documentController.evaluateDocumentActions(GlobalFunctions
85-
.getInstance().getDocumentActionFunctions().iterator());
83+
int actions = documentController
84+
.evaluateDocumentActions(GlobalFunctions.getInstance().getDocumentActionFunctions().iterator());
8685

8786
// if it is a template execute the commands
88-
if ((actions < 0 && documentController.getModel().isTemplate())
89-
|| (actions == Integer.MAX_VALUE))
87+
if ((actions < 0 && documentController.getModel().isTemplate()) || (actions == Integer.MAX_VALUE))
9088
{
9189
dci.executeTemplateCommands();
9290

9391
// there can be new commands now
9492
dci.scanGlobalDocumentCommands();
9593
}
96-
dci.scanInsertFormValueCommands();
9794

9895
} catch (java.lang.Exception e)
9996
{

core/src/main/java/de/muenchen/allg/itd51/wollmux/event/handlers/OnActivateSidebar.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private void activateSidebarPanel(XController2 controller, String deckName)
8989
try
9090
{
9191
XDeck deck = UnoSidebar.getDeckByName(deckName, controller);
92-
if (deck != null)
92+
if (deck != null && !deck.isActive())
9393
{
9494
deck.activate(true);
9595
}

core/src/main/java/de/muenchen/allg/itd51/wollmux/event/handlers/OnSaveAs.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private File getDefaultFile(Function func)
123123
value = "";
124124
values.put(par, value);
125125
}
126-
String filename = func.getString(values);
126+
String filename = func.getResult(values);
127127
File f = new File(filename);
128128
if (f.isAbsolute())
129129
return f;

core/src/main/java/de/muenchen/allg/itd51/wollmux/event/handlers/OnTextDocumentControllerInitialized.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
*/
3737
public class OnTextDocumentControllerInitialized extends WollMuxEvent
3838
{
39-
private final TextDocumentController documentController;
39+
private TextDocumentController documentController;
4040

4141
/**
4242
* Handled if TextDocumentController is initialized.

core/src/main/java/de/muenchen/allg/itd51/wollmux/event/handlers/WollMuxEvent.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ protected void errorMessage(Throwable t)
9191
*/
9292
if (t.getCause() instanceof RuntimeException)
9393
{
94+
LOGGER.error("", t);
9495
return;
9596
}
9697

core/src/main/java/de/muenchen/allg/itd51/wollmux/form/model/Control.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public void computeNewValues(String value, SimpleMap values, SimpleMap modified)
282282
public String computeValue(SimpleMap values)
283283
{
284284
if (autofill.isPresent())
285-
return autofill.get().getString(values);
285+
return autofill.get().getResult(values);
286286
else if (type == UIElementType.COMBOBOX && !options.isEmpty())
287287
return options.get(0);
288288
else

0 commit comments

Comments
 (0)