Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.swt.examples.browser.demos/pom.xml2
-rw-r--r--examples/org.eclipse.swt.examples.launcher/pom.xml2
-rw-r--r--examples/org.eclipse.swt.examples.ole.win32/pom.xml2
-rw-r--r--examples/org.eclipse.swt.examples.views/pom.xml2
-rw-r--r--examples/org.eclipse.swt.examples/META-INF/MANIFEST.MF2
-rw-r--r--examples/org.eclipse.swt.examples/pom.xml4
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/browser-content.html2
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/imageanalyzer/ImageAnalyzer.java55
-rw-r--r--examples/org.eclipse.swt.snippets/previews/Snippet379.pngbin0 -> 12342 bytes
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet154.java4
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet246.java37
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet337.java2
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet379.java63
13 files changed, 124 insertions, 53 deletions
diff --git a/examples/org.eclipse.swt.examples.browser.demos/pom.xml b/examples/org.eclipse.swt.examples.browser.demos/pom.xml
index 1bd4f24028..739538de2a 100644
--- a/examples/org.eclipse.swt.examples.browser.demos/pom.xml
+++ b/examples/org.eclipse.swt.examples.browser.demos/pom.xml
@@ -14,7 +14,7 @@
<parent>
<artifactId>eclipse.platform.swt.localbuild</artifactId>
<groupId>eclipse.platform.swt</groupId>
- <version>4.23.0-SNAPSHOT</version>
+ <version>4.24.0-SNAPSHOT</version>
<relativePath>../../local-build/local-build-parent/</relativePath>
</parent>
<groupId>org.eclipse.swt</groupId>
diff --git a/examples/org.eclipse.swt.examples.launcher/pom.xml b/examples/org.eclipse.swt.examples.launcher/pom.xml
index 32477aa6f1..f066a82431 100644
--- a/examples/org.eclipse.swt.examples.launcher/pom.xml
+++ b/examples/org.eclipse.swt.examples.launcher/pom.xml
@@ -14,7 +14,7 @@
<parent>
<artifactId>eclipse.platform.swt.localbuild</artifactId>
<groupId>eclipse.platform.swt</groupId>
- <version>4.23.0-SNAPSHOT</version>
+ <version>4.24.0-SNAPSHOT</version>
<relativePath>../../local-build/local-build-parent/</relativePath>
</parent>
<groupId>org.eclipse.swt</groupId>
diff --git a/examples/org.eclipse.swt.examples.ole.win32/pom.xml b/examples/org.eclipse.swt.examples.ole.win32/pom.xml
index 6b424468ee..5e50471043 100644
--- a/examples/org.eclipse.swt.examples.ole.win32/pom.xml
+++ b/examples/org.eclipse.swt.examples.ole.win32/pom.xml
@@ -14,7 +14,7 @@
<parent>
<artifactId>eclipse.platform.swt</artifactId>
<groupId>eclipse.platform.swt</groupId>
- <version>4.23.0-SNAPSHOT</version>
+ <version>4.24.0-SNAPSHOT</version>
<relativePath>../../</relativePath>
</parent>
<groupId>org.eclipse.swt</groupId>
diff --git a/examples/org.eclipse.swt.examples.views/pom.xml b/examples/org.eclipse.swt.examples.views/pom.xml
index 04d7fb8d74..b0af44b7b2 100644
--- a/examples/org.eclipse.swt.examples.views/pom.xml
+++ b/examples/org.eclipse.swt.examples.views/pom.xml
@@ -14,7 +14,7 @@
<parent>
<artifactId>eclipse.platform.swt.localbuild</artifactId>
<groupId>eclipse.platform.swt</groupId>
- <version>4.23.0-SNAPSHOT</version>
+ <version>4.24.0-SNAPSHOT</version>
<relativePath>../../local-build/local-build-parent/</relativePath>
</parent>
<groupId>org.eclipse.swt</groupId>
diff --git a/examples/org.eclipse.swt.examples/META-INF/MANIFEST.MF b/examples/org.eclipse.swt.examples/META-INF/MANIFEST.MF
index 9bbf5adabe..a278ed410e 100644
--- a/examples/org.eclipse.swt.examples/META-INF/MANIFEST.MF
+++ b/examples/org.eclipse.swt.examples/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %plugin.SWTStandaloneExampleSet.name
Bundle-SymbolicName: org.eclipse.swt.examples; singleton:=true
-Bundle-Version: 3.107.100.qualifier
+Bundle-Version: 3.107.200.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-11
diff --git a/examples/org.eclipse.swt.examples/pom.xml b/examples/org.eclipse.swt.examples/pom.xml
index 89677ad88b..82f064df74 100644
--- a/examples/org.eclipse.swt.examples/pom.xml
+++ b/examples/org.eclipse.swt.examples/pom.xml
@@ -14,11 +14,11 @@
<parent>
<artifactId>eclipse.platform.swt.localbuild</artifactId>
<groupId>eclipse.platform.swt</groupId>
- <version>4.23.0-SNAPSHOT</version>
+ <version>4.24.0-SNAPSHOT</version>
<relativePath>../../local-build/local-build-parent/</relativePath>
</parent>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.examples</artifactId>
- <version>3.107.100-SNAPSHOT</version>
+ <version>3.107.200-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/browser-content.html b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/browser-content.html
index bcb8288efc..3fb059c6b3 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/browser-content.html
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/browser-content.html
@@ -22,7 +22,7 @@ and more, check out <a href="http://www.eclipse.org/swt/">http://www.eclipse.org
<h3>Eclipse Downloads Page</h3>
<p>To download the latest Integration Build of eclipse, go to:
-<a href="http://download.eclipse.org/eclipse/downloads/">http://download.eclipse.org/eclipse/downloads</a>.</p>
+<a href="https://download.eclipse.org/eclipse/downloads/">https://download.eclipse.org/eclipse/downloads</a>.</p>
<h3>Bug Reports and Feature Requests</h3>
<p>To report an SWT bug or request an SWT feature, go to:
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/imageanalyzer/ImageAnalyzer.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/imageanalyzer/ImageAnalyzer.java
index 1638aa6d44..326e3d0668 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/imageanalyzer/ImageAnalyzer.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/imageanalyzer/ImageAnalyzer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -205,7 +205,7 @@ public class ImageAnalyzer {
shell.setText(bundle.getString("Image_analyzer"));
// Hook resize and dispose listeners.
- shell.addControlListener(ControlListener.controlResizedAdapter(e-> resizeShell(e)));
+ shell.addControlListener(ControlListener.controlResizedAdapter(this::resizeShell));
shell.addShellListener(ShellListener.shellClosedAdapter(e -> {
animate = false; // stop any animation in progress
if (animateThread != null) {
@@ -833,7 +833,7 @@ public class ImageAnalyzer {
loader = new ImageLoader();
if (incremental) {
// Prepare to handle incremental events.
- loader.addImageLoaderListener(event -> incrementalDataLoaded(event));
+ loader.addImageLoaderListener(this::incrementalDataLoaded);
incrementalThreadStart();
}
// Read the new image(s) from the chosen file.
@@ -884,7 +884,7 @@ public class ImageAnalyzer {
loader = new ImageLoader();
if (incremental) {
// Prepare to handle incremental events.
- loader.addImageLoaderListener(event -> incrementalDataLoaded(event));
+ loader.addImageLoaderListener(this::incrementalDataLoaded);
incrementalThreadStart();
}
// Read the new image(s) from the chosen URL.
@@ -929,7 +929,7 @@ public class ImageAnalyzer {
// Synchronize so we don't try to remove when the vector is null.
synchronized (ImageAnalyzer.this) {
if (incrementalEvents != null) {
- if (incrementalEvents.size() > 0) {
+ if (!incrementalEvents.isEmpty()) {
ImageLoaderEvent event = incrementalEvents.remove(0);
if (image != null) image.dispose();
image = new Image(display, event.imageData);
@@ -1655,22 +1655,19 @@ public class ImageAnalyzer {
shell.setText(string);
if (imageDataArray.length > 1) {
- string = createMsg(bundle.getString("Type_index"),
- new Object[] {fileTypeString(imageData.type),
- Integer.valueOf(imageDataIndex + 1),
- Integer.valueOf(imageDataArray.length)});
+ string = createMsg(bundle.getString("Type_index"), fileTypeString(imageData.type),
+ Integer.valueOf(imageDataIndex + 1), Integer.valueOf(imageDataArray.length));
} else {
string = createMsg(bundle.getString("Type_string"), fileTypeString(imageData.type));
}
typeLabel.setText(string);
string = createMsg(bundle.getString("Size_value"),
- new Object[] {Integer.valueOf(imageData.width),
- Integer.valueOf(imageData.height)});
+ Integer.valueOf(imageData.width), Integer.valueOf(imageData.height));
sizeLabel.setText(string);
string = createMsg(bundle.getString("Depth_value"),
- new Object[] {Integer.valueOf(imageData.depth), Integer.valueOf(display.getDepth())});
+ Integer.valueOf(imageData.depth), Integer.valueOf(display.getDepth()));
depthLabel.setText(string);
string = createMsg(bundle.getString("Transparent_pixel_value"), pixelInfo(imageData.transparentPixel));
@@ -1680,27 +1677,25 @@ public class ImageAnalyzer {
timeToLoadLabel.setText(string);
string = createMsg(bundle.getString("Animation_size_value"),
- new Object[] {Integer.valueOf(loader.logicalScreenWidth),
- Integer.valueOf(loader.logicalScreenHeight)});
+ Integer.valueOf(loader.logicalScreenWidth), Integer.valueOf(loader.logicalScreenHeight));
screenSizeLabel.setText(string);
string = createMsg(bundle.getString("Background_pixel_value"), pixelInfo(loader.backgroundPixel));
backgroundPixelLabel.setText(string);
string = createMsg(bundle.getString("Image_location_value"),
- new Object[] {Integer.valueOf(imageData.x), Integer.valueOf(imageData.y)});
+ Integer.valueOf(imageData.x), Integer.valueOf(imageData.y));
locationLabel.setText(string);
string = createMsg(bundle.getString("Disposal_value"),
- new Object[] {Integer.valueOf(imageData.disposalMethod),
- disposalString(imageData.disposalMethod)});
+ Integer.valueOf(imageData.disposalMethod), disposalString(imageData.disposalMethod));
disposalMethodLabel.setText(string);
int delay = imageData.delayTime * 10;
int delayUsed = visibleDelay(delay);
if (delay != delayUsed) {
string = createMsg(bundle.getString("Delay_value"),
- new Object[] {Integer.valueOf(delay), Integer.valueOf(delayUsed)});
+ Integer.valueOf(delay), Integer.valueOf(delayUsed));
} else {
string = createMsg(bundle.getString("Delay_used"), Integer.valueOf(delay));
}
@@ -1722,17 +1717,17 @@ public class ImageAnalyzer {
string = createMsg(
bundle.getString("Pixel_data_value"),
- new Object[] {
Integer.valueOf(imageData.bytesPerLine),
Integer.valueOf(imageData.scanlinePad),
depthInfo(imageData.depth),
(imageData.alphaData != null && imageData.alphaData.length > 0) ?
- bundle.getString("Scroll_for_alpha") : "" });
+ bundle.getString("Scroll_for_alpha") : "");
dataLabel.setText(string);
String data = dataHexDump(dataText.getLineDelimiter());
dataText.setText(data);
+ ArrayList<StyleRange> ranges = new ArrayList<>();
// bold the first column all the way down
int index = 0;
while((index = data.indexOf(':', index+1)) != -1) {
@@ -1742,8 +1737,9 @@ public class ImageAnalyzer {
start = index - ALPHA_CHARS;
length = ALPHA_CHARS;
}
- dataText.setStyleRange(new StyleRange(start, length, dataText.getForeground(), dataText.getBackground(), SWT.BOLD));
+ ranges.add(new StyleRange(start, length, dataText.getForeground(), dataText.getBackground(), SWT.BOLD));
}
+ if(!ranges.isEmpty()) dataText.setStyleRanges(ranges.toArray(new StyleRange[0]));
statusLabel.setText("");
@@ -2083,7 +2079,7 @@ public class ImageAnalyzer {
*/
void showErrorDialog(String operation, String filename, Throwable e) {
MessageBox box = new MessageBox(shell, SWT.ICON_ERROR);
- String message = createMsg(bundle.getString("Error"), new String[] {operation, filename});
+ String message = createMsg(bundle.getString("Error"), operation, filename);
String errorMessage = "";
if (e != null) {
if (e instanceof SWTException) {
@@ -2168,16 +2164,13 @@ public class ImageAnalyzer {
Object[] args = {Integer.valueOf(depth), ""};
switch (depth) {
case 1:
- args[1] = createMsg(bundle.getString("Multi_pixels"),
- new Object[] {Integer.valueOf(8), " [01234567]"});
+ args[1] = createMsg(bundle.getString("Multi_pixels"), Integer.valueOf(8), " [01234567]");
break;
case 2:
- args[1] = createMsg(bundle.getString("Multi_pixels"),
- new Object[] {Integer.valueOf(4), "[00112233]"});
+ args[1] = createMsg(bundle.getString("Multi_pixels"), Integer.valueOf(4), "[00112233]");
break;
case 4:
- args[1] = createMsg(bundle.getString("Multi_pixels"),
- new Object[] {Integer.valueOf(2), "[00001111]"});
+ args[1] = createMsg(bundle.getString("Multi_pixels"), Integer.valueOf(2), "[00001111]");
break;
case 8:
args[1] = bundle.getString("One_byte");
@@ -2353,13 +2346,9 @@ public class ImageAnalyzer {
compressionRatioLabel.setEnabled(false);
}
- static String createMsg(String msg, Object[] args) {
+ static String createMsg(String msg, Object... args) {
MessageFormat formatter = new MessageFormat(msg);
return formatter.format(args);
}
- static String createMsg(String msg, Object arg) {
- MessageFormat formatter = new MessageFormat(msg);
- return formatter.format(new Object[]{arg});
- }
}
diff --git a/examples/org.eclipse.swt.snippets/previews/Snippet379.png b/examples/org.eclipse.swt.snippets/previews/Snippet379.png
new file mode 100644
index 0000000000..ee1cc11fbb
--- /dev/null
+++ b/examples/org.eclipse.swt.snippets/previews/Snippet379.png
Binary files differ
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet154.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet154.java
index 3b53f20a1b..cc37286975 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet154.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet154.java
@@ -54,7 +54,7 @@ public class Snippet154 {
/* Create and setting up frame */
Frame frame = SWT_AWT.new_Frame(composite);
- Panel panel = new Panel(new BorderLayout()) {
+ Panel panel = new Panel(new java.awt.BorderLayout()) {
@Override
public void update(java.awt.Graphics g) {
/* Do not erase the background */
@@ -84,7 +84,7 @@ public class Snippet154 {
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.createDefaultColumnsFromModel();
JScrollPane scrollPane = new JScrollPane(table);
- contentPane.setLayout(new BorderLayout());
+ contentPane.setLayout(new java.awt.BorderLayout());
contentPane.add(scrollPane);
shell.open();
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet246.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet246.java
index a8eb74443c..331228deac 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet246.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet246.java
@@ -21,32 +21,51 @@ package org.eclipse.swt.snippets;
*/
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
public class Snippet246 {
+ static Display display;
public static void main(String[] args) {
- Display display = new Display();
- Font font = new Font(display, "Comic Sans MS", 24, SWT.BOLD);
- Image image = new Image(display, 87, 48);
+ display = new Display();
+ Shell shell = new Shell(display);
+ shell.setText("Snippet 246");
+ GridLayout layout = new GridLayout(2, false);
+ shell.setLayout(layout);
+ createImage();
+
+ String executionPath = System.getProperty("user.dir");
+ Label label = new Label(shell, SWT.WRAP);
+ label.setText("File created as: " + executionPath.replace("\\", "/")+"/swt.png");
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+ private static void createImage() {
+ Font font = new Font(display, "Comic Sans MS", 48, SWT.BOLD);
+ Image image = new Image(display, 174, 96);
GC gc = new GC(image);
gc.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
gc.fillRectangle(image.getBounds());
gc.setFont(font);
gc.setForeground(display.getSystemColor(SWT.COLOR_RED));
- gc.drawString("S", 3, 0);
+ gc.drawString("S", 3, 10);
gc.setForeground(display.getSystemColor(SWT.COLOR_GREEN));
- gc.drawString("W", 25, 0);
+ gc.drawString("W", 50, 10);
gc.setForeground(display.getSystemColor(SWT.COLOR_BLUE));
- gc.drawString("T", 62, 0);
+ gc.drawString("T", 124, 10);
gc.dispose();
ImageLoader loader = new ImageLoader();
- loader.data = new ImageData[] {image.getImageData()};
+ loader.data = new ImageData[] { image.getImageData() };
loader.save("swt.png", SWT.IMAGE_PNG);
-
image.dispose();
font.dispose();
- display.dispose();
}
}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet337.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet337.java
index 669bef4745..357afaff54 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet337.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet337.java
@@ -64,7 +64,7 @@ public static void main(String args[]) {
mainPanel.add(new JTextField("a JTextField"));
mainPanel.add(launchBrowserButton);
- mainFrame.getContentPane().add(mainPanel, BorderLayout.CENTER);
+ mainFrame.getContentPane().add(mainPanel, java.awt.BorderLayout.CENTER);
mainFrame.pack();
mainFrame.setVisible(true);
});
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet379.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet379.java
new file mode 100644
index 0000000000..1a865ce39b
--- /dev/null
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet379.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2021 Christoph Läubrich and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Christoph Läubrich - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.snippets;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * This snippet demonstrates the usage of {@link BorderLayout}
+ */
+public class Snippet379 {
+
+ public static void main(String[] args) {
+
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setText("Border Layout Snippet");
+ BorderLayout layout = new BorderLayout();
+ layout.marginHeight = 16;
+ layout.marginWidth = 8;
+ layout.spacing = 4;
+ layout.controlSpacing = 2;
+ layout.type = SWT.VERTICAL;
+ shell.setBackground(display.getSystemColor(SWT.COLOR_CYAN));
+ shell.setLayout(layout);
+ shell.setSize(800, 600);
+ region(new Button(shell, SWT.PUSH), SWT.TOP).setText("North 1");
+ region(new Button(shell, SWT.PUSH), SWT.TOP).setText("North 2");
+ region(new Button(shell, SWT.PUSH), SWT.BOTTOM).setText("South 1");
+ region(new Button(shell, SWT.PUSH), SWT.BOTTOM).setText("South 2");
+ region(new Button(shell, SWT.PUSH), SWT.LEFT).setText("West 1");
+ region(new Button(shell, SWT.PUSH), SWT.LEFT).setText("West 2");
+ region(new Button(shell, SWT.PUSH), SWT.RIGHT).setText("East 1");
+ region(new Button(shell, SWT.PUSH), SWT.RIGHT).setText("East 2");
+ new Text(shell, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL).setText("Center 1");
+ new Text(shell, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL).setText("Center 2");
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ display.dispose();
+ }
+
+ private static <C extends Control> C region(C control, int region) {
+ control.setLayoutData(new BorderData(region));
+ return control;
+ }
+
+}

Back to the top