use of javafx.scene.layout.BorderPane in project Gargoyle by callakrsos.
the class DesignerFx method createCodeEditorPanel.
private BorderPane createCodeEditorPanel() {
BorderPane p = new BorderPane();
// JPanel p = new JPanel();
// p.setLayout(new BorderLayout());
// codeEditorPane.setBorder(BorderFactory.createLineBorder(Color.black));
// makeTextComponentUndoable(codeEditorPane);
p.setTop(new Label("Source code:"));
// SwingNode fxScrollPane = new SwingNode();
// createSwingContent(fxScrollPane, new JScrollPane(codeEditorPane));
p.setCenter(codeEditorPane);
// createSwingContent(swingNode, p);
return p;
}
use of javafx.scene.layout.BorderPane in project Gargoyle by callakrsos.
the class GoogleTrendComposite method chkShowBrowserOnAction.
public void chkShowBrowserOnAction(ActionEvent e) {
// if (chkShowBrowser.isSelected()) {
FxUtil.createStageAndShow(new BorderPane(browserParent), stage -> {
chkShowBrowser.setDisable(true);
stage.setOnCloseRequest(ev -> {
chkShowBrowser.setDisable(false);
});
});
// }
// if (chkShowBrowser.isSelected()) {
// spMainContent.getItems().add(spBrowserContent);
// } else {
// spMainContent.getItems().removeIf(v -> {
// return v == spBrowserContent;
// });
// }
}
use of javafx.scene.layout.BorderPane in project Gargoyle by callakrsos.
the class DockNode method setFloating.
/**
* Whether the node is currently floating.
*
* @param floating Whether the node is currently floating.
* @param translation null The offset of the node after being set floating. Used for aligning it
* with its layout bounds inside the dock pane when it becomes detached. Can be null
* indicating no translation.
*
*
* tansalation param value is value set (screenX,screenY)
*/
public void setFloating(boolean floating, Point2D translation) {
if (floating && !this.isFloating()) {
// position the new stage relative to the old scene offset
Point2D floatScene = this.localToScene(0, 0);
Point2D floatScreen = this.localToScreen(0, 0);
// setup window stage
dockTitleBar.setVisible(this.isCustomTitleBar());
dockTitleBar.setManaged(this.isCustomTitleBar());
if (this.isDocked()) {
this.undock();
}
stage = new Stage();
stage.initStyle(stageStyle);
stage.titleProperty().bind(titleProperty);
if (dockPane != null && dockPane.getScene() != null && dockPane.getScene().getWindow() != null) {
stage.initOwner(dockPane.getScene().getWindow());
}
if (null == stage.getOwner() && null != this.owner)
stage.initOwner(this.owner);
/* append close handler. 2017-05-29 by kyj.*/
EventHandler<WindowEvent> closeHandler = ev -> {
try {
ObservableList<Node> childrenUnmodifiable = null;
if (dockPane != null)
dockPane.getChildrenUnmodifiable();
else
childrenUnmodifiable = FXCollections.observableArrayList(getContents());
Consumer<Closeable> clo = n -> {
try {
n.close();
} catch (Exception e) {
e.printStackTrace();
}
};
childrenUnmodifiable.stream().filter(n -> n instanceof Closeable).map(n -> (Closeable) n).forEach(clo);
} catch (Exception e) {
e.printStackTrace();
}
};
// stage.setOnCloseRequest(value);
stage.addEventHandler(WindowEvent.WINDOW_CLOSE_REQUEST, closeHandler);
// offset the new stage to cover exactly the area the dock was local to the scene
// this is useful for when the user presses the + sign and we have no information
// on where the mouse was clicked
// the border pane allows the dock node to
// have a drop shadow effect on the border
// but also maintain the layout of contents
// such as a tab that has no content
borderPane = new BorderPane();
borderPane.getStyleClass().add("dock-node-border");
borderPane.setCenter(this);
borderPane.applyCss();
Scene scene = new Scene(borderPane);
scene.getStylesheets().add(SkinManager.getInstance().getSkin());
// apply the floating property so we can get its padding size
// while it is floating to offset it by the drop shadow
// this way it pops out above exactly where it was when docked
this.floatingProperty.set(floating);
this.applyCss();
/*
* 2016-10-26 apply default value by kyj
* tanslation param value is empty , i call api that stage will be located center
*/
if (translation != null) {
Point2D stagePosition = new Point2D(0, 0);
if (this.isDecorated()) {
Window owner = this.owner;
if (null != owner)
stagePosition = floatScene.add(new Point2D(owner.getX(), owner.getY()));
else
stagePosition = floatScene.add(new Point2D(0, 0));
} else {
if (floatScreen != null)
stagePosition = floatScreen;
}
if (translation != null) {
stagePosition = stagePosition.add(translation);
}
// Insets insetsDelta = borderPane.getInsets();
stage.setX(/*stagePosition.getX() - insetsDelta.getLeft()*/
translation.getX());
stage.setY(/*stagePosition.getY() - insetsDelta.getTop()*/
translation.getY());
} else
stage.centerOnScreen();
if (stageStyle == StageStyle.TRANSPARENT) {
scene.setFill(null);
}
stage.setResizable(this.isStageResizable());
if (this.isStageResizable()) {
stage.addEventFilter(MouseEvent.MOUSE_PRESSED, this);
stage.addEventFilter(MouseEvent.MOUSE_MOVED, this);
stage.addEventFilter(MouseEvent.MOUSE_DRAGGED, this);
}
// we want to set the client area size
// without this it subtracts the native border sizes from the scene
// size
stage.sizeToScene();
stage.setScene(scene);
stage.show();
} else if (!floating && this.isFloating()) {
this.floatingProperty.set(floating);
stage.removeEventFilter(MouseEvent.MOUSE_PRESSED, this);
stage.removeEventFilter(MouseEvent.MOUSE_MOVED, this);
stage.removeEventFilter(MouseEvent.MOUSE_DRAGGED, this);
stage.close();
}
}
use of javafx.scene.layout.BorderPane in project Gargoyle by callakrsos.
the class FxUtil method openBrowser.
public static WebView openBrowser(Node parent, String content, boolean isLink) {
WebView view = new WebView();
WebEngine engine = view.getEngine();
engine.setOnError(err -> {
String message = err.getMessage();
DialogUtil.showMessageDialog(FxUtil.getWindow(parent), message);
});
view.setOnKeyPressed(key -> {
if (key.getCode() == KeyCode.F12) {
FxUtil.createStageAndShow("Simple Web Console", new WebViewConsole(view));
}
});
engine.setJavaScriptEnabled(true);
engine.setCreatePopupHandler(new Callback<PopupFeatures, WebEngine>() {
@Override
public WebEngine call(PopupFeatures p) {
// Stage stage = new Stage();
// WebView wv2 = new WebView();
//
// wv2.getEngine().setJavaScriptEnabled(true);
//
// stage.setScene(new Scene(wv2, BROWSER_WIDTH,
// BROWSER_HEIGHT));
// stage.initOwner(parent == null ? (Window) null :
// parent.getScene().getWindow());
// stage.show();
WebView openBrowser = openBrowser(view, "", false);
return openBrowser.getEngine();
}
});
engine.setOnAlert(ev -> {
DialogUtil.showMessageDialog(ev.getData());
});
engine.setConfirmHandler(new Callback<String, Boolean>() {
@Override
public Boolean call(String param) {
Optional<Pair<String, String>> showYesOrNoDialog = DialogUtil.showYesOrNoDialog("Confirm.", param);
if (showYesOrNoDialog.isPresent()) {
Pair<String, String> pair = showYesOrNoDialog.get();
if (pair == null)
return false;
return "Y".equals(pair.getValue());
}
return false;
}
});
engine.setOnAlert((WebEvent<String> wEvent) -> {
System.out.println("Alert Event - Message: " + wEvent.getData());
});
if (isLink)
engine.load(content);
else
engine.loadContent(content);
BorderPane root = new BorderPane(view);
TextField txtLink = new TextField(content);
txtLink.addEventHandler(KeyEvent.KEY_PRESSED, ev -> {
if (KeyCode.ENTER == ev.getCode())
engine.load(txtLink.getText());
});
root.setTop(txtLink);
engine.getLoadWorker().stateProperty().addListener(new ChangeListener<State>() {
@Override
public void changed(ObservableValue<? extends State> observable, State oldValue, State newValue) {
// if (newValue == State.SUCCEEDED) {
String location = engine.getLocation();
txtLink.setText(location);
// }
}
});
FxUtil.createStageAndShow(new Scene(root, BROWSER_WIDTH, BROWSER_HEIGHT), stage -> {
stage.initOwner(parent == null ? (Window) null : parent.getScene().getWindow());
});
return view;
}
use of javafx.scene.layout.BorderPane in project Gargoyle by callakrsos.
the class SVNTreeView method menuPropertiesOnAction.
/**
* @작성자 : KYJ
* @작성일 : 2016. 8. 8.
* @param e
* @throws IOException
*/
public void menuPropertiesOnAction(ActionEvent e) {
TreeItem<SVNItem> selectedItem = getSelectionModel().getSelectedItem();
try {
if (selectedItem != null) {
SVNItem value = selectedItem.getValue();
Properties properties = value.getManager().getProperties();
FXMLLoader fxmlLoader = new FXMLLoader(SVNTreeView.class.getResource("AddNewSVNRepositoryView.fxml"));
BorderPane n = fxmlLoader.load();
Stage window = (Stage) getParent().getScene().getWindow();
Stage parent = (Stage) com.kyj.fx.voeditor.visual.util.ValueUtil.decode(window, window, SharedMemory.getPrimaryStage());
Stage stage = new Stage();
AddNewSVNRepositoryController controller = fxmlLoader.getController();
controller.setStage(stage);
controller.setProperties(properties);
stage.setScene(new Scene(n));
stage.setResizable(false);
stage.initOwner(parent);
stage.setTitle("Modify Location.");
stage.centerOnScreen();
stage.showAndWait();
Properties result = controller.getResult();
if (result != null) {
SVNItem newSVNItem = new SVNRepository(new JavaSVNManager(result));
TreeItem<SVNItem> createNode = scmTreeMaker.createNode(newSVNItem, null);
getRoot().getChildren().remove(selectedItem);
getRoot().getChildren().add(createNode);
}
}
} catch (Exception ex) {
LOGGER.error(ValueUtil.toString(ex));
}
}
Aggregations