use of org.apache.hop.ui.hopgui.file.IHopFileType 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.IHopFileType 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.IHopFileType 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;
}
}
use of org.apache.hop.ui.hopgui.file.IHopFileType in project hop by apache.
the class ExplorerPerspective method loadTypeImages.
private void loadTypeImages(Composite parentComposite) {
typeImageMap = new HashMap<>();
int iconSize = (int) (PropsUi.getInstance().getZoomFactor() * 16);
for (IHopFileType fileType : fileTypes) {
String imageFilename = fileType.getFileTypeImage();
if (imageFilename != null) {
try {
SvgCacheEntry svgCacheEntry = SvgCache.loadSvg(new SvgFile(imageFilename, fileType.getClass().getClassLoader()));
SwtUniversalImageSvg imageSvg = new SwtUniversalImageSvg(new SvgImage(svgCacheEntry.getSvgDocument()));
Image image = imageSvg.getAsBitmapForSize(hopGui.getDisplay(), iconSize, iconSize);
typeImageMap.put(fileType.getName(), image);
} catch (Exception e) {
hopGui.getLog().logError("Error loading image : '" + imageFilename + "' for type '" + fileType.getName() + "'", e);
}
}
}
// Properly dispose images when done...
//
parentComposite.addListener(SWT.Dispose, e -> {
for (Image image : typeImageMap.values()) {
image.dispose();
}
});
}
use of org.apache.hop.ui.hopgui.file.IHopFileType in project hop by apache.
the class HopGuiWorkflowGraph method loadReferencedObject.
protected void loadReferencedObject(ActionMeta actionCopy, int index) {
try {
IHasFilename referencedMeta = actionCopy.getAction().loadReferencedObject(index, hopGui.getMetadataProvider(), variables);
if (referencedMeta == null) {
// Sorry, nothing loaded
return;
}
IHopFileType fileTypeHandler = hopGui.getPerspectiveManager().findFileTypeHandler(referencedMeta);
fileTypeHandler.openFile(hopGui, referencedMeta.getFilename(), hopGui.getVariables());
} catch (Exception e) {
new ErrorDialog(hopShell(), BaseMessages.getString(PKG, "HopGuiWorkflowGraph.ErrorDialog.FileNotLoaded.Header"), BaseMessages.getString(PKG, "HopGuiWorkflowGraph.ErrorDialog.FileNotLoaded.Message"), e);
}
}
Aggregations