Search in sources :

Example 1 with EmptyFileType

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

the class ExplorerPerspective method onTabClose.

protected void onTabClose(CTabFolderEvent event) {
    CTabItem tabItem = (CTabItem) event.item;
    ExplorerFile file = (ExplorerFile) tabItem.getData();
    if (file.getFileTypeHandler().isCloseable()) {
        files.remove(file);
        tabItem.dispose();
        // Refresh tree to remove bold
        // 
        this.refresh();
        // 
        if (tabFolder.getItemCount() == 0) {
            HopGui.getInstance().handleFileCapabilities(new EmptyFileType(), false, false, false);
        }
        updateGui();
    } else {
        // Ignore event if canceled
        event.doit = false;
    }
}
Also used : EmptyFileType(org.apache.hop.ui.hopgui.file.empty.EmptyFileType)

Example 2 with EmptyFileType

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

the class HopGui method open.

/**
 * Build the shell
 */
protected void open() {
    shell.setImage(GuiResource.getInstance().getImageHopUiTaskbar());
    shell.setText(BaseMessages.getString(PKG, "HopGui.Application.Name"));
    addMainMenu();
    addMainToolbar();
    addPerspectivesToolbar();
    addMainPerspectivesComposite();
    handleFileCapabilities(new EmptyFileType(), false, false, false);
    loadPerspectives();
    replaceKeyboardShortcutListeners(this);
    shell.addListener(SWT.Close, this::closeEvent);
    BaseTransformDialog.setSize(shell);
    // Open the Hop GUI shell
    // 
    shell.open();
    if (EnvironmentUtils.getInstance().isWeb()) {
        shell.setMaximized(true);
    }
    display.asyncExec(() -> {
        openingLastFiles = true;
        // 
        try {
            ExtensionPointHandler.callExtensionPoint(log, variables, HopExtensionPoint.HopGuiStart.id, this);
        } catch (Exception e) {
            new ErrorDialog(shell, "Error", "Error calling extension point '" + HopExtensionPoint.HopGuiStart.id + "'", e);
        }
        // 
        if (openingLastFiles) {
            auditDelegate.openLastFiles();
        }
    });
    // On RAP, return here otherwise UIThread doesn't get terminated properly.
    if (EnvironmentUtils.getInstance().isWeb()) {
        return;
    }
    boolean retry = true;
    while (retry) {
        try {
            // 
            while (!shell.isDisposed()) {
                if (!display.readAndDispatch()) {
                    display.sleep();
                }
            }
            retry = false;
        } catch (Throwable throwable) {
            System.err.println("Error in the Hop GUI : " + throwable.getMessage() + Const.CR + Const.getClassicStackTrace(throwable));
        }
    }
    display.dispose();
}
Also used : EmptyFileType(org.apache.hop.ui.hopgui.file.empty.EmptyFileType) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) HopException(org.apache.hop.core.exception.HopException)

Example 3 with EmptyFileType

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

the class MetadataPerspective method remove.

@Override
public boolean remove(IHopFileTypeHandler typeHandler) {
    if (typeHandler instanceof MetadataEditor) {
        MetadataEditor<?> editor = (MetadataEditor<?>) typeHandler;
        if (editor.isCloseable()) {
            editors.remove(editor);
            for (CTabItem item : tabFolder.getItems()) {
                if (editor.equals(item.getData())) {
                    item.dispose();
                }
            }
            // Refresh tree to remove bold
            // 
            this.refresh();
            // 
            if (tabFolder.getItemCount() == 0) {
                HopGui.getInstance().handleFileCapabilities(new EmptyFileType(), false, false, false);
            }
        }
    }
    return false;
}
Also used : EmptyFileType(org.apache.hop.ui.hopgui.file.empty.EmptyFileType) MetadataEditor(org.apache.hop.ui.core.metadata.MetadataEditor)

Example 4 with EmptyFileType

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

the class MetadataPerspective method onTabClose.

protected void onTabClose(CTabFolderEvent event) {
    CTabItem tabItem = (CTabItem) event.item;
    MetadataEditor<?> editor = (MetadataEditor<?>) tabItem.getData();
    if (editor.isCloseable()) {
        editors.remove(editor);
        tabItem.dispose();
        // Refresh tree to remove bold
        // 
        this.refresh();
        // 
        if (tabFolder.getItemCount() == 0) {
            HopGui.getInstance().handleFileCapabilities(new EmptyFileType(), false, false, false);
        }
    } else {
        // Ignore event if canceled
        event.doit = false;
    }
}
Also used : EmptyFileType(org.apache.hop.ui.hopgui.file.empty.EmptyFileType) MetadataEditor(org.apache.hop.ui.core.metadata.MetadataEditor)

