Skip to content

Commit 8d289e0

Browse files
committed
Show dedicated indicator in tabs of dirty parts
Tabs render dirty parts by showing a `*` in front of the tab name (e.g., in front of the file name. This information is hard to see by developers. This change introduces a graphical indicator on the close button to highlight dirty (unsaved) changes.
1 parent 5a5032c commit 8d289e0

File tree

1 file changed

+5
-10
lines changed
  • bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt

1 file changed

+5
-10
lines changed

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

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,8 @@
4848
import org.eclipse.e4.ui.internal.workbench.renderers.swt.SWTRenderersMessages;
4949
import org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer;
5050
import org.eclipse.e4.ui.internal.workbench.swt.CSSConstants;
51-
import org.eclipse.e4.ui.model.application.ui.MDirtyable;
5251
import org.eclipse.e4.ui.model.application.ui.MElementContainer;
5352
import org.eclipse.e4.ui.model.application.ui.MUIElement;
54-
import org.eclipse.e4.ui.model.application.ui.MUILabel;
5553
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
5654
import org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder;
5755
import org.eclipse.e4.ui.model.application.ui.basic.MCompositePart;
@@ -643,10 +641,11 @@ protected void updateTab(CTabItem cti, MPart part, String attName, Object newVal
643641
case UIEvents.UILabel.LABEL:
644642
case UIEvents.UILabel.LOCALIZED_LABEL:
645643
String newName = (String) newValue;
646-
cti.setText(getLabel(part, newName));
644+
cti.setText(getLabel(newName));
647645
break;
648646
case UIEvents.Dirtyable.DIRTY:
649-
cti.setText(getLabel(part, part.getLocalizedLabel()));
647+
cti.setText(getLabel(part.getLocalizedLabel()));
648+
cti.setShowDirty(part.isDirty());
650649
break;
651650
case UIEvents.UILabel.ICONURI:
652651
changePartTabImage(part, cti);
@@ -676,16 +675,12 @@ public void contextDisposed() {
676675
super.contextDisposed(eventBroker);
677676
}
678677

679-
private String getLabel(MUILabel itemPart, String newName) {
678+
private String getLabel(String newName) {
680679
if (newName == null) {
681680
newName = ""; //$NON-NLS-1$
682681
} else {
683682
newName = LegacyActionTools.escapeMnemonics(newName);
684683
}
685-
686-
if (itemPart instanceof MDirtyable && ((MDirtyable) itemPart).isDirty()) {
687-
newName = '*' + newName;
688-
}
689684
return newName;
690685
}
691686

@@ -976,7 +971,7 @@ else if (element instanceof MPlaceholder) {
976971
tabItem = new CTabItem(tabFolder, createFlags, index);
977972

978973
tabItem.setData(OWNING_ME, element);
979-
tabItem.setText(getLabel(part, part.getLocalizedLabel()));
974+
tabItem.setText(getLabel(part.getLocalizedLabel()));
980975
tabItem.setImage(getImage(part));
981976

982977
String toolTip = getToolTip(part);

0 commit comments

Comments
 (0)