mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
bug 358829: AbstractPage-derived pages should remember current tab
This commit is contained in:
parent
6a63d0325f
commit
e28830a10b
1 changed files with 35 additions and 13 deletions
|
@ -151,6 +151,8 @@ implements
|
||||||
private static final String PREF_ASK_REINDEX = "askReindex"; //$NON-NLS-1$
|
private static final String PREF_ASK_REINDEX = "askReindex"; //$NON-NLS-1$
|
||||||
|
|
||||||
private Map<URL, Image> loadedIcons = new HashMap<URL, Image>();
|
private Map<URL, Image> loadedIcons = new HashMap<URL, Image>();
|
||||||
|
private static Map<Class<? extends AbstractPage>, Class<? extends ICPropertyTab>> recentTabs =
|
||||||
|
new HashMap<Class<? extends AbstractPage>, Class<? extends ICPropertyTab>>();
|
||||||
|
|
||||||
private final Image IMG_WARN = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_REFACTORING_WARNING);
|
private final Image IMG_WARN = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_REFACTORING_WARNING);
|
||||||
/*
|
/*
|
||||||
|
@ -362,20 +364,40 @@ implements
|
||||||
// Set listener after data load, to avoid firing
|
// Set listener after data load, to avoid firing
|
||||||
// selection event on not-initialized tab items
|
// selection event on not-initialized tab items
|
||||||
if (folder != null) {
|
if (folder != null) {
|
||||||
folder.addSelectionListener(new SelectionAdapter() {
|
folder.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(org.eclipse.swt.events.SelectionEvent event) {
|
public void widgetSelected(org.eclipse.swt.events.SelectionEvent event) {
|
||||||
if (folder.getSelection().length > 0 ) {
|
if (folder.getSelection().length > 0 ) {
|
||||||
ICPropertyTab newTab = (ICPropertyTab)folder.getSelection()[0].getData();
|
updateSelectedTab();
|
||||||
if (newTab != null && currentTab != newTab) {
|
}
|
||||||
if (currentTab != null) currentTab.handleTabEvent(ICPropertyTab.VISIBLE, null);
|
}
|
||||||
currentTab = newTab;
|
});
|
||||||
currentTab.handleTabEvent(ICPropertyTab.VISIBLE, NOT_NULL);
|
if (folder.getItemCount() > 0) {
|
||||||
}
|
int selectedTab = 0;
|
||||||
}
|
Class<? extends ICPropertyTab> recentTab = recentTabs.get(getClass());
|
||||||
}
|
if (recentTab != null) {
|
||||||
});
|
TabItem[] tabs = folder.getItems();
|
||||||
if (folder.getItemCount() > 0) folder.setSelection(0);
|
for (int i = 0; i < tabs.length; i++) {
|
||||||
|
TabItem control = tabs[i];
|
||||||
|
if (recentTab.isInstance(control.getData())) {
|
||||||
|
selectedTab = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
folder.setSelection(selectedTab);
|
||||||
|
updateSelectedTab();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateSelectedTab() {
|
||||||
|
ICPropertyTab newTab = (ICPropertyTab)folder.getSelection()[0].getData();
|
||||||
|
if (newTab != null && currentTab != newTab) {
|
||||||
|
recentTabs.put(getClass(), newTab.getClass());
|
||||||
|
if (currentTab != null) currentTab.handleTabEvent(ICPropertyTab.VISIBLE, null);
|
||||||
|
currentTab = newTab;
|
||||||
|
currentTab.handleTabEvent(ICPropertyTab.VISIBLE, NOT_NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue