Search in sources :

Example 1 with GuiOsxKeyboardShortcut

use of org.apache.hop.core.gui.plugin.key.GuiOsxKeyboardShortcut 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 GuiOsxKeyboardShortcut

use of org.apache.hop.core.gui.plugin.key.GuiOsxKeyboardShortcut 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 3 with GuiOsxKeyboardShortcut

use of org.apache.hop.core.gui.plugin.key.GuiOsxKeyboardShortcut 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 4 with GuiOsxKeyboardShortcut

use of org.apache.hop.core.gui.plugin.key.GuiOsxKeyboardShortcut 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)

Example 5 with GuiOsxKeyboardShortcut

use of org.apache.hop.core.gui.plugin.key.GuiOsxKeyboardShortcut in project hop by apache.

the class MetadataPerspective method refresh.

@GuiToolbarElement(root = GUI_PLUGIN_TOOLBAR_PARENT_ID, id = TOOLBAR_ITEM_REFRESH, toolTip = "i18n::MetadataPerspective.ToolbarElement.Refresh.Tooltip", image = "ui/images/refresh.svg")
@GuiKeyboardShortcut(key = SWT.F5)
@GuiOsxKeyboardShortcut(key = SWT.F5)
public void refresh() {
    try {
        tree.setRedraw(false);
        tree.removeAll();
        // top level: object key
        // 
        IHopMetadataProvider metadataProvider = hopGui.getMetadataProvider();
        List<Class<IHopMetadata>> metadataClasses = metadataProvider.getMetadataClasses();
        // Sort by name
        Collections.sort(metadataClasses, (cl1, cl2) -> {
            HopMetadata a1 = HopMetadataUtil.getHopMetadataAnnotation(cl1);
            HopMetadata a2 = HopMetadataUtil.getHopMetadataAnnotation(cl2);
            return a1.name().compareTo(a2.name());
        });
        for (Class<IHopMetadata> metadataClass : metadataClasses) {
            HopMetadata annotation = HopMetadataUtil.getHopMetadataAnnotation(metadataClass);
            Image image = GuiResource.getInstance().getImage(annotation.image(), metadataClass.getClassLoader(), ConstUi.SMALL_ICON_SIZE, ConstUi.SMALL_ICON_SIZE);
            TreeItem classItem = new TreeItem(tree, SWT.NONE);
            classItem.setText(0, Const.NVL(annotation.name(), ""));
            classItem.setImage(image);
            classItem.setExpanded(true);
            classItem.setData(annotation.key());
            classItem.setData(KEY_HELP, annotation.description());
            // level 1: object names
            // 
            IHopMetadataSerializer<IHopMetadata> serializer = metadataProvider.getSerializer(metadataClass);
            List<String> names = serializer.listObjectNames();
            Collections.sort(names);
            for (final String name : names) {
                TreeItem item = new TreeItem(classItem, SWT.NONE);
                item.setText(0, Const.NVL(name, ""));
                MetadataEditor<?> editor = this.findEditor(annotation.key(), name);
                if (editor != null) {
                    if (editor.hasChanged()) {
                        item.setFont(GuiResource.getInstance().getFontBold());
                    }
                }
            }
        }
        TreeUtil.setOptimalWidthOnColumns(tree);
        TreeMemory.setExpandedFromMemory(tree, METADATA_PERSPECTIVE_TREE);
        tree.setRedraw(true);
    } catch (Exception e) {
        new ErrorDialog(getShell(), BaseMessages.getString(PKG, "MetadataPerspective.RefreshMetadata.Error.Header"), BaseMessages.getString(PKG, "MetadataPerspective.RefreshMetadata.Error.Message"), e);
    }
}
Also used : IHopMetadata(org.apache.hop.metadata.api.IHopMetadata) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) Image(org.eclipse.swt.graphics.Image) HopException(org.apache.hop.core.exception.HopException) IHopMetadataProvider(org.apache.hop.metadata.api.IHopMetadataProvider) HopMetadata(org.apache.hop.metadata.api.HopMetadata) IHopMetadata(org.apache.hop.metadata.api.IHopMetadata) 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