@@ -843,8 +843,9 @@ protected void displayInstanceTabs(boolean redrawTabs) {
843843 fInitializingTabs = false ;
844844 return ;
845845 }
846+ Class <? extends ILaunchConfigurationTab > lastActiveTabKind = null ;
846847 if (redrawTabs ) {
847- showInstanceTabsFor (type );
848+ lastActiveTabKind = showInstanceTabsFor (type );
848849 }
849850 // show the name area
850851 updateVisibleControls (true );
@@ -873,17 +874,25 @@ protected void displayInstanceTabs(boolean redrawTabs) {
873874 // Turn off initializing flag to update message
874875 fInitializingTabs = false ;
875876
877+ // Try to activate the same (type of) tab that was active before.
878+ if (!setActiveTab (lastActiveTabKind )) {
879+ // The tab with the wanted class wasn't found. Try to activate the first one
880+ setActiveTab (0 );
881+ }
882+
876883 if (!fViewform .isVisible ()) {
877884 fViewform .setVisible (true );
878885 }
879886 }
880887
881888 /**
882- * Populate the tabs in the configuration edit area to be appropriate to the current
883- * launch configuration type.
889+ * Populate the tabs in the configuration edit area to be appropriate to the
890+ * current launch configuration type.
891+ *
884892 * @param configType the type to show tabs for
893+ * @return The class of the last active tab.
885894 */
886- private void showInstanceTabsFor (ILaunchConfigurationType configType ) {
895+ private Class <? extends ILaunchConfigurationTab > showInstanceTabsFor (ILaunchConfigurationType configType ) {
887896 // try to keep on same tab
888897 Class <? extends ILaunchConfigurationTab > tabKind = null ;
889898 if (getActiveTab () != null ) {
@@ -895,7 +904,7 @@ private void showInstanceTabsFor(ILaunchConfigurationType configType) {
895904 group = createGroup ();
896905 } catch (CoreException ce ) {
897906 DebugUIPlugin .errorDialog (getShell (), LaunchConfigurationsMessages .LaunchConfigurationDialog_Error_19 , LaunchConfigurationsMessages .LaunchConfigurationDialog_Exception_occurred_creating_launch_configuration_tabs_27 ,ce ); //
898- return ;
907+ return null ;
899908 }
900909 disposeExistingTabs ();
901910 fTabGroup = group ;
@@ -923,18 +932,8 @@ private void showInstanceTabsFor(ILaunchConfigurationType configType) {
923932 tab .setControl (control .getParent ());
924933 }
925934 }
926- //set the default tab as the first one
927- if (tabs .length > 0 ) {
928- setActiveTab (tabs [0 ]);
929- }
930- // select same tab as before, if possible
931- for (ILaunchConfigurationTab t : tabs ) {
932- if (t .getClass ().equals (tabKind )) {
933- setActiveTab (t );
934- break ;
935- }
936- }
937935 fDescription = getDescription (configType );
936+ return tabKind ;
938937 }
939938
940939 /**
@@ -1602,6 +1601,29 @@ protected void errorDialog(CoreException exception) {
16021601 ErrorDialog .openError (getShell (), null , null , exception .getStatus ());
16031602 }
16041603
1604+ /**
1605+ * @param tabKind The class of the tab that has to be activated.
1606+ * @return <code>true</code> if a tab was activated, <code>false</code>
1607+ * otherwise.
1608+ */
1609+ private boolean setActiveTab (Class <? extends ILaunchConfigurationTab > tabKind ) {
1610+ if (tabKind == null ) {
1611+ return false ;
1612+ }
1613+
1614+ ILaunchConfigurationTab [] tabs = getTabs ();
1615+
1616+ // select same tab as before, if possible
1617+ for (ILaunchConfigurationTab t : tabs ) {
1618+ if (t .getClass ().equals (tabKind )) {
1619+ setActiveTab (t );
1620+ return true ;
1621+ }
1622+ }
1623+
1624+ return false ;
1625+ }
1626+
16051627 /**
16061628 * Sets the displayed tab to the given tab. Has no effect if the specified
16071629 * tab is not one of the tabs being displayed in the dialog currently.
0 commit comments