use of org.apache.hop.ui.hopgui.delegates.HopGuiFileOpenedExtension in project hop by apache.
the class DataProbeGuiPlugin method addLocation.
private void addLocation(IVariables variables, PipelineProbe pipelineProbe, PipelineMeta pipelineMeta, TransformMeta transformMeta) throws HopException {
// Allow our plugins (projects etc) to turn the filename into a relative path...
//
String probeFilename = pipelineMeta.getFilename();
HopGuiFileOpenedExtension ext = new HopGuiFileOpenedExtension(null, variables, probeFilename);
ExtensionPointHandler.callExtensionPoint(LogChannel.UI, variables, HopGuiExtensionPoint.HopGuiFileOpenedDialog.id, ext);
pipelineProbe.getDataProbeLocations().add(new DataProbeLocation(ext.filename, transformMeta.getName()));
}
use of org.apache.hop.ui.hopgui.delegates.HopGuiFileOpenedExtension in project hop by apache.
the class ActionPipelineGuiPlugin method copyAsActionToClipboard.
@GuiContextAction(id = "pipeline-graph-transform-10300-copy-pipeline-action", parentId = HopGuiPipelineContext.CONTEXT_ID, type = GuiActionType.Modify, name = "Copy as pipeline action", tooltip = "Copy this pipeline as an action so you can paste it in a workflow", image = "ui/images/copy.svg", category = "Basic", categoryOrder = "1")
public void copyAsActionToClipboard(HopGuiPipelineContext context) {
PipelineMeta pipelineMeta = context.getPipelineMeta();
HopGuiPipelineGraph pipelineGraph = context.getPipelineGraph();
IVariables variables = pipelineGraph.getVariables();
ActionPipeline actionPipeline = new ActionPipeline(pipelineMeta.getName());
HopGuiFileOpenedExtension ext = new HopGuiFileOpenedExtension(null, variables, pipelineMeta.getFilename());
//
try {
ExtensionPointHandler.callExtensionPoint(LogChannel.UI, variables, HopGuiExtensionPoint.HopGuiFileOpenedDialog.id, ext);
} catch (Exception xe) {
LogChannel.UI.logError("Error handling extension point 'HopGuiFileOpenDialog'", xe);
}
actionPipeline.setFileName(ext.filename);
//
try {
IHopMetadataProvider metadataProvider = pipelineGraph.getHopGui().getMetadataProvider();
IHopMetadataSerializer<PipelineRunConfiguration> serializer = metadataProvider.getSerializer(PipelineRunConfiguration.class);
List<String> configNames = serializer.listObjectNames();
if (!configNames.isEmpty()) {
if (configNames.size() == 1) {
actionPipeline.setRunConfiguration(configNames.get(0));
} else {
EnterSelectionDialog dialog = new EnterSelectionDialog(pipelineGraph.getShell(), configNames.toArray(new String[0]), "Select run configuration", "Select the pipeline run configuration to use in the action:");
String configName = dialog.open();
if (configName != null) {
actionPipeline.setRunConfiguration(configName);
}
}
}
} catch (Exception e) {
new ErrorDialog(pipelineGraph.getShell(), "Error", "Error selecting pipeline run configurations", e);
}
ActionMeta actionMeta = new ActionMeta(actionPipeline);
StringBuilder xml = new StringBuilder(5000).append(XmlHandler.getXmlHeader());
xml.append(XmlHandler.openTag(HopGuiWorkflowClipboardDelegate.XML_TAG_WORKFLOW_ACTIONS)).append(Const.CR);
xml.append(XmlHandler.openTag(HopGuiWorkflowClipboardDelegate.XML_TAG_ACTIONS)).append(Const.CR);
xml.append(actionMeta.getXml());
xml.append(XmlHandler.closeTag(HopGuiWorkflowClipboardDelegate.XML_TAG_ACTIONS)).append(Const.CR);
xml.append(XmlHandler.closeTag(HopGuiWorkflowClipboardDelegate.XML_TAG_WORKFLOW_ACTIONS)).append(Const.CR);
pipelineGraph.pipelineClipboardDelegate.toClipboard(xml.toString());
}
use of org.apache.hop.ui.hopgui.delegates.HopGuiFileOpenedExtension in project hop by apache.
the class ActionWorkflowGuiPlugin method copyAsActionToClipboard.
@GuiContextAction(id = "workflow-graph-workflow-copy-action", parentId = HopGuiWorkflowContext.CONTEXT_ID, type = GuiActionType.Modify, name = "Copy as workflow action", tooltip = "Copy this workflow as an action so you can paste it in another workflow", image = "ui/images/copy.svg", category = "Basic", categoryOrder = "1")
public void copyAsActionToClipboard(HopGuiWorkflowContext context) {
WorkflowMeta workflowMeta = context.getWorkflowMeta();
HopGuiWorkflowGraph workflowGraph = context.getWorkflowGraph();
HopGui hopGui = workflowGraph.getHopGui();
IVariables variables = workflowGraph.getVariables();
ActionWorkflow actionWorkflow = new ActionWorkflow(workflowMeta.getName());
HopGuiFileOpenedExtension ext = new HopGuiFileOpenedExtension(null, variables, workflowMeta.getFilename());
//
try {
ExtensionPointHandler.callExtensionPoint(LogChannel.UI, variables, HopGuiExtensionPoint.HopGuiFileOpenedDialog.id, ext);
} catch (Exception xe) {
LogChannel.UI.logError("Error handling extension point 'HopGuiFileOpenDialog'", xe);
}
actionWorkflow.setFileName(ext.filename);
//
try {
IHopMetadataProvider metadataProvider = workflowGraph.getHopGui().getMetadataProvider();
IHopMetadataSerializer<WorkflowRunConfiguration> serializer = metadataProvider.getSerializer(WorkflowRunConfiguration.class);
List<String> configNames = serializer.listObjectNames();
if (!configNames.isEmpty()) {
if (configNames.size() == 1) {
actionWorkflow.setRunConfiguration(configNames.get(0));
} else {
EnterSelectionDialog dialog = new EnterSelectionDialog(workflowGraph.getShell(), configNames.toArray(new String[0]), "Select run configuration", "Select the workflow run configuration to use in the action:");
String configName = dialog.open();
if (configName != null) {
actionWorkflow.setRunConfiguration(configName);
}
}
}
} catch (Exception e) {
new ErrorDialog(workflowGraph.getShell(), "Error", "Error selecting workflow run configurations", e);
}
ActionMeta actionMeta = new ActionMeta(actionWorkflow);
StringBuilder xml = new StringBuilder(5000).append(XmlHandler.getXmlHeader());
xml.append(XmlHandler.openTag(HopGuiWorkflowClipboardDelegate.XML_TAG_WORKFLOW_ACTIONS)).append(Const.CR);
xml.append(XmlHandler.openTag(HopGuiWorkflowClipboardDelegate.XML_TAG_ACTIONS)).append(Const.CR);
xml.append(actionMeta.getXml());
xml.append(XmlHandler.closeTag(HopGuiWorkflowClipboardDelegate.XML_TAG_ACTIONS)).append(Const.CR);
xml.append(XmlHandler.closeTag(HopGuiWorkflowClipboardDelegate.XML_TAG_WORKFLOW_ACTIONS)).append(Const.CR);
workflowGraph.workflowClipboardDelegate.toClipboard(xml.toString());
}
use of org.apache.hop.ui.hopgui.delegates.HopGuiFileOpenedExtension in project hop by apache.
the class BaseDialog method presentFileDialog.
public static final String presentFileDialog(boolean save, Shell shell, TextVar textVar, IVariables variables, FileObject fileObject, String[] filterExtensions, String[] filterNames, boolean folderAndFile) {
boolean useNativeFileDialog = "Y".equalsIgnoreCase(HopGui.getInstance().getVariables().getVariable("HOP_USE_NATIVE_FILE_DIALOG", "N"));
IFileDialog dialog;
if (useNativeFileDialog) {
FileDialog fileDialog = new FileDialog(shell, save ? SWT.SAVE : SWT.OPEN);
dialog = new NativeFileDialog(fileDialog);
} else {
HopVfsFileDialog vfsDialog = new HopVfsFileDialog(shell, variables, fileObject, false, save);
if (save) {
if (fileObject != null) {
vfsDialog.setSaveFilename(fileObject.getName().getBaseName());
try {
vfsDialog.setFilterPath(HopVfs.getFilename(fileObject.getParent()));
} catch (FileSystemException fse) {
// This wasn't a valid filename, ignore the error to reduce spamming
}
} else {
//
if (filterExtensions != null && filterExtensions.length > 0) {
String filterExtension = filterExtensions[0];
String extension = filterExtension.substring(filterExtension.lastIndexOf("."));
vfsDialog.setSaveFilename("filename" + extension);
}
}
}
dialog = vfsDialog;
}
if (save) {
dialog.setText(BaseMessages.getString(PKG, "BaseDialog.SaveFile"));
} else {
dialog.setText(BaseMessages.getString(PKG, "BaseDialog.OpenFile"));
}
if (filterExtensions == null || filterNames == null) {
dialog.setFilterExtensions(new String[] { "*.*" });
dialog.setFilterNames(new String[] { BaseMessages.getString(PKG, "System.FileType.AllFiles") });
} else {
dialog.setFilterExtensions(filterExtensions);
dialog.setFilterNames(filterNames);
}
if (fileObject != null) {
dialog.setFileName(HopVfs.getFilename(fileObject));
}
if (variables != null && textVar != null && textVar.getText() != null) {
dialog.setFileName(variables.resolve(textVar.getText()));
}
AtomicBoolean doIt = new AtomicBoolean(true);
try {
ExtensionPointHandler.callExtensionPoint(LogChannel.UI, variables, HopGuiExtensionPoint.HopGuiFileOpenDialog.id, new HopGuiFileDialogExtension(doIt, dialog));
} catch (Exception xe) {
LogChannel.UI.logError("Error handling extension point 'HopGuiFileOpenDialog'", xe);
}
String filename = null;
if (!doIt.get() || dialog.open() != null) {
if (folderAndFile) {
filename = FilenameUtils.concat(dialog.getFilterPath(), dialog.getFileName());
} else {
filename = dialog.getFileName();
}
try {
HopGuiFileOpenedExtension openedExtension = new HopGuiFileOpenedExtension(dialog, variables, filename);
ExtensionPointHandler.callExtensionPoint(LogChannel.UI, variables, HopGuiExtensionPoint.HopGuiFileOpenedDialog.id, openedExtension);
if (openedExtension.filename != null) {
filename = openedExtension.filename;
}
} catch (Exception xe) {
LogChannel.UI.logError("Error handling extension point 'HopGuiFileOpenDialog'", xe);
}
if (textVar != null) {
textVar.setText(filename);
}
}
return filename;
}
use of org.apache.hop.ui.hopgui.delegates.HopGuiFileOpenedExtension in project hop by apache.
the class HopGuiWorkflowClipboardDelegate method pasteNoXmlContent.
private void pasteNoXmlContent(WorkflowMeta workflowMeta, String clipboardContent, Point location) {
try {
//
if (clipboardContent.startsWith("file:///") || clipboardContent.startsWith("/")) {
String[] filenames = clipboardContent.split(Const.CR);
for (String filename : filenames) {
String cleanFilename = HopVfs.getFilename(HopVfs.getFileObject(filename));
// See if the filename needs to be treated somehow...
// We don't have a file dialog so we pass in null.
//
HopGuiFileOpenedExtension ext = new HopGuiFileOpenedExtension(null, hopGui.getVariables(), cleanFilename);
ExtensionPointHandler.callExtensionPoint(LogChannel.UI, workflowGraph.getVariables(), HopGuiExtensionPoint.HopGuiFileOpenedDialog.id, ext);
if (ext.filename != null) {
cleanFilename = ext.filename;
}
File file = new File(cleanFilename);
HopGuiWorkflowClipboardExtension wce = new HopGuiWorkflowClipboardExtension();
wce.filename = cleanFilename;
wce.file = file;
wce.workflowGraph = workflowGraph;
wce.workflowMeta = workflowMeta;
wce.workflowClipboardDelegate = this;
wce.location = location;
// Try the plugins to see which one responds
//
ExtensionPointHandler.callExtensionPoint(LogChannel.UI, workflowGraph.getVariables(), HopGuiExtensionPoint.HopGuiWorkflowClipboardFilePaste.id, wce);
}
} else {
// Add a notepad
//
NotePadMeta notePadMeta = new NotePadMeta(clipboardContent, location.x, location.y, ConstUi.NOTE_MIN_SIZE, ConstUi.NOTE_MIN_SIZE);
workflowMeta.addNote(notePadMeta);
hopGui.undoDelegate.addUndoNew(workflowMeta, new NotePadMeta[] { notePadMeta }, new int[] { workflowMeta.indexOfNote(notePadMeta) });
shiftLocation(location);
}
} catch (Exception e) {
// "Error pasting transforms...",
// "I was unable to paste transforms to this pipeline"
new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "HopGui.Dialog.UnablePasteEntries.Title"), BaseMessages.getString(PKG, "HopGui.Dialog.UnablePasteEntries.Message"), e);
}
}
Aggregations