use of com.intellij.openapi.wm.impl.IdeFrameImpl in project intellij-community by JetBrains.
the class GuiTestUtil method waitForIdeToStart.
// Called by IdeTestApplication via reflection.
@SuppressWarnings("UnusedDeclaration")
public static void waitForIdeToStart() {
GuiActionRunner.executeInEDT(false);
Robot robot = null;
try {
robot = BasicRobot.robotWithCurrentAwtHierarchy();
final MyProjectManagerListener listener = new MyProjectManagerListener();
//[ACCEPT IntelliJ IDEA Privacy Policy Agreement]
acceptAgreementIfNeeded(robot);
findFrame(new GenericTypeMatcher<Frame>(Frame.class) {
@Override
protected boolean isMatching(@NotNull Frame frame) {
if (frame instanceof IdeFrame) {
if (frame instanceof IdeFrameImpl) {
listener.myActive = true;
ProjectManager.getInstance().addProjectManagerListener(listener);
}
return true;
}
return false;
}
}).withTimeout(LONG_TIMEOUT.duration()).using(robot);
if (listener.myActive) {
Pause.pause(new Condition("Project to be opened") {
@Override
public boolean test() {
boolean notified = listener.myNotified;
if (notified) {
ProgressManager progressManager = ProgressManager.getInstance();
boolean isIdle = !progressManager.hasModalProgressIndicator() && !progressManager.hasProgressIndicator() && !progressManager.hasUnsafeProgressIndicator();
if (isIdle) {
ProjectManager.getInstance().removeProjectManagerListener(listener);
}
return isIdle;
}
return false;
}
}, LONG_TIMEOUT);
}
} finally {
GuiActionRunner.executeInEDT(true);
if (robot != null) {
robot.cleanUpWithoutDisposingWindows();
}
}
}
use of com.intellij.openapi.wm.impl.IdeFrameImpl in project intellij-community by JetBrains.
the class CustomActionsSchema method initActionIcons.
private void initActionIcons() {
ActionManager actionManager = ActionManager.getInstance();
for (String actionId : myIconCustomizations.keySet()) {
final AnAction anAction = actionManager.getAction(actionId);
if (anAction != null) {
Icon icon;
final String iconPath = myIconCustomizations.get(actionId);
if (iconPath != null && new File(FileUtil.toSystemDependentName(iconPath)).exists()) {
Image image = null;
try {
image = ImageLoader.loadFromStream(VfsUtilCore.convertToURL(VfsUtil.pathToUrl(iconPath)).openStream());
} catch (IOException e) {
LOG.debug(e);
}
icon = image == null ? null : new JBImageIcon(image);
} else {
icon = AllIcons.Toolbar.Unknown;
}
anAction.getTemplatePresentation().setIcon(icon);
anAction.getTemplatePresentation().setDisabledIcon(IconLoader.getDisabledIcon(icon));
anAction.setDefaultIcon(false);
}
}
final IdeFrameImpl frame = WindowManagerEx.getInstanceEx().getFrame(null);
if (frame != null) {
frame.updateView();
}
}
use of com.intellij.openapi.wm.impl.IdeFrameImpl in project android by JetBrains.
the class GuiTests method waitForIdeToStart.
// Called by IdeTestApplication via reflection.
@SuppressWarnings("UnusedDeclaration")
public static void waitForIdeToStart() {
GuiActionRunner.executeInEDT(false);
Robot robot = null;
try {
robot = BasicRobot.robotWithCurrentAwtHierarchy();
MyProjectManagerListener listener = new MyProjectManagerListener();
findFrame(new GenericTypeMatcher<Frame>(Frame.class) {
@Override
protected boolean isMatching(@NotNull Frame frame) {
if (frame instanceof IdeFrame) {
if (frame instanceof IdeFrameImpl) {
listener.myActive = true;
ProjectManager.getInstance().addProjectManagerListener(listener);
}
return true;
}
return false;
}
}).withTimeout(TimeUnit.MINUTES.toMillis(2)).using(robot);
// we attempt to clear here. All other events, including those posted by the Robot, will go through the IDE event queue.
try {
if (SYSTEM_EVENT_QUEUE.peekEvent() != null) {
SYSTEM_EVENT_QUEUE.getNextEvent();
}
} catch (InterruptedException ex) {
// Ignored.
}
if (listener.myActive) {
Wait.seconds(1).expecting("project to be opened").until(() -> {
boolean notified = listener.myNotified;
if (notified) {
ProgressManager progressManager = ProgressManager.getInstance();
boolean isIdle = !progressManager.hasModalProgressIndicator() && !progressManager.hasProgressIndicator() && !progressManager.hasUnsafeProgressIndicator();
if (isIdle) {
ProjectManager.getInstance().removeProjectManagerListener(listener);
}
return isIdle;
}
return false;
});
}
} finally {
GuiActionRunner.executeInEDT(true);
if (robot != null) {
robot.cleanUpWithoutDisposingWindows();
}
}
}
use of com.intellij.openapi.wm.impl.IdeFrameImpl in project intellij-plugins by JetBrains.
the class IDEAFacade method getProject.
@Nullable
public static Project getProject(Component component) {
Project res = null;
if (component != null) {
res = (Project) getData(component, CommonDataKeys.PROJECT.getName());
} else {
IdeFrame[] frames = WindowManagerEx.getInstanceEx().getAllProjectFrames();
for (IdeFrame frame : frames) {
final IdeFrameImpl eachFrame = (IdeFrameImpl) frame;
if (eachFrame.isActive()) {
res = eachFrame.getProject();
if (res != null)
break;
}
}
}
if (res == null) {
Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
res = openProjects.length > 0 ? openProjects[0] : null;
}
return res;
}
use of com.intellij.openapi.wm.impl.IdeFrameImpl in project intellij-community by JetBrains.
the class SearchEverywhereAction method actionPerformed.
public void actionPerformed(AnActionEvent e, MouseEvent me) {
if (myBalloon != null && myBalloon.isVisible()) {
showAll.set(!showAll.get());
myNonProjectCheckBox.setSelected(showAll.get());
// myPopupField.getTextEditor().setBackground(showAll.get() ? new JBColor(new Color(0xffffe4), new Color(0x494539)) : UIUtil.getTextFieldBackground());
rebuildList(myPopupField.getText());
return;
}
myCurrentWorker = ActionCallback.DONE;
if (e != null) {
myEditor = e.getData(CommonDataKeys.EDITOR);
myFileEditor = e.getData(PlatformDataKeys.FILE_EDITOR);
myFile = e.getData(CommonDataKeys.PSI_FILE);
}
if (e == null && myFocusOwner != null) {
e = AnActionEvent.createFromAnAction(this, me, ActionPlaces.UNKNOWN, DataManager.getInstance().getDataContext(myFocusOwner));
}
if (e == null)
return;
final Project project = e.getProject();
if (project == null)
return;
//noinspection SSBasedInspection
SwingUtilities.invokeLater(() -> LookupManager.getInstance(project).hideActiveLookup());
updateComponents();
myContextComponent = PlatformDataKeys.CONTEXT_COMPONENT.getData(e.getDataContext());
Window wnd = myContextComponent != null ? SwingUtilities.windowForComponent(myContextComponent) : KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
if (wnd == null && myContextComponent instanceof Window) {
wnd = (Window) myContextComponent;
}
if (wnd == null || wnd.getParent() != null)
return;
myActionEvent = e;
if (myPopupField != null) {
Disposer.dispose(myPopupField);
}
myPopupField = new MySearchTextField();
myPopupField.getTextEditor().addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
myHistoryIndex = 0;
myHistoryItem = null;
}
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_SHIFT) {
myList.repaint();
}
}
@Override
public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_SHIFT) {
myList.repaint();
}
}
});
initSearchField(myPopupField);
myPopupField.setOpaque(false);
final JTextField editor = myPopupField.getTextEditor();
editor.setColumns(SEARCH_FIELD_COLUMNS);
final JPanel panel = new JPanel(new BorderLayout()) {
@Override
protected void paintComponent(Graphics g) {
final Gradient gradient = getGradientColors();
((Graphics2D) g).setPaint(new GradientPaint(0, 0, gradient.getStartColor(), 0, getHeight(), gradient.getEndColor()));
g.fillRect(0, 0, getWidth(), getHeight());
}
};
final JLabel title = new JLabel(" Search Everywhere: ");
final JPanel topPanel = new NonOpaquePanel(new BorderLayout());
title.setForeground(new JBColor(Gray._240, Gray._200));
if (SystemInfo.isMac) {
title.setFont(title.getFont().deriveFont(Font.BOLD, title.getFont().getSize() - 1f));
} else {
title.setFont(title.getFont().deriveFont(Font.BOLD));
}
topPanel.add(title, BorderLayout.WEST);
final JPanel controls = new JPanel(new BorderLayout());
controls.setOpaque(false);
final JLabel settings = new JLabel(AllIcons.General.SearchEverywhereGear);
new ClickListener() {
@Override
public boolean onClick(@NotNull MouseEvent event, int clickCount) {
showSettings();
return true;
}
}.installOn(settings);
controls.add(settings, BorderLayout.EAST);
myNonProjectCheckBox.setForeground(new JBColor(Gray._240, Gray._200));
myNonProjectCheckBox.setText("Include non-project items (" + getShortcut() + ") ");
if (!NonProjectScopeDisablerEP.isSearchInNonProjectDisabled()) {
controls.add(myNonProjectCheckBox, BorderLayout.WEST);
}
topPanel.add(controls, BorderLayout.EAST);
panel.add(myPopupField, BorderLayout.CENTER);
panel.add(topPanel, BorderLayout.NORTH);
panel.setBorder(IdeBorderFactory.createEmptyBorder(3, 5, 4, 5));
DataManager.registerDataProvider(panel, this);
final ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(panel, editor);
myBalloon = builder.setCancelOnClickOutside(true).setModalContext(false).setRequestFocus(true).setCancelCallback(() -> !mySkipFocusGain).createPopup();
myBalloon.getContent().setBorder(JBUI.Borders.empty());
final Window window = WindowManager.getInstance().suggestParentWindow(project);
project.getMessageBus().connect(myBalloon).subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() {
@Override
public void enteredDumbMode() {
}
@Override
public void exitDumbMode() {
ApplicationManager.getApplication().invokeLater(() -> rebuildList(myPopupField.getText()));
}
});
Component parent = UIUtil.findUltimateParent(window);
registerDataProvider(panel, project);
final RelativePoint showPoint;
if (parent != null) {
int height = UISettings.getInstance().getShowMainToolbar() ? 135 : 115;
if (parent instanceof IdeFrameImpl && ((IdeFrameImpl) parent).isInFullScreen()) {
height -= 20;
}
showPoint = new RelativePoint(parent, new Point((parent.getSize().width - panel.getPreferredSize().width) / 2, height));
} else {
showPoint = JBPopupFactory.getInstance().guessBestPopupLocation(e.getDataContext());
}
myList.setFont(UIUtil.getListFont());
myBalloon.show(showPoint);
initSearchActions(myBalloon, myPopupField);
IdeFocusManager focusManager = IdeFocusManager.getInstance(project);
focusManager.requestFocus(editor, true);
FeatureUsageTracker.getInstance().triggerFeatureUsed(IdeActions.ACTION_SEARCH_EVERYWHERE);
}
Aggregations