Example usage for com.intellij.openapi.util DimensionService getInstance

List of usage examples for com.intellij.openapi.util DimensionService getInstance

Introduction

In this page you can find the example usage for com.intellij.openapi.util DimensionService getInstance.

Prototype

public static DimensionService getInstance() 

Source Link

Usage

From source file:com.android.tools.idea.uibuilder.lint.LintNotificationPanel.java

License:Apache License

@NotNull
public JBPopup showInBestPositionFor(@Nullable Project project, @NotNull JComponent component) {
    return setupPopup(project, popup -> {
        Dimension preferredSize = DimensionService.getInstance().getSize(DIMENSION_KEY, project);
        if (preferredSize == null) {
            preferredSize = myPanel.getPreferredSize();
        }//from  w w w  .  j a  v a  2 s  .c  o m

        showInScreenPosition(project, new RelativePoint(component,
                new Point(component.getWidth() - preferredSize.width, component.getHeight())));
    });
}

From source file:com.hp.alm.ali.idea.ui.dialog.MyDialog.java

License:Apache License

protected void restoreSizeAndLocation() {
    // Dialog's size and location: migrate to DialogWrapper to avoid need for our own code

    Point location = null;/* ww w. j a va 2 s. c  om*/
    Dimension size = null;
    dimensionKey = getDimensionKey();
    if (dimensionKey != null) {
        location = DimensionService.getInstance().getLocation(dimensionKey, project);
        size = DimensionService.getInstance().getSize(dimensionKey, project);
    }
    if (location != null) {
        setLocation(location);
    } else {
        centerOnOwner();
    }
    if (size != null) {
        setSize(size.width, size.height);
    }

    Rectangle bounds = getBounds();
    ScreenUtil.fitToScreen(bounds);
    setBounds(bounds);
}

From source file:com.hp.alm.ali.idea.ui.dialog.MyDialog.java

License:Apache License

public void dispose() {
    if (dimensionKey != null) {
        DimensionService.getInstance().setSize(dimensionKey, getSize());
        DimensionService.getInstance().setLocation(dimensionKey, getLocation());
    }//w  ww . ja v  a  2s .c  o  m
    super.dispose();
}

From source file:com.intellij.debugger.ui.StatementEvaluationDialog.java

License:Apache License

public StatementEvaluationDialog(final Project project, TextWithImports text) {
    super(project, text);
    setTitle(DebuggerBundle.message("evaluate.statement.dialog.title"));
    myPanel = new JPanel(new BorderLayout());

    final Splitter splitter = new Splitter(true);
    splitter.setHonorComponentsMinimumSize(true);

    final JPanel editorPanel = new JPanel(new GridBagLayout());

    final JLabel statementsLabel = new JLabel(DebuggerBundle.message("label.evaluation.dialog.statements"));
    editorPanel.add(statementsLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 0.0, 0.0,
            GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0));
    editorPanel.add(getStatementEditor(), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 1.0,
            GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 0, 0, 0), 0, 0));

    splitter.setFirstComponent(editorPanel);

    final MyEvaluationPanel evaluationPanel = getEvaluationPanel();
    final JPanel ep = new JPanel(new BorderLayout());
    //final JLabel resultLabel = new JLabel(DebuggerBundle.message("label.evaluate.dialog.result"));
    //ep.add(resultLabel, BorderLayout.NORTH);
    ep.add(evaluationPanel, BorderLayout.CENTER);
    splitter.setSecondComponent(ep);//  ww  w .j ava  2s. c  om
    final Dimension statementSize = DimensionService.getInstance().getSize(STATEMENT_EDITOR_DIMENSION_KEY,
            project);
    final Dimension evaluationSize = DimensionService.getInstance().getSize(EVALUATION_PANEL_DIMENSION_KEY,
            project);
    if (statementSize != null && evaluationSize != null) {
        final float proportion = (float) statementSize.height
                / (float) (statementSize.height + evaluationSize.height);
        splitter.setProportion(proportion);
    }
    myPanel.add(splitter, BorderLayout.CENTER);

    setDebuggerContext(getDebuggerContext());

    final KeyStroke codeFragment = KeyStroke.getKeyStroke(KeyEvent.VK_E, KeyEvent.ALT_MASK);
    final KeyStroke resultStroke = KeyStroke.getKeyStroke(KeyEvent.VK_R, KeyEvent.ALT_MASK);
    final KeyStroke altEnter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.CTRL_MASK);

    final JRootPane rootPane = getRootPane();
    final AnAction toStatementAction = new AnAction() {
        public void actionPerformed(AnActionEvent e) {
            getStatementEditor().requestFocus();
        }
    };
    toStatementAction.registerCustomShortcutSet(new CustomShortcutSet(codeFragment), rootPane);
    addDisposeRunnable(new Runnable() {
        public void run() {
            toStatementAction.unregisterCustomShortcutSet(rootPane);
        }
    });

    final AnAction toEvaluationAction = new AnAction() {
        public void actionPerformed(AnActionEvent e) {
            getEvaluationPanel().getWatchTree().requestFocus();
        }
    };
    toEvaluationAction.registerCustomShortcutSet(new CustomShortcutSet(resultStroke), rootPane);
    addDisposeRunnable(new Runnable() {
        public void run() {
            toEvaluationAction.unregisterCustomShortcutSet(rootPane);
        }
    });

    final AnAction okAction = new AnAction() {
        public void actionPerformed(AnActionEvent e) {
            doOKAction();
        }
    };
    okAction.registerCustomShortcutSet(new CustomShortcutSet(altEnter), rootPane);
    addDisposeRunnable(new Runnable() {
        public void run() {
            okAction.unregisterCustomShortcutSet(rootPane);
        }
    });

    final DebuggerEditorImpl editor = getEditor();
    final DocumentAdapter docListener = new DocumentAdapter() {
        public void documentChanged(final DocumentEvent e) {
            DebuggerInvocationUtil.invokeLater(getProject(), new Runnable() {
                public void run() {
                    updateSwitchButton(e.getDocument());
                }
            });
        }
    };
    editor.addDocumentListener(docListener);
    addDisposeRunnable(new Runnable() {
        public void run() {
            editor.removeDocumentListener(docListener);
        }
    });

    init();
}

