Search in sources :

Example 1 with GuiKeyboardShortcut

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);
    }
}
Also used : KettleImport(org.apache.hop.imports.kettle.KettleImport) KettleImportDialog(org.apache.hop.imports.kettle.KettleImportDialog) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) HopGui(org.apache.hop.ui.hopgui.HopGui) GuiMenuElement(org.apache.hop.core.gui.plugin.menu.GuiMenuElement) GuiOsxKeyboardShortcut(org.apache.hop.core.gui.plugin.key.GuiOsxKeyboardShortcut) GuiKeyboardShortcut(org.apache.hop.core.gui.plugin.key.GuiKeyboardShortcut)

Example 2 with GuiKeyboardShortcut

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);
}
Also used : KeyboardShortcut(org.apache.hop.core.gui.plugin.key.KeyboardShortcut) GuiKeyboardShortcut(org.apache.hop.core.gui.plugin.key.GuiKeyboardShortcut) GuiOsxKeyboardShortcut(org.apache.hop.core.gui.plugin.key.GuiOsxKeyboardShortcut)

Example 3 with GuiKeyboardShortcut

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);
                }
            }
        }
    }
}
Also used : HopExtensionPoint(org.apache.hop.core.extension.HopExtensionPoint) GuiOsxKeyboardShortcut(org.apache.hop.core.gui.plugin.key.GuiOsxKeyboardShortcut) GuiKeyboardShortcut(org.apache.hop.core.gui.plugin.key.GuiKeyboardShortcut)

Example 4 with GuiKeyboardShortcut

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);
        }
    }
}
Also used : FileObject(org.apache.commons.vfs2.FileObject) Point(org.eclipse.swt.graphics.Point) HopException(org.apache.hop.core.exception.HopException) FileSystemException(org.apache.commons.vfs2.FileSystemException) GuiOsxKeyboardShortcut(org.apache.hop.core.gui.plugin.key.GuiOsxKeyboardShortcut) GuiToolbarElement(org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement) GuiKeyboardShortcut(org.apache.hop.core.gui.plugin.key.GuiKeyboardShortcut)

Example 5 with GuiKeyboardShortcut

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);
    }
}
Also used : FileObject(org.apache.commons.vfs2.FileObject) HopException(org.apache.hop.core.exception.HopException) FileSystemException(org.apache.commons.vfs2.FileSystemException) GuiOsxKeyboardShortcut(org.apache.hop.core.gui.plugin.key.GuiOsxKeyboardShortcut) GuiToolbarElement(org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement) GuiKeyboardShortcut(org.apache.hop.core.gui.plugin.key.GuiKeyboardShortcut)

Aggregations

GuiKeyboardShortcut (org.apache.hop.core.gui.plugin.key.GuiKeyboardShortcut)11 GuiOsxKeyboardShortcut (org.apache.hop.core.gui.plugin.key.GuiOsxKeyboardShortcut)11 HopException (org.apache.hop.core.exception.HopException)5 GuiToolbarElement (org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement)5 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)3 FileObject (org.apache.commons.vfs2.FileObject)2 FileSystemException (org.apache.commons.vfs2.FileSystemException)2 HopExtensionPoint (org.apache.hop.core.extension.HopExtensionPoint)2 GuiMenuElement (org.apache.hop.core.gui.plugin.menu.GuiMenuElement)2 IHopFileType (org.apache.hop.ui.hopgui.file.IHopFileType)2 IHopPerspective (org.apache.hop.ui.hopgui.perspective.IHopPerspective)2 Field (java.lang.reflect.Field)1 Method (java.lang.reflect.Method)1 GuiContextAction (org.apache.hop.core.action.GuiContextAction)1 GuiContextActionFilter (org.apache.hop.core.action.GuiContextActionFilter)1 HopPluginException (org.apache.hop.core.exception.HopPluginException)1 GuiRegistry (org.apache.hop.core.gui.plugin.GuiRegistry)1 GuiWidgetElement (org.apache.hop.core.gui.plugin.GuiWidgetElement)1 GuiCallback (org.apache.hop.core.gui.plugin.callback.GuiCallback)1 KeyboardShortcut (org.apache.hop.core.gui.plugin.key.KeyboardShortcut)1