本文整理匯總了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;
}