Package org.eclipse.jface.viewers

Examples of org.eclipse.jface.viewers.StyledString


                cell.setImage(bundleFolderImg);
                cell.setText("Required Bundles");
            }
        } else if (cell.getElement() instanceof ImportUsedByPackage) {
            if (cell.getColumnIndex() == 0) {
                StyledString styledString = new StyledString("Used By: ", UIConstants.ITALIC_QUALIFIER_STYLER);
                styledString.append(((ImportUsedByPackage) cell.getElement()).usedByName);
                cell.setText(styledString.getString());
                cell.setStyleRanges(styledString.getStyleRanges());
            }
        } else if (cell.getElement() instanceof ImportUsedByClass) {
            if (cell.getColumnIndex() == 0) {
                ImportUsedByClass importUsedBy = (ImportUsedByClass) cell.getElement();
                String fqn = importUsedBy.clazz.getFQN();
                String className = fqn.substring(fqn.lastIndexOf('.') + 1);
                cell.setText(className);
                cell.setImage(classImg);
            }
        } else if (cell.getElement() instanceof ExportUsesPackage) {
            if (cell.getColumnIndex() == 0) {
                StyledString styledString = new StyledString("Uses: ", UIConstants.ITALIC_QUALIFIER_STYLER);
                styledString.append(((ExportUsesPackage) cell.getElement()).name);
                cell.setText(styledString.getString());
                cell.setStyleRanges(styledString.getStyleRanges());
            }
        } else if (cell.getElement() instanceof RequiredBundle) {
            RequiredBundle rb = (RequiredBundle) cell.getElement();
            switch (cell.getColumnIndex()) {
            case 0 :
                StyledString label;
                if (rb.isSatisfied())
                    label = new StyledString(rb.getName(), StyledString.QUALIFIER_STYLER);
                else
                    label = new StyledString(rb.getName());

                String version = rb.getAttribs().get(Constants.BUNDLE_VERSION_ATTRIBUTE);
                if (version != null)
                    label.append(" " + version, StyledString.COUNTER_STYLER);

                String resolution = rb.getAttribs().get(Constants.RESOLUTION_DIRECTIVE);
                boolean optional = org.osgi.framework.Constants.RESOLUTION_OPTIONAL.equals(resolution);
                if (resolution != null)
                    label.append(" <" + resolution + ">", UIConstants.ITALIC_QUALIFIER_STYLER);

                cell.setText(label.getString());
                cell.setStyleRanges(label.getStyleRanges());

                if (optional)
                    cell.setImage(requiredBundleOptImg);
                else if (rb.isSatisfied())
                    cell.setImage(requiredBundleSatisfiedImg);
                else
                    cell.setImage(requiredBundleImg);
                break;
            case 1 :
                cell.setText(formatAttribs(rb.getAttribs()));
                break;
            default :
                break;
            }
        } else if (cell.getElement() instanceof ImportPackage || cell.getElement() instanceof ExportPackage) {
            HeaderClause entry = (HeaderClause) cell.getElement();
            switch (cell.getColumnIndex()) {
            case 0 :
                boolean selfImport = false;
                if (entry instanceof ImportPackage) {
                    selfImport = ((ImportPackage) entry).isSelfImport();
                }

                StyledString styledString;
                if (selfImport) {
                    styledString = new StyledString(entry.getName(), StyledString.QUALIFIER_STYLER);
                } else {
                    styledString = new StyledString(entry.getName());
                }

                String version = entry.getAttribs().get(Constants.VERSION_ATTRIBUTE);
                if (version != null)
                    styledString.append(" " + version, StyledString.COUNTER_STYLER);

                String resolution = entry.getAttribs().get(Constants.RESOLUTION_DIRECTIVE);
                boolean optional = org.osgi.framework.Constants.RESOLUTION_OPTIONAL.equals(resolution);
                if (resolution != null) {
                    styledString.append(" <" + resolution + ">", UIConstants.ITALIC_QUALIFIER_STYLER);
                }

                cell.setText(styledString.getString());
                cell.setStyleRanges(styledString.getStyleRanges());
                if (optional) {
                    cell.setImage(packageOptImg);
                } else if (selfImport) {
                    cell.setImage(packageImpExpImg);
                } else {
View Full Code Here


            public void update(ViewerCell cell) {
                Object element = cell.getElement();

                if (element instanceof Builder) {
                    Builder builder = (Builder) element;
                    StyledString label = new StyledString(builder.getBsn(), StyledString.QUALIFIER_STYLER);
                    cell.setText(label.getString());
                    cell.setStyleRanges(label.getStyleRanges());
                    cell.setImage(projectImg);
                } else {
                    super.update(cell);
                }
            }
View Full Code Here

                cell.setImage(image);
            }
        } else if (element instanceof Project) {
            if (index == 0) {
                Project project = (Project) element;
                StyledString label = new StyledString(project.getName());
                if (showRepoId)
                    label.append("  [Workspace]", StyledString.QUALIFIER_STYLER);

                cell.setText(label.getString());
                cell.setStyleRanges(label.getStyleRanges());
                cell.setImage(projectImg);
            }
        } else if (element instanceof ProjectBundle) {
            if (index == 0) {
                StyledString label = new StyledString(((ProjectBundle) element).getBsn());
                if (showRepoId)
                    label.append("  [Workspace]", StyledString.QUALIFIER_STYLER);

                cell.setText(label.getString());
                cell.setStyleRanges(label.getStyleRanges());
                cell.setImage(bundleImg);
            }
        } else if (element instanceof RepositoryBundle) {
            if (index == 0) {
                RepositoryBundle bundle = (RepositoryBundle) element;
                StyledString label = new StyledString(bundle.getText());
                if (showRepoId)
                    label.append("  [" + bundle.getRepo().getName() + "]", StyledString.QUALIFIER_STYLER);
                cell.setText(label.getString());
                cell.setStyleRanges(label.getStyleRanges());
                cell.setImage(bundleImg);
            }
        } else if (element instanceof RepositoryBundleVersion) {
            if (index == 0) {
                RepositoryBundleVersion bundleVersion = (RepositoryBundleVersion) element;
                String versionText = bundleVersion.getText();
               
                if (versionText.contains(" \u21E9")) {
                    versionText = versionText.replaceAll(" \u21E9", "");
                    cell.setImage(arrowImg);
                }

                StyledString styledString = new StyledString(versionText, StyledString.COUNTER_STYLER);
                cell.setText(styledString.getString());
                cell.setStyleRanges(styledString.getStyleRanges());
            }
        } else if (element instanceof ContinueSearchElement) {
            StyledString label = new StyledString("Continue Search on JPM4J.org...", new HyperlinkStyler());
            cell.setText(label.getString());
            cell.setStyleRanges(label.getStyleRanges());
        } else if (element != null) {
            // Catch-all
            cell.setText(element.toString());
        }
    }
