Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JProCompatible Version (Dont Merge) #45

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 82 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.dockfx</groupId>
<groupId>de.sandec</groupId>
<artifactId>dockfx</artifactId>
<packaging>jar</packaging>
<version>0.4-SNAPSHOT</version>
<version>0.4.1</version>
<name>DockFX</name>
<url>https://github.com/RobertBColton/DockFX.git</url>

Expand All @@ -16,10 +16,22 @@
<netbeans.checkstyle.format>true</netbeans.checkstyle.format>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<fileExtensions>java, properties, xml</fileExtensions>
<jpro.version>2020.1.1-SNAPSHOT</jpro.version>
<javafx.version>15</javafx.version>
</properties>

<build>
<plugins>
<plugin>
<groupId>com.sandec.jpro</groupId>
<artifactId>jpro-maven-plugin</artifactId>
<version>${jpro.version}</version>
<configuration>
<visible>false</visible>
<mainClassName>org.dockfx.demo.DockFX</mainClassName>
<openingPath>/</openingPath>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
Expand Down Expand Up @@ -71,9 +83,77 @@
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

</build>

<distributionManagement>
<repository>
<id>bintray-sandec-repo</id>
<name>sandec-repo</name>
<url>https://api.bintray.com/maven/sandec/repo/dockfx/;publish=1</url>
</repository>
</distributionManagement>

<pluginRepositories>
<pluginRepository>
<id>jpro - sandec repository</id>
<url>https://sandec.bintray.com/repo</url>
</pluginRepository>
</pluginRepositories>

<repositories>
<repository>
<id>jpro - sandec repository</id>
<url>https://sandec.bintray.com/repo</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>${javafx.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<version>${javafx.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>${javafx.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-media</artifactId>
<version>${javafx.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>

<reporting>
<plugins>
<plugin>
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/org/dockfx/DockNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ protected void invalidated() {
borderPane.pseudoClassStateChanged(MAXIMIZED_PSEUDO_CLASS, get());
}

Stage rootWindow = (Stage) stage;
while(rootWindow.getOwner() != null) {
rootWindow = (Stage) rootWindow.getOwner();
}
if(this.get()) {
stage.setX(rootWindow.getX());
stage.setY(rootWindow.getY());
stage.setWidth(rootWindow.getWidth());
stage.setHeight(rootWindow.getHeight());
}

/*
stage.setMaximized(get());

// TODO: This is a work around to fill the screen bounds and not overlap the task bar when
Expand All @@ -113,7 +125,7 @@ protected void invalidated() {

stage.setWidth(bounds.getWidth());
stage.setHeight(bounds.getHeight());
}
}*/
}

@Override
Expand Down
31 changes: 28 additions & 3 deletions src/main/java/org/dockfx/DockPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.BiConsumer;

import com.sun.javafx.css.StyleManager;

import com.sun.javafx.scene.NodeHelper;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.beans.value.ChangeListener;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.collections.ObservableMap;
Expand All @@ -29,12 +33,15 @@
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.SplitPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.StackPane;
import javafx.scene.shape.Rectangle;
import javafx.stage.Popup;
import javafx.stage.Stage;
import javafx.stage.Window;
import javafx.util.Duration;

/**
Expand All @@ -48,7 +55,14 @@ public class DockPane extends StackPane implements EventHandler<DockEvent> {
/**
* Package-private internal list of all DockPanes for event mouse picking.
*/
static List<DockPane> dockPanes = new ArrayList<DockPane>();
final static String DOCKFX_DOCKPANES_CONTEXT = "DOCKFX_DOCKPANES_CONTEXT";
public static List<DockPane> getDockPanes(Stage context) {
if(context.getOwner() != null) return getDockPanes((Stage) context.getOwner());
if(!context.getProperties().containsKey(DOCKFX_DOCKPANES_CONTEXT)) {
context.getProperties().put(DOCKFX_DOCKPANES_CONTEXT, new ArrayList<DockPane>());
}
return (List<DockPane>) context.getProperties().get(DOCKFX_DOCKPANES_CONTEXT);
}

