use of org.apache.hop.ui.hopgui.file.IHopFileTypeHandler in project hop by apache.
the class HopNeo4jPerspective method openTransform.
private void openTransform(Session session, String name, String type, String id) {
LogChannel.UI.logDetailed("Open transform : " + id + ", name : " + name + ", type: " + type);
Map<String, Object> params = new HashMap<>();
params.put("subjectName", name);
params.put("subjectType", type);
params.put("subjectId", id);
StringBuilder cypher = new StringBuilder();
cypher.append(// TRANSFORM
"MATCH(e:Execution { name : $subjectName, type : $subjectType, id : $subjectId } )");
cypher.append(// Transform
"-[:EXECUTION_OF_TRANSFORM]->(t:Transform { name : $subjectName } )");
cypher.append("-[:TRANSFORM_OF_PIPELINE]->(p:Pipeline) ");
cypher.append("RETURN p.filename, t.name ");
String[] names = session.readTransaction(tx -> {
Result statementResult = tx.run(cypher.toString(), params);
if (!statementResult.hasNext()) {
statementResult.consume();
// No file found
return null;
}
Record record = statementResult.next();
statementResult.consume();
String filename = LoggingCore.getStringValue(record, 0);
String transformName = LoggingCore.getStringValue(record, 1);
return new String[] { filename, transformName };
});
if (names == null) {
return;
}
String filename = names[0];
String transformName = names[1];
if (StringUtils.isEmpty(filename)) {
return;
}
try {
hopGui.fileDelegate.fileOpen(filename);
if (StringUtils.isEmpty(transformName)) {
return;
}
HopDataOrchestrationPerspective perspective = HopGui.getDataOrchestrationPerspective();
IHopFileTypeHandler typeHandler = perspective.getActiveFileTypeHandler();
if (typeHandler == null || !(typeHandler instanceof HopGuiPipelineGraph)) {
return;
}
HopGuiPipelineGraph graph = (HopGuiPipelineGraph) typeHandler;
PipelineMeta pipelineMeta = graph.getPipelineMeta();
TransformMeta transformMeta = pipelineMeta.findTransform(transformName);
if (transformMeta == null) {
return;
}
pipelineMeta.unselectAll();
transformMeta.setSelected(true);
graph.editTransform(pipelineMeta, transformMeta);
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.OpeningTransform.Dialog.Header"), BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.OpeningTransform.Dialog.Message"), e);
}
}
use of org.apache.hop.ui.hopgui.file.IHopFileTypeHandler in project hop by apache.
the class TestingGuiPlugin method getActivePipelineMeta.
/**
* Get the active pipeline. If we don't have an active one, return null
*
* @return The active pipeline or null
*/
public static final PipelineMeta getActivePipelineMeta() {
IHopFileTypeHandler handler = HopGui.getInstance().getActiveFileTypeHandler();
//
if (handler == null || handler.getSubject() == null) {
return null;
}
Object subject = handler.getSubject();
if (!(subject instanceof PipelineMeta)) {
return null;
}
// On with the program
//
PipelineMeta pipelineMeta = (PipelineMeta) subject;
return pipelineMeta;
}
use of org.apache.hop.ui.hopgui.file.IHopFileTypeHandler in project hop by apache.
the class HopGuiFileDelegate method fileSave.
public void fileSave() {
try {
IHopFileTypeHandler typeHandler = getActiveFileTypeHandler();
IHopFileType fileType = typeHandler.getFileType();
if (fileType.hasCapability(IHopFileType.CAPABILITY_SAVE)) {
//
if (StringUtils.isEmpty(typeHandler.getFilename()) && !fileType.hasCapability(IHopFileType.CAPABILITY_HANDLE_METADATA)) {
// Ask for the filename: saveAs
//
fileSaveAs();
} else {
typeHandler.save();
}
}
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), "Error", "Error saving file", e);
}
}
use of org.apache.hop.ui.hopgui.file.IHopFileTypeHandler in project hop by apache.
the class HopGuiFileDelegate method fileClose.
public boolean fileClose() {
try {
IHopPerspective perspective = hopGui.getActivePerspective();
IHopFileTypeHandler typeHandler = getActiveFileTypeHandler();
IHopFileType fileType = typeHandler.getFileType();
if (fileType.hasCapability(IHopFileType.CAPABILITY_CLOSE)) {
perspective.remove(typeHandler);
}
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), "Error", "Error saving/closing file", e);
}
return false;
}
use of org.apache.hop.ui.hopgui.file.IHopFileTypeHandler in project hop by apache.
the class HopGuiFileDelegate method fileSaveAs.
/**
* We need to figure out which file is open at the given time so we can save it.
* To do this we see which is the active perspective.
* Then we ask the perspective for the shown/active file.
* We then know the filter extension and name so we can show a dialog.
* We can then also have the {@link IHopFileType to save the file.
*
* @return The original filename, not having any variables replaced. It returns null if no file was saved
*/
public String fileSaveAs() {
try {
IHopFileTypeHandler typeHandler = getActiveFileTypeHandler();
IHopFileType fileType = typeHandler.getFileType();
if (!fileType.hasCapability(IHopFileType.CAPABILITY_SAVE_AS)) {
return null;
}
String filename = BaseDialog.presentFileDialog(true, hopGui.getShell(), fileType.getFilterExtensions(), fileType.getFilterNames(), true);
if (filename == null) {
return null;
}
filename = hopGui.getVariables().resolve(filename);
typeHandler.saveAs(filename);
// Also save the state of Hop GUI
//
hopGui.auditDelegate.writeLastOpenFiles();
return filename;
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), "Error", "Error saving file", e);
return null;
}
}
Aggregations