javax.swing.text.html.ImageView#com.intellij.openapi.wm.ex.WindowManagerEx源码实例Demo

下面列出了javax.swing.text.html.ImageView#com.intellij.openapi.wm.ex.WindowManagerEx 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: consulo   文件: WelcomePopupAction.java
protected void showPopup(DataContext context, ListPopup popup, JComponent contextComponent) {
  Component focusedComponent = contextComponent != null ? contextComponent : context.getData(PlatformDataKeys.CONTEXT_COMPONENT);
  if (focusedComponent != null) {
    if (popup instanceof PopupFactoryImpl.ActionGroupPopup && focusedComponent instanceof JLabel) {
      ((PopupFactoryImpl.ActionGroupPopup)popup).showUnderneathOfLabel((JLabel)focusedComponent);
    } else {
      popup.showUnderneathOf(focusedComponent);
    }
  }
  else {
    Rectangle r;
    int x;
    int y;
    focusedComponent = WindowManagerEx.getInstanceEx().getFocusedComponent((Project)null);
    r = WindowManagerEx.getInstanceEx().getScreenBounds();
    x = r.x + r.width / 2;
    y = r.y + r.height / 2;
    Point point = new Point(x, y);
    SwingUtilities.convertPointToScreen(point, focusedComponent.getParent());

    popup.showInScreenCoordinates(focusedComponent.getParent(), point);
  }
}
 
源代码2 项目: consulo   文件: IdeMenuBar.java
public IdeMenuBar(ActionManager actionManager, DataManager dataManager) {
  myActionManager = actionManager;
  myTimerListener = new MyTimerListener();
  myVisibleActions = new ArrayList<AnAction>();
  myNewVisibleActions = new ArrayList<AnAction>();
  myPresentationFactory = new MenuItemPresentationFactory();
  myDataManager = dataManager;

  if (WindowManagerEx.getInstanceEx().isFloatingMenuBarSupported()) {
    myAnimator = new MyAnimator();
    myActivationWatcher = new Timer(100, new MyActionListener());
    myClockPanel = new ClockPanel();
    myButton = new MyExitFullScreenButton();
    add(myClockPanel);
    add(myButton);
    addPropertyChangeListener(WindowManagerEx.FULL_SCREEN, evt -> updateState());
    addMouseListener(new MyMouseListener());
  }
  else {
    myAnimator = null;
    myActivationWatcher = null;
    myClockPanel = null;
    myButton = null;
  }
}
 
public static void showNotification() {

    if (notificationHasBeenShown) {
      return;
    }

    consulo.ui.Window window = WindowManagerEx.getInstanceEx().getMostRecentFocusedWindow();
    if(!KeyboardSettingsExternalizable.isSupportedKeyboardLayout(TargetAWT.to(window))) {
      return;
    }

    MyNotificationListener listener = new MyNotificationListener();

    Notifications.Bus.notify(createNotification(LOCALIZATION_GROUP_DISPLAY_ID, listener));
    notificationHasBeenShown = true;
  }
 
public static Notification createNotification(@Nonnull final String groupDisplayId, @Nullable NotificationListener listener) {

    final String productName = ApplicationNamesInfo.getInstance().getProductName();

    Window recentFocusedWindow = TargetAWT.to(WindowManagerEx.getInstanceEx().getMostRecentFocusedWindow());

    String text = "<html>We have found out that you are using a non-english keyboard layout. You can <a href='enable'>enable</a> smart layout support for " +
                  KeyboardSettingsExternalizable.getDisplayLanguageNameForComponent(recentFocusedWindow) +
                  " language." +
                  "You can change this option in the settings of " +
                  productName +
                  " <a href='settings'>more...</a></html>";

    String title = "Enable smart keyboard internalization for " + productName + ".";

    return new Notification(groupDisplayId, title, text, NotificationType.INFORMATION, listener);
  }
 
