Java Code Examples for consulo.awt.TargetAWT#to()
The following examples show how to use
consulo.awt.TargetAWT#to() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IJSwingUtilities.java From consulo with Apache License 2.0 | 6 votes |
/** * @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); }
Example 2
Source File: DesktopToolWindowManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
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(); }
Example 3
Source File: InspectionListCellRenderer.java From consulo with Apache License 2.0 | 5 votes |
@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean sel, boolean focus) { final JPanel panel = new JPanel(new BorderLayout()); panel.setOpaque(true); final Color bg = sel ? UIUtil.getListSelectionBackground() : UIUtil.getListBackground(); final Color fg = sel ? UIUtil.getListSelectionForeground() : UIUtil.getListForeground(); panel.setBackground(bg); panel.setForeground(fg); SimpleTextAttributes attr = sel ? SELECTED : PLAIN; if (value instanceof InspectionToolWrapper) { final InspectionToolWrapper toolWrapper = (InspectionToolWrapper)value; final SimpleColoredComponent c = new SimpleColoredComponent(); SpeedSearchUtil.appendColoredFragmentForMatcher(" " + toolWrapper.getDisplayName(), c, attr, myMatcher, bg, sel); panel.add(c, BorderLayout.WEST); final SimpleColoredComponent group = new SimpleColoredComponent(); SpeedSearchUtil.appendColoredFragmentForMatcher(toolWrapper.getGroupDisplayName() + " ", group, attr, myMatcher, bg, sel); final JPanel right = new JPanel(new BorderLayout()); right.setBackground(bg); right.setForeground(fg); right.add(group, BorderLayout.CENTER); final JLabel icon = new JLabel(TargetAWT.to(getIcon(toolWrapper))); icon.setBackground(bg); icon.setForeground(fg); right.add(icon, BorderLayout.EAST); panel.add(right, BorderLayout.EAST); } else { // E.g. "..." item return super.getListCellRendererComponent(list, value, index, sel, focus); } return panel; }
Example 4
Source File: BranchActionGroup.java From consulo with Apache License 2.0 | 5 votes |
public BranchActionGroup() { super("", true); myIcon = new LayeredIcon(TargetAWT.to(DvcsImplIcons.Favorite), EmptyIcon.ICON_16); myHoveredIcon = new LayeredIcon(TargetAWT.to(DvcsImplIcons.FavoriteOnHover), TargetAWT.to(DvcsImplIcons.NotFavoriteOnHover)); getTemplatePresentation().setIcon(myIcon); getTemplatePresentation().setHoveredIcon(myHoveredIcon); updateIcons(); }
Example 5
Source File: RunConfigurable.java From consulo with Apache License 2.0 | 5 votes |
private void drawPressAddButtonMessage(final ConfigurationType configurationType) { JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); panel.setBorder(new EmptyBorder(7, 10, 0, 0)); panel.add(new JLabel("Press the")); ActionLink addIcon = new ActionLink("", TargetAWT.to(ADD_ICON), myAddAction); addIcon.setBorder(new EmptyBorder(0, 5, 0, 5)); panel.add(addIcon); final String configurationTypeDescription = configurationType != null ? configurationType.getConfigurationTypeDescription() : ExecutionBundle.message("run.configuration.default.type.description"); panel.add(new JLabel(ExecutionBundle.message("empty.run.configuration.panel.text.label3", configurationTypeDescription))); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(panel, true); myRightPanel.removeAll(); myRightPanel.add(scrollPane, BorderLayout.CENTER); if (configurationType == null) { JPanel settingsPanel = new JPanel(new GridBagLayout()); settingsPanel.setBorder(new EmptyBorder(7, 10, 0, 0)); GridBag grid = new GridBag().setDefaultAnchor(GridBagConstraints.NORTHWEST); for (Pair<UnnamedConfigurable, JComponent> each : myAdditionalSettings) { settingsPanel.add(each.second, grid.nextLine().next()); } settingsPanel.add(createSettingsPanel(), grid.nextLine().next()); JPanel wrapper = new JPanel(new BorderLayout()); wrapper.add(settingsPanel, BorderLayout.WEST); wrapper.add(Box.createGlue(), BorderLayout.CENTER); myRightPanel.add(wrapper, BorderLayout.SOUTH); } myRightPanel.revalidate(); myRightPanel.repaint(); }
Example 6
Source File: DesktopTextBoxWithExtensions.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override public TextBoxWithExtensions setExtensions(@Nonnull Extension... extensions) { List<ExtendableTextComponent.Extension> awtExtensions = new ArrayList<>(extensions.length); for (Extension extension : extensions) { ExtendableTextComponent.Extension ex = new ExtendableTextComponent.Extension() { @Override public Icon getIcon(boolean hovered) { return TargetAWT.to(hovered ? extension.getHoveredIcon() : extension.getIcon()); } @Override public boolean isIconBeforeText() { return extension.isLeft(); } @Override public Runnable getActionOnClick() { Clickable.ClickListener clickListener = extension.getClickListener(); return clickListener == null ? null : clickListener::onClick; } }; awtExtensions.add(ex); } toAWTComponent().setExtensions(awtExtensions); toAWTComponent().repaint(); return this; }
Example 7
Source File: JDialogAsUIWindow.java From consulo with Apache License 2.0 | 5 votes |
public JDialogAsUIWindow(Window owner, boolean modal) { super(TargetAWT.to(owner), (String) null); setModal(modal); myWindowOverAWTWindow = new WindowOverAWTWindow(this) { @RequiredUIAccess @Override public void setTitle(@Nonnull String title) { JDialogAsUIWindow.this.setTitle(title); } }; }
Example 8
Source File: SelectContentStep.java From consulo with Apache License 2.0 | 4 votes |
@Override public Icon getIconFor(Content value) { return TargetAWT.to(value.getIcon()); }
Example 9
Source File: ArtifactsStructureConfigurable.java From consulo with Apache License 2.0 | 4 votes |
public AddArtifactAction(@Nonnull ArtifactType type, @Nonnull ArtifactTemplate artifactTemplate, final @Nonnull String actionText, final Image icon) { super(actionText, null, TargetAWT.to(icon)); myType = type; myArtifactTemplate = artifactTemplate; }
Example 10
Source File: AsyncProcessIcon.java From consulo with Apache License 2.0 | 4 votes |
public AsyncProcessIcon(@NonNls String name, Image[] icons, Image passive) { super(name, Arrays.stream(icons).map(TargetAWT::to).toArray(Icon[]::new), TargetAWT.to(passive), CYCLE_LENGTH); }
Example 11
Source File: RefProjectImpl.java From consulo with Apache License 2.0 | 4 votes |
@Override public Icon getIcon(final boolean expanded) { return TargetAWT.to(Application.get().getIcon()); }
Example 12
Source File: ActionToolbar.java From consulo with Apache License 2.0 | 4 votes |
/** * @return component which represents the tool bar on UI */ @Nonnull default javax.swing.JComponent getComponent() { return (javax.swing.JComponent)TargetAWT.to(getUIComponent()); }
Example 13
Source File: DesktopUIInternalImpl.java From consulo with Apache License 2.0 | 4 votes |
@Override public Image _ImageEffects_resize(Image original, int width, int height) { return new DesktopResizeImageImpl(TargetAWT.to(original), width, height); }
Example 14
Source File: UsageInArtifact.java From consulo with Apache License 2.0 | 4 votes |
@Override public Icon getIcon() { return TargetAWT.to(myOriginalArtifact.getArtifactType().getIcon()); }
Example 15
Source File: WindowManager.java From consulo with Apache License 2.0 | 4 votes |
@Deprecated @Nullable public JFrame getFrame(@Nullable Project project) { consulo.ui.Window window = getWindow(project); return (JFrame)TargetAWT.to(window); }
Example 16
Source File: DesktopTransparentImageImpl.java From consulo with Apache License 2.0 | 4 votes |
@Nullable @Override public Icon retrieveIcon() { return TargetAWT.to(myImage); }
Example 17
Source File: ChooseArtifactsDialog.java From consulo with Apache License 2.0 | 4 votes |
@Override protected Icon getItemIcon(Artifact item) { return TargetAWT.to(item.getArtifactType().getIcon()); }
Example 18
Source File: DialogWrapperPeerFactoryImpl.java From consulo with Apache License 2.0 | 4 votes |
@Override public DialogWrapperPeer createPeer(@Nonnull final DialogWrapper wrapper, final consulo.ui.Window owner, final boolean canBeParent, final boolean applicationModalIfPossible) { return new DialogWrapperPeerImpl(wrapper, TargetAWT.to(owner), canBeParent, applicationModalIfPossible); }
Example 19
Source File: ArtifactChooser.java From consulo with Apache License 2.0 | 4 votes |
@Override protected Icon getItemIcon(@Nonnull ArtifactPointer value) { final Artifact artifact = value.get(); return artifact != null ? TargetAWT.to(artifact.getArtifactType().getIcon()) : null; }
Example 20
Source File: FileChooser.java From consulo with Apache License 2.0 | 3 votes |
/** * Shows file/folder open dialog, allows user to choose files/folders and then passes result to callback in EDT. * On MacOS Open Dialog will be shown with slide effect if Macish UI is turned on. * * @param descriptor file chooser descriptor * @param project project * @param parent parent component * @param toSelect file to preselect * @param callback callback will be invoked after user have closed dialog and only if there are files selected * @see FileChooserConsumer * @since 11.1 */ @Deprecated public static void chooseFiles(@Nonnull final FileChooserDescriptor descriptor, @Nullable final Project project, @Nullable final Component parent, @Nullable final VirtualFile toSelect, @Nonnull final Consumer<List<VirtualFile>> callback) { Component parentComponent = parent == null ? TargetAWT.to(WindowManager.getInstance().suggestParentWindow(project)) : parent; final FileChooserFactory factory = FileChooserFactory.getInstance(); final PathChooserDialog pathChooser = factory.createPathChooser(descriptor, project, parentComponent); pathChooser.choose(toSelect, callback); }