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;
}
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();
}
}
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);
});
}
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);
}
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();
}
}
}
}
Aggregations