本文整理汇总了Java中com.vaadin.event.ShortcutListener类的典型用法代码示例。如果您正苦于以下问题:Java ShortcutListener类的具体用法?Java ShortcutListener怎么用?Java ShortcutListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ShortcutListener类属于com.vaadin.event包,在下文中一共展示了ShortcutListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createNextWindowTabShortcut
import com.vaadin.event.ShortcutListener; //导入依赖的package包/类
public ShortcutListener createNextWindowTabShortcut(Window.TopLevelWindow topLevelWindow) {
String nextTabShortcut = clientConfig.getNextTabShortcut();
KeyCombination combination = KeyCombination.create(nextTabShortcut);
return new ShortcutListener("onNextTab", combination.getKey().getCode(),
KeyCombination.Modifier.codes(combination.getModifiers())) {
@Override
public void handleAction(Object sender, Object target) {
TabSheetBehaviour tabSheet = getConfiguredWorkArea(createWorkAreaContext(topLevelWindow))
.getTabbedWindowContainer().getTabSheetBehaviour();
if (tabSheet != null && !hasDialogWindows() && tabSheet.getComponentCount() > 1) {
Component selectedTabComponent = tabSheet.getSelectedTab();
String tabId = tabSheet.getTab(selectedTabComponent);
int tabPosition = tabSheet.getTabPosition(tabId);
int newTabPosition = (tabPosition + 1) % tabSheet.getComponentCount();
String newTabId = tabSheet.getTab(newTabPosition);
tabSheet.setSelectedTab(newTabId);
moveFocus(tabSheet, newTabId);
}
}
};
}
示例2: createPreviousWindowTabShortcut
import com.vaadin.event.ShortcutListener; //导入依赖的package包/类
public ShortcutListener createPreviousWindowTabShortcut(Window.TopLevelWindow topLevelWindow) {
String previousTabShortcut = clientConfig.getPreviousTabShortcut();
KeyCombination combination = KeyCombination.create(previousTabShortcut);
return new ShortcutListener("onPreviousTab", combination.getKey().getCode(),
KeyCombination.Modifier.codes(combination.getModifiers())) {
@Override
public void handleAction(Object sender, Object target) {
TabSheetBehaviour tabSheet = getConfiguredWorkArea(createWorkAreaContext(topLevelWindow))
.getTabbedWindowContainer().getTabSheetBehaviour();
if (tabSheet != null && !hasDialogWindows() && tabSheet.getComponentCount() > 1) {
Component selectedTabComponent = tabSheet.getSelectedTab();
String selectedTabId = tabSheet.getTab(selectedTabComponent);
int tabPosition = tabSheet.getTabPosition(selectedTabId);
int newTabPosition = (tabSheet.getComponentCount() + tabPosition - 1) % tabSheet.getComponentCount();
String newTabId = tabSheet.getTab(newTabPosition);
tabSheet.setSelectedTab(newTabId);
moveFocus(tabSheet, newTabId);
}
}
};
}
示例3: initComponent
import com.vaadin.event.ShortcutListener; //导入依赖的package包/类
public void initComponent(CubaTree component) {
componentComposition = new CssLayout();
componentComposition.setPrimaryStyleName("c-tree-composition");
componentComposition.setWidthUndefined();
componentComposition.addComponent(component);
component.setSizeFull();
component.addShortcutListener(new ShortcutListener("tableEnter", com.vaadin.event.ShortcutAction.KeyCode.ENTER, null) {
@Override
public void handleAction(Object sender, Object target) {
if (target == WebAbstractTree.this.component) {
if (enterPressAction != null) {
enterPressAction.actionPerform(WebAbstractTree.this);
} else {
handleClickAction();
}
}
}
});
}
示例4: createSearchField
import com.vaadin.event.ShortcutListener; //导入依赖的package包/类
private TextField createSearchField() {
TextField textFieldSearch = new TextField();
textFieldSearch.setWidth("30ex");
textFieldSearch.addShortcutListener(new ShortcutListener("Search", ShortcutAction.KeyCode.ENTER, null) {
private static final long serialVersionUID = 1L;
@Override
public void handleAction(Object sender, Object target) {
if (target == textFieldSearch) {
String query = textFieldSearch.getValue();
Page page = Application.getInstance().createSearchPage(query);
show(page);
}
}
});
return textFieldSearch;
}
示例5: VaadinTextAreaField
import com.vaadin.event.ShortcutListener; //导入依赖的package包/类
public VaadinTextAreaField(InputComponentListener changeListener, int maxLength, String allowedCharacters) {
setMaxLength(maxLength);
if (changeListener != null) {
addValueChangeListener(event -> changeListener.changed(VaadinTextAreaField.this));
addShortcutListener(new ShortcutListener("Commit", ShortcutAction.KeyCode.ENTER, null) {
private static final long serialVersionUID = 1L;
@Override
public void handleAction(Object sender, Object target) {
if (target == VaadinTextAreaField.this) {
if (commitListener != null) {
commitListener.run();
}
}
}
});
} else {
setReadOnly(true);
}
}
示例6: buildEditableNavigatorField
import com.vaadin.event.ShortcutListener; //导入依赖的package包/类
protected Field<?> buildEditableNavigatorField(Object itemId) {
if (itemBeingEdited != null && itemBeingEdited.equals(itemId)) {
final EnableFocusTextField field = new EnableFocusTextField();
field.addStyleName(ValoTheme.TEXTFIELD_SMALL);
field.setImmediate(true);
field.setWidth(95, Unit.PERCENTAGE);
field.addFocusListener(e -> {
field.setFocusAllowed(false);
field.selectAll();
field.setFocusAllowed(true);
});
field.focus();
field.addShortcutListener(new ShortcutListener("Escape", KeyCode.ESCAPE, null) {
@Override
public void handleAction(Object sender, Object target) {
abortEditingItem();
}
});
field.addValueChangeListener(event -> finishEditingItem((String) event.getProperty().getValue()));
field.addBlurListener(event -> abortEditingItem());
return field;
} else {
return null;
}
}
示例7: createExecuteSqlShortcutListener
import com.vaadin.event.ShortcutListener; //导入依赖的package包/类
protected ShortcutListener createExecuteSqlShortcutListener() {
return new ShortcutListener("", KeyCode.ENTER, new int[] { ModifierKey.CTRL }) {
private static final long serialVersionUID = 1L;
@Override
public void handleAction(Object sender, Object target) {
if (target instanceof Table) {
Table table = (Table) target;
TabularResultLayout layout = (TabularResultLayout) table.getParent();
reExecute(layout.getSql());
} else if (target instanceof AceEditor) {
if (executeAtCursorButtonValue) {
if (execute(false) && !settingsProvider.get().getProperties().is(SQL_EXPLORER_AUTO_COMMIT)) {
setButtonsEnabled();
}
}
}
}
};
}
示例8: createExecuteSqlScriptShortcutListener
import com.vaadin.event.ShortcutListener; //导入依赖的package包/类
protected ShortcutListener createExecuteSqlScriptShortcutListener(){
return new ShortcutListener("", KeyCode.ENTER, new int[] {ModifierKey.CTRL, ModifierKey.SHIFT}){
private static final long serialVersionUID = 1L;
@Override
public void handleAction(Object sender, Object target){
if (target instanceof Table) {
Table table = (Table) target;
TabularResultLayout layout = (TabularResultLayout) table.getParent();
reExecute(layout.getSql());
}else if (target instanceof AceEditor){
if(executeScriptButtonValue){
if(execute(true) && !settingsProvider.get().getProperties().is(SQL_EXPLORER_AUTO_COMMIT)){
setButtonsEnabled();
}
}
}
}
};
}
示例9: SearchTextField
import com.vaadin.event.ShortcutListener; //导入依赖的package包/类
public SearchTextField() {
this.setDefaultComponentAlignment(Alignment.MIDDLE_RIGHT);
ELabel icon = ELabel.fontIcon(FontAwesome.SEARCH);
innerField = new TextField();
innerField.setImmediate(true);
innerField.setInputPrompt(UserUIContext.getMessage(GenericI18Enum.BUTTON_SEARCH));
innerField.setWidth("180px");
this.with(icon, innerField).withStyleName("searchfield");
ShortcutListener shortcutListener = new ShortcutListener("searchfield", ShortcutAction.KeyCode.ENTER, null) {
@Override
public void handleAction(Object sender, Object target) {
String value = ((TextField) target).getValue();
if (isNotBlank(value)) {
doSearch(value);
} else {
emptySearch();
}
}
};
ShortcutExtension.installShortcutAction(innerField, shortcutListener);
}
示例10: createMenuSearch
import com.vaadin.event.ShortcutListener; //导入依赖的package包/类
private void createMenuSearch() {
HorizontalLayout searchLayout = new HorizontalLayout();
searchLayout.setSpacing(true);
searchLayout.setMargin(new MarginInfo(true, false, true, false));
searchLayout.setWidth("100%");
final CubaTextField searchField = new CubaTextField();
searchField.setWidth("100%");
searchField.addShortcutListener(new ShortcutListener("", KeyCode.ENTER, null) {
@Override
public void handleAction(Object sender, Object target) {
search(searchField.getValue());
}
});
searchField.focus();
searchLayout.addComponent(searchField);
searchLayout.setExpandRatio(searchField, 1);
filter = null;
Button searchButton = new Button(messages.getMessage(getClass(), "LeftPanel.search"));
searchButton.setIcon(FontAwesome.SEARCH);
searchButton.addClickListener(event -> search(searchField.getValue()));
searchLayout.addComponent(searchButton);
searchLayout.setComponentAlignment(searchButton, MIDDLE_RIGHT);
menuLayout.addComponent(searchLayout);
}
示例11: assignShortcut
import com.vaadin.event.ShortcutListener; //导入依赖的package包/类
protected void assignShortcut(Window webWindow, AppMenu.MenuItem menuItem, MenuItem item) {
KeyCombination itemShortcut = item.getShortcut();
if (itemShortcut != null) {
ShortcutListener shortcut = new MenuShortcutAction(menuItem, "shortcut_" + item.getId(), item.getShortcut());
AbstractComponent windowImpl = webWindow.unwrap(AbstractComponent.class);
windowImpl.addShortcutListener(shortcut);
appMenu.setMenuItemShortcutCaption(menuItem, itemShortcut.format());
}
}
示例12: assignShortcut
import com.vaadin.event.ShortcutListener; //导入依赖的package包/类
protected void assignShortcut(Window webWindow, SideMenu.MenuItem menuItem, MenuItem item) {
KeyCombination itemShortcut = item.getShortcut();
if (itemShortcut != null) {
ShortcutListener shortcut = new SideMenuShortcutListener(menuItem, item);
AbstractComponent windowImpl = webWindow.unwrap(AbstractComponent.class);
windowImpl.addShortcutListener(shortcut);
if (Strings.isNullOrEmpty(menuItem.getBadgeText())) {
menuItem.setDescription(itemShortcut.format());
}
}
}
示例13: addShortcutListener
import com.vaadin.event.ShortcutListener; //导入依赖的package包/类
@Override
public void addShortcutListener(ShortcutListener shortcut) {
if (shortcutActionManager == null) {
shortcutActionManager = new ShortcutActionManager(this);
}
shortcutActionManager.addAction(shortcut);
}
示例14: addShortcutAction
import com.vaadin.event.ShortcutListener; //导入依赖的package包/类
@Override
public void addShortcutAction(ShortcutAction action) {
KeyCombination keyCombination = action.getShortcutCombination();
com.vaadin.event.ShortcutListener shortcut =
new ContainerShortcutActionWrapper(action, this, keyCombination);
component.addShortcutListener(shortcut);
if (shortcuts == null) {
shortcuts = new HashMap<>();
}
shortcuts.put(action, shortcut);
}
示例15: addEnterShortcut
import com.vaadin.event.ShortcutListener; //导入依赖的package包/类
@Deprecated
public static void addEnterShortcut(TextField textField, final Runnable runnable) {
CubaTextField cubaTextField = (CubaTextField) WebComponentsHelper.unwrap(textField);
cubaTextField.addShortcutListener(new ShortcutListener("", ShortcutAction.KeyCode.ENTER, KeyCombination.Modifier.codes()) {
@Override
public void handleAction(Object sender, Object target) {
runnable.run();
}
});
}