List of usage examples for java.beans PropertyChangeListener PropertyChangeListener
PropertyChangeListener
From source file:edu.ku.brc.specify.tasks.StatsTrackerTask.java
@Override protected PropertyChangeListener getPCLForWorker() { return new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { if ("progress".equals(evt.getPropertyName())) { if (progress != null) progress.setValue((Integer) evt.getNewValue()); }//from w w w . java 2s .c o m } }; }
From source file:org.openconcerto.erp.core.supplychain.receipt.component.BonReceptionSQLComponent.java
public void addViews() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); // Champ Module c.gridx = 0;/*from w w w.jav a 2s. c om*/ c.gridy++; c.gridwidth = GridBagConstraints.REMAINDER; final JPanel addP = ComptaSQLConfElement.createAdditionalPanel(); this.setAdditionalFieldsPanel(new FormLayouter(addP, 1)); this.add(addP, c); c.gridy++; c.gridwidth = 1; this.textTotalHT.setOpaque(false); this.textTotalTVA.setOpaque(false); this.textTotalTTC.setOpaque(false); this.selectCommande = new ElementComboBox(); // Numero JLabel labelNum = new JLabel(getLabelFor("NUMERO")); labelNum.setHorizontalAlignment(SwingConstants.RIGHT); this.add(labelNum, c); this.textNumeroUnique = new JUniqueTextField(16); c.gridx++; c.weightx = 1; c.weighty = 0; c.fill = GridBagConstraints.NONE; DefaultGridBagConstraints.lockMinimumSize(this.textNumeroUnique); this.add(this.textNumeroUnique, c); // Date JLabel labelDate = new JLabel(getLabelFor("DATE")); labelDate.setHorizontalAlignment(SwingConstants.RIGHT); c.fill = GridBagConstraints.HORIZONTAL; c.gridx++; c.weightx = 0; this.add(labelDate, c); JDate date = new JDate(true); c.gridx++; c.weightx = 0; c.weighty = 0; this.add(date, c); // Reference c.gridy++; c.gridx = 0; final JLabel labelNom = new JLabel(getLabelFor("NOM")); labelNom.setHorizontalAlignment(SwingConstants.RIGHT); this.add(labelNom, c); c.gridx++; c.fill = GridBagConstraints.HORIZONTAL; DefaultGridBagConstraints.lockMinimumSize(this.textReference); this.add(this.textReference, c); // Fournisseur JLabel labelFournisseur = new JLabel(getLabelFor("ID_FOURNISSEUR")); labelFournisseur.setHorizontalAlignment(SwingConstants.RIGHT); c.gridx = 0; c.gridy++; c.weightx = 0; c.weighty = 0; this.add(labelFournisseur, c); this.fournisseur = new ElementComboBox(); c.gridx++; c.weightx = 0; c.weighty = 0; c.fill = GridBagConstraints.NONE; this.add(this.fournisseur, c); // Devise c.gridx = 0; c.gridy++; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel(getLabelFor("ID_DEVISE"), SwingConstants.RIGHT), c); final ElementComboBox boxDevise = new ElementComboBox(); c.gridx = GridBagConstraints.RELATIVE; c.gridwidth = 1; c.weightx = 1; c.weighty = 0; c.fill = GridBagConstraints.NONE; this.add(boxDevise, c); this.addView(boxDevise, "ID_DEVISE"); // Element du bon this.tableBonItem = new BonReceptionItemTable(); c.gridx = 0; c.gridy++; c.weightx = 1; c.weighty = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.BOTH; this.add(this.tableBonItem, c); this.fournisseur.addValueListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { tableBonItem.setFournisseur(fournisseur.getSelectedRow()); } }); c.anchor = GridBagConstraints.EAST; // Totaux reconfigure(this.textTotalHT); reconfigure(this.textTotalTVA); reconfigure(this.textTotalTTC); // Poids Total c.gridy++; c.gridx = 1; c.weightx = 0; c.weighty = 0; c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; DefaultProps props = DefaultNXProps.getInstance(); Boolean b = props.getBooleanValue("ArticleShowPoids"); if (b) { JPanel panelPoids = new JPanel(new GridBagLayout()); GridBagConstraints c2 = new DefaultGridBagConstraints(); c2.fill = GridBagConstraints.NONE; panelPoids.add(new JLabel(getLabelFor("TOTAL_POIDS")), c2); // Necessaire pour ne pas avoir de saut de layout DefaultGridBagConstraints.lockMinimumSize(this.textPoidsTotal); this.textPoidsTotal.setEnabled(false); this.textPoidsTotal.setHorizontalAlignment(JTextField.RIGHT); this.textPoidsTotal.setDisabledTextColor(Color.BLACK); c2.gridx++; c2.weightx = 1; c2.fill = GridBagConstraints.HORIZONTAL; panelPoids.add(this.textPoidsTotal, c2); this.add(panelPoids, c); } c.gridx = 2; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 0; c.weighty = 0; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; final GridBagConstraints cTotalPan = new DefaultGridBagConstraints(); JPanel panelTotalHT = new JPanel(); panelTotalHT.setLayout(new GridBagLayout()); cTotalPan.gridx = 0; cTotalPan.weightx = 0; cTotalPan.fill = GridBagConstraints.HORIZONTAL; cTotalPan.anchor = GridBagConstraints.WEST; final JLabelBold labelTotalHT = new JLabelBold(getLabelFor("TOTAL_HT")); panelTotalHT.add(labelTotalHT, cTotalPan); cTotalPan.anchor = GridBagConstraints.EAST; cTotalPan.gridx++; cTotalPan.weightx = 1; this.textTotalHT.setFont(labelTotalHT.getFont()); DefaultGridBagConstraints.lockMinimumSize(this.textTotalHT); panelTotalHT.add(this.textTotalHT, cTotalPan); this.add(panelTotalHT, c); JPanel panelTotalTVA = new JPanel(); panelTotalTVA.setLayout(new GridBagLayout()); cTotalPan.gridx = 0; cTotalPan.weightx = 0; cTotalPan.anchor = GridBagConstraints.WEST; cTotalPan.fill = GridBagConstraints.HORIZONTAL; panelTotalTVA.add(new JLabelBold(getLabelFor("TOTAL_TVA")), cTotalPan); cTotalPan.anchor = GridBagConstraints.EAST; cTotalPan.gridx++; cTotalPan.weightx = 1; DefaultGridBagConstraints.lockMinimumSize(this.textTotalTVA); panelTotalTVA.add(this.textTotalTVA, cTotalPan); c.gridy++; c.fill = GridBagConstraints.HORIZONTAL; this.add(panelTotalTVA, c); JPanel panelTotalTTC = new JPanel(); panelTotalTTC.setLayout(new GridBagLayout()); cTotalPan.gridx = 0; cTotalPan.anchor = GridBagConstraints.WEST; cTotalPan.gridwidth = GridBagConstraints.REMAINDER; cTotalPan.fill = GridBagConstraints.BOTH; cTotalPan.weightx = 1; panelTotalTTC.add(new JSeparator(), cTotalPan); cTotalPan.gridwidth = 1; cTotalPan.fill = GridBagConstraints.NONE; cTotalPan.weightx = 0; cTotalPan.gridy++; panelTotalTTC.add(new JLabelBold(getLabelFor("TOTAL_TTC")), cTotalPan); cTotalPan.anchor = GridBagConstraints.EAST; cTotalPan.gridx++; this.textTotalTTC.setFont(labelTotalHT.getFont()); DefaultGridBagConstraints.lockMinimumSize(this.textTotalTTC); panelTotalTTC.add(this.textTotalTTC, cTotalPan); c.gridy++; // probleme de tremblement vertical this.add(panelTotalTTC, c); c.anchor = GridBagConstraints.WEST; /******************************************************************************************* * * INFORMATIONS COMPLEMENTAIRES ******************************************************************************************/ c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1; c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy++; TitledSeparator sep = new TitledSeparator("Informations complmentaires"); c.insets = new Insets(10, 2, 1, 2); this.add(sep, c); c.insets = new Insets(2, 2, 1, 2); c.gridx = 0; c.gridy++; c.gridheight = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1; c.weighty = 0; c.fill = GridBagConstraints.BOTH; final ITextArea textInfos = new ITextArea(4, 4); JScrollPane scrollPane = new JScrollPane(textInfos); DefaultGridBagConstraints.lockMinimumSize(scrollPane); this.add(textInfos, c); this.addRequiredSQLObject(date, "DATE"); this.addSQLObject(textInfos, "INFOS"); this.addSQLObject(this.textReference, "NOM"); this.addSQLObject(this.selectCommande, "ID_COMMANDE"); this.addRequiredSQLObject(this.textNumeroUnique, "NUMERO"); this.addSQLObject(this.textPoidsTotal, "TOTAL_POIDS"); this.addRequiredSQLObject(this.textTotalHT, "TOTAL_HT"); this.addRequiredSQLObject(this.textTotalTVA, "TOTAL_TVA"); this.addRequiredSQLObject(this.textTotalTTC, "TOTAL_TTC"); this.addRequiredSQLObject(this.fournisseur, "ID_FOURNISSEUR"); this.textNumeroUnique.setText(NumerotationAutoSQLElement.getNextNumero(BonReceptionSQLElement.class)); // Listeners this.tableBonItem.getModel().addTableModelListener(new TableModelListener() { public void tableChanged(TableModelEvent e) { int columnIndexHT = BonReceptionSQLComponent.this.tableBonItem.getModel().getColumnIndexForElement( BonReceptionSQLComponent.this.tableBonItem.getPrixTotalHTElement()); int columnIndexTTC = BonReceptionSQLComponent.this.tableBonItem.getModel().getColumnIndexForElement( BonReceptionSQLComponent.this.tableBonItem.getPrixTotalTTCElement()); int columnIndexPoids = BonReceptionSQLComponent.this.tableBonItem.getModel() .getColumnIndexForElement( BonReceptionSQLComponent.this.tableBonItem.getPoidsTotalElement()); if (e.getColumn() == TableModelEvent.ALL_COLUMNS || e.getColumn() == columnIndexHT || e.getColumn() == columnIndexTTC) { updateTotal(); } if (e.getColumn() == TableModelEvent.ALL_COLUMNS || e.getColumn() == columnIndexPoids) { BonReceptionSQLComponent.this.textPoidsTotal.setText(String .valueOf(Math.round(BonReceptionSQLComponent.this.tableBonItem.getPoidsTotal() * 1000) / 1000.0)); } } }); // Lock UI DefaultGridBagConstraints.lockMinimumSize(this.fournisseur); }
From source file:edu.ku.brc.specify.config.init.InstSetupPanel.java
/** * /*from w ww . j ava 2s. co m*/ */ protected void doCreate() { if (isOK == null || !isOK) { progressBar.setIndeterminate(true); progressBar.setVisible(true); setUIEnabled(false); label.setText(UIRegistry.getResourceString("CONN_DB")); testBtn.setVisible(false); SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() { @Override protected Object doInBackground() throws Exception { isOK = false; try { getValues(properties); firePropertyChange(propName, 0, 1); conn = DBConnection.getInstance(); AppContextMgr.getInstance().setHasContext(true); // override BuildSampleDatabase bsd = new BuildSampleDatabase(); bsd.setSession(HibernateUtil.getCurrentSession()); int treeDir = BuildSampleDatabase.getTreeDirForClass(properties, StorageTreeDef.class); isOK = bsd.createEmptyInstitution(properties, false, false, true, treeDir); AppContextMgr.getInstance().setClassObject(DataType.class, bsd.getDataType()); HibernateUtil.closeSession(); if (!isOK) { errorKey = "BAD_INST"; return null; } String userName = properties.getProperty("usrUsername"); String password = properties.getProperty("usrPassword"); String dbName = properties.getProperty("dbName"); firePropertyChange(propName, 0, 2); isOK = tryLogginIn(userName, password, dbName); if (!isOK) { errorKey = "BAD_LOGIN"; return null; } } catch (Exception ex) { ex.printStackTrace(); errorKey = "INST_UNRECOVERABLE"; } return null; } /* (non-Javadoc) * @see javax.swing.SwingWorker#done() */ @Override protected void done() { super.done(); progressBar.setIndeterminate(false); progressBar.setVisible(false); setUIEnabled(true); updateBtnUI(); label.setText(UIRegistry.getResourceString( isOK ? "INST_CREATED" : (errorKey != null ? errorKey : "ERR_CRE_INST"))); if (isOK) { setUIEnabled(false); prevBtn.setEnabled(false); } } }; worker.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { if (propName.equals(evt.getPropertyName())) { String key = null; switch ((Integer) evt.getNewValue()) { case 1: key = "CREATING_INST"; break; case 2: key = "LOGIN_USER"; break; default: break; } if (key != null) { InstSetupPanel.this.label.setText(UIRegistry.getResourceString(key)); } } } }); worker.execute(); } }
From source file:EditorPaneExample18.java
public EditorPaneExample18() { super("JEditorPane Example 18"); pane = new JEditorPane(); pane.setEditable(true); // Editable getContentPane().add(new JScrollPane(pane), "Center"); // Add a menu bar menuBar = new JMenuBar(); setJMenuBar(menuBar);//from w ww. ja v a 2s. com // Populate it createMenuBar(); // Build the panel of controls JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridwidth = 1; c.gridheight = 1; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; c.weightx = 0.0; c.weighty = 0.0; JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT); panel.add(urlLabel, c); JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT); c.gridy = 1; panel.add(loadingLabel, c); JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT); c.gridy = 2; panel.add(typeLabel, c); c.gridy = 3; panel.add(new JLabel(LOAD_TIME), c); c.gridy = 4; c.gridwidth = 2; c.weightx = 1.0; c.anchor = GridBagConstraints.WEST; onlineLoad = new JCheckBox("Online Load"); panel.add(onlineLoad, c); onlineLoad.setSelected(true); onlineLoad.setForeground(typeLabel.getForeground()); c.gridy = 5; c.gridwidth = 2; c.weightx = 1.0; c.anchor = GridBagConstraints.WEST; editableBox = new JCheckBox("Editable JEditorPane"); panel.add(editableBox, c); editableBox.setSelected(true); editableBox.setForeground(typeLabel.getForeground()); c.gridy = 6; c.weightx = 0.0; JButton saveButton = new JButton("Save"); panel.add(saveButton, c); saveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { EditorKit kit = pane.getEditorKit(); try { if (kit instanceof RTFEditorKit) { kit.write(System.out, pane.getDocument(), 0, pane.getDocument().getLength()); System.out.flush(); } else { if (writer == null) { writer = new OutputStreamWriter(System.out); pane.write(writer); writer.flush(); } kit.write(writer, pane.getDocument(), 0, pane.getDocument().getLength()); writer.flush(); } } catch (Exception e) { System.out.println("Write failed"); } } }); c.gridx = 1; c.gridy = 0; c.weightx = 1.0; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; urlCombo = new JComboBox(); panel.add(urlCombo, c); urlCombo.setEditable(true); loadingState = new JLabel(spaces, JLabel.LEFT); loadingState.setForeground(Color.black); c.gridy = 1; panel.add(loadingState, c); loadedType = new JLabel(spaces, JLabel.LEFT); loadedType.setForeground(Color.black); c.gridy = 2; panel.add(loadedType, c); timeLabel = new JLabel(""); c.gridy = 3; panel.add(timeLabel, c); getContentPane().add(panel, "South"); // Register a custom EditorKit for HTML ClassLoader loader = getClass().getClassLoader(); if (loader != null) { // Java 2 JEditorPane.registerEditorKitForContentType("text/html", "AdvancedSwing.Chapter4.HiddenViewHTMLEditorKit", loader); } else { // JDK 1.1 JEditorPane.registerEditorKitForContentType("text/html", "AdvancedSwing.Chapter4.HiddenViewHTMLEditorKit"); } // Allocate the empty tree model DefaultMutableTreeNode emptyRootNode = new DefaultMutableTreeNode("Empty"); emptyModel = new DefaultTreeModel(emptyRootNode); // Create and place the heading tree tree = new JTree(emptyModel); tree.setPreferredSize(new Dimension(200, 200)); getContentPane().add(new JScrollPane(tree), "East"); // Change page based on combo selection urlCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (populatingCombo == true) { return; } Object selection = urlCombo.getSelectedItem(); loadNewPage(selection); } }); // Change editability based on the checkbox editableBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { pane.setEditable(editableBox.isSelected()); pane.revalidate(); pane.repaint(); } }); // Listen for page load to complete pane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("page")) { loadComplete(); displayLoadTime(); populateCombo(findLinks(pane.getDocument(), null)); TreeNode node = buildHeadingTree(pane.getDocument()); tree.setModel(new DefaultTreeModel(node)); createMenuBar(); enableMenuBar(true); getRootPane().revalidate(); enableInput(); loadingPage = false; } } }); // Listener for tree selection tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent evt) { TreePath path = evt.getNewLeadSelectionPath(); if (path != null) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); Object userObject = node.getUserObject(); if (userObject instanceof Heading) { Heading heading = (Heading) userObject; try { Rectangle textRect = pane.modelToView(heading.getOffset()); textRect.y += 3 * textRect.height; pane.scrollRectToVisible(textRect); } catch (BadLocationException e) { } } } } }); // Listener for hypertext events pane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent evt) { // Ignore hyperlink events if the frame is busy if (loadingPage == true) { return; } if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { JEditorPane sp = (JEditorPane) evt.getSource(); if (evt instanceof HTMLFrameHyperlinkEvent) { HTMLDocument doc = (HTMLDocument) sp.getDocument(); doc.processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent) evt); } else { loadNewPage(evt.getURL()); } } else if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) { pane.setCursor(handCursor); } else if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) { pane.setCursor(defaultCursor); } } }); }
From source file:org.squidy.designer.model.PipeShape.java
public void initialize() { if (pipe == null) { if (LOG.isErrorEnabled()) { LOG.error("Could not initialize PipeShape without a pipe instance. Removing from parent."); }/*w w w .j a v a 2s . c o m*/ return; } visualization = new VisualizationShape(this); visualization.setScale(0.5); addChild(visualization); // ShapeUtils.setApparent(visualization, false); pipe.addProcessingFeedback(visualization); flowIncoming = new DataTypeShape(pipe.getInputTypes()); flowIncoming.setScale(0.1); addChild(flowIncoming); // ShapeUtils.setApparent(flowIncoming, false); flowOutgoing = new DataTypeShape(pipe.getOutputTypes()); flowOutgoing.setScale(0.1); addChild(flowOutgoing); // ShapeUtils.setApparent(flowOutgoing, false); final PropertyChangeListener changeListener = new PropertyChangeListener() { /* * (non-Javadoc) * * * @seejava.beans.PropertyChangeListener#propertyChange(java. * beans. PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent evt) { if (evt.getNewValue() != null) { setBounds(computeBounds()); positionVisualization(); } } }; addPropertyChangeListener(PNode.PROPERTY_PARENT, changeListener); source.addPropertyChangeListener(PNode.PROPERTY_FULL_BOUNDS, changeListener); target.addPropertyChangeListener(PNode.PROPERTY_FULL_BOUNDS, changeListener); pipe.addStatusChangeListener(Processable.STATUS_PROCESSABLE_DELETED, new PropertyChangeListener() { /* * (non-Javadoc) * * @see * java.beans.PropertyChangeListener#propertyChange(java * .beans.PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent evt) { if (source != null) { source.removePropertyChangeListener(changeListener); } if (target != null) { target.removePropertyChangeListener(changeListener); } removeFromParent(); } }); addInputEventListener(new PBasicInputEventHandler() { /* * (non-Javadoc) * * @see * edu.umd.cs.piccolo.event.PBasicInputEventHandler#mouseEntered * (edu.umd.cs.piccolo.event.PInputEvent) */ @Override public void mouseEntered(PInputEvent event) { super.mouseEntered(event); // ShapeUtils.setApparent(visualization, true); // ShapeUtils.setApparent(flowIncoming, true); // ShapeUtils.setApparent(flowOutgoing, true); } /* * (non-Javadoc) * * @see * edu.umd.cs.piccolo.event.PBasicInputEventHandler#mouseExited( * edu.umd.cs.piccolo.event.PInputEvent) */ @Override public void mouseExited(PInputEvent event) { super.mouseExited(event); // ShapeUtils.setApparent(visualization, false); // ShapeUtils.setApparent(flowIncoming, false); // ShapeUtils.setApparent(flowOutgoing, false); } /* * (non-Javadoc) * * @see * edu.umd.cs.piccolo.event.PBasicInputEventHandler#mousePressed * (edu.umd.cs.piccolo. event.PInputEvent) */ @Override public void mousePressed(PInputEvent event) { super.mousePressed(event); if (!event.isHandled()) { Point2D p = event.getPosition(); double x = p.getX(); double y = p.getY(); // Check intersection based on mouse position (5 pixel // around // position) // Rectangle2D rectangle = globalToLocal(new // Rectangle2D.Double(x, y, 100 * getGlobalScale(), // 100 * getGlobalScale())); // if (shape.intersects(rectangle)) { event.getInputManager().setKeyboardFocus(event.getPath()); // // if (event.isRightMouseButton()) { // globalToLocal(p); // System.out.println("Do you wan't to create a bendpoint at x=" // + p.getX() + " / y=" // + p.getY() + "?"); // } event.setHandled(true); // } } // PNode nextNode = event.getPath().nextPickedNode(); // if (nextNode != null) { // EventListenerList listenerList = nextNode.getListenerList(); // // if (listenerList != null) { // PBasicInputEventHandler[] listeners = // listenerList.getListeners(PBasicInputEventHandler.class); // for (PBasicInputEventHandler listener : listeners) { // listener.mousePressed(event); // } // } // } } /* * (non-Javadoc) * * @see * edu.umd.cs.piccolo.event.PBasicInputEventHandler#keyboardFocusGained * (edu.umd.cs.piccolo .event.PInputEvent) */ @Override public void keyboardFocusGained(PInputEvent event) { super.keyboardFocusGained(event); selected = true; moveToFront(); invalidatePaint(); } /* * (non-Javadoc) * * @see * edu.umd.cs.piccolo.event.PBasicInputEventHandler#keyboardFocusLost * (edu.umd.cs.piccolo .event.PInputEvent) */ @Override public void keyboardFocusLost(PInputEvent event) { super.keyboardFocusLost(event); selected = false; invalidatePaint(); } /* * (non-Javadoc) * * @see * edu.umd.cs.piccolo.event.PBasicInputEventHandler#keyPressed(edu * .umd.cs.piccolo.event .PInputEvent) */ @Override public void keyPressed(PInputEvent event) { super.keyPressed(event); if (KeyEvent.VK_DELETE == event.getKeyCode()) { // DrawingArea drawingArea = (DrawingArea) // event.getCamera().getComponent(); // drawingArea.removeEdge(Edge.this); if (LOG.isDebugEnabled()) { LOG.debug("Backspace has been pressed. Trigger deletion of edge?"); } pipe.delete(); Manager.get().notify(getPipe(), Action.DELETE); } } }); }
From source file:de.mprengemann.intellij.plugin.androidicons.dialogs.AndroidMultiDrawableImporter.java
private void updateName() { final String exportName = controller.getExportName(); if (exportName == null) { return;// w w w. j av a 2 s .c o m } resExportName.setText(exportName); resExportName.addPropertyChangeListener("value", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent propertyChangeEvent) { controller.setExportName(((String) resExportName.getValue())); } }); }
From source file:org.openconcerto.erp.core.supplychain.order.component.CommandeSQLComponent.java
public void addViews() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); // Numero du commande c.gridx = 0;//from w ww . j a va 2 s. c o m c.weightx = 0; this.add(new JLabel(getLabelFor("NUMERO"), SwingConstants.RIGHT), c); this.numeroUniqueCommande = new JUniqueTextField(16); c.gridx++; c.weightx = 1; c.fill = GridBagConstraints.NONE; DefaultGridBagConstraints.lockMinimumSize(numeroUniqueCommande); this.add(this.numeroUniqueCommande, c); // Date JLabel labelDate = new JLabel(getLabelFor("DATE")); labelDate.setHorizontalAlignment(SwingConstants.RIGHT); c.gridx = 2; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.add(labelDate, c); JDate dateCommande = new JDate(true); c.gridx++; c.fill = GridBagConstraints.NONE; this.add(dateCommande, c); // Fournisseur c.gridx = 0; c.gridy++; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel(getLabelFor("ID_FOURNISSEUR"), SwingConstants.RIGHT), c); c.gridx = GridBagConstraints.RELATIVE; c.gridwidth = 1; c.weightx = 1; c.weighty = 0; c.fill = GridBagConstraints.NONE; this.add(this.fourn, c); if (!getTable().getFieldsName().contains("LIVRER")) { // Commande en cours JCheckBox boxEnCours = new JCheckBox(getLabelFor("EN_COURS")); c.gridx = 2; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; c.gridwidth = GridBagConstraints.REMAINDER; this.add(boxEnCours, c); c.gridwidth = 1; this.addRequiredSQLObject(boxEnCours, "EN_COURS"); } // Fournisseur if (getTable().contains("ID_CONTACT_FOURNISSEUR")) { c.gridx = 0; c.gridy++; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel(getLabelFor("ID_CONTACT_FOURNISSEUR"), SwingConstants.RIGHT), c); c.gridx = GridBagConstraints.RELATIVE; c.gridwidth = 1; c.weightx = 1; c.weighty = 0; c.fill = GridBagConstraints.HORIZONTAL; final ElementComboBox boxContactFournisseur = new ElementComboBox(); final SQLElement contactElement = Configuration.getInstance().getDirectory() .getElement("CONTACT_FOURNISSEUR"); boxContactFournisseur.init(contactElement, contactElement.getComboRequest(true)); this.add(boxContactFournisseur, c); this.addView(boxContactFournisseur, "ID_CONTACT_FOURNISSEUR", REQ); fourn.addValueListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent arg0) { // TODO Raccord de mthode auto-gnr if (fourn.getSelectedRow() != null) { boxContactFournisseur.getRequest() .setWhere(new Where(contactElement.getTable().getField("ID_FOURNISSEUR"), "=", fourn.getSelectedRow().getID())); } else { boxContactFournisseur.getRequest().setWhere(null); } } }); } // Adresse de livraison if (getTable().getFieldsName().contains("ID_ADRESSE")) { if (getTable().getFieldsName().contains("LIVRAISON_F")) { c.gridx = 0; c.gridy++; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel(getLabelFor("ID_ADRESSE")), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; // c.gridy++; this.addView("ID_ADRESSE"); final DefaultElementSQLObject comp = (DefaultElementSQLObject) this.getView("ID_ADRESSE").getComp(); if (getTable().getFieldsName().contains("LIVRAISON_F")) { final JCheckBox boxLivr = new JCheckBox("Livr par le fournisseur"); this.add(boxLivr, c); this.addSQLObject(boxLivr, "LIVRAISON_F"); boxLivr.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (boxLivr.isSelected() && !comp.isCreated()) { comp.setCreated(true); if (CommandeSQLComponent.this.getTable().contains("ID_AFFAIRE")) { SQLRowValues rowVals = getLivraisonAdr( ((ElementComboBox) CommandeSQLComponent.this.getView("ID_AFFAIRE") .getComp()).getSelectedRow()); comp.setValue(rowVals); } } else { if (!boxLivr.isSelected()) { comp.setCreated(false); } } } }); } c.gridy++; this.add(comp, c); this.add(this.getView("ID_ADRESSE").getComp(), c); } else { c.gridy++; c.gridx = 0; this.add(new JLabel("Livraison"), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; this.add(boxLivrClient, c); c.gridwidth = 1; final GridBagConstraints cAdr = new DefaultGridBagConstraints(); panelAdrSpec.add(new JLabel(getLabelFor("ID_CLIENT"), SwingConstants.RIGHT), cAdr); final ElementComboBox boxClient = new ElementComboBox(true); cAdr.weightx = 1; cAdr.gridx++; panelAdrSpec.add(boxClient, cAdr); this.addView(boxClient, "ID_CLIENT"); cAdr.gridy++; cAdr.weightx = 0; cAdr.gridx = 0; panelAdrSpec.add(new JLabel("Adresse", SwingConstants.RIGHT), cAdr); final SQLRequestComboBox boxAdr = new SQLRequestComboBox(true); boxAdr.uiInit(Configuration.getInstance().getDirectory().getElement(getTable().getTable("ADRESSE")) .getComboRequest(true)); boxClient.addModelListener("wantedID", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (boxClient.getSelectedRow() != null && !boxClient.getSelectedRow().isUndefined()) { Where w = new Where(boxAdr.getRequest().getPrimaryTable().getField("ID_CLIENT"), "=", boxClient.getSelectedRow().getID()); w = w.or(new Where(boxAdr.getRequest().getPrimaryTable().getKey(), "=", boxClient.getSelectedRow().getInt("ID_ADRESSE"))); w = w.or(new Where(boxAdr.getRequest().getPrimaryTable().getKey(), "=", boxClient.getSelectedRow().getInt("ID_ADRESSE_F"))); w = w.or(new Where(boxAdr.getRequest().getPrimaryTable().getKey(), "=", boxClient.getSelectedRow().getInt("ID_ADRESSE_L"))); boxAdr.getRequest().setWhere(w); } else { boxAdr.getRequest().setWhere(null); } } }); cAdr.weightx = 1; cAdr.gridx++; panelAdrSpec.add(boxAdr, cAdr); cAdr.gridx = 0; cAdr.gridy++; cAdr.weightx = 0; if (getMode() == Mode.MODIFICATION) { panelAdrSpec.add(new JLabel(getLabelFor("ID_ADRESSE")), cAdr); } cAdr.gridx++; cAdr.gridwidth = GridBagConstraints.REMAINDER; this.addView("ID_ADRESSE"); compAdr = (DefaultElementSQLObject) this.getView("ID_ADRESSE").getComp(); cAdr.gridy++; if (getMode() == Mode.MODIFICATION) { panelAdrSpec.add(compAdr, cAdr); } boxAdr.addValueListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { SQLRow row = boxAdr.getSelectedRow(); if (row != null && !row.isUndefined()) { compAdr.setCreated(true); SQLRowValues asRowValues = new SQLRowValues(row.asRowValues()); compAdr.setValue(asRowValues); } } }); c.gridy++; c.gridx = 0; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1; this.add(panelAdrSpec, c); c.gridwidth = 1; c.weightx = 0; boxLivrClient.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { panelAdrSpec.setVisible(boxLivrClient.isSelected()); if (!boxLivrClient.isSelected()) { boxClient.setValue((Integer) null); boxAdr.setValue((Integer) null); compAdr.setCreated(false); } } }); panelAdrSpec.setVisible(false); } } c.gridwidth = 1; // Champ Module c.gridx = 0; c.gridy++; c.gridwidth = GridBagConstraints.REMAINDER; final JPanel addP = ComptaSQLConfElement.createAdditionalPanel(); this.setAdditionalFieldsPanel(new FormLayouter(addP, 2)); this.add(addP, c); c.gridy++; c.gridwidth = 1; final ElementComboBox boxDevise = new ElementComboBox(); if (DefaultNXProps.getInstance().getBooleanValue(AbstractVenteArticleItemTable.ARTICLE_SHOW_DEVISE, false)) { // Devise c.gridx = 0; c.gridy++; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel(getLabelFor("ID_DEVISE"), SwingConstants.RIGHT), c); c.gridx = GridBagConstraints.RELATIVE; c.gridwidth = 1; c.weightx = 1; c.weighty = 0; c.fill = GridBagConstraints.NONE; this.add(boxDevise, c); this.addView(boxDevise, "ID_DEVISE"); } // Reference c.gridx = 0; c.gridy++; c.gridwidth = 1; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.EAST; this.add(new JLabel(getLabelFor("NOM"), SwingConstants.RIGHT), c); final JTextField textNom = new JTextField(); c.gridx++; c.weightx = 1; this.add(textNom, c); String field; field = "ID_COMMERCIAL"; // Commercial c.weightx = 0; c.gridx++; this.add(new JLabel(getLabelFor(field), SwingConstants.RIGHT), c); ElementComboBox commSel = new ElementComboBox(false, 25); c.gridx = GridBagConstraints.RELATIVE; c.gridwidth = 1; c.weightx = 1; c.weighty = 0; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.WEST; this.add(commSel, c); addRequiredSQLObject(commSel, field); // Table d'lment c.fill = GridBagConstraints.BOTH; c.gridy++; c.gridx = 0; c.weightx = 0; c.weighty = 1; c.gridwidth = 4; this.add(this.table, c); if (DefaultNXProps.getInstance().getBooleanValue(AbstractVenteArticleItemTable.ARTICLE_SHOW_DEVISE, false)) { boxDevise.addValueListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { table.setDevise(boxDevise.getSelectedRow()); } }); } this.fourn.addValueListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { table.setFournisseur(fourn.getSelectedRow()); } }); // Bottom c.gridy++; c.weighty = 0; this.add(getBottomPanel(), c); c.gridx = 0; c.gridy++; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.WEST; JPanel panelOO = new JPanel(new FlowLayout(FlowLayout.RIGHT)); panelOO.add(this.checkImpression, c); panelOO.add(this.checkVisu, c); c.gridwidth = GridBagConstraints.REMAINDER; this.add(panelOO, c); addRequiredSQLObject(this.fourn, "ID_FOURNISSEUR"); addSQLObject(textNom, "NOM"); addRequiredSQLObject(dateCommande, "DATE"); // addRequiredSQLObject(radioEtat, "ID_ETAT_DEVIS"); addRequiredSQLObject(this.numeroUniqueCommande, "NUMERO"); addSQLObject(this.infos, "INFOS"); this.numeroUniqueCommande.setText(NumerotationAutoSQLElement.getNextNumero(CommandeSQLElement.class)); // radioEtat.setValue(EtatDevisSQLElement.EN_ATTENTE); // this.numeroUniqueDevis.addLabelWarningMouseListener(new MouseAdapter() { // public void mousePressed(MouseEvent e) { // // if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) { // numeroUniqueDevis.setText(NumerotationAutoSQLElement.getNextNumeroDevis()); // } // } // }); DefaultGridBagConstraints.lockMinimumSize(this.fourn); DefaultGridBagConstraints.lockMinimumSize(commSel); }
From source file:org.openmicroscopy.shoola.agents.measurement.view.ObjectInspector.java
/** Initializes the component composing the display. */ private void initComponents() { infoLabel = new JLabel(MAGNIFICATION + " is " + model.getDrawingView().getScaleFactor()); //create the table fieldTable = new FigureTable(new FigureTableModel(attributeFields, COLUMN_NAMES)); fieldTable.getTableHeader().setReorderingAllowed(false); fieldTable.setRowHeight(26);//w w w. j a v a 2 s . c o m fieldTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); fieldTable.setCellSelectionEnabled(true); fieldTable.setColumnSelectionAllowed(true); fieldTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { int col = fieldTable.getSelectedColumn(); int row = fieldTable.getSelectedRow(); Object value = fieldTable.getValueAt(row, col); if (e.getClickCount() == 1) { if (value instanceof Boolean) { toggleValue(); } } else if (e.getClickCount() > 1) { e.consume(); if (value instanceof Color) { //Only if the figure is not read only. FigureTableModel ftm = (FigureTableModel) fieldTable.getModel(); ROIFigure figure = ftm.getFigure(); if (figure != null && !figure.isReadOnly()) if (figure.canEdit()) controller.showColorPicker((Color) value); } else if (value instanceof Boolean) { toggleValue(); } } } }); fieldTable.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (FigureTable.VALUE_CHANGED_PROPERTY.equals(name)) { handleValueChanged((String) evt.getNewValue()); } } }); }
From source file:org.pentaho.ui.xul.binding.DefaultBinding.java
protected PropertyChangeListener setupBinding(final Reference a, final String va, final Reference b, final String vb, final Direction dir) { if (a.get() == null || va == null) { handleException(new BindingException("source bean or property is null")); }// w w w .j a v a2 s .c o m if (!(a.get() instanceof XulEventSource)) { handleException(new BindingException( "Binding error, source object " + a.get() + " not a XulEventSource instance")); } if (b.get() == null || vb == null) { handleException(new BindingException("target bean or property is null")); } Method sourceGetMethod = BindingUtil.findGetMethod(a.get(), va); Class getterClazz = BindingUtil.getMethodReturnType(sourceGetMethod, a.get()); getterMethods.push(sourceGetMethod); // find set method final Method targetSetMethod = BindingUtil.findSetMethod(b.get(), vb, getterClazz); // setup prop change listener to handle binding PropertyChangeListener listener = new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { final PropertyChangeListener cThis = this; if (evt.getPropertyName().equalsIgnoreCase(va)) { try { Object targetObject = b.get(); if (targetObject == null) { logger.debug("Binding target was Garbage Collected, removing propListener"); DefaultBinding.this.destroyBindings(); return; } Object value = doConversions(evt.getNewValue(), dir); final Object finalVal = evaluateExpressions(value); logger.debug("Setting val: " + finalVal + " on: " + targetObject); targetSetMethod.invoke(targetObject, finalVal); } catch (Exception e) { logger.debug(e); handleException(new BindingException("Error invoking setter method [" + targetSetMethod.getName() + "] on target: " + target.get(), e)); } } } }; ((XulEventSource) a.get()).addPropertyChangeListener(listener); return listener; }
From source file:org.isatools.isacreator.gui.DataEntryForm.java
public JComponent createFileField(final JTextComponent field) { final FileChooserUI fileChooserUI = new FileChooserUI(); final DropDownComponent dropdown = new DropDownComponent(field, fileChooserUI, DropDownComponent.FILE); fileChooserUI.addPropertyChangeListener("selectedFiles", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { String contents = ""; int count = 0; for (String file : fileChooserUI.getSelectedFiles()) { contents += file;/*from w ww . ja v a 2 s . c o m*/ if (count != fileChooserUI.getSelectedFiles().length - 1) { contents += ","; } count++; } field.setText(contents); dropdown.hidePopup(fileChooserUI); } }); fileChooserUI.addPropertyChangeListener("noSelectedFiles", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { dropdown.hidePopup(fileChooserUI); } }); return dropdown; }