contact within block now working
This commit is contained in:
@@ -159,6 +159,10 @@ public abstract class Block extends StretchableTile{
|
||||
return fieldset;
|
||||
}
|
||||
|
||||
public Collection<? extends Contact> contacts() {
|
||||
return internalContacts;
|
||||
}
|
||||
|
||||
public abstract Direction directionA();
|
||||
public abstract Direction directionB();
|
||||
|
||||
@@ -194,6 +198,10 @@ public abstract class Block extends StretchableTile{
|
||||
}
|
||||
return getWaitTime(NO_TAG).get(dir);
|
||||
}
|
||||
|
||||
public int indexOf(BlockContact contact) {
|
||||
return 1+internalContacts.indexOf(contact);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject json() {
|
||||
@@ -203,6 +211,15 @@ public abstract class Block extends StretchableTile{
|
||||
JSONArray jWaitTimes = new JSONArray();
|
||||
for (WaitTime wt : waitTimes) jWaitTimes.put(wt.json());
|
||||
json.put(WAIT_TIMES, jWaitTimes);
|
||||
JSONObject jContacts = null;
|
||||
for (BlockContact contact : internalContacts) {
|
||||
int addr = contact.addr();
|
||||
if (addr != 0) {
|
||||
if (isNull(jContacts)) jContacts = new JSONObject();
|
||||
jContacts.put(contact.id().toString(), contact.addr());
|
||||
}
|
||||
}
|
||||
if (isSet(jContacts)) json.put(CONTACT, jContacts);
|
||||
return json;
|
||||
}
|
||||
|
||||
@@ -230,6 +247,10 @@ public abstract class Block extends StretchableTile{
|
||||
if (object instanceof JSONObject) waitTimes.add(new WaitTime(null).load((JSONObject) object));
|
||||
});
|
||||
}
|
||||
if (json.has(CONTACT)) {
|
||||
JSONObject jContact = json.getJSONObject(CONTACT);
|
||||
for (String key : jContact.keySet()) new BlockContact(this).addr(jContact.getInt(key));
|
||||
}
|
||||
return super.load(json);
|
||||
}
|
||||
|
||||
@@ -260,6 +281,16 @@ public abstract class Block extends StretchableTile{
|
||||
return contact;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeChild(BaseClass child) {
|
||||
super.removeChild(child);
|
||||
internalContacts.remove(child);
|
||||
}
|
||||
|
||||
public void removeContact(BlockContact blockContact) {
|
||||
internalContacts.remove(blockContact);
|
||||
}
|
||||
|
||||
public static Select selector(Block preselected,Collection<Block> exclude) {
|
||||
if (isNull(exclude)) exclude = new Vector<Block>();
|
||||
Select select = new Select(Block.class.getSimpleName());
|
||||
|
||||
Reference in New Issue
Block a user