Merging from 3.0-beta2

* InputDialog now looks better with larger fonts
* Find dialog's button is now Find Next instead of OK

git-svn-id: https://ipscan.svn.sourceforge.net/svnroot/ipscan/trunk@319 375186e5-ef17-0410-b0b6-91563547dcda
This commit is contained in:
angryziber 2008-03-22 14:04:45 +00:00
parent 491951a205
commit 9ffeae7099
3 changed files with 28 additions and 17 deletions

View File

@ -124,6 +124,7 @@ text.about=%NAME\n\nVersion: %VERSION\nBuild: %BUILD\nBuild date: %DATE\n\n%COPY
text.about.system=Java: %JAVA\nOS: %OS
button.OK=OK
button.cancel=Cancel
button.find.next=Find &Next
button.close=&Close
button.next=&Next ->
button.start=&Start

View File

@ -6,15 +6,15 @@
package net.azib.ipscan.gui;
import net.azib.ipscan.config.Labels;
import net.azib.ipscan.gui.util.LayoutHelper;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
/**
* Customizable InputDialog
@ -45,10 +45,12 @@ public class InputDialog extends AbstractModalDialog {
Shell parent = currentDisplay != null ? currentDisplay.getActiveShell() : null;
shell = new Shell(parent, SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);
shell.setSize(new Point(310, 125));
shell.setLayout(null);
shell.setLayout(LayoutHelper.formLayout(10, 10, 4));
messageLabel = new Label(shell, SWT.NONE);
messageLabel.setBounds(new Rectangle(10, 10, 282, 14));
messageLabel.setLayoutData(LayoutHelper.formData(new FormAttachment(0), null, new FormAttachment(0), null));
text = new Text(shell, SWT.BORDER);
okButton = new Button(shell, SWT.NONE);
okButton.setText(Labels.getLabel("button.OK"));
@ -56,11 +58,8 @@ public class InputDialog extends AbstractModalDialog {
cancelButton = new Button(shell, SWT.NONE);
cancelButton.setText(Labels.getLabel("button.cancel"));
positionButtons(okButton, cancelButton);
positionButtonsInFormLayout(okButton, cancelButton, text);
text = new Text(shell, SWT.BORDER);
text.setBounds(new Rectangle(10, 28, shell.getClientArea().width - 20, 24));
okButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
message = text.getText();
@ -73,14 +72,16 @@ public class InputDialog extends AbstractModalDialog {
shell.dispose();
}
});
text.setFocus();
}
private void setText(String text) {
if (text != null) {
this.text.setText(text);
this.text.setSelection(0, -1);
this.text.pack();
this.text.setLayoutData(LayoutHelper.formData(Math.max(this.text.getSize().x, 310), SWT.DEFAULT, new FormAttachment(0), null, new FormAttachment(messageLabel), null));
this.text.setFocus();
shell.pack();
}
}
@ -89,10 +90,19 @@ public class InputDialog extends AbstractModalDialog {
*
* @return the entered text or null in case of cancel.
*/
public String open(String text) {
public String open(String text, String okButtonText) {
okButton.setText(okButtonText);
setText(text);
super.open();
return message;
}
/**
* Opens the dialog and waits for user to input the data.
*
* @return the entered text or null in case of cancel.
*/
public String open(String text) {
return open(text, Labels.getLabel("button.OK"));
}
}

View File

@ -92,7 +92,7 @@ public class GotoActions {
public void handleEvent(Event event) {
InputDialog dialog = new InputDialog(Labels.getLabel("title.find"), Labels.getLabel("text.find"));
String text = dialog.open(lastText);
String text = dialog.open(lastText, Labels.getLabel("button.find.next"));
if (text == null) {
return;
}