Java Code Examples for com.intellij.openapi.util.DimensionService

The following are top voted examples for showing how to use com.intellij.openapi.util.DimensionService. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: ali-idea-plugin   File: MyDialog.java   View source code 6 votes vote down vote up
protected void restoreSizeAndLocation() {
    // Dialog's size and location: migrate to DialogWrapper to avoid need for our own code

    Point location = null;
    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);
}
 
Example 2
Project: intellij-ce-playground   File: NewWelcomeScreen.java   View source code 5 votes vote down vote up
@Override
public void setupFrame(JFrame frame) {
  frame.setResizable(false);
  frame.pack();
  Point location = DimensionService.getInstance().getLocation(WelcomeFrame.DIMENSION_KEY, null);
  Rectangle screenBounds = ScreenUtil.getScreenRectangle(location != null ? location : new Point(0, 0));
  frame.setLocation(new Point(
    screenBounds.x + (screenBounds.width - frame.getWidth()) / 2,
    screenBounds.y + (screenBounds.height - frame.getHeight()) / 3
  ));
}
 
Example 3
Project: intellij-ce-playground   File: PopupPositionManager.java   View source code 5 votes vote down vote up
public static Dimension getPopupSize(final JBPopup popup) {
  Dimension size = null;
  if (popup instanceof AbstractPopup) {
    final String dimensionKey = ((AbstractPopup)popup).getDimensionServiceKey();
    if (dimensionKey != null) {
      size = DimensionService.getInstance().getSize(dimensionKey);
    }
  }

  if (size == null) {
    size = popup.getContent().getPreferredSize();
  }

  return size;
}
 
Example 4
Project: tools-idea   File: StatementEvaluationDialog.java   View source code 5 votes vote down vote up
public void dispose() {
  try {
    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();
  }
}
 
Example 5
Project: tools-idea   File: SplitterProportionsDataImpl.java   View source code 5 votes vote down vote up
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);
  }
}
 
Example 6
Project: tools-idea   File: SplitterProportionsDataImpl.java   View source code 5 votes vote down vote up
public void externalizeFromDimensionService(String key) {
  proportions.clear();
  for (int i = 0; ;i++) {
    String serviceKey = key + "."+i;
    int value = DimensionService.getInstance().getExtendedState(serviceKey);
    if (value == -1) break;
    double proportion = value * 0.001;
    proportions.add(new Float(proportion));
  }
}
 
Example 7
Project: tools-idea   File: NewWelcomeScreen.java   View source code 5 votes vote down vote up
@Override
public void setupFrame(JFrame frame) {
  frame.setResizable(false);
  frame.pack();
  Point location = DimensionService.getInstance().getLocation(WelcomeFrame.DIMENSION_KEY, null);
  Rectangle screenBounds = ScreenUtil.getScreenRectangle(location != null ? location : new Point(0, 0));
  frame.setLocation(new Point(
    screenBounds.x + (screenBounds.width - frame.getWidth()) / 2,
    screenBounds.y + (screenBounds.height - frame.getHeight()) / 3
  ));
}
 
Example 8
Project: tools-idea   File: FrameWrapper.java   View source code 5 votes vote down vote up
protected void loadFrameState() {
  final Window frame = getFrame();
  final Point location;
  final Dimension size;
  final int extendedState;
  DimensionService dimensionService = DimensionService.getInstance();
  if (myDimensionKey == null || dimensionService == null) {
    location = null;
    size = null;
    extendedState = -1;
  }
  else {
    location = dimensionService.getLocation(myDimensionKey);
    size = dimensionService.getSize(myDimensionKey);
    extendedState = dimensionService.getExtendedState(myDimensionKey);
  }

  if (size != null && location != null) {
    frame.setLocation(location);
    frame.setSize(size);
    ((RootPaneContainer)frame).getRootPane().revalidate();
  }
  else {
    final IdeFrame ideFrame = WindowManagerEx.getInstanceEx().getIdeFrame(myProject);
    if (ideFrame != null) {
      frame.pack();
      frame.setBounds(ideFrame.suggestChildFrameBounds());
    }
  }

  if (extendedState == Frame.MAXIMIZED_BOTH && frame instanceof JFrame) {
    ((JFrame)frame).setExtendedState(extendedState);
  }
}
 
