Java Code Examples for javafx.stage.Window

The following examples show how to use javafx.stage.Window. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Open-Lowcode   Source File: CMultipleChoiceField.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Node getNode(
		PageActionManager actionmanager,
		CPageData inputdata,
		Window parentwindow,
		TabPane[] parenttabpanes,
		CollapsibleNode nodetocollapsewhenactiontriggered) {
	CChoiceFieldValue[] currentchoice = null;
	ArrayList<String> restrictedvalues = null;
	if (this.multipledefaultvaluecode != null) {
		currentchoice = new CChoiceFieldValue[multipledefaultvaluecode.length];
		for (int i = 0; i < this.multipledefaultvaluecode.length; i++) {
			currentchoice[i] = findChoiceFromStoredValue(multipledefaultvaluecode[i]);
		}
	}
	if (this.multipledefaultvaluecode==null) if (this.preselectedvalues.size()>0) {
		currentchoice = new CChoiceFieldValue[this.preselectedvalues.size()];
		for (int i=0;i<this.preselectedvalues.size();i++) currentchoice[i] = this.preselectedvalues.get(i);
	}
	choicefield = new ChoiceField(actionmanager, compactshow, twolines, label, helper, isactive, iseditable, false,
			values, currentchoice, restrictedvalues);
	Node node = choicefield.getNode();
	this.checkboxpanel = choicefield.getCheckBoxList();
	return node;
}
 
Example 2
Source Project: gef   Source File: InfiniteCanvasViewer.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private void onWindowChanged(Window oldValue, Window newValue) {
	if (oldValue != null) {
		oldValue.focusedProperty().removeListener(windowFocusedObserver);
	}
	if (newValue != null) {
		newValue.focusedProperty().addListener(windowFocusedObserver);
		// check if window is focused
		if (Boolean.TRUE.equals(newValue.focusedProperty().get())) {
			isWindowFocused = true;
			viewerFocusedPropertyBinding.invalidate();
		}
	} else {
		// window unfocused
		isInitialized = false;
		isWindowFocused = false;
		viewerFocusedPropertyBinding.invalidate();
	}
}
 
Example 3
Source Project: kafka-message-tool   Source File: DefaultControllerProvider.java    License: MIT License 6 votes vote down vote up
@Override
public BrokerConfigView getBrokerConfigGuiController(KafkaBrokerConfig config,
                                                     AnchorPane parentPane,
                                                     Runnable refeshCallback,
                                                     UserInteractor guiInteractor,
                                                     Window parentWindow) {
    return getControllerFor(config, brokerControllers, () -> {
        try {
            return new BrokerConfigView(config,
                                        parentPane,
                                        guiInformer,
                                        parentWindow,
                                        refeshCallback,
                                        guiInteractor,
                                        statusChecker,
                                        kafkaClusterProxies);
        } catch (IOException e) {
            Logger.error(e);
            return null;
        }
    });
}
 
Example 4
Source Project: logbook-kai   Source File: Tools.java    License: MIT License 6 votes vote down vote up
/**
 * テーブルの内容をCSVファイルとして出力します
 *
 * @param table テーブル
 * @param title タイトル及びファイル名
 * @param own 親ウインドウ
 */
public static void store(TableView<?> table, String title, Window own) throws IOException {
    String body = table.getItems()
            .stream()
            .map(Object::toString)
            .collect(Collectors.joining(CSV_NL))
            .replaceAll(SEPARATOR, CSV_SEPARATOR);
    String content = new StringJoiner(CSV_NL)
            .add(tableHeader(table, CSV_SEPARATOR))
            .add(body)
            .toString();

    FileChooser chooser = new FileChooser();
    chooser.setTitle(title + "の保存");
    chooser.setInitialFileName(title + ".csv");
    chooser.getExtensionFilters().addAll(
            new ExtensionFilter("CSV Files", "*.csv"));
    File f = chooser.showSaveDialog(own);
    if (f != null) {
        Files.write(f.toPath(), content.getBytes(LogWriter.DEFAULT_CHARSET));
    }
}
 
