use of javafx.scene.control.Toggle in project sis by apache.
the class CoverageExplorer method onViewTypeSet.
/**
* Invoked when a new view type has been specified.
*
* @param type the new way to show coverages in this explorer.
*/
private void onViewTypeSet(final View type) {
final ViewAndControls c = getViewAndControls(type, true);
if (content != null) {
content.getItems().setAll(c.controls(), c.view());
final Toggle selector = c.selector;
if (selector != null) {
selector.setSelected(true);
}
}
}
use of javafx.scene.control.Toggle in project org.csstudio.display.builder by kasemir.
the class RadioRepresentation method updateChanges.
@Override
public void updateChanges() {
super.updateChanges();
if (dirty_size.checkAndClear()) {
// Size
jfx_node.setPrefSize(model_widget.propWidth().getValue(), model_widget.propHeight().getValue());
// Orientation seems more of a hint. JFX will chose based on width vs. height.
jfx_node.setOrientation(model_widget.propHorizontal().getValue() ? Orientation.HORIZONTAL : Orientation.VERTICAL);
}
if (dirty_content.checkAndClear()) {
active = true;
try {
// Copy volatile lists before iteration
final List<String> save_items = new ArrayList<String>(items);
final List<Node> save_buttons = new ArrayList<Node>(jfx_node.getChildren());
// Set text of buttons, adding new ones as needed
int i, save_index = index;
for (i = 0; i < save_items.size(); i++) {
if (i < save_buttons.size())
((RadioButton) save_buttons.get(i)).setText(save_items.get(i));
else
save_buttons.add(createRadioButton(save_items.get(i)));
}
while (i < save_buttons.size() && save_buttons.size() > 1) save_buttons.remove(save_buttons.size() - 1);
// Select one of the radio buttons
toggle.selectToggle(save_index < 0 || save_index >= save_buttons.size() ? null : (Toggle) save_buttons.get(save_index));
jfx_node.getChildren().setAll(save_buttons);
} finally {
active = false;
}
}
if (dirty_style.checkAndClear()) {
final Color fg = JFXUtil.convert(model_widget.propForegroundColor().getValue());
final Font font = JFXUtil.convert(model_widget.propFont().getValue());
for (Node rb_node : jfx_node.getChildren()) {
final RadioButton rb = (RadioButton) rb_node;
rb.setTextFill(fg);
rb.setFont(font);
}
}
}
use of javafx.scene.control.Toggle in project TeachingInSimulation by ScOrPiOzzy.
the class TeacherQuestionPaper method loadQuestions.
private void loadQuestions() {
this.paper.getChildren().clear();
boolean mostWrong = false;
Toggle toggle = order.getSelectedToggle();
if (toggle != null) {
mostWrong = Boolean.valueOf((String) order.getSelectedToggle().getUserData());
}
List<Question> questions = SpringUtil.getBean(QuestionAction.class).findQuestionsByPublish(pid, mostWrong);
for (int i = 0; i < questions.size(); i++) {
int index = i + 1;
Question question = questions.get(i);
PreviewQuestionItem item = new PreviewQuestionItem(index, QuestionType.getQuestionType(question.getType()), question, true);
item.setOnMouseClicked(e -> {
selectQuestion(question, item);
});
paper.getChildren().add(item);
if (i == 0) {
selectQuestion(question, item);
}
}
}
use of javafx.scene.control.Toggle in project TeachingInSimulation by ScOrPiOzzy.
the class PaginationBar method refrash.
/**
* 创建除首页、末页以外的中间页
*/
private void refrash() {
if (content != null) {
content.accept(getPageIndex());
}
pages.getChildren().clear();
pageBtn.getToggles().clear();
first.setDisable(false);
first.setOnAction(e -> {
setPageIndex(0);
});
pages.getChildren().add(first);
pageBtn.getToggles().add(first);
if (getPageCount() == 0) {
first.setDisable(true);
return;
} else if (getPageCount() == 1) {
return;
} else if (getPageCount() <= LIMIT + 1) {
addMiddles(getPageCount() - 2, 2);
} else if (getPageIndex() - LIMIT / 2 <= 1) {
addMiddles(LIMIT - 1, 2);
pages.getChildren().add(etc2);
} else if (getPageIndex() + LIMIT / 2 + 1 >= getPageCount() - 1) {
pages.getChildren().add(etc1);
addMiddles(LIMIT - 1, getPageCount() - LIMIT + 1);
} else {
pages.getChildren().add(etc1);
addMiddles(LIMIT, getPageIndex() + 1 - LIMIT / 2);
pages.getChildren().add(etc2);
}
last.setUserData(getPageCount() - 1);
last.setText(String.valueOf(getPageCount()));
last.setOnAction(e -> {
setPageIndex((int) last.getUserData());
});
pages.getChildren().add(last);
pageBtn.getToggles().add(last);
for (Toggle toggle : pageBtn.getToggles()) {
if (getPageIndex() == (int) toggle.getUserData()) {
toggle.setSelected(true);
}
}
}
use of javafx.scene.control.Toggle in project financial by greatkendy123.
the class MyController method initWhiteVersion.
/**
* 初始化白名单版本
*
* @time 2018年1月4日
*/
private void initWhiteVersion() {
ToggleGroup group = new ToggleGroup();
whiteVersionOld.setToggleGroup(group);
whiteVersionNew.setToggleGroup(group);
// "旧名单"
whiteVersionOld.setUserData(0);
// "新名单"
whiteVersionNew.setUserData(1);
whiteVersionOld.setSelected(true);
log.info("默认导入版本:新名单");
group.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
public void changed(ObservableValue<? extends Toggle> ov, Toggle toggle, Toggle new_toggle) {
Integer version = (Integer) group.getSelectedToggle().getUserData();
if (version == 1) {
log.info("导入版本:新名单");
// ShowUtil.show("新名单版本未开发!!!");
} else {
log.info("导入版本:旧名单");
}
}
});
}
Aggregations