Search in sources :

Example 1 with TabItemHandler

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

the class HopGuiPipelineTransformContext method openReferencedObject.

public static final void openReferencedObject(PipelineMeta pipelineMeta, IVariables variables, ITransformMeta iTransformMeta, String objectDescription, int index) {
    HopGui hopGui = HopGui.getInstance();
    try {
        IHasFilename hasFilename = iTransformMeta.loadReferencedObject(index, pipelineMeta.getMetadataProvider(), variables);
        if (hasFilename != null) {
            String filename = variables.resolve(hasFilename.getFilename());
            // Is this object already loaded?
            // 
            HopDataOrchestrationPerspective perspective = HopGui.getDataOrchestrationPerspective();
            TabItemHandler tabItemHandler = perspective.findTabItemHandlerWithFilename(filename);
            if (tabItemHandler != null) {
                perspective.switchToTab(tabItemHandler);
            } else {
                hopGui.fileDelegate.fileOpen(filename);
            }
        }
    } catch (Exception e) {
        new ErrorDialog(hopGui.getShell(), "Error", "Error opening referenced object '" + objectDescription + "'", e);
    }
}
Also used : IHasFilename(org.apache.hop.core.file.IHasFilename) HopDataOrchestrationPerspective(org.apache.hop.ui.hopgui.perspective.dataorch.HopDataOrchestrationPerspective) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) TabItemHandler(org.apache.hop.ui.hopgui.perspective.TabItemHandler) HopGui(org.apache.hop.ui.hopgui.HopGui)

Example 2 with TabItemHandler

use of org.apache.hop.ui.hopgui.perspective.TabItemHandler 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 3 with TabItemHandler

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

the class HopDataOrchestrationPerspective method initialize.

