List of usage examples for javax.swing.text BadLocationException printStackTrace
public void printStackTrace()
From source file:com.intuit.tank.tools.debugger.AgentDebuggerFrame.java
public void skip() { flowController.skip(currentRunningStep + 1); try {/*from w ww.ja v a 2s. co m*/ int lineStartOffset = scriptEditorTA.getLineStartOffset(currentRunningStep + 1); for (GutterIconInfo info : scriptEditorScrollPane.getGutter().getAllTrackingIcons()) { if (info.getMarkedOffset() == lineStartOffset && info.getIcon() == skippedIcon) { scriptEditorScrollPane.getGutter().removeTrackingIcon(info); } } scriptEditorScrollPane.getGutter() .addOffsetTrackingIcon(scriptEditorTA.getLineStartOffset(currentRunningStep + 1), skippedIcon); } catch (BadLocationException e) { e.printStackTrace(); } flowController.doNext(); }
From source file:com.intuit.tank.tools.debugger.AgentDebuggerFrame.java
protected void moveCursor(boolean moveUp) { try {/*from w w w. j a v a 2 s . c om*/ scriptEditorTA.grabFocus(); int caretLineNumber = this.scriptEditorTA.getCaretLineNumber() + (moveUp ? -1 : 1); if (caretLineNumber > 0 && moveUp) { scriptEditorTA.setCurrentLine(caretLineNumber); fireStepChanged(caretLineNumber); } int lastLine = scriptEditorTA.getLineOfOffset(this.scriptEditorTA.getText().length()); if (!moveUp && caretLineNumber <= lastLine) { scriptEditorTA.setCurrentLine(caretLineNumber); fireStepChanged(caretLineNumber); } } catch (BadLocationException e) { e.printStackTrace(); } }
From source file:com.intuit.tank.tools.debugger.AgentDebuggerFrame.java
private void doToggleSkip(int line) { try {//from w w w. j a v a 2 s . c o m boolean found = false; for (GutterIconInfo info : scriptEditorScrollPane.getGutter().getAllTrackingIcons()) { if (scriptEditorTA.getLineOfOffset(info.getMarkedOffset()) == line && info.getIcon() == skippedIcon) { scriptEditorScrollPane.getGutter().removeTrackingIcon(info); found = true; } } if (!found) { scriptEditorScrollPane.getGutter().addOffsetTrackingIcon(scriptEditorTA.getLineStartOffset(line), skippedIcon); } if (flowController != null) { if (flowController.getSkipList().contains(line)) { flowController.removeSkip(line); } else { flowController.skip(line); } } } catch (BadLocationException e) { e.printStackTrace(); } }
From source file:com.intuit.tank.tools.debugger.AgentDebuggerFrame.java
private void buildEditorString(HDTestPlan currentTestPlan) { StringBuilder sb = new StringBuilder(); if (currentTestPlan != null) { for (HDScriptGroup group : currentTestPlan.getGroup()) { for (HDScript script : group.getGroupSteps()) { for (HDScriptUseCase useCase : script.getUseCase()) { for (TestStep step : useCase.getScriptSteps()) { if (sb.length() != 0) { sb.append('\n'); }// ww w.java 2s .c o m sb.append(step.getInfo()); steps.add(new DebugStep(step)); } } } } } GutterIconInfo[] allTrackingIcons = scriptEditorScrollPane.getGutter().getAllTrackingIcons(); List<IconContainer> icons = new ArrayList<IconContainer>(allTrackingIcons.length); for (GutterIconInfo gi : allTrackingIcons) { try { icons.add(new IconContainer(scriptEditorTA.getLineOfOffset(gi.getMarkedOffset()), gi.getIcon())); } catch (BadLocationException e) { e.printStackTrace(); } } scriptEditorScrollPane.getGutter().removeAllTrackingIcons(); scriptEditorTA.setText(sb.toString()); for (IconContainer ic : icons) { try { scriptEditorScrollPane.getGutter() .addOffsetTrackingIcon(scriptEditorTA.getLineStartOffset(ic.getLine()), ic.getIcon()); } catch (BadLocationException e) { e.printStackTrace(); } } }
From source file:com.intuit.tank.tools.debugger.AgentDebuggerFrame.java
public void stepFinished(final TestStepContext context) { try {//from w w w .j a v a 2 s. co m SwingUtilities.invokeAndWait(new Runnable() { public void run() { actionComponents.doneStepping(); DebugStep debugStep = steps.get(currentRunningStep); if (debugStep != null) { debugStep.setExitVariables(context.getVariables().getVaribleValues()); debugStep.setRequest(context.getRequest()); debugStep.setResponse(context.getResponse()); } try { if (context.getResponse() != null && (context.getResponse().getHttpCode() >= 400 || context.getResponse().getHttpCode() == -1)) { // highlight the line int lineStartOffset = scriptEditorTA.getLineStartOffset(currentRunningStep); int lineEndOffset = scriptEditorTA.getLineEndOffset(currentRunningStep); scriptEditorTA.getHighlighter().addHighlight(lineStartOffset, lineEndOffset, new SquiggleUnderlineHighlightPainter(Color.RED)); } } catch (BadLocationException e1) { e1.printStackTrace(); } if (!context.getErrors().isEmpty()) { try { debugStep.setErrors(context.getErrors()); scriptEditorScrollPane.getGutter().addOffsetTrackingIcon( scriptEditorTA.getLineStartOffset(currentRunningStep), errorIcon); } catch (BadLocationException e) { e.printStackTrace(); } } fireStepExited(context.getTestStep().getStepIndex()); } }); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.intuit.tank.tools.debugger.AgentDebuggerFrame.java
public void start() { startWaiting();//www . j av a 2s . c o m flowController = new DebuggerFlowController(this); scriptEditorTA.getHighlighter().removeAllHighlights(); actionComponents.start(); loggerTA.setText(""); loggerTA.setCaretPosition(0); loggerTA.repaint(); new Thread(new Runnable() { public void run() { fireStepChanged(-1); if (!steps.isEmpty()) { for (DebugStep step : steps) { step.clear(); } setCurrentStep(-1); for (GutterIconInfo gi : scriptEditorScrollPane.getGutter().getAllTrackingIcons()) { if (gi.getIcon() == errorIcon) { scriptEditorScrollPane.getGutter().removeTrackingIcon(gi); } else if (gi.getIcon() == skippedIcon) { try { flowController.skip(scriptEditorTA.getLineOfOffset(gi.getMarkedOffset())); } catch (BadLocationException e) { e.printStackTrace(); } } } // start apiHarness and get the variables.... try { createHarness(); runningThread = new Thread(new Runnable() { public void run() { harness.runConcurrentTestPlans(); } }); runningThread.start(); } catch (Exception e) { showError("Error starting test: " + e); actionComponents.stop(); } } else { stopWaiting(); actionComponents.stop(); } } }).start(); }
From source file:com.intuit.tank.tools.debugger.AgentDebuggerFrame.java
/** * @throws HeadlessException//www.j a v a 2 s .c o m */ public AgentDebuggerFrame(final boolean isStandalone, String serviceUrl) throws HeadlessException { super("Intuit Tank Agent Debugger"); workingDir = PanelBuilder.createWorkingDir(this, serviceUrl); setSize(new Dimension(1024, 800)); setBounds(new Rectangle(getSize())); setPreferredSize(getSize()); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setLayout(new BorderLayout()); this.standalone = isStandalone; addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent e) { quit(); } }); errorIcon = ActionProducer.getIcon("bullet_error.png", IconSize.SMALL); modifiedIcon = ActionProducer.getIcon("bullet_code_change.png", IconSize.SMALL); skippedIcon = ActionProducer.getIcon("skip.png", IconSize.SMALL); this.glassPane = new InfiniteProgressPanel(); setGlassPane(glassPane); debuggerActions = new ActionProducer(this, serviceUrl); requestResponsePanel = new RequestResponsePanel(this); requestResponsePanel.init(); testPlanChooser = new JComboBox(); testPlanChooser.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent event) { if (event.getItem() != null) { HDTestPlan selected = (HDTestPlan) event.getItem(); if (!selected.equals(currentTestPlan)) { setCurrentTestPlan(selected); } } } }); tankClientChooser = new JComboBox<TankClientChoice>(); debuggerActions.setChoiceComboBoxOptions(tankClientChooser); actionComponents = new ActionComponents(standalone, testPlanChooser, tankClientChooser, debuggerActions); addScriptChangedListener(actionComponents); setJMenuBar(actionComponents.getMenuBar()); Component topPanel = PanelBuilder.createTopPanel(actionComponents); Component bottomPanel = PanelBuilder.createBottomPanel(this); Component contentPanel = PanelBuilder.createContentPanel(this); final JPopupMenu popup = actionComponents.getPopupMenu(); scriptEditorTA.setPopupMenu(null); scriptEditorTA.addMouseListener(new MouseAdapter() { int lastHash; @Override public void mousePressed(MouseEvent e) { maybeShow(e); } @Override public void mouseReleased(MouseEvent e) { maybeShow(e); } private void maybeShow(MouseEvent e) { if (lastHash == getHash(e)) { return; } if (e.isPopupTrigger()) { // select the line try { int offset = scriptEditorTA.viewToModel(e.getPoint()); Rectangle modelToView = scriptEditorTA.modelToView(offset); Point point = new Point(modelToView.x + 1, e.getPoint().y); if (modelToView.contains(point)) { if (!multiSelect) { int line = scriptEditorTA.getLineOfOffset(offset); scriptEditorTA.setCurrentLine(line); } popup.show(e.getComponent(), e.getX(), e.getY()); } } catch (BadLocationException e1) { e1.printStackTrace(); } } else if (e.isShiftDown()) { int line = scriptEditorTA.getCaretLineNumber(); int start = Math.min(line, lastLine); int end = Math.max(line, lastLine); multiSelect = end - start > 1; if (multiSelect) { multiSelectStart = start; multiSelectEnd = end; try { scriptEditorTA.setEnabled(true); scriptEditorTA.select(scriptEditorTA.getLineStartOffset(start), scriptEditorTA.getLineEndOffset(end)); scriptEditorTA.setEnabled(false); } catch (BadLocationException e1) { e1.printStackTrace(); multiSelect = false; } } } else { multiSelect = false; lastLine = scriptEditorTA.getCaretLineNumber(); } lastHash = getHash(e); } private int getHash(MouseEvent e) { return new HashCodeBuilder().append(e.getButton()).append(e.getSource().hashCode()) .append(e.getPoint()).toHashCode(); } }); JSplitPane mainSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT); mainSplit.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); mainSplit.setTopComponent(contentPanel); mainSplit.setBottomComponent(bottomPanel); mainSplit.setDividerLocation(600); mainSplit.setResizeWeight(0.8D); mainSplit.setDividerSize(5); add(topPanel, BorderLayout.NORTH); add(mainSplit, BorderLayout.CENTER); WindowUtil.centerOnScreen(this); pack(); KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); manager.addKeyEventDispatcher(new KeyEventDispatcher() { @Override public boolean dispatchKeyEvent(KeyEvent e) { if (e.getID() == KeyEvent.KEY_PRESSED) { handleKeyEvent(e); } return false; } }); }
From source file:com.centurylink.mdw.designer.pages.ExportHelper.java
private void printElementHtml(Element element, Object parent, int depth, Font font, int parentLevel) { String tag = element.getName(); Object av;/*from ww w .ja v a 2 s . co m*/ if (element instanceof HTMLDocument.RunElement) { HTMLDocument.RunElement re = (HTMLDocument.RunElement) element; int start = re.getStartOffset(); int end = re.getEndOffset(); try { String content = re.getDocument().getText(start, end - start); printAttributesHtml(re); av = re.getAttribute(CSS.Attribute.FONT_SIZE); String fontsize = av == null ? null : av.toString(); av = re.getAttribute(CSS.Attribute.FONT_FAMILY); String fontfamily = av == null ? null : av.toString(); av = re.getAttribute(CSS.Attribute.COLOR); String fontcolor = av == null ? null : av.toString(); if (fontcolor != null || fontsize != null || fontfamily != null) { if (fontfamily == null) fontfamily = font.getFamilyname(); float size = fontsize == null ? font.getSize() : (Float.parseFloat(fontsize) + 9); int style = font.getStyle(); Color color; if (fontcolor != null) { color = Color.decode(fontcolor); } else color = font.getColor(); font = FontFactory.getFont(fontfamily, size, style, color); } if (parent instanceof Paragraph) { ((Paragraph) parent).add(new Chunk(content, font)); } else { System.err.println("chunk with parent " + (parent == null ? "null" : parent.getClass().getName()) + ": " + content); } } catch (BadLocationException e) { e.printStackTrace(); } } else if (element instanceof HTMLDocument.BlockElement) { HTMLDocument.BlockElement be = (HTMLDocument.BlockElement) element; printAttributesHtml(be); av = be.getAttribute(javax.swing.text.html.HTML.Attribute.ALIGN); String align = av == null ? null : av.toString(); if (tag.equalsIgnoreCase("html")) { printElementChildrenHtml(element, parent, depth + 1, font, parentLevel); } else if (tag.equalsIgnoreCase("head")) { // do nothing } else if (tag.equalsIgnoreCase("body")) { printElementChildrenHtml(element, parent, depth + 1, font, parentLevel); } else if (tag.equalsIgnoreCase("p")) { if (parent instanceof Section) { Paragraph paragraph = new Paragraph(); if (align != null) { paragraph.setAlignment(align); } printElementChildrenHtml(element, paragraph, depth + 1, normalFont, parentLevel); ((Section) parent).add(paragraph); } else { System.err.println("p with parent " + (parent == null ? "null" : parent.getClass().getName())); } } else if (tag.equalsIgnoreCase("h1") || tag.equalsIgnoreCase("h2") || tag.equalsIgnoreCase("h3")) { if (parent instanceof Section) { Paragraph title = new Paragraph(); printElementChildrenHtml(element, title, depth + 1, subSectionFont, parentLevel); ((Section) parent).addSection(title, parentLevel == 0 ? 0 : (parentLevel + 1)); } else { System.err .println("list with parent " + (parent == null ? "null" : parent.getClass().getName())); } } else if (tag.equalsIgnoreCase("ul")) { if (parent instanceof Section) { com.lowagie.text.List list = new com.lowagie.text.List(false, false, 20.0f); printElementChildrenHtml(element, list, depth + 1, normalFont, parentLevel); ((Section) parent).add(list); } else { System.err .println("list with parent " + (parent == null ? "null" : parent.getClass().getName())); } } else if (tag.equalsIgnoreCase("ol")) { if (parent instanceof Section) { com.lowagie.text.List list = new com.lowagie.text.List(true, false, 20.0f); printElementChildrenHtml(element, list, depth + 1, normalFont, parentLevel); ((Section) parent).add(list); } else { System.err .println("list with parent " + (parent == null ? "null" : parent.getClass().getName())); } } else if (tag.equalsIgnoreCase("li")) { ListItem li = new ListItem(); li.setSpacingAfter(0.0f); printElementChildrenHtml(element, li, depth + 1, normalFont, parentLevel); ((com.lowagie.text.List) parent).add(li); } else if (tag.equalsIgnoreCase("p-implied")) { if (parent instanceof ListItem) { Paragraph paragraph = new Paragraph(); printElementChildrenHtml(element, paragraph, depth + 1, normalFont, parentLevel); ((ListItem) parent).add(paragraph); } else if (parent instanceof Cell) { Paragraph paragraph = new Paragraph(); printElementChildrenHtml(element, paragraph, depth + 1, normalFont, parentLevel); ((Cell) parent).add(paragraph); } } else if (tag.equalsIgnoreCase("table")) { try { Table table = new Table(3); table.setBorderWidth(1); table.setBorderColor(new Color(0, 128, 128)); table.setPadding(1.0f); table.setSpacing(0.5f); Cell c = new Cell("header"); c.setHeader(true); c.setColspan(3); table.addCell(c); table.endHeaders(); printElementChildrenHtml(element, table, depth + 1, normalFont, parentLevel); // TODO ((Section) parent).add(table); } catch (BadElementException e) { e.printStackTrace(); } } else if (tag.equalsIgnoreCase("tr")) { printElementChildrenHtml(element, parent, depth + 1, normalFont, parentLevel); // TODO } else if (tag.equalsIgnoreCase("td")) { Cell cell = new Cell(); printElementChildrenHtml(element, cell, depth + 1, normalFont, parentLevel); // TODO ((Table) parent).addCell(cell); } else { System.err.println("Unknown element " + element.getName()); printElementChildrenHtml(element, parent, depth + 1, normalFont, parentLevel); } } else { return; // could be BidiElement - not sure what it is } }
From source file:net.java.sip.communicator.impl.gui.main.chat.ChatWritePanel.java
/** * When CTRL+Z is pressed invokes the <code>ChatWritePanel.undo()</code> * method, when CTRL+R is pressed invokes the * <code>ChatWritePanel.redo()</code> method. * * @param e the <tt>KeyEvent</tt> that notified us *///from w ww.j a va 2 s .co m public void keyPressed(KeyEvent e) { if ((e.getModifiers() & KeyEvent.CTRL_MASK) == KeyEvent.CTRL_MASK && (e.getKeyCode() == KeyEvent.VK_Z) // And not ALT(right ALT gives CTRL + ALT). && (e.getModifiers() & KeyEvent.ALT_MASK) != KeyEvent.ALT_MASK) { if (undo.canUndo()) undo(); } else if ((e.getModifiers() & KeyEvent.CTRL_MASK) == KeyEvent.CTRL_MASK && (e.getKeyCode() == KeyEvent.VK_R) // And not ALT(right ALT gives CTRL + ALT). && (e.getModifiers() & KeyEvent.ALT_MASK) != KeyEvent.ALT_MASK) { if (undo.canRedo()) redo(); } else if (e.getKeyCode() == KeyEvent.VK_TAB) { if (!(chatPanel.getChatSession() instanceof ConferenceChatSession)) return; e.consume(); int index = ((JEditorPane) e.getSource()).getCaretPosition(); StringBuffer message = new StringBuffer(chatPanel.getMessage()); int position = index - 1; while (position > 0 && (message.charAt(position) != ' ')) { position--; } if (position != 0) position++; String sequence = message.substring(position, index); if (sequence.length() <= 0) { // Do not look for matching contacts if the matching pattern is // 0 chars long, since all contacts will match. return; } Iterator<ChatContact<?>> iter = chatPanel.getChatSession().getParticipants(); ArrayList<String> contacts = new ArrayList<String>(); while (iter.hasNext()) { ChatContact<?> c = iter.next(); if (c.getName().length() >= (index - position) && c.getName().substring(0, index - position).equals(sequence)) { message.replace(position, index, c.getName().substring(0, index - position)); contacts.add(c.getName()); } } if (contacts.size() > 1) { char key = contacts.get(0).charAt(index - position - 1); int pos = index - position - 1; boolean flag = true; while (flag) { try { for (String name : contacts) { if (key != name.charAt(pos)) { flag = false; } } if (flag) { pos++; key = contacts.get(0).charAt(pos); } } catch (IndexOutOfBoundsException exp) { flag = false; } } message.replace(position, index, contacts.get(0).substring(0, pos)); Iterator<String> contactIter = contacts.iterator(); String contactList = "<DIV align='left'><h5>"; while (contactIter.hasNext()) { contactList += contactIter.next() + " "; } contactList += "</h5></DIV>"; chatPanel.getChatConversationPanel().appendMessageToEnd(contactList, ChatHtmlUtils.HTML_CONTENT_TYPE); } else if (contacts.size() == 1) { String limiter = (position == 0) ? ": " : ""; message.replace(position, index, contacts.get(0) + limiter); } try { ((JEditorPane) e.getSource()).getDocument().remove(0, ((JEditorPane) e.getSource()).getDocument().getLength()); ((JEditorPane) e.getSource()).getDocument().insertString(0, message.toString(), null); } catch (BadLocationException ex) { ex.printStackTrace(); } } else if (e.getKeyCode() == KeyEvent.VK_UP) { // Only enters editing mode if the write panel is empty in // order not to lose the current message contents, if any. if (this.chatPanel.getLastSentMessageUID() != null && this.chatPanel.isWriteAreaEmpty()) { this.chatPanel.startLastMessageCorrection(); e.consume(); } } else if (e.getKeyCode() == KeyEvent.VK_DOWN) { if (chatPanel.isMessageCorrectionActive()) { Document doc = editorPane.getDocument(); if (editorPane.getCaretPosition() == doc.getLength()) { chatPanel.stopMessageCorrection(); } } } }
From source file:com.centurylink.mdw.designer.pages.ExportHelper.java
private Object generateElementHtml(Element element, int depth, Font font) { String tag = element.getName(); Object myself;/*from w ww.ja va2 s . c o m*/ Object av; if (element instanceof HTMLDocument.RunElement) { HTMLDocument.RunElement re = (HTMLDocument.RunElement) element; int start = re.getStartOffset(); int end = re.getEndOffset(); try { String content = re.getDocument().getText(start, end - start); HtmlAttr htmlattr = printAttributesHtml(re); av = re.getAttribute(CSS.Attribute.FONT_SIZE); String fontsize = av == null ? null : av.toString(); av = re.getAttribute(CSS.Attribute.FONT_FAMILY); String fontfamily = av == null ? null : av.toString(); av = re.getAttribute(CSS.Attribute.COLOR); String fontcolor = av == null ? null : av.toString(); if (fontcolor != null || fontsize != null || fontfamily != null) { if (fontfamily == null) fontfamily = font.getFamilyname(); if (fontsize != null && fontsize.endsWith("pt")) fontsize = fontsize.substring(0, fontsize.indexOf("pt")); float size = fontsize == null ? font.getSize() : (Float.parseFloat(fontsize) + 8); int style = font.getStyle(); Color color; if (fontcolor != null) { color = Color.decode(fontcolor); } else color = font.getColor(); font = FontFactory.getFont(fontfamily, size, style, color); } else if (htmlattr.bold || htmlattr.italic) { String family = font.getFamilyname(); float size = font.getSize(); Color color = font.getColor(); if (htmlattr.bold && htmlattr.italic) font = FontFactory.getFont(family, size, Font.BOLDITALIC, color); else if (htmlattr.italic) font = FontFactory.getFont(family, size, Font.ITALIC, color); else if (htmlattr.bold) font = FontFactory.getFont(family, size, Font.BOLD); } myself = new Chunk(content, font); } catch (BadLocationException e) { e.printStackTrace(); myself = null; } } else if (element instanceof HTMLDocument.BlockElement) { HTMLDocument.BlockElement be = (HTMLDocument.BlockElement) element; HtmlAttr htmlattr = printAttributesHtml(be); if (htmlattr.bold) { System.out.println("+++BOLD!!!"); } av = be.getAttribute(javax.swing.text.html.HTML.Attribute.ALIGN); String align = av == null ? null : av.toString(); if (htmlattr.bold || htmlattr.italic) { String family = font.getFamilyname(); float size = font.getSize(); Color color = font.getColor(); if (htmlattr.bold && htmlattr.italic) font = FontFactory.getFont(family, size, Font.BOLDITALIC, color); else if (htmlattr.italic) font = FontFactory.getFont(family, size, Font.ITALIC, color); else if (htmlattr.bold) font = FontFactory.getFont(family, size, Font.BOLD, Color.blue); } if (tag.equalsIgnoreCase("html")) { myself = generateElementChildrenHtml(element, depth + 1, font); } else if (tag.equalsIgnoreCase("head")) { myself = null; } else if (tag.equalsIgnoreCase("body")) { myself = generateElementChildrenHtml(element, depth + 1, font); } else if (tag.equalsIgnoreCase("p") || tag.equalsIgnoreCase("p-implied")) { List<Object> children = generateElementChildrenHtml(element, depth + 1, normalFont); Paragraph paragraph = new Paragraph(); paragraph.setFirstLineIndent(0F); for (Object child : children) { if (child instanceof Chunk) { Chunk chunk = (Chunk) child; /*if (!chunk.getContent().equals("\n"))*/ paragraph.add(chunk); } else paragraph.add(child); } if (align != null) paragraph.setAlignment(align); myself = paragraph; } else if (tag.equalsIgnoreCase("h1") || tag.equalsIgnoreCase("h2") || tag.equalsIgnoreCase("h3")) { List<Object> children = generateElementChildrenHtml(element, depth + 1, subSectionFont); Paragraph title = new Paragraph(); for (Object child : children) { title.add(child); } myself = new TempSectionPdf(title); } else if (tag.equalsIgnoreCase("ul")) { com.lowagie.text.List list = new com.lowagie.text.List(false, false, 20.0f); list.setIndentationLeft(25.0f); List<Object> children = generateElementChildrenHtml(element, depth + 1, normalFont); for (Object child : children) { list.add(child); } myself = list; } else if (tag.equalsIgnoreCase("ol")) { com.lowagie.text.List list = new com.lowagie.text.List(true, false, 20.0f); list.setIndentationLeft(25.0f); List<Object> children = generateElementChildrenHtml(element, depth + 1, normalFont); for (Object child : children) { list.add(child); } myself = list; } else if (tag.equalsIgnoreCase("li")) { ListItem li = new ListItem(); li.setSpacingAfter(0.0f); List<Object> children = generateElementChildrenHtml(element, depth + 1, normalFont); for (Object child : children) { li.add(child); } myself = li; } else if (tag.equalsIgnoreCase("table")) { List<Object> rows = generateElementChildrenHtml(element, depth + 1, normalFont); try { int ncols = 0; for (Object row : rows) { if (row instanceof List<?>) { int n = ((List<?>) row).size(); if (n > ncols) ncols = n; } } Table table = new Table(2); table.setBorderWidth(1); table.setBorderColor(new Color(0, 128, 128)); table.setPadding(1.0f); table.setSpacing(0.5f); Cell c = new Cell("header"); c.setHeader(true); c.setColspan(ncols); table.addCell(c); table.endHeaders(); for (Object row : rows) { if (row instanceof List<?>) { for (Object cell : (List<?>) row) { if (cell instanceof Cell) table.addCell((Cell) cell); } } } myself = table; } catch (BadElementException e) { e.printStackTrace(); myself = null; } } else if (tag.equalsIgnoreCase("tr")) { List<Object> children = generateElementChildrenHtml(element, depth + 1, normalFont); myself = children; } else if (tag.equalsIgnoreCase("td")) { Cell cell = new Cell(); List<Object> children = generateElementChildrenHtml(element, depth + 1, normalFont); for (Object child : children) { cell.add(child); } myself = cell; } else if (tag.equalsIgnoreCase("div")) { List<Object> children = generateElementChildrenHtml(element, depth + 1, normalFont); Paragraph paragraph = new Paragraph(); paragraph.setFirstLineIndent(0F); for (Object child : children) { paragraph.add(child); } if (align != null) paragraph.setAlignment(align); myself = paragraph; } else { System.err.println("Unknown element " + element.getName()); myself = null; } } else { myself = null; // could be BidiElement - not sure what it is } return myself; }