Example 5
Source Project: Open-Lowcode   Source File: CCollapsibleBand.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Node getNode(
		PageActionManager actionmanager,
		CPageData inputdata,
		Window parentwindow,
		TabPane[] parenttabpanes,
		CollapsibleNode nodetocollapsewhenactiontriggered) {
	Node payloadnode = payload.getNode(actionmanager, inputdata, parentwindow, parenttabpanes,
			(closewheninlineactioninside ? this : null));
	collapsiblepane = new TitledPane(this.title, payloadnode);
	collapsiblepane.setCollapsible(true);
	collapsiblepane.setExpanded(this.openbydefault);
	collapsiblepane.setBorder(Border.EMPTY);
	collapsiblepane.setAnimated(false);

	return collapsiblepane;
}
 
Example 6
Source Project: Open-Lowcode   Source File: NicePopup.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * creates a Nice popup
 * 
 * @param parentnode      parent node
 * @param popupnode       popup node
 * @param parentwindow    parent window
 * @param allowscroll     if true, scroll is allowed
 * @param showunderwidget true for a lightweight component, false for a
 *                        heavyweigth component
 * @param shownow         if true, show now, if false, show later
 */
public NicePopup(
		Node parentnode,
		Node popupnode,
		Window parentwindow,
		boolean allowscroll,
		boolean showunderwidget,
		boolean shownow) {
	this.parentnode = parentnode;
	this.popupnode = popupnode;
	this.parentwindow = parentwindow;
	this.allowscroll = allowscroll;
	this.showunderwidget = showunderwidget;
	if (shownow)
		show();
}
 
Example 7
@FXML
private void onOk(final ActionEvent actionEvent)
{
	// possibly replace with ControlsFX validation framework

	if (getEnteredName().isEmpty())
	{
		Alert alert = new Alert(Alert.AlertType.ERROR);
		alert.setTitle(Constants.APPLICATION_NAME);
		// todo: i18n
		alert.setContentText("Please enter a name for this method.");
		alert.initOwner(newPurchaseDialog.getWindow());
		alert.showAndWait();
		return;
	}

	model.setCancelled(false);
	Platform.runLater(() -> {
		Window window = newPurchaseDialog.getWindow();
		window.hide();
	});
}
 
Example 8
Source Project: ResponsiveFX   Source File: ResponsiveHandler.java    License: Apache License 2.0 6 votes vote down vote up
public static void addResponsiveToWindow(Window window) {
    StringProperty stylesheet = new SimpleStringProperty(getCurrentResponsiveStylesheet(window));
    Util.bindStyleSheetToWindow(window, stylesheet);

    updatePseudoClassesForAllChildren(window);
    //TODO: Falsch! Hier muss der ursprünglich gesetzte Wert gespeichert werden! managed müsste eine styledProperty sein
    updateManagedPropertyForAllChildren(window);

    Util.registerRecursiveChildObserver(window, n -> removeAllPseudoClasses(n), n -> updatePseudoClasses(n, getTypeForWindow(window)));

    window.widthProperty().addListener(e -> {
        stylesheet.setValue(getCurrentResponsiveStylesheet(window));
        updatePseudoClassesForAllChildren(window);
        updateManagedPropertyForAllChildren(window);
    });
    window.getScene().getRoot().layout();
}
 
Example 9
public void selectFolderDialog() {
    Window window = ConverterApplication.getEnv().getWindow();
    DirectoryChooser directoryChooser = new DirectoryChooser();
    String sourceFolder = AppProperties.getProperty("source.folder");
    directoryChooser.setInitialDirectory(Utils.getInitialDirecotory(sourceFolder));

    StringJoiner filetypes = new StringJoiner("/");

    Arrays.stream(FILE_EXTENSIONS).map(String::toUpperCase).forEach(filetypes::add);

    directoryChooser.setTitle("Select folder with " + filetypes.toString() + " files for conversion");
    File selectedDirectory = directoryChooser.showDialog(window);
    if (selectedDirectory != null) {
        processFiles(Collections.singleton(selectedDirectory));
        AppProperties.setProperty("source.folder", selectedDirectory.getAbsolutePath());
        if (!chaptersMode.get()) {
            filesChapters.getTabs().add(filesTab);
            filesChapters.getSelectionModel().select(filesTab);
        }
    }
}
 
