2015-01-21 21:58:35 +01:00
|
|
|
/*******************************************************************************
|
2015-10-22 00:25:12 +02:00
|
|
|
* Copyright (c) 2015 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;
|
|
|
|
import java.util.List;
|
|
|
|
|
2015-01-06 17:14:16 +01:00
|
|
|
public class HierNode implements IHierNode {
|
2015-01-03 16:34:32 +01:00
|
|
|
|
|
|
|
protected String name;
|
|
|
|
|
2020-11-28 19:41:00 +01:00
|
|
|
protected IHierNode parent = null;
|
2015-10-22 00:02:58 +02:00
|
|
|
|
2015-01-06 17:14:16 +01:00
|
|
|
protected ArrayList<IHierNode> childs;
|
2015-01-03 16:34:32 +01:00
|
|
|
|
2015-01-10 00:23:46 +01:00
|
|
|
protected PropertyChangeSupport pcs;
|
|
|
|
|
|
|
|
public HierNode() {
|
|
|
|
childs = new ArrayList<IHierNode>();
|
|
|
|
pcs=new PropertyChangeSupport(this);
|
|
|
|
}
|
|
|
|
|
2015-01-03 16:34:32 +01:00
|
|
|
public HierNode(String name) {
|
2020-11-28 19:41:00 +01:00
|
|
|
this();
|
|
|
|
this.name=name;
|
2015-10-22 00:02:58 +02:00
|
|
|
}
|
|
|
|
|
2020-11-28 19:41:00 +01:00
|
|
|
public HierNode(String name, IHierNode parent) {
|
2015-01-10 00:23:46 +01:00
|
|
|
this();
|
2015-01-03 16:34:32 +01:00
|
|
|
this.name=name;
|
2020-11-28 19:41:00 +01:00
|
|
|
this.parent=parent;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
@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
|
|
|
}
|
|
|
|
|
2015-01-10 00:23:46 +01:00
|
|
|
|
2015-01-03 16:34:32 +01:00
|
|
|
@Override
|
|
|
|
public String getFullName() {
|
2020-11-28 19:41:00 +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
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getName() {
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setName(String name) {
|
|
|
|
this.name=name;
|
|
|
|
}
|
|
|
|
|
2015-10-22 00:02:58 +02:00
|
|
|
@Override
|
2020-11-28 19:41:00 +01:00
|
|
|
public void setParent(IHierNode parent) {
|
|
|
|
this.parent=parent;
|
2015-10-22 00:02:58 +02:00
|
|
|
}
|
|
|
|
|
2015-01-03 16:34:32 +01:00
|
|
|
@Override
|
2015-01-06 17:14:16 +01:00
|
|
|
public List<IHierNode> getChildNodes() {
|
2015-01-03 16:34:32 +01:00
|
|
|
return childs;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-01-03 16:34:32 +01:00
|
|
|
}
|