 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.model.index;
23 import java.util.Collection;
24 import java.util.HashSet;
25 import java.util.Iterator;
26 import java.util.TreeSet;
27 import org.jetbrains.annotations.NotNull;
28 import org.junit.Assert;
29 import org.junit.Test;
43 index.
add(
new File(
"a"), 1L);
44 index.
add(
new File(
"b"), 1L);
45 index.
add(
new File(
"c"), 1L);
46 Assert.assertEquals(
"a,b,c",
getPending(index));
48 index.
add(
new File(
"d"), 1L);
50 index.
add(
new File(
"b"), 1L);
51 index.
add(
new File(
"d"), 1L);
53 index.
add(
new File(
"b"), 2L);
54 index.
add(
new File(
"d"), 2L);
59 index.
add(
new File(
"b"), 3L);
60 index.
add(
new File(
"c"), 3L);
61 index.
remove(
new File(
"b"));
83 index.
add(
new File(
"abc"), 1L);
84 index.
setName(
new File(
"abc"), 1L,
"abC");
88 index.
add(
new File(
"bcd"), 1L);
89 index.
setName(
new File(
"bcd"), 1L,
"BcD");
103 index.
add(
new File(
"a"), 1L);
104 index.
add(
new File(
"b"), 1L);
105 index.
add(
new File(
"c"), 1L);
106 index.
setName(
new File(
"a"), 2L,
"a");
107 index.
setName(
new File(
"b"), 2L,
"a");
108 index.
setName(
new File(
"c"), 2L,
"a");
110 index.
add(
new File(
"b"), 1L);
111 index.
add(
new File(
"c"), 2L);
112 index.
add(
new File(
"d"), 2L);
114 index.
setName(
new File(
"b"), 2L,
"a");
115 index.
setName(
new File(
"c"), 2L,
"a");
116 index.
setName(
new File(
"d"), 2L,
"a");
129 index.
add(
new File(
"a"), 1L);
130 Assert.assertEquals(
"add a\n" +
"pending changed\n", listener.
getAndClearEvents());
132 index.
add(
new File(
"a"), 1L);
135 index.
add(
new File(
"a"), 2L);
138 index.
add(
new File(
"b"), 2L);
139 index.
add(
new File(
"c"), 2L);
142 index.
remove(
new File(
"b"));
145 index.
setName(
new File(
"a"), 2L,
"name1");
146 index.
setName(
new File(
"b"), 2L,
"name2");
147 index.
setName(
new File(
"c"), 2L,
"name3");
148 Assert.assertEquals(
"name changed\n" +
"name changed\n" +
"name changed\n", listener.
getAndClearEvents());
159 final Collection<File> pendingFiles =
new HashSet<>();
161 final File pendingFile = index.removePending();
162 if (pendingFile ==
null) {
165 pendingFiles.add(pendingFile);
167 return format(pendingFiles);
188 private static String
format(@NotNull
final Collection<File>
files) {
189 final Iterable<File> tmp =
new TreeSet<>(
files);
190 final StringBuilder sb =
new StringBuilder();
191 final Iterator<File>
it = tmp.iterator();
193 sb.append(
it.next());
194 while (
it.hasNext()) {
196 sb.append(
it.next());
199 return sb.toString();
static String findPartialName(@NotNull final Index< File > index, @NotNull final String name)
Calls Index#findPartialName(String) on the given Index and name and returns a string representation o...
Standard Edition Runtime Environment README Import and export control rules on cryptographic software vary from country to country The Java Cryptography Java provides two different sets of cryptographic policy files
static Index< File > newIndex()
Returns a new Index instance.
final StringBuilder stringBuilder
The recorded events in text representation.
void endUpdate()
Ends an update.
void remove(@NotNull V value)
Removes a value from the cache.
static String getPending(@NotNull final Index< File > index)
Returns all pending values of a MapsIndex.
void valueAdded(@NotNull final File value)
void setPending(@NotNull V value)
Marks a value as pending.
static String format(@NotNull final Collection< File > files)
Returns a text representation of a Collection.
void addIndexListener(@NotNull IndexListener< V > listener)
Adds an IndexListener to be notified of changes.
Regression tests for MapsIndex.
void testTransaction()
Checks that Index#beginUpdate() and Index#endUpdate() works as expected.
void test1()
Checks that values are correctly marked as pending.
void testFind1()
Checks that Index#findPartialName(String) works as expected.
Abstract base class for Index implementations.
Interface for listeners interested in Index related events.
An IndexListener that records a text representation of all generated events.
void add(@NotNull V value, long timestamp)
Adds a value to the cache.
void beginUpdate()
Starts an update.
void testListener()
Checks that listeners are notified.
void valueRemoved(@NotNull final File value)
String getAndClearEvents()
Returns the accumulated events.
This document describes some hints and requirements for general development on the CrossfireEditor If you plan to make changes to the editor code or setup please read the following and keep it in derived from a basic editor application called Gridder by Pasi Ker�nen so please communicate with best through the cf devel mailing before considering any fundamental changes About code DO NOT USE TABS No matter what Java development platform you are please configure insert indent Tabs are displayed totally different in every editor and there are millions of different editors out there The insertion of tabs in the source code is messing up the syntax formatting in a way that is UNREPAIRABLE Apart from please keep code indentation accurate This is not just good it helps to keep code readable and in that way dramatically decreases the chance for overlooked bugs Everyone is welcomed to correct indentation errors wherever they are spotted Before you start to do this please double check that your editor is really configured to insert spaces Line feeds may be checked in either in windows or in unix linux style All reasonable text and java editors can deal with both linefeed formats Converting line feeds is but in this case please make sure that only linefeed characters are changed and nothing else is affected Due to the platform independent nature of the editor has the potential to run on almost any given operating system the build process differs greatly between systems as well as java environments In the several people have attempted to add build scripts along with structural changes to optimize the setup on one particular system environment which has led to conflict Please do *not *attempt to change the structure or any directories for the mere purpose of improving a build process or performance in a java environment Build scripts may be placed in the root it would be especially fine if it is just one or two files but the latter is not required Please excuse me for placing such restriction I and many users of the editor greatly appreciate build scripts We just had some real troubles over this issue in the past and I don t want to have them repeated the editor has relatively high performance requirements I ve spent a lot of extra work to keep everything as fast and memory efficient as possible when you add new data fields or calculations in the archetype please make sure they are as efficient as possible and worth both the time and space they consume Now don t be afraid too much No development would be possible without adding calculations and data at all Just bear in mind unlike for many other open source performance does make a difference for the CrossfireEditor The for as many systems as possible In case you are unexperienced with java and note that the graphics look different on every and with every font They also have different sizes proportions and behave different A seemingly trivial and effectless change can wreck havoc for the same GUI run on another system please don t be totally afraid of it
void setName(@NotNull V value, long timestamp, @NotNull String name)
Associates a value with a name.