javax.swing.text.html.ParagraphView#consulo.awt.TargetAWT源码实例Demo

下面列出了javax.swing.text.html.ParagraphView#consulo.awt.TargetAWT 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: consulo   文件: DesktopWindowManagerImpl.java
public void showFrame() {
  final DesktopIdeFrameImpl frame = new DesktopIdeFrameImpl(myActionManager, myDataManager, ApplicationManager.getApplication());
  myProject2Frame.put(null, frame);

  if (myFrameBounds == null || !ScreenUtil.isVisible(myFrameBounds)) { //avoid situations when IdeFrame is out of all screens
    myFrameBounds = ScreenUtil.getMainScreenBounds();
    int xOff = myFrameBounds.width / 8;
    int yOff = myFrameBounds.height / 8;
    JBInsets.removeFrom(myFrameBounds, new Insets(yOff, xOff, yOff, xOff));
  }

  JFrame jWindow = (JFrame)TargetAWT.to(frame.getWindow());

  jWindow.setBounds(myFrameBounds);
  jWindow.setExtendedState(myFrameExtendedState);
  jWindow.setVisible(true);
}
 
源代码2 项目: consulo   文件: ModuleStructureConfigurable.java
public void addLibraryOrderEntry(final Module module, final Library library) {
  Component parent = TargetAWT.to(WindowManager.getInstance().suggestParentWindow(module.getProject()));

  final ModuleEditor moduleEditor = myContext.myModulesConfigurator.getModuleEditor(module);
  LOG.assertTrue(moduleEditor != null, "Current module editor was not initialized");
  final ModifiableRootModel modelProxy = moduleEditor.getModifiableRootModelProxy();
  final OrderEntry[] entries = modelProxy.getOrderEntries();
  for (OrderEntry entry : entries) {
    if (entry instanceof LibraryOrderEntry && Comparing.strEqual(entry.getPresentableName(), library.getName())) {
      if (Messages.showYesNoDialog(parent,
                                   ProjectBundle.message("project.roots.replace.library.entry.message", entry.getPresentableName()),
                                   ProjectBundle.message("project.roots.replace.library.entry.title"),
                                   Messages.getInformationIcon()) == Messages.YES) {
        modelProxy.removeOrderEntry(entry);
        break;
      }
    }
  }
  modelProxy.addLibraryEntry(library);
  myContext.getDaemonAnalyzer().queueUpdate(new ModuleProjectStructureElement(myContext, module));
  myTree.repaint();
}
 
源代码3 项目: consulo   文件: DesktopDeferredIconImpl.java
@Nonnull
@Override
public Icon evaluate() {
  consulo.ui.image.Image result;
  try {
    result = nonNull(myEvaluator.fun(myParam));
  }
  catch (IndexNotReadyException e) {
    result = EMPTY_ICON;
  }

  if (Holder.CHECK_CONSISTENCY) {
    checkDoesntReferenceThis(result);
  }

  Icon icon = TargetAWT.to(result);

  if (getScale() != 1f && icon instanceof ScalableIcon) {
    icon = ((ScalableIcon)result).scale(getScale());
  }
  return icon;
}
 
源代码4 项目: consulo   文件: Bookmark.java
@Nonnull
private static Image createMnemonicIcon(char cha) {
  int width = AllIcons.Actions.Checked.getWidth();
  int height = AllIcons.Actions.Checked.getHeight();

  return ImageEffects.canvas(width, height, c -> {
    // FIXME [VISTALL] make constant ??
    c.setFillStyle(TargetAWT.from(new JBColor(new Color(0xffffcc), new Color(0x675133))));
    c.fillRect(0, 0, width, height);

    c.setStrokeStyle(StandardColors.GRAY);
    c.rect(0, 0, width, height);
    c.stroke();

    c.setFillStyle(ComponentColors.TEXT);
    c.setFont(FontManager.get().createFont("Monospaced", 11, consulo.ui.font.Font.STYLE_BOLD));
    c.setTextAlign(Canvas2D.TextAlign.center);
    c.setTextBaseline(Canvas2D.TextBaseline.middle);

    c.fillText(Character.toString(cha), width / 2, height / 2 - 2);
  });
}
 
