use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class RunnerContentUi method detachTo.
@Override
public ActionCallback detachTo(int window, GridCell cell) {
if (myOriginal != null) {
return myOriginal.detachTo(window, cell);
}
RunnerContentUi target = null;
if (window > 0) {
for (RunnerContentUi child : myChildren) {
if (child.myWindow == window) {
target = child;
break;
}
}
}
final GridCellImpl gridCell = (GridCellImpl) cell;
final Content[] contents = gridCell.getContents();
storeDefaultIndices(contents);
for (Content content : contents) {
content.putUserData(RunnerLayout.DROP_INDEX, getStateFor(content).getTab().getIndex());
}
Dimension size = gridCell.getSize();
if (size == null) {
size = JBUI.size(200, 200);
}
final DockableGrid content = new DockableGrid(null, null, size, Arrays.asList(contents), window);
if (target != null) {
target.add(content, null);
} else {
Point location = gridCell.getLocation();
if (location == null) {
location = getComponent().getLocationOnScreen();
}
location.translate(size.width / 2, size.height / 2);
getDockManager().createNewDockContainerFor(content, new RelativePoint(location));
}
return ActionCallback.DONE;
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class RunnerContentUi method add.
@Override
public void add(@NotNull DockableContent dockable, RelativePoint dropTarget) {
final DockableGrid dockableGrid = (DockableGrid) dockable;
final RunnerContentUi prev = dockableGrid.getRunnerUi();
saveUiState();
final List<Content> contents = dockableGrid.getContents();
final boolean wasRestoring = myOriginal != null && myOriginal.isStateBeingRestored();
setStateIsBeingRestored(true, this);
try {
final Point point = dropTarget != null ? dropTarget.getPoint(myComponent) : null;
boolean hadGrid = !myTabs.shouldAddToGlobal(point);
for (Content content : contents) {
final View view = getStateFor(content);
if (view.isMinimizedInGrid())
continue;
prev.myManager.removeContent(content, false);
myManager.removeContent(content, false);
if (hadGrid && !wasRestoring) {
view.assignTab(getTabFor(getSelectedGrid()));
view.setPlaceInGrid(calcPlaceInGrid(point, myComponent.getSize()));
} else if (contents.size() == 1 && !wasRestoring) {
view.assignTab(null);
view.setPlaceInGrid(myLayoutSettings.getDefaultGridPlace(content));
}
view.setWindow(myWindow);
myManager.addContent(content);
}
} finally {
setStateIsBeingRestored(false, this);
}
saveUiState();
updateTabsUI(true);
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class VcsCommitInfoBalloon method showCommitDetails.
public void showCommitDetails() {
if (myBalloon == null || !myBalloon.isVisible()) {
createNewCommitInfoBalloon();
myBalloon.show(new RelativePoint(calculateBestPopupLocation()));
}
updateCommitDetails();
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class AnActionButton method getPreferredPopupPoint.
public final RelativePoint getPreferredPopupPoint() {
Container c = myContextComponent;
ActionToolbar toolbar = null;
while ((c = c.getParent()) != null) {
if (c instanceof JComponent && (toolbar = (ActionToolbar) ((JComponent) c).getClientProperty(ActionToolbar.ACTION_TOOLBAR_PROPERTY_KEY)) != null) {
break;
}
}
if (toolbar instanceof JComponent) {
for (Component comp : ((JComponent) toolbar).getComponents()) {
if (comp instanceof ActionButtonComponent) {
if (comp instanceof AnActionHolder) {
if (((AnActionHolder) comp).getAction() == this) {
return new RelativePoint(comp.getParent(), new Point(comp.getX(), comp.getY() + comp.getHeight()));
}
}
}
}
}
return null;
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class PopupUtil method showBalloonForComponent.
public static void showBalloonForComponent(@NotNull Component component, @NotNull final String message, final MessageType type, final boolean atTop, @Nullable final Disposable disposable) {
final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
if (popupFactory == null)
return;
BalloonBuilder balloonBuilder = popupFactory.createHtmlTextBalloonBuilder(message, type, null);
balloonBuilder.setDisposable(disposable == null ? ApplicationManager.getApplication() : disposable);
Balloon balloon = balloonBuilder.createBalloon();
Dimension size = component.getSize();
Balloon.Position position;
int x;
int y;
if (size == null) {
x = y = 0;
position = Balloon.Position.above;
} else {
x = Math.min(10, size.width / 2);
y = size.height;
position = Balloon.Position.below;
}
balloon.show(new RelativePoint(component, new Point(x, y)), position);
}
Aggregations