Example 10
Source Project: gef   Source File: InfiniteCanvasViewer.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private void onSceneChanged(Scene oldScene, Scene newScene) {
	Window oldWindow = null;
	Window newWindow = null;
	Node oldFocusOwner = null;
	Node newFocusOwner = null;
	if (oldScene != null) {
		oldWindow = oldScene.windowProperty().get();
		oldScene.windowProperty().removeListener(windowObserver);
		oldFocusOwner = oldScene.focusOwnerProperty().get();
		oldScene.focusOwnerProperty().removeListener(focusOwnerObserver);
	}
	if (newScene != null) {
		newWindow = newScene.windowProperty().get();
		newScene.windowProperty().addListener(windowObserver);
		newFocusOwner = newScene.focusOwnerProperty().get();
		newScene.focusOwnerProperty().addListener(focusOwnerObserver);
	}
	onWindowChanged(oldWindow, newWindow);
	onFocusOwnerChanged(oldFocusOwner, newFocusOwner);
}
 
Example 11
Source Project: scenic-view   Source File: WindowChecker.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override public void run() {
    // Keep iterating until we have a any windows.
    // If we past the maximum wait time, we'll exit
    long currentWait = -1;
    List<Window> windows = getValidWindows(filter);
    while (running) {
        onWindowsFound(windows);
        try {
            // Logger.print("No JavaFX window found - sleeping for " + sleepTime / 1000 + " seconds");
            Thread.sleep(sleepTime);
            if (maxWaitTime != -1) {
                currentWait += sleepTime;
            }

            if (currentWait > maxWaitTime) {
                finish();
            }
        } catch (final InterruptedException ex) {
            if (running) {
                ExceptionLogger.submitException(ex);
            }
        }

        windows = getValidWindows(filter);
    }
}
 
Example 12
Source Project: marathonv5   Source File: JavaFXTargetLocator.java    License: Apache License 2.0 6 votes vote down vote up
private List<Window> getContextMenu() {
    List<Window> contextMenus = new ArrayList<>();
    new Wait("Unable to context menu") {
        @Override
        public boolean until() {
            Iterator<Window> windows = JavaCompatibility.getWindows();
            while (windows.hasNext()) {
                Window window = windows.next();
                if (window instanceof ContextMenu) {
                    contextMenus.add(window);
                }
            }
            return contextMenus.size() > 0;
        }
    };
    ;
    return contextMenus;
}
 
Example 13
Source Project: PeerWasp   Source File: SelectRootPathUtils.java    License: MIT License 6 votes vote down vote up
public static String showDirectoryChooser(String pathAsString, Window toOpenDialog) {
	DirectoryChooser chooser = new DirectoryChooser();
	chooser.setTitle("Choose your root directory");

	// if parent of given directory does exist, we open chooser with that location.
	// otherwise, take the user home as fallback.
	File path = new File(pathAsString).getParentFile();
	if(path.getParentFile().exists()) {
		chooser.setInitialDirectory(path.getParentFile());
	} else {
		chooser.setInitialDirectory(FileUtils.getUserDirectory());
	}

	try {
		File selectedDirectory = chooser.showDialog(toOpenDialog);
		if (selectedDirectory != null) {
			return selectedDirectory.getAbsolutePath();
		}
	} catch (IllegalArgumentException e) {
		SelectRootPathUtils.showInvalidDirectoryChooserEntryInformation();
		return pathAsString;
	}
	return pathAsString;
}
 
