Search in sources :

Example 1 with GuiToolbarWidgets

use of org.apache.hop.ui.core.gui.GuiToolbarWidgets in project hop by apache.

the class ProjectsGuiPlugin method selectProjectInList.

public static void selectProjectInList(String name) {
    GuiToolbarWidgets toolbarWidgets = HopGui.getInstance().getMainToolbarWidgets();
    toolbarWidgets.selectComboItem(ID_TOOLBAR_PROJECT_COMBO, name);
    Combo combo = getProjectsCombo();
    if (combo != null) {
        ProjectsConfig config = ProjectsConfigSingleton.getConfig();
        ProjectConfig projectConfig = config.findProjectConfig(name);
        if (projectConfig != null) {
            String projectHome = projectConfig.getProjectHome();
            if (StringUtils.isNotEmpty(projectHome)) {
                combo.setToolTipText(BaseMessages.getString(PKG, "ProjectGuiPlugin.SelectProject.Tooltip", name, projectHome, projectConfig.getConfigFilename()));
            }
        }
    }
}
Also used : ProjectConfig(org.apache.hop.projects.project.ProjectConfig) GuiToolbarWidgets(org.apache.hop.ui.core.gui.GuiToolbarWidgets) ProjectsConfig(org.apache.hop.projects.config.ProjectsConfig) Combo(org.eclipse.swt.widgets.Combo)

Example 2 with GuiToolbarWidgets

use of org.apache.hop.ui.core.gui.GuiToolbarWidgets in project hop by apache.

the class GitGuiPlugin method enableButtons.

private void enableButtons() {
    GuiToolbarWidgets widgets = ExplorerPerspective.getInstance().getToolBarWidgets();
    boolean isGit = git != null;
    boolean isSelected = isGit && getSelectedFile() != null;
    widgets.enableToolbarItem(TOOLBAR_ITEM_GIT_INFO, isGit);
    widgets.enableToolbarItem(TOOLBAR_ITEM_ADD, isSelected);
    widgets.enableToolbarItem(TOOLBAR_ITEM_REVERT, isSelected);
    widgets.enableToolbarItem(TOOLBAR_ITEM_COMMIT, isSelected);
    widgets.enableToolbarItem(TOOLBAR_ITEM_PUSH, isGit);
    widgets.enableToolbarItem(TOOLBAR_ITEM_PULL, isGit);
}
Also used : GuiToolbarWidgets(org.apache.hop.ui.core.gui.GuiToolbarWidgets)

Example 3 with GuiToolbarWidgets

use of org.apache.hop.ui.core.gui.GuiToolbarWidgets in project hop by apache.

the class HopGuiWorkflowLogDelegate method addToolBar.

private void addToolBar() {
    toolbar = new ToolBar(workflowLogComposite, SWT.WRAP | SWT.LEFT | SWT.HORIZONTAL);
    FormData fdToolBar = new FormData();
    fdToolBar.left = new FormAttachment(0, 0);
    fdToolBar.top = new FormAttachment(0, 0);
    fdToolBar.right = new FormAttachment(100, 0);
    toolbar.setLayoutData(fdToolBar);
    hopGui.getProps().setLook(toolbar, Props.WIDGET_STYLE_TOOLBAR);
    toolBarWidgets = new GuiToolbarWidgets();
    toolBarWidgets.registerGuiPluginObject(this);
    toolBarWidgets.createToolbarWidgets(toolbar, GUI_PLUGIN_TOOLBAR_PARENT_ID);
    toolbar.pack();
}
Also used : FormData(org.eclipse.swt.layout.FormData) GuiToolbarWidgets(org.apache.hop.ui.core.gui.GuiToolbarWidgets) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 4 with GuiToolbarWidgets

use of org.apache.hop.ui.core.gui.GuiToolbarWidgets in project hop by apache.

the class MetadataPerspective method createTree.

