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); }
@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 )); }
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; }
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(); } }
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); } }
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)); } }
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); } }
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()); } }
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); }
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; }
public void dispose() { if(dimensionKey != null) { DimensionService.getInstance().setSize(dimensionKey, getSize()); DimensionService.getInstance().setLocation(dimensionKey, getLocation()); } super.dispose(); }
@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); }
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); }
@Nullable public Point getLocation() { return DimensionService.getInstance().getLocation(getDimensionKey(), myContext.getProject()); }
@Nullable public Dimension getSize() { return DimensionService.getInstance().getSize(getDimensionKey(), myContext.getProject()); }
private void initSize(){ Dimension size = DimensionService.getInstance().getSize(DIMENSION_KEY, getProject()); if (size == null){ DimensionService.getInstance().setSize(DIMENSION_KEY, new Dimension(700, 500), getProject()); } }
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); }