Skip to content

Commit 168689f

Browse files
committed
Reduce noise for traced e4 model data
This reduces amount of data printed out if `/trace/focus` flag for `org.eclipse.e4.ui.workbench.swt` is set (and of course for all other e4 model related tracing). Should help to see what's going on in #2839
1 parent 7f9ec57 commit 168689f

File tree

3 files changed

+68
-34
lines changed

3 files changed

+68
-34
lines changed

bundles/org.eclipse.e4.ui.model.workbench/src/org/eclipse/e4/ui/model/application/ui/basic/impl/PartImpl.java

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,20 +1350,34 @@ public String toString() {
13501350
result.append(object);
13511351
result.append(", context: "); //$NON-NLS-1$
13521352
result.append(context);
1353-
result.append(", variables: "); //$NON-NLS-1$
1354-
result.append(variables);
1355-
result.append(", label: "); //$NON-NLS-1$
1356-
result.append(label);
1357-
result.append(", iconURI: "); //$NON-NLS-1$
1358-
result.append(iconURI);
1359-
result.append(", tooltip: "); //$NON-NLS-1$
1360-
result.append(tooltip);
1361-
result.append(", dirty: "); //$NON-NLS-1$
1362-
result.append(dirty);
1363-
result.append(", closeable: "); //$NON-NLS-1$
1364-
result.append(closeable);
1365-
result.append(", description: "); //$NON-NLS-1$
1366-
result.append(description);
1353+
if (variables != null && !variables.isEmpty()) {
1354+
result.append(", variables: "); //$NON-NLS-1$
1355+
result.append(variables);
1356+
}
1357+
if (label != null) {
1358+
result.append(", label: "); //$NON-NLS-1$
1359+
result.append(label);
1360+
}
1361+
if (iconURI != null) {
1362+
result.append(", iconURI: "); //$NON-NLS-1$
1363+
result.append(iconURI);
1364+
}
1365+
if (tooltip != null && !tooltip.isBlank()) {
1366+
result.append(", tooltip: "); //$NON-NLS-1$
1367+
result.append(tooltip);
1368+
}
1369+
if (dirty) {
1370+
result.append(", dirty: "); //$NON-NLS-1$
1371+
result.append(dirty);
1372+
}
1373+
if (closeable) {
1374+
result.append(", closeable: "); //$NON-NLS-1$
1375+
result.append(closeable);
1376+
}
1377+
if (description != null) {
1378+
result.append(", description: "); //$NON-NLS-1$
1379+
result.append(description);
1380+
}
13671381
result.append(')');
13681382
return result.toString();
13691383
}

bundles/org.eclipse.e4.ui.model.workbench/src/org/eclipse/e4/ui/model/application/ui/impl/UIElementImpl.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -862,18 +862,26 @@ public String toString() {
862862
StringBuilder result = new StringBuilder(super.toString());
863863
result.append(" (widget: "); //$NON-NLS-1$
864864
result.append(widget);
865-
result.append(", renderer: "); //$NON-NLS-1$
866-
result.append(renderer);
867-
result.append(", toBeRendered: "); //$NON-NLS-1$
868-
result.append(toBeRendered);
869-
result.append(", onTop: "); //$NON-NLS-1$
870-
result.append(onTop);
871-
result.append(", visible: "); //$NON-NLS-1$
872-
result.append(visible);
873-
result.append(", containerData: "); //$NON-NLS-1$
874-
result.append(containerData);
875-
result.append(", accessibilityPhrase: "); //$NON-NLS-1$
876-
result.append(accessibilityPhrase);
865+
if (toBeRendered) {
866+
result.append(", toBeRendered: "); //$NON-NLS-1$
867+
result.append(toBeRendered);
868+
}
869+
if (onTop) {
870+
result.append(", onTop: "); //$NON-NLS-1$
871+
result.append(onTop);
872+
}
873+
if (visible) {
874+
result.append(", visible: "); //$NON-NLS-1$
875+
result.append(visible);
876+
}
877+
if (containerData != null) {
878+
result.append(", containerData: "); //$NON-NLS-1$
879+
result.append(containerData);
880+
}
881+
if (accessibilityPhrase != null) {
882+
result.append(", accessibilityPhrase: "); //$NON-NLS-1$
883+
result.append(accessibilityPhrase);
884+
}
877885
result.append(')');
878886
return result.toString();
879887
}

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/e4/compatibility/CompatibilityPart.java

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import jakarta.annotation.PostConstruct;
2222
import jakarta.annotation.PreDestroy;
2323
import jakarta.inject.Inject;
24+
import java.util.List;
25+
import java.util.Map;
2426
import org.eclipse.core.runtime.Assert;
2527
import org.eclipse.core.runtime.IStatus;
2628
import org.eclipse.core.runtime.Status;
@@ -487,10 +489,16 @@ public String toString() {
487489
if (part != null) {
488490
builder.append("partId="); //$NON-NLS-1$
489491
builder.append(part.getElementId());
490-
builder.append(", properties="); //$NON-NLS-1$
491-
builder.append(part.getProperties());
492-
builder.append(", tags="); //$NON-NLS-1$
493-
builder.append(part.getTags());
492+
Map<String, String> properties = part.getProperties();
493+
if (properties != null && !properties.isEmpty()) {
494+
builder.append(", properties="); //$NON-NLS-1$
495+
builder.append(properties);
496+
}
497+
List<String> tags = part.getTags();
498+
if (tags != null && !tags.isEmpty()) {
499+
builder.append(", tags="); //$NON-NLS-1$
500+
builder.append(tags);
501+
}
494502
}
495503
if (wrapped != null) {
496504
builder.append(", wrapped="); //$NON-NLS-1$
@@ -500,10 +508,14 @@ public String toString() {
500508
builder.append(", legacyPart="); //$NON-NLS-1$
501509
builder.append(legacyPart.getClass());
502510
}
503-
builder.append(", beingDisposed="); //$NON-NLS-1$
504-
builder.append(beingDisposed);
505-
builder.append(", alreadyDisposed="); //$NON-NLS-1$
506-
builder.append(alreadyDisposed);
511+
if (beingDisposed) {
512+
builder.append(", beingDisposed="); //$NON-NLS-1$
513+
builder.append(beingDisposed);
514+
}
515+
if (alreadyDisposed) {
516+
builder.append(", alreadyDisposed="); //$NON-NLS-1$
517+
builder.append(alreadyDisposed);
518+
}
507519
builder.append("]"); //$NON-NLS-1$
508520
return builder.toString();
509521
}

0 commit comments

Comments
 (0)