Search in sources :

Example 1 with AdjustComponentWhenShown

use of com.intellij.util.ui.AdjustComponentWhenShown in project intellij-community by JetBrains.

the class ChangesBrowserDialog method initDialog.

private void initDialog(final Project project, final CommittedChangesTableModel changes, final Mode mode) {
    myProject = project;
    myChanges = changes;
    myMode = mode;
    setTitle(VcsBundle.message("dialog.title.changes.browser"));
    setCancelButtonText(CommonBundle.getCloseButtonText());
    final ModalityState currentState = ModalityState.current();
    if ((mode != Mode.Choose) && (ModalityState.NON_MODAL.equals(currentState))) {
        setModal(false);
    }
    myAppender = new AsynchConsumer<List<CommittedChangeList>>() {

        public void finished() {
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    if (ChangesBrowserDialog.this.isShowing()) {
                        myCommittedChangesBrowser.stopLoading();
                    }
                }
            });
        }

        public void consume(final List<CommittedChangeList> committedChangeLists) {
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    if (ChangesBrowserDialog.this.isShowing()) {
                        final boolean selectFirst = (myChanges.getRowCount() == 0) && (!committedChangeLists.isEmpty());
                        myChanges.addRows(committedChangeLists);
                        if (selectFirst) {
                            myCommittedChangesBrowser.selectFirstIfAny();
                        }
                    }
                }
            });
        }
    };
    init();
    if (myInitRunnable != null) {
        new AdjustComponentWhenShown() {

            @Override
            protected boolean init() {
                myInitRunnable.consume(ChangesBrowserDialog.this);
                return true;
            }
        }.install(myCommittedChangesBrowser);
    }
}
Also used : CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList) ModalityState(com.intellij.openapi.application.ModalityState) List(java.util.List) CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList) AdjustComponentWhenShown(com.intellij.util.ui.AdjustComponentWhenShown)

Aggregations

ModalityState (com.intellij.openapi.application.ModalityState)1 CommittedChangeList (com.intellij.openapi.vcs.versionBrowser.CommittedChangeList)1 AdjustComponentWhenShown (com.intellij.util.ui.AdjustComponentWhenShown)1 List (java.util.List)1