@Override
public void hyperlinkUpdate(@Nonnull Notification notification, @Nonnull HyperlinkEvent event) {
  if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
    final String description = event.getDescription();
    if ("enable".equals(description)) {
      KeyboardSettingsExternalizable.getInstance().setNonEnglishKeyboardSupportEnabled(true);
    }
    else if ("settings".equals(description)) {
      final ShowSettingsUtil util = ShowSettingsUtil.getInstance();
      IdeFrame ideFrame = WindowManagerEx.getInstanceEx().findFrameFor(null);
      //util.editConfigurable((JFrame)ideFrame, new StatisticsConfigurable(true));
      util.showSettingsDialog(ideFrame.getProject(), KeymapPanel.class);
    }

    NotificationsConfiguration.getNotificationsConfiguration().changeSettings(LOCALIZATION_GROUP_DISPLAY_ID, NotificationDisplayType.NONE, false, false);
    notification.expire();
  }
}
 
源代码6 项目: consulo   文件: AbstractExpandableItemsHandler.java
private boolean noIntersections(Rectangle bounds) {
  Window owner = SwingUtilities.getWindowAncestor(myComponent);
  Window popup = SwingUtilities.getWindowAncestor(myTipComponent);
  Window focus = TargetAWT.to(WindowManagerEx.getInstanceEx().getMostRecentFocusedWindow());
  if (focus == owner.getOwner()) {
    focus = null; // do not check intersection with parent
  }
  boolean focused = SystemInfo.isWindows || owner.isFocused();
  for (Window other : owner.getOwnedWindows()) {
    if (!focused && !SystemInfo.isWindows) {
      focused = other.isFocused();
    }
    if (popup != other && other.isVisible() && bounds.x + 10 >= other.getX() && bounds.intersects(other.getBounds())) {
      return false;
    }
    if (focus == other) {
      focus = null; // already checked
    }
  }
  return focused && (focus == owner || focus == null || !owner.getBounds().intersects(focus.getBounds()));
}
 
源代码7 项目: consulo   文件: AbstractPopup.java
private Window updateMaskAndAlpha(Window window) {
  if (window == null) return null;

  if (!window.isDisplayable() || !window.isShowing()) return window;

  final WindowManagerEx wndManager = getWndManager();
  if (wndManager == null) return window;

  if (!wndManager.isAlphaModeEnabled(window)) return window;

  if (myAlpha != myLastAlpha) {
    wndManager.setAlphaModeRatio(window, myAlpha);
    myLastAlpha = myAlpha;
  }

  if (myMaskProvider != null) {
    final Dimension size = window.getSize();
    Shape mask = myMaskProvider.getMask(size);
    wndManager.setWindowMask(window, mask);
  }

  WindowManagerEx.WindowShadowMode mode = myShadowed ? WindowManagerEx.WindowShadowMode.NORMAL : WindowManagerEx.WindowShadowMode.DISABLED;
  WindowManagerEx.getInstanceEx().setWindowShadow(window, mode);

  return window;
}
 
源代码8 项目: consulo   文件: IJSwingUtilities.java
/**
 * @return true if window ancestor of component was most recent focused window and most recent focused component
 * in that window was descended from component
 */
public static boolean hasFocus2(Component component) {
  WindowManagerEx windowManager = WindowManagerEx.getInstanceEx();
  Window activeWindow=null;
  if (windowManager != null) {
    activeWindow = TargetAWT.to(windowManager.getMostRecentFocusedWindow());
  }
  if(activeWindow==null){
    return false;
  }
  Component focusedComponent = windowManager.getFocusedComponent(activeWindow);
  if (focusedComponent == null) {
    return false;
  }

  return SwingUtilities.isDescendingFrom(focusedComponent, component);
}
 
源代码9 项目: consulo   文件: DesktopToolWindowManagerImpl.java
private EditorsSplitters getSplittersToFocus() {
  WindowManagerEx windowManager = (WindowManagerEx)myWindowManager.get();

  Window activeWindow = TargetAWT.to(windowManager.getMostRecentFocusedWindow());

  if (activeWindow instanceof DesktopFloatingDecorator) {
    IdeFocusManager ideFocusManager = IdeFocusManager.findInstanceByComponent(activeWindow);
    IdeFrame lastFocusedFrame = ideFocusManager.getLastFocusedFrame();
    JComponent frameComponent = lastFocusedFrame != null ? lastFocusedFrame.getComponent() : null;
    Window lastFocusedWindow = frameComponent != null ? SwingUtilities.getWindowAncestor(frameComponent) : null;
    activeWindow = ObjectUtil.notNull(lastFocusedWindow, activeWindow);
  }

  FileEditorManagerEx fem = FileEditorManagerEx.getInstanceEx(myProject);
  EditorsSplitters splitters = activeWindow != null ? fem.getSplittersFor(activeWindow) : null;
  return splitters != null ? splitters : fem.getSplitters();
}
 
