use of com.haulmont.cuba.gui.components.KeyCombination in project cuba by cuba-platform.
the class MenuBuilder method assignShortcut.
private void assignShortcut(JMenuItem jMenuItem, MenuItem item) {
if (item.getShortcut() != null) {
KeyCombination.Key key = item.getShortcut().getKey();
KeyCombination.Modifier[] modifiers = item.getShortcut().getModifiers();
KeyCombination combo = new KeyCombination(key, modifiers);
jMenuItem.setAccelerator(DesktopComponentsHelper.convertKeyCombination(combo));
}
}
use of com.haulmont.cuba.gui.components.KeyCombination in project cuba by cuba-platform.
the class LogWindow method initUI.
protected void initUI() {
ClientConfig clientConfig = AppBeans.<Configuration>get(Configuration.NAME).getConfig(ClientConfig.class);
String closeShortcut = clientConfig.getCloseShortcut();
KeyCombination closeCombination = KeyCombination.create(closeShortcut);
com.vaadin.event.ShortcutAction closeShortcutAction = new com.vaadin.event.ShortcutAction("closeShortcutAction", closeCombination.getKey().getCode(), KeyCombination.Modifier.codes(closeCombination.getModifiers()));
addActionHandler(new com.vaadin.event.Action.Handler() {
@Override
public com.vaadin.event.Action[] getActions(Object target, Object sender) {
return new com.vaadin.event.Action[] { closeShortcutAction };
}
@Override
public void handleAction(com.vaadin.event.Action action, Object sender, Object target) {
if (Objects.equals(action, closeShortcutAction)) {
close();
}
}
});
VerticalLayout layout = new VerticalLayout();
layout.setSpacing(true);
layout.setMargin(false);
layout.setSizeFull();
setContent(layout);
Panel scrollablePanel = new Panel();
scrollablePanel.setSizeFull();
VerticalLayout scrollContent = new VerticalLayout();
scrollContent.setMargin(false);
scrollContent.setSpacing(false);
scrollContent.setSizeUndefined();
scrollablePanel.setContent(scrollContent);
final Label label = new Label();
label.setContentMode(ContentMode.HTML);
label.setValue(writeLog());
label.setSizeUndefined();
label.setStyleName("c-log-content");
((Layout) scrollablePanel.getContent()).addComponent(label);
HorizontalLayout topLayout = new HorizontalLayout();
topLayout.setMargin(false);
topLayout.setSpacing(false);
topLayout.setWidth("100%");
topLayout.setHeightUndefined();
Messages messages = AppBeans.get(Messages.NAME);
Button refreshBtn = new CubaButton(messages.getMessage(getClass(), "logWindow.refreshBtn"), event -> label.setValue(writeLog()));
topLayout.addComponent(refreshBtn);
layout.addComponent(topLayout);
layout.addComponent(scrollablePanel);
layout.setExpandRatio(scrollablePanel, 1.0f);
}
use of com.haulmont.cuba.gui.components.KeyCombination in project cuba by cuba-platform.
the class WebButton method setShortcutCombination.
@Override
public void setShortcutCombination(KeyCombination shortcut) {
KeyCombination oldValue = this.shortcut;
if (!Objects.equals(oldValue, shortcut)) {
this.shortcut = shortcut;
if (shortcut != null) {
int[] shortcutModifiers = KeyCombination.Modifier.codes(shortcut.getModifiers());
int shortcutCode = shortcut.getKey().getCode();
component.setClickShortcut(shortcutCode, shortcutModifiers);
} else {
component.removeClickShortcut();
}
}
}
Aggregations