private void removeSelected() { myDetails.removeAll(); mySelectedConfigurable = null; myUiState.lastEditedConfigurable = null; myDetails.add(myEmptySelection, BorderLayout.CENTER); }
public ProjectStructureConfigurable( final Project project, final ProjectLibrariesConfigurable projectLibrariesConfigurable, final GlobalLibrariesConfigurable globalLibrariesConfigurable, final ModuleStructureConfigurable moduleStructureConfigurable, FacetStructureConfigurable facetStructureConfigurable, ArtifactsStructureConfigurable artifactsStructureConfigurable) { myProject = project; myFacetStructureConfigurable = facetStructureConfigurable; myArtifactsStructureConfigurable = artifactsStructureConfigurable; myModuleConfigurator = new ModulesConfigurator(myProject); myContext = new StructureConfigurableContext(myProject, myModuleConfigurator); myModuleConfigurator.setContext(myContext); myProjectLibrariesConfig = projectLibrariesConfigurable; myGlobalLibrariesConfig = globalLibrariesConfigurable; myModulesConfig = moduleStructureConfigurable; myProjectLibrariesConfig.init(myContext); myGlobalLibrariesConfig.init(myContext); myModulesConfig.init(myContext); myFacetStructureConfigurable.init(myContext); if (!project.isDefault()) { myArtifactsStructureConfigurable.init( myContext, myModulesConfig, myProjectLibrariesConfig, myGlobalLibrariesConfig); } final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(myProject); myUiState.lastEditedConfigurable = propertiesComponent.getValue("project.structure.last.edited"); final String proportion = propertiesComponent.getValue("project.structure.proportion"); myUiState.proportion = proportion != null ? Float.parseFloat(proportion) : 0; final String sideProportion = propertiesComponent.getValue("project.structure.side.proportion"); myUiState.sideProportion = sideProportion != null ? Float.parseFloat(sideProportion) : 0; }
@Override public ActionCallback navigateTo(@Nullable final Place place, final boolean requestFocus) { final Configurable toSelect = (Configurable) place.getPath(CATEGORY); JComponent detailsContent = myDetails.getTargetComponent(); if (mySelectedConfigurable != toSelect) { if (mySelectedConfigurable instanceof BaseStructureConfigurable) { ((BaseStructureConfigurable) mySelectedConfigurable).onStructureUnselected(); } saveSideProportion(); removeSelected(); if (toSelect != null) { detailsContent = toSelect.createComponent(); myDetails.setContent(detailsContent); } mySelectedConfigurable = toSelect; if (mySelectedConfigurable != null) { myUiState.lastEditedConfigurable = mySelectedConfigurable.getDisplayName(); } if (toSelect instanceof MasterDetailsComponent) { final MasterDetailsComponent masterDetails = (MasterDetailsComponent) toSelect; if (myUiState.sideProportion > 0) { masterDetails.getSplitter().setProportion(myUiState.sideProportion); } masterDetails.setHistory(myHistory); } if (toSelect instanceof DetailsComponent.Facade) { ((DetailsComponent.Facade) toSelect) .getDetailsComponent() .setBannerMinHeight(myToolbarComponent.getPreferredSize().height); } if (toSelect instanceof BaseStructureConfigurable) { ((BaseStructureConfigurable) toSelect).onStructureSelected(); } } if (detailsContent != null) { JComponent toFocus = IdeFocusTraversalPolicy.getPreferredFocusedComponent(detailsContent); if (toFocus == null) { toFocus = detailsContent; } if (requestFocus) { myToFocus = toFocus; UIUtil.requestFocus(toFocus); } } final ActionCallback result = new ActionCallback(); Place.goFurther(toSelect, place, requestFocus).notifyWhenDone(result); myDetails.revalidate(); myDetails.repaint(); if (toSelect != null) { mySidePanel.select(createPlaceFor(toSelect)); } if (!myHistory.isNavigatingNow() && mySelectedConfigurable != null) { myHistory.pushQueryPlace(); } return result; }