use of javafx.beans.value.ObservableValue in project Gargoyle by callakrsos.
the class TextSameLineDiffAppController method initialize.
@FXML
public void initialize() {
/* initControls */
ivReviced = new ImageView();
ivpReviced = new ImageViewPane(ivReviced);
ivpReviced.setPrefWidth(200);
ivpReviced.setPrefHeight(150);
ivOrigin = new ImageView();
ivpOrigin = new ImageViewPane(ivOrigin);
ivpOrigin.setPrefWidth(200);
ivpOrigin.setPrefHeight(150);
gpSnap.add(ivpReviced, 0, 0);
gpSnap.add(ivpOrigin, 1, 0);
lvOrinal.setCellFactory(param -> new DefaultTextFieldListCell(ORIGINAL));
lvRevice.setCellFactory(param -> new DefaultTextFieldListCell(REVICED));
fileCompareResultProperty.addListener((oba, oldresult, newresult) -> {
if (newresult == null)
return;
List<ChunkWrapper> wrapperedOrigin = extractedWrapperedChunk(DeltaType.ORIGINAL, newresult);
List<ChunkWrapper> wrapperedReviced = extractedWrapperedChunk(DeltaType.REVICED, newresult);
lvOrinal.getItems().addAll(wrapperedOrigin);
lvRevice.getItems().addAll(wrapperedReviced);
tvChgHis.getItems().addAll(wrapperedOrigin.stream().filter(w -> w.getDelta() != null).collect(Collectors.toList()));
});
lvRevice.setOnMouseClicked(event -> {
if (event.getClickCount() == 2) {
int movePosition = -1;
ChunkWrapper selectedItem = lvRevice.getSelectionModel().getSelectedItem();
Delta delta = selectedItem.getDelta();
if (delta != null && delta.getOriginal() != null) {
movePosition = selectedItem.getPosition();
lvOrinal.scrollTo(movePosition - 1);
lvOrinal.getSelectionModel().select(movePosition);
}
}
});
lvOrinal.setOnMouseClicked(event -> {
if (event.getClickCount() == 2) {
int movePosition = -1;
ChunkWrapper selectedItem = lvOrinal.getSelectionModel().getSelectedItem();
Delta delta = selectedItem.getDelta();
if (delta != null && delta.getRevised() != null) {
movePosition = delta.getRevised().getPosition();
lvRevice.scrollTo(movePosition - 1);
lvRevice.getSelectionModel().select(movePosition);
}
}
});
lvOrinal.addEventFilter(ScrollEvent.SCROLL, event -> {
snappOriginShot();
});
lvRevice.addEventFilter(ScrollEvent.SCROLL, event -> {
snappReviceShot();
});
btnCompare.setOnMouseClicked(event -> {
String ori = txtOrigin.getText();
String rev = txtRevice.getText();
if (!(ori.isEmpty() && rev.isEmpty())) {
clear();
try {
this.compare.setOriginal(ori);
this.compare.setRevised(rev);
CompareResult chunkResult = this.compare.getChunkResult();
this.fileCompareResultProperty.set(chunkResult);
snappOriginShot();
snappReviceShot();
} catch (Exception e) {
e.printStackTrace();
}
}
});
colStatus.setCellValueFactory(new Callback<CellDataFeatures<ChunkWrapper, String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(CellDataFeatures<ChunkWrapper, String> param) {
TYPE type = param.getValue().getType();
StringProperty prop = new SimpleStringProperty();
if (type != null)
prop.set(type.name());
return prop;
}
});
colPosition.setCellValueFactory(param -> new SimpleIntegerProperty(new Integer(param.getValue().getPosition() + 1)));
colRevice.setCellValueFactory(param -> {
Delta delta = param.getValue().getDelta();
SimpleStringProperty prop = new SimpleStringProperty();
if (delta != null) {
Chunk c = delta.getRevised();
prop.setValue(c.getLines().toString());
}
return prop;
});
colOrigin.setCellValueFactory(param -> {
Delta delta = param.getValue().getDelta();
SimpleStringProperty prop = new SimpleStringProperty();
if (delta != null) {
Chunk c = delta.getOriginal();
prop.setValue(c.getLines().toString());
}
return prop;
});
}
use of javafx.beans.value.ObservableValue in project Gargoyle by callakrsos.
the class HtmlBaseDiffAppController method initialize.
@FXML
public void initialize() {
/* initControls */
ivReviced = new ImageView();
ivpReviced = new ImageViewPane(ivReviced);
ivpReviced.setPrefWidth(200);
ivpReviced.setPrefHeight(150);
ivOrigin = new ImageView();
ivpOrigin = new ImageViewPane(ivOrigin);
ivpOrigin.setPrefWidth(200);
ivpOrigin.setPrefHeight(150);
gpSnap.add(ivpReviced, 0, 0);
gpSnap.add(ivpOrigin, 1, 0);
// lvOrinal.setCellFactory(param -> new
// DefaultTextFieldListCell(ORIGINAL));
// lvRevice.setCellFactory(param -> new
// DefaultTextFieldListCell(REVICED));
fileCompareResultProperty.addListener((oba, oldresult, newresult) -> {
if (newresult == null)
return;
// List<ChunkWrapper> wrapperedOrigin =
// extractedWrapperedChunk(DeltaType.ORIGINAL, newresult);
// List<ChunkWrapper> wrapperedReviced =
// extractedWrapperedChunk(DeltaType.REVICED, newresult);
// lvOrinal.getItems().addAll(wrapperedOrigin);
// lvRevice.getItems().addAll(wrapperedReviced);
// tvChgHis.getItems().addAll(wrapperedOrigin.stream().filter(w
// -> w.getDelta() != null).collect(Collectors.toList()));
});
// lvRevice.setOnMouseClicked(event -> {
// if (event.getClickCount() == 2) {
// int movePosition = -1;
// ChunkWrapper selectedItem =
// lvRevice.getSelectionModel().getSelectedItem();
// Delta delta = selectedItem.getDelta();
// if (delta != null && delta.getOriginal() != null) {
// movePosition = selectedItem.getPosition();
// lvOrinal.scrollTo(movePosition - 1);
// lvOrinal.getSelectionModel().select(movePosition);
// }
//
// }
// });
// lvOrinal.setOnMouseClicked(event -> {
// if (event.getClickCount() == 2) {
// int movePosition = -1;
// ChunkWrapper selectedItem =
// lvOrinal.getSelectionModel().getSelectedItem();
// Delta delta = selectedItem.getDelta();
// if (delta != null && delta.getRevised() != null) {
// movePosition = delta.getRevised().getPosition();
// lvRevice.scrollTo(movePosition - 1);
// lvRevice.getSelectionModel().select(movePosition);
// }
// }
//
// });
// lvOrinal.addEventFilter(ScrollEvent.SCROLL, event -> {
// snappOriginShot();
// });
//
// lvRevice.addEventFilter(ScrollEvent.SCROLL, event -> {
// snappReviceShot();
// });
btnCompare.setOnMouseClicked(event -> {
String ori = txtOrigin.getText();
String rev = txtRevice.getText();
if (!(ori.isEmpty() && rev.isEmpty())) {
clear();
try {
this.compare.setOriginal(ori);
this.compare.setRevised(rev);
CompareResult chunkResult = this.compare.getChunkResult();
this.fileCompareResultProperty.set(chunkResult);
snappOriginShot();
snappReviceShot();
} catch (Exception e) {
e.printStackTrace();
}
}
});
colStatus.setCellValueFactory(new Callback<CellDataFeatures<ChunkWrapper, String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(CellDataFeatures<ChunkWrapper, String> param) {
TYPE type = param.getValue().getType();
StringProperty prop = new SimpleStringProperty();
if (type != null)
prop.set(type.name());
return prop;
}
});
colPosition.setCellValueFactory(param -> new SimpleIntegerProperty(new Integer(param.getValue().getPosition() + 1)));
colRevice.setCellValueFactory(param -> {
Delta delta = param.getValue().getDelta();
SimpleStringProperty prop = new SimpleStringProperty();
if (delta != null) {
Chunk c = delta.getRevised();
prop.setValue(c.getLines().toString());
}
return prop;
});
colOrigin.setCellValueFactory(param -> {
Delta delta = param.getValue().getDelta();
SimpleStringProperty prop = new SimpleStringProperty();
if (delta != null) {
Chunk c = delta.getOriginal();
prop.setValue(c.getLines().toString());
}
return prop;
});
}
use of javafx.beans.value.ObservableValue in project uPMT by coco35700.
the class TypeTreeViewControllerClass method rename.
@Override
public void rename() {
super.rename();
ChangeListener<Boolean> listener = new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldPropertyValue, Boolean newPropertyValue) {
if (!newPropertyValue) {
if (type.getType().isCategory()) {
String oldName = new String(type.getType().getName());
if (!oldName.equals(textField.getText())) {
boolean hasName = false;
// System.out.println("Parent: "+type.getParent().getName());
for (Type classe : type.getParent().getTypes()) {
// System.out.println("Classes: "+classe.getName());
if (classe.getName().equals(textField.getText())) {
hasName = true;
break;
}
}
if (!hasName) {
RenameClassSchemeCommand cmd = new RenameClassSchemeCommand(type.getClassNameController(), oldName, textField.getText(), main);
cmd.execute();
UndoCollector.INSTANCE.add(cmd);
} else {
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle(main._langBundle.getString("invalid_name"));
alert.setHeaderText(null);
alert.setContentText(main._langBundle.getString("class_name_invalid"));
alert.show();
}
}
}
typePane.setLeft(nomType);
rename.setDisable(false);
textField.focusedProperty().removeListener(this);
}
}
};
textField.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event) {
if (event.getCode() == KeyCode.ENTER) {
if (type.getType().isProperty()) {
textField.setText(textField.getText());
}
typePane.setLeft(nomType);
rename.setDisable(false);
}
if (event.getCode() == KeyCode.ESCAPE) {
typePane.setLeft(nomType);
rename.setDisable(true);
}
}
});
textField.focusedProperty().addListener(listener);
typePane.setLeft(textField);
Platform.runLater(() -> textField.requestFocus());
Platform.runLater(() -> textField.selectAll());
}
use of javafx.beans.value.ObservableValue in project Board-Instrumentation-Framework by intel.
the class Marvin method testAppSize.
/*
private void LoadApplication(Stage stage)
{
stage.setIconified(true);
_Config = new ConfigurationReader();
if (null == _Config)
{
return;
}
Configuration config = _Config.ReadStartupInfo(ConfigFilename);
if (null == config)
{
return;
}
_objTabPane = new TabPane();
_objTabPane.setSide(config.getSide());
GridPane sceneGrid = new GridPane();
GridPane.setHalignment(_Config.getConfiguration().getMenuBar(), HPos.LEFT);
GridPane.setValignment(_Config.getConfiguration().getMenuBar(), VPos.TOP);
sceneGrid.add(_Config.getConfiguration().getMenuBar(), 0, 0);
sceneGrid.add(_objTabPane, 0, 1);
Scene scene = null;
Rectangle2D visualBounds = _Config.getConfiguration().getPrimaryScreen().getVisualBounds();
int appWidth = (int) visualBounds.getWidth();
int appHeight = (int) visualBounds.getHeight();
if (config.getWidth() > 0)
{
appWidth = config.getWidth();
}
else
{
config.setWidth(appWidth);
}
if (config.getHeight() > 0)
{
appHeight = config.getHeight();
}
else
{
config.setHeight(appHeight);
}
scene = new Scene(sceneGrid);
SetAppStyle(scene.getStylesheets());
stage.setScene(scene);
stage.setIconified(true);
stage.setX(_Config.getConfiguration().getPrimaryScreen().getVisualBounds().getMinX());
stage.setY(_Config.getConfiguration().getPrimaryScreen().getVisualBounds().getMinY());
stage.setMaximized(true);
stage.addEventHandler(WindowEvent.WINDOW_SHOWN, new EventHandler<WindowEvent>()
{
@Override
public void handle(WindowEvent window)
{
FinishLoad(stage);
}
});
while (false && !_SizeCheckWindowShowing)
{
try
{
Thread.sleep(100);
}
catch (InterruptedException ex)
{
Logger.getLogger(Marvin.class.getName()).log(Level.SEVERE, null, ex);
}
}
FinishLoad(stage);
}
*/
// / pop up quick simple tab,menu and style it, then grab the size of the window
// / so we know the canvas dimenstions
private void testAppSize(Stage stage) {
final GridPane stagePane = new GridPane();
final GridPane canvasPane = new GridPane();
canvasPane.setAlignment(Pos.TOP_LEFT);
_Config = new ConfigurationReader();
final Configuration basicConfig = _Config.ReadStartupInfo(ConfigFilename);
stage.setX(basicConfig.getPrimaryScreen().getVisualBounds().getMinX());
stage.setY(basicConfig.getPrimaryScreen().getVisualBounds().getMinY());
TabPane tabPane = new TabPane();
Tab objTab = new Tab();
final Side tabSide = basicConfig.getSide();
if (tabSide == Side.TOP || tabSide == Side.BOTTOM) {
tabPane.setSide(Side.TOP);
} else {
tabPane.setSide(Side.LEFT);
}
objTab.setText("");
tabPane.getTabs().add(objTab);
stagePane.add(tabPane, 0, 1);
MenuBar objMenuBar = new MenuBar();
if (basicConfig.getShowMenuBar()) {
Menu objMenu = new Menu("About");
MenuItem objItem = new MenuItem("Dummy");
objMenu.getItems().add(objItem);
objMenuBar.getMenus().add(objMenu);
stagePane.add(objMenuBar, 0, 0);
}
if (basicConfig.getEnableScrollBars()) {
ScrollPane testScrollPane = new ScrollPane();
testScrollPane.setPannable(true);
testScrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);
testScrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);
testScrollPane.setContent(canvasPane);
objTab.setContent(testScrollPane);
} else {
objTab.setContent(canvasPane);
}
stage.setTitle(basicConfig.getAppTitle());
Scene scene = new Scene(stagePane);
stage.setScene(scene);
SetAppStyle(scene.getStylesheets());
stage.addEventHandler(WindowEvent.WINDOW_SHOWN, new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent window) {
scene.heightProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneHeight, Number newSceneHeight) {
scene.heightProperty().removeListener(this);
Point2D canvasInScene = canvasPane.localToScene(0.0, 0.0);
int cvHeight;
int cvWidth;
if (tabSide == Side.TOP || tabSide == Side.BOTTOM) {
cvHeight = (int) (scene.getHeight() - canvasInScene.getY());
cvWidth = (int) scene.getWidth();
} else {
cvHeight = (int) (scene.getHeight() - canvasInScene.getY());
cvWidth = (int) (scene.getWidth() - canvasInScene.getX());
}
basicConfig.setCanvasWidth(cvWidth);
basicConfig.setCanvasHeight(cvHeight);
stage.setIconified(true);
Platform.runLater(new Runnable() {
@Override
public void run() {
FinishLoad(stage);
}
});
}
});
}
});
stage.show();
if (basicConfig.getWidth() > 0) {
stage.setWidth(basicConfig.getWidth());
stage.setHeight(basicConfig.getHeight());
} else {
stage.setMaximized(true);
}
}
use of javafx.beans.value.ObservableValue in project Board-Instrumentation-Framework by intel.
the class DoubleBarGaugeWidget method Create.
public boolean Create(GridPane pane, DataManager dataMgr) {
SetParent(pane);
if (false == SetupGauge()) {
return false;
}
_Gauge.setInnerValue(_InitialValue);
_Gauge.setOuterValue(_InitialValue);
ConfigureAlignment();
SetupPeekaboo(dataMgr);
ConfigureDimentions();
pane.add(_Gauge, getColumn(), getRow(), getColumnSpan(), getRowSpan());
dataMgr.AddListener(getMinionID(), getNamespace(), new ChangeListener() {
@Override
public void changed(ObservableValue o, Object oldVal, Object newVal) {
if (IsPaused()) {
return;
}
double newDialValue = 0;
String strVal = newVal.toString();
try {
newDialValue = Double.parseDouble(strVal);
} catch (NumberFormatException ex) {
LOGGER.severe("Invalid data for BarGauge received: " + strVal);
return;
}
_Gauge.setInnerValue(newDialValue);
}
});
if (null == _OuterID || null == _OuterNamespace) {
LOGGER.severe("No Outter Data source defined for BarGauge");
return false;
}
dataMgr.AddListener(_OuterID, _OuterNamespace, new ChangeListener() {
@Override
public void changed(ObservableValue o, Object oldVal, Object newVal) {
if (IsPaused()) {
return;
}
double newDialValue = 0;
String strVal = newVal.toString();
try {
newDialValue = Double.parseDouble(strVal);
} catch (NumberFormatException ex) {
LOGGER.severe("Invalid data for BarGauge received: " + strVal);
return;
}
_Gauge.setOuterValue(newDialValue);
}
});
return true;
}
Aggregations