mirror of
https://github.com/angryip/ipscan.git
synced 2025-10-26 11:18:17 +00:00
EditOpenersDialog now uses FormLayout.
LayoutHelper introduced. Plus some more Mac tweaks. git-svn-id: https://ipscan.svn.sourceforge.net/svnroot/ipscan/trunk/ipscan@116 375186e5-ef17-0410-b0b6-91563547dcda
This commit is contained in:
parent
d9b278e099
commit
6fa1347357
@ -96,6 +96,7 @@ public class AboutDialog extends AbstractModalDialog {
|
||||
Point size = shell.getSize();
|
||||
shell.setSize(size.x, size.y - button.getSize().y);
|
||||
button.setVisible(false);
|
||||
licenseText.setFocus();
|
||||
}
|
||||
else {
|
||||
button.setFocus();
|
||||
|
||||
@ -110,7 +110,10 @@ public abstract class AbstractModalDialog {
|
||||
list.select(index - 1);
|
||||
}
|
||||
|
||||
list.setTopIndex(selectedItems[0] - 2);
|
||||
if (!Platform.MAC_OS) {
|
||||
// this doesn't look good on Mac
|
||||
list.setTopIndex(selectedItems[0] - 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,7 +143,10 @@ public abstract class AbstractModalDialog {
|
||||
list.select(index + 1);
|
||||
}
|
||||
|
||||
list.setTopIndex(selectedItems[0]);
|
||||
if (!Platform.MAC_OS) {
|
||||
// this doesn't look good on Mac
|
||||
list.setTopIndex(selectedItems[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -10,7 +10,6 @@ import net.azib.ipscan.config.Labels;
|
||||
import net.azib.ipscan.config.NamedListConfig;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
@ -42,12 +41,12 @@ public class EditFavoritesDialog extends AbstractModalDialog {
|
||||
shell = new Shell(parent, SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);
|
||||
|
||||
shell.setText(Labels.getLabel("title.favorite.edit"));
|
||||
shell.setSize(new Point(405, 297));
|
||||
shell.setLayout(null);
|
||||
|
||||
Label messageLabel = new Label(shell, SWT.NONE);
|
||||
messageLabel.setText(Labels.getLabel("text.favorite.edit"));
|
||||
messageLabel.setBounds(new Rectangle(10, 10, 282, 14));
|
||||
messageLabel.setText(Labels.getLabel("text.favorite.edit"));
|
||||
messageLabel.pack();
|
||||
messageLabel.setLocation(10, 10);
|
||||
|
||||
favoritesList = new List(shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
|
||||
favoritesList.setBounds(new Rectangle(10, 30, 330, 200));
|
||||
@ -58,27 +57,31 @@ public class EditFavoritesDialog extends AbstractModalDialog {
|
||||
|
||||
Button upButton = new Button(shell, SWT.NONE);
|
||||
upButton.setText(Labels.getLabel("button.up"));
|
||||
upButton.setBounds(new Rectangle(350, 30, 40, 25));
|
||||
upButton.pack();
|
||||
upButton.setLocation(350, 30);
|
||||
upButton.addListener(SWT.Selection, new UpButtonListener(favoritesList));
|
||||
|
||||
Button downButton = new Button(shell, SWT.NONE);
|
||||
downButton.setText(Labels.getLabel("button.down"));
|
||||
downButton.setBounds(new Rectangle(350, 60, 40, 25));
|
||||
downButton.setText(Labels.getLabel("button.down"));
|
||||
downButton.pack();
|
||||
downButton.setLocation(350, 60);
|
||||
downButton.addListener(SWT.Selection, new DownButtonListener(favoritesList));
|
||||
|
||||
Button deleteButton = new Button(shell, SWT.NONE);
|
||||
deleteButton.setText(Labels.getLabel("button.delete"));
|
||||
deleteButton.setBounds(new Rectangle(350, 105, 40, 25));
|
||||
deleteButton.setText(Labels.getLabel("button.delete"));
|
||||
deleteButton.pack();
|
||||
deleteButton.setLocation(350, 105);
|
||||
deleteButton.addListener(SWT.Selection, new DeleteButtonListener());
|
||||
|
||||
Button okButton = new Button(shell, SWT.NONE);
|
||||
okButton.setText(Labels.getLabel("button.OK"));
|
||||
okButton.setBounds(new Rectangle(180, 238, 75, 25));
|
||||
shell.setDefaultButton(okButton);
|
||||
|
||||
Button cancelButton = new Button(shell, SWT.NONE);
|
||||
cancelButton.setText(Labels.getLabel("button.cancel"));
|
||||
cancelButton.setBounds(new Rectangle(265, 238, 75, 25));
|
||||
|
||||
shell.pack();
|
||||
shell.setSize(shell.getSize().x, 297);
|
||||
positionButtons(okButton, cancelButton);
|
||||
|
||||
okButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
|
||||
@ -91,6 +94,7 @@ public class EditFavoritesDialog extends AbstractModalDialog {
|
||||
shell.close();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void saveFavorites() {
|
||||
|
||||
@ -9,13 +9,15 @@ import java.util.Iterator;
|
||||
import net.azib.ipscan.config.Config;
|
||||
import net.azib.ipscan.config.Labels;
|
||||
import net.azib.ipscan.config.OpenersConfig;
|
||||
import net.azib.ipscan.config.Platform;
|
||||
import net.azib.ipscan.config.OpenersConfig.Opener;
|
||||
import net.azib.ipscan.fetchers.Fetcher;
|
||||
import net.azib.ipscan.fetchers.FetcherRegistry;
|
||||
import net.azib.ipscan.gui.util.LayoutHelper;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.layout.FormAttachment;
|
||||
import org.eclipse.swt.layout.RowLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
@ -59,14 +61,13 @@ public class EditOpenersDialog extends AbstractModalDialog {
|
||||
|
||||
shell.setText(Labels.getLabel("title.openers.edit"));
|
||||
shell.setSize(new Point(405, 307));
|
||||
shell.setLayout(null);
|
||||
shell.setLayout(LayoutHelper.createLayout(10, 10, 4));
|
||||
|
||||
Label messageLabel = new Label(shell, SWT.NONE);
|
||||
messageLabel.setText(Labels.getLabel("text.openers.edit"));
|
||||
messageLabel.setBounds(new Rectangle(10, 10, 282, 14));
|
||||
messageLabel.setText(Labels.getLabel("text.openers.edit"));
|
||||
|
||||
openersList = new List(shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
|
||||
openersList.setBounds(new Rectangle(10, 30, 135, 200));
|
||||
openersList.setLayoutData(LayoutHelper.createData(135, 200, null, null, new FormAttachment(messageLabel), null));
|
||||
for (Iterator i = Config.getOpenersConfig().iterateNames(); i.hasNext();) {
|
||||
String name = (String) i.next();
|
||||
openersList.add(name);
|
||||
@ -74,32 +75,28 @@ public class EditOpenersDialog extends AbstractModalDialog {
|
||||
openersList.addListener(SWT.Selection, new ItemSelectListener());
|
||||
|
||||
Button upButton = new Button(shell, SWT.NONE);
|
||||
upButton.setText(Labels.getLabel("button.up"));
|
||||
upButton.setBounds(new Rectangle(150, 30, 40, 25));
|
||||
upButton.setText(Labels.getLabel("button.up"));
|
||||
upButton.addListener(SWT.Selection, new UpButtonListener(openersList));
|
||||
|
||||
Button downButton = new Button(shell, SWT.NONE);
|
||||
downButton.setText(Labels.getLabel("button.down"));
|
||||
downButton.setBounds(new Rectangle(150, 60, 40, 25));
|
||||
downButton.setText(Labels.getLabel("button.down"));
|
||||
downButton.addListener(SWT.Selection, new DownButtonListener(openersList));
|
||||
|
||||
Button addButton = new Button(shell, SWT.NONE);
|
||||
addButton.setText(Labels.getLabel("button.add"));
|
||||
addButton.setBounds(new Rectangle(150, 105, 40, 25));
|
||||
addButton.setText(Labels.getLabel("button.add"));
|
||||
addButton.addListener(SWT.Selection, new AddButtonListener());
|
||||
|
||||
Button deleteButton = new Button(shell, SWT.NONE);
|
||||
deleteButton.setText(Labels.getLabel("button.delete"));
|
||||
deleteButton.setBounds(new Rectangle(150, 135, 40, 25));
|
||||
deleteButton.setText(Labels.getLabel("button.delete"));
|
||||
deleteButton.addListener(SWT.Selection, new DeleteButtonListener());
|
||||
|
||||
Button closeButton = new Button(shell, SWT.NONE);
|
||||
closeButton.setText(Labels.getLabel("button.close"));
|
||||
|
||||
positionButtons(closeButton, null);
|
||||
|
||||
upButton.setLayoutData(LayoutHelper.createData(new FormAttachment(openersList), new FormAttachment(deleteButton, 0, SWT.RIGHT), new FormAttachment(messageLabel), null));
|
||||
downButton.setLayoutData(LayoutHelper.createData(new FormAttachment(openersList), new FormAttachment(deleteButton, 0, SWT.RIGHT), new FormAttachment(upButton), null));
|
||||
addButton.setLayoutData(LayoutHelper.createData(new FormAttachment(openersList), new FormAttachment(deleteButton, 0, SWT.RIGHT), new FormAttachment(downButton, 16), null));
|
||||
deleteButton.setLayoutData(LayoutHelper.createData(new FormAttachment(openersList), null, new FormAttachment(addButton), null));
|
||||
|
||||
editFieldsGroup = new Group(shell, SWT.NONE);
|
||||
editFieldsGroup.setBounds(205, 30, 185, 200);
|
||||
editFieldsGroup.setLayoutData(LayoutHelper.createData(new FormAttachment(upButton), null, new FormAttachment(messageLabel), null));
|
||||
RowLayout rowLayout = new RowLayout(SWT.VERTICAL);
|
||||
rowLayout.fill = true;
|
||||
rowLayout.justify = true;
|
||||
@ -134,7 +131,22 @@ public class EditOpenersDialog extends AbstractModalDialog {
|
||||
workingDirText.setSize(SWT.DEFAULT, 22);
|
||||
|
||||
editFieldsGroup.layout();
|
||||
|
||||
editFieldsGroup.pack();
|
||||
|
||||
// no close button on Mac
|
||||
if (!Platform.MAC_OS) {
|
||||
Button closeButton = new Button(shell, SWT.NONE);
|
||||
closeButton.setText(Labels.getLabel("button.close"));
|
||||
closeButton.setLayoutData(LayoutHelper.createData(85, SWT.DEFAULT, null, new FormAttachment(editFieldsGroup, 0, SWT.RIGHT), new FormAttachment(editFieldsGroup), null));
|
||||
closeButton.addListener(SWT.Selection, new Listener() {
|
||||
public void handleEvent(Event event) {
|
||||
shell.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
shell.pack();
|
||||
|
||||
openersList.select(0);
|
||||
loadFieldsForSelection();
|
||||
|
||||
@ -143,11 +155,6 @@ public class EditOpenersDialog extends AbstractModalDialog {
|
||||
saveOpeners();
|
||||
}
|
||||
});
|
||||
closeButton.addListener(SWT.Selection, new Listener() {
|
||||
public void handleEvent(Event event) {
|
||||
shell.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void saveOpeners() {
|
||||
@ -236,6 +243,9 @@ public class EditOpenersDialog extends AbstractModalDialog {
|
||||
private class ItemSelectListener implements Listener {
|
||||
|
||||
public void handleEvent(Event event) {
|
||||
if (openersList.getSelectionCount() == 0)
|
||||
return;
|
||||
|
||||
saveCurrentFields();
|
||||
loadFieldsForSelection();
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import java.util.Iterator;
|
||||
|
||||
import net.azib.ipscan.config.Config;
|
||||
import net.azib.ipscan.config.Labels;
|
||||
import net.azib.ipscan.config.Platform;
|
||||
import net.azib.ipscan.config.Version;
|
||||
import net.azib.ipscan.gui.MainMenu.CommandsMenu;
|
||||
import net.azib.ipscan.gui.actions.StartStopScanningAction;
|
||||
@ -146,12 +147,12 @@ public class MainWindow {
|
||||
|
||||
// start/stop button
|
||||
shell.setDefaultButton(startStopButton);
|
||||
startStopButton.setLayoutData(new RowData(SWT.DEFAULT, 23));
|
||||
startStopButton.setLayoutData(new RowData(SWT.DEFAULT, !Platform.MAC_OS ? 23 : SWT.DEFAULT));
|
||||
startStopButton.addSelectionListener(startStopScanningAction);
|
||||
|
||||
// feeder selection combobox
|
||||
this.feederSelectionCombo = feederSelectionCombo;
|
||||
feederSelectionCombo.setLayoutData(new RowData(SWT.DEFAULT, 23));
|
||||
if (!Platform.MAC_OS) feederSelectionCombo.setLayoutData(new RowData(SWT.DEFAULT, !Platform.MAC_OS ? 23 : SWT.DEFAULT));
|
||||
for (Iterator i = feederRegistry.iterator(); i.hasNext();) {
|
||||
AbstractFeederGUI feederGUI = (AbstractFeederGUI) i.next();
|
||||
feederSelectionCombo.add(feederGUI.getFeederName());
|
||||
|
||||
@ -259,10 +259,10 @@ public class OptionsDialog extends AbstractModalDialog {
|
||||
|
||||
label = new Label(portsGroup, SWT.WRAP);
|
||||
label.setText(Labels.getLabel("options.ports.portsDescription"));
|
||||
label.setLayoutData(new RowData(280, SWT.DEFAULT));
|
||||
label.setLayoutData(new RowData(300, SWT.DEFAULT));
|
||||
portsText = new Text(portsGroup, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);
|
||||
portsText.setLayoutData(new RowData(260, 60));
|
||||
// TODO: configuration string validation
|
||||
portsText.setLayoutData(new RowData(SWT.DEFAULT, 60));
|
||||
// TODO: ports configuration string validation
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -57,16 +57,19 @@ public class SelectFetchersDialog extends AbstractModalDialog {
|
||||
shell = new Shell(parent, SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);
|
||||
|
||||
shell.setText(Labels.getLabel("title.fetchers.select"));
|
||||
shell.setSize(new Point(405, 332));
|
||||
shell.setSize(new Point(420, 332));
|
||||
shell.setLayout(null);
|
||||
|
||||
Label messageLabel = new Label(shell, SWT.NONE);
|
||||
messageLabel.setText(Labels.getLabel("text.fetchers.select"));
|
||||
messageLabel.setBounds(new Rectangle(10, 10, 380, 14));
|
||||
Label messageLabel = new Label(shell, SWT.WRAP);
|
||||
messageLabel.setText(Labels.getLabel("text.fetchers.select"));
|
||||
messageLabel.setSize(messageLabel.computeSize(420, SWT.DEFAULT));
|
||||
messageLabel.setLocation(10, 10);
|
||||
Rectangle messageLabelBounds = messageLabel.getBounds();
|
||||
int topLocation = messageLabelBounds.y + messageLabelBounds.height + 10;
|
||||
|
||||
Label selectedLabel = new Label(shell, SWT.NONE);
|
||||
selectedLabel.setText(Labels.getLabel("text.fetchers.selectedList"));
|
||||
selectedLabel.setBounds(new Rectangle(10, 35, 155, 14));
|
||||
selectedLabel.setBounds(new Rectangle(10, topLocation, 155, 14));
|
||||
|
||||
Button okButton = new Button(shell, SWT.NONE);
|
||||
okButton.setText(Labels.getLabel("button.OK"));
|
||||
@ -77,7 +80,7 @@ public class SelectFetchersDialog extends AbstractModalDialog {
|
||||
positionButtons(okButton, cancelButton);
|
||||
|
||||
selectedFetchersList = new List(shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
|
||||
selectedFetchersList.setBounds(new Rectangle(10, 55, 155, okButton.getLocation().y - 65));
|
||||
selectedFetchersList.setBounds(new Rectangle(10, topLocation + 20, 155, okButton.getLocation().y - 25 - topLocation));
|
||||
Iterator i = fetcherRegistry.getSelectedFetchers().iterator();
|
||||
i.next(); // skip IP
|
||||
while (i.hasNext()) {
|
||||
@ -87,27 +90,31 @@ public class SelectFetchersDialog extends AbstractModalDialog {
|
||||
}
|
||||
|
||||
Button upButton = new Button(shell, SWT.NONE);
|
||||
upButton.setText(Labels.getLabel("button.up"));
|
||||
upButton.setBounds(new Rectangle(170, 55, 40, 25));
|
||||
upButton.setText(Labels.getLabel("button.up"));
|
||||
upButton.pack();
|
||||
upButton.setLocation(170, topLocation + 20);
|
||||
|
||||
Button downButton = new Button(shell, SWT.NONE);
|
||||
downButton.setText(Labels.getLabel("button.down"));
|
||||
downButton.setBounds(new Rectangle(170, 85, 40, 25));
|
||||
downButton.setText(Labels.getLabel("button.down"));
|
||||
downButton.pack();
|
||||
downButton.setLocation(170, topLocation + 50);
|
||||
|
||||
Button addButton = new Button(shell, SWT.NONE);
|
||||
addButton.setText(Labels.getLabel("button.left"));
|
||||
addButton.setBounds(new Rectangle(170, 130, 40, 25));
|
||||
addButton.setText(Labels.getLabel("button.left"));
|
||||
addButton.pack();
|
||||
addButton.setLocation(170, topLocation + 95);
|
||||
|
||||
Button removeButton = new Button(shell, SWT.NONE);
|
||||
removeButton.setText(Labels.getLabel("button.right"));
|
||||
removeButton.setBounds(new Rectangle(170, 160, 40, 25));
|
||||
removeButton.setText(Labels.getLabel("button.right"));
|
||||
removeButton.pack();
|
||||
removeButton.setLocation(170, topLocation + 125);
|
||||
|
||||
Label registeredLabel = new Label(shell, SWT.NONE);
|
||||
registeredLabel.setText(Labels.getLabel("text.fetchers.availableList"));
|
||||
registeredLabel.setBounds(new Rectangle(230, 35, 155, 14));
|
||||
registeredLabel.setBounds(new Rectangle(245, topLocation, 155, 14));
|
||||
|
||||
registeredFetchersList = new List(shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
|
||||
registeredFetchersList.setBounds(new Rectangle(230, 55, 160, okButton.getLocation().y - 65));
|
||||
registeredFetchersList.setBounds(new Rectangle(245, topLocation + 20, 160, okButton.getLocation().y - 25 - topLocation));
|
||||
i = fetcherRegistry.getRegisteredFetchers().iterator();
|
||||
i.next(); // skip IP
|
||||
while (i.hasNext()) {
|
||||
@ -120,8 +127,12 @@ public class SelectFetchersDialog extends AbstractModalDialog {
|
||||
|
||||
upButton.addListener(SWT.Selection, new UpButtonListener(selectedFetchersList));
|
||||
downButton.addListener(SWT.Selection, new DownButtonListener(selectedFetchersList));
|
||||
addButton.addListener(SWT.Selection, new AddRemoveButtonListener(registeredFetchersList, selectedFetchersList));
|
||||
removeButton.addListener(SWT.Selection, new AddRemoveButtonListener(selectedFetchersList, registeredFetchersList));
|
||||
AddRemoveButtonListener addButtonListener = new AddRemoveButtonListener(registeredFetchersList, selectedFetchersList);
|
||||
addButton.addListener(SWT.Selection, addButtonListener);
|
||||
registeredFetchersList.addListener(SWT.MouseDoubleClick, addButtonListener);
|
||||
AddRemoveButtonListener removeButtonListener = new AddRemoveButtonListener(selectedFetchersList, registeredFetchersList);
|
||||
removeButton.addListener(SWT.Selection, removeButtonListener);
|
||||
selectedFetchersList.addListener(SWT.MouseDoubleClick, removeButtonListener);
|
||||
|
||||
cancelButton.addListener(SWT.Selection, new Listener() {
|
||||
public void handleEvent(Event e) {
|
||||
|
||||
@ -130,7 +130,7 @@ public class ColumnsActions {
|
||||
|
||||
Fetcher fetcher = (Fetcher) tableColumn.getData();
|
||||
|
||||
MessageBox messageBox = new MessageBox(event.display.getActiveShell(), SWT.ICON_INFORMATION);
|
||||
MessageBox messageBox = new MessageBox(event.display.getActiveShell(), SWT.ICON_INFORMATION | SWT.OK);
|
||||
messageBox.setText(Labels.getLabel("text.fetchers.info") + Labels.getLabel(fetcher.getLabel()));
|
||||
try {
|
||||
messageBox.setMessage(Labels.getLabel(fetcher.getLabel() + ".info"));
|
||||
|
||||
41
src/net/azib/ipscan/gui/util/LayoutHelper.java
Normal file
41
src/net/azib/ipscan/gui/util/LayoutHelper.java
Normal file
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* This file is a part of Angry IP Scanner source code,
|
||||
* see http://www.azib.net/ for more information.
|
||||
* Licensed under GPLv2.
|
||||
*/
|
||||
|
||||
package net.azib.ipscan.gui.util;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.FormAttachment;
|
||||
import org.eclipse.swt.layout.FormData;
|
||||
import org.eclipse.swt.layout.FormLayout;
|
||||
|
||||
/**
|
||||
* A helper class to create FormLayout and FormData object more conveniently.
|
||||
*
|
||||
* @author Anton Keks
|
||||
*/
|
||||
public class LayoutHelper {
|
||||
|
||||
public static FormLayout createLayout(int marginWidth, int marginHeight, int spacing) {
|
||||
FormLayout formLayout = new FormLayout();
|
||||
formLayout.marginWidth = marginWidth;
|
||||
formLayout.marginHeight = marginHeight;
|
||||
formLayout.spacing = spacing;
|
||||
return formLayout;
|
||||
}
|
||||
|
||||
public static FormData createData(int width, int height, FormAttachment left, FormAttachment right, FormAttachment top, FormAttachment bottom) {
|
||||
FormData formData = new FormData(width, height);
|
||||
formData.left = left;
|
||||
formData.right = right;
|
||||
formData.top = top;
|
||||
formData.bottom = bottom;
|
||||
return formData;
|
||||
}
|
||||
|
||||
public static FormData createData(FormAttachment left, FormAttachment right, FormAttachment top, FormAttachment bottom) {
|
||||
return createData(SWT.DEFAULT, SWT.DEFAULT, left, right, top, bottom);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user