@Override public void setDefaultCompletionCellRenderer(ListCellRenderer<Object> r) { if (r==null) { r = createDefaultCompletionCellRenderer(); } if (r instanceof CompletionCellRenderer && Util.getUseSubstanceRenderers()) { if (UIManager.getLookAndFeel().getClass().getName(). contains(".Substance")) { CompletionCellRenderer ccr = (CompletionCellRenderer)r; delegateToSubstanceRenderer(ccr); } } renderer = r; }
/** * Attempts to open a web browser to the specified URI. * * @param uri The URI to open. If this is <code>null</code>, nothing happens and this method returns <code>false</code>. * @return Whether the operation was successful. This will be * <code>false</code> on JRE's older than 1.6. */ public static boolean browse(URI uri) { boolean success = false; if (uri!=null) { Object desktop = getDesktop(); if (desktop!=null) { try { Method m = desktop.getClass().getDeclaredMethod( "browse", new Class[] { URI.class }); m.invoke(desktop, new Object[] { uri }); success = true; } catch (RuntimeException re) { throw re; // Keep FindBugs happy } catch (Exception e) { // Ignore, just return "false" below. } } } return success; }
/** * Returns a decent "parameter" color based on the current default * foreground color. * * @return The parameter color to use. */ private String createParamColor() { return Util.isLightForeground(getForeground()) ? Util.getHexString(Util.getHyperlinkForeground()): "#aa0077"; }
if (Util.startsWithIgnoreCase(c.getInputText(), text)) { retVal.add(c); index++;
Util.browse(new URI(url.toString())); } catch (/*IO*/URISyntaxException ioe) { UIManager.getLookAndFeel().provideErrorFeedback(descArea);
"body { font-family: " + font.getFamily() + "; font-size: " + font.getSize() + "pt" + "; color: " + Util.getHexString(fg) + "; }"); Color linkFG = Util.getHyperlinkForeground(); doc.getStyleSheet().addRule( "a { color: " + Util.getHexString(linkFG) + "; }");
/** * Sets the location of this window relative to the given rectangle. * * @param r The visual position of the caret (in screen coordinates). */ public void setLocationRelativeTo(Rectangle r) { // Multi-monitor support - make sure the completion window (and // description window, if applicable) both fit in the same window in // a multi-monitor environment. To do this, we decide which monitor // the rectangle "r" is in, and use that one (just pick top-left corner // as the defining point). Rectangle screenBounds = Util.getScreenBoundsForPoint(r.x, r.y); //Dimension screenSize = tooltip.getToolkit().getScreenSize(); // Try putting our stuff "below" the caret first. int y = r.y + r.height + 5; // Get x-coordinate of completions. Try to align left edge with the // caret first. int x = r.x; if (x<screenBounds.x) { x = screenBounds.x; } else if (x+getWidth()>screenBounds.x+screenBounds.width) { // completions don't fit x = screenBounds.x + screenBounds.width - getWidth(); } setLocation(x, y); }
@Override public String getText(boolean selected) { // Strip out HTML tags return selected ? Util.stripHtml(text). replaceAll("<", "<").replaceAll(">", ">") : text; }
/** * Sets the color to use for function arguments. * * @param color The color to use. This is ignored if <code>null</code>. * @see #setTypeColor(Color) */ public void setParamColor(Color color) { if (color!=null) { paramColor = Util.getHexString(color); } }
if (Util.getShouldAllowDecoratingMainAutoCompleteWindows()) { PopupWindowDecorator decorator = PopupWindowDecorator.get(); if (decorator!=null) {
/** * Returns the color to use for hyperlink-style components. This method * will return <code>Color.blue</code> unless it appears that the current * LookAndFeel uses light text on a dark background, in which case a * brighter alternative is returned. * * @return The color to use for hyperlinks. */ static Color getHyperlinkForeground() { // This property is defined by all standard LaFs, even Nimbus (!), // but you never know what crazy LaFs there are... Color fg = UIManager.getColor("Label.foreground"); if (fg==null) { fg = new JLabel().getForeground(); } return isLightForeground(fg) ? LIGHT_HYPERLINK_FG : Color.blue; }
if (Util.startsWithIgnoreCase(c.getInputText(), text)) { list.add(c); index++;
Util.browse(new URI(url.toString())); } catch (/*IO*/URISyntaxException ioe) { UIManager.getLookAndFeel().provideErrorFeedback(null);
/** * Sets the location of this tool tip relative to the given rectangle. * * @param r The visual position of the caret (in screen coordinates). */ public void setLocationRelativeTo(Rectangle r) { // Multi-monitor support - make sure the completion window (and // description window, if applicable) both fit in the same window in // a multi-monitor environment. To do this, we decide which monitor // the rectangle "r" is in, and use that one (just pick top-left corner // as the defining point). Rectangle screenBounds = Util.getScreenBoundsForPoint(r.x, r.y); //Dimension screenSize = tooltip.getToolkit().getScreenSize(); // Try putting our stuff "above" the caret first. int y = r.y - 5 - tooltip.getHeight(); if (y<0) { y = r.y + r.height + 5; } // Get x-coordinate of completions. Try to align left edge with the // caret first. int x = r.x; if (x<screenBounds.x) { x = screenBounds.x; } else if (x+tooltip.getWidth()>screenBounds.x+screenBounds.width) { // completions don't fit x = screenBounds.x + screenBounds.width - tooltip.getWidth(); } tooltip.setLocation(x, y); }
@Override public String getText(boolean selected) { // Strip out HTML tags return selected ? Util.stripHtml(text). replaceAll("<", "<").replaceAll(">", ">") : text; }
/** * Sets the color to use for function/field types. Note that if * {@link #getShowTypes()} returns <code>false</code>, this property * effectively does nothing. * * @param color The color to use for types. This is ignored if * <code>null</code>. * @see #setShowTypes(boolean) * @see #setParamColor(Color) */ public void setTypeColor(Color color) { if (color!=null) { typeColor = Util.getHexString(color); } }
if (Util.getShouldAllowDecoratingMainAutoCompleteWindows()) { PopupWindowDecorator decorator = PopupWindowDecorator.get(); if (decorator!=null) {
if (Util.startsWithIgnoreCase(c.getInputText(), text)) { retVal.add(c); index++;
Util.browse(new URI(url.toString())); } catch (/*IO*/URISyntaxException ioe) { UIManager.getLookAndFeel().provideErrorFeedback(null);
@Override public void setUI(ListUI ui) { if (Util.getUseSubstanceRenderers() && SUBSTANCE_LIST_UI.equals(ui.getClass().getName())) { // Substance requires its special ListUI be installed for // its renderers to actually render (!), but long completion // lists (e.g. PHPCompletionProvider in RSTALanguageSupport) // will simply populate too slowly on initial display (when // calculating preferred size of all items), so in this case // we give a prototype cell value. CompletionProvider p = ac.getCompletionProvider(); BasicCompletion bc = new BasicCompletion(p, "Hello world"); setPrototypeCellValue(bc); } else { // Our custom UI that is faster for long HTML completion lists. ui = new FastListUI(); setPrototypeCellValue(null); } super.setUI(ui); }