/** If there's anything to print, initiate a print job */ public synchronized void actionPerformed(ActionEvent ae) { if (isPrintUnderway) { out("ignoring [" + ae.getActionCommand() + "]; print already underway."); return; } LWMap map = VUE.getActiveMap(); Rectangle2D bounds = map.getBounds(); if (bounds.isEmpty()) { out("nothing to print in " + map); return; } boolean viewerPrint = false; if (ae.getActionCommand() != null && ae.getActionCommand().indexOf("Visible") >= 0) viewerPrint = true; // if any tool windows open in W2K/1.4.2 when start this thread, // the print dialog get's obscured! isPrintUnderway = true; setEnabled(false); try { new PrintJob(VUE.getActiveViewer(), viewerPrint).start(); // if (DEBUG.Enabled) // new PrintJob(VUE.getActiveViewer(), viewerPrint).start(); // else // new PrintJob(VUE.getActiveViewer(), viewerPrint).runPrint(); } catch (Throwable t) { out("exception creating or running PrintJob: " + t); t.printStackTrace(); isPrintUnderway = false; setEnabled(true); } }
/** Creates a new instance of NodeFilterEditor */ public NodeFilterEditor(NodeFilter nodeFilter, boolean editable) { this.nodeFilter = nodeFilter; tufts.vue.LWMap map = tufts.vue.VUE.getActiveMap(); if (map != null) map.getMapFilterModel().addListener(this); tufts.vue.VUE.addActiveListener(tufts.vue.LWMap.class, this); questionLabel.setToolTipText(NodeFilterEditor.NODE_FILTER_INFO); setNodeFilterPanel(); }
public Component getTableCellEditorComponent( JTable table, Object value, boolean isSelected, int row, int column) { TableModel tableModel = table.getModel(); if (tableModel instanceof NodeFilter) { editor = new JComboBox((Vector) tufts.vue.VUE.getActiveMap().getMapFilterModel().getKeyVector()); return editor; } return (new JComboBox()); // if no editor present }
public AddDialog(NodeFilter model) { super( tufts.vue.VUE.getDialogParentAsFrame(), VueResources.getString("dialog.addkey.title"), true); this.model = model; allTypes = (Vector) TypeFactory.getAllTypes(); keyLabel = new JLabel(VueResources.getString("button.key.label")); typeLabel = new JLabel(VueResources.getString("nodefilter.type.label")); operatorLabel = new JLabel(VueResources.getString("nodefilter.operator.label")); valueLabel = new JLabel(VueResources.getString("nodefilter.value.label")); keyEditor = new JComboBox(tufts.vue.VUE.getActiveMap().getMapFilterModel().getKeyVector()); operatorEditor = new JComboBox(); valueEditor = new JTextField(); typeEditor = new JTextField(); typeEditor.setEditable(false); keyEditor.setPreferredSize(new Dimension(80, 20)); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(2, 2, 2, 2); JPanel panel = new JPanel(); panel.setLayout(gridbag); c.anchor = GridBagConstraints.EAST; c.gridwidth = GridBagConstraints.RELATIVE; gridbag.setConstraints(keyLabel, c); panel.add(keyLabel); c.anchor = GridBagConstraints.WEST; c.gridwidth = GridBagConstraints.REMAINDER; gridbag.setConstraints(keyEditor, c); panel.add(keyEditor); c.anchor = GridBagConstraints.EAST; c.gridwidth = GridBagConstraints.RELATIVE; gridbag.setConstraints(operatorLabel, c); panel.add(operatorLabel); c.anchor = GridBagConstraints.WEST; c.gridwidth = GridBagConstraints.REMAINDER; gridbag.setConstraints(operatorEditor, c); panel.add(operatorEditor); c.anchor = GridBagConstraints.EAST; c.gridwidth = GridBagConstraints.RELATIVE; gridbag.setConstraints(valueLabel, c); panel.add(valueLabel); c.anchor = GridBagConstraints.WEST; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.HORIZONTAL; gridbag.setConstraints(valueEditor, c); panel.add(valueEditor); c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; c.gridwidth = GridBagConstraints.RELATIVE; gridbag.setConstraints(typeLabel, c); panel.add(typeLabel); c.anchor = GridBagConstraints.WEST; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.HORIZONTAL; gridbag.setConstraints(typeEditor, c); panel.add(typeEditor); // SOUTH: southPanel(cancelButton, okButton) JButton okButton = new JButton(VueResources.getString("button.ok.label")); okButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { updateModelAndNotify(); setVisible(false); } }); JButton cancelButton = new JButton(VueResources.getString("button.cancel.lable")); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false); } }); JPanel southPanel = new JPanel(); southPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); southPanel.add(okButton); southPanel.add(cancelButton); c.gridwidth = GridBagConstraints.REMAINDER; gridbag.setConstraints(southPanel, c); panel.add(southPanel); getContentPane().setLayout(new BorderLayout()); getContentPane().add(panel, BorderLayout.CENTER); pack(); setLocation(500, 300); setVisible(true); }
private void setNodeFilterPanel() { lWMap = tufts.vue.VUE.getActiveMap(); addButton.setToolTipText(VueResources.getString("nodefilter.addfilter.tooltip")); deleteButton.setToolTipText(VueResources.getString("nodefilter.deletefilter.tooltip")); elementsModel = new ElementComboBoxModel(); elementsModel.setElements(lWMap.getMapFilterModel().getKeyVector()); elements = new JComboBox(elementsModel); Font f = elements.getFont(); Font menuFont = new Font(f.getFontName(), f.getStyle(), f.getSize() - 2); elements.setFont(menuFont); // elements.setPreferredSize(new Dimension(150,20)); /// this is not user friendly may want to fix later. /** * elements.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { * if(e.getStateChange() == ItemEvent.SELECTED) { if(e.getItem().toString() == ADD_ELEMENT) { } * else if(e.getItem() instanceof Key) { Statement stmt = new Statement(); * stmt.setKey((Key)e.getItem()); nodeFilter.addStatement(stmt); * nodeFilter.fireTableDataChanged(); } else { System.out.println("Not Supported"); } } } }); */ nodeFilterTable = new JTable(nodeFilter); nodeFilterTable.addFocusListener( new FocusListener() { public void focusLost(FocusEvent e) { if (nodeFilterTable.isEditing()) { nodeFilterTable .getCellEditor( nodeFilterTable.getEditingRow(), nodeFilterTable.getEditingColumn()) .stopCellEditing(); } nodeFilterTable.removeEditor(); } public void focusGained(FocusEvent e) {} }); nodeFilterTable.addKeyListener( new KeyAdapter() { public void keyPressed(KeyEvent e) { if (nodeFilterTable.getSelectedRow() == (nodeFilterTable.getRowCount() - 1) && e.getKeyCode() == e.VK_ENTER) { addButtonListener.addStatement(); } } }); nodeFilterTable.setPreferredScrollableViewportSize(new Dimension(240, 100)); JScrollPane nodeFilterScrollPane = new JScrollPane(nodeFilterTable); nodeFilterScrollPane.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY)); JPanel nodeFilterPanel = new JPanel(); nodeFilterPanel.setLayout(new BorderLayout()); nodeFilterPanel.add(nodeFilterScrollPane, BorderLayout.CENTER); addButtonListener = new AddButtonListener(nodeFilter); addButton.addActionListener(addButtonListener); deleteButton.setEnabled(false); sListener = new NodeFilterSelectionListener(deleteButton, -1); nodeFilterTable.getSelectionModel().addListSelectionListener(sListener); deleteButtonListener = new DeleteButtonListener(nodeFilterTable, sListener); deleteButton.addActionListener(deleteButtonListener); // keyEditor = new KeyCellEditor(); // nodeFilterTable.getColumnModel().getColumn(NodeFilter.KEY_COL).setCellEditor(keyEditor); JPanel innerPanel = new JPanel(); innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.Y_AXIS)); JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 2, 0)); // bottomPanel.setBorder(BorderFactory.createEmptyBorder(3,6,3,6)); bottomPanel.add(elementLabel); bottomPanel.add(elements); bottomPanel.add(addButton); bottomPanel.add(deleteButton); bottomPanel.add(questionLabel); // innerPanel.add(labelPanel); innerPanel.add(bottomPanel); innerPanel.add(nodeFilterPanel); setLayout(new BorderLayout()); add(innerPanel, BorderLayout.CENTER); validate(); }