下面列出了org.eclipse.lsp4j.ParameterInformation#org.openide.util.ImageUtilities 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private Image badgeIcon(Image origImg) {
Image badge = null;
switch (aij.getState()) {
case UPDATING:
case LAUNCHING:
case TERMINATING:
badge = ImageUtilities.loadImage(WAITING_ICON);
break;
case READY:
badge = ImageUtilities.loadImage(RUNNING_ICON);
break;
case TERMINATED:
badge = ImageUtilities.loadImage(TERMINATED_ICON);
break;
}
return badge != null ? ImageUtilities.mergeImages(origImg, badge, 15, 8) : origImg;
}
private static SourceGroup createFileSourceGroup (File file, Collection<? super URL> rootsList) {
Icon icon;
Icon openedIcon;
String displayName;
final URL url = FileUtil.urlForArchiveOrDir(file);
if (url == null) {
return null;
}
else if ("jar".equals(url.getProtocol())) { //NOI18N
icon = openedIcon = ImageUtilities.loadImageIcon(ARCHIVE_ICON, false);
displayName = file.getName();
}
else {
icon = getFolderIcon (false);
openedIcon = getFolderIcon (true);
displayName = file.getAbsolutePath();
}
rootsList.add (url);
FileObject root = URLMapper.findFileObject (url);
if (root != null) {
return new LibrariesSourceGroup (root,displayName,icon,openedIcon);
}
return null;
}
private List<SourceGroup> getKeys() {
JavaPlatform platform = ((PlatformNode)this.getNode()).pp.getPlatform();
if (platform == null) {
return Collections.emptyList();
}
//Todo: Should listen on returned classpath, but now the bootstrap libraries are read only
FileObject[] roots = platform.getBootstrapLibraries().getRoots();
List<SourceGroup> result = new ArrayList<SourceGroup>(roots.length);
for (int i=0; i<roots.length; i++) {
FileObject file;
Icon icon;
if ("jar".equals(roots[i].toURL().getProtocol())) { //NOI18N
file = FileUtil.getArchiveFile(roots[i]);
icon = ImageUtilities.loadImageIcon(ARCHIVE_ICON, false);
} else {
file = roots[i];
icon = null;
}
if (file.isValid()) {
result.add(new LibrariesSourceGroup(roots[i], file.getNameExt(), icon, icon));
}
}
return result;
}
public static Image getIcon(
@NonNull final FileObject pkg,
final boolean empty,
@NonNull Callable<Accessibility> accessibilityProvider) {
if ( empty ) {
return ImageUtilities.loadImage(PACKAGE_EMPTY);
} else {
Accessibility a;
try {
a = pkg.isValid() ? accessibilityProvider.call() : Accessibility.UNKNOWN;
} catch (Exception e) {
a = Accessibility.UNKNOWN;
}
switch (a) {
case EXPORTED:
return ImageUtilities.loadImage(PACKAGE_PUBLIC);
case PRIVATE:
return ImageUtilities.loadImage(PACKAGE_PRIVATE);
case UNKNOWN:
return ImageUtilities.loadImage(PACKAGE);
default:
throw new IllegalStateException(String.valueOf(a));
}
}
}
@NbBundle.Messages({
"NotifyMultipleInstallations.title=Multiple MySQL installations found",
"NotifyMultipleInstallations.text=Select the installation to use"
})
private static void notifyAboutMultipleInstallations() {
NotificationDisplayer.getDefault().notify(
Bundle.NotifyMultipleInstallations_title(),
ImageUtilities.loadImageIcon(ICON_BASE, false),
Bundle.NotifyMultipleInstallations_text(),
new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
SelectInstallationPanel.showSelectInstallationDialog();
}
}, NotificationDisplayer.Priority.HIGH, NotificationDisplayer.Category.WARNING);
}
private Image getBasicIcon() {
AntProjectCookie.ParseStatus cookie = getCookie(AntProjectCookie.ParseStatus.class);
if (cookie.getFile() == null && cookie.getFileObject() == null) {
// Script has been invalidated perhaps? Don't continue, we would
// just get an NPE from the getParseException.
return ImageUtilities.loadImage("org/apache/tools/ant/module/resources/AntIconError.gif"); // NOI18N
}
if (!cookie.isParsed()) {
// Assume for now it is not erroneous.
return ImageUtilities.loadImage("org/apache/tools/ant/module/resources/AntIcon.gif"); // NOI18N
}
Throwable exc = cookie.getParseException();
if (exc != null) {
return ImageUtilities.loadImage("org/apache/tools/ant/module/resources/AntIconError.gif"); // NOI18N
} else {
return ImageUtilities.loadImage("org/apache/tools/ant/module/resources/AntIcon.gif"); // NOI18N
}
}
@Test
public void testNodesGeneratedCorrectly() throws Exception {
Collection<? extends Node> arr = Lookups.forPath("UI/Runtime").lookupAll(Node.class);
assertEquals("One node is there: " + arr, 1, arr.size());
Node n = arr.iterator().next();
assertEquals("my1", n.getName());
assertEquals("disp1", n.getDisplayName());
assertEquals("By default short description delegates to displayName", n.getDisplayName(), n.getShortDescription());
Image img1 = ImageUtilities.loadImage("org/netbeans/core/ide/TestIcon1.png");
Image img2 = ImageUtilities.loadImage("org/netbeans/core/ide/TestIcon2.png");
assertSame("icon1 is in use", img1, n.getIcon(BeanInfo.ICON_COLOR_16x16));
Node[] subNodes = n.getChildren().getNodes(true);
assertEquals("Two subnodes", 2, subNodes.length);
// now everything is initialized
assertEquals("my2", n.getName());
assertEquals("disp2", n.getDisplayName());
assertEquals("short2", n.getShortDescription());
assertSame("icon2 is in use", img2, n.getIcon(BeanInfo.ICON_COLOR_16x16));
}
/**
* Returns an icon for the given {@link ModuleElement.DirectiveKind}.
* @param kind the {@link ModuleElement.DirectiveKind} to return an icon for.
* @return the icon
* @since 1.45
*/
public static Icon getModuleDirectiveIcon(@NonNull final ModuleElement.DirectiveKind kind) {
Parameters.notNull("kind", kind); //NOI18N
switch (kind) {
case EXPORTS:
return ImageUtilities.loadImageIcon(EXPORTS_ICON, true);
case REQUIRES:
return ImageUtilities.loadImageIcon(REQUIRES_ICON, true);
case USES:
return ImageUtilities.loadImageIcon(USES_ICON, true);
case PROVIDES:
return ImageUtilities.loadImageIcon(PROVIDES_ICON, true);
case OPENS:
return ImageUtilities.loadImageIcon(OPENS_ICON, true);
default:
throw new IllegalArgumentException(kind.toString());
}
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
String methodName = method.getName();
if (DECORABLE_SETNAME_METHOD.equals(methodName)) {
recInfo.setName((String) args[0]);
}
if (DECORABLE_SETDISPLAYNAME_METHOD.equals(methodName)) {
recInfo.setDisplayName((String) args[0]);
}
if (DECORABLE_SETSHORTDESCRIPTOR_METHOD.equals(methodName)) {
recInfo.setToolTip((String) args[0]);
}
if (DECORABLE_SETICONBASE_METHOD.equals(methodName)) {
String iconBase = (String) args[0];
recInfo.setIcon(ImageUtilities.loadImageIcon(iconBase, true));
}
return null;
}
private Image annotateImage(Image image) {
Image icon = image;
boolean badged = false;
// platform providers
for (PlatformProvider provider : project.getPlatformProviders()) {
BadgeIcon badgeIcon = provider.getBadgeIcon();
if (badgeIcon != null) {
icon = ImageUtilities.addToolTipToImage(icon, String.format(ICON_TOOLTIP, badgeIcon.getUrl(), provider.getDisplayName()));
if (!badged) {
icon = ImageUtilities.mergeImages(icon, badgeIcon.getImage(), 0, 0);
badged = true;
}
} else {
icon = ImageUtilities.addToolTipToImage(icon, String.format(ICON_TOOLTIP, PLACEHOLDER_BADGE_URL, provider.getDisplayName()));
}
}
// project type, only if no platform
if (!badged) {
Image projectBadge = ImageUtilities.loadImage(project.isJsLibrary() ? JS_LIBRARY_BADGE_ICON : HTML5_BADGE_ICON);
icon = ImageUtilities.mergeImages(icon, projectBadge, 0, 0);
}
return icon;
}
private static JToggleButton createToggleButton (final String id, String iconPath, String tooltip) {
Icon icon = ImageUtilities.loadImageIcon(iconPath, false);
boolean isSelected = isButtonSelected(id);
final JToggleButton toggleButton = new JToggleButton(icon, isSelected);
// ensure small size, just for the icon
Dimension size = new Dimension(icon.getIconWidth() + 8, icon.getIconHeight() + 8);
toggleButton.setPreferredSize(size);
toggleButton.setMargin(new Insets(1, 1, 1, 1));
if (!"Aqua".equals(UIManager.getLookAndFeel().getID())) { //NOI18N
// We do not want an ugly border with the exception of Mac, where it paints the toggle state!
toggleButton.setBorder(new EmptyBorder(toggleButton.getBorder().getBorderInsets(toggleButton)));
}
toggleButton.setToolTipText(tooltip);
toggleButton.setFocusable(false);
return toggleButton;
}
/**
* @return New instance of MainProjectScanningScope
*/
public static MainProjectScanningScope create() {
return new MainProjectScanningScope(
NbBundle.getBundle( MainProjectScanningScope.class ).getString( "LBL_MainProjectScope" ), //NOI18N
NbBundle.getBundle( MainProjectScanningScope.class ).getString( "HINT_MainProjectScope" ), //NOI18N
ImageUtilities.loadImage( "org/netbeans/modules/tasklist/projectint/main_project_scope.png" ) //NOI18N
);
}
protected Icon getAddIcon() {
String iconMask = LanguageIcons.CLASS;
Image baseIcon = Icons.getImage(iconMask);
Image addBadge = Icons.getImage(GeneralIcons.BADGE_ADD);
Image addImage = ImageUtilities.mergeImages(baseIcon, addBadge, 0, 0);
return ImageUtilities.image2Icon(addImage);
}
@Override
public Image getIcon(int param) {
Image retValue = ImageUtilities.mergeImages(getTreeFolderIcon(false),
ImageUtilities.loadImage(LIBS_BADGE), //NOI18N
8, 8);
return retValue;
}
@Override
public Image getIcon(int type) {
if (bookmarkIcon == null) {
bookmarkIcon = ImageUtilities.loadImage(
"org/netbeans/modules/editor/bookmarks/resources/bookmark_16.png", false);
}
return bookmarkIcon;
}
private Window createDragWindow( Image dragImage, Rectangle bounds ) {
Window w = new Window( SwingUtilities.windowForComponent(sourceRow) );
w.add(new JLabel(ImageUtilities.image2Icon(dragImage)));
w.setBounds(bounds);
w.setVisible(true);
NativeWindowSystem nws = NativeWindowSystem.getDefault();
if( nws.isUndecoratedWindowAlphaSupported() ) {
nws.setWindowAlpha(w, 0.7f);
}
return w;
}
/** Creates a new instance of ResultWindow */
@NbBundle.Messages({"TITLE_TEST_RESULTS=Test Results",
"ACSN_TestResults=Test Results",
"ACSD_TestResults=Displays information about passed and failed tests and output generated by them"})
public ResultWindow() {
super();
setFocusable(true);
setLayout(new BorderLayout());
setName(ID);
setDisplayName(Bundle.TITLE_TEST_RESULTS());
setIcon(ImageUtilities.loadImage( "org/netbeans/modules/gsf/testrunner/ui/resources/testResults.png", true));//NOI18N
AccessibleContext accContext = getAccessibleContext();
accContext.setAccessibleName(Bundle.ACSN_TestResults());
accContext.setAccessibleDescription(Bundle.ACSD_TestResults());
pop = new JPopupMenu();
pop.add(new Close());
pop.add(new CloseAll());
pop.add(new CloseAllButCurrent());
popL = new PopupListener();
closeL = new CloseListener();
tabPane = TabbedPaneFactory.createCloseButtonTabbedPane();
tabPane.setMinimumSize(new Dimension(0, 0));
tabPane.addMouseListener(popL);
tabPane.addPropertyChangeListener(closeL);
add(tabPane);
}
@Override
public ImageIcon getIcon() {
if (newConstructorIcon == null) {
newConstructorIcon = ImageUtilities.loadImageIcon(NEW_CSTR, false);
}
return newConstructorIcon;
}
private void notifyNetworkProblem (final OperationException ex) {
// Some network problem found
ActionListener onMouseClickAction = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ProblemPanel problem = new ProblemPanel(ex, false);
problem.showNetworkProblemDialog ();
}
};
String title = getBundle ("InstallSupport_InBackground_NetworkError");
String description = getBundle ("InstallSupport_InBackground_NetworkError_Details");
NotificationDisplayer.getDefault().notify(title,
ImageUtilities.loadImageIcon("org/netbeans/modules/autoupdate/ui/resources/error.png", false),
description, onMouseClickAction, NotificationDisplayer.Priority.HIGH, NotificationDisplayer.Category.ERROR);
}
protected synchronized Image badgeImage() {
if (badgeImage == null) {
String path = getClass().getPackage().getName().replace('.', '/') + "/" + getID() + "_badge.png"; // NOI18N
badgeImage = ImageUtilities.loadImage(path, true);
}
return badgeImage;
}
public static Icon getTaskIcon(IssueImpl issue) {
Image priorityIcon = issue.getPriorityIcon();
Image scheduleIcon = getScheduleIcon(issue);
if (scheduleIcon != null) {
return ImageUtilities.image2Icon(ImageUtilities.mergeImages(priorityIcon, scheduleIcon, 0, 0));
}
return ImageUtilities.image2Icon(priorityIcon);
}
public static CurrentEditorScanningScope create() {
return new CurrentEditorScanningScope(
NbBundle.getBundle( CurrentEditorScanningScope.class ).getString( "LBL_CurrentEditorScope" ), //NOI18N)
NbBundle.getBundle( CurrentEditorScanningScope.class ).getString( "HINT_CurrentEditorScope" ), //NOI18N
ImageUtilities.loadImage( "org/netbeans/modules/tasklist/ui/resources/cur_editor_scope.png" ) //NOI18N
);
}
public Image getOpenedIcon(int type) {
if (this.nodeDelegate != null){
return this.nodeDelegate.getOpenedIcon(type);
}
return ImageUtilities.loadImage(
"org/netbeans/modules/xml/jaxb/resources/XML_file.png" );//NOI18N
}
/**
* Returns default folder icon as {@link Image}. Never returns {@code null}.
* @param opened whether closed or opened icon should be returned
* @return default folder icon
*/
public static Image getTreeFolderIcon(boolean opened) {
Image base = (Image) UIManager.get(opened ? OPENED_ICON_KEY_UIMANAGER_NB : ICON_KEY_UIMANAGER_NB); // #70263
if (base == null) {
Icon baseIcon = UIManager.getIcon(opened ? OPENED_ICON_KEY_UIMANAGER : ICON_KEY_UIMANAGER); // #70263
if (baseIcon != null) {
base = ImageUtilities.icon2Image(baseIcon);
} else { // fallback to our owns
base = ImageUtilities.loadImage(opened ? OPENED_ICON_PATH : ICON_PATH, false);
}
}
return base;
}
private DelegatingScopeProvider(Map<?, ?> map) {
this.map = map;
String path = (String) map.get("iconBase"); //NOI18N
icon = path != null && !path.equals("") ? ImageUtilities.loadImageIcon(path, false) : null;
id = (String) map.get("id"); //NOI18N
displayName = (String) map.get("displayName"); //NOI18N
position = (Integer) map.get("position"); //NOI18N
}
@Override
public void stateChanged(@NonNull final ChangeEvent event) {
final JViewport jv = (JViewport)event.getSource();
jlName.setText( "Sample" ); // NOI18N
jlName.setIcon(ImageUtilities.loadImageIcon(SAMPLE_ITEM_ICON, false));
jList.setFixedCellHeight(jlName.getPreferredSize().height);
jList.setFixedCellWidth(jv.getExtentSize().width);
}
/**
* Returns <code>JTextField</code> palette item.
*
* @param dtde corresponding drop target drag event.
* @return <code>JTextField</code> palette item.
*/
@Override
public PaletteItem getPaletteItem(DropTargetDragEvent dtde) {
PaletteItem pItem;
if (!assistantInitialized) {
initAssistant();
}
if (!J2EEUtils.hasPrimaryKey(column.getDatabaseConnection(), column.getTableName())) {
FormEditor.getAssistantModel(model).setContext("tableWithoutPK"); // NOI18N
return null;
}
if (FormJavaSource.isInDefaultPackage(model)) {
// 97982: default package
FormEditor.getAssistantModel(model).setContext("columnDefaultPackage"); // NOI18N
return null;
}
setBindingOnly(dtde.getDropAction() == DnDConstants.ACTION_MOVE);
if (isBindingOnly()) {
FormEditor.getAssistantModel(model).setContext("columnDropBinding", "columnDropComponent"); // NOI18N
pItem = new PaletteItem(new ClassSource("javax.persistence.EntityManager", // NOI18N
new ClassSourceResolver.LibraryEntry(LibraryManager.getDefault().getLibrary("eclipselink"))), // NOI18N
null);
pItem.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/form/j2ee/resources/binding.gif", false).getImage()); // NOI18N
} else {
pItem = new PaletteItem(new ClassSource("javax.swing.JTextField"), null); // NOI18N
}
return pItem;
}
Image getDefaultIcon() {
Image i = ImageUtilities.loadImage(DEFAULT_ICON, true);
if (i == null) {
throw new MissingResourceException("No default icon", "", DEFAULT_ICON); // NOI18N
}
return i;
}
private Image annotateUsbWifi(Image icon) {
if (device.hasEthernet()) {
icon = ImageUtilities.mergeImages(icon, IconProvider.IMG_WIFI_BADGE, 12, 0);
}
if (device.hasUSB()) {
icon = ImageUtilities.mergeImages(icon, IconProvider.IMG_USB_BADGE, 12, 8);
}
return icon;
}
/**
* Creates a new instance of ZoomDefaultAction.
*
* @param manager the zoom manager.
*/
public ZoomDefaultAction(ZoomManager manager) {
this.manager = manager;
String path = NbBundle.getMessage(ZoomDefaultAction.class,
"IMG_ZoomDefaultAction");
Image img = ImageUtilities.loadImage(path);
if (img != null) {
putValue(Action.SMALL_ICON, new ImageIcon(img));
}
String desc = NbBundle.getMessage(ZoomDefaultAction.class,
"LBL_ZoomDefaultAction");
putValue(Action.NAME, desc); // for accessibility
putValue(Action.SHORT_DESCRIPTION, desc);
}