Search in sources :

Example 1 with IHopPerspective

use of org.apache.hop.ui.hopgui.perspective.IHopPerspective in project hop by apache.

the class HopGuiFileDelegate method fileOpenRecent.

/**
 * Show all the recent files in a new dialog...
 */
public void fileOpenRecent() {
    // Get the recent files for the active perspective...
    // 
    IHopPerspective perspective = hopGui.getActivePerspective();
    try {
        // Let's limit ourselves to 100 operations...
        // 
        List<AuditEvent> events = AuditManager.findEvents(HopNamespace.getNamespace(), "file", "open", 100, true);
        Set<String> filenames = new HashSet<>();
        List<RowMetaAndData> rows = new ArrayList<>();
        IRowMeta rowMeta = new RowMeta();
        rowMeta.addValueMeta(new ValueMetaString("filename"));
        rowMeta.addValueMeta(new ValueMetaString("operation"));
        rowMeta.addValueMeta(new ValueMetaString("date"));
        for (AuditEvent event : events) {
            String filename = event.getName();
            if (!filenames.contains(filename)) {
                filenames.add(filename);
                String operation = event.getOperation();
                String dateString = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(event.getDate());
                rows.add(new RowMetaAndData(rowMeta, new Object[] { filename, operation, dateString }));
            }
        }
        SelectRowDialog rowDialog = new SelectRowDialog(hopGui.getShell(), hopGui.getVariables(), SWT.NONE, rows);
        rowDialog.setTitle("Select the file to open");
        RowMetaAndData row = rowDialog.open();
        if (row != null) {
            String filename = row.getString("filename", null);
            hopGui.fileDelegate.fileOpen(filename);
        }
    } catch (Exception e) {
        new ErrorDialog(hopGui.getShell(), "Error", "Error getting list of recently opened files", e);
    }
}
Also used : ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) RowMeta(org.apache.hop.core.row.RowMeta) IRowMeta(org.apache.hop.core.row.IRowMeta) IRowMeta(org.apache.hop.core.row.IRowMeta) ArrayList(java.util.ArrayList) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) SelectRowDialog(org.apache.hop.ui.core.dialog.SelectRowDialog) HopException(org.apache.hop.core.exception.HopException) RowMetaAndData(org.apache.hop.core.RowMetaAndData) IHopPerspective(org.apache.hop.ui.hopgui.perspective.IHopPerspective) AuditEvent(org.apache.hop.history.AuditEvent) FileObject(org.apache.commons.vfs2.FileObject) SimpleDateFormat(java.text.SimpleDateFormat) HashSet(java.util.HashSet)

Example 2 with IHopPerspective

use of org.apache.hop.ui.hopgui.perspective.IHopPerspective 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;
}
Also used : IHopFileType(org.apache.hop.ui.hopgui.file.IHopFileType) IHopFileTypeHandler(org.apache.hop.ui.hopgui.file.IHopFileTypeHandler) IHopPerspective(org.apache.hop.ui.hopgui.perspective.IHopPerspective) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) HopException(org.apache.hop.core.exception.HopException)

Example 3 with IHopPerspective

use of org.apache.hop.ui.hopgui.perspective.IHopPerspective in project hop by apache.

the class HopGuiFileDelegate method closeAllFiles.

public void closeAllFiles() {
    for (IHopPerspective perspective : hopGui.getPerspectiveManager().getPerspectives()) {
        List<TabItemHandler> tabItemHandlers = perspective.getItems();
        if (tabItemHandlers != null) {
            // Copy the list to avoid changing the list we're editing (closing items)
            // 
            List<TabItemHandler> handlers = new ArrayList<>(tabItemHandlers);
            for (TabItemHandler tabItemHandler : handlers) {
                IHopFileTypeHandler typeHandler = tabItemHandler.getTypeHandler();
                typeHandler.close();
            }
        }
    }
}
Also used : IHopFileTypeHandler(org.apache.hop.ui.hopgui.file.IHopFileTypeHandler) IHopPerspective(org.apache.hop.ui.hopgui.perspective.IHopPerspective) ArrayList(java.util.ArrayList) TabItemHandler(org.apache.hop.ui.hopgui.perspective.TabItemHandler)

Example 4 with IHopPerspective

use of org.apache.hop.ui.hopgui.perspective.IHopPerspective in project hop by apache.

the class HopGui method getActivePipelineGraph.

/**
 * Convenience method to pick up the active pipeline graph
 *
 * @return The active pipeline graph or null if none is active
 */
public static HopGuiPipelineGraph getActivePipelineGraph() {
    IHopPerspective activePerspective = HopGui.getInstance().getActivePerspective();
    if (!(activePerspective instanceof HopDataOrchestrationPerspective)) {
        return null;
    }
    HopDataOrchestrationPerspective perspective = (HopDataOrchestrationPerspective) activePerspective;
    IHopFileTypeHandler typeHandler = perspective.getActiveFileTypeHandler();
    if (!(typeHandler instanceof HopGuiPipelineGraph)) {
        return null;
    }
    return (HopGuiPipelineGraph) typeHandler;
}
Also used : IHopFileTypeHandler(org.apache.hop.ui.hopgui.file.IHopFileTypeHandler) HopDataOrchestrationPerspective(org.apache.hop.ui.hopgui.perspective.dataorch.HopDataOrchestrationPerspective) IHopPerspective(org.apache.hop.ui.hopgui.perspective.IHopPerspective) HopGuiPipelineGraph(org.apache.hop.ui.hopgui.file.pipeline.HopGuiPipelineGraph)

Example 5 with IHopPerspective

use of org.apache.hop.ui.hopgui.perspective.IHopPerspective 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;
}
Also used : IHopFileTypeHandler(org.apache.hop.ui.hopgui.file.IHopFileTypeHandler) HopGuiWorkflowGraph(org.apache.hop.ui.hopgui.file.workflow.HopGuiWorkflowGraph) HopDataOrchestrationPerspective(org.apache.hop.ui.hopgui.perspective.dataorch.HopDataOrchestrationPerspective) IHopPerspective(org.apache.hop.ui.hopgui.perspective.IHopPerspective)

Aggregations

IHopPerspective (org.apache.hop.ui.hopgui.perspective.IHopPerspective)10 IHopFileTypeHandler (org.apache.hop.ui.hopgui.file.IHopFileTypeHandler)7 HopException (org.apache.hop.core.exception.HopException)5 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)4 ArrayList (java.util.ArrayList)3 GuiKeyboardShortcut (org.apache.hop.core.gui.plugin.key.GuiKeyboardShortcut)3 GuiOsxKeyboardShortcut (org.apache.hop.core.gui.plugin.key.GuiOsxKeyboardShortcut)3 TabItemHandler (org.apache.hop.ui.hopgui.perspective.TabItemHandler)2 HopDataOrchestrationPerspective (org.apache.hop.ui.hopgui.perspective.dataorch.HopDataOrchestrationPerspective)2 FileOutputStream (java.io.FileOutputStream)1 PrintStream (java.io.PrintStream)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 SimpleDateFormat (java.text.SimpleDateFormat)1 java.util (java.util)1 HashSet (java.util.HashSet)1 List (java.util.List)1 TeeOutputStream (org.apache.commons.io.output.TeeOutputStream)1 FileObject (org.apache.commons.vfs2.FileObject)1