consumer) {
private static interface BiConsumer {
void accept(T t, U u);
}
-
+
}
diff --git a/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/SizeBindings.java b/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/SizeBindings.java
index 95f1460df..0cff4c553 100644
--- a/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/SizeBindings.java
+++ b/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/SizeBindings.java
@@ -24,23 +24,22 @@
import javafx.scene.shape.Rectangle;
/**
- * This class is an helper for binding two components to the same size. It can
- * handle {@link Pane},{@link Node}, {@link ScrollPane}, {@link Rectangle},
- * {@link Control}
+ * This class is an helper for binding two components to the same size. It can handle {@link Pane},{@link Node},
+ * {@link ScrollPane}, {@link Rectangle}, {@link Control}
*
* @author alexander.casall
*
- * @deprecated Use {@link de.saxsys.jfx.mvvm.utils.sizebinding.SizeBindingsBuilder} instead.
- * This class is deprecated because the usage of overloaded methods for different types of components isn't flexible enough.
+ * @deprecated Use {@link de.saxsys.jfx.mvvm.utils.sizebinding.SizeBindingsBuilder} instead. This class is deprecated
+ * because the usage of overloaded methods for different types of components isn't flexible enough.
*
*/
@Deprecated
public final class SizeBindings {
-
+
private SizeBindings() {
}
-
+
/**
* Binds the size of a {@link Pane} to a {@link Pane}.
*
@@ -55,7 +54,7 @@ public static void bindSize(final Pane fromPane, final Pane toPane) {
toPane.minHeightProperty().bind(fromPane.heightProperty());
toPane.maxHeightProperty().bind(fromPane.heightProperty());
}
-
+
/**
* Unbind the size of a {@link Region}.
*
@@ -68,7 +67,7 @@ public static void unbindSize(final Region toPane) {
toPane.minHeightProperty().unbind();
toPane.maxHeightProperty().unbind();
}
-
+
/**
* Unbind the size of a {@link Control}.
*
@@ -81,7 +80,7 @@ public static void unbindSize(final Control toControl) {
toControl.minHeightProperty().unbind();
toControl.maxHeightProperty().unbind();
}
-
+
/**
* Binds the size of a {@link ScrollPane} to a {@link Pane}.
*
@@ -96,7 +95,7 @@ public static void bindSize(final ScrollPane from, final Pane toPane) {
toPane.minHeightProperty().bind(from.heightProperty());
toPane.maxHeightProperty().bind(from.heightProperty());
}
-
+
/**
* Binds the size of a {@link Pane} to a {@link ScrollPane}.
*
@@ -111,7 +110,7 @@ public static void bindSize(final Pane from, final ScrollPane toPane) {
toPane.minHeightProperty().bind(from.heightProperty());
toPane.maxHeightProperty().bind(from.heightProperty());
}
-
+
/**
* Binds the size of a {@link Node} to a {@link Pane}.
*
@@ -144,7 +143,7 @@ public static void bindSize(final Node from, final Pane toPane) {
.bind(((Rectangle) from).heightProperty());
return;
}
-
+
if (from instanceof ImageView) {
toPane.minWidthProperty().bind(
((ImageView) from).fitWidthProperty());
@@ -156,12 +155,12 @@ public static void bindSize(final Node from, final Pane toPane) {
((ImageView) from).fitHeightProperty());
return;
}
-
+
throw new IllegalArgumentException(
"Type of parameter is not mapped yet, please add mapping for type: "
+ from.getClass());
}
-
+
/**
* Binds the size of a {@link Pane} to a {@link Node}.
*
@@ -192,12 +191,12 @@ public static void bindSize(final Pane from, final Node toNode) {
((Rectangle) toNode).heightProperty().bind(from.heightProperty());
return;
}
-
+
throw new IllegalArgumentException(
"Type of parameter is not mapped yet, please add mapping for type: "
+ toNode.getClass());
}
-
+
/**
* Binds the with of a {@link Node} to a {@link Pane}.
*
@@ -223,7 +222,7 @@ public static void bindWidth(final Node from, final Pane toPane) {
return;
}
}
-
+
/**
* Binds the with of a {@link Node} to a {@link Control}.
*
@@ -251,5 +250,5 @@ public static void bindWidth(final Node from, final Control toControl) {
return;
}
}
-
+
}
diff --git a/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/BindHeightBuilderStepImpl.java b/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/BindHeightBuilderStepImpl.java
index 37f735480..3a7f217f7 100644
--- a/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/BindHeightBuilderStepImpl.java
+++ b/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/BindHeightBuilderStepImpl.java
@@ -1,3 +1,18 @@
+/*******************************************************************************
+ * Copyright 2014 Manuel Mauky
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
package de.saxsys.jfx.mvvm.utils.sizebinding;
import javafx.beans.property.ReadOnlyDoubleProperty;
@@ -9,48 +24,56 @@
/**
* Implementation of the Builder steps to bind the height of a given source component to the target component.
*
- * @author manuel.mauky
+ * @author manuel.mauky
*/
-class BindHeightBuilderStepImpl implements SizeBindingsBuilder.BindHeightBuilderStep, SizeBindingsBuilder.FromBindHeightBuilderStep {
-
- private ReadOnlyDoubleProperty height;
-
- @Override
- public void to(Region target) {
- target.maxHeightProperty().bind(height);
- target.minHeightProperty().bind(height);
- }
- @Override
- public void to(Control target) {
- target.maxHeightProperty().bind(height);
- target.minHeightProperty().bind(height);
- }
- @Override
- public void to(Rectangle target) {
- target.heightProperty().bind(height);
- }
- @Override
- public void to(ImageView target){
- target.fitHeightProperty().bind(height);
- }
- @Override
- public SizeBindingsBuilder.FromBindHeightBuilderStep from(Region source) {
- height = source.heightProperty();
- return this;
- }
- @Override
- public SizeBindingsBuilder.FromBindHeightBuilderStep from(Control source) {
- height = source.heightProperty();
- return this;
- }
- @Override
- public SizeBindingsBuilder.FromBindHeightBuilderStep from(Rectangle source) {
- height = source.heightProperty();
- return this;
- }
- @Override
- public SizeBindingsBuilder.FromBindHeightBuilderStep from(ImageView source){
- height = source.fitHeightProperty();
- return this;
- }
+class BindHeightBuilderStepImpl implements SizeBindingsBuilder.BindHeightBuilderStep,
+ SizeBindingsBuilder.FromBindHeightBuilderStep {
+
+ private ReadOnlyDoubleProperty height;
+
+ @Override
+ public void to(Region target) {
+ target.maxHeightProperty().bind(height);
+ target.minHeightProperty().bind(height);
+ }
+
+ @Override
+ public void to(Control target) {
+ target.maxHeightProperty().bind(height);
+ target.minHeightProperty().bind(height);
+ }
+
+ @Override
+ public void to(Rectangle target) {
+ target.heightProperty().bind(height);
+ }
+
+ @Override
+ public void to(ImageView target) {
+ target.fitHeightProperty().bind(height);
+ }
+
+ @Override
+ public SizeBindingsBuilder.FromBindHeightBuilderStep from(Region source) {
+ height = source.heightProperty();
+ return this;
+ }
+
+ @Override
+ public SizeBindingsBuilder.FromBindHeightBuilderStep from(Control source) {
+ height = source.heightProperty();
+ return this;
+ }
+
+ @Override
+ public SizeBindingsBuilder.FromBindHeightBuilderStep from(Rectangle source) {
+ height = source.heightProperty();
+ return this;
+ }
+
+ @Override
+ public SizeBindingsBuilder.FromBindHeightBuilderStep from(ImageView source) {
+ height = source.fitHeightProperty();
+ return this;
+ }
}
diff --git a/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/BindSizeBuilderStepImpl.java b/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/BindSizeBuilderStepImpl.java
index 0a2eaf8d0..98c87532a 100644
--- a/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/BindSizeBuilderStepImpl.java
+++ b/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/BindSizeBuilderStepImpl.java
@@ -1,3 +1,18 @@
+/*******************************************************************************
+ * Copyright 2014 Manuel Mauky
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
package de.saxsys.jfx.mvvm.utils.sizebinding;
import javafx.scene.control.Control;
@@ -10,59 +25,60 @@
*
* @author manuel.mauky
*/
-class BindSizeBuilderStepImpl implements SizeBindingsBuilder.BindSizeBuilderStep, SizeBindingsBuilder.FromBindSizeBuilderStep {
- private SizeBindingsBuilder.FromBindWidthBuilderStep widthStep;
- private SizeBindingsBuilder.FromBindHeightBuilderStep heightStep;
-
- @Override
- public void to(Region target){
- widthStep.to(target);
- heightStep.to(target);
- }
-
- @Override
- public void to(Control target) {
- widthStep.to(target);
- heightStep.to(target);
- }
-
- @Override
- public void to(Rectangle target) {
- widthStep.to(target);
- heightStep.to(target);
- }
-
- @Override
- public void to(ImageView target){
- widthStep.to(target);
- heightStep.to(target);
- }
-
- @Override
- public SizeBindingsBuilder.FromBindSizeBuilderStep from(Region source) {
- widthStep = new BindWidthBuilderStepImpl().from(source);
- heightStep = new BindHeightBuilderStepImpl().from(source);
- return this;
- }
-
- @Override
- public SizeBindingsBuilder.FromBindSizeBuilderStep from(Control source) {
- widthStep = new BindWidthBuilderStepImpl().from(source);
- heightStep = new BindHeightBuilderStepImpl().from(source);
- return this;
- }
-
- @Override
- public SizeBindingsBuilder.FromBindSizeBuilderStep from(Rectangle source) {
- widthStep = new BindWidthBuilderStepImpl().from(source);
- heightStep = new BindHeightBuilderStepImpl().from(source);
- return this;
- }
-
- @Override
- public SizeBindingsBuilder.FromBindSizeBuilderStep from(ImageView source){
- widthStep = new BindWidthBuilderStepImpl().from(source);
- heightStep = new BindHeightBuilderStepImpl().from(source);
- return this;
- }
+class BindSizeBuilderStepImpl implements SizeBindingsBuilder.BindSizeBuilderStep,
+ SizeBindingsBuilder.FromBindSizeBuilderStep {
+ private SizeBindingsBuilder.FromBindWidthBuilderStep widthStep;
+ private SizeBindingsBuilder.FromBindHeightBuilderStep heightStep;
+
+ @Override
+ public void to(Region target) {
+ widthStep.to(target);
+ heightStep.to(target);
+ }
+
+ @Override
+ public void to(Control target) {
+ widthStep.to(target);
+ heightStep.to(target);
+ }
+
+ @Override
+ public void to(Rectangle target) {
+ widthStep.to(target);
+ heightStep.to(target);
+ }
+
+ @Override
+ public void to(ImageView target) {
+ widthStep.to(target);
+ heightStep.to(target);
+ }
+
+ @Override
+ public SizeBindingsBuilder.FromBindSizeBuilderStep from(Region source) {
+ widthStep = new BindWidthBuilderStepImpl().from(source);
+ heightStep = new BindHeightBuilderStepImpl().from(source);
+ return this;
+ }
+
+ @Override
+ public SizeBindingsBuilder.FromBindSizeBuilderStep from(Control source) {
+ widthStep = new BindWidthBuilderStepImpl().from(source);
+ heightStep = new BindHeightBuilderStepImpl().from(source);
+ return this;
+ }
+
+ @Override
+ public SizeBindingsBuilder.FromBindSizeBuilderStep from(Rectangle source) {
+ widthStep = new BindWidthBuilderStepImpl().from(source);
+ heightStep = new BindHeightBuilderStepImpl().from(source);
+ return this;
+ }
+
+ @Override
+ public SizeBindingsBuilder.FromBindSizeBuilderStep from(ImageView source) {
+ widthStep = new BindWidthBuilderStepImpl().from(source);
+ heightStep = new BindHeightBuilderStepImpl().from(source);
+ return this;
+ }
}
diff --git a/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/BindWidthBuilderStepImpl.java b/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/BindWidthBuilderStepImpl.java
index d0d3f0c93..ed1fc30bf 100644
--- a/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/BindWidthBuilderStepImpl.java
+++ b/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/BindWidthBuilderStepImpl.java
@@ -1,3 +1,18 @@
+/*******************************************************************************
+ * Copyright 2014 Manuel Mauky
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
package de.saxsys.jfx.mvvm.utils.sizebinding;
import javafx.beans.property.ReadOnlyDoubleProperty;
@@ -12,46 +27,54 @@
*
* @author manuel.mauky
*/
-class BindWidthBuilderStepImpl implements SizeBindingsBuilder.BindWidthBuilderStep, SizeBindingsBuilder.FromBindWidthBuilderStep {
-
- private ReadOnlyDoubleProperty width;
-
- @Override
- public void to(Region target) {
- target.maxWidthProperty().bind(width);
- target.minWidthProperty().bind(width);
- }
- @Override
- public void to(Control target) {
- target.maxWidthProperty().bind(width);
- target.minWidthProperty().bind(width);
- }
- @Override
- public void to(Rectangle target) {
- target.widthProperty().bind(width);
- }
- @Override
- public void to(ImageView target){
- target.fitWidthProperty().bind(width);
- }
- @Override
- public SizeBindingsBuilder.FromBindWidthBuilderStep from(Region source) {
- width = source.widthProperty();
- return this;
- }
- @Override
- public SizeBindingsBuilder.FromBindWidthBuilderStep from(Control source){
- width = source.widthProperty();
- return this;
- }
- @Override
- public SizeBindingsBuilder.FromBindWidthBuilderStep from(Rectangle source) {
- width = source.widthProperty();
- return this;
- }
- @Override
- public SizeBindingsBuilder.FromBindWidthBuilderStep from(ImageView source){
- width = source.fitWidthProperty();
- return this;
- }
+class BindWidthBuilderStepImpl implements SizeBindingsBuilder.BindWidthBuilderStep,
+ SizeBindingsBuilder.FromBindWidthBuilderStep {
+
+ private ReadOnlyDoubleProperty width;
+
+ @Override
+ public void to(Region target) {
+ target.maxWidthProperty().bind(width);
+ target.minWidthProperty().bind(width);
+ }
+
+ @Override
+ public void to(Control target) {
+ target.maxWidthProperty().bind(width);
+ target.minWidthProperty().bind(width);
+ }
+
+ @Override
+ public void to(Rectangle target) {
+ target.widthProperty().bind(width);
+ }
+
+ @Override
+ public void to(ImageView target) {
+ target.fitWidthProperty().bind(width);
+ }
+
+ @Override
+ public SizeBindingsBuilder.FromBindWidthBuilderStep from(Region source) {
+ width = source.widthProperty();
+ return this;
+ }
+
+ @Override
+ public SizeBindingsBuilder.FromBindWidthBuilderStep from(Control source) {
+ width = source.widthProperty();
+ return this;
+ }
+
+ @Override
+ public SizeBindingsBuilder.FromBindWidthBuilderStep from(Rectangle source) {
+ width = source.widthProperty();
+ return this;
+ }
+
+ @Override
+ public SizeBindingsBuilder.FromBindWidthBuilderStep from(ImageView source) {
+ width = source.fitWidthProperty();
+ return this;
+ }
}
diff --git a/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/SizeBindingsBuilder.java b/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/SizeBindingsBuilder.java
index 474cc9b86..4a3939d56 100644
--- a/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/SizeBindingsBuilder.java
+++ b/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/SizeBindingsBuilder.java
@@ -1,3 +1,18 @@
+/*******************************************************************************
+ * Copyright 2014 Manuel Mauky
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
package de.saxsys.jfx.mvvm.utils.sizebinding;
import javafx.scene.control.Control;
@@ -7,8 +22,7 @@
/**
- * This class is a helper for binding/unbind the size of two components.
- * It can handle the following component types:
+ * This class is a helper for binding/unbind the size of two components. It can handle the following component types:
*
*
* - {@link javafx.scene.layout.Region}
@@ -17,89 +31,98 @@
* - {@link javafx.scene.image.ImageView}
*
*
- * Usage example:
+ * Usage example:
*
*
- * VBox box = new VBox();
- *
- * Rectangle rect = new Rectangle();
- *
- * SizeBindingsBuilder.bindSize().from(box).to(rect);
- *
+ * VBox box = new VBox();
+ *
+ * Rectangle rect = new Rectangle();
+ *
+ * SizeBindingsBuilder.bindSize().from(box).to(rect);
+ *
*
*
- * @author manuel.mauky
+ * @author manuel.mauky
*
*/
public class SizeBindingsBuilder {
-
- public static BindSizeBuilderStep bindSize() {
- return new BindSizeBuilderStepImpl();
- }
-
- public static BindWidthBuilderStep bindWidth() {
- return new BindWidthBuilderStepImpl();
- }
-
- public static BindHeightBuilderStep bindHeight() {
- return new BindHeightBuilderStepImpl();
- }
-
-
- public static UnbindStep unbindSize() {
- return new UnbindSizeBuilderStepImpl();
- }
-
- public static UnbindStep unbindHeight() {
- return new UnbindHeightBuilderStepImpl();
- }
-
- public static UnbindStep unbindWidth() {
- return new UnbindWidthBuilderStepImpl();
- }
-
-
- // BUILDER STEP INTERFACES
-
- static interface BindTargetStep {
- void to(Region target);
- void to(Control target);
- void to(Rectangle target);
- void to(ImageView target);
- }
-
- static interface BindSourceStep {
- A from(Region source);
- A from(Control source);
- A from(Rectangle source);
- A from(ImageView source);
- }
-
- public static interface BindWidthBuilderStep extends BindSourceStep {
- }
-
- public static interface FromBindWidthBuilderStep extends BindTargetStep {
- }
-
- public static interface BindHeightBuilderStep extends BindSourceStep {
- }
-
- public static interface FromBindHeightBuilderStep extends BindTargetStep {
- }
-
- public static interface BindSizeBuilderStep extends BindSourceStep {
- }
-
- public static interface FromBindSizeBuilderStep extends BindTargetStep {
- }
-
-
- public static interface UnbindStep {
- void of(Region source);
- void of(Control source);
- void of(Rectangle source);
- void of(ImageView source);
- }
-
-
+
+ public static BindSizeBuilderStep bindSize() {
+ return new BindSizeBuilderStepImpl();
+ }
+
+ public static BindWidthBuilderStep bindWidth() {
+ return new BindWidthBuilderStepImpl();
+ }
+
+ public static BindHeightBuilderStep bindHeight() {
+ return new BindHeightBuilderStepImpl();
+ }
+
+
+ public static UnbindStep unbindSize() {
+ return new UnbindSizeBuilderStepImpl();
+ }
+
+ public static UnbindStep unbindHeight() {
+ return new UnbindHeightBuilderStepImpl();
+ }
+
+ public static UnbindStep unbindWidth() {
+ return new UnbindWidthBuilderStepImpl();
+ }
+
+
+ // BUILDER STEP INTERFACES
+
+ static interface BindTargetStep {
+ void to(Region target);
+
+ void to(Control target);
+
+ void to(Rectangle target);
+
+ void to(ImageView target);
+ }
+
+ static interface BindSourceStep {
+ A from(Region source);
+
+ A from(Control source);
+
+ A from(Rectangle source);
+
+ A from(ImageView source);
+ }
+
+ public static interface BindWidthBuilderStep extends BindSourceStep {
+ }
+
+ public static interface FromBindWidthBuilderStep extends BindTargetStep {
+ }
+
+ public static interface BindHeightBuilderStep extends BindSourceStep {
+ }
+
+ public static interface FromBindHeightBuilderStep extends BindTargetStep {
+ }
+
+ public static interface BindSizeBuilderStep extends BindSourceStep {
+ }
+
+ public static interface FromBindSizeBuilderStep extends BindTargetStep {
+ }
+
+
+ public static interface UnbindStep {
+ void of(Region source);
+
+ void of(Control source);
+
+ void of(Rectangle source);
+
+ void of(ImageView source);
+ }
+
+
}
diff --git a/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/UnbindHeightBuilderStepImpl.java b/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/UnbindHeightBuilderStepImpl.java
index 3c0a3e58a..dfd6ca55d 100644
--- a/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/UnbindHeightBuilderStepImpl.java
+++ b/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/UnbindHeightBuilderStepImpl.java
@@ -1,3 +1,18 @@
+/*******************************************************************************
+ * Copyright 2014 Manuel Mauky
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
package de.saxsys.jfx.mvvm.utils.sizebinding;
import javafx.scene.control.Control;
@@ -11,25 +26,25 @@
* @author manuel.mauky
*/
class UnbindHeightBuilderStepImpl implements SizeBindingsBuilder.UnbindStep {
- @Override
- public void of(Region source) {
- source.maxHeightProperty().unbind();
- source.minHeightProperty().unbind();
- }
-
- @Override
- public void of(Control source) {
- source.maxHeightProperty().unbind();
- source.minHeightProperty().unbind();
- }
-
- @Override
- public void of(Rectangle source) {
- source.heightProperty().unbind();
- }
-
- @Override
- public void of(ImageView source) {
- source.fitHeightProperty().unbind();
- }
+ @Override
+ public void of(Region source) {
+ source.maxHeightProperty().unbind();
+ source.minHeightProperty().unbind();
+ }
+
+ @Override
+ public void of(Control source) {
+ source.maxHeightProperty().unbind();
+ source.minHeightProperty().unbind();
+ }
+
+ @Override
+ public void of(Rectangle source) {
+ source.heightProperty().unbind();
+ }
+
+ @Override
+ public void of(ImageView source) {
+ source.fitHeightProperty().unbind();
+ }
}
diff --git a/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/UnbindSizeBuilderStepImpl.java b/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/UnbindSizeBuilderStepImpl.java
index 55cd3e817..a93513249 100644
--- a/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/UnbindSizeBuilderStepImpl.java
+++ b/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/UnbindSizeBuilderStepImpl.java
@@ -1,3 +1,18 @@
+/*******************************************************************************
+ * Copyright 2014 Manuel Mauky
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
package de.saxsys.jfx.mvvm.utils.sizebinding;
import javafx.scene.control.Control;
@@ -11,27 +26,27 @@
* @author manuel.mauky
*/
class UnbindSizeBuilderStepImpl implements SizeBindingsBuilder.UnbindStep {
- @Override
- public void of(Region source) {
- new UnbindWidthBuilderStepImpl().of(source);
- new UnbindHeightBuilderStepImpl().of(source);
- }
-
- @Override
- public void of(Control source) {
- new UnbindWidthBuilderStepImpl().of(source);
- new UnbindHeightBuilderStepImpl().of(source);
- }
-
- @Override
- public void of(Rectangle source) {
- new UnbindWidthBuilderStepImpl().of(source);
- new UnbindHeightBuilderStepImpl().of(source);
- }
-
- @Override
- public void of(ImageView source) {
- new UnbindWidthBuilderStepImpl().of(source);
- new UnbindHeightBuilderStepImpl().of(source);
- }
+ @Override
+ public void of(Region source) {
+ new UnbindWidthBuilderStepImpl().of(source);
+ new UnbindHeightBuilderStepImpl().of(source);
+ }
+
+ @Override
+ public void of(Control source) {
+ new UnbindWidthBuilderStepImpl().of(source);
+ new UnbindHeightBuilderStepImpl().of(source);
+ }
+
+ @Override
+ public void of(Rectangle source) {
+ new UnbindWidthBuilderStepImpl().of(source);
+ new UnbindHeightBuilderStepImpl().of(source);
+ }
+
+ @Override
+ public void of(ImageView source) {
+ new UnbindWidthBuilderStepImpl().of(source);
+ new UnbindHeightBuilderStepImpl().of(source);
+ }
}
diff --git a/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/UnbindWidthBuilderStepImpl.java b/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/UnbindWidthBuilderStepImpl.java
index cd769949d..cbbdbebb9 100644
--- a/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/UnbindWidthBuilderStepImpl.java
+++ b/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/utils/sizebinding/UnbindWidthBuilderStepImpl.java
@@ -1,3 +1,18 @@
+/*******************************************************************************
+ * Copyright 2014 Manuel Mauky
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
package de.saxsys.jfx.mvvm.utils.sizebinding;
import javafx.scene.control.Control;
@@ -11,27 +26,27 @@
* @author manuel.mauky
*/
class UnbindWidthBuilderStepImpl implements SizeBindingsBuilder.UnbindStep {
-
- @Override
- public void of(Region source) {
- source.maxWidthProperty().unbind();
- source.minWidthProperty().unbind();
- }
-
- @Override
- public void of(Control source) {
- source.maxWidthProperty().unbind();
- source.minWidthProperty().unbind();
-
- }
-
- @Override
- public void of(Rectangle source) {
- source.widthProperty().unbind();
- }
-
- @Override
- public void of(ImageView source) {
- source.fitWidthProperty().unbind();
- }
+
+ @Override
+ public void of(Region source) {
+ source.maxWidthProperty().unbind();
+ source.minWidthProperty().unbind();
+ }
+
+ @Override
+ public void of(Control source) {
+ source.maxWidthProperty().unbind();
+ source.minWidthProperty().unbind();
+
+ }
+
+ @Override
+ public void of(Rectangle source) {
+ source.widthProperty().unbind();
+ }
+
+ @Override
+ public void of(ImageView source) {
+ source.fitWidthProperty().unbind();
+ }
}
diff --git a/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/viewloader/DependencyInjector.java b/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/viewloader/DependencyInjector.java
index c9cfdfe7e..056c61c5d 100644
--- a/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/viewloader/DependencyInjector.java
+++ b/mvvmfx/src/main/java/de/saxsys/jfx/mvvm/viewloader/DependencyInjector.java
@@ -12,146 +12,147 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-******************************************************************************/
+ ******************************************************************************/
package de.saxsys.jfx.mvvm.viewloader;
-import de.saxsys.jfx.mvvm.api.InjectViewModel;
-import de.saxsys.jfx.mvvm.base.view.View;
-import javafx.util.Callback;
-import net.jodah.typetools.TypeResolver;
-
import java.lang.reflect.Field;
import java.security.AccessController;
import java.security.PrivilegedAction;
+import javafx.util.Callback;
+
+import net.jodah.typetools.TypeResolver;
+import de.saxsys.jfx.mvvm.api.InjectViewModel;
+import de.saxsys.jfx.mvvm.base.view.View;
/**
* This class handles the dependency injection for the mvvmFX framework.
*
- * The main reason for this class is to make it possible for the user
- * to use her own dependency injection mechanism/framework.
- * The user can define how instances should be retrieved by setting an callback that
- * returns an instance for a given class type (see {@link DependencyInjector#setCustomInjector}.
+ * The main reason for this class is to make it possible for the user to use her own dependency injection
+ * mechanism/framework. The user can define how instances should be retrieved by setting an callback that returns an
+ * instance for a given class type (see {@link DependencyInjector#setCustomInjector}.
*
- * @author manuel.mauky
+ * @author manuel.mauky
*/
public class DependencyInjector {
-
- private Callback, Object> customInjector;
-
- private static DependencyInjector singleton = new DependencyInjector();
-
- DependencyInjector(){
- }
-
- public static DependencyInjector getInstance(){
- return singleton;
- }
-
-
- /**
- * Define a custom injector that is used to retrieve instances. This can be used
- * as a bridge to you dependency injection framework.
- *
- * The callback has to return an instance for the given class type. This is
- * same way as it is done in the {@link javafx.fxml.FXMLLoader#setControllerFactory(javafx.util.Callback)}
- * method.
- *
- * @param callback the callback that returns instances of a specific class type.
- */
- public void setCustomInjector(Callback, Object> callback){
- this.customInjector = callback;
- }
-
- /**
- * Returns an instance of the given type. When there is a custom injector defined (See: {@link #setCustomInjector(javafx.util.Callback)})
- * then this injector is used.
- * Otherwise a new instance of the desired type is created. This is done by a call to {@link Class#newInstance()} which means that all constraints
- * of the newInstance method are also need to be satisfied.
- *
- * @param type
- * @param
- * @return
- */
- T getInstanceOf(Class extends T> type){
- T instance = getUninitializedInstanceOf(type);
-
- if(instance instanceof View){
- injectViewModel((View)instance);
- }
-
- return instance;
- }
-
- void injectViewModel(final View view) {
- final Class> viewModelType = TypeResolver.resolveRawArgument(View.class, view.getClass());
- final Field field = getViewModelField(view.getClass(), viewModelType);
-
- if(field != null){
- AccessController.doPrivileged(new PrivilegedAction