Search in sources :

Example 1 with Toggle

use of javafx.scene.control.Toggle in project jphp by jphp-compiler.

the class RadioGroupPane method getSelected.

public T getSelected() {
    Toggle toggle = getToggleGroup().getSelectedToggle();
    T selected = null;
    if (toggle != null) {
        selected = (T) toggle.getUserData();
    }
    return selected;
}
Also used : Toggle(javafx.scene.control.Toggle)

Example 2 with Toggle

use of javafx.scene.control.Toggle in project Gargoyle by callakrsos.

the class DesignerFx method loadSettings.

private void loadSettings() {
    try {
        File file = new File(SETTINGS_FILE_NAME);
        if (file.exists()) {
            DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
            Document document = builder.parse(new FileInputStream(file));
            Element settingsElement = document.getDocumentElement();
            Element codeElement = (Element) settingsElement.getElementsByTagName("code").item(0);
            Element xpathElement = (Element) settingsElement.getElementsByTagName("xpath").item(0);
            String code = getTextContext(codeElement);
            String languageVersion = codeElement.getAttribute("language-version");
            String xpath = getTextContext(xpathElement);
            String xpathVersion = xpathElement.getAttribute("version");
            codeEditorPane.setText(code);
            setLanguageVersion(LanguageRegistry.findLanguageVersionByTerseName(languageVersion));
            xpathQueryArea.setText(xpath);
            //				for (Enumeration<AbstractButton> e = xpathVersionButtonGroup.getElements(); e.hasMoreElements();) {
            //					AbstractButton button = e.nextElement();
            //					if (xpathVersion.equals(button.getActionCommand())) {
            //						button.setSelected(true);
            //						break;
            //					}
            //				}
            ObservableList<Toggle> toggles = xpathVersionButtonGroup.getToggles();
            for (Toggle e : toggles) {
                if (xpathVersion.equals(e.getUserData())) {
                    e.setSelected(true);
                    break;
                }
            }
        }
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (SAXException e) {
        e.printStackTrace();
    }
}
Also used : DocumentBuilder(javax.xml.parsers.DocumentBuilder) Element(org.w3c.dom.Element) Toggle(javafx.scene.control.Toggle) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IOException(java.io.IOException) Document(org.w3c.dom.Document) File(java.io.File) FileInputStream(java.io.FileInputStream) SAXException(org.xml.sax.SAXException)

Example 3 with Toggle

use of javafx.scene.control.Toggle in project Gargoyle by callakrsos.

the class LogViewController method onAfter.

@FxPostInitialize
public void onAfter() throws IOException {
    File monitoringFile = composite.getMonitoringFile();
    fileChannel = FileChannel.open(monitoringFile.toPath(), StandardOpenOption.READ);
    buffer = ByteBuffer.allocate(seekSize);
    String encoding = ResourceLoader.loadCharset();
    if (Charset.isSupported(encoding)) {
        charset.set(Charset.forName(encoding));
    } else {
        LOGGER.info("does not supported encoding {} , default utf-8 setting. ", encoding);
        encoding = "UTF-8";
        charset.set(Charset.forName(encoding));
    }
    //설정에 저장된 인코딩셋을 불러와 디폴트로 선택되게함.
    ObservableList<Toggle> toggles = ENCODING.getToggles();
    toggles.stream().map(tg -> {
        if (tg instanceof RadioMenuItem) {
            RadioMenuItem r = (RadioMenuItem) tg;
            if (r.getText().toUpperCase().equals(charset.get().name().toUpperCase())) {
                return r;
            }
        }
        return null;
    }).filter(v -> v != null).findFirst().ifPresent(rmi -> {
        rmi.setSelected(true);
    });
    //캐릭터셋이 변경될때 환경변수에 등록하는 과정
    this.charset.addListener((oba, o, newCharset) -> {
        String name = newCharset.name();
        if (ValueUtil.isEmpty(name)) {
            return;
        }
        ResourceLoader.saveCharset(name);
    });
}
Also used : Button(javafx.scene.control.Button) RadioMenuItem(javafx.scene.control.RadioMenuItem) LoggerFactory(org.slf4j.LoggerFactory) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) FXCollections(javafx.collections.FXCollections) Timer(java.util.Timer) ByteBuffer(java.nio.ByteBuffer) Charset(java.nio.charset.Charset) TimerTask(java.util.TimerTask) KeyCode(javafx.scene.input.KeyCode) ObjectProperty(javafx.beans.property.ObjectProperty) Logger(org.slf4j.Logger) RuntimeException(com.sun.star.uno.RuntimeException) StandardOpenOption(java.nio.file.StandardOpenOption) FXMLController(com.kyj.fx.voeditor.visual.framework.annotation.FXMLController) IOException(java.io.IOException) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) LongProperty(javafx.beans.property.LongProperty) CodeArea(org.fxmisc.richtext.CodeArea) KeyEvent(javafx.scene.input.KeyEvent) File(java.io.File) FxPostInitialize(com.kyj.fx.voeditor.visual.framework.annotation.FxPostInitialize) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) ResourceLoader(com.kyj.fx.voeditor.visual.momory.ResourceLoader) BooleanProperty(javafx.beans.property.BooleanProperty) ActionEvent(javafx.event.ActionEvent) ToggleGroup(javafx.scene.control.ToggleGroup) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) ToggleButton(javafx.scene.control.ToggleButton) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Closeable(java.io.Closeable) Window(javafx.stage.Window) Toggle(javafx.scene.control.Toggle) ObservableList(javafx.collections.ObservableList) FileChannel(java.nio.channels.FileChannel) SimpleLongProperty(javafx.beans.property.SimpleLongProperty) Toggle(javafx.scene.control.Toggle) RadioMenuItem(javafx.scene.control.RadioMenuItem) File(java.io.File) FxPostInitialize(com.kyj.fx.voeditor.visual.framework.annotation.FxPostInitialize)

