use of org.apache.hop.ui.hopgui.file.workflow.HopGuiWorkflowGraph 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.file.workflow.HopGuiWorkflowGraph in project hop by apache.
the class HopGuiFileDelegate method exportToSvg.
public void exportToSvg() {
try {
String svgXml = null;
IVariables variables = null;
String proposedName = null;
HopGuiPipelineGraph pipelineGraph = HopGui.getActivePipelineGraph();
if (pipelineGraph != null) {
PipelineMeta pipelineMeta = pipelineGraph.getPipelineMeta();
variables = pipelineGraph.getVariables();
svgXml = PipelineSvgPainter.generatePipelineSvg(pipelineMeta, 1.0f, pipelineGraph.getVariables());
proposedName = pipelineMeta.getName() + ".svg";
}
HopGuiWorkflowGraph workflowGraph = HopGui.getActiveWorkflowGraph();
if (workflowGraph != null) {
WorkflowMeta workflowMeta = workflowGraph.getWorkflowMeta();
variables = workflowGraph.getVariables();
svgXml = WorkflowSvgPainter.generateWorkflowSvg(workflowMeta, 1.0f, workflowGraph.getVariables());
proposedName = workflowMeta.getName() + ".svg";
}
if (svgXml != null) {
String proposedFilename = variables.getVariable("user.home") + File.separator + proposedName;
FileObject proposedFile = HopVfs.getFileObject(proposedFilename);
String filename = BaseDialog.presentFileDialog(true, hopGui.getShell(), null, variables, proposedFile, new String[] { "*.svg" }, new String[] { "SVG Files" }, true);
if (filename != null) {
String realFilename = variables.resolve(filename);
FileObject file = HopVfs.getFileObject(realFilename);
if (file.exists()) {
MessageBox box = new MessageBox(hopGui.getShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION);
box.setText("File exists");
box.setMessage("This file already exists. Do you want to overwrite it?");
int answer = box.open();
if ((answer & SWT.YES) == 0) {
return;
}
}
OutputStream outputStream = null;
try {
outputStream = HopVfs.getOutputStream(file, false);
outputStream.write(svgXml.getBytes(Const.XML_ENCODING));
} finally {
if (outputStream != null) {
outputStream.close();
}
}
}
}
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), "Error", "Error exporting to SVG", e);
}
}
use of org.apache.hop.ui.hopgui.file.workflow.HopGuiWorkflowGraph in project hop by apache.
the class HopDataOrchestrationPerspective method addWorkflow.
/**
* Add a new workflow tab to the tab folder...
*
* @param workflowMeta
* @return The file type handler
*/
public IHopFileTypeHandler addWorkflow(HopGui hopGui, WorkflowMeta workflowMeta, HopWorkflowFileType workflowFile) throws HopException {
CTabItem tabItem = new CTabItem(tabFolder, SWT.CLOSE);
tabItem.setImage(GuiResource.getInstance().getImageWorkflow());
HopGuiWorkflowGraph workflowGraph = new HopGuiWorkflowGraph(tabFolder, hopGui, tabItem, this, workflowMeta, workflowFile);
tabItem.setControl(workflowGraph);
// Update the internal variables (file specific) in the workflow graph variables
//
workflowMeta.setInternalHopVariables(workflowGraph.getVariables());
// Update the variables using the list of parameters
//
hopGui.setParametersAsVariablesInUI(workflowMeta, workflowGraph.getVariables());
// Set the tab name
//
updateTabLabel(tabItem, workflowMeta.getFilename(), workflowMeta.getName());
// Switch to the tab
tabFolder.setSelection(tabItem);
activeItem = new TabItemHandler(tabItem, workflowGraph);
items.add(activeItem);
//
while (tabSelectionHistory.size() - 1 > tabSelectionIndex) {
tabSelectionHistory.pop();
}
int tabIndex = tabFolder.indexOf(tabItem);
tabSelectionHistory.add(tabIndex);
tabSelectionIndex = tabSelectionHistory.size() - 1;
try {
ExtensionPointHandler.callExtensionPoint(hopGui.getLog(), workflowGraph.getVariables(), HopExtensionPoint.HopGuiNewWorkflowTab.id, workflowGraph);
} catch (Exception e) {
throw new HopException("Error calling extension point plugin for plugin id " + HopExtensionPoint.HopGuiNewWorkflowTab.id + " trying to handle a new workflow tab", e);
}
workflowGraph.setFocus();
return workflowGraph;
}
use of org.apache.hop.ui.hopgui.file.workflow.HopGuiWorkflowGraph in project hop by apache.
the class HopGui method getActiveWorkflowGraph.
public static HopGuiWorkflowGraph getActiveWorkflowGraph() {
IHopPerspective activePerspective = HopGui.getInstance().getActivePerspective();
if (!(activePerspective instanceof HopDataOrchestrationPerspective)) {
return null;
}
HopDataOrchestrationPerspective perspective = (HopDataOrchestrationPerspective) activePerspective;
IHopFileTypeHandler typeHandler = perspective.getActiveFileTypeHandler();
if (!(typeHandler instanceof HopGuiWorkflowGraph)) {
return null;
}
return (HopGuiWorkflowGraph) typeHandler;
}
use of org.apache.hop.ui.hopgui.file.workflow.HopGuiWorkflowGraph in project hop by apache.
the class ActionLogIconClickedExtensionPoint method callExtensionPoint.
@Override
public void callExtensionPoint(ILogChannel log, IVariables variables, HopGuiWorkflowGraphExtension extension) throws HopException {
HopGuiWorkflowGraph workflowGraph = extension.getWorkflowGraph();
AreaOwner areaOwner = extension.getAreaOwner();
if (areaOwner == null) {
return;
}
if (areaOwner.getAreaType() == AreaOwner.AreaType.CUSTOM) {
if (areaOwner.getOwner() == null) {
return;
}
if (areaOwner.getOwner() instanceof String) {
String message = (String) areaOwner.getOwner();
if (message.startsWith(DrawAsyncLoggingIconExtensionPoint.STRING_AREA_OWNER_PREFIX)) {
String serviceName = message.substring(DrawAsyncLoggingIconExtensionPoint.STRING_AREA_OWNER_PREFIX.length());
if (StringUtils.isNotEmpty(serviceName)) {
MultiMetadataProvider metadataProvider = workflowGraph.getHopGui().getMetadataProvider();
IHopMetadataSerializer<AsyncWebService> serializer = metadataProvider.getSerializer(AsyncWebService.class);
if (serializer.exists(serviceName)) {
MetadataManager<AsyncWebService> manager = new MetadataManager<>(workflowGraph.getVariables(), metadataProvider, AsyncWebService.class);
manager.editMetadata(serviceName);
extension.setPreventingDefault(true);
}
}
}
}
}
}
Aggregations