Example usage for com.intellij.openapi.options BaseConfigurable getPreferredFocusedComponent

List of usage examples for com.intellij.openapi.options BaseConfigurable getPreferredFocusedComponent

Introduction

In this page you can find the example usage for com.intellij.openapi.options BaseConfigurable getPreferredFocusedComponent.

Prototype

@Override
    public JComponent getPreferredFocusedComponent() 

Source Link

Usage

From source file:com.android.tools.idea.structure.dialog.ProjectStructureConfigurable.java

License:Apache License

@Override
@NotNull/*from  www .  ja v a2  s. co m*/
public ActionCallback navigateTo(@Nullable Place place, boolean requestFocus) {
    if (place == null) {
        return ActionCallback.DONE;
    }

    Configurable toSelect;
    Object displayName = place.getPath(CATEGORY_NAME);
    if (displayName instanceof String) {
        toSelect = findConfigurable((String) displayName);
    } else {
        toSelect = (Configurable) place.getPath(CATEGORY);
    }

    JComponent detailsContent = myDetails.getTargetComponent();

    if (mySelectedConfigurable != toSelect) {
        saveSideProportion();
        removeSelected();
    }

    if (toSelect != null) {
        detailsContent = toSelect.createComponent();
        myDetails.setContent(detailsContent);
    }

    mySelectedConfigurable = toSelect;
    if (mySelectedConfigurable != null) {
        myUiState.lastEditedConfigurable = mySelectedConfigurable.getDisplayName();
    }

    if (toSelect instanceof MasterDetailsComponent) {
        MasterDetailsComponent masterDetails = (MasterDetailsComponent) toSelect;
        if (myUiState.sideProportion > 0) {
            masterDetails.getSplitter().setProportion(myUiState.sideProportion);
        }
        masterDetails.setHistory(myHistory);
    } else if (toSelect == mySdksConfigurable) {
        mySdksConfigurable.setHistory(myHistory);
    }

    if (toSelect != null) {
        mySidePanel.select(createPlaceFor(toSelect));
    }

    JComponent toFocus = null;
    if (mySelectedConfigurable instanceof BaseConfigurable) {
        BaseConfigurable configurable = (BaseConfigurable) mySelectedConfigurable;
        toFocus = configurable.getPreferredFocusedComponent();
    } else if (mySelectedConfigurable instanceof MasterDetailsComponent) {
        MasterDetailsComponent configurable = (MasterDetailsComponent) mySelectedConfigurable;
        toFocus = configurable.getMaster();
    }

    if (toFocus == null && detailsContent != null) {
        toFocus = IdeFocusTraversalPolicy.getPreferredFocusedComponent(detailsContent);
        if (toFocus == null) {
            toFocus = detailsContent;
        }
    }
    myToFocus = toFocus;
    if (myToFocus != null) {
        requestFocus(myToFocus);
    }

    ActionCallback result = new ActionCallback();
    goFurther(toSelect, place, requestFocus).notifyWhenDone(result);

    myDetails.revalidate();
    myDetails.repaint();

    if (!myHistory.isNavigatingNow() && mySelectedConfigurable != null) {
        myHistory.pushQueryPlace();
    }

    return result;
}