Search in sources :

Example 1 with GuiMenuElement

use of org.apache.hop.core.gui.plugin.menu.GuiMenuElement in project hop by apache.

the class ProjectsGuiPlugin method menuProjectExport.

@GuiMenuElement(root = HopGui.ID_MAIN_MENU, id = ID_MAIN_MENU_PROJECT_EXPORT, label = "i18n::HopGui.FileMenu.Project.Export.Label", image = "export.svg", parentId = HopGui.ID_MAIN_MENU_FILE, separator = false)
public void menuProjectExport() {
    HopGui hopGui = HopGui.getInstance();
    Shell shell = hopGui.getShell();
    String zipFilename = BaseDialog.presentFileDialog(true, shell, new String[] { "*.zip", "*.*" }, new String[] { "Zip files (*.zip)", "All Files (*.*)" }, true);
    if (zipFilename == null) {
        return;
    }
    Combo combo = getProjectsCombo();
    if (combo == null) {
        return;
    }
    String projectName = combo.getText();
    if (StringUtils.isEmpty(projectName)) {
        return;
    }
    ProjectsConfig config = ProjectsConfigSingleton.getConfig();
    ProjectConfig projectConfig = config.findProjectConfig(projectName);
    String projectHome = projectConfig.getProjectHome();
    try {
        IRunnableWithProgress op = monitor -> {
            try {
                monitor.setTaskName(BaseMessages.getString(PKG, "ProjectGuiPlugin.ZipDirectory.Taskname.Text"));
                OutputStream outputStream = HopVfs.getOutputStream(zipFilename, false);
                ZipOutputStream zos = new ZipOutputStream(outputStream);
                FileObject projectDirectory = HopVfs.getFileObject(projectHome);
                String projectHomeFolder = HopVfs.getFileObject(projectHome).getParent().getName().getURI();
                zipFile(projectDirectory, projectDirectory.getName().getURI(), zos, projectHomeFolder);
                zos.close();
                outputStream.close();
                monitor.done();
            } catch (Exception e) {
                throw new InvocationTargetException(e, "Error zipping project: " + e.getMessage());
            }
        };
        ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
        pmd.run(false, op);
        GuiResource.getInstance().toClipboard(zipFilename);
        MessageBox box = new MessageBox(shell, SWT.CLOSE | SWT.ICON_INFORMATION);
        box.setText(BaseMessages.getString(PKG, "ProjectGuiPlugin.ZipDirectory.Dialog.Header"));
        box.setMessage(BaseMessages.getString(PKG, "ProjectGuiPlugin.ZipDirectory.Dialog.Message1", zipFilename) + Const.CR + BaseMessages.getString(PKG, "ProjectGuiPlugin.ZipDirectory.Dialog.Message2"));
        box.open();
    } catch (Exception e) {
        new ErrorDialog(HopGui.getInstance().getShell(), BaseMessages.getString(PKG, "ProjectGuiPlugin.ZipDirectory.Error.Dialog.Header"), BaseMessages.getString(PKG, "ProjectGuiPlugin.ZipDirectory.Error.Dialog.Message"), e);
    }
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) HopVfsFileDialog(org.apache.hop.ui.core.vfs.HopVfsFileDialog) HopException(org.apache.hop.core.exception.HopException) HopGui(org.apache.hop.ui.hopgui.HopGui) Project(org.apache.hop.projects.project.Project) VariableValueDescription(org.apache.hop.core.variables.VariableValueDescription) ProjectConfig(org.apache.hop.projects.project.ProjectConfig) ZipEntry(java.util.zip.ZipEntry) ILogChannel(org.apache.hop.core.logging.ILogChannel) ProjectsConfigSingleton(org.apache.hop.projects.config.ProjectsConfigSingleton) ProjectsConfig(org.apache.hop.projects.config.ProjectsConfig) BaseDialog(org.apache.hop.ui.core.dialog.BaseDialog) HopNamespace(org.apache.hop.ui.core.gui.HopNamespace) LifecycleEnvironmentDialog(org.apache.hop.projects.environment.LifecycleEnvironmentDialog) ProgressMonitorDialog(org.apache.hop.ui.core.dialog.ProgressMonitorDialog) IHopMetadataSerializer(org.apache.hop.metadata.api.IHopMetadataSerializer) Const(org.apache.hop.core.Const) InvocationTargetException(java.lang.reflect.InvocationTargetException) AuditEvent(org.apache.hop.history.AuditEvent) GuiToolbarElement(org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) SWT(org.eclipse.swt.SWT) IRunnableWithProgress(org.apache.hop.core.IRunnableWithProgress) ProjectDialog(org.apache.hop.projects.project.ProjectDialog) ZipOutputStream(java.util.zip.ZipOutputStream) java.util(java.util) IVariables(org.apache.hop.core.variables.IVariables) GuiMenuElement(org.apache.hop.core.gui.plugin.menu.GuiMenuElement) IHopMetadataProvider(org.apache.hop.metadata.api.IHopMetadataProvider) GuiPlugin(org.apache.hop.core.gui.plugin.GuiPlugin) Variables(org.apache.hop.core.variables.Variables) LocalWorkflowRunConfiguration(org.apache.hop.workflow.engines.local.LocalWorkflowRunConfiguration) LocalPipelineRunConfiguration(org.apache.hop.pipeline.engines.local.LocalPipelineRunConfiguration) PipelineRunConfiguration(org.apache.hop.pipeline.config.PipelineRunConfiguration) HopConfig(org.apache.hop.core.config.HopConfig) ExtensionPointHandler(org.apache.hop.core.extension.ExtensionPointHandler) OutputStream(java.io.OutputStream) HopVfs(org.apache.hop.core.vfs.HopVfs) Combo(org.eclipse.swt.widgets.Combo) Shell(org.eclipse.swt.widgets.Shell) BaseMessages(org.apache.hop.i18n.BaseMessages) HopGuiEvents(org.apache.hop.ui.core.bus.HopGuiEvents) GuiResource(org.apache.hop.ui.core.gui.GuiResource) WorkflowRunConfiguration(org.apache.hop.workflow.config.WorkflowRunConfiguration) IOException(java.io.IOException) FileObject(org.apache.commons.vfs2.FileObject) PipelineExecutionConfigurationDialog(org.apache.hop.ui.pipeline.dialog.PipelineExecutionConfigurationDialog) GuiToolbarElementType(org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElementType) LogChannel(org.apache.hop.core.logging.LogChannel) LifecycleEnvironment(org.apache.hop.projects.environment.LifecycleEnvironment) AuditManager(org.apache.hop.history.AuditManager) MessageBox(org.eclipse.swt.widgets.MessageBox) ProjectsUtil(org.apache.hop.projects.util.ProjectsUtil) HopExtensionPoint(org.apache.hop.core.extension.HopExtensionPoint) GuiToolbarWidgets(org.apache.hop.ui.core.gui.GuiToolbarWidgets) Control(org.eclipse.swt.widgets.Control) InputStream(java.io.InputStream) ZipOutputStream(java.util.zip.ZipOutputStream) OutputStream(java.io.OutputStream) ProgressMonitorDialog(org.apache.hop.ui.core.dialog.ProgressMonitorDialog) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) Combo(org.eclipse.swt.widgets.Combo) HopException(org.apache.hop.core.exception.HopException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.apache.hop.core.IRunnableWithProgress) MessageBox(org.eclipse.swt.widgets.MessageBox) ProjectConfig(org.apache.hop.projects.project.ProjectConfig) Shell(org.eclipse.swt.widgets.Shell) ProjectsConfig(org.apache.hop.projects.config.ProjectsConfig) ZipOutputStream(java.util.zip.ZipOutputStream) FileObject(org.apache.commons.vfs2.FileObject) HopGui(org.apache.hop.ui.hopgui.HopGui) GuiMenuElement(org.apache.hop.core.gui.plugin.menu.GuiMenuElement)

