Java Code Examples for org.openide.util.ImageUtilities#addToolTipToImage()

The following examples show how to use org.openide.util.ImageUtilities#addToolTipToImage() . 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: ClientSideProjectLogicalView.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: PhpLogicalViewProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private Image annotateImage(Image image) {
    Image badged = image;
    boolean first = true;
    PhpModule phpModule = project.getPhpModule();
    for (PhpFrameworkProvider frameworkProvider : project.getFrameworks()) {
        BadgeIcon badgeIcon = frameworkProvider.getBadgeIcon();
        final String frameworkName = frameworkProvider.getName(phpModule);
        if (badgeIcon != null) {
            badged = ImageUtilities.addToolTipToImage(badged, String.format(TOOLTIP, badgeIcon.getUrl(), frameworkName));
            if (first) {
                badged = ImageUtilities.mergeImages(badged, badgeIcon.getImage(), 15, 0);
                first = false;
            }
        } else {
            badged = ImageUtilities.addToolTipToImage(badged, String.format(TOOLTIP, Utils.PLACEHOLDER_BADGE_URL, frameworkName));
        }
    }
    return badged;
}
 
Example 3
Source File: ExtIconTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testByteConversions() {
    ExtIcon ext = new ExtIcon();
    URL res = getClass().getClassLoader().getResource("org/netbeans/modules/project/ui/module.gif");
    assertNotNull(res);
    //#138000
    Image img = ImageUtilities.loadImage("org/netbeans/modules/project/ui/module.gif");
    img = ImageUtilities.addToolTipToImage(img, "XXX");
    Icon icon = ImageUtilities.image2Icon(img);
    ext.setIcon(icon);
    try {
        byte[] bytes1 = ext.getBytes();
        ExtIcon ext2 = new ExtIcon(bytes1);
        byte[] bytes2 = ext2.getBytes();
        ExtIcon ext3 = new ExtIcon(bytes2);
        byte[] bytes3 = ext3.getBytes();
        
        assertEquals(bytes1.length, bytes2.length);
        assertEquals(bytes3.length, bytes3.length);
        for (int i = 0; i < bytes1.length; i++) {
            assertEquals("Non equals at position " + i,bytes1[i], bytes2[i]);
            assertEquals("Non equals at position " + i,bytes1[i], bytes3[i]);
        }
    }
    catch (IOException ex) {
        Exceptions.printStackTrace(ex);
        fail();
    }
    
}
 
Example 4
Source File: VersioningAnnotationProviderTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Image annotateIcon(Image icon, VCSContext context) {
    try {
        Thread.sleep(3000);
    } catch (InterruptedException ex) {
        Exceptions.printStackTrace(ex);
    }
    icon = ImageUtilities.mergeImages(icon, VersioningAnnotationProviderTest.IMAGE_ANNOTATION, 16, 16);
    icon = ImageUtilities.addToolTipToImage(icon, "Annotated");
    return icon;
}
 
Example 5
Source File: VCSAnnotationProviderTestCase.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Image annotateIcon(Image icon, VCSContext context) {
    try {
        Thread.sleep(3000);
    } catch (InterruptedException ex) {
        Exceptions.printStackTrace(ex);
    }
    icon = ImageUtilities.mergeImages(icon, VCSAnnotationProviderTestCase.IMAGE_ANNOTATION, 16, 16);
    icon = ImageUtilities.addToolTipToImage(icon, "Annotated");
    return icon;
}
 
Example 6
Source File: OSGiJarAccessibilityQueryImpl.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@NbBundle.Messages("Tooltip_manifest=Contains OSGi manifest headers")
private Image getIcon() {
    return ImageUtilities.addToolTipToImage(ImageUtilities.loadImage(BADGE), toolTip);
}
 
Example 7
Source File: ModuleJarAccessibilityQueryImpl.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@NbBundle.Messages("Tooltip_manifest=Contains NetBeans module manifest headers")
private Image getIcon() {
    return ImageUtilities.addToolTipToImage(ImageUtilities.loadImage(BADGE), toolTip);
}
 