源代码10 项目: consulo   文件: DesktopFloatingDecorator.java
@Override
public final void show() {
  setFocusableWindowState(myInfo.isActive());

  super.show();
  final UISettings uiSettings = UISettings.getInstance();
  if (uiSettings.ENABLE_ALPHA_MODE) {
    final WindowManagerEx windowManager = WindowManagerEx.getInstanceEx();
    windowManager.setAlphaModeEnabled(this, true);
    if (myInfo.isActive()) {
      windowManager.setAlphaModeRatio(this, 0.0f);
    }
    else {
      windowManager.setAlphaModeRatio(this, uiSettings.ALPHA_MODE_RATIO);
    }
  }
  paint(getGraphics()); // This prevents annoying flick

  setFocusableWindowState(true);

  uiSettings.addUISettingsListener(myUISettingsListener, myDelayAlarm);
}
 
源代码11 项目: consulo   文件: DesktopFloatingDecorator.java
@Override
public void uiSettingsChanged(final UISettings uiSettings) {
  LOG.assertTrue(isDisplayable());
  LOG.assertTrue(isShowing());
  final WindowManagerEx windowManager = WindowManagerEx.getInstanceEx();
  myDelayAlarm.cancelAllRequests();
  if (uiSettings.ENABLE_ALPHA_MODE) {
    if (!myInfo.isActive()) {
      windowManager.setAlphaModeEnabled(DesktopFloatingDecorator.this, true);
      windowManager.setAlphaModeRatio(DesktopFloatingDecorator.this, uiSettings.ALPHA_MODE_RATIO);
    }
  }
  else {
    windowManager.setAlphaModeEnabled(DesktopFloatingDecorator.this, false);
  }
}
 
源代码12 项目: consulo   文件: LafManagerImpl.java
private static void fireUpdate() {

    UISettings.getInstance().fireUISettingsChanged();
    EditorFactory.getInstance().refreshAllEditors();

    Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
    for (Project openProject : openProjects) {
      FileStatusManager.getInstance(openProject).fileStatusesChanged();
      DaemonCodeAnalyzer.getInstance(openProject).restart();
    }
    for (IdeFrame frame : WindowManagerEx.getInstanceEx().getAllProjectFrames()) {
      if (frame instanceof IdeFrameEx) {
        ((IdeFrameEx)frame).updateView();
      }
    }
    ActionToolbarImpl.updateAllToolbarsImmediately();
  }
 
源代码13 项目: IntelliJ-Key-Promoter-X   文件: KPXStartupDialog.java
public static void showStartupDialog(Project project) {
  Window w = WindowManagerEx.getInstanceEx().suggestParentWindow(project);
  if (ourInstance != null && ourInstance.isVisible()) {
    ourInstance.dispose();
  }
  ourInstance = (w == null) ? new KPXStartupDialog() : new KPXStartupDialog(w);
  ourInstance.show();
}
 
源代码14 项目: intellij   文件: ProjectFrameUpdater.java
@Override
public void projectOpened(Project project) {
  if (!enabled.getValue()) {
    return;
  }
  ProjectFrameHelper frameHelper = WindowManagerEx.getInstanceEx().getFrameHelper(project);
  if (frameHelper != null) {
    frameHelper.updateView();
  }
}
 
源代码15 项目: idea-php-symfony2-plugin   文件: IdeHelper.java
/**
 * Find current window element of given project.
 * Use this to find a component for new dialogs without using JBPopupFactory
 *
 * @see com.intellij.ui.popup.AbstractPopup#showCenteredInCurrentWindow
 */
