Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiraj Modi2021-03-15 15:57:55 +0000
committerNiraj Modi2021-03-19 11:10:25 +0000
commitfa3e4c2491448b1f094b8d800910bf98220f43cb (patch)
tree84e0b632d12f762e38fcc0306d2498a182672e94
parentf27a2e6f55ee2867f81c7b06b392fb979a245e78 (diff)
downloadeclipse.platform.swt-fa3e4c2491448b1f094b8d800910bf98220f43cb.tar.gz
eclipse.platform.swt-fa3e4c2491448b1f094b8d800910bf98220f43cb.tar.xz
eclipse.platform.swt-fa3e4c2491448b1f094b8d800910bf98220f43cb.zip
Bug 571966 - Improve Snippet314 behavior to show visual clues if editor
is in modified state - Prepending "* " to the window title and making behavior some-what similar to 'notepad' Change-Id: I318bc750b26fc417531e4f4230cb5a078e31cf53 Signed-off-by: Niraj Modi <niraj.modi@in.ibm.com>
-rw-r--r--examples/org.eclipse.swt.snippets/META-INF/MANIFEST.MF2
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet314.java18
2 files changed, 16 insertions, 4 deletions
diff --git a/examples/org.eclipse.swt.snippets/META-INF/MANIFEST.MF b/examples/org.eclipse.swt.snippets/META-INF/MANIFEST.MF
index fd0d4577eb..7b4989e220 100644
--- a/examples/org.eclipse.swt.snippets/META-INF/MANIFEST.MF
+++ b/examples/org.eclipse.swt.snippets/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.swt.snippets
-Bundle-Version: 3.2.200
+Bundle-Version: 3.2.300
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Require-Bundle: org.eclipse.swt
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet314.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet314.java
index addd2a7acf..fae463ce6a 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet314.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet314.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2016 IBM Corporation and others.
+ * Copyright (c) 2009, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -39,12 +39,24 @@ public class Snippet314 {
MenuItem saveItem = new MenuItem (fileMenu, SWT.PUSH);
saveItem.setText ("&Save\tCtrl+S");
saveItem.setAccelerator (SWT.MOD1 + 'S');
- saveItem.addListener (SWT.Selection, e -> shell.setModified (false));
+ saveItem.addListener (SWT.Selection, e -> {
+ shell.setModified (false);
+ // Update Shell title, to hint that it's not in modified state.
+ if(shell.getText().startsWith("*")) {
+ shell.setText (shell.getText().substring(1));
+ }
+ });
MenuItem exitItem = new MenuItem (fileMenu, SWT.PUSH);
exitItem.setText ("Exit");
exitItem.addListener (SWT.Selection, e -> shell.close ());
Text text = new Text (shell, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- text.addListener (SWT.Modify, e -> shell.setModified (true));
+ text.addListener (SWT.Modify, e -> {
+ shell.setModified (true);
+ // Update Shell title, to hint that it's in modified state.
+ if(!shell.getText().startsWith("*")) {
+ shell.setText ("*" + shell.getText());
+ }
+ });
shell.addListener (SWT.Close, e -> {
if (shell.getModified()) {
MessageBox box = new MessageBox (shell, SWT.PRIMARY_MODAL | SWT.OK | SWT.CANCEL);

Back to the top