public void updateAttribsFromComponents() { if (widthCB.isSelected()) { String w = widthField.getModel().getValue().toString(); if (widthCombo.getSelectedIndex() == 0) w += "%"; // $NON-NLS-1$ attribs.put("width", w); // $NON-NLS-1$ } else attribs.remove("width"); // $NON-NLS-1$ if (alignCB.isSelected()) attribs.put("align", alignCombo.getSelectedItem().toString()); // $NON-NLS-1$ else attribs.remove("align"); // $NON-NLS-1$ if (borderCB.isSelected()) attribs.put( "border", //$NON-NLS-1$ borderField.getModel().getValue().toString()); else attribs.remove("border"); // $NON-NLS-1$ if (cellSpacingCB.isSelected()) attribs.put( "cellspacing", //$NON-NLS-1$ cellSpacingField.getModel().getValue().toString()); else attribs.remove("cellspacing"); // $NON-NLS-1$ if (cellPaddingCB.isSelected()) attribs.put( "cellpadding", //$NON-NLS-1$ cellPaddingField.getModel().getValue().toString()); else attribs.remove("cellpadding"); // $NON-NLS-1$ if (bgPanel.isSelected()) attribs.put("bgcolor", bgPanel.getColor()); // $NON-NLS-1$ else attribs.remove("bgcolor"); // $NON-NLS-1$ }
public void updateComponentsFromAttribs() { if (attribs.containsKey("width")) // $NON-NLS-1$ { widthCB.setSelected(true); String w = attribs.get("width").toString(); // $NON-NLS-1$ if (w.endsWith("%")) // $NON-NLS-1$ w = w.substring(0, w.length() - 1); else widthCombo.setSelectedIndex(1); widthField.setEnabled(true); try { widthField.getModel().setValue(new Integer(w)); } catch (Exception ex) { ex.printStackTrace(); } } else { widthCB.setSelected(false); widthField.setEnabled(false); widthCombo.setEnabled(false); } if (attribs.containsKey("align")) // $NON-NLS-1$ { alignCB.setSelected(true); alignCombo.setEnabled(true); alignCombo.setSelectedItem(attribs.get("align")); // $NON-NLS-1$ } else { alignCB.setSelected(false); alignCombo.setEnabled(false); } if (attribs.containsKey("border")) // $NON-NLS-1$ { borderCB.setSelected(true); borderField.setEnabled(true); try { borderField .getModel() .setValue(new Integer(attribs.get("border").toString())); // $NON-NLS-1$ } catch (Exception ex) { ex.printStackTrace(); } } else { borderCB.setSelected(false); borderField.setEnabled(false); } if (attribs.containsKey("cellpadding")) // $NON-NLS-1$ { cellPaddingCB.setSelected(true); cellPaddingField.setEnabled(true); try { cellPaddingField .getModel() .setValue(new Integer(attribs.get("cellpadding").toString())); // $NON-NLS-1$ } catch (Exception ex) { ex.printStackTrace(); } } else { cellPaddingCB.setSelected(false); cellPaddingField.setEnabled(false); } if (attribs.containsKey("cellspacing")) // $NON-NLS-1$ { cellSpacingCB.setSelected(true); cellSpacingField.setEnabled(true); try { cellSpacingField .getModel() .setValue(new Integer(attribs.get("cellspacing").toString())); // $NON-NLS-1$ } catch (Exception ex) { ex.printStackTrace(); } } else { cellSpacingCB.setSelected(false); cellSpacingField.setEnabled(false); } if (attribs.containsKey("bgcolor")) // $NON-NLS-1$ { bgPanel.setSelected(true); bgPanel.setColor(attribs.get("bgcolor").toString()); // $NON-NLS-1$ } else { bgPanel.setSelected(false); } }