Skip to content

Commit a6ec55b

Browse files
committed
Make unsaved changes indicator the default on tabs
Flip SHOW_DIRTY_INDICATOR_ON_TABS_DEFAULT to true so the dirty indicator introduced in 4.40 becomes opt-out, gathering broader feedback during this development cycle.
1 parent ea2f35b commit a6ec55b

4 files changed

Lines changed: 92 additions & 52 deletions

File tree

bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/CTabRendering.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,16 @@ public class CTabRendering extends CTabFolderRenderer implements ICTabRendering,
8080
* A named preference for setting CTabFolder's to be rendered with dirty
8181
* indicator overlay on close button
8282
* <p>
83-
* The default value for this preference is: <code>false</code> (do not show
84-
* dirty indicator)
83+
* The default value for this preference is: <code>true</code> (show dirty
84+
* indicator)
8585
* </p>
8686
*/
8787
public static final String SHOW_DIRTY_INDICATOR_ON_TABS = "SHOW_DIRTY_INDICATOR_ON_TABS"; //$NON-NLS-1$
8888

8989
/**
9090
* Default value for "dirty indicator" preference for tabs
9191
*/
92-
public static final boolean SHOW_DIRTY_INDICATOR_ON_TABS_DEFAULT = false;
92+
public static final boolean SHOW_DIRTY_INDICATOR_ON_TABS_DEFAULT = true;
9393

9494
private static int MIN_VIEW_CHARS = 1;
9595
private static int MAX_VIEW_CHARS = Integer.MAX_VALUE;

tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/workbench/MPartTest.java

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import static org.junit.jupiter.api.Assertions.assertNull;
2222

