protected LinkModel getInternalLink() { if (internalLink == null) { internalLink = new LinkModel("internal"); } return internalLink; }
/** * @param text text to that a renderer would display * @param target the target that a URL should load into. * @param template a string that represents a URL with * &{N} place holders for string substitution * @param args an array of strings which will be used for substitition */ public LinkModel(String text, String target, String template, String[] args) { setText(text); setTarget(target); setURL(createURL(template, args)); }
/** * Set the url and resets the visited flag. * * Think: keep list of visited urls here? */ public void setURL(URL url) { if (url == null) { throw new IllegalArgumentException("URL for link cannot be null"); } if (url.equals(getURL())) return; URL old = getURL(); this.url = url; firePropertyChange("URL", old, url); setVisited(false); }
/** * Set the display text. */ public void setText(String text) { String old = getText(); this.text = text; firePropertyChange("text", old, getText()); }
/** * Sets a flag to indicate if the link has been visited. The state of this * flag can be used to render the color of the link. */ public void setVisited(boolean visited) { boolean old = getVisited(); this.visited = visited; firePropertyChange(VISITED_PROPERTY, old, getVisited()); }
/** * * @param text * @param target * @param url */ public LinkModel(String text, String target, URL url) { setText(text); setTarget(target); setURL(url != null ? url : getDefaultURL()); }
protected void updateFromTarget() { if (getTarget() != null) { putValue(Action.NAME, getTarget().getText()); putValue(Action.SHORT_DESCRIPTION, getTarget().getURL().toString()); putValue(VISITED_KEY, new Boolean(getTarget().getVisited())); } else { Object[] keys = getKeys(); if (keys == null) return; for (int i = 0; i < keys.length; i++) { putValue(keys[i].toString(), null); } } }
public void setURLString(String howToURLString) { URL url = null; try { url = new URL(howToURLString); } catch (MalformedURLException e) { url = getDefaultURL(); LOG.warning("the given urlString is malformed: " + howToURLString + "\n falling back to default url: " + url); } setURL(url); }
public void visit(LinkModel link) { try { // make sure to reload editorPane.getDocument().putProperty(Document.StreamDescriptionProperty, null); // JW: editorPane defaults to asynchronous loading // no need to explicitly start a thread - really? editorPane.setPage(link.getURL()); link.setVisited(true); } catch (IOException e1) { editorPane.setText("<html>Error 404: couldn't show " + link.getURL() + " </html>"); } }
public String getText() { if (text != null) { return text; } else if (url != null) { return getURL().toString(); } return null; }
/** * installs a propertyChangeListener on the target and * updates the visual properties from the target. */ @Override protected void installTarget() { if (getTarget() != null) { getTarget().addPropertyChangeListener(getTargetListener()); } updateFromTarget(); }
public void addPropertyChangeListener(PropertyChangeListener l) { getPropertyChangeSupport().addPropertyChangeListener(l); }
/** * * @param text * @param target * @param url */ public LinkModel(String text, String target, URL url) { setText(text); setTarget(target); setURL(url != null ? url : getDefaultURL()); }
protected void updateFromTarget() { if (getTarget() != null) { putValue(Action.NAME, getTarget().getText()); putValue(Action.SHORT_DESCRIPTION, getTarget().getURL().toString()); putValue(VISITED_KEY, new Boolean(getTarget().getVisited())); } else { Object[] keys = getKeys(); if (keys == null) return; for (int i = 0; i < keys.length; i++) { putValue(keys[i].toString(), null); } } }
/** * Set the display text. */ public void setText(String text) { String old = getText(); this.text = text; firePropertyChange("text", old, getText()); }
public void setURLString(String howToURLString) { URL url = null; try { url = new URL(howToURLString); } catch (MalformedURLException e) { url = getDefaultURL(); LOG.warning("the given urlString is malformed: " + howToURLString + "\n falling back to default url: " + url); } setURL(url); }
/** * Sets a flag to indicate if the link has been visited. The state of this * flag can be used to render the color of the link. */ public void setVisited(boolean visited) { boolean old = getVisited(); this.visited = visited; firePropertyChange(VISITED_PROPERTY, old, getVisited()); }
public void visit(LinkModel link) { try { // make sure to reload editorPane.getDocument().putProperty(Document.StreamDescriptionProperty, null); // JW: editorPane defaults to asynchronous loading // no need to explicitly start a thread - really? editorPane.setPage(link.getURL()); link.setVisited(true); } catch (IOException e1) { editorPane.setText("<html>Error 404: couldn't show " + link.getURL() + " </html>"); } }