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));
}
use of com.haulmont.cuba.web.gui.components.util.ShortcutListenerDelegate in project cuba by cuba-platform.
the class WebAppWorkArea method createCloseShortcut.
protected ShortcutListener createCloseShortcut(RootWindow topLevelWindow) {
Configuration configuration = beanLocator.get(Configuration.NAME);
ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
String closeShortcut = clientConfig.getCloseShortcut();
KeyCombination combination = KeyCombination.create(closeShortcut);
return new ShortcutListenerDelegate("onClose", combination.getKey().getCode(), KeyCombination.Modifier.codes(combination.getModifiers())).withHandler((sender, target) -> closeWindowByShortcut(topLevelWindow));
}
use of com.haulmont.cuba.web.gui.components.util.ShortcutListenerDelegate in project cuba by cuba-platform.
the class WebAppWorkArea method createNextWindowTabShortcut.
protected ShortcutListener createNextWindowTabShortcut(RootWindow topLevelWindow) {
Configuration configuration = beanLocator.get(Configuration.NAME);
ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
String nextTabShortcut = clientConfig.getNextTabShortcut();
KeyCombination combination = KeyCombination.create(nextTabShortcut);
return new ShortcutListenerDelegate("onNextTab", 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 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);
}
});
}
use of com.haulmont.cuba.web.gui.components.util.ShortcutListenerDelegate in project cuba by cuba-platform.
the class WebTree 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(WebTree.this);
}
}
});
componentComposition.addShortcutListener(shortcut);
return shortcut;
}
@Override
protected void detachShortcut(Action action, ShortcutListener shortcutDescriptor) {
componentComposition.removeShortcutListener(shortcutDescriptor);
}
@Override
protected Collection<Action> getActions() {
return WebTree.this.getActions();
}
};
}
Aggregations