Skip to content

Commit

Permalink
HOP-2027 : Fix button positions in dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcasters committed Jun 2, 2021
1 parent 905dea5 commit 9e5e94b
Show file tree
Hide file tree
Showing 49 changed files with 1,098 additions and 1,604 deletions.
Expand Up @@ -19,16 +19,12 @@

import org.apache.hop.ui.core.dialog.BaseDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TableItem;
import org.apache.hop.core.Const;
Expand Down Expand Up @@ -70,11 +66,7 @@ public class EditRowsDialog {

private TableView wFields;

private FormData fdlFields, fdFields;

private Button wOK;

private Button wCancel;
private Button wOk;

private Shell shell;

Expand Down Expand Up @@ -146,16 +138,16 @@ public List<Object[]> open() {

// Buttons go at the very bottom
//
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wOK.addListener(SWT.Selection, e -> ok());
wCancel = new Button(shell, SWT.PUSH);
wOk = new Button(shell, SWT.PUSH);
wOk.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wOk.addListener(SWT.Selection, e -> ok());
Button wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
wCancel.addListener(SWT.Selection, e -> cancel());
BaseTransformDialog.positionBottomButtons(
shell,
new Button[] {
wOK, wCancel,
wOk, wCancel,
},
Const.MARGIN,
null);
Expand All @@ -172,14 +164,13 @@ public List<Object[]> open() {
}

private boolean addFields() {
// int middle = props.getMiddlePct();
int margin = Const.MARGIN;

if (wlMessage == null) {
wlMessage = new Label(shell, SWT.LEFT);
wlMessage.setText(message);
props.setLook(wlMessage);
fdlFields = new FormData();
FormData fdlFields = new FormData();
fdlFields.left = new FormAttachment(0, 0);
fdlFields.right = new FormAttachment(100, 0);
fdlFields.top = new FormAttachment(0, margin);
Expand Down Expand Up @@ -221,11 +212,11 @@ private boolean addFields() {
props);
wFields.setShowingBlueNullValues(true);

fdFields = new FormData();
FormData fdFields = new FormData();
fdFields.left = new FormAttachment(0, 0);
fdFields.top = new FormAttachment(wlMessage, margin);
fdFields.right = new FormAttachment(100, 0);
fdFields.bottom = new FormAttachment(100, -50);
fdFields.bottom = new FormAttachment(wOk, -2 * margin);
wFields.setLayoutData(fdFields);

shell.layout(true, true);
Expand Down
Expand Up @@ -100,11 +100,24 @@ public void modifyText(ModifyEvent e) {
int middle = props.getMiddlePct();
int margin = Const.MARGIN;

// Some buttons at the bottom
wOk = new Button(shell, SWT.PUSH);
wOk.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wOk.addListener(SWT.Selection, e -> ok());
wPreview = new Button(shell, SWT.PUSH);
wPreview.setText(BaseMessages.getString(PKG, "GetLoggingInfoDialog.Button.PreviewRows"));
wPreview.setEnabled(!isReceivingInput);
wPreview.addListener(SWT.Selection, e -> preview());
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
wCancel.addListener(SWT.Selection, e -> cancel());
setButtonPositions(new Button[] {wOk, wPreview, wCancel}, margin, null);

// See if the transform receives input.
//
isReceivingInput = pipelineMeta.findNrPrevTransforms(transformMeta) > 0;

// Transformname line
// Transform name line
wlTransformname = new Label(shell, SWT.RIGHT);
wlTransformname.setText(BaseMessages.getString(PKG, "System.Label.TransformName"));
props.setLook(wlTransformname);
Expand Down Expand Up @@ -189,25 +202,9 @@ public void widgetSelected(SelectionEvent e) {
fdFields.left = new FormAttachment(0, 0);
fdFields.top = new FormAttachment(wlFields, margin);
fdFields.right = new FormAttachment(100, 0);
fdFields.bottom = new FormAttachment(100, -50);
fdFields.bottom = new FormAttachment(wOk, -2 * margin);
wFields.setLayoutData(fdFields);

// Some buttons
wOk = new Button(shell, SWT.PUSH);
wOk.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wPreview = new Button(shell, SWT.PUSH);
wPreview.setText(BaseMessages.getString(PKG, "GetLoggingInfoDialog.Button.PreviewRows"));
wPreview.setEnabled(!isReceivingInput);
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));

setButtonPositions(new Button[] {wOk, wPreview, wCancel}, margin, wFields);

// Add listeners
wCancel.addListener(SWT.Selection, e -> cancel());
wOk.addListener(SWT.Selection, e -> ok());
wPreview.addListener(SWT.Selection, e -> preview());

getData();

BaseDialog.defaultShellHandling(shell, c -> ok(), c -> cancel());
Expand Down
Expand Up @@ -220,10 +220,13 @@ public String open() {
//
wOk = new Button(shell, SWT.PUSH);
wOk.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wOk.addListener(SWT.Selection, e -> ok());
Button wTest = new Button(shell, SWT.PUSH);
wTest.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.TestClass.Button"));
wTest.addListener(SWT.Selection, e -> test());
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
wCancel.addListener(SWT.Selection, e -> cancel());
setButtonPositions(new Button[] {wOk, wTest, wCancel}, margin, null);

// Filename line
Expand Down Expand Up @@ -287,28 +290,28 @@ public String open() {
fdlScript.top = new FormAttachment(0, 0);
wlScript.setLayoutData(fdlScript);

wlPosition = new Label(wTop, SWT.NONE);
wlPosition.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.Position.Label"));
props.setLook(wlPosition);
FormData fdlPosition = new FormData();
fdlPosition.left = new FormAttachment(wTree, margin);
fdlPosition.right = new FormAttachment(30, 0);
fdlPosition.bottom = new FormAttachment(100, 0);
wlPosition.setLayoutData(fdlPosition);

folder = new CTabFolder(wTop, SWT.BORDER | SWT.RESIZE);
folder.setUnselectedImageVisible(true);
folder.setUnselectedCloseVisible(true);
FormData fdScript = new FormData();
fdScript.left = new FormAttachment(wTree, margin);
fdScript.top = new FormAttachment(wlScript, margin);
fdScript.right = new FormAttachment(100, -5);
fdScript.bottom = new FormAttachment(100, -50);
fdScript.bottom = new FormAttachment(wlPosition, -margin);
folder.setLayoutData(fdScript);

wlPosition = new Label(wTop, SWT.NONE);
wlPosition.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.Position.Label"));
props.setLook(wlPosition);
FormData fdlPosition = new FormData();
fdlPosition.left = new FormAttachment(wTree, margin);
fdlPosition.right = new FormAttachment(30, 0);
fdlPosition.top = new FormAttachment(folder, margin);
wlPosition.setLayoutData(fdlPosition);

Text wlHelpLabel = new Text(wTop, SWT.V_SCROLL | SWT.LEFT);
wlHelpLabel.setEditable(false);
wlHelpLabel.setText("Hallo");
wlHelpLabel.setText("Help");
props.setLook(wlHelpLabel);
FormData fdHelpLabel = new FormData();
fdHelpLabel.left = new FormAttachment(wlPosition, margin);
Expand Down Expand Up @@ -364,14 +367,11 @@ public String open() {
fdSash.left = new FormAttachment(0, 0);
fdSash.top = new FormAttachment(wTransformName, 0);
fdSash.right = new FormAttachment(100, 0);
fdSash.bottom = new FormAttachment(100, -50);
fdSash.bottom = new FormAttachment(wOk, -2 * margin);
wSash.setLayoutData(fdSash);

wSash.setWeights(new int[] {75, 25});
wSash.setWeights(75, 25);

wCancel.addListener(SWT.Selection, e -> cancel());
wTest.addListener(SWT.Selection, e -> test());
wOk.addListener(SWT.Selection, e -> ok());
wTree.addListener(SWT.MouseDoubleClick, this::treeDblClick);

folder.addCTabFolder2Listener(
Expand Down
Expand Up @@ -188,6 +188,22 @@ public String open() {
int middle = props.getMiddlePct();
int margin = props.getMargin();

// Buttons at the bottom
//
wOk = new Button(shell, SWT.PUSH);
wOk.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wOk.addListener(SWT.Selection, e -> ok());
Button wVars = new Button(shell, SWT.PUSH);
wVars.addListener(SWT.Selection, e -> test(true, true));
wVars.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.GetVariables.Button"));
Button wTest = new Button(shell, SWT.PUSH);
wTest.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.TestScript.Button"));
wTest.addListener(SWT.Selection, e -> newTest());
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
wCancel.addListener(SWT.Selection, e -> cancel());
setButtonPositions(new Button[] {wOk, wVars, wTest, wCancel}, margin, null);

// Filename line
wlTransformName = new Label(shell, SWT.RIGHT);
wlTransformName.setText(
Expand Down Expand Up @@ -260,7 +276,7 @@ public String open() {
props.setLook(wlOptimizationLevel);
FormData fdlOptimizationLevel = new FormData();
fdlOptimizationLevel.left = new FormAttachment(wTree, margin * 2);
fdlOptimizationLevel.bottom = new FormAttachment(100, -2 * margin);
fdlOptimizationLevel.bottom = new FormAttachment(100, -margin);
wlOptimizationLevel.setLayoutData(fdlOptimizationLevel);

wOptimizationLevel = new TextVar(variables, wTop, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
Expand All @@ -282,7 +298,7 @@ public String open() {
FormData fdlPosition = new FormData();
fdlPosition.left = new FormAttachment(wTree, 2 * margin);
fdlPosition.right = new FormAttachment(100, 0);
fdlPosition.bottom = new FormAttachment(wOptimizationLevel, -2 * margin);
fdlPosition.bottom = new FormAttachment(wOptimizationLevel, -margin);
wlPosition.setLayoutData(fdlPosition);

folder = new CTabFolder(wTop, SWT.BORDER | SWT.RESIZE);
Expand All @@ -292,7 +308,7 @@ public String open() {
fdScript.left = new FormAttachment(wTree, margin);
fdScript.top = new FormAttachment(wlScript, margin);
fdScript.right = new FormAttachment(100, -5);
fdScript.bottom = new FormAttachment(wlPosition, -2 * margin);
fdScript.bottom = new FormAttachment(wlPosition, -margin);
folder.setLayoutData(fdScript);

FormData fdTop = new FormData();
Expand Down Expand Up @@ -383,27 +399,12 @@ public String open() {
fdSash.left = new FormAttachment(0, 0);
fdSash.top = new FormAttachment(wTransformName, 0);
fdSash.right = new FormAttachment(100, 0);
fdSash.bottom = new FormAttachment(100, -50);
fdSash.bottom = new FormAttachment(wOk, -2 * margin);
wSash.setLayoutData(fdSash);

wSash.setWeights(new int[] {75, 25});

wOk = new Button(shell, SWT.PUSH);
wOk.setText(BaseMessages.getString(PKG, "System.Button.OK"));
Button wVars = new Button(shell, SWT.PUSH);
wVars.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.GetVariables.Button"));
Button wTest = new Button(shell, SWT.PUSH);
wTest.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.TestScript.Button"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));

setButtonPositions(new Button[] {wOk, wCancel, wVars, wTest}, margin, null);
wSash.setWeights(75, 25);

// Add listeners
wCancel.addListener(SWT.Selection, e -> cancel());
wTest.addListener(SWT.Selection, e -> newTest());
wVars.addListener(SWT.Selection, e -> test(true, true));
wOk.addListener(SWT.Selection, e -> ok());
wTree.addListener(SWT.MouseDoubleClick, e -> treeDblClick(e));

folder.addCTabFolder2Listener(
Expand Down
Expand Up @@ -308,7 +308,7 @@ public void widgetSelected(SelectionEvent e) {
props.setLook(wUseVar);
FormData fdUseVar = new FormData();
fdUseVar.left = new FormAttachment(wlUseVar, margin);
fdUseVar.bottom = new FormAttachment(100, 0);
fdUseVar.top = new FormAttachment(wlUseVar, 0, SWT.CENTER);
wUseVar.setLayoutData(fdUseVar);
wUseVar.addSelectionListener(lsSel);
Composite wBottom = new Composite(wSash, SWT.NONE);
Expand Down Expand Up @@ -625,7 +625,7 @@ public void widgetSelected(SelectionEvent e) {
fdTabFolder.left = new FormAttachment(0, 0);
fdTabFolder.top = new FormAttachment(wTransformName, margin);
fdTabFolder.right = new FormAttachment(100, 0);
fdTabFolder.bottom = new FormAttachment(100, -50);
fdTabFolder.bottom = new FormAttachment(100, 0);
wTabFolder.setLayoutData(fdTabFolder);

FormData fdBottom = new FormData();
Expand All @@ -639,10 +639,10 @@ public void widgetSelected(SelectionEvent e) {
fdSash.left = new FormAttachment(0, 0);
fdSash.top = new FormAttachment(wTransformName, 0);
fdSash.right = new FormAttachment(100, 0);
fdSash.bottom = new FormAttachment(wOk, -2 * margin);
fdSash.bottom = new FormAttachment(wOk, -margin);
wSash.setLayoutData(fdSash);

wSash.setWeights(new int[] {60, 40});
wSash.setWeights(60, 40);

// Add listeners

Expand Down
Expand Up @@ -126,6 +126,16 @@ public String open() {
int margin = props.getMargin();
int middle = 30;

// Some buttons at the bottom

Button wOk = new Button(shell, SWT.PUSH);
wOk.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wOk.addListener(SWT.Selection, e -> ok());
Button wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
wCancel.addListener(SWT.Selection, e -> cancel());
BaseTransformDialog.positionBottomButtons(shell, new Button[] {wOk, wCancel}, margin, null);

CTabFolder wNoteFolder = new CTabFolder(shell, SWT.BORDER);
props.setLook(wNoteFolder, Props.WIDGET_STYLE_TAB);

Expand Down Expand Up @@ -328,20 +338,9 @@ public String open() {
fdNoteFolder.left = new FormAttachment(0, 0);
fdNoteFolder.top = new FormAttachment(0, margin);
fdNoteFolder.right = new FormAttachment(100, 0);
fdNoteFolder.bottom = new FormAttachment(100, -50);
fdNoteFolder.bottom = new FormAttachment(wOk, -2 * margin);
wNoteFolder.setLayoutData(fdNoteFolder);

// Some buttons

Button wOk = new Button(shell, SWT.PUSH);
wOk.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wOk.addListener(SWT.Selection, e -> ok());
Button wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
wCancel.addListener(SWT.Selection, e -> cancel());
BaseTransformDialog.positionBottomButtons(
shell, new Button[] {wOk, wCancel}, margin, wNoteFolder);

// Add listeners

wValue1.addModifyListener(e -> testValue(1, true, null));
Expand All @@ -356,7 +355,7 @@ public String open() {

getData();

BaseTransformDialog.setSize(shell);
wNoteFolder.setSelection(0);

BaseDialog.defaultShellHandling(shell, c -> ok(), c -> cancel());

Expand Down

0 comments on commit 9e5e94b

Please sign in to comment.