use of org.apache.hop.ui.core.gui.GuiResource in project hop by apache.
the class GitGuiPlugin method filePainted.
/**
* If we have a git project we can take a look and see if a file is changed.
*
* @param tree
* @param treeItem
* @param path
* @param name
*/
@Override
public void filePainted(Tree tree, TreeItem treeItem, String path, String name) {
GuiResource guiResource = GuiResource.getInstance();
UIFile file = null;
// Changed git file colored blue
try {
file = changedFiles.get(HopVfs.getFileObject(path).getName().getPath());
} catch (HopFileException e) {
// do nothing
}
if (file != null) {
switch(file.getChangeType()) {
case DELETE:
case MODIFY:
case RENAME:
case COPY:
treeItem.setForeground(colorStaged);
break;
case ADD:
if (file.getIsStaged()) {
treeItem.setForeground(colorStaged);
} else {
treeItem.setForeground(colorUnstaged);
}
break;
}
}
String ignored = ignoredFiles.get(path);
if (ignored != null) {
treeItem.setForeground(colorIgnored);
}
}
use of org.apache.hop.ui.core.gui.GuiResource in project hop by apache.
the class PropsUi method setLook.
public void setLook(final Control control, int style) {
final GuiResource gui = GuiResource.getInstance();
Font font = null;
Color background = null;
Color foreground = null;
switch(style) {
case WIDGET_STYLE_DEFAULT:
background = gui.getColorWhite();
foreground = gui.getColorBlack();
font = null;
if (control instanceof Group && OS.contains("mac")) {
control.addPaintListener(paintEvent -> {
paintEvent.gc.setForeground(gui.getColorBlack());
paintEvent.gc.setBackground(gui.getColorBackground());
paintEvent.gc.fillRectangle(2, 0, control.getBounds().width - 8, control.getBounds().height - 20);
});
} else if (control instanceof Combo) {
if (Const.isWindows() && isDarkMode()) {
background = gui.getColorBackground();
} else {
// Just keep the default
return;
}
}
break;
case WIDGET_STYLE_FIXED:
foreground = gui.getColorBlack();
background = gui.getColorWhite();
font = gui.getFontFixed();
break;
case WIDGET_STYLE_TABLE:
foreground = gui.getColorBlack();
background = gui.getColorWhite();
font = null;
break;
case WIDGET_STYLE_NOTEPAD:
foreground = gui.getColorBlack();
background = gui.getColorWhite();
font = gui.getFontNote();
break;
case WIDGET_STYLE_GRAPH:
foreground = gui.getColorBlack();
background = gui.getColorWhite();
font = gui.getFontGraph();
break;
case WIDGET_STYLE_TOOLBAR:
foreground = gui.getColorBlack();
if (isDarkMode()) {
background = gui.getColorLightGray();
} else {
background = gui.getColorDemoGray();
}
break;
case WIDGET_STYLE_TAB:
background = gui.getColorWhite();
foreground = gui.getColorBlack();
CTabFolder tabFolder = (CTabFolder) control;
tabFolder.setBorderVisible(true);
// need to make a copy of the tab selection background color to get around bug
Color c = gui.getColorTab();
Color tabColor = new Color(c.getDevice(), c.getRed(), c.getGreen(), c.getBlue());
tabFolder.setSelectionBackground(tabColor);
break;
default:
background = gui.getColorBackground();
font = null;
break;
}
if (font != null && !font.isDisposed()) {
control.setFont(font);
}
if (background != null && !background.isDisposed()) {
boolean setBackground = true;
if (control instanceof Button) {
Button b = (Button) control;
if ((b.getStyle() & SWT.PUSH) != 0) {
setBackground = false;
}
}
if (setBackground) {
control.setBackground(background);
}
}
if (foreground != null && !foreground.isDisposed()) {
boolean setForeground = true;
if (control instanceof Button) {
Button b = (Button) control;
if ((b.getStyle() & SWT.PUSH) != 0) {
setForeground = false;
}
}
if (setForeground) {
control.setForeground(foreground);
}
}
}
use of org.apache.hop.ui.core.gui.GuiResource 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;
}
use of org.apache.hop.ui.core.gui.GuiResource in project hop by apache.
the class PipelineDebugDialog method refreshTransformList.
private void refreshTransformList() {
GuiResource resource = GuiResource.getInstance();
// Add the list of transforms...
//
int maxIconSize = 0;
int indexSelected = -1;
wTransforms.table.removeAll();
for (int i = 0; i < pipelineDebugMeta.getPipelineMeta().getTransforms().size(); i++) {
TransformMeta transformMeta = pipelineDebugMeta.getPipelineMeta().getTransform(i);
TableItem item = new TableItem(wTransforms.table, SWT.NONE);
Image image = resource.getImagesTransforms().get(transformMeta.getTransformPluginId()).getAsBitmapForSize(display, ConstUi.ICON_SIZE, ConstUi.ICON_SIZE);
item.setImage(0, image);
item.setText(0, "");
item.setText(1, transformMeta.getName());
if (image.getBounds().width > maxIconSize) {
maxIconSize = image.getBounds().width;
}
TransformDebugMeta transformDebugMeta = transformDebugMetaMap.get(transformMeta);
if (transformDebugMeta != null) {
// We have debugging information so we mark the row
//
item.setBackground(resource.getColorLight());
if (indexSelected < 0) {
indexSelected = i;
}
}
}
wTransforms.removeEmptyRows();
wTransforms.optWidth(false);
wTransforms.table.getColumn(0).setWidth(maxIconSize + 10);
wTransforms.table.getColumn(0).setAlignment(SWT.CENTER);
//
if (indexSelected >= 0) {
wTransforms.table.setSelection(indexSelected);
showTransformDebugInformation();
}
}
Aggregations