Example 2 with GuiMenuElement

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

use of org.apache.hop.core.gui.plugin.menu.GuiMenuElement in project hop by apache.

the class HopBeamGuiPlugin method menuToolsFatJar.

@GuiMenuElement(root = HopGui.ID_MAIN_MENU, id = ID_MAIN_MENU_TOOLS_FAT_JAR, label = "i18n::BeamGuiPlugin.Menu.GenerateFatJar.Text", parentId = HopGui.ID_MAIN_MENU_TOOLS_PARENT_ID, separator = true)
public void menuToolsFatJar() {
    HopGui hopGui = HopGui.getInstance();
    final Shell shell = hopGui.getShell();
    MessageBox box = new MessageBox(shell, SWT.OK | SWT.CANCEL | SWT.ICON_INFORMATION);
    box.setText(BaseMessages.getString(PKG, "BeamGuiPlugin.GenerateFatJar.Dialog.Header"));
    box.setMessage(BaseMessages.getString(PKG, "BeamGuiPlugin.GenerateFatJar.Dialog.Message1") + Const.CR + BaseMessages.getString(PKG, "BeamGuiPlugin.GenerateFatJar.Dialog.Message2"));
    int answer = box.open();
    if ((answer & SWT.CANCEL) != 0) {
        return;
    }
    // Ask
    // 
    String filename = BaseDialog.presentFileDialog(true, shell, new String[] { "*.jar", "*.*" }, new String[] { BaseMessages.getString(PKG, "BeamGuiPlugin.FileTypes.Jars.Label"), BaseMessages.getString(PKG, "BeamGuiPlugin.FileTypes.All.Label") }, true);
    if (filename == null) {
        return;
    }
    try {
        List<String> jarFilenames = findInstalledJarFilenames();
        IRunnableWithProgress op = monitor -> {
            try {
                monitor.setTaskName(BaseMessages.getString(PKG, "BeamGuiPlugin.GenerateFatJar.Progress.Message"));
                FatJarBuilder fatJarBuilder = new FatJarBuilder(hopGui.getVariables(), filename, jarFilenames);
                fatJarBuilder.setExtraTransformPluginClasses(null);
                fatJarBuilder.setExtraXpPluginClasses(null);
                fatJarBuilder.buildTargetJar();
                monitor.done();
            } catch (Exception e) {
                throw new InvocationTargetException(e, "Error building fat jar: " + e.getMessage());
            }
        };
        ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
        pmd.run(false, op);
        GuiResource.getInstance().toClipboard(filename);
        box = new MessageBox(shell, SWT.CLOSE | SWT.ICON_INFORMATION);
        box.setText(BaseMessages.getString(PKG, "BeamGuiPlugin.FatJarCreated.Dialog.Header"));
        box.setMessage(BaseMessages.getString(PKG, "BeamGuiPlugin.FatJarCreated.Dialog.Message1", filename) + Const.CR + BaseMessages.getString(PKG, "BeamGuiPlugin.FatJarCreated.Dialog.Message2"));
        box.open();
    } catch (Exception e) {
        new ErrorDialog(shell, "Error", "Error creating fat jar", e);
    }
}
Also used : FatJarBuilder(org.apache.hop.beam.pipeline.fatjar.FatJarBuilder) GuiMenuElement(org.apache.hop.core.gui.plugin.menu.GuiMenuElement) HopGui(org.apache.hop.ui.hopgui.HopGui) GuiPlugin(org.apache.hop.core.gui.plugin.GuiPlugin) ArrayList(java.util.ArrayList) SerializableMetadataProvider(org.apache.hop.core.metadata.SerializableMetadataProvider) HashSet(java.util.HashSet) OutputStream(java.io.OutputStream) HopVfs(org.apache.hop.core.vfs.HopVfs) Shell(org.eclipse.swt.widgets.Shell) BaseMessages(org.apache.hop.i18n.BaseMessages) GuiResource(org.apache.hop.ui.core.gui.GuiResource) BaseDialog(org.apache.hop.ui.core.dialog.BaseDialog) ProgressMonitorDialog(org.apache.hop.ui.core.dialog.ProgressMonitorDialog) Set(java.util.Set) FileUtils(org.apache.commons.io.FileUtils) Const(org.apache.hop.core.Const) File(java.io.File) StandardCharsets(java.nio.charset.StandardCharsets) InvocationTargetException(java.lang.reflect.InvocationTargetException) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) List(java.util.List) SWT(org.eclipse.swt.SWT) MessageBox(org.eclipse.swt.widgets.MessageBox) IRunnableWithProgress(org.apache.hop.core.IRunnableWithProgress) ProgressMonitorDialog(org.apache.hop.ui.core.dialog.ProgressMonitorDialog) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) MessageBox(org.eclipse.swt.widgets.MessageBox) IRunnableWithProgress(org.apache.hop.core.IRunnableWithProgress) Shell(org.eclipse.swt.widgets.Shell) FatJarBuilder(org.apache.hop.beam.pipeline.fatjar.FatJarBuilder) HopGui(org.apache.hop.ui.hopgui.HopGui) GuiMenuElement(org.apache.hop.core.gui.plugin.menu.GuiMenuElement)

