2015-01-21 21:58:35 +01:00
|
|
|
/*******************************************************************************
|
2021-01-09 14:26:49 +01:00
|
|
|
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others.
|
2015-01-21 21:58:35 +01:00
|
|
|
* All rights reserved. This program and the accompanying materials
|
|
|
|
* are made available under the terms of the Eclipse Public License v1.0
|
|
|
|
* which accompanies this distribution, and is available at
|
|
|
|
* http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
*
|
|
|
|
* Contributors:
|
|
|
|
* MINRES Technologies GmbH - initial API and implementation
|
|
|
|
*******************************************************************************/
|
2015-01-06 17:14:16 +01:00
|
|
|
package com.minres.scviewer.database;
|
2015-01-03 16:34:32 +01:00
|
|
|
|
|
|
|
import java.beans.PropertyChangeListener;
|
2015-01-10 00:23:46 +01:00
|
|
|
import java.beans.PropertyChangeSupport;
|
2015-01-03 16:34:32 +01:00
|
|
|
import java.util.ArrayList;
|
2021-01-09 20:10:58 +01:00
|
|
|
import java.util.Collections;
|
2015-01-03 16:34:32 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
2021-01-09 12:43:02 +01:00
|
|
|
/**
|
|
|
|
* The Class HierNode.
|
|
|
|
*/
|
2015-01-06 17:14:16 +01:00
|
|
|
public class HierNode implements IHierNode {
|
2015-01-03 16:34:32 +01:00
|
|
|
|
2021-01-09 12:43:02 +01:00
|
|
|
/** The name. */
|
2015-01-03 16:34:32 +01:00
|
|
|
protected String name;
|
2021-01-09 12:43:02 +01:00
|
|
|
|
|
|
|
/** The parent. */
|
2020-11-28 19:41:00 +01:00
|
|
|
protected IHierNode parent = null;
|
2021-01-09 12:43:02 +01:00
|
|
|
|
|
|
|
/** The childs. */
|
2021-01-09 20:10:58 +01:00
|
|
|
protected List<IHierNode> childNodes = Collections.synchronizedList(new ArrayList<>());
|
2021-01-09 12:43:02 +01:00
|
|
|
|
|
|
|
/** The pcs. */
|
2021-01-09 20:10:58 +01:00
|
|
|
protected PropertyChangeSupport pcs = new PropertyChangeSupport(this);
|
2015-01-10 00:23:46 +01:00
|
|
|
|
2021-01-09 12:43:02 +01:00
|
|
|
/**
|
|
|
|
* Instantiates a new hier node.
|
|
|
|
*
|
|
|
|
* @param name the name
|
|
|
|
*/
|
2015-01-03 16:34:32 +01:00
|
|
|
public HierNode(String name) {
|
2021-01-09 12:43:02 +01:00
|
|
|
this.name = name;
|
2015-10-22 00:02:58 +02:00
|
|
|
}
|
|
|
|
|
2021-01-09 12:43:02 +01:00
|
|
|
/**
|
|
|
|
* Instantiates a new hier node.
|
|
|
|
*
|
|
|
|
* @param name the name
|
|
|
|
* @param parent the parent
|
|
|
|
*/
|
2020-11-28 19:41:00 +01:00
|
|
|
public HierNode(String name, IHierNode parent) {
|
2021-01-09 12:43:02 +01:00
|
|
|
this.name = name;
|
|
|
|
this.parent = parent;
|
2015-01-03 16:34:32 +01:00
|
|
|
}
|
|
|
|
|
2021-01-09 20:10:58 +01:00
|
|
|
/**
|
|
|
|
* Instantiates a new hier node.
|
|
|
|
*/
|
|
|
|
public HierNode() {
|
|
|
|
}
|
|
|
|
|
2021-01-09 12:43:02 +01:00
|
|
|
/**
|
|
|
|
* Adds the property change listener.
|
|
|
|
*
|
|
|
|
* @param l the l
|
|
|
|
*/
|
2015-01-03 16:34:32 +01:00
|
|
|
@Override
|
|
|
|
public void addPropertyChangeListener(PropertyChangeListener l) {
|
2015-01-10 00:23:46 +01:00
|
|
|
pcs.addPropertyChangeListener(l);
|
2015-01-03 16:34:32 +01:00
|
|
|
}
|
|
|
|
|
2021-01-09 12:43:02 +01:00
|
|
|
/**
|
|
|
|
* Removes the property change listener.
|
|
|
|
*
|
|
|
|
* @param l the l
|
|
|
|
*/
|
2015-01-03 16:34:32 +01:00
|
|
|
@Override
|
|
|
|
public void removePropertyChangeListener(PropertyChangeListener l) {
|
2015-01-10 00:23:46 +01:00
|
|
|
pcs.removePropertyChangeListener(l);
|
2015-01-03 16:34:32 +01:00
|
|
|
}
|
|
|
|
|
2021-01-09 12:43:02 +01:00
|
|
|
/**
|
|
|
|
* Gets the full name.
|
|
|
|
*
|
|
|
|
* @return the full name
|
|
|
|
*/
|
2015-01-03 16:34:32 +01:00
|
|
|
@Override
|
|
|
|
public String getFullName() {
|
2021-01-09 12:43:02 +01:00
|
|
|
if (parent != null)
|
|
|
|
return parent.getFullName() + "." + name;
|
2015-10-22 00:02:58 +02:00
|
|
|
else
|
|
|
|
return name;
|
2015-01-03 16:34:32 +01:00
|
|
|
}
|
|
|
|
|
2021-01-09 12:43:02 +01:00
|
|
|
/**
|
|
|
|
* Gets the name.
|
|
|
|
*
|
|
|
|
* @return the name
|
|
|
|
*/
|
2015-01-03 16:34:32 +01:00
|
|
|
@Override
|
|
|
|
public String getName() {
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2021-01-09 12:43:02 +01:00
|
|
|
/**
|
|
|
|
* Sets the name.
|
|
|
|
*
|
|
|
|
* @param name the new name
|
|
|
|
*/
|
2015-01-03 16:34:32 +01:00
|
|
|
@Override
|
|
|
|
public void setName(String name) {
|
2021-01-09 12:43:02 +01:00
|
|
|
this.name = name;
|
2015-01-03 16:34:32 +01:00
|
|
|
}
|
|
|
|
|
2021-01-09 20:10:58 +01:00
|
|
|
/**
|
|
|
|
* Gets the parent.
|
|
|
|
*
|
|
|
|
* @return the parent
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public IHierNode getParent() {
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
2021-01-09 12:43:02 +01:00
|
|
|
/**
|
|
|
|
* Sets the parent.
|
|
|
|
*
|
|
|
|
* @param parent the new parent
|
|
|
|
*/
|
2015-10-22 00:02:58 +02:00
|
|
|
@Override
|
2020-11-28 19:41:00 +01:00
|
|
|
public void setParent(IHierNode parent) {
|
2021-01-09 12:43:02 +01:00
|
|
|
this.parent = parent;
|
2015-10-22 00:02:58 +02:00
|
|
|
}
|
|
|
|
|
2021-01-09 12:43:02 +01:00
|
|
|
/**
|
|
|
|
* Gets the child nodes.
|
|
|
|
*
|
|
|
|
* @return the child nodes
|
|
|
|
*/
|
2015-01-03 16:34:32 +01:00
|
|
|
@Override
|
2015-01-06 17:14:16 +01:00
|
|
|
public List<IHierNode> getChildNodes() {
|
2021-01-09 20:10:58 +01:00
|
|
|
return Collections.unmodifiableList(childNodes);
|
2015-01-03 16:34:32 +01:00
|
|
|
}
|
|
|
|
|
2021-01-09 12:43:02 +01:00
|
|
|
/**
|
|
|
|
* Adds the child.
|
|
|
|
*
|
|
|
|
* @param child the child
|
|
|
|
*/
|
2021-01-09 20:10:58 +01:00
|
|
|
@Override
|
2021-01-09 12:43:02 +01:00
|
|
|
public void addChild(IHierNode child) {
|
2021-01-09 20:10:58 +01:00
|
|
|
if (!childNodes.contains(child)) {
|
|
|
|
childNodes.add(child);
|
2021-01-09 12:43:02 +01:00
|
|
|
child.setParent(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compare to.
|
|
|
|
*
|
|
|
|
* @param o the o
|
|
|
|
* @return the int
|
|
|
|
*/
|
2015-01-10 00:23:46 +01:00
|
|
|
@Override
|
|
|
|
public int compareTo(IHierNode o) {
|
2020-11-28 19:41:00 +01:00
|
|
|
return getFullName().compareTo(o.getFullName());
|
2015-01-10 00:23:46 +01:00
|
|
|
}
|
|
|
|
|
2021-01-09 12:43:02 +01:00
|
|
|
/**
|
|
|
|
* Derive waveform.
|
|
|
|
*
|
|
|
|
* @return the i derived waveform
|
|
|
|
*/
|
2020-11-29 10:25:48 +01:00
|
|
|
@Override
|
|
|
|
public IDerivedWaveform deriveWaveform() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2015-01-03 16:34:32 +01:00
|
|
|
}
|