/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
* Copyright 2008, 2010 Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
* This file is available and licensed under the following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of Oracle Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package projectmanager;
import javafx.animation.Interpolator;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.animation.transition.FadeTransition;
import javafx.scene.*;
import javafx.scene.control.Button;
import javafx.scene.control.ProgressBar;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
public var screenWidth: Number;
public var screenHeight: Number;
public abstract class AppView extends CustomNode {
protected var dataHandler: DataHandler = bind controller.dataHandler;
protected var controller: Controller;
protected var view: Node;
var viewContent: Node[] = [];
protected var defControl: Node = null;
protected function deleteData() {
}
protected abstract function createView(): Void;
public override function create(): Node {
createView();
insert view into viewContent;
return Group {
content: bind viewContent
}
}
public-read protected var progressVal: Number = 0;
var popupWidth = 240;
var popupHeight = 320;
var del_rectWidth_tv = bind popupWidth + 80;
var del_rectWidth = bind popupWidth - 10;
var del_react_width: Number = if(__PROFILE__=="tv") del_rectWidth_tv else del_rectWidth;
var fontSize: Number = 15;
var fontName: String = "Arial";
var fadeOut: FadeTransition = FadeTransition {
duration: 1s
node: bind view
fromValue: 1.0
toValue: 0.3
repeatCount: 1
autoReverse: true
}
var fadeIn: FadeTransition = FadeTransition {
duration: 1s
node: bind view
fromValue: 0.3
toValue: 1.0
repeatCount: 1
autoReverse: true
}
function getFont(name: String, size: Number) {
Font {
name: name
size: size
}
}
public function showProgress (taskName: String) {
progressVal = 0;
var progressTitle: Text = Text {
content: "Opening {taskName}"
font: bind getFont(fontName, fontSize)
wrappingWidth: bind popupWidth - 30
translateY: 20
translateX: 10
fill: Color.BLACK
};
var progressRect: Rectangle = Rectangle {
x: 0
y: 0
width: bind popupWidth - 10
height: bind progressTitle.boundsInLocal.height + 20 + progressBar.boundsInLocal.height
fill: Color.WHITE
stroke: Color.BLACK
strokeWidth: 2
arcWidth: 20
arcHeight: 20
};
var progressBar: ProgressBar = ProgressBar {
progress: bind ProgressBar.computeProgress(100, progressVal)
translateY: bind progressTitle.boundsInLocal.height + 20
translateX: bind (progressRect.boundsInLocal.width - progressBar.boundsInLocal.width) / 2
};
var progressGroup: Group = Group {
content: [progressRect, progressTitle, progressBar]
blocksMouse: true
translateX: bind screenWidth / 2 - progressGroup.boundsInLocal.width / 2 + progressRect.strokeWidth
translateY: bind screenHeight / 2 - progressGroup.boundsInLocal.height / 2
};
insert progressGroup into viewContent;
var t: Timeline = Timeline {
repeatCount: 1
autoReverse: true
keyFrames: [
KeyFrame {
time: 0s
values: [progressVal => 0]
canSkip: true
},
KeyFrame {
time: 2s
values: [progressVal => 100 tween Interpolator.LINEAR]
canSkip: true
action: function() {
fadeIn.playFromStart();
view.disable = false;
delete progressGroup from viewContent;
}
}
]
}
fadeOut.playFromStart();
view.disable = true;
t.play();
}
public function showMessage(message: String) {
var messageText: Text = Text {
content: message
font: bind getFont(fontName, fontSize)
wrappingWidth: bind popupWidth - 30
translateY: 40
translateX: 10
fill: Color.BLACK
}
var messageRect: Rectangle = Rectangle {
x: 0
y: 0
width: bind popupWidth - 10
height: bind messageText.boundsInLocal.height + 40 + buttonBox.boundsInLocal.height
fill: Color.WHITE
stroke: Color.BLACK
strokeWidth: 2
arcWidth: 20
arcHeight: 20
}
var okBut: Button = Button {
text: "OK"
strong: true
action: function() {
messageGroup.visible = false;
view.disable = false;
fadeIn.playFromStart();
}
}
var buttonBox: HBox = HBox {
spacing: 5
content: [okBut]
translateX: bind messageRect.boundsInLocal.width - (okBut.boundsInLocal.width + 10)
translateY: bind messageText.boundsInLocal.height + 35
}
var messageGroup: Group = Group {
content: [messageRect, messageText, buttonBox]
blocksMouse: true
translateX: bind screenWidth / 2 - messageGroup.boundsInLocal.width / 2 + messageRect.strokeWidth
translateY: bind screenHeight / 2 - messageGroup.boundsInLocal.height / 2
}
insert messageGroup into viewContent;
okBut.requestFocus();
view.disable = true;
fadeOut.playFromStart();
}
public function deleteConfirmation(taskName: String) {
var deleteButtonBox: HBox;
var deleteText: Text = Text {
content: bind "Are you sure you want to delete {taskName}?"
font: bind getFont(fontName, fontSize)
wrappingWidth: bind popupWidth - 30
translateY: 40
translateX: 10
fill: Color.BLACK
}
var deleteRect: Rectangle = Rectangle {
x: 0
y: 0
width: del_react_width;
height: bind deleteText.boundsInLocal.height + 40 + deleteButtonBox.boundsInLocal.height
fill: Color.WHITE
stroke: Color.BLACK
strokeWidth: 2
arcWidth: 20
arcHeight: 20
}
var cancelBut: Button = Button {
text: "Cancel"
strong: true
action: function() {
delete deleteGroup from viewContent;
view.disable = false;
fadeIn.playFromStart();
}
}
var deleteBut: Button = Button {
text: "Delete"
action: function() {
delete deleteGroup from viewContent;
deleteData();
view.disable = false;
fadeIn.playFromStart();
}
}
deleteButtonBox = HBox {
spacing: 5
content: [cancelBut, deleteBut]
translateX: bind deleteRect.boundsInLocal.width - (cancelBut.boundsInLocal.width + deleteBut.boundsInLocal.width + 10)
translateY: bind deleteText.boundsInLocal.height + 35
}
var deleteGroup: Group = Group {
content: [deleteRect, deleteText, deleteButtonBox]
blocksMouse: true
translateX: bind screenWidth / 2 - deleteGroup.boundsInLocal.width / 2 + deleteRect.strokeWidth
translateY: bind screenHeight / 2 - deleteGroup.boundsInLocal.height / 2
}
insert deleteGroup into viewContent;
cancelBut.requestFocus();
view.disable = true;
fadeOut.playFromStart();
}
}