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()));
}
}
}
}
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);
}
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();
}
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);
}
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;
}
Aggregations