Skip to content

Commit

Permalink
Suggestions for further improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
HannesWell committed Apr 20, 2024
1 parent daf97c7 commit 2456c70
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ public abstract class AbstractPluginBlock {

private PluginStatusDialog fDialog;

private boolean fControlCreated;

class PluginModelNameBuffer {
private final Set<String> nameSet;

Expand Down Expand Up @@ -460,8 +458,6 @@ public void createControl(Composite parent, int span, int indent) {

SWTUtil.setButtonDimensionHint(fValidateButton);
fValidateButton.addSelectionListener(fListener);

fControlCreated = true;
}

private Button createButton(Composite parent, int span, int indent, String text) {
Expand Down Expand Up @@ -947,12 +943,6 @@ private int countChecked(Object[] elements) {
}

public void performApply(ILaunchConfigurationWorkingCopy config) {
if (!fControlCreated) {
// This method is also being called before the proper UI elements
// are created, which might cause a NPE
return;
}

if (fAutoIncludeRequirementsButtonChanged) {
boolean includeRequirements = fAutoIncludeRequirementsButton.getSelection();
config.setAttribute(IPDELauncherConstants.AUTOMATIC_INCLUDE_REQUIREMENTS, includeRequirements);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.eclipse.pde.internal.ui.launcher.PluginBlock;
import org.eclipse.pde.launching.IPDELauncherConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
Expand Down Expand Up @@ -60,7 +59,7 @@ public class PluginsTab extends AbstractLauncherTab {
private Combo fDefaultAutoStart;
private Spinner fDefaultStartLevel;
private final Listener fListener;
private boolean fActivated;
private boolean fActivated = false;

private static final int DEFAULT_SELECTION = 0;
private static final int PLUGIN_SELECTION = 1;
Expand Down Expand Up @@ -168,30 +167,27 @@ public void activated(ILaunchConfigurationWorkingCopy configuration) {
return;
}

BusyIndicator.showWhile(getControl().getDisplay(), () -> {
try {
int index = DEFAULT_SELECTION;
if (configuration.getAttribute(IPDELauncherConstants.USE_CUSTOM_FEATURES, false)) {
index = FEATURE_SELECTION;
} else if (!configuration.getAttribute(IPDELauncherConstants.USE_DEFAULT, true)) {
index = PLUGIN_SELECTION;
}
fSelectionCombo.select(index);
fBlock.setActiveBlock(index);
boolean custom = fSelectionCombo.getSelectionIndex() == PLUGIN_SELECTION;
fBlock.initializeFrom(configuration, custom);
boolean auto = configuration.getAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, false);
fDefaultAutoStart.setText(Boolean.toString(auto));
int level = configuration.getAttribute(IPDELauncherConstants.DEFAULT_START_LEVEL, 4);
fDefaultStartLevel.setSelection(level);

// If everything ran smoothly, this tab is activated
fActivated = true;
} catch (CoreException e) {
PDEPlugin.log(e);
try {
int index = DEFAULT_SELECTION;
if (configuration.getAttribute(IPDELauncherConstants.USE_CUSTOM_FEATURES, false)) {
index = FEATURE_SELECTION;
} else if (!configuration.getAttribute(IPDELauncherConstants.USE_DEFAULT, true)) {
index = PLUGIN_SELECTION;
}
});

fSelectionCombo.select(index);
fBlock.setActiveBlock(index);
boolean custom = fSelectionCombo.getSelectionIndex() == PLUGIN_SELECTION;
fBlock.initializeFrom(configuration, custom);
boolean auto = configuration.getAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, false);
fDefaultAutoStart.setText(Boolean.toString(auto));
int level = configuration.getAttribute(IPDELauncherConstants.DEFAULT_START_LEVEL, 4);
fDefaultStartLevel.setSelection(level);

// If everything ran smoothly, this tab is activated
fActivated = true;
} catch (CoreException e) {
PDEPlugin.log(e);
}
}

@Override
Expand All @@ -206,7 +202,9 @@ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
int index = fSelectionCombo.getSelectionIndex();
configuration.setAttribute(IPDELauncherConstants.USE_DEFAULT, index == DEFAULT_SELECTION);
configuration.setAttribute(IPDELauncherConstants.USE_CUSTOM_FEATURES, index == FEATURE_SELECTION);
fBlock.performApply(configuration);
if (fActivated) {
fBlock.performApply(configuration);
}
// clear default values for auto-start and start-level if default
String autoText = fDefaultAutoStart.getText();
if (Boolean.toString(false).equals(autoText)) {
Expand Down

0 comments on commit 2456c70

Please sign in to comment.