源代码5 项目: consulo   文件: MinimizeCurrentWindowAction.java
@Override
public void update(final AnActionEvent e) {
  final Presentation p = e.getPresentation();
  p.setVisible(SystemInfo.isMac);

  if (SystemInfo.isMac) {
    Project project = e.getData(CommonDataKeys.PROJECT);
    if (project != null) {
      JFrame frame = (JFrame)TargetAWT.to(WindowManager.getInstance().getWindow(project));
      if (frame != null) {
        JRootPane pane = frame.getRootPane();
        p.setEnabled(pane != null && pane.getClientProperty(MacMainFrameDecorator.FULL_SCREEN) == null);
      }
    }
  }
  else {
    p.setEnabled(false);
  }
}
 
源代码6 项目: 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();
}
 
源代码7 项目: consulo   文件: Messages.java
/**
 * @return {@link #YES} if user pressed "Yes" or {@link #NO} if user pressed "No", or {@link #CANCEL} if user pressed "Cancel" button.
 */
@YesNoCancelResult
public static int showYesNoCancelDialog(@Nonnull Component parent,
                                        String message,
                                        @Nonnull String title,
                                        @Nonnull String yes,
                                        @Nonnull String no,
                                        @Nonnull String cancel,
                                        Icon icon) {
  try {
    if (canShowMacSheetPanel()) {
      return MacMessages.getInstance().showYesNoCancelDialog(title, message, yes, no, cancel, TargetAWT.from(SwingUtilities.getWindowAncestor(parent)), null);
    }
  }
  catch (Exception exception) {
  }

  int buttonNumber = showDialog(parent, message, title, new String[]{yes, no, cancel}, 0, icon);
  return buttonNumber == 0 ? YES : buttonNumber == 1 ? NO : CANCEL;
}
 
源代码8 项目: consulo   文件: CreateDirectoryOrPackageHandler.java
@Nullable
private Boolean suggestCreatingFileInstead(String subDirName) {
  Boolean createFile = false;
  if (StringUtil.countChars(subDirName, '.') == 1 && Registry.is("ide.suggest.file.when.creating.filename.like.directory")) {
    FileType fileType = findFileTypeBoundToName(subDirName);
    if (fileType != null) {
      String message = "The name you entered looks like a file name. Do you want to create a file named " + subDirName + " instead?";
      int ec = Messages.showYesNoCancelDialog(myProject, message, "File Name Detected", "&Yes, create file", "&No, create " + (myIsDirectory ? "directory" : "packages"),
                                              CommonBundle.getCancelButtonText(), TargetAWT.to(fileType.getIcon()));
      if (ec == Messages.CANCEL) {
        createFile = null;
      }
      if (ec == Messages.YES) {
        createFile = true;
      }
    }
  }
  return createFile;
}
 
源代码9 项目: consulo   文件: NewItemWithTemplatesPopupPanel.java
public NewItemWithTemplatesPopupPanel(List<T> templatesList, ListCellRenderer<T> renderer) {
  setBackground(JBUI.CurrentTheme.NewClassDialog.panelBackground());

  myTemplatesListModel = new MyListModel(templatesList);
  myTemplatesList = createTemplatesList(myTemplatesListModel, renderer);

  ScrollingUtil.installMoveUpAction(myTemplatesList, (JComponent)TargetAWT.to(myTextField));
  ScrollingUtil.installMoveDownAction(myTemplatesList, (JComponent)TargetAWT.to(myTextField));

  JBScrollPane scrollPane = new JBScrollPane(myTemplatesList);
  scrollPane.setBorder(JBUI.Borders.empty());
  scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
  templatesListHolder = new Box(BoxLayout.Y_AXIS);
  Border border = JBUI.Borders
          .merge(JBUI.Borders.emptyTop(JBUI.CurrentTheme.NewClassDialog.fieldsSeparatorWidth()), JBUI.Borders.customLine(JBUI.CurrentTheme.NewClassDialog.bordersColor(), 1, 0, 0, 0), true);

  templatesListHolder.setBorder(border);
  templatesListHolder.add(scrollPane);

  add(templatesListHolder, BorderLayout.CENTER);
}
 
源代码10 项目: consulo   文件: DesktopWindowWatcher.java
/**
 * @return active window for specified <code>project</code>. There is only one window
 * for project can be at any point of time.
 */