Example 14
Source Project: NSMenuFX   Source File: StageUtils.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static void updateStages() {
	List<Stage> currentStages = new LinkedList<>();
	for (Window w : windows) {
		if (w instanceof Stage) {
			currentStages.add((Stage)w);
		}
	}

	// Remove no-longer existing stages
	stages.removeIf(stage -> !currentStages.contains(stage));

	// Add any new stages
	currentStages.stream()
			.filter(currentStage -> !stages.contains(currentStage))
			.forEach(newStage -> stages.add(newStage));
}
 
Example 15
Source Project: bisq   Source File: Overlay.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
protected void cleanup() {
    if (centerTime != null)
        centerTime.stop();

    if (owner == null)
        owner = MainView.getRootContainer();
    Scene rootScene = owner.getScene();
    if (rootScene != null) {
        Window window = rootScene.getWindow();
        if (window != null && positionListener != null) {
            window.xProperty().removeListener(positionListener);
            window.yProperty().removeListener(positionListener);
            window.widthProperty().removeListener(positionListener);
        }
    }
}
 
Example 16
Source Project: kafka-message-tool   Source File: BrokerConfigGuiActionsHandler.java    License: MIT License 6 votes vote down vote up
public BrokerConfigGuiActionsHandler(TabPaneSelectionInformer tabSelectionInformer,
                                     ListViewActionsHandler<KafkaBrokerConfig> listViewActionsHandler,
                                     UserInteractor interactor,
                                     ModelDataProxy modelDataProxy,
                                     ControllerProvider controllerProvider,
                                     AnchorPane parentPane,
                                     Window parentWindow) {
    super(tabSelectionInformer, listViewActionsHandler);

    this.listViewActionsHandler = listViewActionsHandler;
    this.interactor = interactor;
    this.modelDataProxy = modelDataProxy;
    this.controllerProvider = controllerProvider;
    this.parentWindow = parentWindow;
    this.parentPane = parentPane;
    this.fromPojoConverter = new FromPojoConverter(modelDataProxy);

}
 
Example 17
Source Project: metastone   Source File: CardPlayedToken.java    License: GNU General Public License v2.0 6 votes vote down vote up
public CardPlayedToken(GameBoardView boardView, Card card) {
	Window parent = boardView.getScene().getWindow();
	this.cardToken = new CardTooltip();

	popup = new Popup();
	popup.getContent().setAll(cardToken);
	popup.setX(parent.getX() + 40);
	popup.show(parent);
	popup.setY(parent.getY() + parent.getHeight() * 0.5 - cardToken.getHeight() * 0.5);

	cardToken.setCard(card);

	NotificationProxy.sendNotification(GameNotification.ANIMATION_STARTED);
	FadeTransition animation = new FadeTransition(Duration.seconds(1.2), cardToken);
	animation.setDelay(Duration.seconds(0.6f));
	animation.setOnFinished(this::onComplete);
	animation.setFromValue(1);
	animation.setToValue(0);
	animation.play();
}
 
Example 18
Source Project: gramophy   Source File: dashController.java    License: GNU General Public License v3.0 6 votes vote down vote up
@FXML
public void selectMusicLibraryFolderButtonClicked(ActionEvent event)
{
    Node e = (Node) event.getSource();
    Window ps = e.getScene().getWindow();
    DirectoryChooser directoryChooser = new DirectoryChooser();
    File newMusicFolder = directoryChooser.showDialog(ps);
    File presentFolder = new File(config.get("music_lib_path"));

    if(newMusicFolder == null) return;

    if(!newMusicFolder.getAbsolutePath().equals(presentFolder.getAbsolutePath()))
    {
        selectMusicLibraryField.setText(newMusicFolder.getAbsolutePath());
    }
}
 
Example 19
Source Project: MyBox   Source File: MainMenuController.java    License: Apache License 2.0 6 votes vote down vote up
@FXML
protected void closeOtherWindows(ActionEvent event) {
    List<Window> windows = new ArrayList<>();
    windows.addAll(Window.getWindows());
    for (Window window : windows) {
        if (parentController != null) {
            if (!window.equals(parentController.getMyStage())) {
                window.hide();
            }
        } else {
            if (!window.equals(myStage)) {
                window.hide();
            }
        }
    }
}
 
