"Feature Settings for CDS and Protein Views");
featureSettingsPanels.setOpaque(true);
featureSettingsUI.setContentPane(featureSettingsPanels);
- JPanel dummyDNA = new JPanel(),dummyProtein=new JPanel();
- FocusListener fl1 = new FocusListener()
- {
-
- @Override
- public void focusLost(FocusEvent e)
- {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void focusGained(FocusEvent e)
- {
- int tab = featureSettingsPanels.getSelectedIndex();
- getAlignFrames().get(tab).showFeatureSettingsUI();
- }
- };
- dummyDNA.addFocusListener(fl1);
- dummyProtein.addFocusListener(fl1);
-
- featureSettingsPanels.addTab("CDS", dummyDNA);
- featureSettingsPanels.addTab("Protein", dummyProtein);
+ createDummyTabs();
}
if (featureSettingsPanels
.indexOfTabComponent((Component) featureSettings) > -1)
}
}
+ /*
+ * for materialising feature settings for a tab when clicked on
+ */
+ private FocusListener fl1 = new FocusListener()
+ {
+
+ @Override
+ public void focusLost(FocusEvent e)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void focusGained(FocusEvent e)
+ {
+ int tab = featureSettingsPanels.getSelectedIndex();
+ getAlignFrames().get(tab).showFeatureSettingsUI();
+ }
+ };
+
+ /**
+ * tab names for feature settings
+ */
+ private String[] tabName = new String[] {
+ MessageManager.getString("label.CDS"),
+ MessageManager.getString("label.Protein") };
+
+ /**
+ * create placeholder tabs which materialise the feature settings for a given
+ * view. Also reinitialises any tabs containing stale feature settings
+ */
+ private void createDummyTabs()
+ {
+ for (int tabIndex = 0; tabIndex < 2; tabIndex++)
+ {
+ JPanel dummyTab = new JPanel();
+ dummyTab.addFocusListener(fl1);
+ featureSettingsPanels.addTab(tabName[tabIndex], dummyTab);
+ }
+ }
+
+ private void replaceWithDummyTab(FeatureSettingsControllerI toClose)
+ {
+ Component dummyTab = null;
+ for (int tabIndex = 0; tabIndex < 2; tabIndex++)
+ {
+ if (featureSettingsPanels.getTabCount() > tabIndex)
+ {
+ dummyTab = featureSettingsPanels.getTabComponentAt(tabIndex);
+ if (dummyTab instanceof FeatureSettingsControllerGuiI
+ && !dummyTab.isVisible())
+ {
+ featureSettingsPanels.removeTabAt(tabIndex);
+ // close the feature Settings tab
+ ((FeatureSettingsControllerGuiI) dummyTab)
+ .featureSettings_isClosed();
+ // create a dummy tab in its place
+ dummyTab = new JPanel();
+ dummyTab.addFocusListener(fl1);
+ featureSettingsPanels.insertTab(tabName[tabIndex], null, dummyTab,
+ MessageManager.formatMessage(
+ "label.sequence_feature_settings_for",
+ tabName[tabIndex]),
+ tabIndex);
+ }
+ }
+ }
+ }
+
@Override
public void closeFeatureSettings(
- FeatureSettingsControllerI featureSettings)
+ FeatureSettingsControllerI featureSettings,
+ boolean closeContainingFrame)
{
if (featureSettingsUI != null)
{
- try
+ if (closeContainingFrame)
{
- featureSettingsUI.setClosed(true);
- } catch (Exception x)
+ try
+ {
+ featureSettingsUI.setClosed(true);
+ } catch (Exception x)
+ {
+ }
+ featureSettingsUI = null;
+ }
+ else
{
+ replaceWithDummyTab(featureSettings);
}
- featureSettingsUI = null;
}
}
}
\ No newline at end of file