From source file:com.intellij.debugger.ui.StatementEvaluationDialog.java

License:Apache License

public void dispose() {
    try {/*ww w.  j  av  a  2 s . co m*/
        final DebuggerEditorImpl editor = getEditor();
        final DimensionService dimensionService = DimensionService.getInstance();
        dimensionService.setSize(STATEMENT_EDITOR_DIMENSION_KEY, editor.getSize(null), getProject());
        dimensionService.setSize(EVALUATION_PANEL_DIMENSION_KEY, getEvaluationPanel().getSize(), getProject());
    } finally {
        super.dispose();
    }
}

From source file:com.intellij.execution.ui.layout.impl.GridCellImpl.java

License:Apache License

public void saveUiState() {
    saveProportions();/* ww w. ja v a2 s .c o  m*/

    for (Content each : myContents.getKeys()) {
        saveState(each, false);
    }

    for (Content each : myMinimizedContents) {
        saveState(each, true);
    }

    final DimensionService service = DimensionService.getInstance();
    final Dimension size = myContext.getContentManager().getComponent().getSize();
    service.setSize(getDimensionKey(), size, myContext.getProject());
    if (myContext.getWindow() != 0) {
        final Window frame = SwingUtilities.getWindowAncestor(myPlaceholder);
        if (frame != null) {
            service.setLocation(getDimensionKey(), frame.getLocationOnScreen());
        }
    }
}

From source file:com.intellij.execution.ui.layout.impl.GridCellImpl.java

License:Apache License

@Nullable
public Point getLocation() {
    return DimensionService.getInstance().getLocation(getDimensionKey(), myContext.getProject());
}

From source file:com.intellij.execution.ui.layout.impl.GridCellImpl.java

License:Apache License

@Nullable
public Dimension getSize() {
    return DimensionService.getInstance().getSize(getDimensionKey(), myContext.getProject());
}

From source file:com.intellij.ide.fileTemplates.ui.ConfigureTemplatesDialog.java

License:Apache License

private void initSize() {
    Dimension size = DimensionService.getInstance().getSize(DIMENSION_KEY, getProject());
    if (size == null) {
        DimensionService.getInstance().setSize(DIMENSION_KEY, new Dimension(700, 500), getProject());
    }//w  w w .  jav  a 2 s.  c  o m
}

From source file:com.intellij.ide.ui.SplitterProportionsDataImpl.java

License:Apache License

@Override
public void externalizeToDimensionService(String key) {
    for (int i = 0; i < proportions.size(); i++) {
        float proportion = proportions.get(i).floatValue();
        String serviceKey = key + "." + i;
        int value = (int) (proportion * 1000);
        DimensionService.getInstance().setExtendedState(serviceKey, value);
    }//from ww  w  .  ja  va2s.  c o  m
}