@Nullable
private Window getFocusedWindowForProject(@Nullable final Project project) {
  //todo[anton,vova]: it is possible that returned wnd is not contained in myFocusedWindows; investigate
  outer:
  for (consulo.ui.Window window : myFocusedWindows) {
    Window awtWindow = TargetAWT.to(window);

    while (!awtWindow.isDisplayable() || !awtWindow.isShowing()) { // if window isn't visible then gets its first visible ancestor
      awtWindow = awtWindow.getOwner();
      if (awtWindow == null) {
        continue outer;
      }
    }
    final DataContext dataContext = DataManager.getInstance().getDataContext(awtWindow);
    if (project == dataContext.getData(CommonDataKeys.PROJECT)) {
      return awtWindow;
    }
  }
  return null;
}
 
源代码11 项目: consulo   文件: DesktopDeferredIconImpl.java
private void checkDoesntReferenceThis(final consulo.ui.image.Image icon) {
  if (icon == this) {
    throw new IllegalStateException("Loop in icons delegation");
  }

  if (icon instanceof DesktopDeferredIconImpl) {
    checkDoesntReferenceThis(((DesktopDeferredIconImpl)icon).myScaledDelegateIcon);
  }
  else if (icon instanceof LayeredIcon) {
    for (Icon layer : ((LayeredIcon)icon).getAllLayers()) {
      checkDoesntReferenceThis(TargetAWT.from(layer));
    }
  }
  else if (icon instanceof RowIcon) {
    final RowIcon rowIcon = (RowIcon)icon;
    final int count = rowIcon.getIconCount();
    for (int i = 0; i < count; i++) {
      checkDoesntReferenceThis(TargetAWT.from(rowIcon.getIcon(i)));
    }
  }
}
 
源代码12 项目: consulo   文件: BaseExecuteBeforeRunDialog.java
private DefaultMutableTreeNode buildNodes() {
  DefaultMutableTreeNode root = new DefaultMutableTreeNode(new Descriptor());
  RunManager runManager = RunManager.getInstance(myProject);
  final ConfigurationType[] configTypes = runManager.getConfigurationFactories();

  for (final ConfigurationType type : configTypes) {
    final Icon icon = TargetAWT.to(type.getIcon());
    DefaultMutableTreeNode typeNode = new DefaultMutableTreeNode(new ConfigurationTypeDescriptor(type, icon, isConfigurationAssigned(type)));
    root.add(typeNode);
    final Set<String> addedNames = new THashSet<>();
    RunConfiguration[] configurations = runManager.getConfigurations(type);
    for (final RunConfiguration configuration : configurations) {
      final String configurationName = configuration.getName();
      if (addedNames.contains(configurationName)) {
        // add only the first configuration if more than one has the same name
        continue;
      }
      addedNames.add(configurationName);
      typeNode.add(new DefaultMutableTreeNode(new ConfigurationDescriptor(configuration, isConfigurationAssigned(configuration))));
    }
  }

  return root;
}
 
源代码13 项目: consulo   文件: NewItemSimplePopupPanel.java
public NewItemSimplePopupPanel() {
  super(new BorderLayout());

  myTextField = createTextField();
  add(TargetAWT.to(myTextField), BorderLayout.NORTH);

  //myErrorShowPoint = new RelativePoint(myTextField, new Point(0, myTextField.getHeight()));
}
 
源代码14 项目: consulo   文件: DesktopMenuImpl.java
@RequiredUIAccess
@Nonnull
@Override
public Menu add(@Nonnull MenuItem menuItem) {
  if (menuItem instanceof MenuSeparator) {
    myComponent.addSeparator();
    return this;
  }
  myComponent.add((JMenuItem)TargetAWT.to(menuItem));
  return this;
}
 
源代码15 项目: consulo   文件: WizardStep.java
@Nonnull
@Deprecated
@DeprecationInfo("Temp UI version")
@RequiredUIAccess
default java.awt.Component getSwingComponent() {
  return TargetAWT.to(getComponent());
}
 
源代码16 项目: consulo   文件: DesktopStripeButton.java
@RequiredUIAccess
@Override
public void updatePresentation() {
  updateState();
  updateText();
  Image image = myDecorator.getToolWindow().getIcon();
  setIcon(TargetAWT.to(image));
  setDisabledIcon(image == null ? null : TargetAWT.to(ImageEffects.grayed(image)));
}
 
