Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix layout issue on username/password login page caused by PR #1040 #1043

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;

/**
* LoginStandardControl is the way to login to the api
*/
public class UsernamePasswordLoginStandardControl extends Composite {

private final Grid12 grid;
private final Button loginButton;
private final Text userName;
private final Text password;
Expand All @@ -49,10 +52,27 @@ public class UsernamePasswordLoginStandardControl extends Composite {
public UsernamePasswordLoginStandardControl(Composite parent, int style, AuthenticationRunner authentication) {
super(parent, style);
this.authentication = authentication;
grid = new Grid12(this, 40, false, true);
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
this.setLayoutData(data);
GridLayout layout = new GridLayout(2, false);
layout.verticalSpacing = 10;
this.setLayout(layout);

final int MAX_CHARS_IN_TEXT = 40;
Label usernameLabel = new Label(this, SWT.RIGHT);
data = new GridData(GridData.HORIZONTAL_ALIGN_END);
usernameLabel.setLayoutData(data);
usernameLabel.setText(Labels.getString("SettingsPage.username"));
userName = new Text(this, SWT.LEFT | SWT.BORDER);
userName.setText(authentication.getConfig().getString(Config.USERNAME));
userName.setTextLimit(MAX_CHARS_IN_TEXT);
GC gc = new GC(userName);
final Point TEXT_SIZE = gc.textExtent("8");
gc.dispose();
data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
data.widthHint = MAX_CHARS_IN_TEXT * TEXT_SIZE.x;
userName.setLayoutData(data);

grid.createLabel(4, Labels.getString("SettingsPage.username"));
userName = grid.createText(6, SWT.BORDER | SWT.FILL, authentication.getConfig().getString(Config.USERNAME));
userName.addKeyListener(new KeyListener() {
@Override
public void keyReleased(KeyEvent e){}
Expand All @@ -63,10 +83,17 @@ public void keyPressed(KeyEvent e){
}
}
});
grid.createPadding(2);

grid.createLabel(4, Labels.getString("SettingsPage.password"));
password = grid.createText(6, SWT.PASSWORD | SWT.BORDER, "");
Label passwordLabel = new Label(this, SWT.RIGHT | SWT.WRAP);
data = new GridData(GridData.HORIZONTAL_ALIGN_END);
passwordLabel.setLayoutData(data);
passwordLabel.setText(Labels.getString("SettingsPage.password"));
password = new Text(this, SWT.PASSWORD | SWT.LEFT | SWT.BORDER);
password.setText("");
password.setTextLimit(MAX_CHARS_IN_TEXT);
data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
data.widthHint = MAX_CHARS_IN_TEXT * TEXT_SIZE.x;
password.setLayoutData(data);
password.addKeyListener(new KeyListener() {
@Override
public void keyReleased(KeyEvent e){}
Expand All @@ -80,18 +107,32 @@ public void keyPressed(KeyEvent e) {
}
}
});
grid.createPadding(2);

grid.createLabel(4, Labels.getString("SettingsPage.instServerUrl"));
instanceUrl = grid.createText(6, SWT.BORDER, authentication.getConfig().getString(Config.ENDPOINT));
grid.createPadding(2);
Label serverURLLabel = new Label(this, SWT.RIGHT | SWT.WRAP);
data = new GridData(GridData.HORIZONTAL_ALIGN_END);
serverURLLabel.setLayoutData(data);
serverURLLabel.setText(Labels.getString("SettingsPage.instServerUrl"));
instanceUrl = new Text(this, SWT.LEFT | SWT.BORDER);
instanceUrl.setText(authentication.getConfig().getString(Config.ENDPOINT));
instanceUrl.setTextLimit(MAX_CHARS_IN_TEXT);
data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
data.widthHint = MAX_CHARS_IN_TEXT * TEXT_SIZE.x;
instanceUrl.setLayoutData(data);

@SuppressWarnings("unused")
Label emptyLabel = grid.createLabel(8, "");
loginButton = grid.createButton(2, SWT.PUSH | SWT.FILL | SWT.FLAT, Labels.getString("SettingsPage.login"));
Label emptyLabel = new Label(this, SWT.RIGHT);
emptyLabel.setText("");
loginButton = new Button(this, SWT.PUSH | SWT.CENTER | SWT.FLAT);
loginButton.setText(Labels.getString("SettingsPage.login"));
loginButton.addListener(SWT.Selection, this::loginButton_Clicked);
grid.createPadding(2);
loginLabel = grid.createLabel(10, "");
data = new GridData(GridData.HORIZONTAL_ALIGN_END);
data.widthHint = Labels.getString("SettingsPage.login").length() * 2 * TEXT_SIZE.x;
loginButton.setLayoutData(data);

loginLabel = new Label(this, SWT.LEFT);
data = new GridData();
data.horizontalSpan = 2;
loginLabel.setLayoutData(data);
}

private void loginButton_Clicked(Event event) {
Expand Down
Loading