本文整理匯總了Java中javafx.scene.input.DataFormat類的典型用法代碼示例。如果您正苦於以下問題:Java DataFormat類的具體用法?Java DataFormat怎麽用?Java DataFormat使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DataFormat類屬於javafx.scene.input包,在下文中一共展示了DataFormat類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: dragDropped
import javafx.scene.input.DataFormat; //導入依賴的package包/類
/**
* Handle dropped files to editor.
*/
@FXThread
private void dragDropped(@NotNull final DragEvent dragEvent) {
final Dragboard dragboard = dragEvent.getDragboard();
final List<File> files = unsafeCast(dragboard.getContent(DataFormat.FILES));
if (files == null || files.size() != 1) {
return;
}
final File file = files.get(0);
if (!canAccept(file)) return;
handleFile(file);
}
示例2: dragOver
import javafx.scene.input.DataFormat; //導入依賴的package包/類
/**
* Handle drag over.
*/
@FXThread
private void dragOver(@NotNull final DragEvent dragEvent) {
final Dragboard dragboard = dragEvent.getDragboard();
final List<File> files = unsafeCast(dragboard.getContent(DataFormat.FILES));
if (files == null || files.size() != 1) {
return;
}
final File file = files.get(0);
if (!canAccept(file)) return;
final Set<TransferMode> transferModes = dragboard.getTransferModes();
final boolean isCopy = transferModes.contains(TransferMode.COPY);
dragEvent.acceptTransferModes(isCopy ? TransferMode.COPY : TransferMode.MOVE);
dragEvent.consume();
}
示例3: handleDragDroppedEvent
import javafx.scene.input.DataFormat; //導入依賴的package包/類
/**
* Handle dropped events.
*
* @param dragEvent the dropped event.
*/
@FXThread
private void handleDragDroppedEvent(@NotNull final DragEvent dragEvent) {
final Dragboard dragboard = dragEvent.getDragboard();
final List<File> files = unsafeCast(dragboard.getContent(DataFormat.FILES));
if (files == null || files.size() != 1) {
return;
}
final File file = files.get(0);
if (!file.getName().endsWith(FileExtensions.JME_MATERIAL)) {
return;
}
addMaterial(file.toPath());
}
示例4: handleDragOverEvent
import javafx.scene.input.DataFormat; //導入依賴的package包/類
/**
* Handle drag over events.
*
* @param dragEvent the drag over event.
*/
@FXThread
private void handleDragOverEvent(@NotNull final DragEvent dragEvent) {
final Dragboard dragboard = dragEvent.getDragboard();
final List<File> files = unsafeCast(dragboard.getContent(DataFormat.FILES));
if (files == null || files.size() != 1) {
return;
}
final File file = files.get(0);
if (!file.getName().endsWith(FileExtensions.JME_MATERIAL)) {
return;
}
final Set<TransferMode> transferModes = dragboard.getTransferModes();
final boolean isCopy = transferModes.contains(TransferMode.COPY);
dragEvent.acceptTransferModes(isCopy ? TransferMode.COPY : TransferMode.MOVE);
dragEvent.consume();
}
示例5: execute
import javafx.scene.input.DataFormat; //導入依賴的package包/類
@FXThread
@Override
protected void execute(@Nullable final ActionEvent event) {
super.execute(event);
final Clipboard clipboard = Clipboard.getSystemClipboard();
if (clipboard == null) return;
final List<File> files = unsafeCast(clipboard.getContent(DataFormat.FILES));
if (files == null || files.isEmpty()) return;
final Path currentFile = getElement().getFile();
final boolean isCut = "cut".equals(clipboard.getContent(EditorUtil.JAVA_PARAM));
if (isCut) {
files.forEach(file -> moveFile(currentFile, file.toPath()));
} else {
files.forEach(file -> copyFile(currentFile, file.toPath()));
}
clipboard.clear();
}
示例6: updateContent
import javafx.scene.input.DataFormat; //導入依賴的package包/類
protected void updateContent(CMap<DataFormat,CList<LineSegment>> content)
{
SegmentTextEditorModel m = new SegmentTextEditorModel();
if(content != null)
{
CList<DataFormat> formats = content.keys();
CSorter.sort(formats);
for(DataFormat f: formats)
{
CList<LineSegment> lines = content.get(f);
m.addSegments(lines);
}
}
editor.setTextModel(m);
D.print(m.getLineCount());
}
示例7: pasteHandler
import javafx.scene.input.DataFormat; //導入依賴的package包/類
/**
* 붙여넣기 핸들링 <br/>
*
* 10.26 이미지 붙여넣기
*
* @작성자 : KYJ
* @작성일 : 2017. 10. 26.
* @param ev
*/
protected void pasteHandler(KeyEvent ev) {
Clipboard systemClipboard = Clipboard.getSystemClipboard();
Set<DataFormat> contentTypes = systemClipboard.getContentTypes();
LOGGER.debug("{}", contentTypes);
List<File> files = systemClipboard.getFiles();
if (systemClipboard.getImage() != null) {
pasteImage(systemClipboard.getImage());
} else if (files != null) {
for (File f : files) {
try {
String contentType = Files.probeContentType(f.toPath());
LOGGER.debug(contentType);
if (contentType.startsWith("image/")) {
pasteImage(contentType, FileUtil.getBytes(f));
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
示例8: getScene
import javafx.scene.input.DataFormat; //導入依賴的package包/類
@Override
protected Scene getScene() {
if (null == CONTENT_IMAGE) {
CONTENT_IMAGE = new Image(DragDropWithControls.class.getResource("JavaFX.png").toExternalForm());
dataFormatToCheckBoxID.put(DataFormat.IMAGE, new Pair<String, Object>(ID_IMAGE, CONTENT_IMAGE));
}
Parameters params = getParameters();
parameters = params == null ? Collections.<String>emptyList() : params.getRaw();
if (parameters.size() > 1 && parameters.get(1).equals(PARAMETER_ONLY_SOURCE_STAGE)) {
leftScene = prepareSourceStage(stage);
return leftScene;
} else if (parameters.size() > 1 && parameters.get(1).equals(PARAMETER_ONLY_TARGET_STAGE)) {
rightScene = prepareTargetStage(secondaryStage);
return rightScene;
} else {
leftScene = prepareSourceStage(stage);
secondaryStage = new Stage();
rightScene = prepareTargetStage(secondaryStage);
return leftScene;
}
}
示例9: createFormatSelect
import javafx.scene.input.DataFormat; //導入依賴的package包/類
private Node createFormatSelect(final Set<DataFormat> dataFormats) {
VBox box = new VBox();
for (final Map.Entry<DataFormat, Pair<String, Object>> df : dataFormatToCheckBoxID.entrySet()) {
CheckBox cb = new CheckBox(df.getValue().getKey());
cb.selectedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
if (t1) {
dataFormats.add(df.getKey());
} else {
dataFormats.remove(df.getKey());
}
}
});
box.getChildren().add(cb);
}
((CheckBox) box.getChildren().get(0)).selectedProperty().set(true);
return box;
}
示例10: doDragDetected
import javafx.scene.input.DataFormat; //導入依賴的package包/類
private void doDragDetected(MouseEvent e) {
ObservableList<TreeItem<File>> items = assetTree.getSelectionModel().getSelectedItems();
if (items.isEmpty()) {
e.consume();
return;
}
List<File> files = new ArrayList<>(items.size());
items.filtered(t -> t.getValue() != null).forEach(t -> {files.add(t.getValue());});
if (files.size() <= 0) {
e.consume();
return;
}
Dragboard db = assetTree.startDragAndDrop(TransferMode.COPY_OR_MOVE);
ClipboardContent clipboardContent = new ClipboardContent();
clipboardContent.put(DataFormat.FILES, files);
db.setContent(clipboardContent);
e.consume();
}
示例11: copy
import javafx.scene.input.DataFormat; //導入依賴的package包/類
@Override public boolean copy(Map<DataFormat, Object> content) {
@SuppressWarnings("unchecked")
List<File> files = (List<File>) content.get(DataFormat.FILES);
if (files == null) {
files = new ArrayList<>();
content.put(DataFormat.FILES, files);
}
files.add(group.getPath().toFile());
return true;
}
示例12: copy
import javafx.scene.input.DataFormat; //導入依賴的package包/類
@Override public boolean copy(Map<DataFormat, Object> content) {
@SuppressWarnings("unchecked")
List<File> files = (List<File>) content.get(DataFormat.FILES);
if (files == null) {
files = new ArrayList<>();
content.put(DataFormat.FILES, files);
}
files.add(entry.getFilePath().toFile());
return true;
}
示例13: copy
import javafx.scene.input.DataFormat; //導入依賴的package包/類
private void copy(ObservableList<TreeItem<Resource>> selectedItems) {
Clipboard clipboard = Clipboard.getSystemClipboard();
Map<DataFormat, Object> content = new HashMap<>();
for (TreeItem<Resource> treeItem : selectedItems) {
Resource resource = treeItem.getValue();
if (resource != null) {
if (!resource.copy(content)) {
FXUIUtils.showMessageDialog(null, "Clipboard operation failed", "Unhandled resource selection",
AlertType.ERROR);
}
}
}
clipboard.setContent(content);
clipboardOperation = Operation.COPY;
}
示例14: copy
import javafx.scene.input.DataFormat; //導入依賴的package包/類
@Override public boolean copy(Map<DataFormat, Object> content) {
@SuppressWarnings("unchecked")
List<File> files = (List<File>) content.get(DataFormat.FILES);
if (files == null) {
files = new ArrayList<>();
content.put(DataFormat.FILES, files);
}
files.add(path.toFile());
return true;
}
示例15: initializeEngineEvents
import javafx.scene.input.DataFormat; //導入依賴的package包/類
private void initializeEngineEvents()
{
webView.addEventFilter(KeyEvent.KEY_PRESSED, e -> {
if( e.isShortcutDown() && e.getCode() == KeyCode.V)
{
String content = (String) Clipboard.getSystemClipboard().getContent(DataFormat.PLAIN_TEXT);
if (content != null)
{
webView.getEngine().executeScript("editor.onPaste('" + sanitizeForAce(content) + "');");
}
}
});
}