Search in sources :

Example 1 with RadioMenuItem

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

the class DesignerFx method createFxMenuBar.

//	private JMenuBar createMenuBar() {
//		JMenuBar menuBar = new JMenuBar();
//		JMenu menu = new JMenu("Language");
//		ButtonGroup group = new ButtonGroup();
//
//		LanguageVersion[] languageVersions = getSupportedLanguageVersions();
//		for (int i = 0; i < languageVersions.length; i++) {
//			LanguageVersion languageVersion = languageVersions[i];
//			MenuItem button = new MenuItem(languageVersion.getShortName());
//			languageVersionMenuItems[i] = button;
//			group.add(button);
//			menu.add(button);
//		}
//		languageVersionMenuItems[DEFAULT_LANGUAGE_VERSION_SELECTION_INDEX].setSelected(true);
//		menuBar.add(menu);
//
//		JMenu actionsMenu = new JMenu("Actions");
//		JMenuItem copyXMLItem = new JMenuItem("Copy xml to clipboard");
//		copyXMLItem.addActionListener(new ActionListener() {
//			public void actionPerformed(ActionEvent e) {
//				copyXmlToClipboard();
//			}
//		});
//		actionsMenu.add(copyXMLItem);
//		JMenuItem createRuleXMLItem = new JMenuItem("Create rule XML");
//		createRuleXMLItem.addActionListener(new ActionListener() {
//			public void actionPerformed(ActionEvent e) {
//				createRuleXML();
//			}
//		});
//		actionsMenu.add(createRuleXMLItem);
//		menuBar.add(actionsMenu);
//
//		return menuBar;
//	}
private MenuBar createFxMenuBar() {
    MenuBar menuBar = new MenuBar();
    Menu menu = new Menu("Language");
    ToggleGroup group = new ToggleGroup();
    LanguageVersion[] languageVersions = getSupportedLanguageVersions();
    for (int i = 0; i < languageVersions.length; i++) {
        LanguageVersion languageVersion = languageVersions[i];
        //			JRadioButtonMenuItem button = new JRadioButtonMenuItem(languageVersion.getShortName());
        RadioMenuItem button = new RadioMenuItem(languageVersion.getShortName());
        button.setToggleGroup(group);
        languageVersionMenuItems[i] = button;
        //			group.add(button);
        menu.getItems().add(button);
    }
    //		languageVersionMenuItems[DEFAULT_LANGUAGE_VERSION_SELECTION_INDEX].setSelected(true);
    languageVersionMenuItems[getDefaultLanguageVersionSelectionIndex()].setSelected(true);
    menuBar.getMenus().add(menu);
    Menu actionsMenu = new Menu("Actions");
    MenuItem copyXMLItem = new MenuItem("Copy xml to clipboard");
    copyXMLItem.setOnAction(e -> copyXmlToClipboard());
    actionsMenu.getItems().add(copyXMLItem);
    MenuItem createRuleXMLItem = new MenuItem("Create rule XML");
    createRuleXMLItem.setOnAction(e -> createRuleXML());
    actionsMenu.getItems().add(createRuleXMLItem);
    menuBar.getMenus().add(actionsMenu);
    return menuBar;
}
Also used : ToggleGroup(javafx.scene.control.ToggleGroup) JMenuBar(javax.swing.JMenuBar) MenuBar(javafx.scene.control.MenuBar) LanguageVersion(net.sourceforge.pmd.lang.LanguageVersion) MenuItem(javafx.scene.control.MenuItem) RadioMenuItem(javafx.scene.control.RadioMenuItem) Menu(javafx.scene.control.Menu) RadioMenuItem(javafx.scene.control.RadioMenuItem)

Example 2 with RadioMenuItem

use of javafx.scene.control.RadioMenuItem 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 3 with RadioMenuItem

use of javafx.scene.control.RadioMenuItem in project jgnash by ccavanaugh.

the class ThemeManager method addKnownThemes.

public static void addKnownThemes(@NotNull final Menu menu) {
    Objects.requireNonNull(menu);
    themesMenu = menu;
    for (final String[] theme : KNOWN_THEMES) {
        final RadioMenuItem radioMenuItem = new RadioMenuItem(theme[0]);
        radioMenuItem.setUserData(theme[1]);
        radioMenuItem.setOnAction(themeHandler);
        radioMenuItem.setToggleGroup(toggleGroup);
        themesMenu.getItems().add(radioMenuItem);
    }
    JavaFXUtils.runLater(ThemeManager::syncRadioMenuItem);
}
Also used : RadioMenuItem(javafx.scene.control.RadioMenuItem)

Aggregations

RadioMenuItem (javafx.scene.control.RadioMenuItem)3 ToggleGroup (javafx.scene.control.ToggleGroup)2 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 File (java.io.File)1 IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1 FileChannel (java.nio.channels.FileChannel)1 Charset (java.nio.charset.Charset)1 StandardOpenOption (java.nio.file.StandardOpenOption)1 Timer (java.util.Timer)1 TimerTask (java.util.TimerTask)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Platform (javafx.application.Platform)1 BooleanProperty (javafx.beans.property.BooleanProperty)1