2323
import jakarta.inject.Inject;
24+
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
25+
import org.eclipse.core.runtime.preferences.InstanceScope;
2426
import org.eclipse.e4.core.contexts.IEclipseContext;
2527
import org.eclipse.e4.ui.model.application.MApplication;
2628
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
@@ -30,6 +32,7 @@
3032
import org.eclipse.e4.ui.tests.rules.WorkbenchContextExtension;
3133
import org.eclipse.e4.ui.workbench.IPresentationEngine;
3234
import org.eclipse.e4.ui.workbench.modeling.EModelService;
35+
import org.eclipse.e4.ui.workbench.renderers.swt.CTabRendering;
3336
import org.eclipse.swt.custom.CTabFolder;
3437
import org.eclipse.swt.custom.CTabItem;
3538
import org.junit.jupiter.api.Test;
@@ -191,34 +194,45 @@ public void testMPart_getContext() {
191194

192195
@Test
193196
public void testMPartBug369866() {
194-
final MWindow window = createWindowWithOneView("Part");
195-
196-
application.getChildren().add(window);
197-
contextRule.createAndRunWorkbench(window);
198-
199-
MPartSashContainer container = (MPartSashContainer) window.getChildren().get(0);
200-
MPartStack stack = (MPartStack) container.getChildren().get(0);
201-
MPart part = (MPart) stack.getChildren().get(0);
202-
203-
CTabFolder folder = (CTabFolder) stack.getWidget();
204-
CTabItem item = folder.getItem(0);
205-
206-
// bug 369866 has a StringIOOBE from toggling the dirty flag with an
207-
// empty part name
208-
assertFalse(part.isDirty());
209-
assertEquals("Part", item.getText());
210-
211-
part.setDirty(true);
212-
assertEquals("*Part", item.getText());
213-
214-
part.setLabel("");
215-
assertEquals("*", item.getText());
216-
217-
part.setDirty(false);
218-
assertEquals("", item.getText());
219-
220-
part.setDirty(true);
221-
assertEquals("*", item.getText());
197+
// This test verifies the textual '*' dirty prefix, which is only used
198+
// when the graphical dirty indicator is disabled.
199+
IEclipsePreferences prefs = InstanceScope.INSTANCE
200+
.getNode(CTabRendering.PREF_QUALIFIER_ECLIPSE_E4_UI_WORKBENCH_RENDERERS_SWT);
201+
boolean previous = prefs.getBoolean(CTabRendering.SHOW_DIRTY_INDICATOR_ON_TABS,
202+
CTabRendering.SHOW_DIRTY_INDICATOR_ON_TABS_DEFAULT);
203+
prefs.putBoolean(CTabRendering.SHOW_DIRTY_INDICATOR_ON_TABS, false);
204+
try {
205+
final MWindow window = createWindowWithOneView("Part");
206+
207+
application.getChildren().add(window);
208+
contextRule.createAndRunWorkbench(window);
209+
210+
MPartSashContainer container = (MPartSashContainer) window.getChildren().get(0);
211+
MPartStack stack = (MPartStack) container.getChildren().get(0);
212+
MPart part = (MPart) stack.getChildren().get(0);
213+
214+
CTabFolder folder = (CTabFolder) stack.getWidget();
215+
CTabItem item = folder.getItem(0);
216+
217+
// bug 369866 has a StringIOOBE from toggling the dirty flag with an
218+
// empty part name
219+
assertFalse(part.isDirty());
220+
assertEquals("Part", item.getText());
221+
222+
part.setDirty(true);
223+
assertEquals("*Part", item.getText());
224+
225+
part.setLabel("");
226+
assertEquals("*", item.getText());
227+
228+
part.setDirty(false);
229+
assertEquals("", item.getText());
230+
231+
part.setDirty(true);
232+
assertEquals("*", item.getText());
233+
} finally {
234+
prefs.putBoolean(CTabRendering.SHOW_DIRTY_INDICATOR_ON_TABS, previous);
235+
}
222236
}
223237

224238
private MWindow createWindowWithOneView(String partName) {

tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/workbench/MSaveablePartTest.java

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@
1919
import static org.junit.jupiter.api.Assertions.assertFalse;
2020

2121
import jakarta.inject.Inject;
22+
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
23+
import org.eclipse.core.runtime.preferences.InstanceScope;
2224
import org.eclipse.e4.ui.model.application.MApplication;
2325
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
2426
import org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainer;
2527
import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
2628
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
2729
import org.eclipse.e4.ui.tests.rules.WorkbenchContextExtension;
2830
import org.eclipse.e4.ui.workbench.modeling.EModelService;
31+
import org.eclipse.e4.ui.workbench.renderers.swt.CTabRendering;
2932
import org.eclipse.swt.custom.CTabFolder;
3033
import org.eclipse.swt.custom.CTabItem;
3134
import org.junit.jupiter.api.Test;
@@ -44,27 +47,38 @@ public class MSaveablePartTest {
4447

4548
@Test
4649
public void testCreateView() {
47-
final MWindow window = createWindowWithOneView("Part Name");
48-
49-
application.getChildren().add(window);
50-
contextRule.createAndRunWorkbench(window);
51-
52-
MPartSashContainer container = (MPartSashContainer) window
53-
.getChildren().get(0);
54-
MPartStack stack = (MPartStack) container.getChildren().get(0);
55-
MPart part = (MPart) stack.getChildren().get(0);
56-
57-
CTabFolder folder = (CTabFolder) stack.getWidget();
58-
CTabItem item = folder.getItem(0);
59-
assertEquals("Part Name", item.getText());
60-
61-
assertFalse(part.isDirty());
62-
63-
part.setDirty(true);
64-
assertEquals("*Part Name", item.getText());
65-
66-
part.setDirty(false);
67-
assertEquals("Part Name", item.getText());
50+
// This test verifies the textual '*' dirty prefix, which is only used
51+
// when the graphical dirty indicator is disabled.
52+
IEclipsePreferences prefs = InstanceScope.INSTANCE
53+
.getNode(CTabRendering.PREF_QUALIFIER_ECLIPSE_E4_UI_WORKBENCH_RENDERERS_SWT);
54+
boolean previous = prefs.getBoolean(CTabRendering.SHOW_DIRTY_INDICATOR_ON_TABS,
55+
CTabRendering.SHOW_DIRTY_INDICATOR_ON_TABS_DEFAULT);
56+
prefs.putBoolean(CTabRendering.SHOW_DIRTY_INDICATOR_ON_TABS, false);
57+
try {
58+
final MWindow window = createWindowWithOneView("Part Name");
59+
60+
application.getChildren().add(window);
61+
contextRule.createAndRunWorkbench(window);
62+
63+
MPartSashContainer container = (MPartSashContainer) window
64+
.getChildren().get(0);
65+
MPartStack stack = (MPartStack) container.getChildren().get(0);
66+
MPart part = (MPart) stack.getChildren().get(0);
67+
68+
CTabFolder folder = (CTabFolder) stack.getWidget();
69+
CTabItem item = folder.getItem(0);
70+
assertEquals("Part Name", item.getText());
71+
72+
assertFalse(part.isDirty());
73+
74+
part.setDirty(true);
75+
assertEquals("*Part Name", item.getText());
76+
77+
part.setDirty(false);
78+
assertEquals("Part Name", item.getText());
79+
} finally {
80+
prefs.putBoolean(CTabRendering.SHOW_DIRTY_INDICATOR_ON_TABS, previous);
81+
}
6882
}
6983

7084
private MWindow createWindowWithOneView(String partName) {

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/multieditor/MultiEditorTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
import org.eclipse.core.runtime.ILog;
3636
import org.eclipse.core.runtime.ILogListener;
3737
import org.eclipse.core.runtime.IStatus;
38+
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
39+
import org.eclipse.core.runtime.preferences.InstanceScope;
40+
import org.eclipse.e4.ui.workbench.renderers.swt.CTabRendering;
3841
import org.eclipse.jface.action.IContributionItem;
3942
import org.eclipse.jface.action.ToolBarContributionItem;
4043
import org.eclipse.jface.action.ToolBarManager;
@@ -233,6 +236,14 @@ public void testDirty() throws Throwable {
233236
MockEditorPart editorA = (MockEditorPart) innerEditors[0];
234237
MockEditorPart editorB = (MockEditorPart) innerEditors[0];
235238

239+
// This test verifies the textual '*' dirty prefix, which is only used
240+
// when the graphical dirty indicator is disabled.
241+
IEclipsePreferences prefs = InstanceScope.INSTANCE
242+
.getNode(CTabRendering.PREF_QUALIFIER_ECLIPSE_E4_UI_WORKBENCH_RENDERERS_SWT);
243+
boolean previous = prefs.getBoolean(CTabRendering.SHOW_DIRTY_INDICATOR_ON_TABS,
244+
CTabRendering.SHOW_DIRTY_INDICATOR_ON_TABS_DEFAULT);
245+
prefs.putBoolean(CTabRendering.SHOW_DIRTY_INDICATOR_ON_TABS, false);
246+
236247
char firstChar = item.getText().charAt(0);
237248
assertFalse(firstChar == '*');
238249

@@ -249,6 +260,7 @@ public void testDirty() throws Throwable {
249260
editorB.setDirty(false);
250261
assertEquals(firstChar, item.getText().charAt(0));
251262
} finally {
263+
prefs.putBoolean(CTabRendering.SHOW_DIRTY_INDICATOR_ON_TABS, previous);
252264
page.closeAllEditors(false);
253265
}
254266
}

0 commit comments

Comments
 (0)