Example 20
@FXML
public void close(ActionEvent evt) {

    //
    // For some reason, this.getScene() which is on the fx:root returns null
    //

    Scene scene = ((Button)evt.getSource()).getScene();
    if( scene != null ) {
        Window w = scene.getWindow();
        if (w != null) {
            w.hide();
        }
    }
}
 
Example 21
Source Project: Open-Lowcode   Source File: CPopupButton.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * generate and shows the popup
 * 
 * @param parentnode      parent javafx node
 * @param popupnode       node to show in the popup pane
 * @param inputdata       page input data
 * @param parentwindow    parent javafx window
 * @param allowscroll     if true, allows scroll
 * @param showunderwidget if true, shows under widget, if false, shows at the
 *                        middle of the application window
 */
public static void generateAndShowPopup(
		Node parentnode,
		Node popupnode,
		CPageData inputdata,
		Window parentwindow,
		boolean allowscroll,
		boolean showunderwidget) {
	NicePopup nicepopup = new NicePopup(parentnode, popupnode, parentwindow, allowscroll, showunderwidget);
	if (nicepopup.getSubScene() != null)
		inputdata.addSubScene(nicepopup.getSubScene());

}
 
Example 22
@FXML
public void close(ActionEvent evt) {

    //
    // For some reason, this.getScene() which is on the fx:root returns null
    //

    Scene scene = ((Button)evt.getSource()).getScene();
    if( scene != null ) {
        Window w = scene.getWindow();
        if (w != null) {
            w.hide();
        }
    }
}
 
Example 23
Source Project: jmonkeybuilder   Source File: ExternalFileEditorDialog.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@FxThread
public void show(@NotNull final Window owner) {
    super.show(owner);

    Path initDirectory = getInitDirectory();
    if (initDirectory == null) {
        initDirectory = Paths.get(System.getProperty("user.home"));
    }

    final Path toExpand = initDirectory;
    final Array<Path> rootFolders = ArrayFactory.newArray(Path.class);

    final FileSystem fileSystem = FileSystems.getDefault();
    fileSystem.getRootDirectories().forEach(rootFolders::add);

    final ResourceTree resourceTree = getResourceTree();
    resourceTree.setOnLoadHandler(finished -> {
        if (finished) {
            resourceTree.expandTo(toExpand, true);
        }
    });

    if (rootFolders.size() < 2) {
        resourceTree.fill(notNull(rootFolders.first()));
    } else {
        resourceTree.fill(rootFolders);
    }

    EXECUTOR_MANAGER.addFxTask(resourceTree::requestFocus);
}
 
Example 24
@FXML
private void onCancel(final ActionEvent actionEvent)
{
	model.setCancelled(true);
	Platform.runLater(() -> {
		Window window = newPurchaseDialog.getWindow();
		window.hide();
	});
}
 
Example 25
Source Project: yfiton   Source File: Notifications.java    License: Apache License 2.0 5 votes vote down vote up
public void show(Notifications notification) {
    Window window = null;
    if (notification.owner == null) {
        /*
         * If the owner is not set, we work with the whole screen.
         */
        startX = 0;
        startY = 0;
        screenWidth = screenBounds.getWidth();
        screenHeight = screenBounds.getHeight();

        window = Utils.getWindow(null);
    } else {
        /*
         * If the owner is set, we will make the notifications popup
         * inside its window.
         */
        startX = notification.owner.getX();
        startY = notification.owner.getY();
        screenWidth = notification.owner.getWidth();
        screenHeight = notification.owner.getHeight();
        window = notification.owner;
    }

    padding = screenHeight * 3 / 100.0;

    show(window, notification);
}
 