@Override
public void initialize(HopGui hopGui, Composite parent) {
    this.hopGui = hopGui;
    this.parent = parent;
    PropsUi props = PropsUi.getInstance();
    composite = new Composite(parent, SWT.NONE);
    FormLayout layout = new FormLayout();
    layout.marginRight = props.getMargin();
    layout.marginBottom = props.getMargin();
    composite.setLayout(layout);
    FormData formData = new FormData();
    formData.left = new FormAttachment(0, 0);
    formData.top = new FormAttachment(0, 0);
    formData.right = new FormAttachment(100, 0);
    formData.bottom = new FormAttachment(100, 0);
    composite.setLayoutData(formData);
    // A tab folder covers the complete area...
    // 
    tabFolder = new CTabFolder(composite, SWT.MULTI | SWT.BORDER);
    props.setLook(tabFolder, Props.WIDGET_STYLE_TAB);
    FormData fdLabel = new FormData();
    fdLabel.left = new FormAttachment(0, 0);
    fdLabel.right = new FormAttachment(100, 0);
    fdLabel.top = new FormAttachment(0, 0);
    fdLabel.bottom = new FormAttachment(100, 0);
    tabFolder.setLayoutData(fdLabel);
    tabFolder.addCTabFolder2Listener(new CTabFolder2Adapter() {

        @Override
        public void close(CTabFolderEvent event) {
            handleTabCloseEvent(event);
        }
    });
    tabFolder.addListener(SWT.Selection, event -> handleTabSelectionEvent(event));
    // Create tab item context menu
    Menu menu = new Menu(tabFolder);
    tabFolder.setMenu(menu);
    tabFolder.addListener(SWT.MenuDetect, event -> handleTabMenuDetectEvent(event));
    // Create menu item
    MenuItem miClose = new MenuItem(menu, SWT.NONE);
    miClose.setText(BaseMessages.getString(PKG, "DataOrchestrationPerspective.Close.Button.Text"));
    miClose.addListener(SWT.Selection, event -> {
        if (activeItem != null) {
            activeItem.getTypeHandler().close();
        }
    });
    MenuItem miCloseOthers = new MenuItem(menu, SWT.NONE);
    miCloseOthers.setText(BaseMessages.getString(PKG, "DataOrchestrationPerspective.CloseOther.Button.Text"));
    miCloseOthers.addListener(SWT.Selection, event -> {
        TabItemHandler currentItem = activeItem;
        items.forEach(item -> {
            if (!item.equals(currentItem)) {
                // FIXME: Works only if you activate the item
                activeItem = item;
                item.getTypeHandler().close();
            }
        });
    });
    MenuItem miCloseAll = new MenuItem(menu, SWT.NONE);
    miCloseAll.setText(BaseMessages.getString(PKG, "DataOrchestrationPerspective.CloseAll.Button.Text"));
    miCloseAll.addListener(SWT.Selection, event -> items.forEach(item -> {
        // FIXME: Works only if you activate the item
        activeItem = item;
        item.getTypeHandler().close();
    }));
    // Support reorder tab item
    new TabFolderReorder(tabFolder);
    HopGuiKeyHandler.getInstance().addParentObjectToHandle(this);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) EmptyHopFileTypeHandler(org.apache.hop.ui.hopgui.file.empty.EmptyHopFileTypeHandler) IHopPerspective(org.apache.hop.ui.hopgui.perspective.IHopPerspective) Arrays(java.util.Arrays) HopPipelineFileType(org.apache.hop.ui.hopgui.file.pipeline.HopPipelineFileType) Props(org.apache.hop.core.Props) ISearchable(org.apache.hop.core.search.ISearchable) HopException(org.apache.hop.core.exception.HopException) WorkflowMeta(org.apache.hop.workflow.WorkflowMeta) IHopFileTypeHandler(org.apache.hop.ui.hopgui.file.IHopFileTypeHandler) HopGui(org.apache.hop.ui.hopgui.HopGui) GuiPlugin(org.apache.hop.core.gui.plugin.GuiPlugin) TabItemHandler(org.apache.hop.ui.hopgui.perspective.TabItemHandler) GuiKeyboardShortcut(org.apache.hop.core.gui.plugin.key.GuiKeyboardShortcut) Stack(java.util.Stack) ArrayList(java.util.ArrayList) HopGuiPipelineGraph(org.apache.hop.ui.hopgui.file.pipeline.HopGuiPipelineGraph) HopWorkflowFileType(org.apache.hop.ui.hopgui.file.workflow.HopWorkflowFileType) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) ExtensionPointHandler(org.apache.hop.core.extension.ExtensionPointHandler) BaseMessages(org.apache.hop.i18n.BaseMessages) GuiResource(org.apache.hop.ui.core.gui.GuiResource) CTabFolder(org.eclipse.swt.custom.CTabFolder) FormLayout(org.eclipse.swt.layout.FormLayout) HopGuiWorkflowGraph(org.apache.hop.ui.hopgui.file.workflow.HopGuiWorkflowGraph) FormData(org.eclipse.swt.layout.FormData) TabFolderReorder(org.apache.hop.ui.core.widget.TabFolderReorder) CTabFolder2Adapter(org.eclipse.swt.custom.CTabFolder2Adapter) org.eclipse.swt.widgets(org.eclipse.swt.widgets) IGuiContextHandler(org.apache.hop.ui.hopgui.context.IGuiContextHandler) CTabFolderEvent(org.eclipse.swt.custom.CTabFolderEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) Const(org.apache.hop.core.Const) PropsUi(org.apache.hop.ui.core.PropsUi) HopPerspectivePlugin(org.apache.hop.ui.hopgui.perspective.HopPerspectivePlugin) CTabItem(org.eclipse.swt.custom.CTabItem) ISearchableCallback(org.apache.hop.core.search.ISearchableCallback) HopGuiKeyHandler(org.apache.hop.ui.hopgui.HopGuiKeyHandler) List(java.util.List) GuiOsxKeyboardShortcut(org.apache.hop.core.gui.plugin.key.GuiOsxKeyboardShortcut) SWT(org.eclipse.swt.SWT) IHopFileType(org.apache.hop.ui.hopgui.file.IHopFileType) EmptyFileType(org.apache.hop.ui.hopgui.file.empty.EmptyFileType) HopExtensionPoint(org.apache.hop.core.extension.HopExtensionPoint) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) CTabFolder(org.eclipse.swt.custom.CTabFolder) CTabFolder2Adapter(org.eclipse.swt.custom.CTabFolder2Adapter) TabFolderReorder(org.apache.hop.ui.core.widget.TabFolderReorder) CTabFolderEvent(org.eclipse.swt.custom.CTabFolderEvent) TabItemHandler(org.apache.hop.ui.hopgui.perspective.TabItemHandler) PropsUi(org.apache.hop.ui.core.PropsUi) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 4 with TabItemHandler