Example 9
Project: tools-idea   File: FrameWrapper.java   View source code 5 votes vote down vote up
private static void saveFrameState(String dimensionKey, Component frame) {
  DimensionService dimensionService = DimensionService.getInstance();
  if (dimensionKey == null || dimensionService == null) return;
  dimensionService.setLocation(dimensionKey, frame.getLocation());
  dimensionService.setSize(dimensionKey, frame.getSize());
  if (frame instanceof JFrame) {
    dimensionService.setExtendedState(dimensionKey, ((JFrame)frame).getExtendedState());
  }
}
 
Example 10
Project: tools-idea   File: DebuggerUIUtil.java   View source code 5 votes vote down vote up
public static void showValuePopup(@NotNull XFullValueEvaluator text, @NotNull MouseEvent event, @NotNull Project project) {
  final JTextArea textArea = new JTextArea("Evaluating...");
  final FullValueEvaluationCallbackImpl callback = new FullValueEvaluationCallbackImpl(textArea);
  text.startEvaluation(callback);
  textArea.setEditable(false);
  textArea.setBackground(HintUtil.INFORMATION_COLOR);
  textArea.setLineWrap(false);

  final JScrollPane component = ScrollPaneFactory.createScrollPane(textArea);
  final Dimension frameSize = WindowManager.getInstance().getFrame(project).getSize();
  Dimension size = DimensionService.getInstance().getSize(FULL_VALUE_POPUP_DIMENSION_KEY, project);
  if (size == null) {
    size = new Dimension(frameSize.width / 2, frameSize.height / 2);
  }

  component.setPreferredSize(size);
  component.setBorder(null);

  final JBPopup popup = JBPopupFactory.getInstance().createComponentPopupBuilder(component, null)
    .setResizable(true)
    .setMovable(true)
    .setDimensionServiceKey(project, FULL_VALUE_POPUP_DIMENSION_KEY, false)
    .setRequestFocus(false)
    .setCancelCallback(new Computable<Boolean>() {
      @Override
      public Boolean compute() {
        callback.setObsolete();
        return true;
      }
    })
    .createPopup();
  final Component parentComponent = event.getComponent();
  RelativePoint point = new RelativePoint(parentComponent, new Point(event.getX()-size.width, event.getY()-size.height));
  popup.show(point);
}
 
Example 11
Project: tools-idea   File: PopupPositionManager.java   View source code 5 votes vote down vote up
protected static Dimension getPopupSize(final JBPopup popup) {
  Dimension size = null;
  if (popup instanceof AbstractPopup) {
    final String dimensionKey = ((AbstractPopup)popup).getDimensionServiceKey();
    if (dimensionKey != null) {
      size = DimensionService.getInstance().getSize(dimensionKey);
    }
  }

  if (size == null) {
    size = popup.getContent().getPreferredSize();
  }

  return size;
}
 
Example 12
Project: ali-idea-plugin   File: MyDialog.java   View source code 5 votes vote down vote up
public void dispose() {
    if(dimensionKey != null) {
        DimensionService.getInstance().setSize(dimensionKey, getSize());
        DimensionService.getInstance().setLocation(dimensionKey, getLocation());
    }
    super.dispose();
}
 
Example 13
Project: consulo   File: PopupPositionManager.java   View source code 5 votes vote down vote up
public static Dimension getPopupSize(final JBPopup popup) {
  Dimension size = null;
  if (popup instanceof AbstractPopup) {
    final String dimensionKey = ((AbstractPopup)popup).getDimensionServiceKey();
    if (dimensionKey != null) {
      size = DimensionService.getInstance().getSize(dimensionKey);
    }
  }

  if (size == null) {
    size = popup.getContent().getPreferredSize();
  }

  return size;
}
 
