Skip to content

Commit

Permalink
Bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbodogit committed Jan 16, 2016
1 parent 6140383 commit f89b031
Show file tree
Hide file tree
Showing 12 changed files with 210 additions and 138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,84 +15,88 @@
import javafx.scene.layout.StackPane;

public class SingleDockContainer extends StackPane implements DockContainer {

private DockContainer container;

@Override
public void putDock(DockNode node, DockNode.DOCK_POSITION position, double percentage) {

if (getChildren().isEmpty()) {
getChildren().add(node);
node.setParentContainer(this);
} else {
manageSubContainers(node, position,percentage);
manageSubContainers(node, position, percentage);
}
}

@Override
public void putDock(DockNode node, DockNode nodeTarget, DockNode.DOCK_POSITION position, double percentage) {

if (getChildren().get(0) == nodeTarget)
{
manageSubContainers(node, position,percentage);

if (getChildren().get(0) == nodeTarget) {
manageSubContainers(node, position, percentage);
}
}

@Override
public boolean isDockVisible(DockNode node)
{
public boolean isDockVisible(DockNode node) {
return true;
}

@Override
public int indexOf(Node node) {
return (getChildren().get(0) == node) ? 0 : -1;
}

@Override
public void removeNode(Node node) {
getChildren().remove(node);
((DockContainableComponent) node).setParentContainer(null);
}

@Override
public void insertNode(Node node, int index) {
getChildren().set(index, node);

((DockContainableComponent) node).setParentContainer(this);
}

@Override
public void undock(DockNode node) {
if (getChildren().get(0) == node) {
getChildren().remove(node);
node.setParentContainer(null);
}
}
private void manageSubContainers(DockNode node, DockNode.DOCK_POSITION position,double percentage) {

private void manageSubContainers(DockNode node, DockNode.DOCK_POSITION position, double percentage) {
Node existNode = getChildren().get(0);
getChildren().remove(existNode);


if (DockCommons.isABorderPosition(position)) {
DockSplitterContainer splitter = DockCommons.createSplitter(existNode, node, position,percentage);
getChildren().remove(existNode);
DockSplitterContainer splitter = DockCommons.createSplitter(existNode, node, position, percentage);
getChildren().add(splitter);
splitter.setParentContainer(this);
} else if (existNode instanceof DockTabberContainer) {

DockTabberContainer tabber = (DockTabberContainer)existNode;
tabber.putDock(node, DockNode.DOCK_POSITION.CENTER, percentage);
} else {
getChildren().remove(existNode);
DockTabberContainer tabber = DockCommons.createTabber(existNode, node, position);
getChildren().add(tabber);
tabber.setParentContainer(this);
}
}

@Override
public void setParentContainer(DockContainer container) {
this.container = container;
}

@Override
public DockContainer getParentContainer() {
return container;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ public static DockTabberContainer createTabber(Node existNode, Node newNode, Doc

tabber.getStyleClass().add("docknode-tab-pane");

newDockNode.ensureVisibility();

return tabber;
}
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.anchorage.docks.containers.interfaces;


/**
*
* @author Alessio
*/
public interface DockContainableComponent {

public void setParentContainer(DockContainer container);
public DockContainer getParentContainer();

}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.anchorage.docks.containers.interfaces;


/**
*
* @author Alessio
*/
public interface DockContainableComponent {

public void setParentContainer(DockContainer container);
public DockContainer getParentContainer();

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@ public final class DockTabberContainer extends TabPane implements DockContainer

@Override
public void putDock(DockNode node, DockNode.DOCK_POSITION position, double percentage) {

Tab newTab = new Tab(node.getContent().titleProperty().get());
newTab.closableProperty().bind(node.closeableProperty());
getTabs().add(newTab);
newTab.setContent(node);
node.setParentContainer(this);
node.ensureVisibility();
}

private void createSplitter(DockNode node, DockNode.DOCK_POSITION position) {
DockContainer currentContainer = container;

DockSplitterContainer splitter = DockCommons.createSplitter(this, node, position,0.5);
DockSplitterContainer splitter = DockCommons.createSplitter(this, node, position, 0.5);

int indexOf = currentContainer.indexOf(this);

Expand All @@ -54,8 +59,7 @@ public boolean isDockVisible(DockNode node) {
public void putDock(DockNode node, DockNode nodeTarget, DockNode.DOCK_POSITION position, double percentage) {
if (position != DockNode.DOCK_POSITION.CENTER) {
createSplitter(node, position);
}
else {
} else {

DockContainableComponent containableComponent = (DockContainableComponent) node;
if (containableComponent.getParentContainer() != this) {
Expand All @@ -64,6 +68,7 @@ public void putDock(DockNode node, DockNode nodeTarget, DockNode.DOCK_POSITION p
getTabs().add(newTab);
newTab.setContent(node);
node.setParentContainer(this);
node.ensureVisibility();
}
}
}
Expand Down Expand Up @@ -129,14 +134,13 @@ public void manageDragOnSameNode(DockNode node, DockNode.DOCK_POSITION position)
DockNode otherNode = (getTabs().get(0).getContent() == node) ? (DockNode) getTabs().get(1).getContent() : (DockNode) getTabs().get(0).getContent();
node.undock();
node.dock(otherNode, position);
}
else if (getTabByNode(node) != null && getTabs().size() > 2) {
} else if (getTabByNode(node) != null && getTabs().size() > 2) {

node.undock();

DockContainer currentContainer = container;

DockSplitterContainer splitter = DockCommons.createSplitter(this, node, position,0.5);
DockSplitterContainer splitter = DockCommons.createSplitter(this, node, position, 0.5);

int indexOf = currentContainer.indexOf(this);

Expand All @@ -151,7 +155,7 @@ else if (getTabByNode(node) != null && getTabs().size() > 2) {
}

public void ensureVisibility(DockNode node) {

Tab tabNode = getTabByNode(node);
getSelectionModel().select(tabNode);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,17 @@ private void makePreview(ZoneSelector selector, DockNode currentNodeTarget) {
showPreview(sceneBounds,selector);
}
else {
Bounds sceneBounds = currentNodeTarget.localToScene(currentNodeTarget.getBoundsInParent());
Bounds nodeSceneBounds = currentNodeTarget.localToScene(currentNodeTarget.getBoundsInLocal());
Bounds stationSceneBounds = ownerStation.localToScene(ownerStation.getBoundsInLocal());

Bounds sceneBounds = new BoundingBox(nodeSceneBounds.getMinX()-stationSceneBounds.getMinX(),
nodeSceneBounds.getMinY()-stationSceneBounds.getMinY(),
nodeSceneBounds.getWidth(),nodeSceneBounds.getHeight());

if (ownerStation.isSubStation())
{
DockSubStation subStationNode = ownerStation.getDockNodeForSubStation();

if (subStationNode.floatingProperty().get())
{
sceneBounds = new BoundingBox(sceneBounds.getMinX()-FLOATING_NODE_DROPSHADOW_RADIUS-subStationNode.getFloatableStage().getPaddingOffset().getLeft(),
Expand Down
Loading

0 comments on commit f89b031

Please sign in to comment.