• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java JBPopupAdapter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.openapi.ui.popup.JBPopupAdapter的典型用法代码示例。如果您正苦于以下问题:Java JBPopupAdapter类的具体用法?Java JBPopupAdapter怎么用?Java JBPopupAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JBPopupAdapter类属于com.intellij.openapi.ui.popup包,在下文中一共展示了JBPopupAdapter类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: projectOpened

import com.intellij.openapi.ui.popup.JBPopupAdapter; //导入依赖的package包/类
@Override
public void projectOpened() {
  ApplicationManager.getApplication().invokeLater((DumbAwareRunnable)() -> ApplicationManager.getApplication().runWriteAction(
    (DumbAwareRunnable)() -> {
      if (PropertiesComponent.getInstance().getBoolean(ourShowPopup, true)) {
        final String content = "<html>If you'd like to learn more about PyCharm Edu, " +
                               "click <a href=\"https://www.jetbrains.com/pycharm-edu/quickstart/\">here</a> to watch a tutorial</html>";
        final Notification notification = new Notification("Watch Tutorials!", "", content, NotificationType.INFORMATION,
                                                           new NotificationListener.UrlOpeningListener(true));
        StartupManager.getInstance(myProject).registerPostStartupActivity(() -> Notifications.Bus.notify(notification));
        Balloon balloon = notification.getBalloon();
        if (balloon != null) {
          balloon.addListener(new JBPopupAdapter() {
            @Override
            public void onClosed(LightweightWindowEvent event) {
              notification.expire();
            }
          });
        }
        notification.whenExpired(() -> PropertiesComponent.getInstance().setValue(ourShowPopup, false, true));
      }
    }));
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:24,代码来源:PyStudyShowTutorial.java


示例2: trackDimensions

import com.intellij.openapi.ui.popup.JBPopupAdapter; //导入依赖的package包/类
private void trackDimensions(@Nullable String dimensionKey) {
  Window popupWindow = getPopupWindow();
  if (popupWindow == null) return;
  ComponentListener windowListener = new ComponentAdapter() {
    @Override
    public void componentResized(ComponentEvent e) {
      if (myShown) {
        processOnSizeChanged();
      }
    }
  };
  popupWindow.addComponentListener(windowListener);
  addPopupListener(new JBPopupAdapter() {
    @Override
    public void onClosed(LightweightWindowEvent event) {
      popupWindow.removeComponentListener(windowListener);
      if (dimensionKey != null && myUserSizeChanged) {
        WindowStateService.getInstance(myProject).putSizeFor(myProject, dimensionKey, myPrevSize);
      }
    }
  });
}
 
开发者ID:consulo,项目名称:consulo,代码行数:23,代码来源:BranchActionGroupPopup.java


示例3: setBalloon

import com.intellij.openapi.ui.popup.JBPopupAdapter; //导入依赖的package包/类
public void setBalloon(@NotNull final Balloon balloon) {
  hideBalloon();
  myBalloonRef = new WeakReference<Balloon>(balloon);
  balloon.addListener(new JBPopupAdapter() {
    @Override
    public void onClosed(LightweightWindowEvent event) {
      if (SoftReference.dereference(myBalloonRef) == balloon) {
        myBalloonRef = null;
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:Notification.java


示例4: actionPerformed

import com.intellij.openapi.ui.popup.JBPopupAdapter; //导入依赖的package包/类
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
  Project project = e.getProject();
  if (project == null) {
    return;
  }

  Filter filter = myFilterModel.getFilter();
  final MultilinePopupBuilder popupBuilder = new MultilinePopupBuilder(project, myVariants, getPopupText(getTextValues(filter)),
                                                                       supportsNegativeValues());
  JBPopup popup = popupBuilder.createPopup();
  popup.addListener(new JBPopupAdapter() {
    @Override
    public void onClosed(LightweightWindowEvent event) {
      if (event.isOk()) {
        Collection<String> selectedValues = popupBuilder.getSelectedValues();
        if (selectedValues.isEmpty()) {
          myFilterModel.setFilter(null);
        }
        else {
          myFilterModel.setFilter(createFilter(selectedValues));
          rememberValuesInSettings(selectedValues);
        }
      }
    }
  });
  popup.showUnderneathOf(MultipleValueFilterPopupComponent.this);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:MultipleValueFilterPopupComponent.java


示例5: FramelessNotificationPopup

import com.intellij.openapi.ui.popup.JBPopupAdapter; //导入依赖的package包/类
public FramelessNotificationPopup(final JComponent owner, final JComponent content, Color backgroud, boolean useDefaultPreferredSize, final ActionListener listener) {
  myBackgroud = backgroud;
  myUseDefaultPreferredSize = useDefaultPreferredSize;
  myContent = new ContentComponent(content);

  myActionListener = listener;

  myFadeInTimer = UIUtil.createNamedTimer("Frameless fade in",10, myFadeTracker);
  myPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(myContent, null)
    .setRequestFocus(false)
    .setResizable(false)
    .setMovable(true)
    .setLocateWithinScreenBounds(false)
    .setAlpha(0.2f).addListener(new JBPopupAdapter() {
    public void onClosed(LightweightWindowEvent event) {
      if (myFadeInTimer.isRunning()) {
        myFadeInTimer.stop();
      }
      myFadeInTimer.removeActionListener(myFadeTracker);
    }
  })
    .createPopup();
  final Point p = RelativePoint.getSouthEastOf(owner).getScreenPoint();
  Rectangle screen = ScreenUtil.getScreenRectangle(p.x, p.y);

  final Point initial = new Point(screen.x + screen.width - myContent.getPreferredSize().width - 50,
                                  screen.y + screen.height - 5);

  myPopup.showInScreenCoordinates(owner, initial);

  myFadeInTimer.setRepeats(true);
  myFadeInTimer.start();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:FramelessNotificationPopup.java


示例6: createBalloon

import com.intellij.openapi.ui.popup.JBPopupAdapter; //导入依赖的package包/类
@NotNull
@Override
public Balloon createBalloon() {
  final BalloonImpl result = new BalloonImpl(
    myContent, myBorder, myBorderInsets, myFill, myHideOnMouseOutside, myHideOnKeyOutside, myHideOnAction, myShowCallout, myCloseButtonEnabled,
    myFadeoutTime, myHideOnFrameResize, myHideOnLinkClick, myClickHandler, myCloseOnClick, myAnimationCycle, myCalloutShift,
    myPositionChangeXShift, myPositionChangeYShift, myDialogMode, myTitle, myContentInsets, myShadow, mySmallVariant, myBlockClicks,
    myLayer);

  if (myStorage != null && myAnchor != null) {
    List<Balloon> balloons = myStorage.get(myAnchor);
    if (balloons == null) {
      myStorage.put(myAnchor, balloons = new ArrayList<Balloon>());
      Disposer.register(myAnchor, new Disposable() {
        @Override
        public void dispose() {
          List<Balloon> toDispose = myStorage.remove(myAnchor);
          if (toDispose != null) {
            for (Balloon balloon : toDispose) {
              if (!balloon.isDisposed()) {
                Disposer.dispose(balloon);
              }
            }
          }
        }
      });
    }
    balloons.add(result);
    result.addListener(new JBPopupAdapter() {
      @Override
      public void onClosed(LightweightWindowEvent event) {
        if (!result.isDisposed()) {
          Disposer.dispose(result);
        }
      }
    });
  }

  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:41,代码来源:BalloonPopupBuilderImpl.java


示例7: showBalloon

import com.intellij.openapi.ui.popup.JBPopupAdapter; //导入依赖的package包/类
private void showBalloon() {
  if (myBalloon != null) {
    Disposer.dispose(myBalloon);
    return;
  }

  myBalloon = JBPopupFactory.getInstance().createBalloonBuilder(myBalloonComponent)
    .setAnimationCycle(200)
    .setCloseButtonEnabled(true)
    .setHideOnAction(false)
    .setHideOnClickOutside(false)
    .setHideOnFrameResize(false)
    .setHideOnKeyOutside(false)
    .setSmallVariant(true)
    .setShadow(true)
    .createBalloon();

  Disposer.register(myBalloon, new Disposable() {
    @Override
    public void dispose() {
      myBalloon = null;
    }
  });

  myBalloon.addListener(new JBPopupAdapter() {
    @Override
    public void onClosed(LightweightWindowEvent event) {
      if (myBalloon != null) {
        Disposer.dispose(myBalloon);
      }
    }
  });

  myBalloon.show(new PositionTracker<Balloon>(myIcon) {
    @Override
    public RelativePoint recalculateLocation(Balloon object) {
      return new RelativePoint(myIcon, new Point(myIcon.getSize().width / 2, 4));
    }
  }, Balloon.Position.above);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:41,代码来源:ActionMacroManager.java


示例8: projectOpened

import com.intellij.openapi.ui.popup.JBPopupAdapter; //导入依赖的package包/类
@Override
public void projectOpened() {
  ApplicationManager.getApplication().invokeLater(new DumbAwareRunnable() {
    @Override
    public void run() {
      ApplicationManager.getApplication().runWriteAction(new DumbAwareRunnable() {
        @Override
        public void run() {
          if (PropertiesComponent.getInstance().getBoolean(ourShowPopup, true)) {
            final String content = "<html>If you'd like to learn more about PyCharm Edu, " +
                                   "click <a href=\"https://www.jetbrains.com/pycharm-edu/quickstart/\">here</a> to watch a tutorial</html>";
            final Notification notification = new Notification("Watch Tutorials!", "", content, NotificationType.INFORMATION,
                                                               new NotificationListener.UrlOpeningListener(true));
            Notifications.Bus.notify(notification);
            Balloon balloon = notification.getBalloon();
            if (balloon != null) {
              balloon.addListener(new JBPopupAdapter() {
                @Override
                public void onClosed(LightweightWindowEvent event) {
                  notification.expire();
                }
              });
            }
            notification.whenExpired(new Runnable() {
              @Override
              public void run() {
                PropertiesComponent.getInstance().setValue(ourShowPopup, false, true);
              }
            });
          }
        }
      });
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:PyStudyShowTutorial.java


示例9: setBalloon

import com.intellij.openapi.ui.popup.JBPopupAdapter; //导入依赖的package包/类
public void setBalloon(@NotNull final Balloon balloon) {
  hideBalloon();
  myBalloonRef = new WeakReference<Balloon>(balloon);
  balloon.addListener(new JBPopupAdapter() {
    @Override
    public void onClosed(LightweightWindowEvent event) {
      WeakReference<Balloon> ref = myBalloonRef;
      if (ref != null && ref.get() == balloon) {
        myBalloonRef = null;
      }
    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:14,代码来源:Notification.java


示例10: createBalloon

import com.intellij.openapi.ui.popup.JBPopupAdapter; //导入依赖的package包/类
@NotNull
public Balloon createBalloon() {
  final BalloonImpl result =
    new BalloonImpl(myContent, myBorder, myFill, myHideOnMouseOutside, myHideOnKeyOutside, myHideOnAction, myShowCalllout,
                    myCloseButtonEnabled, myFadeoutTime, myHideOnFrameResize, myClickHandler, myCloseOnClick, myAnimationCycle,
                    myCalloutShift, myPositionChangeXShift, myPositionChangeYShift, myDialogMode, myTitle, myContentInsets, myShadow,
                    mySmallVariant, myBlockClicks, myLayer);
  if (myAnchor != null) {
    List<Balloon> balloons = myStorage.get(myAnchor);
    if (balloons == null) {
      myStorage.put(myAnchor, balloons = new ArrayList<Balloon>());
      Disposer.register(myAnchor, new Disposable() {
        @Override
        public void dispose() {
          List<Balloon> toDispose = myStorage.remove(myAnchor);
          if (toDispose != null) {
            for (Balloon balloon : toDispose) {
              if (!balloon.isDisposed()) {
                Disposer.dispose(balloon);
              }
            }
          }
        }
      });
    }
    balloons.add(result);
    result.addListener(new JBPopupAdapter() {
      @Override
      public void onClosed(LightweightWindowEvent event) {
        if (!result.isDisposed()) {
          Disposer.dispose(result);
        }
        myStorage.remove(result);
      }
    });
  }
  return result;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:39,代码来源:BalloonPopupBuilderImpl.java


示例11: init

import com.intellij.openapi.ui.popup.JBPopupAdapter; //导入依赖的package包/类
public void init(@NotNull AbstractPopup popup, T component, Ref<UsageView> usageView) {
  myPopup = popup;
  myComponent = component;
  myUsageView = usageView;

  myPopup.addPopupListener(new JBPopupAdapter() {
    @Override
    public void onClosed(LightweightWindowEvent event) {
      setCanceled();
    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:13,代码来源:BackgroundUpdaterTask.java


示例12: buildPopup

import com.intellij.openapi.ui.popup.JBPopupAdapter; //导入依赖的package包/类
private JBPopup buildPopup(final JBList list,
         final Map<Object, String> filterIndex)
{
   final PopupChooserBuilder listPopupBuilder = JBPopupFactory.getInstance().createListPopupBuilder(list);
   listPopupBuilder.setTitle("Run a Forge command");
   listPopupBuilder.setResizable(true);
   listPopupBuilder.addListener(new JBPopupAdapter()
   {
      @Override
      public void onClosed(LightweightWindowEvent event)
      {
         CommandListPopupBuilder.active = false;
      }
   });
   listPopupBuilder.setItemChoosenCallback((Runnable) () -> {
      Object selectedObject = list.getSelectedValue();
      if (selectedObject instanceof UICommand)
      {
         UICommand selectedCommand = (UICommand) selectedObject;

         // Make sure that this cached command is still enabled
         if (selectedCommand.isEnabled(uiContext))
         {
            openWizard(selectedCommand);
         }
      }
   });
   listPopupBuilder.setFilteringEnabled(filterIndex::get);

   return listPopupBuilder.createPopup();
}
 
开发者ID:forge,项目名称:intellij-idea-plugin,代码行数:32,代码来源:CommandListPopupBuilder.java


示例13: addGeneralComment

import com.intellij.openapi.ui.popup.JBPopupAdapter; //导入依赖的package包/类
private void addGeneralComment(@NotNull final Project project, DataContext dataContext) {
  final CommentForm commentForm = new CommentForm(project, true, myIsReply, null);
  commentForm.setReview(myReview);

  if (myIsReply) {
    final JBTable contextComponent = (JBTable)getContextComponent();
    final int selectedRow = contextComponent.getSelectedRow();
    if (selectedRow >= 0) {
      final Object parentComment = contextComponent.getValueAt(selectedRow, 0);
      if (parentComment instanceof Comment) {
        commentForm.setParentComment(((Comment)parentComment));
      }
    }
    else return;
  }

  final JBPopup balloon = CommentBalloonBuilder.getNewCommentBalloon(commentForm, myIsReply ? CrucibleBundle
    .message("crucible.new.reply.$0", commentForm.getParentComment().getPermId()) :
                                                                                  CrucibleBundle
                                                                                    .message("crucible.new.comment.$0",
                                                                                             myReview.getPermaId()));
  balloon.addListener(new JBPopupAdapter() {
    @Override
    public void onClosed(LightweightWindowEvent event) {
      if(!commentForm.getText().isEmpty()) { // do not try to save draft if text is empty
        commentForm.postComment();
      }
      final JComponent component = getContextComponent();
      if (component instanceof GeneralCommentsTree) {
        ((GeneralCommentsTree)component).refresh();
      }
    }
  });

  commentForm.setBalloon(balloon);
  balloon.showInBestPositionFor(dataContext);
  commentForm.requestFocus();
}
 
开发者ID:ktisha,项目名称:Crucible4IDEA,代码行数:39,代码来源:AddCommentAction.java


示例14: setBalloon

import com.intellij.openapi.ui.popup.JBPopupAdapter; //导入依赖的package包/类
public void setBalloon(@Nonnull final Balloon balloon) {
  hideBalloon();
  myBalloonRef = new WeakReference<>(balloon);
  balloon.addListener(new JBPopupAdapter() {
    @Override
    public void onClosed(LightweightWindowEvent event) {
      if (SoftReference.dereference(myBalloonRef) == balloon) {
        myBalloonRef = null;
      }
    }
  });
}
 
开发者ID:consulo,项目名称:consulo,代码行数:13,代码来源:Notification.java


示例15: actionPerformed

import com.intellij.openapi.ui.popup.JBPopupAdapter; //导入依赖的package包/类
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  Project project = e.getProject();
  if (project == null) {
    return;
  }

  Filter filter = myFilterModel.getFilter();
  List<String> values = filter == null
                        ? Collections.emptyList()
                        : myFilterModel.getFilterValues(filter);
  final MultilinePopupBuilder popupBuilder = new MultilinePopupBuilder(project, myVariants,
                                                                       getPopupText(values),
                                                                       supportsNegativeValues());
  JBPopup popup = popupBuilder.createPopup();
  popup.addListener(new JBPopupAdapter() {
    @Override
    public void onClosed(LightweightWindowEvent event) {
      if (event.isOk()) {
        List<String> selectedValues = popupBuilder.getSelectedValues();
        if (selectedValues.isEmpty()) {
          myFilterModel.setFilter(null);
        }
        else {
          myFilterModel.setFilter(myFilterModel.createFilter(selectedValues));
          rememberValuesInSettings(selectedValues);
        }
      }
    }
  });
  popup.showUnderneathOf(MultipleValueFilterPopupComponent.this);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:33,代码来源:MultipleValueFilterPopupComponent.java


示例16: createBalloon

import com.intellij.openapi.ui.popup.JBPopupAdapter; //导入依赖的package包/类
@Nonnull
@Override
public Balloon createBalloon() {
  final BalloonImpl result =
          new BalloonImpl(myContent, myBorder, myBorderInsets, myFill, myHideOnMouseOutside, myHideOnKeyOutside, myHideOnAction, myHideOnCloseClick,
                          myShowCallout, myCloseButtonEnabled, myFadeoutTime, myHideOnFrameResize, myHideOnLinkClick, myClickHandler, myCloseOnClick,
                          myAnimationCycle, myCalloutShift, myPositionChangeXShift, myPositionChangeYShift, myDialogMode, myTitle, myContentInsets, myShadow,
                          mySmallVariant, myBlockClicks, myLayer, myRequestFocus, myPointerSize, myCornerToPointerDistance);

  if (myStorage != null && myAnchor != null) {
    List<Balloon> balloons = myStorage.get(myAnchor);
    if (balloons == null) {
      myStorage.put(myAnchor, balloons = new ArrayList<>());
      Disposer.register(myAnchor, new Disposable() {
        @Override
        public void dispose() {
          List<Balloon> toDispose = myStorage.remove(myAnchor);
          if (toDispose != null) {
            for (Balloon balloon : toDispose) {
              if (!balloon.isDisposed()) {
                Disposer.dispose(balloon);
              }
            }
          }
        }
      });
    }
    balloons.add(result);
    result.addListener(new JBPopupAdapter() {
      @Override
      public void onClosed(LightweightWindowEvent event) {
        if (!result.isDisposed()) {
          Disposer.dispose(result);
        }
      }
    });
  }

  return result;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:41,代码来源:BalloonPopupBuilderImpl.java


示例17: showBalloon

import com.intellij.openapi.ui.popup.JBPopupAdapter; //导入依赖的package包/类
private void showBalloon() {
  if (myBalloon != null) {
    Disposer.dispose(myBalloon);
    return;
  }

  myBalloon =
          JBPopupFactory.getInstance().createBalloonBuilder(myBalloonComponent).setAnimationCycle(200).setCloseButtonEnabled(true).setHideOnAction(false)
                  .setHideOnClickOutside(false).setHideOnFrameResize(false).setHideOnKeyOutside(false).setSmallVariant(true).setShadow(true)
                  .createBalloon();

  Disposer.register(myBalloon, new Disposable() {
    @Override
    public void dispose() {
      myBalloon = null;
    }
  });

  myBalloon.addListener(new JBPopupAdapter() {
    @Override
    public void onClosed(LightweightWindowEvent event) {
      if (myBalloon != null) {
        Disposer.dispose(myBalloon);
      }
    }
  });

  myBalloon.show(new PositionTracker<Balloon>(myIcon) {
    @Override
    public RelativePoint recalculateLocation(Balloon object) {
      return new RelativePoint(myIcon, new Point(myIcon.getSize().width / 2, 4));
    }
  }, Balloon.Position.above);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:35,代码来源:ActionMacroManager.java


示例18: createShortContextPanel

import com.intellij.openapi.ui.popup.JBPopupAdapter; //导入依赖的package包/类
private JPanel createShortContextPanel(final boolean allowNoContexts) {
  JPanel panel = new JPanel(new BorderLayout());

  final JLabel ctxLabel = new JLabel();
  final JLabel change = new JLabel();
  change.setForeground(PlatformColors.BLUE);
  change.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  panel.add(ctxLabel, BorderLayout.CENTER);
  panel.add(change, BorderLayout.EAST);

  final Runnable updateLabel = new Runnable() {
    @Override
    public void run() {
      myExpandByCombo.setEnabled(isExpandableFromEditor());
      updateHighlighter();

      StringBuilder sb = new StringBuilder();
      String oldPrefix = "";
      for (TemplateContextType type : getApplicableContexts()) {
        final TemplateContextType base = type.getBaseContextType();
        String ownName = UIUtil.removeMnemonic(type.getPresentableName());
        String prefix = "";
        if (base != null && !(base instanceof EverywhereContextType)) {
          prefix = UIUtil.removeMnemonic(base.getPresentableName()) + ": ";
          ownName = StringUtil.decapitalize(ownName);
        }
        if (type instanceof EverywhereContextType) {
          ownName = "Other";
        }
        if (sb.length() > 0) {
          sb.append(oldPrefix.equals(prefix) ? ", " : "; ");
        }
        if (!oldPrefix.equals(prefix)) {
          sb.append(prefix);
          oldPrefix = prefix;
        }
        sb.append(ownName);
      }
      final boolean noContexts = sb.length() == 0;
      String contexts = (noContexts ? "No applicable contexts" + (allowNoContexts ? "" : " yet") : "Applicable in " + sb.toString()) + ".  ";
      ctxLabel.setText(StringUtil.first(contexts, 100, true));
      ctxLabel.setForeground(noContexts ? allowNoContexts ? JBColor.GRAY : JBColor.RED : UIUtil.getLabelForeground());
      change.setText(noContexts ? "Define" : "Change");
    }
  };

  new ClickListener() {
    @Override
    public boolean onClick(@NotNull MouseEvent e, int clickCount) {
      if (disposeContextPopup()) return false;

      final JPanel content = createPopupContextPanel(updateLabel, myContext);
      Dimension prefSize = content.getPreferredSize();
      if (myLastSize != null && (myLastSize.width > prefSize.width || myLastSize.height > prefSize.height)) {
        content.setPreferredSize(new Dimension(Math.max(prefSize.width, myLastSize.width), Math.max(prefSize.height, myLastSize.height)));
      }
      myContextPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(content, null).setResizable(true).createPopup();
      myContextPopup.show(new RelativePoint(change, new Point(change.getWidth() , -content.getPreferredSize().height - 10)));
      myContextPopup.addListener(new JBPopupAdapter() {
        @Override
        public void onClosed(LightweightWindowEvent event) {
          myLastSize = content.getSize();
        }
      });
      return true;
    }
  }.installOn(change);

  updateLabel.run();

  return panel;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:73,代码来源:LiveTemplateSettingsEditor.java


示例19: createShortContextPanel

import com.intellij.openapi.ui.popup.JBPopupAdapter; //导入依赖的package包/类
private JPanel createShortContextPanel(final boolean allowNoContexts) {
  JPanel panel = new JPanel(new BorderLayout());

  final JLabel ctxLabel = new JLabel();
  final JLabel change = new JLabel();
  change.setForeground(PlatformColors.BLUE);
  change.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  panel.add(ctxLabel, BorderLayout.CENTER);
  panel.add(change, BorderLayout.EAST);

  final Runnable updateLabel = new Runnable() {
    @Override
    public void run() {
      StringBuilder sb = new StringBuilder();
      String oldPrefix = "";
      for (TemplateContextType type : getApplicableContexts()) {
        final TemplateContextType base = type.getBaseContextType();
        String ownName = UIUtil.removeMnemonic(type.getPresentableName());
        String prefix = "";
        if (base != null && !(base instanceof EverywhereContextType)) {
          prefix = UIUtil.removeMnemonic(base.getPresentableName()) + ": ";
          ownName = StringUtil.decapitalize(ownName);
        }
        if (type instanceof EverywhereContextType) {
          ownName = "Other";
        }
        if (sb.length() > 0) {
          sb.append(oldPrefix.equals(prefix) ? ", " : "; ");
        }
        if (!oldPrefix.equals(prefix)) {
          sb.append(prefix);
          oldPrefix = prefix;
        }
        sb.append(ownName);
      }
      final boolean noContexts = sb.length() == 0;
      ctxLabel.setText((noContexts ? "No applicable contexts" + (allowNoContexts ? "" : " yet") : "Applicable in " + sb.toString()) + ".  ");
      ctxLabel.setForeground(noContexts ? allowNoContexts ? JBColor.GRAY : JBColor.RED : UIUtil.getLabelForeground());
      change.setText(noContexts ? "Define" : "Change");
    }
  };

  new ClickListener() {
    @Override
    public boolean onClick(MouseEvent e, int clickCount) {
      if (disposeContextPopup()) return false;

      final JPanel content = createPopupContextPanel(updateLabel);
      Dimension prefSize = content.getPreferredSize();
      if (myLastSize != null && (myLastSize.width > prefSize.width || myLastSize.height > prefSize.height)) {
        content.setPreferredSize(new Dimension(Math.max(prefSize.width, myLastSize.width), Math.max(prefSize.height, myLastSize.height)));
      }
      myContextPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(content, null).setResizable(true).createPopup();
      myContextPopup.show(new RelativePoint(change, new Point(change.getWidth() , -content.getPreferredSize().height - 10)));
      myContextPopup.addListener(new JBPopupAdapter() {
        @Override
        public void onClosed(LightweightWindowEvent event) {
          myLastSize = content.getSize();
        }
      });
      return true;
    }
  }.installOn(change);

  updateLabel.run();

  return panel;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:69,代码来源:LiveTemplateSettingsEditor.java



注:本文中的com.intellij.openapi.ui.popup.JBPopupAdapter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HttpMessageParserFactory类代码示例发布时间:2022-05-22
下一篇:
Java ResultSet类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap