Skip to content

Commit

Permalink
option aded to look and feel to hide the viewport, fixes #2310
Browse files Browse the repository at this point in the history
  • Loading branch information
hansva committed Jun 1, 2023
1 parent d2f7165 commit 0a337ef
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 43 deletions.
9 changes: 5 additions & 4 deletions core/src/main/java/org/apache/hop/core/Props.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@

package org.apache.hop.core;

import java.util.Iterator;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.apache.hop.core.config.HopConfig;
import org.apache.hop.core.exception.HopException;
import org.apache.hop.core.logging.ILogChannel;
import org.apache.hop.core.logging.LogChannel;

import java.util.Iterator;
import java.util.Map;

/**
* We use Props to store all kinds of user interactive information such as the selected colors,
* fonts, positions of windows, etc.
Expand Down Expand Up @@ -75,6 +74,8 @@ public class Props implements Cloneable {
public static final String STRING_OPEN_LAST_FILE = "OpenLastFile";

public static final String STRING_SHOW_CANVAS_GRID = "ShowCanvasGrid";

public static final String STRING_HIDE_VIEWPORT = "HideViewport";
public static final String STRING_SHOW_TABLE_VIEW_TOOLBAR = "ShowTableViewToolbar";
public static final String STRING_SHOW_EXIT_WARNING = "ShowExitWarning";

Expand All @@ -94,7 +95,7 @@ public class Props implements Cloneable {
public static final int WIDGET_STYLE_TOOLBAR = 5;
public static final int WIDGET_STYLE_PUSH_BUTTON = 6;
public static final int WIDGET_STYLE_TREE = 7;

public Props() {
log = new LogChannel(STRING_USER_PREFERENCES);
}
Expand Down
9 changes: 4 additions & 5 deletions engine/src/main/java/org/apache/hop/core/gui/BasePainter.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.hop.core.gui;

import java.util.List;
import org.apache.hop.base.BaseHopMeta;
import org.apache.hop.base.IBaseMeta;
import org.apache.hop.core.Const;
Expand All @@ -30,8 +31,6 @@
import org.apache.hop.core.variables.IVariables;
import org.apache.hop.pipeline.transform.stream.StreamIcon;

import java.util.List;

public abstract class BasePainter<Hop extends BaseHopMeta<?>, Part extends IBaseMeta> {

public final double theta = Math.toRadians(11); // arrowhead sharpness
Expand Down Expand Up @@ -238,7 +237,7 @@ protected void drawNote(NotePadMeta notePadMeta) {
}

protected Point real2screen(int x, int y) {
Point screen = new Point((int)(x + offset.x), (int)(y + offset.y));
Point screen = new Point((int) (x + offset.x), (int) (y + offset.y));

return screen;
}
Expand Down Expand Up @@ -270,13 +269,13 @@ protected void drawGrid() {
Point bounds = gc.getDeviceBounds();
for (int x = 0; x < bounds.x; x += gridSize) {
for (int y = 0; y < bounds.y; y += gridSize) {
gc.drawPoint((int)(x + (offset.x % gridSize)), (int)(y + (offset.y % gridSize)));
gc.drawPoint((int) (x + (offset.x % gridSize)), (int) (y + (offset.y % gridSize)));
}
}
}

protected int round(double value) {
return (int)Math.round(value);
return (int) Math.round(value);
}

protected int calcArrowLength() {
Expand Down
54 changes: 32 additions & 22 deletions engine/src/main/java/org/apache/hop/pipeline/PipelinePainter.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@

package org.apache.hop.pipeline;

import java.text.DecimalFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.hop.core.Const;
import org.apache.hop.core.NotePadMeta;
import org.apache.hop.core.exception.HopException;
Expand Down Expand Up @@ -50,17 +55,6 @@
import org.apache.hop.pipeline.transform.stream.IStream.StreamType;
import org.apache.hop.pipeline.transform.stream.StreamIcon;

import java.text.DecimalFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static org.apache.hop.core.gui.IGc.EColor;
import static org.apache.hop.core.gui.IGc.EFont;
import static org.apache.hop.core.gui.IGc.EImage;
import static org.apache.hop.core.gui.IGc.ELineStyle;

public class PipelinePainter extends BasePainter<PipelineHopMeta, TransformMeta> {

private static final Class<?> PKG = PipelinePainter.class; // For Translator
Expand Down Expand Up @@ -202,7 +196,7 @@ public void drawPipelineImage() throws HopException {

// Draw the pipeline onto the image
//
gc.setTransform((float)offset.x, (float)offset.y, magnification);
gc.setTransform((float) offset.x, (float) offset.y, magnification);
gc.setAlpha(255);
drawPipeline();

Expand Down Expand Up @@ -790,7 +784,7 @@ private void drawTransform(TransformMeta transformMeta) throws HopException {

// Show an information icon in the upper left corner of the transform...
//
if ( !Utils.isEmpty(transformMeta.getDescription()) ) {
if (!Utils.isEmpty(transformMeta.getDescription())) {
int xInfo = x - (miniIconSize / 2) - 1;
int yInfo = y - (miniIconSize / 2) - 1;
gc.drawImage(EImage.INFO_DISABLED, xInfo, yInfo, magnification);
Expand All @@ -805,7 +799,7 @@ private void drawTransform(TransformMeta transformMeta) throws HopException {
pipelineMeta,
transformMeta));
}

Point namePosition = getNamePosition(name, screen, iconSize);

// Help out the user working in single-click mode by allowing the name to be clicked to edit
Expand Down Expand Up @@ -1237,32 +1231,44 @@ protected void drawArrow(
}
}

/** @return the transformLogMap */
/**
* @return the transformLogMap
*/
public Map<String, String> getTransformLogMap() {
return transformLogMap;
}

