diff --git a/build.xml b/build.xml
index 9810f9ac..c58f5c8c 100755
--- a/build.xml
+++ b/build.xml
@@ -287,7 +287,7 @@
<methods>;
<fields>;
}
- -keep class org.eclipse.swt.internal.image.*FileFormat
+ -keep class org.eclipse.swt.internal.buttonImage.*FileFormat
-keep class * {
% *Proc(int);
% *Proc(int, int);
diff --git a/resources/images/buttons/kill.png b/resources/images/buttons/kill.png
index d8781869..9d2f103d 100644
Binary files a/resources/images/buttons/kill.png and b/resources/images/buttons/kill.png differ
diff --git a/resources/images/buttons/kill.svg b/resources/images/buttons/kill.svg
index 1ede1df7..266906c1 100644
--- a/resources/images/buttons/kill.svg
+++ b/resources/images/buttons/kill.svg
@@ -1,24 +1,24 @@
+
diff --git a/resources/images/buttons/kill@2x.png b/resources/images/buttons/kill@2x.png
new file mode 100644
index 00000000..6488a117
Binary files /dev/null and b/resources/images/buttons/kill@2x.png differ
diff --git a/resources/images/buttons/start.png b/resources/images/buttons/start.png
index b8aab9be..7e728f25 100644
Binary files a/resources/images/buttons/start.png and b/resources/images/buttons/start.png differ
diff --git a/resources/images/buttons/start.svg b/resources/images/buttons/start.svg
index 2c7a5522..535d1ff1 100644
--- a/resources/images/buttons/start.svg
+++ b/resources/images/buttons/start.svg
@@ -1,24 +1,24 @@
+
diff --git a/resources/images/buttons/start@2x.png b/resources/images/buttons/start@2x.png
new file mode 100644
index 00000000..59dba3e9
Binary files /dev/null and b/resources/images/buttons/start@2x.png differ
diff --git a/resources/images/buttons/stop.png b/resources/images/buttons/stop.png
index d65587b2..d88e22f2 100644
Binary files a/resources/images/buttons/stop.png and b/resources/images/buttons/stop.png differ
diff --git a/resources/images/buttons/stop.svg b/resources/images/buttons/stop.svg
index 4490f83a..24be4962 100644
--- a/resources/images/buttons/stop.svg
+++ b/resources/images/buttons/stop.svg
@@ -1,24 +1,24 @@
+
diff --git a/resources/images/buttons/stop@2x.png b/resources/images/buttons/stop@2x.png
new file mode 100644
index 00000000..81d7cb9a
Binary files /dev/null and b/resources/images/buttons/stop@2x.png differ
diff --git a/src/net/azib/ipscan/config/Labels.java b/src/net/azib/ipscan/config/Labels.java
index 7a9169ac..7eb9cc76 100644
--- a/src/net/azib/ipscan/config/Labels.java
+++ b/src/net/azib/ipscan/config/Labels.java
@@ -81,7 +81,7 @@ public final class Labels {
instance.labels = instance.labelsFallback;
}
}
-
+
/**
* Retrieves an InputStream to load the image, specified by a key in resource file.
* @param key
@@ -90,7 +90,7 @@ public final class Labels {
String imagePath = get(key);
return getClass().getClassLoader().getResourceAsStream(imagePath);
}
-
+
/**
* Retrieves a String specified by the label key
* @param key
diff --git a/src/net/azib/ipscan/gui/MainWindow.java b/src/net/azib/ipscan/gui/MainWindow.java
index be8384ce..ac970b0a 100644
--- a/src/net/azib/ipscan/gui/MainWindow.java
+++ b/src/net/azib/ipscan/gui/MainWindow.java
@@ -19,13 +19,16 @@ import net.azib.ipscan.gui.menu.ResultsContextMenu;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
import javax.inject.Inject;
import javax.inject.Named;
+import static net.azib.ipscan.gui.util.LayoutHelper.buttonImage;
import static net.azib.ipscan.gui.util.LayoutHelper.formData;
/**
@@ -166,28 +169,19 @@ public class MainWindow {
prefsButton = createToolbarButton(controlsArea);
ToolItem item = new ToolItem(prefsButton, SWT.PUSH);
- item.setImage(image("prefs"));
+ item.setImage(buttonImage("prefs"));
item.setToolTipText(Labels.getLabel("title.preferences"));
item.addListener(SWT.Selection, preferencesListener);
fetchersButton = createToolbarButton(controlsArea);
item = new ToolItem(fetchersButton, SWT.PUSH);
- item.setImage(image("fetchers"));
+ item.setImage(buttonImage("fetchers"));
item.setToolTipText(Labels.getLabel("title.fetchers.select"));
item.addListener(SWT.Selection, chooseFetchersListsner);
feederSelectionListener.widgetSelected(null);
}
- private Image image(final String baseName) {
- return new Image(Display.getCurrent(), new ImageDataProvider() {
- @Override public ImageData getImageData(int zoom) {
- String suffix = zoom >= 200 ? "@2x.png" : ".png";
- return new ImageData(getClass().getResourceAsStream("/images/buttons/" + baseName + suffix));
- }
- });
- }
-
private ToolBar createToolbarButton(Composite controlsArea) {
ToolBar bar = new ToolBar(controlsArea, SWT.FLAT);
bar.setCursor(bar.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
diff --git a/src/net/azib/ipscan/gui/actions/StartStopScanningAction.java b/src/net/azib/ipscan/gui/actions/StartStopScanningAction.java
index b65de20c..d57ae87b 100644
--- a/src/net/azib/ipscan/gui/actions/StartStopScanningAction.java
+++ b/src/net/azib/ipscan/gui/actions/StartStopScanningAction.java
@@ -31,6 +31,8 @@ import javax.inject.Named;
import javax.inject.Singleton;
import java.net.InetAddress;
+import static net.azib.ipscan.gui.util.LayoutHelper.buttonImage;
+
/**
* Start/Stop button action class.
* It listens to presses on the buttons as well as updates gui statuses
@@ -64,11 +66,11 @@ public class StartStopScanningAction implements SelectionListener, ScanningProgr
this.display = display;
// preload button images
- buttonImages[ScanningState.IDLE.ordinal()] = new Image(display, Labels.getInstance().getImageAsStream("button.start.img"));
- buttonImages[ScanningState.SCANNING.ordinal()] = new Image(display, Labels.getInstance().getImageAsStream("button.stop.img"));
+ buttonImages[ScanningState.IDLE.ordinal()] = buttonImage("start");
+ buttonImages[ScanningState.SCANNING.ordinal()] = buttonImage("stop");
buttonImages[ScanningState.STARTING.ordinal()] = buttonImages[ScanningState.SCANNING.ordinal()];
buttonImages[ScanningState.RESTARTING.ordinal()] = buttonImages[ScanningState.SCANNING.ordinal()];
- buttonImages[ScanningState.STOPPING.ordinal()] = new Image(display, Labels.getInstance().getImageAsStream("button.kill.img"));
+ buttonImages[ScanningState.STOPPING.ordinal()] = buttonImage("kill");
buttonImages[ScanningState.KILLING.ordinal()] = buttonImages[ScanningState.STOPPING.ordinal()];
// preload button texts
@@ -98,7 +100,7 @@ public class StartStopScanningAction implements SelectionListener, ScanningProgr
// add listeners to all state changes
stateMachine.addTransitionListener(this);
- // set the default image
+ // set the default buttonImage
ScanningState state = stateMachine.getState();
button.setImage(buttonImages[state.ordinal()]);
button.setText(buttonTexts[state.ordinal()]);
@@ -191,7 +193,7 @@ public class StartStopScanningAction implements SelectionListener, ScanningProgr
statusBar.setStatusText(Labels.getLabel("state.killingThreads"));
break;
}
- // change button image
+ // change button buttonImage
button.setImage(buttonImages[state.ordinal()]);
button.setText(buttonTexts[state.ordinal()]);
}
@@ -255,7 +257,7 @@ public class StartStopScanningAction implements SelectionListener, ScanningProgr
else
statusBar.getShell().setText(mainWindowTitle);
- // change button image according to the current state
+ // change button buttonImage according to the current state
button.setImage(buttonImages[stateMachine.getState().ordinal()]);
}
});
diff --git a/src/net/azib/ipscan/gui/util/LayoutHelper.java b/src/net/azib/ipscan/gui/util/LayoutHelper.java
index 9515605c..d0d18947 100644
--- a/src/net/azib/ipscan/gui/util/LayoutHelper.java
+++ b/src/net/azib/ipscan/gui/util/LayoutHelper.java
@@ -7,11 +7,11 @@
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.graphics.*;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
/**
@@ -47,4 +47,13 @@ public class LayoutHelper {
fontData.setHeight(fontData.getHeight() * 4/3);
return new Font(shell.getDisplay(), fontData);
}
+
+ public static Image buttonImage(final String baseName) {
+ return new Image(Display.getCurrent(), new ImageDataProvider() {
+ @Override public ImageData getImageData(int zoom) {
+ String suffix = zoom >= 200 ? "@2x.png" : ".png";
+ return new ImageData(getClass().getResourceAsStream("/images/buttons/" + baseName + suffix));
+ }
+ });
+ }
}
diff --git a/test/net/azib/ipscan/config/LabelsTest.java b/test/net/azib/ipscan/config/LabelsTest.java
index 573e47a0..aba1ec56 100644
--- a/test/net/azib/ipscan/config/LabelsTest.java
+++ b/test/net/azib/ipscan/config/LabelsTest.java
@@ -1,25 +1,17 @@
package net.azib.ipscan.config;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import junit.framework.AssertionFailedError;
+import org.junit.Before;
+import org.junit.Test;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
+import java.io.*;
import java.net.URL;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import junit.framework.AssertionFailedError;
-
-import org.junit.Before;
-import org.junit.Test;
+import static org.junit.Assert.*;
public class LabelsTest {
@@ -59,18 +51,18 @@ public class LabelsTest {
// exception is good
}
}
-
+
@Test
public void testImageAsStream() throws IOException {
InputStream stream = Labels.getInstance().getImageAsStream("button.start.img");
- // Now check the first bytes of GIF image header
+ // Now check the first bytes of GIF buttonImage header
stream.read();
assertEquals((int)'P', stream.read());
assertEquals((int)'N', stream.read());
assertEquals((int)'G', stream.read());
stream.close();
}
-
+
/**
* This test recursively processes all source files and tries
* to resolve every label it finds.