@Nullable
public static Window getWindowComponentFromProject(@NotNull Project project) {
    WindowManagerEx windowManager = getWindowManager();
    if(windowManager == null) {
        return null;
    }

    Window window = null;

    Component focusedComponent = windowManager.getFocusedComponent(project);
    if (focusedComponent != null) {
        Component parent = UIUtil.findUltimateParent(focusedComponent);
        if (parent instanceof Window) {
            window = (Window)parent;
        }
    }

    if (window == null) {
        window = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
    }

    if (window != null && window.isShowing()) {
        return window;
    }

    return window;
}
 
源代码16 项目: consulo   文件: WelcomeFrameManager.java
public void showIfNoProjectOpened() {
  myApplication.invokeLater((DumbAwareRunnable)() -> {
    WindowManagerEx windowManager = (WindowManagerEx)WindowManager.getInstance();
    windowManager.disposeRootFrame();
    IdeFrame[] frames = windowManager.getAllProjectFrames();
    if (frames.length == 0) {
      showFrame();
    }
  }, ModalityState.NON_MODAL);
}
 
源代码17 项目: consulo   文件: BaseDataManager.java
public DataContext getDataContextTest(consulo.ui.Component component) {
  DataContext dataContext = getDataContext(component);

  Project project = dataContext.getData(CommonDataKeys.PROJECT);
  Component focusedComponent = ((WindowManagerEx)myWindowManager.get()).getFocusedComponent(project);
  if (focusedComponent != null) {
    dataContext = getDataContext(focusedComponent);
  }
  return dataContext;
}
 
源代码18 项目: consulo   文件: IdeFrameDecorator.java
protected void notifyFrameComponents(boolean state) {
  JFrame jFrame = getJFrame();
  if (jFrame == null) {
    return;
  }

  jFrame.getRootPane().putClientProperty(WindowManagerEx.FULL_SCREEN, state);
  jFrame.getJMenuBar().putClientProperty(WindowManagerEx.FULL_SCREEN, state);
}
 
源代码19 项目: consulo   文件: IdeRootPane.java
public IdeRootPane(ActionManager actionManager, DataManager dataManager, Application application, final IdeFrame frame) {
  myActionManager = actionManager;

  myContentPane.add(myNorthPanel, BorderLayout.NORTH);

  myContentPane.addMouseMotionListener(new MouseMotionAdapter() {}); // listen to mouse motion events for a11y

  createStatusBar(frame);

  updateStatusBarVisibility();

  myContentPane.add(myStatusBar, BorderLayout.SOUTH);

  if (WindowManagerEx.getInstanceEx().isFloatingMenuBarSupported()) {
    menuBar = new IdeMenuBar(actionManager, dataManager);
    getLayeredPane().add(menuBar, new Integer(JLayeredPane.DEFAULT_LAYER - 1));
    if (frame instanceof IdeFrameEx) {
      addPropertyChangeListener(WindowManagerEx.FULL_SCREEN, __ -> myFullScreen = ((IdeFrameEx)frame).isInFullScreen());
    }
  }
  else {
    setJMenuBar(new IdeMenuBar(actionManager, dataManager));
  }

  IdeGlassPaneImpl glassPane = new IdeGlassPaneImpl(this, true);
  setGlassPane(glassPane);
  myGlassPaneInitialized = true;
  SwingUIDecorator.apply(SwingUIDecorator::decorateWindowTitle, this);
  glassPane.setVisible(false);
}
 
源代码20 项目: consulo   文件: ProgressDialog.java
public ProgressDialog(ProgressWindow progressWindow, boolean shouldShowBackground, Project project, String cancelText) {
  myProgressWindow = progressWindow;
  consulo.ui.Window parentWindow = WindowManager.getInstance().suggestParentWindow(project);
  if (parentWindow == null) {
    parentWindow = WindowManagerEx.getInstanceEx().getMostRecentFocusedWindow();
  }
  myParentWindow = parentWindow;

  initDialog(shouldShowBackground, cancelText);
}
 
