@@ -1,5 +1,5 @@ | |||
.v-theme-version:after {content:"6_3_0_dev-20100217";} | |||
.v-theme-version-6_3_0_dev-20100217 {display: none;} | |||
.v-theme-version:after {content:"6_3_0_dev-20100304";} | |||
.v-theme-version-6_3_0_dev-20100304 {display: none;} | |||
/* Automatically compiled css file from subdirectories. */ | |||
.v-absolutelayout-wrapper { | |||
@@ -1354,18 +1354,6 @@ div.v-progressindicator-indeterminate-disabled { | |||
cursor: pointer; | |||
} | |||
/* TODO remove important, replace with better anchors or order */ | |||
.v-table tr.v-table-row-drag-center { | |||
background-color: cyan !important; | |||
} | |||
/* TODO consider using height neutral styling (scrollbar issues when pagelength = table.length ) */ | |||
.v-table-row-drag-top .v-table-cell-content { | |||
border-top: 1px solid cyan ; | |||
} | |||
.v-table-row-drag-bottom .v-table-cell-content { | |||
border-bottom: 1px solid cyan; | |||
} | |||
.v-table-body-noselection .v-table-row, | |||
.v-table-body-noselection .v-table-row-odd { | |||
cursor: default; | |||
@@ -1432,6 +1420,19 @@ div.v-progressindicator-indeterminate-disabled { | |||
color: #ddd; | |||
} | |||
/* TODO remove important, replace with better anchors or order */ | |||
.v-table-row-drag-middle .v-table-cell-content { | |||
background-color: cyan; | |||
} | |||
/* TODO consider using height neutral styling (scrollbar issues when pagelength = table.length ) */ | |||
.v-table-row-drag-top .v-table-cell-content { | |||
border-top: 1px solid cyan ; | |||
} | |||
.v-table-row-drag-bottom .v-table-cell-content { | |||
border-bottom: 1px solid cyan; | |||
} | |||
.v-tabsheet, | |||
.v-tabsheet-content, | |||
.v-tabsheet-deco { |
@@ -87,18 +87,6 @@ | |||
cursor: pointer; | |||
} | |||
/* TODO remove important, replace with better anchors or order */ | |||
.v-table tr.v-table-row-drag-center { | |||
background-color: cyan !important; | |||
} | |||
/* TODO consider using height neutral styling (scrollbar issues when pagelength = table.length ) */ | |||
.v-table-row-drag-top .v-table-cell-content { | |||
border-top: 1px solid cyan ; | |||
} | |||
.v-table-row-drag-bottom .v-table-cell-content { | |||
border-bottom: 1px solid cyan; | |||
} | |||
.v-table-body-noselection .v-table-row, | |||
.v-table-body-noselection .v-table-row-odd { | |||
cursor: default; | |||
@@ -163,4 +151,17 @@ | |||
} | |||
.v-off { | |||
color: #ddd; | |||
} | |||
} | |||
/* TODO remove important, replace with better anchors or order */ | |||
.v-table-row-drag-middle .v-table-cell-content { | |||
background-color: cyan; | |||
} | |||
/* TODO consider using height neutral styling (scrollbar issues when pagelength = table.length ) */ | |||
.v-table-row-drag-top .v-table-cell-content { | |||
border-top: 1px solid cyan ; | |||
} | |||
.v-table-row-drag-bottom .v-table-cell-content { | |||
border-bottom: 1px solid cyan; | |||
} | |||
@@ -1,5 +1,5 @@ | |||
.v-theme-version:after {content:"6_3_0_dev-20100217";} | |||
.v-theme-version-6_3_0_dev-20100217 {display: none;} | |||
.v-theme-version:after {content:"6_3_0_dev-20100304";} | |||
.v-theme-version-6_3_0_dev-20100304 {display: none;} | |||
/* Automatically compiled css file from subdirectories. */ | |||
.v-absolutelayout-wrapper { | |||
@@ -1354,18 +1354,6 @@ div.v-progressindicator-indeterminate-disabled { | |||
cursor: pointer; | |||
} | |||
/* TODO remove important, replace with better anchors or order */ | |||
.v-table tr.v-table-row-drag-center { | |||
background-color: cyan !important; | |||
} | |||
/* TODO consider using height neutral styling (scrollbar issues when pagelength = table.length ) */ | |||
.v-table-row-drag-top .v-table-cell-content { | |||
border-top: 1px solid cyan ; | |||
} | |||
.v-table-row-drag-bottom .v-table-cell-content { | |||
border-bottom: 1px solid cyan; | |||
} | |||
.v-table-body-noselection .v-table-row, | |||
.v-table-body-noselection .v-table-row-odd { | |||
cursor: default; | |||
@@ -1432,6 +1420,19 @@ div.v-progressindicator-indeterminate-disabled { | |||
color: #ddd; | |||
} | |||
/* TODO remove important, replace with better anchors or order */ | |||
.v-table-row-drag-middle .v-table-cell-content { | |||
background-color: cyan; | |||
} | |||
/* TODO consider using height neutral styling (scrollbar issues when pagelength = table.length ) */ | |||
.v-table-row-drag-top .v-table-cell-content { | |||
border-top: 1px solid cyan ; | |||
} | |||
.v-table-row-drag-bottom .v-table-cell-content { | |||
border-bottom: 1px solid cyan; | |||
} | |||
.v-tabsheet, | |||
.v-tabsheet-content, | |||
.v-tabsheet-deco { |
@@ -1,5 +1,5 @@ | |||
.v-theme-version:after {content:"6_3_0_dev-20100217";} | |||
.v-theme-version-6_3_0_dev-20100217 {display: none;} | |||
.v-theme-version:after {content:"6_3_0_dev-20100304";} | |||
.v-theme-version-6_3_0_dev-20100304 {display: none;} | |||
/* Automatically compiled css file from subdirectories. */ | |||
.v-absolutelayout-wrapper { | |||
@@ -1354,18 +1354,6 @@ div.v-progressindicator-indeterminate-disabled { | |||
cursor: pointer; | |||
} | |||
/* TODO remove important, replace with better anchors or order */ | |||
.v-table tr.v-table-row-drag-center { | |||
background-color: cyan !important; | |||
} | |||
/* TODO consider using height neutral styling (scrollbar issues when pagelength = table.length ) */ | |||
.v-table-row-drag-top .v-table-cell-content { | |||
border-top: 1px solid cyan ; | |||
} | |||
.v-table-row-drag-bottom .v-table-cell-content { | |||
border-bottom: 1px solid cyan; | |||
} | |||
.v-table-body-noselection .v-table-row, | |||
.v-table-body-noselection .v-table-row-odd { | |||
cursor: default; | |||
@@ -1432,6 +1420,19 @@ div.v-progressindicator-indeterminate-disabled { | |||
color: #ddd; | |||
} | |||
/* TODO remove important, replace with better anchors or order */ | |||
.v-table-row-drag-middle .v-table-cell-content { | |||
background-color: cyan; | |||
} | |||
/* TODO consider using height neutral styling (scrollbar issues when pagelength = table.length ) */ | |||
.v-table-row-drag-top .v-table-cell-content { | |||
border-top: 1px solid cyan ; | |||
} | |||
.v-table-row-drag-bottom .v-table-cell-content { | |||
border-bottom: 1px solid cyan; | |||
} | |||
.v-tabsheet, | |||
.v-tabsheet-content, | |||
.v-tabsheet-deco { |
@@ -387,7 +387,7 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical, | |||
if (newParentId == null) { | |||
// Remove from old parents children list | |||
final LinkedList<Object> l = children.get(itemId); | |||
final LinkedList<Object> l = children.get(oldParentId); | |||
if (l != null) { | |||
l.remove(itemId); | |||
if (l.isEmpty()) { |
@@ -7,7 +7,7 @@ import com.vaadin.event.TransferableImpl; | |||
import com.vaadin.event.dd.DragAndDropEvent; | |||
import com.vaadin.terminal.PaintException; | |||
import com.vaadin.terminal.PaintTarget; | |||
import com.vaadin.terminal.gwt.client.ui.dd.VIsDragSource; | |||
import com.vaadin.terminal.gwt.client.ui.dd.VDragSourceIs; | |||
import com.vaadin.ui.Component; | |||
/** | |||
@@ -16,12 +16,12 @@ import com.vaadin.ui.Component; | |||
* | |||
* @since 6.3 | |||
*/ | |||
@ClientCriterion(VIsDragSource.class) | |||
public class IsDragSource extends ClientSideCriterion { | |||
@ClientCriterion(VDragSourceIs.class) | |||
public class DragSourceIs extends ClientSideCriterion { | |||
private Component[] component; | |||
public IsDragSource(Component... component) { | |||
public DragSourceIs(Component... component) { | |||
this.component = component; | |||
} | |||
@@ -1325,6 +1325,8 @@ public class ApplicationConnection { | |||
return 'd'; | |||
} else if (value instanceof Long) { | |||
return 'l'; | |||
} else if (value instanceof Enum) { | |||
return 's'; // transported as string representation | |||
} | |||
return 'u'; | |||
} |
@@ -2510,15 +2510,6 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, | |||
case Event.ONMOUSEDOWN: | |||
if (dragmode != 0) { | |||
mDown = true; | |||
event.preventDefault(); | |||
event.stopPropagation(); | |||
} | |||
break; | |||
case Event.ONMOUSEOUT: | |||
mDown = false; | |||
break; | |||
case Event.ONMOUSEMOVE: | |||
if (mDown && dragmode != 0) { | |||
VTransferable transferable = new VTransferable(); | |||
transferable.setDragSource(VScrollTable.this); | |||
transferable.setData("itemId", "" + rowKey); | |||
@@ -2527,12 +2518,13 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, | |||
VDragEvent ev = VDragAndDropManager.get() | |||
.startDrag(transferable, event, true); | |||
ev.createDragImage(getElement(), true); | |||
mDown = false; | |||
// prevent text selection | |||
event.preventDefault(); | |||
event.stopPropagation(); | |||
} | |||
break; | |||
case Event.ONMOUSEOUT: | |||
mDown = false; | |||
break; | |||
default: | |||
break; | |||
} |
@@ -67,10 +67,10 @@ public class VTree extends FlowPanel implements Paintable, VHasDropHandler { | |||
private boolean rendering; | |||
private int dragMode = 0; | |||
private VAbstractDropHandler dropHandler; | |||
private int dragMode; | |||
public VTree() { | |||
super(); | |||
setStyleName(CLASSNAME); | |||
@@ -123,6 +123,9 @@ public class VTree extends FlowPanel implements Paintable, VHasDropHandler { | |||
disabled = uidl.getBooleanAttribute("disabled"); | |||
readonly = uidl.getBooleanAttribute("readonly"); | |||
dragMode = uidl.hasAttribute("dragMode") ? uidl | |||
.getIntAttribute("dragMode") : 0; | |||
isNullSelectionAllowed = uidl.getBooleanAttribute("nullselect"); | |||
clear(); | |||
@@ -150,12 +153,6 @@ public class VTree extends FlowPanel implements Paintable, VHasDropHandler { | |||
selectedIds = uidl.getStringArrayVariableAsSet("selected"); | |||
if (uidl.hasAttribute("dragMode")) { | |||
dragMode = uidl.getIntAttribute("dragMode"); | |||
} else { | |||
dragMode = 0; | |||
} | |||
rendering = false; | |||
} | |||
@@ -164,16 +161,16 @@ public class VTree extends FlowPanel implements Paintable, VHasDropHandler { | |||
currentMouseOverKey = findCurrentMouseOverKey(drag.getElementOver()); | |||
drag.getDropDetails().put("itemIdOver", currentMouseOverKey); | |||
if (currentMouseOverKey != null) { | |||
String detail = getDropDetail(drag.getCurrentGwtEvent()); | |||
VerticalDropLocation detail = getDropDetail(drag | |||
.getCurrentGwtEvent()); | |||
Boolean overTreeNode = null; | |||
TreeNode treeNode = keyToNode.get(currentMouseOverKey); | |||
if (treeNode != null && !treeNode.isLeaf() | |||
&& "MIDDLE".equals(detail)) { | |||
&& detail == VerticalDropLocation.MIDDLE) { | |||
overTreeNode = true; | |||
} | |||
drag.getDropDetails().put("itemIdOver", currentMouseOverKey); | |||
drag.getDropDetails().put("itemIdOverIsNode", overTreeNode); | |||
drag.getDropDetails().put("detail", detail); | |||
@@ -202,16 +199,15 @@ public class VTree extends FlowPanel implements Paintable, VHasDropHandler { | |||
public void dragOver(final VDragEvent currentDrag) { | |||
final Object oldIdOver = currentDrag.getDropDetails().get( | |||
"itemIdOver"); | |||
final String oldDetail = (String) currentDrag | |||
final VerticalDropLocation oldDetail = (VerticalDropLocation) currentDrag | |||
.getDropDetails().get("detail"); | |||
updateTreeRelatedDragData(currentDrag); | |||
final String detail = getDropDetail(currentDrag | |||
final VerticalDropLocation detail = getDropDetail(currentDrag | |||
.getCurrentGwtEvent()); | |||
boolean nodeHasChanged = (currentMouseOverKey != null && currentMouseOverKey != oldIdOver) | |||
|| (currentMouseOverKey == null && oldIdOver != null); | |||
boolean detailHasChanded = (detail != null && !detail | |||
.equals(oldDetail)) | |||
boolean detailHasChanded = (detail != null && detail != oldDetail) | |||
|| (detail == null && oldDetail != null); | |||
if (nodeHasChanged || detailHasChanded) { | |||
@@ -219,13 +215,6 @@ public class VTree extends FlowPanel implements Paintable, VHasDropHandler { | |||
"Change in Transferable " + currentMouseOverKey | |||
+ " " + detail); | |||
final String newKey = currentMouseOverKey; | |||
validate(new VAcceptCallback() { | |||
public void accepted(VDragEvent event) { | |||
if (newKey != null) { | |||
keyToNode.get(newKey).emphasis(detail); | |||
} | |||
} | |||
}, currentDrag); | |||
if (oldIdOver != null | |||
&& oldIdOver != currentMouseOverKey) { | |||
TreeNode treeNode = keyToNode.get(oldIdOver); | |||
@@ -233,6 +222,13 @@ public class VTree extends FlowPanel implements Paintable, VHasDropHandler { | |||
treeNode.emphasis(null); | |||
} | |||
} | |||
validate(new VAcceptCallback() { | |||
public void accepted(VDragEvent event) { | |||
if (newKey != null) { | |||
keyToNode.get(newKey).emphasis(detail); | |||
} | |||
} | |||
}, currentDrag); | |||
} | |||
} | |||
@@ -269,14 +265,14 @@ public class VTree extends FlowPanel implements Paintable, VHasDropHandler { | |||
dropHandler.updateAcceptRules(childUidl); | |||
} | |||
public String getDropDetail(NativeEvent event) { | |||
public VerticalDropLocation getDropDetail(NativeEvent event) { | |||
TreeNode treeNode = keyToNode.get(currentMouseOverKey); | |||
if (treeNode == null) { | |||
return null; | |||
} | |||
VerticalDropLocation verticalDropLocation = VerticalDropLocation.get( | |||
treeNode.nodeCaptionDiv, event.getClientY(), 0.2); | |||
return verticalDropLocation.toString(); | |||
return verticalDropLocation; | |||
} | |||
private void handleUpdate(UIDL uidl) { | |||
@@ -325,11 +321,11 @@ public class VTree extends FlowPanel implements Paintable, VHasDropHandler { | |||
return selectedIds.contains(treeNode.key); | |||
} | |||
protected class TreeNode extends SimplePanel implements ActionOwner { | |||
public class TreeNode extends SimplePanel implements ActionOwner { | |||
public static final String CLASSNAME = "v-tree-node"; | |||
String key; | |||
public String key; | |||
private String[] actionKeys = null; | |||
@@ -355,21 +351,66 @@ public class VTree extends FlowPanel implements Paintable, VHasDropHandler { | |||
| Event.ONCONTEXTMENU); | |||
} | |||
public void emphasis(String string) { | |||
protected void emphasis(VerticalDropLocation detail) { | |||
String base = "v-tree-node-drag-"; | |||
UIObject.setStyleName(getElement(), base + "top", "TOP" | |||
.equals(string)); | |||
UIObject.setStyleName(getElement(), base + "bottom", "BOTTOM" | |||
.equals(string)); | |||
UIObject.setStyleName(getElement(), base + "center", "MIDDLE" | |||
.equals(string)); | |||
UIObject.setStyleName(getElement(), base + "top", | |||
VerticalDropLocation.TOP == detail); | |||
UIObject.setStyleName(getElement(), base + "bottom", | |||
VerticalDropLocation.BOTTOM == detail); | |||
UIObject.setStyleName(getElement(), base + "center", | |||
VerticalDropLocation.MIDDLE == detail); | |||
base = "v-tree-node-caption-drag-"; | |||
UIObject.setStyleName(nodeCaptionDiv, base + "top", "TOP" | |||
.equals(string)); | |||
UIObject.setStyleName(nodeCaptionDiv, base + "bottom", "BOTTOM" | |||
.equals(string)); | |||
UIObject.setStyleName(nodeCaptionDiv, base + "center", "MIDDLE" | |||
.equals(string)); | |||
UIObject.setStyleName(nodeCaptionDiv, base + "top", | |||
VerticalDropLocation.TOP == detail); | |||
UIObject.setStyleName(nodeCaptionDiv, base + "bottom", | |||
VerticalDropLocation.BOTTOM == detail); | |||
UIObject.setStyleName(nodeCaptionDiv, base + "center", | |||
VerticalDropLocation.MIDDLE == detail); | |||
// also add classname to "folder node" into which the drag is | |||
// targeted | |||
TreeNode folder = null; | |||
/* Possible parent of this TreeNode will be stored here */ | |||
TreeNode parentFolder = getParentNode(); | |||
// TODO fix my bugs | |||
if (isLeaf()) { | |||
folder = parentFolder; | |||
// note, parent folder may be null if this is root node => no | |||
// folder target exists | |||
} else { | |||
if (detail == VerticalDropLocation.TOP) { | |||
folder = parentFolder; | |||
} else { | |||
folder = this; | |||
} | |||
// ensure we remove the dragfolder classname from the previous | |||
// folder node | |||
setDragFolderStyleName(this, false); | |||
setDragFolderStyleName(parentFolder, false); | |||
} | |||
if (folder != null) { | |||
setDragFolderStyleName(folder, detail != null); | |||
} | |||
} | |||
private TreeNode getParentNode() { | |||
Widget parent2 = getParent().getParent(); | |||
if (parent2 instanceof TreeNode) { | |||
return (TreeNode) parent2; | |||
} | |||
return null; | |||
} | |||
private void setDragFolderStyleName(TreeNode folder, boolean add) { | |||
if (folder != null) { | |||
UIObject.setStyleName(folder.getElement(), | |||
"v-tree-node-dragfolder", add); | |||
UIObject.setStyleName(folder.nodeCaptionDiv, | |||
"v-tree-node-caption-dragfolder", add); | |||
} | |||
} | |||
@Override | |||
@@ -401,10 +442,13 @@ public class VTree extends FlowPanel implements Paintable, VHasDropHandler { | |||
if (dragMode != 0 || dropHandler != null) { | |||
if (type == Event.ONMOUSEDOWN) { | |||
if (nodeCaptionDiv.isOrHasChild(event.getTarget())) { | |||
ApplicationConnection.getConsole().log( | |||
"TreeNode m down"); | |||
event.preventDefault(); // prevent text selection | |||
mouseDownEvent = event; | |||
if (dragMode > 0) { | |||
ApplicationConnection.getConsole().log( | |||
"TreeNode m down"); | |||
event.preventDefault(); // prevent text selection | |||
mouseDownEvent = event; | |||
} | |||
} | |||
} else if (type == Event.ONMOUSEMOVE | |||
|| type == Event.ONMOUSEOUT) { | |||
@@ -691,4 +735,8 @@ public class VTree extends FlowPanel implements Paintable, VHasDropHandler { | |||
public VDropHandler getDropHandler() { | |||
return dropHandler; | |||
} | |||
public TreeNode getNodeByKey(String key) { | |||
return keyToNode.get(key); | |||
} | |||
} |
@@ -634,6 +634,9 @@ public class VDragAndDropManager { | |||
* <p> | |||
* Using this method may be handy if criterion that uses lazy initialization | |||
* are used. Check | |||
* <p> | |||
* TODO Optimization: consider if we actually only need to keep the last | |||
* command in queue here. | |||
* | |||
* @param command | |||
*/ |
@@ -8,7 +8,7 @@ import com.vaadin.terminal.gwt.client.UIDL; | |||
* | |||
* @since 6.3 | |||
*/ | |||
final public class VIsDragSource extends VAcceptCriterion { | |||
final public class VDragSourceIs extends VAcceptCriterion { | |||
@Override | |||
public boolean validates(VDragEvent drag, UIDL configuration) { |
@@ -9,9 +9,7 @@ import com.vaadin.terminal.gwt.client.UIDL; | |||
/** | |||
* | |||
* @deprecated example class testing custom behavior | |||
*/ | |||
@Deprecated | |||
final public class VLazyInitItemIdentifiers extends VAcceptCriterion { | |||
private boolean loaded = false; | |||
private HashSet<String> hashSet; |
@@ -0,0 +1,37 @@ | |||
/** | |||
* | |||
*/ | |||
package com.vaadin.terminal.gwt.client.ui.dd; | |||
import com.google.gwt.user.client.ui.Widget; | |||
import com.vaadin.terminal.gwt.client.UIDL; | |||
import com.vaadin.terminal.gwt.client.ui.VTree; | |||
import com.vaadin.terminal.gwt.client.ui.VTree.TreeNode; | |||
final public class VTargetNodeIsChildOf extends VAcceptCriterion { | |||
@Override | |||
public boolean validates(VDragEvent drag, UIDL configuration) { | |||
VTree tree = (VTree) VDragAndDropManager.get().getCurrentDropHandler() | |||
.getPaintable(); | |||
TreeNode treeNode = tree.getNodeByKey((String) drag.getDropDetails() | |||
.get("itemIdOver")); | |||
if (treeNode != null) { | |||
Widget parent2 = treeNode.getParent().getParent(); | |||
int depth = configuration.getIntAttribute("depth"); | |||
if (depth < 0) { | |||
depth = Integer.MAX_VALUE; | |||
} | |||
for (int i = 0; i < depth && parent2 instanceof TreeNode; i++) { | |||
if (configuration.getStringAttribute("key").equals( | |||
((TreeNode) parent2).key)) { | |||
return true; | |||
} | |||
parent2 = parent2.getParent().getParent(); | |||
} | |||
} | |||
return false; | |||
} | |||
} |
@@ -102,6 +102,8 @@ public class AcceptCriterionGenerator extends Generator { | |||
.getCriterion(); | |||
for (Class<? extends AcceptCriterion> class1 : clientSideVerifiableCriterion) { | |||
logger.log(Type.INFO, "creating mapping for " | |||
+ class1.getCanonicalName()); | |||
String canonicalName = class1.getCanonicalName(); | |||
Class<? extends VAcceptCriterion> clientClass = class1 | |||
.getAnnotation(ClientCriterion.class).value(); |
@@ -30,7 +30,7 @@ import com.vaadin.terminal.PaintTarget; | |||
import com.vaadin.terminal.Resource; | |||
import com.vaadin.terminal.gwt.client.ui.dd.VIsOverId; | |||
import com.vaadin.terminal.gwt.client.ui.dd.VItemIdIs; | |||
import com.vaadin.ui.Tree.Location; | |||
import com.vaadin.terminal.gwt.client.ui.dd.VerticalDropLocation; | |||
/** | |||
* <p> | |||
@@ -1775,7 +1775,10 @@ public abstract class AbstractSelect extends AbstractField implements | |||
*/ | |||
public class AbstractSelectDropTargetDetails extends DropTargetDetailsImpl { | |||
private Object idOver; | |||
/** | |||
* The treenode id over which the drag event happened. | |||
*/ | |||
protected Object idOver; | |||
/** | |||
* TODO Javadoc! | |||
@@ -1791,7 +1794,8 @@ public abstract class AbstractSelect extends AbstractField implements | |||
} | |||
/** | |||
* TODO Javadoc! | |||
* If the drag operation is currently over an Item, this method returns | |||
* the identifier of the Item. | |||
* | |||
*/ | |||
public Object getItemIdOver() { | |||
@@ -1801,17 +1805,11 @@ public abstract class AbstractSelect extends AbstractField implements | |||
/** | |||
* TODO Javadoc! | |||
* | |||
* @since 6.3 | |||
*/ | |||
public Location getDropLocation() { | |||
String s = (String) getData("detail"); | |||
if ("TOP".equals(s)) { | |||
return Location.TOP; | |||
} else if ("BOTTOM".equals(s)) { | |||
return Location.BOTTOM; | |||
} else { | |||
return Location.MIDDLE; | |||
} | |||
public VerticalDropLocation getDropLocation() { | |||
VerticalDropLocation valueOf = VerticalDropLocation | |||
.valueOf((String) getData("detail")); | |||
return valueOf; | |||
} | |||
} |
@@ -2,7 +2,6 @@ package com.vaadin.ui; | |||
import java.util.Map; | |||
import com.vaadin.event.TransferableImpl; | |||
import com.vaadin.event.DataBoundTransferable; | |||
import com.vaadin.event.Transferable; | |||
import com.vaadin.event.dd.DragAndDropEvent; | |||
@@ -77,10 +76,10 @@ public class DragDropPane extends AbsoluteLayout implements DropTarget { | |||
DragDropPane pane = (DragDropPane) event.getDropTargetDetails() | |||
.getTarget(); | |||
DragEventDetails ed = (DragEventDetails) event.getDropTargetDetails(); | |||
Transferable transferable = event.getTransferable(); | |||
if (transferable instanceof TransferableImpl) { | |||
TransferableImpl ctr = (TransferableImpl) transferable; | |||
DragEventDetails ed = (DragEventDetails) event | |||
.getDropTargetDetails(); | |||
Transferable ctr = event.getTransferable(); | |||
if (ctr.getSourceComponent() != null) { | |||
// use "component" (from DragDropPane) if available, else take | |||
// the source component | |||
Component component = (Component) ctr.getData("component"); | |||
@@ -89,14 +88,13 @@ public class DragDropPane extends AbsoluteLayout implements DropTarget { | |||
} | |||
if (component.getParent() != pane) { | |||
if (transferable instanceof DataBoundTransferable) { | |||
if (ctr instanceof DataBoundTransferable) { | |||
// Item has been dragged, construct a Label from | |||
// Item id | |||
Label l = new Label(); | |||
l.setSizeUndefined(); | |||
l.setValue("ItemId : " | |||
+ ((DataBoundTransferable) transferable) | |||
.getItemId()); | |||
+ ((DataBoundTransferable) ctr).getItemId()); | |||
pane.addComponent(l); | |||
component = l; | |||
@@ -140,9 +138,9 @@ public class DragDropPane extends AbsoluteLayout implements DropTarget { | |||
} else { | |||
// drag coming outside of Vaadin | |||
String object = (String) transferable.getData("text/plain"); | |||
String object = (String) ctr.getData("text/plain"); | |||
String content = (String) transferable.getData("fileContents"); | |||
String content = (String) ctr.getData("fileContents"); | |||
Label l = new Label(); | |||
l.setCaption("Generated from HTML5 drag:"); |
@@ -43,6 +43,8 @@ import com.vaadin.terminal.gwt.client.MouseEventDetails; | |||
import com.vaadin.terminal.gwt.client.ui.VTree; | |||
import com.vaadin.terminal.gwt.client.ui.dd.VLazyInitItemIdentifiers; | |||
import com.vaadin.terminal.gwt.client.ui.dd.VOverTreeNode; | |||
import com.vaadin.terminal.gwt.client.ui.dd.VTargetNodeIsChildOf; | |||
import com.vaadin.terminal.gwt.client.ui.dd.VerticalDropLocation; | |||
/** | |||
* Tree component. A Tree can be used to select an item (or multiple items) from | |||
@@ -113,16 +115,16 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, | |||
*/ | |||
private boolean initialPaint = true; | |||
private DragMode dragMode = DragMode.NONE; | |||
/** | |||
* Supported drag modes for Tree. | |||
*/ | |||
public enum DragMode { | |||
NONE, NODES; | |||
public enum TreeDragMode { | |||
NONE, NODE | |||
// , SUBTREE | |||
} | |||
private TreeDragMode dragMode = TreeDragMode.NONE; | |||
/* Tree constructors */ | |||
/** | |||
@@ -456,7 +458,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, | |||
target.addAttribute("nullselect", true); | |||
} | |||
if (dragMode != DragMode.NONE) { | |||
if (dragMode != TreeDragMode.NONE) { | |||
target.addAttribute("dragMode", dragMode.ordinal()); | |||
} | |||
@@ -1115,10 +1117,6 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, | |||
this.dropHandler = dropHandler; | |||
} | |||
public enum Location { | |||
TOP, BOTTOM, MIDDLE; | |||
} | |||
/** | |||
* TODO Javadoc! | |||
* | |||
@@ -1135,6 +1133,34 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, | |||
return (Tree) super.getTarget(); | |||
} | |||
/** | |||
* If the event is on a node that can not have children (see | |||
* {@link Tree#areChildrenAllowed(Object)}), this method returns the | |||
* parent item id of the target item (see {@link #getItemIdOver()} ). | |||
* The identifier of the parent node is also returned if the cursor is | |||
* on the top part of node. Else this method returns the same as | |||
* {@link #getItemIdOver()}. | |||
* <p> | |||
* In other words this method returns the identifier of the "folder" | |||
* into the drag operation is targeted. | |||
* <p> | |||
* If the method returns null, the current target is on a root node or | |||
* on other undefined area over the tree component. | |||
* <p> | |||
* The default Tree implementation marks the targetted tree node with | |||
* CSS classnames v-tree-node-dragfolder and | |||
* v-tree-node-caption-dragfolder (for the caption element). | |||
*/ | |||
public Object getItemIdInto() { | |||
Object itemIdOver = getItemIdOver(); | |||
if (areChildrenAllowed(itemIdOver) | |||
&& getDropLocation() != VerticalDropLocation.TOP) { | |||
return itemIdOver; | |||
} | |||
return getParent(itemIdOver); | |||
} | |||
} | |||
/** | |||
@@ -1157,6 +1183,14 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, | |||
return itemIdMapper.key(itemId); | |||
} | |||
public void setDragMode(TreeDragMode dragMode) { | |||
this.dragMode = dragMode; | |||
} | |||
public TreeDragMode getDragMode() { | |||
return dragMode; | |||
} | |||
/** | |||
* TODO Javadoc! | |||
* | |||
@@ -1269,17 +1303,20 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, | |||
* Accepts transferable only on tree Node (middle of the node + can has | |||
* child) | |||
* | |||
* TODO replace by composition of itemIdIs + drop property | |||
* | |||
* @since 6.3 | |||
*/ | |||
@ClientCriterion(VOverTreeNode.class) | |||
public static class OverTreeNode extends ClientSideCriterion { | |||
public static class OverFolderNode extends ClientSideCriterion { | |||
private static final long serialVersionUID = 1L; | |||
public boolean accepts(DragAndDropEvent dragEvent) { | |||
try { | |||
// must be over tree node and in the middle of it (not top or | |||
// bottom part) | |||
// bottom | |||
// part) | |||
TreeDropTargetDetails eventDetails = (TreeDropTargetDetails) dragEvent | |||
.getDropTargetDetails(); | |||
@@ -1287,12 +1324,76 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, | |||
if (!eventDetails.getTarget().areChildrenAllowed(itemIdOver)) { | |||
return false; | |||
} | |||
// return true if directly over | |||
return eventDetails.getDropLocation() == VerticalDropLocation.MIDDLE; | |||
} catch (Exception e) { | |||
return false; | |||
} | |||
} | |||
} | |||
/** | |||
* Checks to parent (or parent hierarchy) for the item identifier given in | |||
* constructor. If the parent is found, content is accepted. | |||
*/ | |||
@ClientCriterion(VTargetNodeIsChildOf.class) | |||
public class TargetNodeIsChildOf extends ClientSideCriterion { | |||
private Object parentItemId; | |||
private int depthToCheck = 1; | |||
return eventDetails.getDropLocation() == Location.MIDDLE; | |||
/** | |||
* | |||
* @param parentItemId | |||
*/ | |||
public TargetNodeIsChildOf(Object parentItemId) { | |||
this.parentItemId = parentItemId; | |||
} | |||
/** | |||
* | |||
* @param parentItemId | |||
* @param depthToCheck | |||
* the depth that tree is traversed upwards to seek for the | |||
* parent, -1 means that the whole structure should be | |||
* checked | |||
*/ | |||
public TargetNodeIsChildOf(Object parentItemId, int depthToCheck) { | |||
this.parentItemId = parentItemId; | |||
this.depthToCheck = depthToCheck; | |||
} | |||
private static final long serialVersionUID = 1L; | |||
public boolean accepts(DragAndDropEvent dragEvent) { | |||
try { | |||
TreeDropTargetDetails eventDetails = (TreeDropTargetDetails) dragEvent | |||
.getDropTargetDetails(); | |||
if (eventDetails.getItemIdOver() != null) { | |||
Object itemIdOver = eventDetails.getItemIdOver(); | |||
Object parent2 = getParent(itemIdOver); | |||
int i = 0; | |||
while (parent2 != null && i < depthToCheck) { | |||
if (parent2.equals(parentItemId)) { | |||
return true; | |||
} | |||
i++; | |||
} | |||
} | |||
return false; | |||
} catch (Exception e) { | |||
return false; | |||
} | |||
} | |||
@Override | |||
public void paintContent(PaintTarget target) throws PaintException { | |||
super.paintContent(target); | |||
target.addAttribute("depth", depthToCheck); | |||
target.addAttribute("key", key(parentItemId)); | |||
} | |||
} | |||
} |
@@ -4,7 +4,6 @@ import java.util.Collection; | |||
import com.vaadin.data.Item; | |||
import com.vaadin.data.util.HierarchicalContainer; | |||
import com.vaadin.event.TransferableImpl; | |||
import com.vaadin.event.DataBoundTransferable; | |||
import com.vaadin.event.Transferable; | |||
import com.vaadin.event.dd.DragAndDropEvent; | |||
@@ -13,6 +12,7 @@ import com.vaadin.event.dd.acceptCriteria.AcceptCriterion; | |||
import com.vaadin.event.dd.acceptCriteria.IsDataBound; | |||
import com.vaadin.event.dd.acceptCriteria.ServerSideCriterion; | |||
import com.vaadin.terminal.ExternalResource; | |||
import com.vaadin.terminal.gwt.client.ui.dd.VerticalDropLocation; | |||
import com.vaadin.tests.components.TestBase; | |||
import com.vaadin.ui.Component; | |||
import com.vaadin.ui.DragDropPane; | |||
@@ -22,9 +22,9 @@ import com.vaadin.ui.Layout; | |||
import com.vaadin.ui.Link; | |||
import com.vaadin.ui.Table; | |||
import com.vaadin.ui.Tree; | |||
import com.vaadin.ui.AbstractSelect.AbstractSelectDropTargetDetails; | |||
import com.vaadin.ui.Table.DragModes; | |||
import com.vaadin.ui.Tree.Location; | |||
import com.vaadin.ui.Tree.TreeDragMode; | |||
import com.vaadin.ui.Tree.TreeDropTargetDetails; | |||
/** | |||
* DD playground. Better quality example/prototype codes in {@link DDTest2}. | |||
@@ -64,22 +64,23 @@ public class DDTest1 extends TestBase { | |||
Transferable transferable = dragEvent.getTransferable(); | |||
// System.out.println("Simulating 500ms processing..."); | |||
// try { | |||
// Thread.sleep(9000); | |||
// Thread.sleep(200); | |||
// } catch (InterruptedException e) { | |||
// // TODO Auto-generated catch block | |||
// e.printStackTrace(); | |||
// } | |||
// System.out.println("Done get to work."); | |||
if (transferable instanceof TransferableImpl) { | |||
TransferableImpl ct = (TransferableImpl) transferable; | |||
Component component = (Component) ct | |||
.getData("component"); | |||
if (component != null) { | |||
if (component.toString() != null | |||
&& component.toString().contains("Bar")) { | |||
return true; | |||
} | |||
Component component = (Component) transferable | |||
.getData("component"); | |||
if (component == null) { | |||
component = transferable.getSourceComponent(); | |||
} | |||
if (component != null) { | |||
if (component.toString() != null | |||
&& component.toString().contains("Bar")) { | |||
return true; | |||
} | |||
} | |||
return false; | |||
@@ -116,6 +117,7 @@ public class DDTest1 extends TestBase { | |||
t.addItem("Child"); | |||
t.setParent("Child", "Foo"); | |||
t.setSizeFull(); | |||
t.setDragMode(TreeDragMode.NODE); | |||
/* | |||
* Moves items in tree (and could work in Table too). Also supports | |||
@@ -187,7 +189,7 @@ public class DDTest1 extends TestBase { | |||
} | |||
public void drop(DragAndDropEvent event) { | |||
AbstractSelectDropTargetDetails details = (AbstractSelectDropTargetDetails) event | |||
TreeDropTargetDetails details = (TreeDropTargetDetails) event | |||
.getDropTargetDetails(); | |||
// TODO set properties, so same sorter could be used in Table | |||
Transferable transferable = event.getTransferable(); | |||
@@ -198,12 +200,16 @@ public class DDTest1 extends TestBase { | |||
Object itemIdOver = details.getItemIdOver(); | |||
Location dropLocation = details.getDropLocation(); | |||
// TODO could use the "folder" node id to make the drop | |||
// logic simpler | |||
Object itemIdInto = details.getItemIdInto(); | |||
VerticalDropLocation dropLocation = details | |||
.getDropLocation(); | |||
if (dropLocation == Location.MIDDLE) { | |||
if (dropLocation == VerticalDropLocation.MIDDLE) { | |||
t.setParent(itemId, itemIdOver); | |||
return; | |||
} else if (Location.TOP == dropLocation) { | |||
} else if (VerticalDropLocation.TOP == dropLocation) { | |||
// if on top of the caption area, add before | |||
itemIdOver = idx.prevItemId(itemIdOver); | |||
} |
@@ -13,7 +13,7 @@ import com.vaadin.event.dd.DragAndDropEvent; | |||
import com.vaadin.event.dd.DropHandler; | |||
import com.vaadin.event.dd.acceptCriteria.AcceptCriterion; | |||
import com.vaadin.event.dd.acceptCriteria.And; | |||
import com.vaadin.event.dd.acceptCriteria.IsDragSource; | |||
import com.vaadin.event.dd.acceptCriteria.DragSourceIs; | |||
import com.vaadin.event.dd.acceptCriteria.IsDataBound; | |||
import com.vaadin.event.dd.acceptCriteria.Or; | |||
import com.vaadin.event.dd.acceptCriteria.ServerSideCriterion; | |||
@@ -26,7 +26,8 @@ import com.vaadin.ui.Table; | |||
import com.vaadin.ui.Tree; | |||
import com.vaadin.ui.Window; | |||
import com.vaadin.ui.AbstractSelect.AbstractSelectDropTargetDetails; | |||
import com.vaadin.ui.Tree.OverTreeNode; | |||
import com.vaadin.ui.Tree.OverFolderNode; | |||
import com.vaadin.ui.Tree.TreeDragMode; | |||
import com.vaadin.ui.Tree.TreeDropTargetDetails; | |||
public class DDTest2 extends TestBase { | |||
@@ -45,6 +46,10 @@ public class DDTest2 extends TestBase { | |||
Window w = getLayout().getWindow(); | |||
/* darn reindeer has no icons */ | |||
/* Make all trees (their nodes actually) draggable */ | |||
tree1.setDragMode(TreeDragMode.NODE); | |||
tree2.setDragMode(TreeDragMode.NODE); | |||
hl.addComponent(tree1); | |||
hl.addComponent(table); | |||
hl.addComponent(tree2); | |||
@@ -59,6 +64,7 @@ public class DDTest2 extends TestBase { | |||
tree3 = new Tree( | |||
"Tree with lazy loading criteria, of first server visit caches accept rules for all captions"); | |||
tree3.setDragMode(TreeDragMode.NODE); | |||
tree3.addItem("Drag on me"); | |||
tree3.addItem("Or me"); | |||
@@ -112,11 +118,15 @@ public class DDTest2 extends TestBase { | |||
*/ | |||
table.setDragMode(Table.DragModes.ROWS); | |||
OverTreeNode onNode = new OverTreeNode(); | |||
IsDragSource fromTable = new IsDragSource(table); | |||
OverFolderNode onNode = new OverFolderNode(); | |||
DragSourceIs fromTable = new DragSourceIs(table); | |||
IsDragSource fromTree = new IsDragSource(tree1); | |||
DragSourceIs fromTree = new DragSourceIs(tree1); | |||
final Or fromTree1OrTable = new Or(fromTable, fromTree); | |||
// Or could in the case be replaced with, keeping here as an example and | |||
// test | |||
DragSourceIs treeOrTable = new DragSourceIs(table, tree1); | |||
final And and = new And(fromTree1OrTable, onNode); | |||
DropHandler dropHandler = new DropHandler() { |
@@ -8,15 +8,15 @@ import com.vaadin.event.DataBoundTransferable; | |||
import com.vaadin.event.dd.DragAndDropEvent; | |||
import com.vaadin.event.dd.DropHandler; | |||
import com.vaadin.event.dd.acceptCriteria.AcceptCriterion; | |||
import com.vaadin.event.dd.acceptCriteria.IsDragSource; | |||
import com.vaadin.event.dd.acceptCriteria.DragSourceIs; | |||
import com.vaadin.terminal.ThemeResource; | |||
import com.vaadin.terminal.gwt.client.ui.dd.VerticalDropLocation; | |||
import com.vaadin.tests.components.TestBase; | |||
import com.vaadin.tests.util.TestUtils; | |||
import com.vaadin.ui.HorizontalLayout; | |||
import com.vaadin.ui.Table; | |||
import com.vaadin.ui.Tree; | |||
import com.vaadin.ui.Window; | |||
import com.vaadin.ui.AbstractSelect.AbstractSelectDropTargetDetails; | |||
import com.vaadin.ui.Tree.Location; | |||
public class DDTest4 extends TestBase { | |||
@@ -25,11 +25,16 @@ public class DDTest4 extends TestBase { | |||
HorizontalLayout hl = new HorizontalLayout(); | |||
Table table = new Table("Drag and drop sortable table"); | |||
private Tree tree3; | |||
@Override | |||
protected void setup() { | |||
Window w = getLayout().getWindow(); | |||
TestUtils | |||
.injectCSS( | |||
w, | |||
".v-table-row-drag-middle .v-table-cell-content {" | |||
+ " background-color: inherit ; border-bottom: 1px solid cyan;" | |||
+ "}"); | |||
/* darn reindeer has no icons */ | |||
// hl.addComponent(tree1); | |||
@@ -40,6 +45,8 @@ public class DDTest4 extends TestBase { | |||
hl.setExpandRatio(table, 1); | |||
table.setWidth("100%"); | |||
table.setPageLength(10); | |||
table.setRowHeaderMode(Table.ROW_HEADER_MODE_ID); | |||
table.setSelectable(true); | |||
populateTable(); | |||
addComponent(hl); | |||
@@ -50,7 +57,7 @@ public class DDTest4 extends TestBase { | |||
table.setDropHandler(new DropHandler() { | |||
// accept only drags from this table | |||
AcceptCriterion crit = new IsDragSource(table); | |||
AcceptCriterion crit = new DragSourceIs(table); | |||
public AcceptCriterion getAcceptCriterion() { | |||
return crit; | |||
@@ -74,10 +81,13 @@ public class DDTest4 extends TestBase { | |||
IndexedContainer clone = null; | |||
try { | |||
clone = (IndexedContainer) containerDataSource.clone(); | |||
int newIndex = containerDataSource.indexOfId(itemIdOver); | |||
if (dropTargetData.getDropLocation() != Location.TOP) { | |||
int newIndex = containerDataSource.indexOfId(itemIdOver) - 1; | |||
if (dropTargetData.getDropLocation() != VerticalDropLocation.TOP) { | |||
newIndex++; | |||
} | |||
if (newIndex < 0) { | |||
newIndex = 0; | |||
} | |||
containerDataSource.removeItem(itemId); | |||
Item newItem = containerDataSource.addItemAt(newIndex, | |||
itemId); |
@@ -15,8 +15,8 @@ import com.vaadin.ui.DragAndDropWrapper; | |||
import com.vaadin.ui.HorizontalLayout; | |||
import com.vaadin.ui.Label; | |||
import com.vaadin.ui.Window; | |||
import com.vaadin.ui.DragAndDropWrapper.WrapperTransferable; | |||
import com.vaadin.ui.DragAndDropWrapper.DragStartMode; | |||
import com.vaadin.ui.DragAndDropWrapper.WrapperTransferable; | |||
public class DDTest5 extends TestBase { | |||
@@ -0,0 +1,143 @@ | |||
package com.vaadin.tests.dd; | |||
import com.vaadin.data.util.BeanItemContainer; | |||
import com.vaadin.event.DataBoundTransferable; | |||
import com.vaadin.event.dd.DragAndDropEvent; | |||
import com.vaadin.event.dd.DropHandler; | |||
import com.vaadin.event.dd.acceptCriteria.AcceptAll; | |||
import com.vaadin.event.dd.acceptCriteria.AcceptCriterion; | |||
import com.vaadin.terminal.Resource; | |||
import com.vaadin.terminal.ThemeResource; | |||
import com.vaadin.tests.components.TestBase; | |||
import com.vaadin.tests.util.TestUtils; | |||
import com.vaadin.ui.CssLayout; | |||
import com.vaadin.ui.SplitPanel; | |||
import com.vaadin.ui.Tree; | |||
import com.vaadin.ui.Tree.TreeDragMode; | |||
import com.vaadin.ui.Tree.TreeDropTargetDetails; | |||
public class DDTest6 extends TestBase { | |||
java.util.Random r = new java.util.Random(1); | |||
File[] files = new File[] { new Folder("Docs"), new Folder("Music"), | |||
new Folder("Images"), new File("document.doc"), | |||
new File("song.mp3"), new File("photo.jpg") }; | |||
private DropHandler dh; | |||
private static int count; | |||
@Override | |||
protected void setup() { | |||
SplitPanel sp = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL); | |||
CssLayout l = new CssLayout(); | |||
sp.setFirstComponent(l); | |||
CssLayout l2 = new CssLayout(); | |||
sp.setSecondComponent(l2); | |||
final Tree tree1 = new Tree("Volume 1"); | |||
BeanItemContainer<File> fs1 = new BeanItemContainer<File>(File.class); | |||
tree1.setContainerDataSource(fs1); | |||
for (int i = 0; i < files.length; i++) { | |||
fs1.addBean(files[i]); | |||
if (files[i] instanceof Folder) { | |||
tree1.setChildrenAllowed(files[i], true); | |||
} else { | |||
tree1.setChildrenAllowed(files[i], false); | |||
} | |||
if (i >= files.length / 2) { | |||
tree1.setParent(files[i], files[i - files.length / 2]); | |||
} | |||
} | |||
tree1.setItemCaptionPropertyId("name"); | |||
tree1.setItemIconPropertyId("icon"); | |||
tree1.setDragMode(TreeDragMode.NODE); | |||
DropHandler dropHandler = new DropHandler() { | |||
public AcceptCriterion getAcceptCriterion() { | |||
return AcceptAll.get(); | |||
} | |||
public void drop(DragAndDropEvent dropEvent) { | |||
DataBoundTransferable transferable = (DataBoundTransferable) dropEvent | |||
.getTransferable(); | |||
TreeDropTargetDetails dropTargetData = (TreeDropTargetDetails) dropEvent | |||
.getDropTargetDetails(); | |||
tree1.setParent(transferable.getItemId(), dropTargetData | |||
.getItemIdInto()); | |||
} | |||
}; | |||
tree1.setDropHandler(dropHandler); | |||
l.addComponent(tree1); | |||
getLayout().setSizeFull(); | |||
getLayout().addComponent(sp); | |||
TestUtils | |||
.injectCSS( | |||
getLayout().getWindow(), | |||
"" | |||
+ ".v-tree-node-caption-drag-top {/*border-top: none;*/} " | |||
+ ".v-tree-node-caption-drag-bottom {border-bottom: none ;} " | |||
+ ".v-tree-node-caption-drag-center {background-color: transparent;}" | |||
+ ".v-tree-node-caption-dragfolder { background-color: cyan;} "); | |||
} | |||
private final static ThemeResource FOLDER = new ThemeResource( | |||
"../runo/icons/16/folder.png"); | |||
private final static ThemeResource DOC = new ThemeResource( | |||
"../runo/icons/16/document.png"); | |||
public static class File { | |||
private Resource icon = DOC; | |||
private String name; | |||
public File(String fileName) { | |||
name = fileName; | |||
} | |||
public void setIcon(Resource icon) { | |||
this.icon = icon; | |||
} | |||
public Resource getIcon() { | |||
return icon; | |||
} | |||
public void setName(String name) { | |||
this.name = name; | |||
} | |||
public String getName() { | |||
return name; | |||
} | |||
} | |||
public static class Folder extends File { | |||
public Folder(String fileName) { | |||
super(fileName); | |||
setIcon(FOLDER); | |||
} | |||
} | |||
@Override | |||
protected String getDescription() { | |||
return "dd: tree and web desktop tests. TODO add traditional icon area on right side with DragAndDropWrapper and absolutelayouts + more files, auto-opening folders"; | |||
} | |||
@Override | |||
protected Integer getTicketNumber() { | |||
return 119; | |||
} | |||
} |
@@ -0,0 +1,26 @@ | |||
package com.vaadin.tests.util; | |||
import com.vaadin.ui.Window; | |||
public class TestUtils { | |||
/** | |||
* Crossbrowser hack to dynamically add css current window. Can be used to | |||
* keep tests css in source files. | |||
* | |||
* @param cssString | |||
*/ | |||
public static void injectCSS(Window w, String cssString) { | |||
String script = "if ('\\v'=='v') /* ie only */ {\n" | |||
+ " document.createStyleSheet().cssText = '" | |||
+ cssString | |||
+ "';\n" | |||
+ " } else {var tag = document.createElement('style'); tag.type = 'text/css';" | |||
+ " document.getElementsByTagName('head')[0].appendChild(tag);tag[ (typeof " | |||
+ "document.body.style.WebkitAppearance=='string') /* webkit only */ ? 'innerText' " | |||
+ ": 'innerHTML'] = '" + cssString + "';}"; | |||
w.executeJavaScript(script); | |||
} | |||
} |