Example 26
Source Project: ResponsiveFX   Source File: ResponsiveHandler.java    License: Apache License 2.0 5 votes vote down vote up
private static void updatePseudoClassesForAllChildren(Window window) {
    List<Node> nodes = Util.getAllNodesInWindow(window);
    for (Node node : nodes) {
        updatePseudoClasses(node, getTypeForWindow(window));

    }
}
 
Example 27
public void setWindow(Window window) {
    window.setOnCloseRequest(event -> {
        if (closeButton.isDisable()) {
            event.consume();
        } else {
            try {
                onClose();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    });
}
 
Example 28
Source Project: phoebus   Source File: DockStage.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/** @return All currently open dock stages (safe copy) */
public static List<Stage> getDockStages()
{
    final List<Stage> dock_windows = new ArrayList<>();
    // Having a KEY_ID property implies that the Window
    // is a Stage that was configured as a DockStage
    for (Window window : Window.getWindows())
        if (window.getProperties().containsKey(KEY_ID))
            dock_windows.add((Stage) window);

    return dock_windows;
}
 
Example 29
Source Project: pmd-designer   Source File: PopOverUtil.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Display a popover at an anchor node, but owned by an arbitrary other window.
 * In case of nested popovers, the inner ones should not be owned by the outer
 * one, otherwise their detached behavior is not independent.
 *
 * @see PopOver#show(Node, double)
 */
public static void showAt(PopOver popOver, Window owner, javafx.scene.Node anchor, double offset) {
    requireNonNull(owner);

    Bounds bounds = anchor.localToScreen(anchor.getBoundsInLocal());

    switch (popOver.getArrowLocation()) {
    case BOTTOM_CENTER:
    case BOTTOM_LEFT:
    case BOTTOM_RIGHT:
        popOver.show(owner, bounds.getMinX() + bounds.getWidth() / 2,
                     bounds.getMinY() + offset);
        break;
    case LEFT_BOTTOM:
    case LEFT_CENTER:
    case LEFT_TOP:
        popOver.show(owner, bounds.getMaxX() - offset,
                     bounds.getMinY() + bounds.getHeight() / 2);
        break;
    case RIGHT_BOTTOM:
    case RIGHT_CENTER:
    case RIGHT_TOP:
        popOver.show(owner, bounds.getMinX() + offset,
                     bounds.getMinY() + bounds.getHeight() / 2);
        break;
    case TOP_CENTER:
    case TOP_LEFT:
    case TOP_RIGHT:
        popOver.show(owner, bounds.getMinX() + bounds.getWidth() / 2,
                     bounds.getMinY() + bounds.getHeight() - offset);
        break;
    default:
        break;
    }
}
 
Example 30
Source Project: FXDesktopSearch   Source File: DesktopSearchController.java    License: Apache License 2.0 5 votes vote down vote up
public void configure(final DesktopSearchMain aApplication, final Backend aBackend, final String aSearchURL, final Window aWindow) {
    gateway = new DesktopGateway(aApplication, DesktopSearchController.this);
    window = aWindow;
    application = aApplication;
    backend = aBackend;
    backend.setProgressListener(new FXProgressListener());
    watcherThread = new ProgressWatcherThread();
    webView.getEngine().setJavaScriptEnabled(true);
    webView.getEngine().getLoadWorker().stateProperty().addListener((ov, t, t1) -> {
        if (t1 == State.SUCCEEDED) {
            final var windowGlobalJSNamespace = (JSObject) webView.getEngine().executeScript("window");
            windowGlobalJSNamespace.setMember("desktop", gateway);
        }
    });
    webView.setContextMenuEnabled(false);
    webView.getEngine().load(aSearchURL);
    webView.getEngine().setJavaScriptEnabled(true);

    if (aApplication.getConfigurationManager().getConfiguration().isCrawlOnStartup()) {
        // Scedule a crawl run 5 seconds after startup...
        final var theTimer = new Timer();
        theTimer.schedule(new TimerTask() {
            @Override
            public void run() {
                Platform.runLater(() -> recrawl());
            }
        }, 5000);
    }
}