源代码21 项目: consulo   文件: BackgroundableProcessIndicator.java
public BackgroundableProcessIndicator(@Nullable final Project project, @Nonnull TaskInfo info, @Nonnull PerformInBackgroundOption option) {
  super(info.isCancellable(), true, project, info.getCancelText());
  setOwnerTask(info);
  myOption = option;
  myInfo = info;
  setTitle(info.getTitle());
  final Project nonDefaultProject = project == null || project.isDisposed() ? null : project.isDefault() ? null : project;
  final IdeFrame frame = ((WindowManagerEx)WindowManager.getInstance()).findFrameFor(nonDefaultProject);
  myStatusBar = frame != null ? (StatusBarEx)frame.getStatusBar() : null;
  myBackgrounded = shouldStartInBackground();
  if (myBackgrounded) {
    doBackground();
  }
}
 
源代码22 项目: consulo   文件: FrameWrapper.java
protected void loadFrameState(@Nullable WindowState state) {
  final Window frame = getFrame();
  if(state != null) {
    state.applyTo(frame);
  }
  else {
    final IdeFrame ideFrame = WindowManagerEx.getInstanceEx().getIdeFrame(myProject);
    if (ideFrame != null) {
      frame.setBounds(TargetAWT.to(ideFrame.suggestChildFrameBounds()));
    }
  }
  ((RootPaneContainer)frame).getRootPane().revalidate();
}
 
源代码23 项目: consulo   文件: ActionToolbarImpl.java
private void actionsUpdated(boolean forced, @Nonnull List<? extends AnAction> newVisibleActions) {
  if (forced || !newVisibleActions.equals(myVisibleActions)) {
    boolean shouldRebuildUI = newVisibleActions.isEmpty() || myVisibleActions.isEmpty();
    myVisibleActions = newVisibleActions;

    Dimension oldSize = getPreferredSize();

    removeAll();
    mySecondaryActions.removeAll();
    mySecondaryActionsButton = null;
    fillToolBar(myVisibleActions, getLayoutPolicy() == AUTO_LAYOUT_POLICY && myOrientation == SwingConstants.HORIZONTAL);

    Dimension newSize = getPreferredSize();

    if (!mySkipWindowAdjustments) {
      ((WindowManagerEx)WindowManager.getInstance()).adjustContainerWindow(this, oldSize, newSize);
    }

    if (shouldRebuildUI) {
      revalidate();
    }
    else {
      Container parent = getParent();
      if (parent != null) {
        parent.invalidate();
        parent.validate();
      }
    }

    repaint();
  }
}
 
源代码24 项目: consulo   文件: UndoManagerImpl.java
private void commandStarted(UndoConfirmationPolicy undoConfirmationPolicy, boolean recordOriginalReference) {
  if (myCommandLevel == 0) {
    myCurrentMerger = new CommandMerger(this, CommandProcessor.getInstance().isUndoTransparentActionInProgress());

    if (recordOriginalReference && myProject != null) {
      Editor editor = null;
      final Application application = ApplicationManager.getApplication();
      if (application.isUnitTestMode() || application.isHeadlessEnvironment()) {
        editor = DataManager.getInstance().getDataContext().getData(CommonDataKeys.EDITOR);
      }
      else {
        Component component = WindowManagerEx.getInstanceEx().getFocusedComponent(myProject);
        if (component != null) {
          editor = DataManager.getInstance().getDataContext(component).getData(CommonDataKeys.EDITOR);
        }
      }

      if (editor != null) {
        Document document = editor.getDocument();
        VirtualFile file = FileDocumentManager.getInstance().getFile(document);
        if (file != null && file.isValid()) {
          myOriginatorReference = DocumentReferenceManager.getInstance().create(file);
        }
      }
    }
  }
  LOG.assertTrue(myCurrentMerger != null, String.valueOf(myCommandLevel));
  myCurrentMerger.setBeforeState(getCurrentState());
  myCurrentMerger.mergeUndoConfirmationPolicy(undoConfirmationPolicy);

  myCommandLevel++;

}
 