/** @param transformLogMap the transformLogMap to set */
/**
* @param transformLogMap the transformLogMap to set
*/
public void setTransformLogMap(Map<String, String> transformLogMap) {
this.transformLogMap = transformLogMap;
}

/** @param startHopTransform the start Hop Transform to set */
/**
* @param startHopTransform the start Hop Transform to set
*/
public void setStartHopTransform(TransformMeta startHopTransform) {
this.startHopTransform = startHopTransform;
}

/** @param endHopLocation the endHopLocation to set */
/**
* @param endHopLocation the endHopLocation to set
*/
public void setEndHopLocation(Point endHopLocation) {
this.endHopLocation = endHopLocation;
}

/** @param noInputTransform the no Input Transform to set */
/**
* @param noInputTransform the no Input Transform to set
*/
public void setNoInputTransform(TransformMeta noInputTransform) {
this.noInputTransform = noInputTransform;
}

/** @param endHopTransform the end Hop Transform to set */
/**
* @param endHopTransform the end Hop Transform to set
*/
public void setEndHopTransform(TransformMeta endHopTransform) {
this.endHopTransform = endHopTransform;
}
Expand Down Expand Up @@ -1332,7 +1338,9 @@ public Map<String, RowBuffer> getOutputRowsMap() {
return outputRowsMap;
}

/** @param outputRowsMap The outputRowsMap to set */
/**
* @param outputRowsMap The outputRowsMap to set
*/
public void setOutputRowsMap(Map<String, RowBuffer> outputRowsMap) {
this.outputRowsMap = outputRowsMap;
}
Expand All @@ -1346,7 +1354,9 @@ public Map<String, Object> getStateMap() {
return stateMap;
}

/** @param stateMap The stateMap to set */
/**
* @param stateMap The stateMap to set
*/
public void setStateMap(Map<String, Object> stateMap) {
this.stateMap = stateMap;
}
Expand Down
9 changes: 9 additions & 0 deletions ui/src/main/java/org/apache/hop/ui/core/PropsUi.java
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,15 @@ public void setShowCanvasGridEnabled(boolean anti) {
setProperty(STRING_SHOW_CANVAS_GRID, anti ? YES : NO);
}

public boolean isHideViewportEnabled() {
String showViewport = getProperty(STRING_HIDE_VIEWPORT, NO);
return YES.equalsIgnoreCase(showViewport); // Default: don't hide the viewport
}

public void setHideViewportEnabled(boolean anti) {
setProperty(STRING_HIDE_VIEWPORT, anti ? YES : NO);
}

