Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Keppler2018-06-01 17:15:35 +0000
committerKarsten Thoms2018-07-15 08:39:28 +0000
commit8c924456a516ce49087a542b155ee70c8d76ae38 (patch)
tree0544160509a60ea260a758bcd36d22f796023964
parenta4f45dcc9c6d0293ec62213108f4dcbe02b5cc21 (diff)
downloadeclipse.platform.debug-8c924456a516ce49087a542b155ee70c8d76ae38.tar.gz
eclipse.platform.debug-8c924456a516ce49087a542b155ee70c8d76ae38.tar.xz
eclipse.platform.debug-8c924456a516ce49087a542b155ee70c8d76ae38.zip
Since a typical Eclipse user will have a lot of empty launch config types (i.e. with no defined launch configs or prototypes), which we can hide from the export launch config dialog. Had to move some private members from the nested class to the top level class to use them in both. Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de> Also-by: Karsten Thoms <karsten.thoms@itemis.de> Change-Id: I04a0e52b5c9d4427e5221591b33ea0aaf67488e7 Bug:535151
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizardPage.java31
1 files changed, 26 insertions, 5 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizardPage.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizardPage.java
index e55ada4c9..c54b38fb5 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizardPage.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizardPage.java
@@ -19,6 +19,7 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import org.eclipse.core.filesystem.EFS;
@@ -76,19 +77,19 @@ import com.ibm.icu.text.MessageFormat;
*/
public class ExportLaunchConfigurationsWizardPage extends WizardPage {
+ private ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager();
+
/**
* The content provider for the tree viewer
* @since 3.4.0
*/
class ConfigContentProvider implements ITreeContentProvider {
- ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager();
-
@Override
public Object[] getChildren(Object parentElement) {
if(parentElement instanceof ILaunchConfigurationType) {
try {
- return lm.getLaunchConfigurations((ILaunchConfigurationType) parentElement, ILaunchConfiguration.CONFIGURATION | ILaunchConfiguration.PROTOTYPE);
+ return getConfigurationTypeChildren((ILaunchConfigurationType) parentElement);
}
catch (Exception e) {
DebugUIPlugin.logErrorMessage(e.getMessage());
@@ -96,6 +97,7 @@ public class ExportLaunchConfigurationsWizardPage extends WizardPage {
}
return null;
}
+
@Override
public Object getParent(Object element) {
if(element instanceof ILaunchConfiguration) {
@@ -113,7 +115,7 @@ public class ExportLaunchConfigurationsWizardPage extends WizardPage {
}
@Override
public Object[] getElements(Object inputElement) {
- return lm.getLaunchConfigurationTypes();
+ return getUsedLaunchConfigurationTypes();
}
}
private String OVERWRITE = "overwrite"; //$NON-NLS-1$
@@ -169,7 +171,7 @@ public class ExportLaunchConfigurationsWizardPage extends WizardPage {
fViewer.setComparator(new WorkbenchViewerComparator());
fContentProvider = new ConfigContentProvider();
fViewer.setContentProvider(fContentProvider);
- fViewer.setInput(DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationTypes());
+ fViewer.setInput(getUsedLaunchConfigurationTypes());
//we don't want to see builders....
fViewer.addFilter(new LaunchCategoryFilter(IInternalDebugUIConstants.ID_EXTERNAL_TOOL_BUILDER_LAUNCH_CATEGORY));
//need to force load the children so that select all works initially
@@ -216,6 +218,25 @@ public class ExportLaunchConfigurationsWizardPage extends WizardPage {
}
/**
+ * @return launch configuration types which currently have configuration or
+ * prototype children, and are therefore relevant for exporting
+ */
+ private ILaunchConfigurationType[] getUsedLaunchConfigurationTypes() {
+ return Arrays.stream(DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationTypes()).filter(launchConfigType -> {
+ try {
+ return getConfigurationTypeChildren(launchConfigType).length > 0;
+ } catch (CoreException e) {
+ DebugUIPlugin.logErrorMessage(e.getMessage());
+ }
+ return true;
+ }).toArray(ILaunchConfigurationType[]::new);
+ }
+
+ private ILaunchConfiguration[] getConfigurationTypeChildren(ILaunchConfigurationType launchConfigurationTypeParent) throws CoreException {
+ return lm.getLaunchConfigurations(launchConfigurationTypeParent, ILaunchConfiguration.CONFIGURATION | ILaunchConfiguration.PROTOTYPE);
+ }
+
+ /**
* Updates the checked state of child launch configurations if the parent type is checked
* @param item
*/

Back to the top