-
Notifications
You must be signed in to change notification settings - Fork 461
/
Copy pathElementLibrary.java
717 lines (648 loc) · 26.3 KB
/
ElementLibrary.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
/*
* Copyright (c) 2016 Helmut Neemann
* Use of this source code is governed by the GPL v3 license
* that can be found in the LICENSE file.
*/
package de.neemann.digital.draw.library;
import de.neemann.digital.core.arithmetic.*;
import de.neemann.digital.core.arithmetic.Comparator;
import de.neemann.digital.core.basic.*;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.core.element.ElementTypeDescription;
import de.neemann.digital.core.element.Keys;
import de.neemann.digital.core.extern.External;
import de.neemann.digital.core.extern.ExternalFile;
import de.neemann.digital.core.flipflops.*;
import de.neemann.digital.core.io.*;
import de.neemann.digital.core.io.telnet.Telnet;
import de.neemann.digital.core.memory.*;
import de.neemann.digital.core.pld.DiodeBackward;
import de.neemann.digital.core.pld.DiodeForward;
import de.neemann.digital.core.pld.PullDown;
import de.neemann.digital.core.pld.PullUp;
import de.neemann.digital.core.switching.*;
import de.neemann.digital.core.wiring.*;
import de.neemann.digital.draw.elements.Circuit;
import de.neemann.digital.draw.elements.PinException;
import de.neemann.digital.draw.elements.Tunnel;
import de.neemann.digital.draw.shapes.ShapeFactory;
import de.neemann.digital.gui.Settings;
import de.neemann.digital.gui.components.data.DummyElement;
import de.neemann.digital.gui.components.data.ScopeTrigger;
import de.neemann.digital.gui.components.graphics.GraphicCard;
import de.neemann.digital.gui.components.graphics.LedMatrix;
import de.neemann.digital.gui.components.graphics.VGA;
import de.neemann.digital.gui.components.terminal.Keyboard;
import de.neemann.digital.gui.components.terminal.Terminal;
import de.neemann.digital.lang.Lang;
import de.neemann.digital.testing.TestCaseElement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.*;
/**
* The ElementLibrary is responsible for storing all the components which can be used in a circuit.
* Also the import of nested circuits is handled in this class.
* This import works in two steps: At first all the files in the same directory as the root circuit are loaded.
* The file names are shown in the components menu. From there you can pick a file to insert it to the circuit.
* When a file is selected it is loaded to the library. After that also an icon is available.
* This is done because the loading of a circuit and the creation of an icon is very time consuming and should
* be avoided if not necessary. It's a kind of lazy loading.
*/
public class ElementLibrary implements Iterable<ElementLibrary.ElementContainer>, LibraryInterface {
private static final Logger LOGGER = LoggerFactory.getLogger(ElementLibrary.class);
private static final long MIN_RESCAN_INTERVAL = 5000;
/**
* @return the additional library path
*/
public static File getLibPath() {
String path;
try {
path = ElementLibrary.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath().replace('\\', '/');
} catch (URISyntaxException e) {
return new File("noLibFound");
}
if (path.endsWith("/target/classes/"))
return toCanonical(new File(path.substring(0, path.length() - 16) + "/src/main/dig/lib"));
if (path.endsWith("/target/Digital.jar"))
return new File(path.substring(0, path.length() - 19) + "/src/main/dig/lib");
if (path.endsWith("Digital.jar"))
return new File(path.substring(0, path.length() - 12) + "/lib");
return new File("noLibFound");
}
private static File toCanonical(File file) {
try {
return file.getCanonicalFile();
} catch (IOException e) {
return file;
}
}
private final HashMap<String, LibraryNode> map = new HashMap<>();
private final HashSet<String> isProgrammable = new HashSet<>();
private final ArrayList<LibraryListener> listeners = new ArrayList<>();
private final LibraryNode root;
private final ElementLibraryFolder custom;
private JarComponentManager jarComponentManager;
private ShapeFactory shapeFactory;
private File rootLibraryPath;
private Exception exception;
private long lastRescanTime;
private StringBuilder warningMessage;
/**
* Creates a new instance.
*/
public ElementLibrary() {
this(null);
}
/**
* Creates a new instance.
*
* @param jarFile the jar file to load
*/
public ElementLibrary(File jarFile) {
root = new LibraryNode(Lang.get("menu_elements"))
.setLibrary(this)
.add(new LibraryNode(Lang.get("lib_Logic"))
.add(And.DESCRIPTION)
.add(NAnd.DESCRIPTION)
.add(Or.DESCRIPTION)
.add(NOr.DESCRIPTION)
.add(XOr.DESCRIPTION)
.add(XNOr.DESCRIPTION)
.add(Not.DESCRIPTION)
.add(LookUpTable.DESCRIPTION))
.add(new LibraryNode(Lang.get("lib_io"))
.add(Out.DESCRIPTION)
.add(Out.LEDDESCRIPTION)
.add(In.DESCRIPTION)
.add(Clock.DESCRIPTION)
.add(Button.DESCRIPTION)
.add(DipSwitch.DESCRIPTION)
.add(Probe.DESCRIPTION)
.add(DummyElement.DATADESCRIPTION)
.add(ScopeTrigger.DESCRIPTION)
.add(new LibraryNode(Lang.get("lib_displays"))
.add(RGBLED.DESCRIPTION)
.add(Out.POLARITYAWARELEDDESCRIPTION)
.add(ButtonLED.DESCRIPTION)
.add(Out.SEVENDESCRIPTION)
.add(Out.SEVENHEXDESCRIPTION)
.add(Out.SIXTEENDESCRIPTION)
.add(LightBulb.DESCRIPTION)
.add(LedMatrix.DESCRIPTION)
)
.add(new LibraryNode(Lang.get("lib_mechanic"))
.add(RotEncoder.DESCRIPTION)
.add(StepperMotorUnipolar.DESCRIPTION)
.add(StepperMotorBipolar.DESCRIPTION)
)
.add(new LibraryNode(Lang.get("lib_peripherals"))
.add(Keyboard.DESCRIPTION)
.add(Terminal.DESCRIPTION)
.add(Telnet.DESCRIPTION)
.add(VGA.DESCRIPTION)
.add(MIDI.DESCRIPTION)
)
)
.add(new LibraryNode(Lang.get("lib_wires"))
.add(Ground.DESCRIPTION)
.add(VDD.DESCRIPTION)
.add(Const.DESCRIPTION)
.add(Tunnel.DESCRIPTION)
.add(Splitter.DESCRIPTION)
.add(Driver.DESCRIPTION)
.add(DriverInvSel.DESCRIPTION)
.add(Delay.DESCRIPTION)
.add(PullUp.DESCRIPTION)
.add(PullDown.DESCRIPTION)
.add(NotConnected.DESCRIPTION))
.add(new LibraryNode(Lang.get("lib_mux"))
.add(Multiplexer.DESCRIPTION)
.add(Demultiplexer.DESCRIPTION)
.add(Decoder.DESCRIPTION)
.add(BitSelector.DESCRIPTION)
.add(PriorityEncoder.DESCRIPTION))
.add(new LibraryNode(Lang.get("lib_flipFlops"))
.add(FlipflopRSAsync.DESCRIPTION)
.add(FlipflopRS.DESCRIPTION)
.add(FlipflopJK.DESCRIPTION)
.add(FlipflopD.DESCRIPTION)
.add(FlipflopT.DESCRIPTION)
.add(FlipflopJKAsync.DESCRIPTION)
.add(FlipflopDAsync.DESCRIPTION)
.add(Monoflop.DESCRIPTION))
.add(new LibraryNode(Lang.get("lib_memory"))
.add(new LibraryNode(Lang.get("lib_ram"))
.add(RAMDualPort.DESCRIPTION)
.add(BlockRAMDualPort.DESCRIPTION)
.add(RAMSinglePort.DESCRIPTION)
.add(RAMSinglePortSel.DESCRIPTION)
.add(RegisterFile.DESCRIPTION)
.add(RAMDualAccess.DESCRIPTION)
.add(RAMAsync.DESCRIPTION)
.add(GraphicCard.DESCRIPTION))
.add(new LibraryNode(Lang.get("lib_eeprom"))
.add(EEPROM.DESCRIPTION)
.add(EEPROMDualPort.DESCRIPTION))
.add(Register.DESCRIPTION)
.add(ROM.DESCRIPTION)
.add(ROMDualPort.DESCRIPTION)
.add(Counter.DESCRIPTION)
.add(CounterPreset.DESCRIPTION)
.add(PRNG.DESCRIPTION))
.add(new LibraryNode(Lang.get("lib_arithmetic"))
.add(Add.DESCRIPTION)
.add(Sub.DESCRIPTION)
.add(Mul.DESCRIPTION)
.add(Div.DESCRIPTION)
.add(BarrelShifter.DESCRIPTION)
.add(Comparator.DESCRIPTION)
.add(Neg.DESCRIPTION)
.add(BitExtender.DESCRIPTION)
.add(BitCount.DESCRIPTION))
.add(new LibraryNode(Lang.get("lib_switching"))
.add(Switch.DESCRIPTION)
.add(SwitchDT.DESCRIPTION)
.add(Relay.DESCRIPTION)
.add(RelayDT.DESCRIPTION)
.add(PFET.DESCRIPTION)
.add(NFET.DESCRIPTION)
.add(Fuse.DESCRIPTION)
//.add(Diode.DESCRIPTION) // see class DiodeTest for further information
.add(DiodeForward.DESCRIPTION)
.add(DiodeBackward.DESCRIPTION)
.add(FGPFET.DESCRIPTION)
.add(FGNFET.DESCRIPTION)
.add(TransGate.DESCRIPTION))
.add(new LibraryNode(Lang.get("lib_misc"))
.add(TestCaseElement.DESCRIPTION)
.add(new LibraryNode(Lang.get("lib_decoration"))
.add(DummyElement.TEXTDESCRIPTION)
.add(DummyElement.RECTDESCRIPTION))
.add(new LibraryNode(Lang.get("lib_generic"))
.add(GenericInitCode.DESCRIPTION)
.add(GenericCode.DESCRIPTION))
.add(new LibraryNode(Lang.get("lib_hdl"))
.add(External.DESCRIPTION)
.add(ExternalFile.DESCRIPTION)
.add(PinControl.DESCRIPTION))
.add(PowerSupply.DESCRIPTION)
.add(BusSplitter.DESCRIPTION)
.add(Reset.DESCRIPTION)
.add(Break.DESCRIPTION)
.add(Stop.DESCRIPTION)
.add(AsyncSeq.DESCRIPTION));
addExternalJarComponents(jarFile);
custom = new ElementLibraryFolder(root, Lang.get("menu_custom"));
File libPath = Settings.getInstance().get(Keys.SETTINGS_LIBRARY_PATH);
if (libPath != null && libPath.exists())
new ElementLibraryFolder(root, Lang.get("menu_library")).scanFolder(libPath, true);
populateNodeMap();
isProgrammable.clear();
root.traverse(libraryNode -> {
ElementTypeDescription d = libraryNode.getDescriptionOrNull();
if (d != null && d.hasAttribute(Keys.BLOWN))
isProgrammable.add(d.getName());
});
}
void addExternalJarComponents(File file) {
if (file != null && file.getPath().length() > 0 && file.exists()) {
if (jarComponentManager == null)
jarComponentManager = new JarComponentManager(this);
try {
jarComponentManager.loadJar(file);
} catch (IOException | InvalidNodeException e) {
exception = e;
}
}
}
/**
* registers a component source to Digital
*
* @param source the source
* @return this for chained calls
*/
public ElementLibrary registerComponentSource(ComponentSource source) {
try {
if (jarComponentManager == null)
jarComponentManager = new JarComponentManager(this);
source.registerComponents(jarComponentManager);
} catch (InvalidNodeException e) {
exception = e;
}
return this;
}
/**
* @return returns a exception during initialization or null if there was none
*/
public Exception checkForException() {
Exception e = exception;
exception = null;
return e;
}
LibraryNode findNode(String path) throws InvalidNodeException {
StringTokenizer st = new StringTokenizer(path, "\\/;");
LibraryNode node = root;
while (st.hasMoreTokens()) {
String name = st.nextToken();
LibraryNode found = null;
for (LibraryNode n : node) {
if (n.getName().equals(name)) {
if (n.isLeaf())
throw new InvalidNodeException(Lang.get("err_Node_N_isAComponent", n));
found = n;
}
}
if (found == null) {
found = new LibraryNode(name);
node.add(found);
}
node = found;
}
return node;
}
/**
* @return the component manager
*/
public JarComponentManager getJarComponentManager() {
return jarComponentManager;
}
/**
* Returns true if element is programmable
*
* @param name the name
* @return true if it is programmable
*/
public boolean isProgrammable(String name) {
return isProgrammable.contains(name);
}
/**
* Sets the shape factory used to import sub circuits
*
* @param shapeFactory the shape factory
*/
public void setShapeFactory(ShapeFactory shapeFactory) {
this.shapeFactory = shapeFactory;
}
@Override
public ShapeFactory getShapeFactory() {
return shapeFactory;
}
/**
* @return the node with the custom elements
*/
public LibraryNode getCustomNode() {
return custom.getNode();
}
private void populateNodeMap() {
map.clear();
final PopulateMapVisitor populateMapVisitor = new PopulateMapVisitor(map);
root.traverse(populateMapVisitor);
warningMessage = populateMapVisitor.getWarningMessage();
}
/**
* @return the warning message or null if there is none
*/
public StringBuilder getWarningMessage() {
return warningMessage;
}
/**
* sets the root library path
*
* @param rootLibraryPath the path
* @throws IOException IOException
*/
public void setRootFilePath(File rootLibraryPath) throws IOException {
if (rootLibraryPath == null) {
if (this.rootLibraryPath != null) {
this.rootLibraryPath = null;
rescanFolder();
}
} else if (!rootLibraryPath.equals(this.rootLibraryPath)) {
this.rootLibraryPath = rootLibraryPath;
rescanFolder();
}
}
/**
* @return the actual root file path
*/
public File getRootFilePath() {
return rootLibraryPath;
}
/**
* Checks if the given file is accessible from the actual library.
*
* @param file the file to check
* @return true if given file is importable
*/
public boolean isFileAccessible(File file) {
if (rootLibraryPath == null) return true;
try {
String root = rootLibraryPath.getCanonicalPath();
return file.getParentFile().getCanonicalFile().toPath().startsWith(root);
} catch (IOException e) {
return false;
}
}
/**
* Returns the node or null if node not present.
*
* @param elementName the name
* @return the node or null
*/
public LibraryNode getElementNodeOrNull(String elementName) {
return map.get(elementName);
}
@Override
public ElementTypeDescription getElementType(String elementName, ElementAttributes attr) throws ElementNotFoundException {
return getElementType(elementName);
}
/**
* Returns a {@link ElementTypeDescription} by a given name.
* If not found its tried to load it.
*
* @param elementName the elements name
* @return the {@link ElementTypeDescription}
* @throws ElementNotFoundException ElementNotFoundException
*/
public ElementTypeDescription getElementType(String elementName) throws ElementNotFoundException {
try {
LibraryNode node = map.get(elementName);
if (node != null)
return node.getDescription();
// effects only some old files!
elementName = elementName.replace("\\", "/");
if (elementName.contains("/")) {
elementName = new File(elementName).getName();
}
node = map.get(elementName);
if (node != null)
return node.getDescription();
if (rootLibraryPath == null)
throw new ElementNotFoundException(Lang.get("err_fileNeedsToBeSaved"));
LOGGER.debug("could not find " + elementName);
if (System.currentTimeMillis() - lastRescanTime > MIN_RESCAN_INTERVAL) {
rescanFolder();
node = map.get(elementName);
if (node != null)
return node.getDescription();
}
} catch (IOException e) {
throw new ElementNotFoundException(Lang.get("msg_errorImportingModel_N0", elementName), e);
}
throw new ElementNotFoundException(Lang.get("err_element_N_notFound", elementName));
}
private void rescanFolder() {
LOGGER.debug("rescan folder");
LibraryNode cn = custom.scanFolder(rootLibraryPath, false);
populateNodeMap();
if (cn != null)
fireLibraryChanged(cn);
lastRescanTime = System.currentTimeMillis();
}
/**
* Fires a library event
*
* @param node the node changed
*/
void fireLibraryChanged(LibraryNode node) {
for (LibraryListener l : listeners)
l.libraryChanged(node);
}
/**
* Adds a listener to this library
*
* @param listener the listener to add
*/
public void addListener(LibraryListener listener) {
listeners.add(listener);
LOGGER.debug("added library listener " + listener.getClass().getSimpleName() + ", listeners: " + listeners.size());
}
/**
* Removes a listener from this library
*
* @param listener the listener to remove
*/
public void removeListener(LibraryListener listener) {
listeners.remove(listener);
LOGGER.debug("removed library listener " + listener.getClass().getSimpleName() + ", listeners: " + listeners.size());
}
@Override
public Iterator<ElementContainer> iterator() {
ArrayList<ElementContainer> nodes = new ArrayList<>();
for (LibraryNode n : getRoot())
addToList(nodes, n, "");
return nodes.iterator();
}
private void addToList(ArrayList<ElementContainer> nodes, LibraryNode node, String path) {
if (node.isLeaf()) {
if (node.isDescriptionLoaded()) {
try {
nodes.add(new ElementContainer(node.getDescription(), path));
} catch (IOException e) {
// can not happen because description is present!
}
}
} else
for (LibraryNode n : node)
addToList(nodes, n, concat(path, node.getName()));
}
private String concat(String path, String name) {
if (path.length() == 0)
return name;
return path + " - " + name;
}
/**
* Removes an element from the library to enforce a reload
*
* @param name the elements name
* @throws IOException IOException
*/
public void invalidateElement(File name) throws IOException {
LibraryNode n = map.get(name.getName());
if (n != null)
n.invalidate();
else {
if (rootLibraryPath != null && isFileAccessible(name))
rescanFolder();
}
}
/**
* Updates all entries
*
* @throws IOException IOException
*/
public void updateEntries() throws IOException {
rescanFolder();
}
/**
* @return the root element
*/
public LibraryNode getRoot() {
return root;
}
/**
* Imports the given file
*
* @param file the file to load
* @return the description
* @throws IOException IOException
*/
ElementTypeDescription importElement(File file) throws IOException {
try {
LOGGER.debug("load element " + file);
Circuit circuit;
try {
circuit = Circuit.loadCircuit(file, shapeFactory);
} catch (FileNotFoundException e) {
throw new IOException(Lang.get("err_couldNotFindIncludedFile_N0", file));
}
ElementTypeDescriptionCustom description = createCustomDescription(file, circuit, this);
description.setShortName(createShortName(file.getName(), circuit.getAttributes().getLabel()));
String descriptionText = Lang.evalMultilingualContent(circuit.getAttributes().get(Keys.DESCRIPTION));
if (descriptionText != null && descriptionText.length() > 0) {
description.setDescription(descriptionText);
}
return description;
} catch (PinException e) {
throw new IOException(Lang.get("msg_errorImportingModel_N0", file), e);
}
}
private String createShortName(String name, String userDefined) {
if (userDefined.isEmpty()) {
if (name.endsWith(".dig")) return name.substring(0, name.length() - 4).replace("_", "\\_");
String transName = Lang.getNull("elem_" + name);
if (transName == null)
return name;
else
return transName;
} else {
return userDefined;
}
}
/**
* Creates a custom element description.
*
* @param file the file
* @param circuit the circuit
* @param library the library
* @return the type description
* @throws PinException PinException
*/
public static ElementTypeDescriptionCustom createCustomDescription(File file, Circuit circuit, ElementLibrary library) throws PinException {
ElementTypeDescriptionCustom d = new ElementTypeDescriptionCustom(file, circuit, library);
d.setElementFactory(attributes -> new CustomElement(d));
return d;
}
/**
* Used to store a elements name and its position in the elements menu.
*/
public static class ElementContainer {
private final ElementTypeDescription name;
private final String treePath;
/**
* Creates anew instance
*
* @param typeDescription the elements typeDescription
* @param treePath the elements menu path
*/
ElementContainer(ElementTypeDescription typeDescription, String treePath) {
this.name = typeDescription;
this.treePath = treePath;
}
/**
* @return the elements name
*/
public ElementTypeDescription getDescription() {
return name;
}
/**
* @return Returns the path in the menu
*/
public String getTreePath() {
return treePath;
}
}
private static final class PopulateMapVisitor implements Visitor {
private static final int MAX_WARNING_ENTRIES = 15;
private final HashMap<String, LibraryNode> map;
private StringBuilder warningMessage;
private int warningEntries = 0;
private PopulateMapVisitor(HashMap<String, LibraryNode> map) {
this.map = map;
}
@Override
public void visit(LibraryNode libraryNode) {
if (libraryNode.isLeaf()) {
final String name = libraryNode.getName();
LibraryNode presentNode = map.get(name);
if (presentNode == null) {
map.put(name, libraryNode);
libraryNode.setUnique(true);
} else {
if (presentNode.equalsFile(libraryNode))
libraryNode.setUnique(true);
else {
presentNode.setUnique(false); // ToDo does not work if there are more than two duplicates and
libraryNode.setUnique(false); // some of the duplicates point to the same file
if (warningMessage == null)
warningMessage = new StringBuilder(Lang.get("msg_duplicateLibraryFiles"));
if (warningEntries <= MAX_WARNING_ENTRIES)
warningMessage.append("\n\n").append(presentNode.getFile()).append("\n").append(libraryNode.getFile());
warningEntries++;
}
}
}
}
private StringBuilder getWarningMessage() {
if (warningEntries >= MAX_WARNING_ENTRIES) {
warningMessage.append("\n\n").append(Lang.get("msg_and_N_More", warningEntries - MAX_WARNING_ENTRIES));
warningEntries = 0;
}
return warningMessage;
}
}
}