Example 14
Project: consulo   File: FlatWelcomeFrame.java   View source code 5 votes vote down vote up
@RequiredDispatchThread
public FlatWelcomeFrame() {
  final JRootPane rootPane = getRootPane();
  myScreen = new FlatWelcomeScreen(this);

  final IdeGlassPaneImpl glassPane = new IdeGlassPaneImpl(rootPane);

  setGlassPane(glassPane);
  glassPane.setVisible(false);
  //setUndecorated(true);
  setContentPane(myScreen);
  setDefaultTitle();
  AppUIUtil.updateWindowIcon(this);
  UIUtil.resetRootPaneAppearance(rootPane);
  setSize(TargetAWT.to(WelcomeFrameManager.getDefaultWindowSize()));
  setResizable(false);
  Point location = DimensionService.getInstance().getLocationNoRealKey(WelcomeFrame.DIMENSION_KEY);
  Rectangle screenBounds = ScreenUtil.getScreenRectangle(location != null ? location : new Point(0, 0));
  setLocation(new Point(screenBounds.x + (screenBounds.width - getWidth()) / 2, screenBounds.y + (screenBounds.height - getHeight()) / 3));

  ProjectManager.getInstance().addProjectManagerListener(new ProjectManagerAdapter() {
    @Override
    public void projectOpened(Project project) {
      Disposer.dispose(FlatWelcomeFrame.this);
    }
  }, this);

  myBalloonLayout = new WelcomeDesktopBalloonLayoutImpl(rootPane, JBUI.insets(8), myScreen.getMainWelcomePanel().myEventListener, myScreen.getMainWelcomePanel().myEventLocation);

  setupCloseAction(this);
  MnemonicHelper.init(this);
  Disposer.register(ApplicationManager.getApplication(), this);
}
 
Example 15
Project: intellij-ce-playground   File: WelcomeFrame.java   View source code 4 votes vote down vote up
private static void saveLocation(Rectangle location) {
  Point middle = new Point(location.x + location.width / 2, location.y = location.height / 2);
  DimensionService.getInstance().setLocation(DIMENSION_KEY, middle, null);
}
 
Example 16
Project: intellij-ce-playground   File: GridCellImpl.java   View source code 4 votes vote down vote up
@Nullable
public Point getLocation() {
  return DimensionService.getInstance().getLocation(getDimensionKey(), myContext.getProject());
}
 
Example 17
Project: intellij-ce-playground   File: GridCellImpl.java   View source code 4 votes vote down vote up
@Nullable
public Dimension getSize() {
  return DimensionService.getInstance().getSize(getDimensionKey(), myContext.getProject());
}
 
Example 18
Project: tools-idea   File: WelcomeFrame.java   View source code 4 votes vote down vote up
private static void saveLocation(Rectangle location) {
  Point middle = new Point(location.x + location.width / 2, location.y = location.height / 2);
  DimensionService.getInstance().setLocation(DIMENSION_KEY, middle, null);
}
 
Example 19
Project: tools-idea   File: GridCellImpl.java   View source code 4 votes vote down vote up
@Nullable
public Point getLocation() {
  return DimensionService.getInstance().getLocation(getDimensionKey(), myContext.getProject());
}
 
Example 20
Project: tools-idea   File: GridCellImpl.java   View source code 4 votes vote down vote up
@Nullable
public Dimension getSize() {
  return DimensionService.getInstance().getSize(getDimensionKey(), myContext.getProject());
}
 
Example 21
Project: tools-idea   File: ConfigureTemplatesDialog.java   View source code 4 votes vote down vote up
private void initSize(){
  Dimension size = DimensionService.getInstance().getSize(DIMENSION_KEY, getProject());
  if (size == null){
    DimensionService.getInstance().setSize(DIMENSION_KEY, new Dimension(700, 500), getProject());
  }
}
 
Example 22
Project: consulo   File: GridCellImpl.java   View source code 4 votes vote down vote up
@Nullable
public Point getLocation() {
  return DimensionService.getInstance().getLocation(getDimensionKey(), myContext.getProject());
}
 
Example 23
Project: consulo   File: GridCellImpl.java   View source code 4 votes vote down vote up
@Nullable
public Dimension getSize() {
  return DimensionService.getInstance().getSize(getDimensionKey(), myContext.getProject());
}
 
Example 24
Project: consulo   File: ConfigureTemplatesDialog.java   View source code 4 votes vote down vote up
private void initSize(){
  Dimension size = DimensionService.getInstance().getSize(DIMENSION_KEY, getProject());
  if (size == null){
    DimensionService.getInstance().setSize(DIMENSION_KEY, new Dimension(700, 500), getProject());
  }
}
 
Example 25
Project: consulo   File: FlatWelcomeFrame.java   View source code 4 votes vote down vote up
public static void saveLocation(Rectangle location) {
  Point middle = new Point(location.x + location.width / 2, location.y = location.height / 2);
  DimensionService.getInstance().setLocationNoRealKey(WelcomeFrame.DIMENSION_KEY, middle);
}