use icon font in edit openers dialog as well

This commit is contained in:
Anton Keks 2016-12-08 22:14:04 +02:00
parent d2dc62da67
commit b9a4bd12dc
3 changed files with 20 additions and 15 deletions

View File

@ -1,6 +1,3 @@
/**
*
*/
package net.azib.ipscan.gui;
import net.azib.ipscan.config.Labels;
@ -11,6 +8,7 @@ import net.azib.ipscan.fetchers.FetcherRegistry;
import net.azib.ipscan.gui.util.LayoutHelper;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.*;
@ -18,12 +16,8 @@ import org.eclipse.swt.widgets.*;
import java.io.File;
import static net.azib.ipscan.gui.util.LayoutHelper.formData;
import static net.azib.ipscan.gui.util.LayoutHelper.iconFont;
/**
* EditOpenersDialog
*
* @author Anton Keks
*/
public class EditOpenersDialog extends AbstractModalDialog {
private final FetcherRegistry fetcherRegistry;
private final OpenersConfig openersConfig;
@ -61,9 +55,12 @@ public class EditOpenersDialog extends AbstractModalDialog {
openersList.add(name);
}
openersList.addListener(SWT.Selection, new ItemSelectListener());
Font iconFont = iconFont(shell);
Button upButton = new Button(shell, SWT.NONE);
upButton.setText(Labels.getLabel("button.up"));
upButton.setFont(iconFont);
upButton.addListener(SWT.Selection, new UpButtonListener(openersList) {
@Override public void handleEvent(Event event) {
super.handleEvent(event);
@ -72,7 +69,8 @@ public class EditOpenersDialog extends AbstractModalDialog {
});
Button downButton = new Button(shell, SWT.NONE);
downButton.setText(Labels.getLabel("button.down"));
downButton.setText(Labels.getLabel("button.down"));
downButton.setFont(iconFont);
downButton.addListener(SWT.Selection, new DownButtonListener(openersList) {
@Override public void handleEvent(Event event) {
super.handleEvent(event);

View File

@ -12,7 +12,6 @@ import net.azib.ipscan.fetchers.IPFetcher;
import net.azib.ipscan.gui.util.LayoutHelper;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.widgets.*;
@ -23,6 +22,7 @@ import java.util.Iterator;
import java.util.Map;
import static net.azib.ipscan.gui.util.LayoutHelper.formData;
import static net.azib.ipscan.gui.util.LayoutHelper.iconFont;
/**
* SelectFetchersDialog
@ -65,9 +65,7 @@ public class SelectFetchersDialog extends AbstractModalDialog {
selectedFetchersList.add(fetcher.getName());
}
FontData fontData = messageLabel.getFont().getFontData()[0];
fontData.setHeight(fontData.getHeight() * 4/3);
Font iconFont = new Font(messageLabel.getDisplay(), fontData);
Font iconFont = iconFont(shell);
Button upButton = new Button(shell, SWT.NONE);
upButton.setText(Labels.getLabel("button.up"));
@ -151,7 +149,7 @@ public class SelectFetchersDialog extends AbstractModalDialog {
}
});
}
/**
* Saves passed selected fetchers to the fetcher registry.
* @param fetchersNamesToSave an array obtained by selectedFetchersList.getItems()

View File

@ -7,9 +7,12 @@
package net.azib.ipscan.gui.util;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Shell;
/**
* A helper class to create FormLayout and FormData object more conveniently.
@ -38,4 +41,10 @@ public class LayoutHelper {
public static FormData formData(FormAttachment left, FormAttachment right, FormAttachment top, FormAttachment bottom) {
return formData(SWT.DEFAULT, SWT.DEFAULT, left, right, top, bottom);
}
public static Font iconFont(Shell shell) {
FontData fontData = shell.getFont().getFontData()[0];
fontData.setHeight(fontData.getHeight() * 4/3);
return new Font(shell.getDisplay(), fontData);
}
}