8585
8686@ SuppressWarnings ("restriction" )
8787public class LifecycleMappingsViewer {
88+
89+ /**
90+ * Uninteresting lifecycle phase
91+ */
92+ private static final String UNINTERESTING = "uninteresting" ; //$NON-NLS-1$
93+
94+ /**
95+ * Maven plugin lifecycle source
96+ */
97+ private static final String MAVEN_PLUGIN = "maven-plugin" ; //$NON-NLS-1$
98+
99+ /**
100+ * Pom lifecycle source
101+ */
102+ private static final String POM = "pom" ; //$NON-NLS-1$
103+
104+ /**
105+ * Eclipse extension lifecycle source
106+ */
107+ private static final String EXTENSION = "extension" ; //$NON-NLS-1$
108+
109+ /**
110+ * Default execution source
111+ */
112+ private static final String DEFAULT = "default" ; //$NON-NLS-1$
113+
114+ /**
115+ * Unknown lifecycle source
116+ */
117+ private static final String UNKNOWN = "unknown" ; //$NON-NLS-1$
118+
88119 /*package*/ TreeViewer mappingsTreeViewer ;
89120
90121 /*package*/ boolean showPhases = false ;
@@ -102,7 +133,7 @@ public class LifecycleMappingsViewer {
102133 private IProject project ;
103134
104135 void updateMappingsTreeViewer () {
105- if (mappingsTreeViewer == null ) {
136+ if (mappingsTreeViewer == null || mappingsTreeViewer . getControl (). isDisposed () ) {
106137 return ;
107138 }
108139 mappingsTreeViewer .refresh ();
@@ -444,52 +475,56 @@ String getSourcelabel(MojoExecutionKey execution, List<IPluginExecutionMetadata>
444475 LinkedHashSet <String > sources = new LinkedHashSet <>();
445476 if (mappings != null && !mappings .isEmpty ()) {
446477 for (IPluginExecutionMetadata mapping : mappings ) {
447- LifecycleMappingMetadataSource metadata = ((PluginExecutionMetadata ) mapping ).getSource ();
448- if (metadata != null ) {
449- Object source = metadata .getSource ();
450- if (source instanceof String s ) {
451- sources .add (s );
452- } else if (source instanceof Artifact artifact ) {
453- sources .add (getSourceLabel (artifact , detailed ));
454- } else if (source instanceof MavenProject mavenProject ) {
455- sources .add (getSourceLabel (mavenProject , detailed ));
456- } else if (source instanceof Bundle bundle ) {
457- sources .add (getSourceLabel (bundle , detailed ));
478+ if (mapping instanceof PluginExecutionMetadata metadata ) {
479+ LifecycleMappingMetadataSource metadataSource = metadata .getSource ();
480+ if (metadataSource == null ) {
481+ sources .add (UNKNOWN );
458482 } else {
459- sources .add ("unknown" ); //$NON-NLS-1$
483+ Object source = metadataSource .getSource ();
484+ if (source instanceof String s ) {
485+ sources .add (s );
486+ } else if (source instanceof Artifact artifact ) {
487+ sources .add (getSourceLabel (artifact , detailed ));
488+ } else if (source instanceof MavenProject mavenProject ) {
489+ sources .add (getSourceLabel (mavenProject , detailed ));
490+ } else if (source instanceof Bundle bundle ) {
491+ sources .add (getSourceLabel (bundle , detailed ));
492+ } else {
493+ sources .add (UNKNOWN ); //$NON-NLS-1$
494+ }
460495 }
461496 } else if (mapping instanceof DefaultPluginExecutionMetadata ) {
462- sources .add ("default" ); //$NON-NLS-1$
497+ sources .add (DEFAULT ); //$NON-NLS-1$
463498 } else {
464- sources .add ("unknown" ); //$NON-NLS-1$
499+ sources .add (UNKNOWN ); //$NON-NLS-1$
465500 }
466501 }
467502 } else {
468503 if (!LifecycleMappingFactory .isInterestingPhase (execution .lifecyclePhase ())) {
469- sources .add ("uninteresting" ); //$NON-NLS-1$
504+ sources .add (UNINTERESTING ); //$NON-NLS-1$
470505 }
471506 }
472507 return String .join (", " , sources );
473508 }
474509
475510 private String getSourceLabel (Bundle bundle , boolean detailed ) {
476- StringBuilder sb = new StringBuilder ("extension" ); //$NON-NLS-1$
511+ StringBuilder sb = new StringBuilder (EXTENSION ); //$NON-NLS-1$
477512 if (detailed ) {
478513 sb .append ('(' ).append (bundle .getSymbolicName ()).append ('_' ).append (bundle .getVersion ()).append (')' );
479514 }
480515 return sb .toString ();
481516 }
482517
483518 private String getSourceLabel (MavenProject project , boolean detailed ) {
484- StringBuilder sb = new StringBuilder ("pom" ); //$NON-NLS-1$
519+ StringBuilder sb = new StringBuilder (POM ); //$NON-NLS-1$
485520 if (detailed ) {
486521 sb .append ('(' ).append (project .toString ()).append (')' );
487522 }
488523 return sb .toString ();
489524 }
490525
491526 private String getSourceLabel (Artifact plugin , boolean detailed ) {
492- StringBuilder sb = new StringBuilder ("maven-plugin" ); //$NON-NLS-1$
527+ StringBuilder sb = new StringBuilder (MAVEN_PLUGIN ); //$NON-NLS-1$
493528 if (detailed ) {
494529 sb .append ('(' ).append (plugin .toString ()).append (')' );
495530 }
0 commit comments