public boolean showExitWarning() {
String show = getProperty(STRING_SHOW_EXIT_WARNING, YES);
return YES.equalsIgnoreCase(show); // Default: show repositories dialog at startup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3309,6 +3309,7 @@ public void drawPipelineImage(GC swtGc, int width, int height) {
pipelinePainter.setMaximum(maximum);
pipelinePainter.setShowingNavigationView(true);
pipelinePainter.setScreenMagnification(magnification);
pipelinePainter.setShowingNavigationView(!PropsUi.getInstance().isHideViewportEnabled());

try {
pipelinePainter.drawPipelineImage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@

package org.apache.hop.ui.hopgui.file.workflow;

import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.vfs2.FileName;
import org.apache.commons.vfs2.FileObject;
Expand Down Expand Up @@ -157,15 +165,6 @@
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.swt.widgets.ToolTip;

import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;

/** Handles the display of Workflows in HopGui, in a graphical form. */
@GuiPlugin(description = "Workflow Graph tab")
public class HopGuiWorkflowGraph extends HopGuiAbstractGraph
Expand Down Expand Up @@ -2827,6 +2826,7 @@ public void drawWorkflowImage(GC swtGc, int width, int height, float magnificati
workflowPainter.setMaximum(maximum);
workflowPainter.setShowingNavigationView(true);
workflowPainter.setScreenMagnification(magnification);
workflowPainter.setShowingNavigationView(!PropsUi.getInstance().isHideViewportEnabled());

try {
workflowPainter.drawWorkflow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public class ConfigGuiOptionsTab {
private Text wGridSize;
private Button wDarkMode;
private Button wShowCanvasGrid;
private Button wHideViewport;
private Button wHideMenuBar;
private Button wShowTableViewToolbar;
private Combo wDefaultLocale;
Expand Down Expand Up @@ -420,6 +421,27 @@ public void addGuiOptionsTab(CTabFolder wTabFolder) {
wShowCanvasGrid.setLayoutData(fdShowCanvasGrid);
wShowCanvasGrid.addListener(SWT.Selection, e -> saveValues());

// Hide Viewport
Label wlHideViewport = new Label(wLookComp, SWT.RIGHT);
wlHideViewport.setText(BaseMessages.getString(PKG, "EnterOptionsDialog.ShowViewport.Label"));
wlHideViewport.setToolTipText(
BaseMessages.getString(PKG, "EnterOptionsDialog.ShowViewport.ToolTip"));
PropsUi.setLook(wlHideViewport);
FormData fdlHideViewport = new FormData();
fdlHideViewport.left = new FormAttachment(0, 0);
fdlHideViewport.right = new FormAttachment(middle, -margin);
fdlHideViewport.top = new FormAttachment(wShowCanvasGrid, margin);
wlHideViewport.setLayoutData(fdlHideViewport);
wHideViewport = new Button(wLookComp, SWT.CHECK);
PropsUi.setLook(wHideViewport);
wHideViewport.setSelection(props.isHideViewportEnabled());
FormData fdHideViewport = new FormData();
fdHideViewport.left = new FormAttachment(middle, 0);
fdHideViewport.right = new FormAttachment(100, -margin);
fdHideViewport.top = new FormAttachment(wlHideViewport, 0, SWT.CENTER);
wHideViewport.setLayoutData(fdHideViewport);
wHideViewport.addListener(SWT.Selection, e -> saveValues());

// Hide menu bar?
Label wlHideMenuBar = new Label(wLookComp, SWT.RIGHT);
wlHideMenuBar.setText(BaseMessages.getString(PKG, "EnterOptionsDialog.HideMenuBar.Label"));
Expand All @@ -429,7 +451,7 @@ public void addGuiOptionsTab(CTabFolder wTabFolder) {
FormData fdlHideMenuBar = new FormData();
fdlHideMenuBar.left = new FormAttachment(0, 0);
fdlHideMenuBar.right = new FormAttachment(middle, -margin);
fdlHideMenuBar.top = new FormAttachment(wShowCanvasGrid, 2 * margin);
fdlHideMenuBar.top = new FormAttachment(wHideViewport, 2 * margin);
wlHideMenuBar.setLayoutData(fdlHideMenuBar);
wHideMenuBar = new Button(wLookComp, SWT.CHECK);
PropsUi.setLook(wHideMenuBar);
Expand Down Expand Up @@ -716,6 +738,7 @@ private void saveValues() {
props.setCanvasGridSize(Const.toInt(wGridSize.getText(), 1));
props.setGlobalZoomFactor(Const.toDouble(wGlobalZoom.getText().replace("%", ""), 100) / 100);
props.setShowCanvasGridEnabled(wShowCanvasGrid.getSelection());
props.setHideViewportEnabled(wHideViewport.getSelection());
props.setDarkMode(wDarkMode.getSelection());
props.setHidingMenuBar(wHideMenuBar.getSelection());
props.setShowTableViewToolbar(wShowTableViewToolbar.getSelection());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@
import org.apache.hop.ui.hopgui.perspective.execution.DragViewZoomBase;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ EnterOptionsDialog.RestartWarning.Option1=Close
EnterOptionsDialog.RestartWarning.Option2=Please don't show this message again
EnterOptionsDialog.ShowCanvasGrid.Label=Show Canvas Grid
EnterOptionsDialog.ShowCanvasGrid.ToolTip=If enabled, the canvas grid will be visible
EnterOptionsDialog.ShowViewport.Label=Hide Viewport
EnterOptionsDialog.ShowViewport.ToolTip=If enabled, the viewport in the bottom right will be hidden
EnterOptionsDialog.HideMenuBar.ToolTip=Enabling this option hides the menu bar from the user interface.
EnterOptionsDialog.HideMenuBar.Label=Hide the menu bar
EnterOptionsDialog.TableOutput.SortMappings.Label=Table Output: sort mappings
Expand Down

0 comments on commit 0a337ef

Please sign in to comment.