public void installUI(JComponent c) { searchnav = (JHelpSearchNavigator) c; HelpModel helpmodel = searchnav.getModel(); searchnav.setLayout(new BorderLayout()); searchnav.addPropertyChangeListener(this); searchnav.addComponentListener(this); if (helpmodel != null) { helpmodel.addHelpModelListener(this); } JLabel search = new JLabel(HelpUtilities.getString(HelpUtilities.getLocale(c), "search.findLabel")); searchparams = new JTextField("", 20); search.setLabelFor(searchparams); searchparams.addActionListener(searchAction); JPanel box = new JPanel(); box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS)); box.add(search); box.add(searchparams); searchnav.add("North", box); topNode = new DefaultMutableTreeNode(); lastTOCnode = null; tree = new JTree(topNode); // public String convertValueToText(Object val TreeSelectionModel tsm = tree.getSelectionModel(); tsm.addTreeSelectionListener(this); tree.setShowsRootHandles(false); tree.setRootVisible(false); sp = new JScrollPane(); sp.getViewport().add(tree); searchnav.add("Center", sp); reloadData(); }
/** * Does Nothing * * @param selected, true to enable, false to disable. */ public void setNodeOrLinkSelected(boolean selected) { if (tbrToolBar != null) { UIViewFrame frame = ProjectCompendium.APP.getCurrentFrame(); if (selected && frame instanceof UIMapViewFrame) { UIMapViewFrame oMapFrame = (UIMapViewFrame) frame; UIViewPane pane = oMapFrame.getViewPane(); int nLinkCount = pane.getNumberOfSelectedLinks(); if (nLinkCount == 0) return; bJustSetting = true; int i = 0; UILink link = null; LinkProperties linkProps = null; boolean bDefaultLinkStyle = false; boolean bDefaultLinkDashed = false; boolean bDefaultLinkWeight = false; boolean bDefaultLinkColour = false; boolean bDefaultArrowType = false; LinkProperties defaultprops = UIUtilities.getLinkProperties(""); int linkstyle = defaultprops.getLinkStyle(); int linkdashed = defaultprops.getLinkDashed(); int linkweight = defaultprops.getLinkWeight(); int linkcolour = defaultprops.getLinkColour(); int arrowtype = defaultprops.getArrowType(); for (Enumeration e = pane.getSelectedLinks(); e.hasMoreElements(); ) { link = (UILink) e.nextElement(); linkProps = link.getLinkProperties(); if (i == 0) { linkstyle = linkProps.getLinkStyle(); linkdashed = linkProps.getLinkDashed(); linkweight = linkProps.getLinkWeight(); linkcolour = linkProps.getLinkColour(); arrowtype = linkProps.getArrowType(); i++; } else { if (arrowtype != linkProps.getArrowType()) { bDefaultArrowType = true; } if (linkstyle != linkProps.getLinkStyle()) { bDefaultLinkStyle = true; } if (linkdashed != linkProps.getLinkDashed()) { bDefaultLinkDashed = true; } if (linkweight != linkProps.getLinkWeight()) { bDefaultLinkWeight = true; } if (linkcolour != linkProps.getLinkColour()) { bDefaultLinkColour = true; } } } tbrToolBar.setEnabled(true); if (bDefaultLinkColour) { selectedLinkColour = new Color(defaultprops.getLinkColour()); } else { selectedLinkColour = new Color(linkcolour); } linkColourPanel.setEnabled(true); txtLinkColour.setEnabled(true); cbLineWeight.setEnabled(true); if (bDefaultLinkWeight) { cbLineWeight.setSelectedIndex(defaultprops.getLinkWeight() - 1); } else { cbLineWeight.setSelectedIndex(linkweight - 1); } cbArrows.setEnabled(true); if (bDefaultArrowType) { cbArrows.setSelectedIndex(defaultprops.getArrowType()); } else { cbArrows.setSelectedIndex(arrowtype); } cbLinkStyle.setEnabled(true); if (bDefaultLinkStyle) { cbLinkStyle.setSelectedIndex(defaultprops.getLinkStyle()); } else { cbLinkStyle.setSelectedIndex(linkstyle); } cbLinkDashed.setEnabled(true); if (bDefaultLinkDashed) { cbLinkDashed.setSelectedIndex(defaultprops.getLinkDashed()); } else { cbLinkDashed.setSelectedIndex(linkdashed); } bJustSetting = false; } else if (!selected) { bJustSetting = true; linkColourPanel.setEnabled(false); txtLinkColour.setEnabled(false); tbrToolBar.setEnabled(false); cbArrows.setEnabled(false); cbLineWeight.setEnabled(false); cbLinkStyle.setEnabled(false); cbLinkDashed.setEnabled(false); bJustSetting = false; } } }
/** * Create a choicebox for link line style options and return the panel it is in. * * @return JPanel the panel holding the new choicebox for the link style options. */ private JPanel createLinkDashedChoiceBox() { JPanel drawPanel = new JPanel(new BorderLayout()); CSH.setHelpIDString(drawPanel, "toolbars.formatlink"); // $NON-NLS-1$ cbLinkDashed = new JComboBox(); cbLinkDashed.setToolTipText( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.selectDashed")); // $NON-NLS-1$ cbLinkDashed.setOpaque(true); cbLinkDashed.setEditable(false); cbLinkDashed.setEnabled(false); cbLinkDashed.setMaximumRowCount(10); cbLinkDashed.setFont(new Font("Dialog", Font.PLAIN, 10)); // $NON-NLS-1$ cbLinkDashed.addItem( new String( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.plainLine"))); //$NON-NLS-1$ cbLinkDashed.addItem( new String( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.largeDashes"))); //$NON-NLS-1$ cbLinkDashed.addItem( new String( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.smallDashes"))); //$NON-NLS-1$ cbLinkDashed.validate(); cbLinkDashed.setSelectedIndex(0); DefaultListCellRenderer drawRenderer = new DefaultListCellRenderer() { public Component getListCellRendererComponent( JList list, Object value, int modelIndex, boolean isSelected, boolean cellHasFocus) { if (list != null) { if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } } setText((String) value); return this; } }; cbLinkDashed.setRenderer(drawRenderer); ActionListener drawActionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { onUpdateLinkDashed(cbLinkDashed.getSelectedIndex()); } }; cbLinkDashed.addActionListener(drawActionListener); drawPanel.add(new JLabel(" "), BorderLayout.WEST); // $NON-NLS-1$ drawPanel.add(cbLinkDashed, BorderLayout.CENTER); return drawPanel; }
/** * Create a choicbox for link line thickness options and return the panel it is in. * * @return JPanel the panel holding the new choicebox for the line thickness options. */ private JPanel createWeightChoiceBox() { JPanel drawPanel = new JPanel(new BorderLayout()); CSH.setHelpIDString(drawPanel, "toolbars.formatlink"); // $NON-NLS-1$ cbLineWeight = new JComboBox(); cbLineWeight.setToolTipText( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.selectWeight")); // $NON-NLS-1$ cbLineWeight.setOpaque(true); cbLineWeight.setEditable(false); cbLineWeight.setEnabled(false); cbLineWeight.setMaximumRowCount(10); cbLineWeight.setFont(new Font("Dialog", Font.PLAIN, 10)); // $NON-NLS-1$ cbLineWeight.addItem(new String("1 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("2 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("3 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("4 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("5 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("6 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("7 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("8 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("9 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("10 px")); // $NON-NLS-1$ cbLineWeight.validate(); cbLineWeight.setSelectedIndex(0); DefaultListCellRenderer drawRenderer = new DefaultListCellRenderer() { public Component getListCellRendererComponent( JList list, Object value, int modelIndex, boolean isSelected, boolean cellHasFocus) { if (list != null) { if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } } setText((String) value); return this; } }; cbLineWeight.setRenderer(drawRenderer); ActionListener drawActionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { int ind = cbLineWeight.getSelectedIndex(); if (ind == 0) onUpdateLinkWeight(1); else if (ind == 1) onUpdateLinkWeight(2); else if (ind == 2) onUpdateLinkWeight(3); else if (ind == 3) onUpdateLinkWeight(4); else if (ind == 4) onUpdateLinkWeight(5); else if (ind == 5) onUpdateLinkWeight(6); else if (ind == 6) onUpdateLinkWeight(7); else if (ind == 7) onUpdateLinkWeight(8); else if (ind == 8) onUpdateLinkWeight(9); else if (ind == 9) onUpdateLinkWeight(10); } }; cbLineWeight.addActionListener(drawActionListener); drawPanel.add(new JLabel(" "), BorderLayout.WEST); // $NON-NLS-1$ drawPanel.add(cbLineWeight, BorderLayout.CENTER); return drawPanel; }
/** Create the arrow head choicebox. */ private JPanel createArrowChoiceBox() { JPanel drawPanel = new JPanel(new BorderLayout()); CSH.setHelpIDString(drawPanel, "toolbars.formatlink"); // $NON-NLS-1$ cbArrows = new JComboBox(); cbArrows.setToolTipText( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.selectArrow")); // $NON-NLS-1$ cbArrows.setOpaque(true); cbArrows.setEditable(false); cbArrows.setEnabled(false); cbArrows.setMaximumRowCount(4); cbArrows.setFont(new Font("Dialog", Font.PLAIN, 10)); // $NON-NLS-1$ Vector arrows = new Vector(5); arrows.insertElementAt( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.noArrows"), 0); //$NON-NLS-1$ arrows.insertElementAt( LanguageProperties.getString(LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.fromTo"), 1); //$NON-NLS-1$ arrows.insertElementAt( LanguageProperties.getString(LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.toFfrom"), 2); //$NON-NLS-1$ arrows.insertElementAt( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.bothWays"), 3); //$NON-NLS-1$ DefaultComboBoxModel comboModel = new DefaultComboBoxModel(arrows); cbArrows.setModel(comboModel); cbArrows.setSelectedIndex(0); DefaultListCellRenderer comboRenderer = new DefaultListCellRenderer() { public Component getListCellRendererComponent( JList list, Object value, int modelIndex, boolean isSelected, boolean cellHasFocus) { if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } setText((String) value); return this; } }; cbArrows.setRenderer(comboRenderer); cbArrows.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { onUpdateArrowType(cbArrows.getSelectedIndex()); } }); drawPanel.add(new JLabel(" "), BorderLayout.WEST); // $NON-NLS-1$ drawPanel.add(cbArrows, BorderLayout.CENTER); return drawPanel; }
/** * Create and return the toolbar with the node formatting options. * * @return UIToolBar, the toolbar with all the node formatting options. */ private UIToolBar createToolBar(int orientation) { tbrToolBar = new UIToolBar( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.name"), UIToolBar.NORTHSOUTH); // $NON-NLS-1$ tbrToolBar.setOrientation(orientation); tbrToolBar.setEnabled(false); CSH.setHelpIDString(tbrToolBar, "toolbars.formatlink"); // $NON-NLS-1$ GridBagLayout grid = new GridBagLayout(); linkPanel = new JPanel(grid); linkColourPanel = new JPanel(new BorderLayout()); linkColourPanel.setBackground(Color.black); JLabel label = new JLabel(" "); // $NON-NLS-1$ GridBagConstraints con5 = new GridBagConstraints(); con5.fill = GridBagConstraints.NONE; con5.anchor = GridBagConstraints.CENTER; grid.addLayoutComponent(label, con5); linkPanel.add(label); txtLinkColour = new JLabel(UIImages.get(BACKGROUND_COLOUR)); txtLinkColour.setBorder(null); txtLinkColour.setToolTipText( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.selectLinkColour")); //$NON-NLS-1$ txtLinkColour.setEnabled(false); txtLinkColour.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { int clickCount = e.getClickCount(); if (clickCount == 1 && txtLinkColour.isEnabled()) { onUpdateLinkColour(linkColourPanel.getBackground().getRGB()); } } }); linkColourPanel.add(txtLinkColour, BorderLayout.CENTER); GridBagConstraints con = new GridBagConstraints(); con.fill = GridBagConstraints.NONE; con.anchor = GridBagConstraints.CENTER; grid.addLayoutComponent(linkColourPanel, con); linkPanel.add(linkColourPanel); btLinkColour = new UIImageButton(UIImages.get(RIGHT_ARROW_ICON)); btLinkColour.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { int clickCount = e.getClickCount(); if (clickCount == 1 && txtLinkColour.isEnabled()) { if (oColorChooserDialog != null) { oColorChooserDialog.setColour(selectedLinkColour); } else { oColorChooserDialog = new UIColorChooserDialog(ProjectCompendium.APP, selectedLinkColour); } oColorChooserDialog.setVisible(true); Color oColour = oColorChooserDialog.getColour(); oColorChooserDialog.setVisible(false); if (oColour != null) { linkColourPanel.setBackground(oColour); onUpdateLinkColour(oColour.getRGB()); } } } }); linkPanel.add(btLinkColour); label = new JLabel(" "); // $NON-NLS-1$ GridBagConstraints con4 = new GridBagConstraints(); con4.fill = GridBagConstraints.NONE; con4.anchor = GridBagConstraints.CENTER; grid.addLayoutComponent(label, con4); linkPanel.add(label); tbrToolBar.add(linkPanel); CSH.setHelpIDString(txtLinkColour, "toolbars.formatlink"); // $NON-NLS-1$ tbrToolBar.add(createWeightChoiceBox()); tbrToolBar.add(createArrowChoiceBox()); tbrToolBar.add(createLinkStyleChoiceBox()); tbrToolBar.add(createLinkDashedChoiceBox()); return tbrToolBar; }