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);
}
}
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);
}
}
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);
}
}
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);
}
}
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();
}
Aggregations