/** * 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; }
/** Draw the contents of the dialog. */ private void drawDialog() { JPanel oCenterPanel = new JPanel(); GridBagLayout gb = new GridBagLayout(); GridBagConstraints gc = new GridBagConstraints(); gc.anchor = GridBagConstraints.WEST; oCenterPanel.setLayout(gb); gc.insets = new Insets(5, 5, 5, 5); int y = 0; cbIncludeKeywords = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importKeywordData")); //$NON-NLS-1$ cbIncludeKeywords.setSelected(true); cbIncludeKeywords.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbIncludeKeywords, gc); oCenterPanel.add(cbIncludeKeywords); cbIncludePlayList = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importPlayListData")); //$NON-NLS-1$ cbIncludePlayList.setSelected(true); cbIncludePlayList.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbIncludePlayList, gc); oCenterPanel.add(cbIncludePlayList); cbIncludeURLs = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importURLData")); //$NON-NLS-1$ cbIncludeURLs.setSelected(true); cbIncludeURLs.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbIncludeURLs, gc); oCenterPanel.add(cbIncludeURLs); cbIncludeAttendees = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importAttendeeData")); //$NON-NLS-1$ cbIncludeAttendees.setSelected(true); cbIncludeAttendees.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbIncludeAttendees, gc); oCenterPanel.add(cbIncludeAttendees); cbIncludeChats = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.imortChatData")); //$NON-NLS-1$ cbIncludeChats.setSelected(true); cbIncludeChats.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbIncludeChats, gc); oCenterPanel.add(cbIncludeChats); cbIncludeWhiteboard = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importWhiteBoardData")); //$NON-NLS-1$ cbIncludeWhiteboard.setSelected(true); cbIncludeWhiteboard.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbIncludeWhiteboard, gc); oCenterPanel.add(cbIncludeWhiteboard); cbIncludeAnnotations = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importAnnotationData")); //$NON-NLS-1$ cbIncludeAnnotations.setSelected(true); cbIncludeAnnotations.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbIncludeAnnotations, gc); oCenterPanel.add(cbIncludeAnnotations); cbIncludeFileData = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importFileData")); //$NON-NLS-1$ cbIncludeFileData.setSelected(true); cbIncludeFileData.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbIncludeFileData, gc); oCenterPanel.add(cbIncludeFileData); cbIncludeVotes = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importVotingData")); //$NON-NLS-1$ cbIncludeVotes.setSelected(true); cbIncludeVotes.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbIncludeVotes, gc); oCenterPanel.add(cbIncludeVotes); // Add spacer label JLabel spacer = new JLabel(" "); // $NON-NLS-1$ gc.gridy = y; y++; gb.setConstraints(spacer, gc); oCenterPanel.add(spacer); // flag to mark seen/unseen on import cbMarkSeen = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.markSeen")); //$NON-NLS-1$ cbMarkSeen.setSelected(true); cbMarkSeen.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbMarkSeen, gc); oCenterPanel.add(cbMarkSeen); // Add spacer label spacer = new JLabel(" "); // $NON-NLS-1$ gc.gridy = y; y++; gb.setConstraints(spacer, gc); oCenterPanel.add(spacer); gc.gridwidth = 1; UIButtonPanel oButtonPanel = new UIButtonPanel(); pbImport = new UIButton( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importMainButton")); //$NON-NLS-1$ pbImport.setMnemonic( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importMainButtonMnemonic") .charAt(0)); pbImport.addActionListener(this); getRootPane().setDefaultButton(pbImport); oButtonPanel.addButton(pbImport); pbClose = new UIButton( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.cancelButton")); //$NON-NLS-1$ pbClose.setMnemonic( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.cancelButtonMnemonic") .charAt(0)); pbClose.addActionListener(this); oButtonPanel.addButton(pbClose); pbHelp = new UIButton( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.helpButton")); //$NON-NLS-1$ pbHelp.setMnemonic( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.helpButtonMnemonic") .charAt(0)); ProjectCompendium.APP.mainHB.enableHelpOnButton( pbHelp, "io.import_flashmeeting_xml", ProjectCompendium.APP.mainHS); // $NON-NLS-1$ oButtonPanel.addHelpButton(pbHelp); // other initializations oContentPane.setLayout(new BorderLayout()); oContentPane.add(oCenterPanel, BorderLayout.CENTER); oContentPane.add(oButtonPanel, BorderLayout.SOUTH); pack(); setResizable(false); return; }