Search in sources :

Example 6 with Toggle

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);
        }
    }
}
Also used : Toggle(javafx.scene.control.Toggle)

Example 7 with Toggle

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);
        }
    }
}
Also used : Node(javafx.scene.Node) Toggle(javafx.scene.control.Toggle) Color(javafx.scene.paint.Color) ArrayList(java.util.ArrayList) RadioButton(javafx.scene.control.RadioButton) Font(javafx.scene.text.Font)

Example 8 with Toggle

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);
        }
    }
}
Also used : QuestionAction(com.cas.sim.tis.action.QuestionAction) Toggle(javafx.scene.control.Toggle) Question(com.cas.sim.tis.entity.Question)

Example 9 with Toggle

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);
        }
    }
}
Also used : Toggle(javafx.scene.control.Toggle)

Example 10 with Toggle

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("导入版本:旧名单");
            }
        }
    });
}
Also used : ToggleGroup(javafx.scene.control.ToggleGroup) Toggle(javafx.scene.control.Toggle)

Aggregations

Toggle (javafx.scene.control.Toggle)12 ToggleGroup (javafx.scene.control.ToggleGroup)5 ToggleButton (javafx.scene.control.ToggleButton)3 File (java.io.File)2 IOException (java.io.IOException)2 QuestionAction (com.cas.sim.tis.action.QuestionAction)1 Question (com.cas.sim.tis.entity.Question)1 FXMLController (com.kyj.fx.voeditor.visual.framework.annotation.FXMLController)1 FxPostInitialize (com.kyj.fx.voeditor.visual.framework.annotation.FxPostInitialize)1 ResourceLoader (com.kyj.fx.voeditor.visual.momory.ResourceLoader)1 FxUtil (com.kyj.fx.voeditor.visual.util.FxUtil)1 ValueUtil (com.kyj.fx.voeditor.visual.util.ValueUtil)1 RuntimeException (com.sun.star.uno.RuntimeException)1 Closeable (java.io.Closeable)1 FileInputStream (java.io.FileInputStream)1 ByteBuffer (java.nio.ByteBuffer)1 FileChannel (java.nio.channels.FileChannel)1 Charset (java.nio.charset.Charset)1 StandardOpenOption (java.nio.file.StandardOpenOption)1 ArrayList (java.util.ArrayList)1