Search in sources :

Example 1 with IdeFrame

use of com.intellij.openapi.wm.IdeFrame in project plugins by kiteco.

the class KiteProjectComponent method projectOpened.

@Override
public void projectOpened() {
    // thread safety assumption for projectOpened + projectClosed: I'm assuming that each
    //   will only only be called one at a time.
    IdeFrame projectFrame = WindowManagerEx.getInstanceEx().findFrameFor(m_project);
    removeWindowFocusListener();
    m_projectWindowFocusListened = SwingUtilities.windowForComponent(projectFrame.getComponent());
    m_projectWindowFocusListened.addWindowFocusListener(m_windowFocusListener);
}
Also used : IdeFrame(com.intellij.openapi.wm.IdeFrame)

Example 2 with IdeFrame

use of com.intellij.openapi.wm.IdeFrame in project intellij-community by JetBrains.

the class SvnAuthenticationNotifier method showAlreadyChecking.

private boolean showAlreadyChecking() {
    final IdeFrame frameFor = WindowManagerEx.getInstanceEx().findFrameFor(myProject);
    if (frameFor != null) {
        final JComponent component = frameFor.getComponent();
        Point point = component.getMousePosition();
        if (point == null) {
            point = new Point((int) (component.getWidth() * 0.7), 0);
        }
        SwingUtilities.convertPointToScreen(point, component);
        JBPopupFactory.getInstance().createHtmlTextBalloonBuilder("Already checking...", MessageType.WARNING, null).createBalloon().show(new RelativePoint(point), Balloon.Position.below);
    }
    return false;
}
Also used : RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint) IdeFrame(com.intellij.openapi.wm.IdeFrame)

Example 3 with IdeFrame

use of com.intellij.openapi.wm.IdeFrame in project intellij-community by JetBrains.

the class BuildManager method getContextProject.

@Nullable
private Project getContextProject(@Nullable Window window) {
    final List<Project> openProjects = getOpenProjects();
    if (openProjects.isEmpty()) {
        return null;
    }
    if (openProjects.size() == 1) {
        return openProjects.get(0);
    }
    if (window == null) {
        window = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
        if (window == null) {
            return null;
        }
    }
    Component comp = window;
    while (true) {
        final Container _parent = comp.getParent();
        if (_parent == null) {
            break;
        }
        comp = _parent;
    }
    Project project = null;
    if (comp instanceof IdeFrame) {
        project = ((IdeFrame) comp).getProject();
    }
    if (project == null) {
        project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(comp));
    }
    return isValidProject(project) ? project : null;
}
Also used : Project(com.intellij.openapi.project.Project) IdeFrame(com.intellij.openapi.wm.IdeFrame) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with IdeFrame

use of com.intellij.openapi.wm.IdeFrame in project intellij-community by JetBrains.

the class ExtractCodeStyleAction method reportResult.