Example 8
Source File: Annotator.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private Image annotateFileIcon (VCSContext context, Image icon) throws IllegalArgumentException {
    FileInformation mostImportantInfo = null;
    for (final File file : context.getRootFiles()) {
        FileInformation info = cache.getStatus(file);
        if (!info.containsStatus(STATUS_IS_IMPORTANT)) {
            continue;
        }
        if (isMoreImportant(info, mostImportantInfo)) {
            mostImportantInfo = info;
        }
    }
    if(mostImportantInfo == null) return null;
    String tooltip = null;
    String statusText = mostImportantInfo.getStatusText(FileInformation.Mode.HEAD_VS_WORKING_TREE);
    if (mostImportantInfo.containsStatus(Status.NOTVERSIONED_EXCLUDED)) {
        // File is IGNORED
        tooltip = getAnnotationProvider().EXCLUDED_FILE_TOOLTIP.getFormat().format(new Object[] { statusText });
    } else if (mostImportantInfo.getStatus().equals(EnumSet.of(Status.NEW_HEAD_INDEX, Status.REMOVED_INDEX_WORKING_TREE))) {
        // ADDED to index but REMOVED in WT
        tooltip = getAnnotationProvider().UP_TO_DATE_FILE_TOOLTIP.getFormat().format(new Object[]{statusText});
    } else if (mostImportantInfo.getStatus().equals(EnumSet.of(Status.MODIFIED_HEAD_INDEX, Status.MODIFIED_INDEX_WORKING_TREE))) {
        // MODIFIED in index, MODIFIED in WT, but in WT same as HEAD
        tooltip = getAnnotationProvider().UP_TO_DATE_FILE_TOOLTIP.getFormat().format(new Object[]{statusText});
    } else if (mostImportantInfo.containsStatus(Status.REMOVED_HEAD_WORKING_TREE)) {
        // DELETED in WT
        tooltip = getAnnotationProvider().REMOVED_FILE_TOOLTIP.getFormat().format(new Object[] { statusText });
    } else if (mostImportantInfo.getStatus().equals(EnumSet.of(Status.NEW_INDEX_WORKING_TREE, Status.REMOVED_HEAD_INDEX))) {
        // recreated in WT
        tooltip = getAnnotationProvider().UP_TO_DATE_FILE_TOOLTIP.getFormat().format(new Object[]{statusText});
    } else if (mostImportantInfo.getStatus().equals(EnumSet.of(Status.NEW_INDEX_WORKING_TREE, Status.REMOVED_HEAD_INDEX, Status.MODIFIED_HEAD_WORKING_TREE))) {
        // recreated in WT and modified
        tooltip = getAnnotationProvider().MODIFIED_FILE_TOOLTIP.getFormat().format(new Object[] { statusText });
    } else if (mostImportantInfo.containsStatus(Status.NEW_INDEX_WORKING_TREE)) {
        // NEW in WT and unversioned
        tooltip = getAnnotationProvider().NEW_FILE_TOOLTIP.getFormat().format(new Object[] { statusText });
    } else if (mostImportantInfo.containsStatus(Status.NEW_HEAD_INDEX)) {
        // ADDED to index
        tooltip = getAnnotationProvider().ADDED_FILE_TOOLTIP.getFormat().format(new Object[] { statusText });
    } else if (mostImportantInfo.containsStatus(Status.MODIFIED_HEAD_WORKING_TREE)) {
        tooltip = getAnnotationProvider().MODIFIED_FILE_TOOLTIP.getFormat().format(new Object[] { statusText });
    } else if (mostImportantInfo.containsStatus(Status.UPTODATE)) {
        tooltip = null;
    } else if (mostImportantInfo.containsStatus(Status.IN_CONFLICT)) {
        tooltip = getAnnotationProvider().CONFLICT_FILE_TOOLTIP.getFormat().format(new Object[] { statusText });
    } else if (mostImportantInfo.containsStatus(Status.NOTVERSIONED_NOTMANAGED)) {
        tooltip = null;
    } else if (mostImportantInfo.containsStatus(Status.UNKNOWN)) {
        tooltip = null;
    } else {
        throw new IllegalStateException("Unknown status: " + mostImportantInfo.getStatus()); //NOI18N
    }
    return tooltip != null ? ImageUtilities.addToolTipToImage(icon, tooltip) : null;
}
 
Example 9
Source File: MercurialAnnotator.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private Image addToolTip (Image icon, VCSContext context) {
    if (!VersioningSupport.getPreferences().getBoolean(VersioningSupport.PREF_BOOLEAN_TEXT_ANNOTATIONS_VISIBLE, false)) {
        return icon;
    }
    File root = null;
    File repository = null;
    for (File f : context.getRootFiles()) {
        File repo = Mercurial.getInstance().getRepositoryRoot(f);
        if (repo != null) {
            if (repository == null) {
                repository = repo;
                root = f;
            } else if (!repository.equals(repo)) {
                // root files are from different repositories, do not annotate icon
                return icon;
            }
        }
    }
    if (repository != null) {
        WorkingCopyInfo info = WorkingCopyInfo.getInstance(repository);
        addFileWithRepositoryAnnotation(info, root);
        HgLogMessage[] parents = info.getWorkingCopyParents();
        String label = null;
        if (parents.length == 1) {
            HgLogMessage parent = parents[0];
            String branchName = null;
            for (String b : parent.getBranches()) {
                branchName = b;
            }
            if (branchName != null) {
                label = NbBundle.getMessage(MercurialAnnotator.class, "LBL_Annotator.currentBranch.toolTip", branchName); //NOI18N
            }
        } else if (parents.length > 1) {
            String b1 = parents[0].getBranches().length == 0 ? HgBranch.DEFAULT_NAME : parents[0].getBranches()[0];
            String b2 = parents[1].getBranches().length == 0 ? HgBranch.DEFAULT_NAME : parents[1].getBranches()[0];
            if (b1.equals(b2)) {
                label = NbBundle.getMessage(MercurialAnnotator.class, "LBL_Annotator.mergeNeeded.oneBranch.toolTip", new Object[] { //NOI18N
                    parents[0].getCSetShortID().substring(0, Math.min(7, parents[0].getCSetShortID().length())), 
                    parents[1].getCSetShortID().substring(0, Math.min(7, parents[1].getCSetShortID().length())), 
                    b1
                });
            } else {
                label = NbBundle.getMessage(MercurialAnnotator.class, "LBL_Annotator.mergeNeeded.twoBranches.toolTip", new Object[] { b1, b2 }); //NOI18N
            }
        }
        if (label != null) {
            icon = ImageUtilities.addToolTipToImage(icon, label.toString());
        }
    }
    return icon;
}