Example 4 with Toggle

use of javafx.scene.control.Toggle in project org.csstudio.display.builder by kasemir.

the class ActionsDialog method getOpenDisplayAction.

/**
 * @return {@link OpenDisplayActionInfo} from sub pane
 */
private OpenDisplayActionInfo getOpenDisplayAction() {
    Target target = Target.REPLACE;
    List<Toggle> modes = open_display_targets.getToggles();
    for (int i = 0; i < modes.size(); ++i) if (modes.get(i).isSelected()) {
        target = Target.values()[i];
        break;
    }
    return new OpenDisplayActionInfo(open_display_description.getText(), open_display_path.getText().trim(), open_display_macros.getMacros(), target);
}
Also used : Target(org.csstudio.display.builder.model.properties.OpenDisplayActionInfo.Target) Toggle(javafx.scene.control.Toggle) OpenDisplayActionInfo(org.csstudio.display.builder.model.properties.OpenDisplayActionInfo)

Example 5 with Toggle

use of javafx.scene.control.Toggle in project POL-POM-5 by PlayOnLinux.

the class SidebarToggleGroupBehavior method selectFirstToggleButton.

/**
 * Ensures, that always a button is selected:
 * - if because of an invalidation of the input list the selection is lost, the selection is reapplied
 * - if no button is selected, select the first button
 */
private void selectFirstToggleButton() {
    final ToggleGroup toggleGroup = getSkin().getToggleGroup();
    if (toggleGroup.getSelectedToggle() == null && !toggleGroup.getToggles().isEmpty()) {
        final E selectedElement = getControl().selectedElementProperty().getValue();
        if (selectedElement != null && getControl().getElements().contains(selectedElement)) {
            // 1 if an "all" button exists, 0 otherwise
            final int offset = toggleGroup.getToggles().size() - getControl().getElements().size();
            final int index = getControl().getElements().indexOf(getControl().selectedElementProperty().getValue());
            // reselect the previously selected item
            toggleGroup.selectToggle(toggleGroup.getToggles().get(offset + index));
        } else {
            final Toggle firstToggle = toggleGroup.getToggles().get(0);
            // trigger the first item in the toggle group
            if (firstToggle instanceof ToggleButton) {
                ((ToggleButton) firstToggle).fire();
            }
        }
    }
}
Also used : ToggleButton(javafx.scene.control.ToggleButton) ToggleGroup(javafx.scene.control.ToggleGroup) Toggle(javafx.scene.control.Toggle)

Aggregations

Toggle (javafx.scene.control.Toggle)11 ToggleGroup (javafx.scene.control.ToggleGroup)4 File (java.io.File)2 IOException (java.io.IOException)2 RadioButton (javafx.scene.control.RadioButton)2 ToggleButton (javafx.scene.control.ToggleButton)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 ScheduleRow (ctc.model.ScheduleRow)1 TrainTracker (ctc.model.TrainTracker)1 Closeable (java.io.Closeable)1 FileInputStream (java.io.FileInputStream)1 ByteBuffer (java.nio.ByteBuffer)1 FileChannel (java.nio.channels.FileChannel)1