Example 5 with EmptyFileType

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

the class HopDataOrchestrationPerspective method handleTabCloseEvent.

private void handleTabCloseEvent(CTabFolderEvent event) {
    // A tab is closed.  We need to handle this gracefully.
    // - Look up which tab it is
    // - Look up which file it contains
    // - Save the file if it was changed
    // - Remove the tab and file from the list
    // 
    CTabItem tabItem = (CTabItem) event.item;
    int tabIndex = tabFolder.indexOf(tabItem);
    TabItemHandler tabItemHandler = findTabItemHandler(tabItem);
    if (tabItemHandler == null) {
        hopGui.getLog().logError("Tab item handler not found for tab item " + tabItem.toString());
        return;
    }
    IHopFileTypeHandler typeHandler = tabItemHandler.getTypeHandler();
    boolean isRemoved = remove(typeHandler);
    // Ignore event if canceled
    if (!isRemoved) {
        event.doit = false;
        return;
    }
    // 
    if (tabIndex >= 0) {
        // Remove the index from the tab selection history
        // 
        int historyIndex = tabSelectionHistory.indexOf(tabIndex);
        while (historyIndex >= 0) {
            if (historyIndex <= tabSelectionIndex) {
                tabSelectionIndex--;
            }
            tabSelectionHistory.remove(historyIndex);
            // Search again
            historyIndex = tabSelectionHistory.indexOf(tabIndex);
        }
        // Compress the history: 2 the same files visited after each other become one.
        // 
        Stack<Integer> newHistory = new Stack<>();
        Integer previous = null;
        for (int i = 0; i < tabSelectionHistory.size(); i++) {
            Integer index = tabSelectionHistory.get(i);
            if (previous == null || previous != index) {
                newHistory.add(index);
            } else {
                if (tabSelectionIndex >= i) {
                    tabSelectionIndex--;
                }
            }
            previous = index;
        }
        tabSelectionHistory = newHistory;
        // 
        for (int i = 0; i < tabSelectionHistory.size(); i++) {
            int index = tabSelectionHistory.get(i);
            if (index > tabIndex) {
                tabSelectionHistory.set(i, index--);
            }
        }
        // 
        if (tabSelectionIndex < 0) {
            tabSelectionIndex = 0;
        } else if (tabSelectionIndex >= tabSelectionHistory.size()) {
            tabSelectionIndex = tabSelectionHistory.size() - 1;
        }
        if (!tabSelectionHistory.isEmpty()) {
            Integer activeIndex = tabSelectionHistory.get(tabSelectionIndex);
            if (activeIndex < items.size()) {
                activeItem = items.get(activeIndex);
                tabFolder.setSelection(activeIndex);
                activeItem.getTypeHandler().updateGui();
            }
        }
        // 
        if (tabFolder.getItemCount() == 0) {
            HopGui.getInstance().handleFileCapabilities(new EmptyFileType(), false, false, false);
        }
    }
}
Also used : IHopFileTypeHandler(org.apache.hop.ui.hopgui.file.IHopFileTypeHandler) EmptyFileType(org.apache.hop.ui.hopgui.file.empty.EmptyFileType) TabItemHandler(org.apache.hop.ui.hopgui.perspective.TabItemHandler) CTabItem(org.eclipse.swt.custom.CTabItem) HopExtensionPoint(org.apache.hop.core.extension.HopExtensionPoint) Stack(java.util.Stack)

Aggregations

EmptyFileType (org.apache.hop.ui.hopgui.file.empty.EmptyFileType)6 MetadataEditor (org.apache.hop.ui.core.metadata.MetadataEditor)2 Stack (java.util.Stack)1 HopException (org.apache.hop.core.exception.HopException)1 HopExtensionPoint (org.apache.hop.core.extension.HopExtensionPoint)1 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)1 IHopFileTypeHandler (org.apache.hop.ui.hopgui.file.IHopFileTypeHandler)1 TabItemHandler (org.apache.hop.ui.hopgui.perspective.TabItemHandler)1 CTabItem (org.eclipse.swt.custom.CTabItem)1