/**
* The current root node of this dock pane's layout.
Expand Down Expand Up @@ -181,7 +195,6 @@ public final boolean isDockRoot() {
*/
public DockPane() {
super();
DockPane.dockPanes.add(this);

this.addEventHandler(DockEvent.ANY, this);
this.addEventFilter(DockEvent.ANY, new EventHandler<DockEvent>() {
Expand Down Expand Up @@ -220,7 +233,19 @@ public void handle(DockEvent event) {
KeyValue kv = new KeyValue(dockAreaIndicator.strokeDashOffsetProperty(), 12);
KeyFrame kf = new KeyFrame(Duration.millis(500), kv);
dockAreaStrokeTimeline.getKeyFrames().add(kf);
dockAreaStrokeTimeline.play();

NodeHelper.treeShowingProperty(this).addListener((p,o,n) -> {
if(n) {
DockPane.getDockPanes((Stage) this.getScene().getWindow()).add(this);
dockAreaStrokeTimeline.play();
} else {
dockAreaStrokeTimeline.stop();
}
});
if(NodeHelper.isTreeShowing(this)) {
DockPane.getDockPanes((Stage) this.getScene().getWindow()).add(this);
dockAreaStrokeTimeline.play();
}

DockPosButton dockCenter = new DockPosButton(false, DockPos.CENTER);
dockCenter.getStyleClass().add("dock-center");
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/org/dockfx/DockTitleBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,20 @@ public void reset() {
* @param eventTask The event task to be run when the event target is found.
* @param explicit The explicit event to be fired on the stage root when no event target is found.
*/
private void pickEventTarget(Point2D location, EventTask eventTask, Event explicit) {
private void pickEventTarget(Point2D location, EventTask eventTask, Event explicit, Stage context) {
// RFE for public scene graph traversal API filed but closed:
// https://bugs.openjdk.java.net/browse/JDK-8133331

List<DockPane> dockPanes = DockPane.dockPanes;
List<DockPane> dockPanes = DockPane.getDockPanes(context);

// fire the dock over event for the active stages
for (DockPane dockPane : dockPanes) {
if(dockPane.getScene() == null) continue;
Window window = dockPane.getScene().getWindow();
if (!(window instanceof Stage)) continue;
if (!window.isShowing()) {
continue;
}
Stage targetStage = (Stage) window;

// obviously this title bar does not need to receive its own events
Expand Down Expand Up @@ -386,7 +390,7 @@ public void run(Node node, Node dragNode) {
};

this.pickEventTarget(new Point2D(event.getScreenX(), event.getScreenY()), eventTask,
dockExitEvent);
dockExitEvent, stage);
} else if (event.getEventType() == MouseEvent.MOUSE_RELEASED) {
dragging = false;

Expand All @@ -405,7 +409,7 @@ public void run(Node node, Node dragNode) {
}
};

this.pickEventTarget(new Point2D(event.getScreenX(), event.getScreenY()), eventTask, null);
this.pickEventTarget(new Point2D(event.getScreenX(), event.getScreenY()), eventTask, null, (Stage) this.getScene().getWindow());

dragNodes.clear();

Expand Down
21 changes: 3 additions & 18 deletions src/main/java/org/dockfx/demo/DockFX.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,13 @@
import java.nio.file.Paths;
import java.util.Random;

import javafx.scene.control.*;
import org.dockfx.DockNode;
import org.dockfx.DockPane;
import org.dockfx.DockPos;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.Separator;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.ToolBar;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Priority;
Expand All @@ -56,15 +46,10 @@ public void start(Stage primaryStage) {

// create a default test node for the center of the dock area
TabPane tabs = new TabPane();
HTMLEditor htmlEditor = new HTMLEditor();
try {
htmlEditor.setHtmlText(new String(Files.readAllBytes(Paths.get("readme.html"))));
} catch (IOException e) {
e.printStackTrace();
}


// empty tabs ensure that dock node has its own background color when floating
tabs.getTabs().addAll(new Tab("Tab 1", htmlEditor), new Tab("Tab 2"), new Tab("Tab 3"));
tabs.getTabs().addAll(new Tab("Tab 1", new Label("Coontent!")), new Tab("Tab 2"), new Tab("Tab 3"));

TableView<String> tableView = new TableView<String>();
// this is why @SupressWarnings is used above
Expand Down