Example 4 with GuiMenuElement

use of org.apache.hop.core.gui.plugin.menu.GuiMenuElement in project hop by apache.

the class HopBeamGuiPlugin method menuToolsExportMetadata.

@GuiMenuElement(root = HopGui.ID_MAIN_MENU, id = ID_MAIN_MENU_TOOLS_EXPORT_METADATA, label = "i18n::BeamGuiPlugin.Menu.ExportMetadata.Text", parentId = HopGui.ID_MAIN_MENU_TOOLS_PARENT_ID, separator = true)
public void menuToolsExportMetadata() {
    HopGui hopGui = HopGui.getInstance();
    final Shell shell = hopGui.getShell();
    MessageBox box = new MessageBox(shell, SWT.OK | SWT.CANCEL | SWT.ICON_INFORMATION);
    box.setText(BaseMessages.getString(PKG, "BeamGuiPlugin.ExportMetadata.Dialog.Header"));
    box.setMessage(BaseMessages.getString(PKG, "BeamGuiPlugin.ExportMetadata.Dialog.Message"));
    int answer = box.open();
    if ((answer & SWT.CANCEL) != 0) {
        return;
    }
    // Ask
    // 
    String filename = BaseDialog.presentFileDialog(true, shell, new String[] { "*.json", "*.*" }, new String[] { BaseMessages.getString(PKG, "BeamGuiPlugin.FileTypes.Json.Label"), BaseMessages.getString(PKG, "BeamGuiPlugin.FileTypes.All.Label") }, true);
    if (filename == null) {
        return;
    }
    try {
        // Save HopGui metadata to JSON...
        // 
        SerializableMetadataProvider metadataProvider = new SerializableMetadataProvider(hopGui.getMetadataProvider());
        String jsonString = metadataProvider.toJson();
        String realFilename = hopGui.getVariables().resolve(filename);
        try (OutputStream outputStream = HopVfs.getOutputStream(realFilename, false)) {
            outputStream.write(jsonString.getBytes(StandardCharsets.UTF_8));
        }
    } catch (Exception e) {
        new ErrorDialog(shell, "Error", "Error saving metadata to JSON file : " + filename, e);
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) SerializableMetadataProvider(org.apache.hop.core.metadata.SerializableMetadataProvider) OutputStream(java.io.OutputStream) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) HopGui(org.apache.hop.ui.hopgui.HopGui) MessageBox(org.eclipse.swt.widgets.MessageBox) GuiMenuElement(org.apache.hop.core.gui.plugin.menu.GuiMenuElement)

