Skip to content

Commit

Permalink
Show a progress indicator when opening a PDE run configuration.
Browse files Browse the repository at this point in the history
The progress indicator uses IProgressMonitor.UNKNOWN as the total amount
of work because the (sometimes) long running operation is deep in the
call stack: it goes all the way down to the TracingOptionsManager in
org.eclipse.pde.core (dependency issues).

Fixes vi-eclipse/Eclipse-PDE#1
  • Loading branch information
fedejeanne committed Jul 24, 2023
1 parent 575c801 commit 447c930
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ public class PDEUIMessages extends NLS {

public static String TracingBlock_restore_default;
public static String TracingBlock_restore_default_selected;
public static String TracingBlock_initializing_tracing;

public static String TracingLauncherTab_name;
public static String TracingLauncherTab_tracing;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
Expand All @@ -28,9 +29,12 @@
import java.util.StringTokenizer;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.IStructuredSelection;
Expand Down Expand Up @@ -276,17 +280,24 @@ protected int createPropertySheet(Composite parent) {
return style == SWT.NULL ? 2 : 0;
}

public void initializeFrom(ILaunchConfiguration config) {
public void initializeFrom(ILaunchConfiguration config, IRunnableContext context) {
fMasterOptions.clear();
disposePropertySources();
try {
fTracingCheck.setSelection(config.getAttribute(IPDELauncherConstants.TRACING, false));
Map<String, String> options = config.getAttribute(IPDELauncherConstants.TRACING_OPTIONS, (Map<String, String>) null);
if (options == null) {
fMasterOptions.putAll(PDECore.getDefault().getTracingOptionsManager().getTracingTemplateCopy());
} else {
fMasterOptions.putAll(PDECore.getDefault().getTracingOptionsManager().getTracingOptions(options));
}

// Calculating the tracing properties might be expensive
runShowingProgress(context, progressMonitor -> {
progressMonitor.beginTask(PDEUIMessages.TracingBlock_initializing_tracing, IProgressMonitor.UNKNOWN);

final Properties properties = (options == null)
? PDECore.getDefault().getTracingOptionsManager().getTracingTemplateCopy()
: PDECore.getDefault().getTracingOptionsManager().getTracingOptions(options);

fMasterOptions.putAll(properties);
});

masterCheckChanged(false);
String checked = config.getAttribute(IPDELauncherConstants.TRACING_CHECKED, (String) null);
if (checked == null) {
Expand Down Expand Up @@ -323,6 +334,14 @@ public void initializeFrom(ILaunchConfiguration config) {
}
}

private void runShowingProgress(IRunnableContext context, IRunnableWithProgress runnable) {
try {
context.run(true, false, runnable);
} catch (InvocationTargetException | InterruptedException e) {
PDEPlugin.logException(e);
}
}

public void performApply(ILaunchConfigurationWorkingCopy config) {
boolean tracingEnabled = fTracingCheck.getSelection();
config.setAttribute(IPDELauncherConstants.TRACING, tracingEnabled);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,7 @@ TracingTab_AttributeLabel_TracingNone=Tracing select none

TracingBlock_restore_default=Restore &All to Defaults
TracingBlock_restore_default_selected=Restore &Selected to Defaults
TracingBlock_initializing_tracing=Initializing tracing
TracingLauncherTab_name = Trac&ing
TracingLauncherTab_tracing =&Enable tracing
TracingLauncherTab_enableAll = E&nable All
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void dispose() {

@Override
public void initializeFrom(ILaunchConfiguration config) {
fTracingBlock.initializeFrom(config);
fTracingBlock.initializeFrom(config, getLaunchConfigurationDialog());
}

@Override
Expand Down

0 comments on commit 447c930

Please sign in to comment.