use of org.apache.hop.ui.hopgui.perspective.TabItemHandler 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;
}
Also used : HopGuiWorkflowGraph(org.apache.hop.ui.hopgui.file.workflow.HopGuiWorkflowGraph) HopException(org.apache.hop.core.exception.HopException) TabItemHandler(org.apache.hop.ui.hopgui.perspective.TabItemHandler) CTabItem(org.eclipse.swt.custom.CTabItem) HopExtensionPoint(org.apache.hop.core.extension.HopExtensionPoint) HopException(org.apache.hop.core.exception.HopException)

Example 5 with TabItemHandler

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

the class HopGuiWorkflowActionContext method openReferencedObject.

public static final void openReferencedObject(WorkflowMeta workflowMeta, IVariables variables, IAction action, String objectDescription, int index) {
    HopGui hopGui = HopGui.getInstance();
    try {
        IHasFilename hasFilename = action.loadReferencedObject(index, workflowMeta.getMetadataProvider(), variables);
        if (hasFilename != null) {
            String filename = variables.resolve(hasFilename.getFilename());
            // Is this object already loaded?
            // 
            HopDataOrchestrationPerspective perspective = HopGui.getDataOrchestrationPerspective();
            TabItemHandler tabItemHandler = perspective.findTabItemHandlerWithFilename(filename);
            if (tabItemHandler != null) {
                perspective.switchToTab(tabItemHandler);
            } else {
                hopGui.fileDelegate.fileOpen(filename);
            }
        }
    } catch (Exception e) {
        new ErrorDialog(hopGui.getShell(), "Error", "Error opening referenced object '" + objectDescription + "'", e);
    }
}
Also used : IHasFilename(org.apache.hop.core.file.IHasFilename) HopDataOrchestrationPerspective(org.apache.hop.ui.hopgui.perspective.dataorch.HopDataOrchestrationPerspective) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) TabItemHandler(org.apache.hop.ui.hopgui.perspective.TabItemHandler) HopGui(org.apache.hop.ui.hopgui.HopGui)

Aggregations

TabItemHandler (org.apache.hop.ui.hopgui.perspective.TabItemHandler)18 IHopFileTypeHandler (org.apache.hop.ui.hopgui.file.IHopFileTypeHandler)9 HopException (org.apache.hop.core.exception.HopException)8 CTabItem (org.eclipse.swt.custom.CTabItem)7 ArrayList (java.util.ArrayList)4 HopExtensionPoint (org.apache.hop.core.extension.HopExtensionPoint)4 IHopPerspective (org.apache.hop.ui.hopgui.perspective.IHopPerspective)4 HopDataOrchestrationPerspective (org.apache.hop.ui.hopgui.perspective.dataorch.HopDataOrchestrationPerspective)4 PipelineMeta (org.apache.hop.pipeline.PipelineMeta)3 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)3 HopGui (org.apache.hop.ui.hopgui.HopGui)3 WorkflowMeta (org.apache.hop.workflow.WorkflowMeta)3 Stack (java.util.Stack)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 IHasFilename (org.apache.hop.core.file.IHasFilename)2 ISearchable (org.apache.hop.core.search.ISearchable)2 ISearchableCallback (org.apache.hop.core.search.ISearchableCallback)2 AuditList (org.apache.hop.history.AuditList)2 AuditState (org.apache.hop.history.AuditState)2 AuditStateMap (org.apache.hop.history.AuditStateMap)2