Example 5 with GuiMenuElement

use of org.apache.hop.core.gui.plugin.menu.GuiMenuElement in project hop by apache.

the class HopGui method menuHelpAbout.

@GuiMenuElement(root = ID_MAIN_MENU, id = ID_MAIN_MENU_HELP_ABOUT, label = "i18n::HopGui.Menu.Help.About", parentId = ID_MAIN_MENU_HELP_PARENT_ID)
public void menuHelpAbout() {
    AboutDialog dialog = new AboutDialog(getShell());
    dialog.open();
}
Also used : AboutDialog(org.apache.hop.ui.hopgui.dialog.AboutDialog) GuiMenuElement(org.apache.hop.core.gui.plugin.menu.GuiMenuElement)

Aggregations

GuiMenuElement (org.apache.hop.core.gui.plugin.menu.GuiMenuElement)7 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)5 HopGui (org.apache.hop.ui.hopgui.HopGui)4 OutputStream (java.io.OutputStream)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 HopException (org.apache.hop.core.exception.HopException)3 MessageBox (org.eclipse.swt.widgets.MessageBox)3 Shell (org.eclipse.swt.widgets.Shell)3 Const (org.apache.hop.core.Const)2 IRunnableWithProgress (org.apache.hop.core.IRunnableWithProgress)2 GuiPlugin (org.apache.hop.core.gui.plugin.GuiPlugin)2 GuiKeyboardShortcut (org.apache.hop.core.gui.plugin.key.GuiKeyboardShortcut)2 GuiOsxKeyboardShortcut (org.apache.hop.core.gui.plugin.key.GuiOsxKeyboardShortcut)2 GuiToolbarElement (org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement)2 SerializableMetadataProvider (org.apache.hop.core.metadata.SerializableMetadataProvider)2 HopVfs (org.apache.hop.core.vfs.HopVfs)2 BaseMessages (org.apache.hop.i18n.BaseMessages)2 BaseDialog (org.apache.hop.ui.core.dialog.BaseDialog)2 ProgressMonitorDialog (org.apache.hop.ui.core.dialog.ProgressMonitorDialog)2 GuiResource (org.apache.hop.ui.core.gui.GuiResource)2