use of org.apache.hop.core.gui.plugin.key.GuiKeyboardShortcut in project hop by apache.
the class HopImportGuiPlugin method menuToolsImport.
@GuiMenuElement(root = HopGui.ID_MAIN_MENU, id = ID_MAIN_MENU_FILE_IMPORT, label = "i18n::HopGuiImport.Menu.Item", image = "kettle-logo.svg", parentId = HopGui.ID_MAIN_MENU_FILE, separator = true)
@GuiKeyboardShortcut(control = true, key = 'i')
@GuiOsxKeyboardShortcut(command = true, key = 'i')
public void menuToolsImport() {
HopGui hopGui = HopGui.getInstance();
try {
// Import using this Kettle import plugin...
//
KettleImport kettleImport = new KettleImport();
kettleImport.init(hopGui.getVariables(), hopGui.getLog());
KettleImportDialog dialog = new KettleImportDialog(hopGui.getShell(), hopGui.getVariables(), kettleImport);
dialog.open();
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), "Error", "Error importing from Kettle", e);
}
}
use of org.apache.hop.core.gui.plugin.key.GuiKeyboardShortcut in project hop by apache.
the class GuiRegistry method addKeyboardShortcut.
public void addKeyboardShortcut(String guiPluginClassName, Method method, GuiKeyboardShortcut shortcut) {
List<KeyboardShortcut> shortcuts = shortCutsMap.computeIfAbsent(guiPluginClassName, k -> new ArrayList<>());
KeyboardShortcut keyboardShortCut = new KeyboardShortcut(shortcut, method);
shortcuts.add(keyboardShortCut);
}
use of org.apache.hop.core.gui.plugin.key.GuiKeyboardShortcut in project hop by apache.
the class HopGuiPipelineGraph method openReferencedObject.
@GuiKeyboardShortcut(key = 'z')
@GuiOsxKeyboardShortcut(key = 'z')
public void openReferencedObject() {
if (lastMove != null) {
// Hide the tooltip!
hideToolTips();
// Find the transform
TransformMeta transformMeta = pipelineMeta.getTransform(lastMove.x, lastMove.y, iconSize);
if (transformMeta != null) {
// Open referenced object...
//
ITransformMeta iTransformMeta = transformMeta.getTransform();
String[] objectDescriptions = iTransformMeta.getReferencedObjectDescriptions();
if (objectDescriptions == null || objectDescriptions.length == 0) {
return;
}
//
if (objectDescriptions.length == 1) {
HopGuiPipelineTransformContext.openReferencedObject(pipelineMeta, variables, iTransformMeta, objectDescriptions[0], 0);
} else {
// Show Selection dialog...
//
EnterSelectionDialog dialog = new EnterSelectionDialog(getShell(), objectDescriptions, BaseMessages.getString(PKG, "HopGuiPipelineGraph.OpenReferencedObject.Selection.Title"), BaseMessages.getString(PKG, "HopGuiPipelineGraph.OpenReferencedObject.Selection.Message"));
String answer = dialog.open(0);
if (answer != null) {
int index = dialog.getSelectionNr();
HopGuiPipelineTransformContext.openReferencedObject(pipelineMeta, variables, iTransformMeta, answer, index);
}
}
}
}
}
use of org.apache.hop.core.gui.plugin.key.GuiKeyboardShortcut in project hop by apache.
the class HopVfsFileDialog method deleteFile.
@GuiToolbarElement(root = BROWSER_TOOLBAR_PARENT_ID, id = BROWSER_ITEM_ID_DELETE, toolTip = "i18n::HopVfsFileDialog.DeleteFile.Tooltip.Message", image = "ui/images/delete.svg")
// FIXME: Keyboard don't work
@GuiKeyboardShortcut(key = SWT.DEL)
@GuiOsxKeyboardShortcut(key = SWT.DEL)
public void deleteFile() {
FileObject file = getSelectedFileObject();
if (file != null) {
try {
MessageBox box = new MessageBox(shell, SWT.YES | SWT.NO | SWT.ICON_QUESTION);
box.setText(BaseMessages.getString(PKG, "HopVfsFileDialog.DeleteFile.Confirmation.Header"));
box.setMessage(BaseMessages.getString(PKG, "HopVfsFileDialog.DeleteFile.Confirmation.Message") + Const.CR + Const.CR + file.getName());
int answer = box.open();
if ((answer & SWT.YES) != 0) {
// If the selected item to delete is folder, set parent for refresh
if (file.isFolder()) {
wFilename.setText(file.getParent().getName().getURI());
}
boolean deleted = file.delete();
if (deleted) {
refreshBrowser();
}
}
} catch (Exception e) {
showError(BaseMessages.getString(PKG, "HopVfsFileDialog.DeleteFile.Error.Message", file.toString()), e);
}
}
}
use of org.apache.hop.core.gui.plugin.key.GuiKeyboardShortcut in project hop by apache.
the class HopVfsFileDialog method renameFile.
@GuiToolbarElement(root = BROWSER_TOOLBAR_PARENT_ID, id = BROWSER_ITEM_ID_RENAME, toolTip = "i18n::HopVfsFileDialog.RenameFile.Tooltip.Message", image = "ui/images/rename.svg")
// FIXME: Keyboard don't work
@GuiKeyboardShortcut(key = SWT.F2)
@GuiOsxKeyboardShortcut(key = SWT.F2)
public void renameFile() {
FileObject file = getSelectedFileObject();
if (file != null) {
TreeItem item = wBrowser.getSelection()[0];
// The control that will be the editor must be a child of the Tree
Text text = new Text(wBrowser, SWT.BORDER);
text.setText(file.getName().getBaseName());
text.addListener(SWT.FocusOut, event -> text.dispose());
text.addListener(SWT.KeyUp, event -> {
switch(event.keyCode) {
case SWT.CR:
case SWT.KEYPAD_CR:
// If name changed
if (!item.getText().equals(text.getText())) {
try {
// If the selected item to rename is folder, set parent for refresh
if (file.isFolder()) {
wFilename.setText(file.getParent().getName().getURI());
}
FileObject newFile = HopVfs.getFileObject(HopVfs.getFilename(file.getParent()) + "/" + text.getText());
file.moveTo(newFile);
} catch (Exception e) {
showError(BaseMessages.getString(PKG, "HopVfsFileDialog.RenameFile.Error.Message", file), e);
} finally {
text.dispose();
refreshBrowser();
}
}
break;
case SWT.ESC:
text.dispose();
break;
}
});
text.selectAll();
text.setFocus();
wBrowserEditor.setEditor(text, item);
}
}
Aggregations