Skip to content

Commit

Permalink
Take default tab in LaunchConfigurationTabGroupViewer from CTabFolder
Browse files Browse the repository at this point in the history
When setting the active tab of the LaunchConfigurationTabGroupViewer for
the first time (right after setting its input), activate the tab that
the CTabFolder considers as the default tab.

Add a missing test too.
  • Loading branch information
fedejeanne committed May 8, 2024
1 parent f29bec5 commit a1466b8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,26 @@ public void testOtherTabIsActivated() {
assertThat(((SpyTab) tabs[secondTabIndex])).matches(SpyTab::isActivated, "should have been activated");
}

@Test
public void testActivateAllTabs() {
ThrowingRunnable<CoreException> activateSeveralTab = () -> {
// Create and select launch config
fLaunchConfigurationsDialog.getTabViewer().setInput(createLaunchConfigurationInstance());

// Select all tabs
for (int i = 0; i < fLaunchConfigurationsDialog.getTabViewer().getTabs().length; i++) {
fLaunchConfigurationsDialog.getTabViewer().setActiveTab(i);
}
};

final ILaunchConfigurationTab[] tabs = runOnDialog(activateSeveralTab);

// All tabs should have been activated exactly once
for (int i = 0; i < tabs.length; i++) {
assertThat(((SpyTab) tabs[i])).matches(SpyTab::isActivatedExactlyOnce, "Tab '" + i + "' should have been activated exactly once");
}
}

private ILaunchConfigurationWorkingCopy createLaunchConfigurationInstance() throws CoreException {
return fLaunchConfigurationType.newInstance(null, "MyLaunchConfiguration_" + System.currentTimeMillis());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -867,15 +867,16 @@ protected void displayInstanceTabs(boolean redrawTabs) {
// Update the name field
fNameWidget.setText(getWorkingCopy().getName());

fCurrentTabIndex = fTabFolder.getSelectionIndex();
fCurrentTabIndex = -1;

// Turn off initializing flag to update message
fInitializingTabs = false;

// Try to activate the same (type of) tab that was active before.
if (!setActiveTab(lastActiveTabKind)) {
// The tab with the wanted class wasn't found. Try to activate the first one
setActiveTab(0);
// The tab with the wanted class wasn't found. Try to activate the default tab
int defaultTabIndex = Math.max(fTabFolder.getSelectionIndex(), 0);
setActiveTab(defaultTabIndex);
}

if (!fViewform.isVisible()) {
Expand Down

0 comments on commit a1466b8

Please sign in to comment.