Bug 578314 - Expand All/Collapse All button should be disabled when
target is getting resolved

Change-Id: I9a59dba632b0b7ae81684cbac78973704b321c83
Signed-off-by: Vikas Chandra <Vikas.Chandra@in.ibm.com>
Reviewed-on: https://git.eclipse.org/r/c/pde/eclipse.pde.ui/+/189892
Tested-by: PDE Bot <pde-bot@eclipse.org>
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/targetdefinition/TargetEditor.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/targetdefinition/TargetEditor.java
index 708d30c..4564e99 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/targetdefinition/TargetEditor.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/targetdefinition/TargetEditor.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2005, 2021 IBM Corporation and others.
+ * Copyright (c) 2005, 2022 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -587,6 +587,7 @@
 				}
 				if (fLocationTree != null) {
 					fLocationTree.setInput(getTarget());
+					fLocationTree.setExpandCollapseState(false);
 				}
 				Job.getJobManager().cancel(getJobFamily());
 
@@ -632,6 +633,7 @@
 								}
 								if (fLocationTree != null) {
 									fLocationTree.setInput(getTarget());
+									fLocationTree.setExpandCollapseState(true);
 								}
 								return Status.OK_STATUS;
 							}
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetLocationsGroup.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetLocationsGroup.java
index 380d33b..4442f83 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetLocationsGroup.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetLocationsGroup.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2021 IBM Corporation and others.
+ * Copyright (c) 2009, 2022 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -360,7 +360,7 @@
 
 		fExpandCollapseButton.addSelectionListener(widgetSelectedAdapter(e -> toggleCollapse()));
 		fExpandCollapseButton.setLayoutData(new GridData());
-		fExpandCollapseButton.setEnabled(true);
+		fExpandCollapseButton.setEnabled(false);
 		SWTFactory.setButtonDimensionHint(fExpandCollapseButton);
 
 		fShowContentButton.addSelectionListener(widgetSelectedAdapter(e -> {
@@ -604,4 +604,9 @@
 		return status;
 	}
 
+	public void setExpandCollapseState(boolean b) {
+		if (fExpandCollapseButton != null)
+			fExpandCollapseButton.setEnabled(b);
+	}
+
 }