[Kafenio-cvs-commit] kafenio_main/src/de/xeinfach/kafenio/action CustomAction.java,1.3,1.4
Status: Beta
Brought to you by:
netsrak
|
From: <ne...@pr...> - 2004-01-28 01:18:05
|
Update of /cvsroot/kafenio/kafenio_main/src/de/xeinfach/kafenio/action In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27171/src/de/xeinfach/kafenio/action Modified Files: CustomAction.java Log Message: added new Hyperlink insertion dialog from maxym (insert link from server is currently not available.) Index: CustomAction.java =================================================================== RCS file: /cvsroot/kafenio/kafenio_main/src/de/xeinfach/kafenio/action/CustomAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CustomAction.java 22 Jan 2004 01:28:56 -0000 1.3 --- CustomAction.java 28 Jan 2004 01:16:52 -0000 1.4 *************** *** 14,18 **** import de.xeinfach.kafenio.component.dialogs.FontSelectorDialog; import de.xeinfach.kafenio.component.dialogs.SimpleInfoDialog; - import de.xeinfach.kafenio.component.dialogs.UserInputAnchorDialog; import de.xeinfach.kafenio.util.Translatrix; --- 14,17 ---- *************** *** 86,153 **** String currentAnchor = ""; String currentTarget = null; - // Somewhat ham-fisted code to obtain the first HREF in the selected text, - // which (if found) is passed to the URL HREF request dialog. - if(htmlTag.toString().equals(HTML.Tag.A.toString())) { - SimpleAttributeSet sasText = null; - for(int i = caretOffset; i < caretOffset + internalTextLength; i++) { - parentTextPane.select(i, i + 1); - sasText = new SimpleAttributeSet(parentTextPane.getCharacterAttributes()); - Enumeration attribEntries1 = sasText.getAttributeNames(); - while(attribEntries1.hasMoreElements() && currentAnchor.equals("")) { - Object entryKey = attribEntries1.nextElement(); - Object entryValue = sasText.getAttribute(entryKey); - if(entryKey.toString().equals(HTML.Tag.A.toString())) { - if(entryValue instanceof SimpleAttributeSet) { - Enumeration subAttributes = ((SimpleAttributeSet)entryValue).getAttributeNames(); - while(subAttributes.hasMoreElements()) { - Object subKey = subAttributes.nextElement(); - if(subKey.toString().toLowerCase().equals("href")) { - currentAnchor = - ((SimpleAttributeSet)entryValue).getAttribute(subKey).toString(); - } else if(subKey.toString().toLowerCase().equals("target")) { - currentTarget = - ((SimpleAttributeSet)entryValue).getAttribute(subKey).toString(); - } - if (!currentAnchor.equals("") && !subAttributes.hasMoreElements()) break; - } - } - } - } - if(!currentAnchor.equals("")) { break; } - } - } parentTextPane.select(caretOffset, caretOffset + internalTextLength); SimpleAttributeSet sasTag = new SimpleAttributeSet(); SimpleAttributeSet sasAttr = new SimpleAttributeSet(); - if(htmlTag.toString().equals(HTML.Tag.A.toString())) { - if(!htmlAttribs.containsKey("href")) { - UserInputAnchorDialog uidInput = - new UserInputAnchorDialog( parentKafenioPanel, - Translatrix.getTranslationString("AnchorDialogTitle"), - true, - currentAnchor, - currentTarget); ! String newAnchor = uidInput.getInputText(); ! String newTarget = uidInput.getTarget(); ! uidInput.dispose(); ! if(newAnchor != null && !newAnchor.equals("")) { ! htmlAttribs2.put("href", newAnchor); ! if (newTarget != null && !newTarget.equals("")) { ! htmlAttribs2.put("target", newTarget); ! System.out.println("linktarget: " + newTarget); ! } ! } else if(newAnchor != null && newAnchor.equals("")) { ! SimpleAttributeSet sasText = new SimpleAttributeSet(parentTextPane.getCharacterAttributes()); ! sasText.removeAttribute(HTML.Tag.A); ! parentTextPane.setCharacterAttributes(sasText, true); ! return; ! } else { ! parentKafenioPanel.repaint(); ! return; ! } ! } ! } else if(htmlTag.toString().equals(HTML.Tag.P.toString())) { SimpleAttributeSet sasText = new SimpleAttributeSet(parentTextPane.getCharacterAttributes()); SimpleAttributeSet sasPara = new SimpleAttributeSet(parentTextPane.getParagraphAttributes()); --- 85,95 ---- String currentAnchor = ""; String currentTarget = null; parentTextPane.select(caretOffset, caretOffset + internalTextLength); + SimpleAttributeSet sasTag = new SimpleAttributeSet(); SimpleAttributeSet sasAttr = new SimpleAttributeSet(); ! if(htmlTag.toString().equals(HTML.Tag.P.toString())) { SimpleAttributeSet sasText = new SimpleAttributeSet(parentTextPane.getCharacterAttributes()); SimpleAttributeSet sasPara = new SimpleAttributeSet(parentTextPane.getParagraphAttributes()); |