public void reportResult(final ValuesExtractionResult forSelection, final Project project, final CodeStyleSettings cloneSettings, final PsiFile file, final Map<Value, Object> backup) {
    final Balloon balloon = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder("Formatting Options were extracted<br/><a href=\"apply\">Apply</a> <a href=\"details\">Details...</a>", MessageType.INFO, new HyperlinkListener() {

        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                boolean apply = "apply".equals(e.getDescription());
                ExtractedSettingsDialog myDialog = null;
                if (!apply) {
                    final List<Value> values = forSelection.getValues();
                    final LanguageCodeStyleSettingsProvider[] providers = Extensions.getExtensions(LanguageCodeStyleSettingsProvider.EP_NAME);
                    Language language = file.getLanguage();
                    CodeStyleSettingsNameProvider nameProvider = new CodeStyleSettingsNameProvider();
                    for (final LanguageCodeStyleSettingsProvider provider : providers) {
                        Language target = provider.getLanguage();
                        if (target.equals(language)) {
                            //this is our language
                            nameProvider.addSettings(provider);
                            myDialog = new ExtractedSettingsDialog(project, nameProvider, values);
                            apply = myDialog.showAndGet();
                            break;
                        }
                    }
                }
                if (apply && myDialog != null) {
                    //create new settings named after the file
                    final ExtractedSettingsDialog finalMyDialog = myDialog;
                    forSelection.applyConditioned(value -> finalMyDialog.valueIsSelectedInTree(value), backup);
                    CodeStyleScheme derivedScheme = CodeStyleSchemes.getInstance().createNewScheme("Derived from " + file.getName(), null);
                    derivedScheme.getCodeStyleSettings().copyFrom(cloneSettings);
                    CodeStyleSchemes.getInstance().addScheme(derivedScheme);
                    CodeStyleSchemesImpl.getSchemeManager().setCurrent(derivedScheme);
                    CodeStyleSettingsManager.getInstance(project).PREFERRED_PROJECT_CODE_STYLE = derivedScheme.getName();
                }
            }
        }
    }).setDisposable(ApplicationManager.getApplication()).setShowCallout(false).setFadeoutTime(0).setShowCallout(false).setAnimationCycle(0).setHideOnClickOutside(false).setHideOnKeyOutside(false).setCloseButtonEnabled(true).setHideOnLinkClick(true).createBalloon();
    ApplicationManager.getApplication().invokeLater(() -> {
        Window window = WindowManager.getInstance().getFrame(project);
        if (window == null) {
            window = JOptionPane.getRootFrame();
        }
        if (window instanceof IdeFrame) {
            BalloonLayout layout = ((IdeFrame) window).getBalloonLayout();
            if (layout != null) {
                layout.add(balloon);
            }
        }
    });
}
Also used : Language(com.intellij.lang.Language) IdeFrame(com.intellij.openapi.wm.IdeFrame) MessageType(com.intellij.openapi.ui.MessageType) HyperlinkEvent(javax.swing.event.HyperlinkEvent) com.intellij.psi.codeStyle(com.intellij.psi.codeStyle) VirtualFile(com.intellij.openapi.vfs.VirtualFile) CodeStyleDeriveProcessor(com.intellij.psi.codeStyle.extractor.processor.CodeStyleDeriveProcessor) LangCodeStyleExtractor(com.intellij.psi.codeStyle.extractor.differ.LangCodeStyleExtractor) Value(com.intellij.psi.codeStyle.extractor.values.Value) PsiManager(com.intellij.psi.PsiManager) Balloon(com.intellij.openapi.ui.popup.Balloon) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) Task(com.intellij.openapi.progress.Task) BalloonLayout(com.intellij.ui.BalloonLayout) Map(java.util.Map) Project(com.intellij.openapi.project.Project) PsiFile(com.intellij.psi.PsiFile) DumbAware(com.intellij.openapi.project.DumbAware) PsiDocumentManager(com.intellij.psi.PsiDocumentManager) ExtractedSettingsDialog(com.intellij.psi.codeStyle.extractor.ui.ExtractedSettingsDialog) Extensions(com.intellij.openapi.extensions.Extensions) ProgressManager(com.intellij.openapi.progress.ProgressManager) HyperlinkListener(javax.swing.event.HyperlinkListener) WindowManager(com.intellij.openapi.wm.WindowManager) Editor(com.intellij.openapi.editor.Editor) java.awt(java.awt) com.intellij.openapi.actionSystem(com.intellij.openapi.actionSystem) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) List(java.util.List) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) GenProcessor(com.intellij.psi.codeStyle.extractor.processor.GenProcessor) CodeStyleSchemesImpl(com.intellij.psi.impl.source.codeStyle.CodeStyleSchemesImpl) LanguageFormatting(com.intellij.lang.LanguageFormatting) ApplicationManager(com.intellij.openapi.application.ApplicationManager) CodeStyleSettingsNameProvider(com.intellij.psi.codeStyle.extractor.ui.CodeStyleSettingsNameProvider) ValuesExtractionResult(com.intellij.psi.codeStyle.extractor.values.ValuesExtractionResult) NotNull(org.jetbrains.annotations.NotNull) Condition(com.intellij.openapi.util.Condition) javax.swing(javax.swing) HyperlinkEvent(javax.swing.event.HyperlinkEvent) ExtractedSettingsDialog(com.intellij.psi.codeStyle.extractor.ui.ExtractedSettingsDialog) Balloon(com.intellij.openapi.ui.popup.Balloon) CodeStyleSettingsNameProvider(com.intellij.psi.codeStyle.extractor.ui.CodeStyleSettingsNameProvider) IdeFrame(com.intellij.openapi.wm.IdeFrame) BalloonLayout(com.intellij.ui.BalloonLayout) Language(com.intellij.lang.Language) HyperlinkListener(javax.swing.event.HyperlinkListener) List(java.util.List)

Example 5 with IdeFrame

use of com.intellij.openapi.wm.IdeFrame in project intellij-community by JetBrains.

the class ComboBoxAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    Project project = e.getProject();
    if (project == null)
        return;
    JFrame frame = WindowManager.getInstance().getFrame(project);
    if (!(frame instanceof IdeFrame))
        return;
    ListPopup popup = createActionPopup(e.getDataContext(), ((IdeFrame) frame).getComponent(), null);
    popup.showCenteredInCurrentWindow(project);
}
Also used : Project(com.intellij.openapi.project.Project) ListPopup(com.intellij.openapi.ui.popup.ListPopup) IdeFrame(com.intellij.openapi.wm.IdeFrame)

Aggregations

IdeFrame (com.intellij.openapi.wm.IdeFrame)49 Project (com.intellij.openapi.project.Project)13 Nullable (org.jetbrains.annotations.Nullable)7 Balloon (com.intellij.openapi.ui.popup.Balloon)5 IdeFocusManager (com.intellij.openapi.wm.IdeFocusManager)5 NotNull (org.jetbrains.annotations.NotNull)5 ProgressManager (com.intellij.openapi.progress.ProgressManager)4 MessageType (com.intellij.openapi.ui.MessageType)3 StatusBarEx (com.intellij.openapi.wm.ex.StatusBarEx)3 IdeFrameImpl (com.intellij.openapi.wm.impl.IdeFrameImpl)3 RelativePoint (com.intellij.ui.awt.RelativePoint)3 HyperlinkEvent (javax.swing.event.HyperlinkEvent)3 Application (com.intellij.openapi.application.Application)2 ApplicationActivationListener (com.intellij.openapi.application.ApplicationActivationListener)2 ApplicationManager (com.intellij.openapi.application.ApplicationManager)2 ModalityState (com.intellij.openapi.application.ModalityState)2 Extensions (com.intellij.openapi.extensions.Extensions)2 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 Ref (com.intellij.openapi.util.Ref)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2