源代码25 项目: consulo   文件: DockManagerImpl.java
private MyDragSession(MouseEvent me, @Nonnull DockableContent content) {
  myWindow = JWindowPopupFactory.getInstance().create(null);
  myContent = content;

  Image previewImage = content.getPreviewImage();

  double requiredSize = 220;

  double width = previewImage.getWidth(null);
  double height = previewImage.getHeight(null);

  double ratio;
  if (width > height) {
    ratio = requiredSize / width;
  }
  else {
    ratio = requiredSize / height;
  }

  BufferedImage buffer = UIUtil.createImage(myWindow, (int)width, (int)height, BufferedImage.TYPE_INT_ARGB);
  buffer.createGraphics().drawImage(previewImage, 0, 0, (int)width, (int)height, null);

  myDefaultDragImage = buffer.getScaledInstance((int)(width * ratio), (int)(height * ratio), Image.SCALE_SMOOTH);
  myDragImage = myDefaultDragImage;

  myWindow.getContentPane().setLayout(new BorderLayout());
  myImageContainer = new JLabel(IconUtil.createImageIcon(myDragImage));
  myImageContainer.setBorder(new LineBorder(Color.lightGray));
  myWindow.getContentPane().add(myImageContainer, BorderLayout.CENTER);

  setLocationFrom(me);

  myWindow.setVisible(true);

  WindowManagerEx.getInstanceEx().setAlphaModeEnabled(myWindow, true);
  WindowManagerEx.getInstanceEx().setAlphaModeRatio(myWindow, 0.1f);
  myWindow.getRootPane().putClientProperty("Window.shadow", Boolean.FALSE);
}
 
源代码26 项目: consulo   文件: DockManagerImpl.java
public void setTransparent(boolean transparent) {
  if (transparent) {
    WindowManagerEx.getInstanceEx().setAlphaModeEnabled(getFrame(), true);
    WindowManagerEx.getInstanceEx().setAlphaModeRatio(getFrame(), 0.5f);
  }
  else {
    WindowManagerEx.getInstanceEx().setAlphaModeEnabled(getFrame(), true);
    WindowManagerEx.getInstanceEx().setAlphaModeRatio(getFrame(), 0f);
  }
}
 
源代码27 项目: consulo   文件: OccurenceNavigatorActionBase.java
@Nullable
@RequiredUIAccess
private static Component getOccurenceNavigatorFromContext(DataContext dataContext) {
  Window window = TargetAWT.to(WindowManagerEx.getInstanceEx().getMostRecentFocusedWindow());

  if (window != null) {
    Component component = window.getFocusOwner();
    for (Component c = component; c != null; c = c.getParent()) {
      if (c instanceof OccurenceNavigator) {
        return c;
      }
    }
  }

  Project project = dataContext.getData(CommonDataKeys.PROJECT);
  if (project == null) {
    return null;
  }

  ToolWindowManagerEx mgr = ToolWindowManagerEx.getInstanceEx(project);

  String id = mgr.getLastActiveToolWindowId(component -> findNavigator(component) != null);
  if (id == null) {
    return null;
  }
  return (Component)findNavigator(mgr.getToolWindow(id).getComponent());
}
 
源代码28 项目: consulo   文件: StoreDefaultLayoutAction.java
public void actionPerformed(AnActionEvent e){
  Project project = e.getData(CommonDataKeys.PROJECT);
  if(project==null){
    return;
  }
  ToolWindowLayout layout = ToolWindowManagerEx.getInstanceEx(project).getLayout();
  WindowManagerEx.getInstanceEx().setLayout(layout);
}
 
源代码29 项目: consulo   文件: RestoreDefaultLayoutAction.java
public void actionPerformed(AnActionEvent e){
  Project project = e.getData(CommonDataKeys.PROJECT);
  if(project==null){
    return;
  }
  ToolWindowLayout layout=WindowManagerEx.getInstanceEx().getLayout();
  ToolWindowManagerEx.getInstanceEx(project).setLayout(layout);
}
 
源代码30 项目: consulo   文件: RecentLocationsAction.java
private static void showPopup(@Nonnull Project project, @Nonnull JBPopup popup) {
  Point savedLocation = DimensionService.getInstance().getLocation(LOCATION_SETTINGS_KEY, project);
  Window recentFocusedWindow = TargetAWT.to(WindowManagerEx.getInstanceEx().getMostRecentFocusedWindow());
  if (savedLocation != null && recentFocusedWindow != null) {
    popup.showInScreenCoordinates(recentFocusedWindow, savedLocation);
  }
  else {
    popup.showCenteredInCurrentWindow(project);
  }
}