View Full Code Here

        case IStatus.CANCEL :
        default :
            break;
        }

        StyledString label = new StyledString(status.getMessage());
        if (status.getException() != null)
            label.append(": " + status.getException().toString(), StyledString.QUALIFIER_STYLER);

        cell.setText(label.getString());
        cell.setStyleRanges(label.getStyleRanges());
    }
View Full Code Here

                }

                boolean included = isIncludedRepo(repo);
                styler = included ? null : strikeoutStyler;

                StyledString styledLabel = new StyledString(label, styler);
                cell.setText(styledLabel.getString());
                cell.setStyleRanges(styledLabel.getStyleRanges());
                cell.setImage(image);
            }

            @Override
            public String getToolTipText(Object element) {
View Full Code Here

    @Override
    public void update(ViewerCell cell) {
        HeaderClause header = (HeaderClause) cell.getElement();

        String className = header.getName();
        StyledString label = new StyledString(className);

        Map<String,String> attribs = header.getAttribs();
        if (!attribs.isEmpty())
            label.append(" ");
        for (Iterator<Entry<String,String>> iter = attribs.entrySet().iterator(); iter.hasNext();) {
            Entry<String,String> entry = iter.next();
            label.append(entry.getKey(), StyledString.QUALIFIER_STYLER);
            label.append("=", StyledString.QUALIFIER_STYLER);
            label.append(entry.getValue(), StyledString.COUNTER_STYLER);

            if (iter.hasNext())
                label.append(", ");
        }

        cell.setText(label.toString());
        cell.setStyleRanges(label.getStyleRanges());

        Image image = images.get(className);
        if (image == null) {
            IConfigurationElement configElem = configElements.get(className);
            if (configElem != null) {
View Full Code Here

        IConfigurationElement element = (IConfigurationElement) cell.getElement();

        boolean deprecated = element.getAttribute("deprecated") != null;

        Styler mainStyler = deprecated ? new StrikeoutStyler(null) : null;
        StyledString label = new StyledString(element.getAttribute("name"), mainStyler);

        Styler classStyle = deprecated ? new StrikeoutStyler(StyledString.QUALIFIER_STYLER) : StyledString.QUALIFIER_STYLER;
        label.append(" [" + element.getAttribute("class") + "]", classStyle);

        cell.setText(label.toString());
        cell.setStyleRanges(label.getStyleRanges());

        String iconPath = element.getAttribute("icon");
        if (iconPath != null) {
            ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(element.getContributor().getName(), iconPath);
            if (descriptor != null) {
View Full Code Here

        @Override
        public void update(ViewerCell cell) {
            FileVersionTuple pkg = (FileVersionTuple) cell.getElement();

            StyledString label = new StyledString(pkg.getVersion().toString(), StyledString.COUNTER_STYLER);
            cell.setText(label.getString());
            cell.setStyleRanges(label.getStyleRanges());
        }
View Full Code Here

        private final Image imgJar = AbstractUIPlugin.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "icons/jar_obj.gif").createImage();

        @Override
        public void update(ViewerCell cell) {
            ResourceDescriptor descriptor = (ResourceDescriptor) cell.getElement();
            StyledString label = new StyledString(descriptor.bsn + " ");
            if (descriptor.version != null)
                label.append(descriptor.version.toString(), StyledString.COUNTER_STYLER);

            cell.setText(label.toString());
            cell.setStyleRanges(label.getStyleRanges());

            cell.setImage(imgJar);
        }
View Full Code Here

    @Override
    public void update(ViewerCell cell) {
        Resource resource = (Resource) cell.getElement();

        StyledString label = new StyledString();
        try {
            Capability identityCap = ResourceUtils.getIdentityCapability(resource);

            String name = ResourceUtils.getIdentity(identityCap);
            label.append(name);

            Version version = ResourceUtils.getVersion(identityCap);
            label.append(" " + version, StyledString.COUNTER_STYLER);
        } catch (IllegalArgumentException e) {
            label.append("<unknown>");
        }

        try {
            URI uri = ResourceUtils.getURI(ResourceUtils.getContentCapability(resource));
            label.append(" [" + uri + "]", StyledString.QUALIFIER_STYLER);
        } catch (IllegalArgumentException e) {
            // ignore
        }

        cell.setText(label.getString());
        cell.setStyleRanges(label.getStyleRanges());
        cell.setImage(bundleImg);
    }
View Full Code Here

TOP

Related Classes of org.eclipse.jface.viewers.StyledString

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.