136 lines
2.9 KiB
Java
136 lines
2.9 KiB
Java
package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.TwinColumnSelection;
|
|
|
|
import java.util.List;
|
|
|
|
import com.google.gwt.view.client.ProvidesKey;
|
|
|
|
|
|
/**
|
|
* A left-side element for the list in TwinColumnSelection
|
|
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
|
*/
|
|
public class ResourceElementBean implements Comparable<ResourceElementBean>{
|
|
|
|
private int identifier;
|
|
private String name;
|
|
private boolean movedToRight;
|
|
private boolean isFolder;
|
|
private ResourceElementBean parent;
|
|
private List<ResourceElementBean> children;
|
|
private String fullPath;
|
|
|
|
// to generate the identifiers
|
|
private static int nextId = 0;
|
|
|
|
/**
|
|
* The key provider that provides the unique ID of a bean.
|
|
*/
|
|
public static final ProvidesKey<ResourceElementBean> KEY_PROVIDER = new ProvidesKey<ResourceElementBean>() {
|
|
@Override
|
|
public Object getKey(ResourceElementBean item) {
|
|
return item == null ? null : item.getIdentifier();
|
|
}
|
|
};
|
|
|
|
/**
|
|
* @param identifier
|
|
* @param parentFolder
|
|
* @param name
|
|
* @param movedToRight
|
|
* @param isFolder
|
|
*/
|
|
public ResourceElementBean(
|
|
ResourceElementBean parent,
|
|
String name,
|
|
boolean isFolder,
|
|
List<ResourceElementBean> children,
|
|
String fullPath) {
|
|
this.identifier = nextId;
|
|
nextId++;
|
|
this.parent = parent;
|
|
this.name = name;
|
|
this.isFolder = isFolder;
|
|
this.children = children;
|
|
this.fullPath = fullPath;
|
|
}
|
|
|
|
public ResourceElementBean getParent() {
|
|
return parent;
|
|
}
|
|
|
|
public void setParent(ResourceElementBean parent) {
|
|
this.parent = parent;
|
|
}
|
|
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
public void setName(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
public boolean isMovedToRight() {
|
|
return movedToRight;
|
|
}
|
|
|
|
public void setMovedToRight(boolean movedToRight) {
|
|
this.movedToRight = movedToRight;
|
|
}
|
|
|
|
public int getIdentifier() {
|
|
return identifier;
|
|
}
|
|
|
|
public void setIdentifier(int identifier) {
|
|
this.identifier = identifier;
|
|
}
|
|
|
|
public boolean isFolder() {
|
|
return isFolder;
|
|
}
|
|
|
|
public void setFolder(boolean isFolder) {
|
|
this.isFolder = isFolder;
|
|
}
|
|
|
|
public List<ResourceElementBean> getChildren() {
|
|
return children;
|
|
}
|
|
|
|
public void setChildren(List<ResourceElementBean> children) {
|
|
this.children = children;
|
|
}
|
|
|
|
public String getFullPath() {
|
|
return fullPath;
|
|
}
|
|
|
|
public void setFullPath(String fullPath) {
|
|
this.fullPath = fullPath;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "ResourceElementBean [identifier=" + identifier + ", name="
|
|
+ name + ", movedToRight=" + movedToRight + ", isFolder="
|
|
+ isFolder + ", fullPath=" + fullPath + "]";
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object o) {
|
|
boolean toReturn = false;
|
|
if (o instanceof ResourceElementBean) {
|
|
toReturn = identifier == ((ResourceElementBean) o).identifier;
|
|
}
|
|
|
|
return toReturn;
|
|
}
|
|
|
|
@Override
|
|
public int compareTo(ResourceElementBean o) {
|
|
int toReturn = (o == null || o.fullPath == null) ? -1 : -o.fullPath.compareTo(fullPath);
|
|
return toReturn;
|
|
}
|
|
}
|