use of com.haulmont.cuba.web.gui.components.util.ShortcutListenerDelegate in project cuba by cuba-platform.
the class WebAppWorkArea method createPreviousWindowTabShortcut.
protected ShortcutListener createPreviousWindowTabShortcut(RootWindow topLevelWindow) {
Configuration configuration = beanLocator.get(Configuration.NAME);
ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
String previousTabShortcut = clientConfig.getPreviousTabShortcut();
KeyCombination combination = KeyCombination.create(previousTabShortcut);
return new ShortcutListenerDelegate("onPreviousTab", combination.getKey().getCode(), KeyCombination.Modifier.codes(combination.getModifiers())).withHandler((sender, target) -> {
TabSheetBehaviour tabSheet = getTabbedWindowContainer().getTabSheetBehaviour();
if (tabSheet != null && !hasModalWindow() && tabSheet.getComponentCount() > 1) {
com.vaadin.ui.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);
}
});
}
use of com.haulmont.cuba.web.gui.components.util.ShortcutListenerDelegate in project cuba by cuba-platform.
the class CubaFoldersPane method createFoldersPaneLayout.
protected CubaVerticalActionsLayout createFoldersPaneLayout(Component foldersPane, Label foldersLabel) {
CubaVerticalActionsLayout layout = new CubaVerticalActionsLayout();
layout.setMargin(true);
layout.setSpacing(true);
layout.setSizeFull();
if (foldersLabel != null)
addFoldersLabel(layout, foldersLabel);
layout.addComponent(foldersPane);
layout.setExpandRatio(foldersPane, 1);
layout.addShortcutListener(new ShortcutListenerDelegate("apply" + foldersPane.getCubaId(), ShortcutAction.KeyCode.ENTER, null).withHandler((sender, target) -> {
if (sender == layout) {
handleFoldersPaneShortcutAction(foldersPane);
}
}));
return layout;
}
use of com.haulmont.cuba.web.gui.components.util.ShortcutListenerDelegate in project cuba by cuba-platform.
the class WebAbstractTable method initComponent.
protected void initComponent(T component) {
component.setMultiSelect(false);
component.setValidationVisible(false);
component.setShowBufferedSourceException(false);
component.setCustomCellValueFormatter(this::formatCellValue);
component.addValueChangeListener(this::tableSelectionChanged);
component.setSpecificVariablesHandler(this::handleSpecificVariables);
component.setIconProvider(this::getItemIcon);
component.setBeforePaintListener(this::beforeComponentPaint);
component.setSortAscendingLabel(messages.getMainMessage("tableSort.ascending"));
component.setSortResetLabel(messages.getMainMessage("tableSort.reset"));
component.setSortDescendingLabel(messages.getMainMessage("tableSort.descending"));
component.setSelectAllLabel(messages.getMainMessage("tableColumnSelector.selectAll"));
component.setDeselectAllLabel(messages.getMainMessage("tableColumnSelector.deselectAll"));
int defaultRowHeaderWidth = 16;
ThemeConstantsManager themeConstantsManager = beanLocator.get(ThemeConstantsManager.NAME, ThemeConstantsManager.class);
ThemeConstants theme = themeConstantsManager.getConstants();
if (theme != null) {
defaultRowHeaderWidth = theme.getInt("cuba.web.Table.defaultRowHeaderWidth", 16);
}
component.setColumnWidth(ROW_HEADER_PROPERTY_ID, defaultRowHeaderWidth);
contextMenuPopup.setParent(component);
component.setContextMenuPopup(contextMenuPopup);
shortcutsDelegate.setAllowEnterShortcut(false);
component.addShortcutListener(new ShortcutListenerDelegate("tableEnter", KeyCode.ENTER, null).withHandler((sender, target) -> {
T tableImpl = WebAbstractTable.this.component;
CubaUI ui = (CubaUI) tableImpl.getUI();
if (!ui.isAccessibleForUser(tableImpl)) {
LoggerFactory.getLogger(WebAbstractTable.class).debug("Ignore click attempt because Table is inaccessible for user");
return;
}
if (target == this.component) {
if (enterPressAction != null) {
enterPressAction.actionPerform(this);
} else {
handleClickAction();
}
}
}));
component.addShortcutListener(new ShortcutListenerDelegate("tableSelectAll", KeyCode.A, new int[] { com.vaadin.event.ShortcutAction.ModifierKey.CTRL }).withHandler((sender, target) -> {
if (target == this.component) {
selectAll();
}
}));
component.addItemClickListener(event -> {
if (event.isDoubleClick() && event.getItem() != null) {
T tableImpl = WebAbstractTable.this.component;
CubaUI ui = (CubaUI) tableImpl.getUI();
if (!ui.isAccessibleForUser(tableImpl)) {
LoggerFactory.getLogger(WebAbstractTable.class).debug("Ignore click attempt because Table is inaccessible for user");
return;
}
handleClickAction();
}
});
component.setAfterUnregisterComponentHandler(this::onAfterUnregisterComponent);
component.setBeforeRefreshRowCacheHandler(this::onBeforeRefreshRowCache);
component.setSelectable(true);
component.setTableFieldFactory(createFieldFactory());
component.setColumnCollapsingAllowed(true);
component.setColumnReorderingAllowed(true);
setEditable(false);
componentComposition = new TableComposition();
componentComposition.setTable(component);
componentComposition.setPrimaryStyleName("c-table-composition");
componentComposition.addComponent(component);
component.setCellStyleGenerator(createStyleGenerator());
component.addColumnCollapseListener(this::handleColumnCollapsed);
// force default sizes
componentComposition.setHeightUndefined();
componentComposition.setWidthUndefined();
setClientCaching();
initEmptyState();
}
use of com.haulmont.cuba.web.gui.components.util.ShortcutListenerDelegate in project cuba by cuba-platform.
the class WebAbstractDataGrid method createShortcutsDelegate.
protected ShortcutsDelegate<ShortcutListener> createShortcutsDelegate() {
return new ShortcutsDelegate<ShortcutListener>() {
@Override
protected ShortcutListener attachShortcut(String actionId, KeyCombination keyCombination) {
ShortcutListener shortcut = new ShortcutListenerDelegate(actionId, keyCombination.getKey().getCode(), KeyCombination.Modifier.codes(keyCombination.getModifiers())).withHandler((sender, target) -> {
if (sender == componentComposition) {
Action action = getAction(actionId);
if (action != null && action.isEnabled() && action.isVisible()) {
action.actionPerform(WebAbstractDataGrid.this);
}
}
});
componentComposition.addShortcutListener(shortcut);
return shortcut;
}
@Override
protected void detachShortcut(Action action, ShortcutListener shortcutDescriptor) {
componentComposition.removeShortcutListener(shortcutDescriptor);
}
@Override
protected Collection<Action> getActions() {
return WebAbstractDataGrid.this.getActions();
}
};
}
use of com.haulmont.cuba.web.gui.components.util.ShortcutListenerDelegate in project cuba by cuba-platform.
the class ServerLogWindow method init.
@Override
public void init(Map<String, Object> params) {
initLoweredAttentionPatterns();
localJmxField.setValue(jmxControlAPI.getLocalNodeName());
localJmxInstance = jmxControlAPI.getLocalInstance();
jmxInstancesDs.refresh();
jmxConnectionField.setValue(localJmxInstance);
jmxConnectionField.setRequired(true);
jmxConnectionField.addValueChangeListener(e -> {
JmxInstance jmxInstance = e.getValue();
try {
refreshHostInfo();
} catch (JmxControlException ex) {
showNotification(getMessage("exception.unableToConnectToInterface"), NotificationType.WARNING);
if (jmxInstance != localJmxInstance) {
jmxConnectionField.setValue(localJmxInstance);
}
}
});
autoRefreshCheck.addValueChangeListener(e -> {
if (Boolean.TRUE.equals(e.getValue())) {
updateLogTailTimer.start();
} else {
updateLogTailTimer.stop();
}
});
jmxConnectionField.removeAllActions();
LookupAction action = LookupAction.create(jmxConnectionField);
action.setAfterLookupCloseHandler((window, actionId) -> {
jmxInstancesDs.refresh();
});
jmxConnectionField.addAction(action);
jmxConnectionField.addAction(new BaseAction("actions.Add").withIcon("icons/plus-btn.png").withHandler(event -> {
JmxInstanceEditor instanceEditor = (JmxInstanceEditor) openEditor(metadata.create(JmxInstance.class), OpenType.DIALOG);
instanceEditor.addCloseListener(actionId -> {
if (COMMIT_ACTION_ID.equals(actionId)) {
jmxInstancesDs.refresh();
jmxConnectionField.setValue(instanceEditor.getItem());
}
});
}));
logTailLabel.setSizeAuto();
logTailLabel.setHtmlEnabled(true);
logTailLabel.setStyleName("c-log-content");
loggerLevelField.setOptionsList(LoggingHelper.getLevels());
appenderLevelField.setOptionsList(LoggingHelper.getLevels());
refreshHostInfo();
loggerNameField.addValueChangeListener(e -> {
List<String> currentLoggers = new ArrayList<>(jmxRemoteLoggingAPI.getLoggerNames(getSelectedConnection()));
currentLoggers.sort(null);
currentLoggers.add(0, getMessage("logger.new"));
if (e.getValue() != null && e.getValue().equals(currentLoggers.get(0))) {
openAddLoggerDialog();
}
});
downloadButton.setEnabled(security.isSpecificPermitted("cuba.gui.administration.downloadlogs"));
logFileNameField.withUnwrapped(ComboBox.class, vComboBox -> {
vComboBox.addShortcutListener(new ShortcutListenerDelegate("", KeyCode.D, new int[] { ModifierKey.CTRL, ModifierKey.SHIFT }).withHandler((sender, target) -> downloadLog()));
vComboBox.addShortcutListener(new ShortcutListenerDelegate("", KeyCode.S, new int[] { ModifierKey.CTRL, ModifierKey.SHIFT }).withHandler((sender, target) -> showLogTail()));
});
downloadButton.setDescription("CTRL-SHIFT-D");
showTailButton.setDescription("CTRL-SHIFT-S");
logContainer.withUnwrappedComposition(CubaScrollBoxLayout.class, vScrollBox -> vScrollBox.setDelayed(true));
}
Aggregations