protected void createTree(Composite parent) {
    PropsUi props = PropsUi.getInstance();
    // Create composite
    // 
    Composite composite = new Composite(parent, SWT.BORDER);
    FormLayout layout = new FormLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    composite.setLayout(layout);
    // Create toolbar
    // 
    toolBar = new ToolBar(composite, SWT.WRAP | SWT.LEFT | SWT.HORIZONTAL);
    toolBarWidgets = new GuiToolbarWidgets();
    toolBarWidgets.registerGuiPluginObject(this);
    toolBarWidgets.createToolbarWidgets(toolBar, GUI_PLUGIN_TOOLBAR_PARENT_ID);
    FormData layoutData = new FormData();
    layoutData.left = new FormAttachment(0, 0);
    layoutData.top = new FormAttachment(0, 0);
    layoutData.right = new FormAttachment(100, 0);
    toolBar.setLayoutData(layoutData);
    toolBar.pack();
    props.setLook(toolBar, Props.WIDGET_STYLE_TOOLBAR);
    tree = new Tree(composite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
    tree.setHeaderVisible(false);
    tree.addListener(SWT.Selection, event -> this.updateSelection());
    tree.addListener(SWT.KeyUp, event -> {
        if (event.keyCode == SWT.DEL) {
            onDeleteMetadata();
        }
    });
    tree.addListener(SWT.DefaultSelection, event -> {
        TreeItem treeItem = tree.getSelection()[0];
        if (treeItem != null) {
            if (treeItem.getParentItem() == null) {
                onNewMetadata();
            } else {
                onEditMetadata();
            }
        }
    });
    tree.addMenuDetectListener(event -> {
        if (tree.getSelectionCount() < 1) {
            return;
        }
        TreeItem treeItem = tree.getSelection()[0];
        if (treeItem != null) {
            // Show the menu
            // 
            Menu menu = new Menu(tree);
            MenuItem menuItem = new MenuItem(menu, SWT.POP_UP);
            menuItem.setText("New");
            menuItem.addListener(SWT.Selection, e -> onNewMetadata());
            if (treeItem.getParentItem() != null) {
                new MenuItem(menu, SWT.SEPARATOR);
                menuItem = new MenuItem(menu, SWT.POP_UP);
                menuItem.setText("Edit");
                menuItem.addListener(SWT.Selection, e -> onEditMetadata());
                menuItem = new MenuItem(menu, SWT.POP_UP);
                menuItem.setText("Rename");
                menuItem.addListener(SWT.Selection, e -> onRenameMetadata());
                menuItem = new MenuItem(menu, SWT.POP_UP);
                menuItem.setText("Duplicate");
                menuItem.addListener(SWT.Selection, e -> duplicateMetadata());
                new MenuItem(menu, SWT.SEPARATOR);
                menuItem = new MenuItem(menu, SWT.POP_UP);
                menuItem.setText("Delete");
                menuItem.addListener(SWT.Selection, e -> onDeleteMetadata());
            }
            tree.setMenu(menu);
            menu.setVisible(true);
        }
    });
    PropsUi.getInstance().setLook(tree);
    FormData treeFormData = new FormData();
    treeFormData.left = new FormAttachment(0, 0);
    treeFormData.top = new FormAttachment(toolBar, 0);
    treeFormData.right = new FormAttachment(100, 0);
    treeFormData.bottom = new FormAttachment(100, 0);
    tree.setLayoutData(treeFormData);
    // Create Tree editor for rename
    treeEditor = new TreeEditor(tree);
    treeEditor.horizontalAlignment = SWT.LEFT;
    treeEditor.grabHorizontal = true;
    // Remember tree node expanded/Collapsed
    TreeMemory.addTreeListener(tree, METADATA_PERSPECTIVE_TREE);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) GuiToolbarWidgets(org.apache.hop.ui.core.gui.GuiToolbarWidgets) FormAttachment(org.eclipse.swt.layout.FormAttachment) PropsUi(org.apache.hop.ui.core.PropsUi)

Example 5 with GuiToolbarWidgets

use of org.apache.hop.ui.core.gui.GuiToolbarWidgets in project hop by apache.

the class ContextDialog method open.

public GuiAction open() {
    shell = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.RESIZE);
    shell.setText(getText());
    shell.setMinimumSize(200, 180);
    shell.setImage(GuiResource.getInstance().getImageHop());
    shell.setLayout(new FormLayout());
    Display display = shell.getDisplay();
    xMargin = 3 * margin;
    yMargin = 2 * margin;
    // Let's take a look at the list of actions and see if we've got categories to use...
    // 
    categories = new ArrayList<>();
    for (GuiAction action : actions) {
        if (StringUtils.isNotEmpty(action.getCategory())) {
            CategoryAndOrder categoryAndOrder = new CategoryAndOrder(action.getCategory(), Const.NVL(action.getCategoryOrder(), "0"), false);
            if (!categories.contains(categoryAndOrder)) {
                categories.add(categoryAndOrder);
            }
        } else {
            // Add an "Other" category
            CategoryAndOrder categoryAndOrder = new CategoryAndOrder(CATEGORY_OTHER, "9999", false);
            if (!categories.contains(categoryAndOrder)) {
                categories.add(categoryAndOrder);
            }
        }
    }
    categories.sort(Comparator.comparing(o -> o.order));
    // Correct the icon size which is multiplied in GuiResource...
    // 
    int correctedIconSize = (int) (iconSize / props.getZoomFactor());
    // Load the action images
    // 
    items.clear();
    for (GuiAction action : actions) {
        ClassLoader classLoader = action.getClassLoader();
        if (classLoader == null) {
            classLoader = ClassLoader.getSystemClassLoader();
        }
        // Load or get from the image cache...
        // 
        Image image = GuiResource.getInstance().getImage(action.getImage(), classLoader, correctedIconSize, correctedIconSize);
        items.add(new Item(action, image));
    }
    // Add a search bar at the top...
    // 
    Composite searchComposite = new Composite(shell, SWT.NONE);
    searchComposite.setLayout(new GridLayout(3, false));
    props.setLook(searchComposite, Props.WIDGET_STYLE_TOOLBAR);
    FormData fdlSearchComposite = new FormData();
    fdlSearchComposite.top = new FormAttachment(0, 0);
    fdlSearchComposite.left = new FormAttachment(0, 0);
    fdlSearchComposite.right = new FormAttachment(100, 0);
    searchComposite.setLayoutData(fdlSearchComposite);
    Label wlSearch = new Label(searchComposite, SWT.LEFT);
    wlSearch.setText(BaseMessages.getString(PKG, "ContextDialog.Search.Label.Text"));
    props.setLook(wlSearch, Props.WIDGET_STYLE_TOOLBAR);
    wSearch = new Text(searchComposite, SWT.LEFT | SWT.BORDER | SWT.SINGLE | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL);
    wSearch.setLayoutData(new GridData(GridData.FILL_BOTH));
    // Create a toolbar at the right of the search bar...
    // 
    ToolBar toolBar = new ToolBar(searchComposite, SWT.WRAP | SWT.LEFT | SWT.HORIZONTAL);
    toolBarWidgets = new GuiToolbarWidgets();
    toolBarWidgets.registerGuiPluginObject(this);
    toolBarWidgets.createToolbarWidgets(toolBar, GUI_PLUGIN_TOOLBAR_PARENT_ID);
    toolBar.pack();
    props.setLook(toolBar, Props.WIDGET_STYLE_TOOLBAR);
    recallToolbarSettings();
    // Add a description label at the bottom...
    // 
    Composite wTooltipComposite = new Composite(shell, SWT.NONE);
    GridLayout gdlTooltipComposite = new GridLayout(1, false);
    gdlTooltipComposite.marginLeft = Const.FORM_MARGIN;
    gdlTooltipComposite.marginRight = Const.FORM_MARGIN;
    gdlTooltipComposite.marginTop = Const.FORM_MARGIN;
    gdlTooltipComposite.marginBottom = Const.FORM_MARGIN;
    wTooltipComposite.setLayout(new GridLayout(1, false));
    props.setLook(wTooltipComposite, Props.WIDGET_STYLE_TOOLBAR);
    FormData fdlTooltip = new FormData();
    fdlTooltip.left = new FormAttachment(0, 0);
    fdlTooltip.right = new FormAttachment(100, 0);
    fdlTooltip.top = new FormAttachment(100, -(int) (props.getZoomFactor() * 50));
    fdlTooltip.bottom = new FormAttachment(100, 0);
    wTooltipComposite.setLayoutData(fdlTooltip);
    wlTooltip = new Label(wTooltipComposite, SWT.LEFT);
    wlTooltip.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    props.setLook(wlTooltip, Props.WIDGET_STYLE_TOOLBAR);
    // The rest of the dialog is used to draw the actions...
    // 
    wScrolledComposite = new ScrolledComposite(shell, SWT.V_SCROLL);
    wCanvas = new Canvas(wScrolledComposite, SWT.NO_BACKGROUND | SWT.DOUBLE_BUFFERED);
    wScrolledComposite.setContent(wCanvas);
    FormData fdCanvas = new FormData();
    fdCanvas.left = new FormAttachment(0, 0);
    fdCanvas.right = new FormAttachment(100, 0);
    fdCanvas.top = new FormAttachment(searchComposite, 0);
    fdCanvas.bottom = new FormAttachment(wTooltipComposite, 0);
    wScrolledComposite.setLayoutData(fdCanvas);
    wScrolledComposite.setExpandHorizontal(true);
    itemsFont = wCanvas.getFont();
    int fontHeight = wCanvas.getFont().getFontData()[0].getHeight() + 1;
    headerFont = new Font(getParent().getDisplay(), props.getDefaultFont().getName(), fontHeight, props.getGraphFont().getStyle() | SWT.BOLD | SWT.ITALIC);
    // TODO: Calculate a more dynamic size based on number of actions, screen size
    // and so on
    // 
    int width = (int) Math.round(800 * props.getZoomFactor());
    int height = (int) Math.round(600 * props.getZoomFactor());
    // 
    if (location != null) {
        /*Adapt to the monitor */
        Monitor monitor = shell.getMonitor();
        org.eclipse.swt.graphics.Rectangle displayPosition = monitor.getBounds();
        if ((location.x - displayPosition.x) > monitor.getClientArea().width - width)
            location.x = (monitor.getClientArea().width + displayPosition.x) - width;
        if (location.y - displayPosition.y > monitor.getClientArea().height - height)
            location.y = (monitor.getClientArea().height + displayPosition.y) - height;
        shell.setSize(width, height);
        shell.setLocation(location.x, location.y);
    } else {
        BaseTransformDialog.setSize(shell, width, height, false);
    }
    // Add all the listeners
    // 
    // If the shell is re-sized we need to recalculate things...
    // 
    shell.addListener(SWT.Resize, event -> onResize(event));
    shell.addListener(SWT.Deactivate, event -> onFocusLost());
    shell.addListener(SWT.Close, event -> storeDialogSettings());
    wSearch.addListener(SWT.KeyDown, event -> onKeyPressed(event));
    wSearch.addListener(SWT.Modify, event -> onModifySearch());
    wSearch.addListener(SWT.DefaultSelection, event -> {
        // 
        if (event.detail == SWT.ICON_SEARCH || event.detail == SWT.ICON_CANCEL) {
            return;
        }
        // 
        if (selectedItem != null) {
            selectedAction = selectedItem.getAction();
        }
        dispose();
    });
    wCanvas.addListener(SWT.KeyDown, event -> onKeyPressed(event));
    wCanvas.addListener(SWT.Paint, event -> onPaint(event));
    wCanvas.addListener(SWT.MouseUp, event -> onMouseUp(event));
    if (!EnvironmentUtils.getInstance().isWeb()) {
        wCanvas.addListener(SWT.MouseMove, event -> onMouseMove(event));
    }
    // 
    if (OsHelper.isMac()) {
        wCanvas.addListener(SWT.MouseVerticalWheel, event -> {
            org.eclipse.swt.graphics.Point origin = wScrolledComposite.getOrigin();
            origin.y -= event.count;
            wScrolledComposite.setOrigin(origin);
        });
    }
    // Layout all the widgets in the shell.
    // 
    shell.layout();
    // Set the active instance.
    // 
    activeInstance = this;
    // Manually set canvas size otherwise canvas never gets drawn.
    wCanvas.setSize(10, 10);
    // Show the dialog now
    // 
    shell.open();
    // Filter all actions by default
    // 
    this.filter(null);
    // Force focus on the search bar
    // 
    wSearch.setFocus();
    // 
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    activeInstance = null;
    return selectedAction;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) java.util(java.util) Props(org.apache.hop.core.Props) Image(org.eclipse.swt.graphics.Image) AreaOwner(org.apache.hop.core.gui.AreaOwner) GuiPlugin(org.apache.hop.core.gui.plugin.GuiPlugin) GC(org.eclipse.swt.graphics.GC) GuiAction(org.apache.hop.core.gui.plugin.action.GuiAction) WindowProperty(org.apache.hop.ui.core.gui.WindowProperty) Font(org.eclipse.swt.graphics.Font) HopConfig(org.apache.hop.core.config.HopConfig) OsHelper(org.apache.hop.ui.core.widget.OsHelper) Rectangle(org.apache.hop.core.gui.Rectangle) AuditState(org.apache.hop.history.AuditState) BaseMessages(org.apache.hop.i18n.BaseMessages) org.eclipse.swt.layout(org.eclipse.swt.layout) GuiResource(org.apache.hop.ui.core.gui.GuiResource) EnvironmentUtils(org.apache.hop.ui.util.EnvironmentUtils) HopNamespace(org.apache.hop.ui.core.gui.HopNamespace) org.eclipse.swt.widgets(org.eclipse.swt.widgets) Const(org.apache.hop.core.Const) GuiToolbarElementType(org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElementType) PropsUi(org.apache.hop.ui.core.PropsUi) LogChannel(org.apache.hop.core.logging.LogChannel) GuiToolbarElement(org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement) List(java.util.List) Color(org.eclipse.swt.graphics.Color) AuditManager(org.apache.hop.history.AuditManager) Point(org.apache.hop.core.gui.Point) SWT(org.eclipse.swt.SWT) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) GuiToolbarWidgets(org.apache.hop.ui.core.gui.GuiToolbarWidgets) BaseTransformDialog(org.apache.hop.ui.pipeline.transform.BaseTransformDialog) Image(org.eclipse.swt.graphics.Image) Font(org.eclipse.swt.graphics.Font) GuiAction(org.apache.hop.core.gui.plugin.action.GuiAction) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) GuiToolbarWidgets(org.apache.hop.ui.core.gui.GuiToolbarWidgets) Point(org.apache.hop.core.gui.Point)

Aggregations

GuiToolbarWidgets (org.apache.hop.ui.core.gui.GuiToolbarWidgets)14 FormAttachment (org.eclipse.swt.layout.FormAttachment)8 FormData (org.eclipse.swt.layout.FormData)8 PropsUi (org.apache.hop.ui.core.PropsUi)4 FormLayout (org.eclipse.swt.layout.FormLayout)4 HopException (org.apache.hop.core.exception.HopException)3 java.util (java.util)2 StringUtils (org.apache.commons.lang.StringUtils)2 Const (org.apache.hop.core.Const)2 Props (org.apache.hop.core.Props)2 GuiPlugin (org.apache.hop.core.gui.plugin.GuiPlugin)2 GuiToolbarElement (org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement)2 LogChannel (org.apache.hop.core.logging.LogChannel)2 AuditManager (org.apache.hop.history.AuditManager)2 BaseMessages (org.apache.hop.i18n.BaseMessages)2 ProjectsConfig (org.apache.hop.projects.config.ProjectsConfig)2 ShellAdapter (org.eclipse.swt.events.ShellAdapter)2 ShellEvent (org.eclipse.swt.events.ShellEvent)2 ToolBar (org.eclipse.swt.widgets.ToolBar)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1