Example usage for com.intellij.openapi.ui SplitterProportionsData externalizeToDimensionService

List of usage examples for com.intellij.openapi.ui SplitterProportionsData externalizeToDimensionService

Introduction

In this page you can find the example usage for com.intellij.openapi.ui SplitterProportionsData externalizeToDimensionService.

Prototype

void externalizeToDimensionService(@NonNls String key);

Source Link

Usage

From source file:com.intellij.history.integration.ui.views.HistoryDialog.java

License:Apache License

private void saveSplitterProportion() {
    SplitterProportionsData d = createSplitterData();
    d.saveSplitterProportions(mySplitter);
    d.externalizeToDimensionService(getPropertiesKey());
}

From source file:com.vladsch.MissingInActions.util.ContentChooser.java

License:Apache License

@Override
protected JComponent createCenterPanel() {
    final int selectionMode = myAllowMultipleSelections ? ListSelectionModel.MULTIPLE_INTERVAL_SELECTION
            : ListSelectionModel.SINGLE_SELECTION;
    myList.setSelectionMode(selectionMode);
    if (myUseIdeaEditor) {
        EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
        myList.setFont(scheme.getFont(EditorFontType.PLAIN));
        Color fg = ObjectUtils.chooseNotNull(scheme.getDefaultForeground(),
                new JBColor(UIUtil::getListForeground));
        Color bg = ObjectUtils.chooseNotNull(scheme.getDefaultBackground(),
                new JBColor(UIUtil::getListBackground));
        myList.setForeground(fg);//from   w w  w.  jav  a2  s  . co  m
        myList.setBackground(bg);
    }

    new DoubleClickListener() {
        @Override
        protected boolean onDoubleClick(MouseEvent e) {
            close(OK_EXIT_CODE);
            return true;
        }
    }.installOn(myList);

    myList.setCellRenderer(new MyListCellRenderer());
    myList.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DELETE) {
                int newSelectionIndex = -1;
                for (Object o : myList.getSelectedValues()) {
                    int i = ((Item) o).index;
                    removeContentAt(myAllContents.get(i));
                    if (newSelectionIndex < 0) {
                        newSelectionIndex = i;
                    }
                }

                rebuildListContent();
                if (myAllContents.isEmpty()) {
                    close(CANCEL_EXIT_CODE);
                    return;
                }
                newSelectionIndex = Math.min(newSelectionIndex, myAllContents.size() - 1);
                myList.setSelectedIndex(newSelectionIndex);
            } else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                doOKAction();
            } else {
                final char aChar = e.getKeyChar();
                if (aChar >= '0' && aChar <= '9') {
                    int idx = aChar == '0' ? 9 : aChar - '1';
                    if (idx < myAllContents.size()) {
                        myList.setSelectedIndex(idx);
                        e.consume();
                        doOKAction();
                    }
                } else {
                    listKeyPressed(e);
                }
            }
        }
    });

    mySplitter.setFirstComponent(
            ListWithFilter.wrap(myList, ScrollPaneFactory.createScrollPane(myList), o -> ((Item) o).longText));
    mySplitter.setSecondComponent(new JPanel());
    rebuildListContent();

    ScrollingUtil.installActions(myList);
    ScrollingUtil.ensureSelectionExists(myList);
    updateViewerForSelection();
    myList.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            myUpdateAlarm.cancelAllRequests();
            myUpdateAlarm.addRequest(() -> updateViewerForSelection(), 100);
        }
    });

    mySplitter.setPreferredSize(JBUI.size(500, 500));

    SplitterProportionsData d = new SplitterProportionsDataImpl();
    d.externalizeToDimensionService(getClass().getName());
    d.restoreSplitterProportions(mySplitter);

    return mySplitter;
}

From source file:com.vladsch.MissingInActions.util.ContentChooser.java

License:Apache License

@Override
public void dispose() {
    super.dispose();

    SplitterProportionsData d = new SplitterProportionsDataImpl();
    d.externalizeToDimensionService(getClass().getName());
    d.saveSplitterProportions(mySplitter);

    if (myViewer != null) {
        EditorFactory.getInstance().releaseEditor(myViewer);
        myViewer = null;// w  w w . j av  a 2  s  . com
    }
}