源代码17 项目: consulo   文件: TreeComboBox.java
private static Icon getValueIcon(final Object value, final int index) {
  if (value instanceof CustomPresentation) {
    return ((CustomPresentation)value).getIcon(index, 0);
  }
  if (value instanceof Iconable) {
    return TargetAWT.to(((Iconable)value).getIcon(0));
  }

  return null;
}
 
源代码18 项目: consulo   文件: DefaultLookupItemRenderer.java
@Nullable
private static Icon _getRawIcon(LookupElement item, boolean real) {
  if (item instanceof LookupItem) {
    Icon icon = (Icon)((LookupItem)item).getAttribute(LookupItem.ICON_ATTR);
    if (icon != null) return icon;
  }

  Object o = item.getObject();

  if (!real) {
    if (item.getObject() instanceof String) {
      return EmptyIcon.ICON_0;
    }

    return new EmptyIcon(IconUtil.getDefaultNodeIconSize() * 2, IconUtil.getDefaultNodeIconSize());
  }

  if (o instanceof Iconable && !(o instanceof PsiElement)) {
    return TargetAWT.to(((Iconable)o).getIcon(Iconable.ICON_FLAG_VISIBILITY));
  }

  final PsiElement element = item.getPsiElement();
  if (element != null && element.isValid()) {
    return TargetAWT.to(IconDescriptorUpdaters.getIcon(element, Iconable.ICON_FLAG_VISIBILITY));
  }
  return null;
}
 
源代码19 项目: consulo   文件: StopAction.java
@Nullable
private static Pair<List<HandlerItem>, HandlerItem> getItemsList(List<Pair<TaskInfo, ProgressIndicator>> tasks,
                                                                 List<RunContentDescriptor> descriptors,
                                                                 RunContentDescriptor toSelect) {
  if (tasks.isEmpty() && descriptors.isEmpty()) {
    return null;
  }

  List<HandlerItem> items = new ArrayList<>(tasks.size() + descriptors.size());
  HandlerItem selected = null;
  for (final RunContentDescriptor descriptor : descriptors) {
    final ProcessHandler handler = descriptor.getProcessHandler();
    if (handler != null) {
      HandlerItem item = new HandlerItem(descriptor.getDisplayName(), TargetAWT.to(descriptor.getIcon()), false) {
        @Override
        void stop() {
          ExecutionManagerImpl.stopProcess(descriptor);
        }
      };
      items.add(item);
      if (descriptor == toSelect) {
        selected = item;
      }
    }
  }

  boolean hasSeparator = true;
  for (final Pair<TaskInfo, ProgressIndicator> eachPair : tasks) {
    items.add(new HandlerItem(eachPair.first.getTitle(), AllIcons.Process.Step_passive, hasSeparator) {
      @Override
      void stop() {
        eachPair.second.cancel();
      }
    });
    hasSeparator = false;
  }
  return Pair.create(items, selected);
}
 
源代码20 项目: consulo   文件: RunnerContentUi.java
@Override
public void showNotify() {
  Window awtWindow = SwingUtilities.getWindowAncestor(myComponent);
  consulo.ui.Window uiWindow = TargetAWT.from(awtWindow);

  IdeFrame ideFrame = uiWindow.getUserData(IdeFrame.KEY);
  if (ideFrame instanceof IdeFrame.Child) {
    ideFrame.setFrameTitle(mySessionName);
  }
}
 
源代码21 项目: consulo   文件: Messages.java
public static void showErrorDialog(@Nonnull Component component, String message) {
  try {
    if (canShowMacSheetPanel()) {
      MacMessages.getInstance().showErrorDialog(CommonBundle.getErrorTitle(), message, OK_BUTTON, TargetAWT.from(SwingUtilities.getWindowAncestor(component)));
      return;
    }
  }
  catch (Exception exception) {
  }

  showDialog(component, message, CommonBundle.getErrorTitle(), new String[]{OK_BUTTON}, 0, getErrorIcon());
}
 
源代码22 项目: consulo   文件: Messages.java
public static void showWarningDialog(@Nonnull Component component, String message, @Nonnull String title) {
  try {
    if (canShowMacSheetPanel()) {
      MacMessages.getInstance().showErrorDialog(title, message, OK_BUTTON, TargetAWT.from(SwingUtilities.getWindowAncestor(component)));
      return;
    }
  }
  catch (Exception exception) {
  }

  showDialog(component, message, title, new String[]{OK_BUTTON}, 0, getWarningIcon());
}
 
