// Copyright 2012 Georg-August-Universität Göttingen, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package de.ugoe.cs.autoquest.eventcore.guimodel; import java.util.LinkedList; import java.util.List; /** *
* Skeletal implementation for GUI elements. *
* * @version 1.0 * @author Patrick Harms */ public abstract class AbstractDefaultGUIElement implements IGUIElement { /** ** Id for object serialization. *
*/ public static final long serialVersionUID = 1L; /** ** Specification of the GUI element *
*/ private final IGUIElementSpec specification; /** ** Reference to the parent element *
*/ private IGUIElement parent; /** ** List of other GUI elements being equal to this *
*/ private List* Boolean that indicates if a GUIElement was used during a session. *
*/ boolean usageObserved; /** ** Constructor. Creates a new AbstractDefaultGUIElement. *
* * @param specification * specification of the created GUI element * @param parent * parent of the created GUI element; null means the element is a top-level window */ public AbstractDefaultGUIElement(IGUIElementSpec specification, IGUIElement parent) { this.specification = specification; this.usageObserved = false; setParent(parent); } /* * (non-Javadoc) * * @see de.ugoe.cs.tasktree.guimodel.GUIElement#getSpecification() */ @Override public IGUIElementSpec getSpecification() { return specification; } /* * (non-Javadoc) * * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#getParent() */ @Override public IGUIElement getParent() { return parent; } /* * (non-Javadoc) * * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#addEqualGUIElement(IGUIElement) */ @Override public void addEqualGUIElement(IGUIElement equalElement) { if (!(equalElement instanceof AbstractDefaultGUIElement)) { throw new IllegalArgumentException ("this implementation can only handle other AbstractDefaultGUIElements"); } AbstractDefaultGUIElement other = (AbstractDefaultGUIElement) equalElement; synchronized (AbstractDefaultGUIElement.class) { if (this.equalGUIElements == null) { if (other.equalGUIElements == null) { this.equalGUIElements = new LinkedList* updates the parent node of this node if required due to model restructuring *
*/ void setParent(IGUIElement newParent) { this.parent = newParent; } /** ** Adds an {@link AbstractDefaultGUIElement} as equal to a list of * {@link AbstractDefaultGUIElement}s if and only if it is not already contained. *
* * @param equalElementsList * list of {@link AbstractDefaultGUIElement} to which the GUI element is added * @param guiElement * GUI element to be added */ private void addIfNotContained(List