本文整理汇总了Java中javafx.scene.input.Dragboard.hasContent方法的典型用法代码示例。如果您正苦于以下问题:Java Dragboard.hasContent方法的具体用法?Java Dragboard.hasContent怎么用?Java Dragboard.hasContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.input.Dragboard
的用法示例。
在下文中一共展示了Dragboard.hasContent方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: acceptable
import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
private boolean acceptable(final Dragboard db, final TreeTableRow<GPXLineItem> row) {
boolean result = false;
if (db.hasContent(SERIALIZED_MIME_TYPE)) {
final int index = (Integer) db.getContent(SERIALIZED_MIME_TYPE);
//System.out.println("index: " + index + ", row index:" + row.getIndex());
if (!row.isEmpty() && (row.getIndex() != index)) {
final TreeItem<GPXLineItem> target = row.getTreeItem();
final GPXLineItem.GPXLineItemType targetType = target.getValue().getType();
final TreeItem<GPXLineItem> item = myTreeTableView.getTreeItem(index);
final GPXLineItem.GPXLineItemType itemType = item.getValue().getType();
// don't create loops and only insert on same level or drop on direct parent type
result = !isParent(item, target) &&
(GPXLineItem.GPXLineItemType.isSameTypeAs(targetType, itemType) || GPXLineItem.GPXLineItemType.isParentTypeOf(targetType, itemType));
}
}
return result;
}
示例2: onDragDropped
import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
@Override
protected void onDragDropped(DragEvent e) {
Dragboard db = e.getDragboard();
if (db.hasContent(DataFormatConstants.COMPONENT_ENTITY)) {
ComponentDefine c = (ComponentDefine) db.getContent(DataFormatConstants.COMPONENT_ENTITY);
e.setDropCompleted(true);
e.consume();
// 当拖动物体到3D场景的时候必须把JFX中的鼠标坐标转到到JME中的坐标.
// 不能直接用jme场景中获取鼠标坐标的方式,因为JME是放在awt canvas上的,这时还未获得焦点,直接用
// JME中的方式获取鼠标坐标会错位。
lastDragXPos = e.getX();
lastDragYPos = e.getY();
// 必须隔一帧,即等拖放操作完成执行后再弹窗.
// 这里不能直接执行CustomDialog,因为当CustomDialog为模态时会锁住窗口,这会导致当第二次拖放操作时发生:
// Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException:
// Key already associated with a running event loop: [email protected]
Jfx.runOnJfx(() -> {
ComponentManager.createComponent(c, this);
});
}
}
示例3: mouseDragDropped
import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
private void mouseDragDropped (final DragEvent event) {
Dragboard db = event.getDragboard();
boolean success = false;
if (db.hasContent(VoogaFileFormat.getInstance())) {
VoogaFile node = (VoogaFile) db.getContent(VoogaFileFormat.getInstance());
if (node.getType() != VoogaFileType.FOLDER) {
if (node.getType() != VoogaFileType.ARCHETYPE &&
node.getType() != VoogaFileType.GAME_OBJECT) {
if (elementManager.hasElement(node.getPath())) {
moveElement(node.getPath(), event);
}
else {
addElement(node, event, "");
}
}
else {
if (node.getType() == VoogaFileType.ARCHETYPE) {
addElement(node, event, node.toString());
}
}
}
success = true;
}
if (db.hasString()) {
Node object = (Node) elementManager.getElement(db.getString());
object.setTranslateX(event.getX() - x_offset);
object.setTranslateY(event.getY() - y_offset);
}
event.setDropCompleted(success);
}
示例4: isAcceptable
import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
protected boolean isAcceptable(Dragboard db, TreeTableRow<T> row)
{
if(db.hasContent(JAVA_DATA_FORMAT))
{
int index = (Integer)db.getContent(JAVA_DATA_FORMAT);
if(row.getIndex() != index)
{
TreeItem target = getTarget(row);
TreeItem item = tree.getTreeItem(index);
return !isParent(item, target);
}
}
return false;
}
示例5: onDragOver
import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
@Override
protected void onDragOver(DragEvent e) {
Dragboard db = e.getDragboard();
if (db.hasContent(DataFormatConstants.COMPONENT_ENTITY)) {
e.acceptTransferModes(TransferMode.ANY);
}
e.consume();
}
示例6: dragDropped
import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
@Override
public void dragDropped(DragEvent event, TreeTableRow row) {
Dragboard dragboard = event.getDragboard();
if (dragboard.hasContent(SERIALIZED_MIME_TYPE)) {
int draggedIndex = (Integer) dragboard.getContent(SERIALIZED_MIME_TYPE);
controller.getCommandExecutor().execute(new DragNDropResourceCommand(controller.getProject(), row, draggedIndex));
event.setDropCompleted(true);
row.getTreeTableView().getSelectionModel().select(row.getIndex());
event.consume();
}
}
示例7: dragDropped
import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
@Override
public void dragDropped(DragEvent event, TreeTableRow row) {
Dragboard db = event.getDragboard();
if (db.hasContent(SERIALIZED_MIME_TYPE)) {
int draggedIndex = (Integer) db.getContent(SERIALIZED_MIME_TYPE);
controller.getCommandExecutor().execute(new DragNDropTaskCommand(controller.getProject(), row, draggedIndex));
event.setDropCompleted(true);
row.getTreeTableView().getSelectionModel().select(row.getIndex());
event.consume();
}
}
示例8: acceptableDrop
import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
/**
* Decides if the content stored in the given {@link Dragboard} can be droped on the given target row.
* Currently, the following sources are allowed:
* - another group (will be added as subgroup on drop)
* - entries if the group implements {@link GroupEntryChanger} (will be assigned to group on drop)
*/
public boolean acceptableDrop(Dragboard dragboard) {
// TODO: we should also check isNodeDescendant
boolean canDropOtherGroup = dragboard.hasContent(DragAndDropDataFormats.GROUP);
boolean canDropEntries = dragboard.hasContent(DragAndDropDataFormats.ENTRIES)
&& (groupNode.getGroup() instanceof GroupEntryChanger);
return canDropOtherGroup || canDropEntries;
}
示例9: handleOnDragDropped
import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
private void handleOnDragDropped(LinkedFileViewModel originalItem, DragEvent event) {
Dragboard dragboard = event.getDragboard();
boolean success = false;
ObservableList<LinkedFileViewModel> items = listView.itemsProperty().get();
if (dragboard.hasContent(DragAndDropDataFormats.LINKED_FILE)) {
LinkedFile linkedFile = (LinkedFile) dragboard.getContent(DragAndDropDataFormats.LINKED_FILE);
LinkedFileViewModel transferedItem = null;
int draggedIdx = 0;
for (int i = 0; i < items.size(); i++) {
if (items.get(i).getFile().equals(linkedFile)) {
draggedIdx = i;
transferedItem = items.get(i);
break;
}
}
int thisIdx = items.indexOf(originalItem);
items.set(draggedIdx, originalItem);
items.set(thisIdx, transferedItem);
success = true;
}
if (dragboard.hasFiles()) {
List<LinkedFileViewModel> linkedFiles = dragboard.getFiles().stream().map(File::toPath).map(viewModel::fromFile).collect(Collectors.toList());
items.addAll(linkedFiles);
}
event.setDropCompleted(success);
event.consume();
}
示例10: isDraggingTab
import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
/**
* Returns true if the given dragboard contains the tab that is currently dragged.
*
* @param dragboard dragboard
* @return true if the given dragboard contains the tab that is currently dragged
*/
public static boolean isDraggingTab(Dragboard dragboard) {
return dragboard.hasContent(dataFormat) && DraggableTab.draggingTab.get() != null;
}