Search in sources :

Example 1 with HopFileTypeRegistry

use of org.apache.hop.ui.hopgui.file.HopFileTypeRegistry in project hop by apache.

the class HopGuiFileDelegate method fileOpen.

public void fileOpen() {
    try {
        // Ask for the file name
        // Check in the registry for extensions and names...
        // 
        HopFileTypeRegistry fileRegistry = HopFileTypeRegistry.getInstance();
        String filename = BaseDialog.presentFileDialog(hopGui.getShell(), fileRegistry.getFilterExtensions(), fileRegistry.getFilterNames(), true);
        if (filename == null) {
            return;
        }
        fileOpen(hopGui.getVariables().resolve(filename));
    } catch (Exception e) {
        new ErrorDialog(hopGui.getShell(), "Error", "Error opening file", e);
    }
}
Also used : HopFileTypeRegistry(org.apache.hop.ui.hopgui.file.HopFileTypeRegistry) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) HopException(org.apache.hop.core.exception.HopException)

Example 2 with HopFileTypeRegistry

use of org.apache.hop.ui.hopgui.file.HopFileTypeRegistry in project hop by apache.

the class HopGuiFileDelegate method fileOpen.

public IHopFileTypeHandler fileOpen(String filename) throws Exception {
    HopFileTypeRegistry fileRegistry = HopFileTypeRegistry.getInstance();
    IHopFileType hopFile = fileRegistry.findHopFileType(filename);
    if (hopFile == null) {
        throw new HopException("We looked at " + fileRegistry.getFileTypes().size() + " different Hop GUI file types but none know how to open file '" + filename + "'");
    }
    IHopFileTypeHandler fileTypeHandler = hopFile.openFile(hopGui, filename, hopGui.getVariables());
    if (fileTypeHandler != null) {
        hopGui.handleFileCapabilities(hopFile, fileTypeHandler.hasChanged(), false, false);
        // Also save the state of Hop GUI
        // 
        hopGui.auditDelegate.writeLastOpenFiles();
    }
    return fileTypeHandler;
}
Also used : HopFileTypeRegistry(org.apache.hop.ui.hopgui.file.HopFileTypeRegistry) IHopFileType(org.apache.hop.ui.hopgui.file.IHopFileType) IHopFileTypeHandler(org.apache.hop.ui.hopgui.file.IHopFileTypeHandler) HopException(org.apache.hop.core.exception.HopException)

Example 3 with HopFileTypeRegistry

use of org.apache.hop.ui.hopgui.file.HopFileTypeRegistry in project hop by apache.

the class HopGui method getContextHandlers.

/**
 * What are the contexts to consider: - the file types registered - the available metadata types
 *
 * @return The list of context handlers
 */
@Override
public List<IGuiContextHandler> getContextHandlers() {
    List<IGuiContextHandler> contextHandlers = new ArrayList<>();
    // Get all the file context handlers
    // 
    HopFileTypeRegistry registry = HopFileTypeRegistry.getInstance();
    List<IHopFileType> hopFileTypes = registry.getFileTypes();
    for (IHopFileType hopFileType : hopFileTypes) {
        contextHandlers.addAll(hopFileType.getContextHandlers());
    }
    // Get all the metadata context handlers...
    // 
    contextHandlers.addAll(new MetadataContext(this, metadataProvider).getContextHandlers());
    return contextHandlers;
}
Also used : HopFileTypeRegistry(org.apache.hop.ui.hopgui.file.HopFileTypeRegistry) IHopFileType(org.apache.hop.ui.hopgui.file.IHopFileType) IGuiContextHandler(org.apache.hop.ui.hopgui.context.IGuiContextHandler) MetadataContext(org.apache.hop.ui.hopgui.context.metadata.MetadataContext)

Aggregations

HopFileTypeRegistry (org.apache.hop.ui.hopgui.file.HopFileTypeRegistry)3 HopException (org.apache.hop.core.exception.HopException)2 IHopFileType (org.apache.hop.ui.hopgui.file.IHopFileType)2 ValueMetaString (org.apache.hop.core.row.value.ValueMetaString)1 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)1 IGuiContextHandler (org.apache.hop.ui.hopgui.context.IGuiContextHandler)1 MetadataContext (org.apache.hop.ui.hopgui.context.metadata.MetadataContext)1 IHopFileTypeHandler (org.apache.hop.ui.hopgui.file.IHopFileTypeHandler)1