当前位置: 首页>>代码示例>>Java>>正文


Java ShortcutListener类代码示例

本文整理汇总了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);
            }
        }
    };
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:26,代码来源:WebWindowManager.java

示例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);
            }
        }
    };
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:26,代码来源:WebWindowManager.java

示例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();
                }
            }
        }
    });
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:22,代码来源:WebAbstractTree.java

示例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;
  }
 
开发者ID:BrunoEberhard,项目名称:minimal-j,代码行数:19,代码来源:Vaadin.java

示例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);
	}
}
 
开发者ID:BrunoEberhard,项目名称:minimal-j,代码行数:21,代码来源:VaadinTextAreaField.java

示例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;
    }
}
 
开发者ID:JumpMind,项目名称:metl,代码行数:27,代码来源:DesignNavigator.java

示例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();
                    }
                }
            }
        }
    };
}
 
开发者ID:JumpMind,项目名称:sqlexplorer-vaadin,代码行数:22,代码来源:QueryPanel.java

示例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();
                    }
                }
            }
        }
    };
}
 
开发者ID:JumpMind,项目名称:sqlexplorer-vaadin,代码行数:22,代码来源:QueryPanel.java

示例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);
}
 
开发者ID:MyCollab,项目名称:mycollab,代码行数:22,代码来源:SearchTextField.java

示例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);
}
 
开发者ID:cuba-platform,项目名称:sampler,代码行数:28,代码来源:SamplerFoldersPane.java

示例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());
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:12,代码来源:MenuBuilder.java

示例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());
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:14,代码来源:SideMenuBuilder.java

示例13: addShortcutListener

import com.vaadin.event.ShortcutListener; //导入依赖的package包/类
@Override
public void addShortcutListener(ShortcutListener shortcut) {
    if (shortcutActionManager == null) {
        shortcutActionManager = new ShortcutActionManager(this);
    }

    shortcutActionManager.addAction(shortcut);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:9,代码来源:CubaTreeTable.java

示例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);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:13,代码来源:WebScrollBoxLayout.java

示例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();
        }
    });
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:11,代码来源:WebComponentsHelper.java


注:本文中的com.vaadin.event.ShortcutListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。