當前位置: 首頁>>代碼示例>>Java>>正文


Java DataFormat類代碼示例

本文整理匯總了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);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:19,代碼來源:ResourcePropertyEditorControl.java

示例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();
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:23,代碼來源:ResourcePropertyEditorControl.java

示例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());
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:24,代碼來源:MaterialPropertyControl.java

示例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();
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:28,代碼來源:MaterialPropertyControl.java

示例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();
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:23,代碼來源:PasteFileAction.java

示例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());
}
 
開發者ID:andy-goryachev,項目名稱:FxEditor,代碼行數:20,代碼來源:ClipboardDemoPane.java

示例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();
			}
		}
	}
}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:34,代碼來源:TinymceDeligator.java

示例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;
    }
}
 
開發者ID:teamfx,項目名稱:openjfx-8u-dev-tests,代碼行數:24,代碼來源:DragDropWithControls.java

示例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;
}
 
開發者ID:teamfx,項目名稱:openjfx-8u-dev-tests,代碼行數:25,代碼來源:DragDropWithControls.java

示例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();
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:19,代碼來源:AssetsForm.java

示例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;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:11,代碼來源:GroupResource.java

示例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;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:12,代碼來源:GroupEntryResource.java

示例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;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:16,代碼來源:ResourceView.java

示例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;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:11,代碼來源:FileResource.java

示例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) + "');");
            }
           }
	});
}
 
開發者ID:dhawal9035,項目名稱:WebPLP,代碼行數:14,代碼來源:CodeEditor.java


注:本文中的javafx.scene.input.DataFormat類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。