源代码23 项目: consulo   文件: FileInfoManager.java
public static Object getFileLookupItem(PsiElement psiElement) {
  if (!(psiElement instanceof PsiFile) || !(psiElement.isPhysical())) {
    return psiElement;
  }

  final PsiFile file = (PsiFile)psiElement;
  return getFileInfoManager()._getLookupItem(file, file.getName(), TargetAWT.to(IconDescriptorUpdaters.getIcon(file, 0)));
}
 
源代码24 项目: consulo   文件: DesktopToolWindowManagerImpl.java
public void projectClosed() {
  if (myFrame == null) {
    return;
  }
  final String[] ids = getToolWindowIds();

  WindowManagerEx windowManager = (WindowManagerEx)myWindowManager.get();

  // Remove ToolWindowsPane
  JFrame window = (JFrame)TargetAWT.to(myFrame.getWindow());
  ((IdeRootPane)window.getRootPane()).setToolWindowsPane(null);
  windowManager.releaseFrame(myFrame);
  List<FinalizableCommand> commandsList = new ArrayList<>();
  appendUpdateToolWindowsPaneCmd(commandsList);

  // Hide all tool windows

  for (final String id : ids) {
    deactivateToolWindowImpl(id, true, commandsList);
  }

  // Remove editor component

  final JComponent editorComponent = getEditorComponent(myProject);
  appendSetEditorComponentCmd(null, commandsList);
  execute(commandsList);
  myFrame = null;
}
 
@Nullable
private static IdeFrame getIdeFrameFromWindow(Window window) {
  final Component frame = UIUtil.findUltimateParent(window);
  if (!(frame instanceof Window)) {
    return null;
  }

  consulo.ui.Window uiWindow = TargetAWT.from((Window)frame);
  return uiWindow.getUserData(IdeFrame.KEY);
}
 
源代码26 项目: consulo   文件: ChooseLibrariesDialogBase.java
protected LibraryDescriptor(final Project project, final NodeDescriptor parentDescriptor, final Library element) {
  super(project, parentDescriptor, element);
  final CellAppearanceEx appearance = OrderEntryAppearanceService.getInstance().forLibrary(project, element, false);
  final SimpleColoredComponent coloredComponent = new SimpleColoredComponent();
  appearance.customize(coloredComponent);
  final PresentationData templatePresentation = getTemplatePresentation();
  templatePresentation.setIcon(TargetAWT.from(coloredComponent.getIcon()));
  templatePresentation.addText(notEmpty(appearance.getText()), SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
 
源代码27 项目: consulo   文件: Win7TaskBar.java
private static WinDef.HWND getHandle(IdeFrame frame) {
  try {
    Pointer pointer = Native.getWindowPointer(TargetAWT.to(frame.getWindow()));
    return new WinDef.HWND(pointer);
  }
  catch (Throwable e) {
    LOG.error(e);
    return null;
  }
}
 
源代码28 项目: consulo   文件: JDialogAsUIWindow.java
public JDialogAsUIWindow(Window owner, String title) {
  super(TargetAWT.to(owner), title);

  myWindowOverAWTWindow = new WindowOverAWTWindow(this) {
    @RequiredUIAccess
    @Override
    public void setTitle(@Nonnull String title) {
      JDialogAsUIWindow.this.setTitle(title);
    }
  };
}
 
源代码29 项目: consulo   文件: XDebuggerEditorBase.java
protected JPanel addMultilineButton(JComponent component) {
  ComponentWithBrowseButton<JComponent> componentWithButton =
          new ComponentWithBrowseButton<>(component, e -> showCodeFragmentEditor(component, this));
  componentWithButton.setButtonIcon(AllIcons.Actions.ShowViewer);
  componentWithButton.getButton().setDisabledIcon(TargetAWT.to(ImageEffects.grayed(AllIcons.Actions.ShowViewer)));
  return componentWithButton;
}
 
源代码30 项目: consulo   文件: FileLabel.java
public void setFile(File ioFile) {
  myFile = ioFile;
  if (myShowIcon) {
    setIcon(TargetAWT.to(FileTypeManager.getInstance().getFileTypeByFileName(myFile.getName()).getIcon()));
  }
  else {
    setIcon(null);
  }
}