List of usage examples for java.beans PropertyChangeListener PropertyChangeListener
PropertyChangeListener
From source file:net.sf.vfsjfilechooser.plaf.metal.MetalVFSFileChooserUI.java
@SuppressWarnings("serial") @Override/*from w ww . j a va 2 s. c o m*/ public void installComponents(VFSJFileChooser fc) { AbstractVFSFileSystemView fsv = fc.getFileSystemView(); fc.setBorder(new EmptyBorder(12, 12, 11, 11)); fc.setLayout(new BorderLayout(0, 11)); filePane = new VFSFilePane(new MetalVFSFileChooserUIAccessor()); fc.addPropertyChangeListener(filePane); updateUseShellFolder(); // ********************************* // // **** Construct the top panel **** // // ********************************* // // Directory manipulation buttons JPanel topPanel = new JPanel(new BorderLayout(11, 0)); topButtonPanel = new JPanel(); topButtonPanel.setLayout(new BoxLayout(topButtonPanel, BoxLayout.LINE_AXIS)); topPanel.add(topButtonPanel, BorderLayout.AFTER_LINE_ENDS); // Add the top panel to the fileChooser fc.add(topPanel, BorderLayout.NORTH); // ComboBox Label lookInLabel = new JLabel(lookInLabelText); topPanel.add(lookInLabel, BorderLayout.BEFORE_LINE_BEGINS); // CurrentDir ComboBox directoryComboBox = new JComboBox() { @Override public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); // Must be small enough to not affect total width. d.width = 150; return d; } }; directoryComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, lookInLabelText); directoryComboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE); lookInLabel.setLabelFor(directoryComboBox); directoryComboBoxModel = createDirectoryComboBoxModel(fc); directoryComboBox.setModel(directoryComboBoxModel); directoryComboBox.addActionListener(directoryComboBoxAction); directoryComboBox.setRenderer(createDirectoryComboBoxRenderer(fc)); directoryComboBox.setAlignmentX(JComponent.LEFT_ALIGNMENT); directoryComboBox.setAlignmentY(JComponent.TOP_ALIGNMENT); directoryComboBox.setMaximumRowCount(8); topPanel.add(directoryComboBox, BorderLayout.CENTER); // Up Button upFolderButton = new JButton(getChangeToParentDirectoryAction()); upFolderButton.setText(null); upFolderButton.setIcon(upFolderIcon); upFolderButton.setToolTipText(upFolderToolTipText); upFolderButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, upFolderAccessibleName); upFolderButton.setAlignmentX(JComponent.LEFT_ALIGNMENT); upFolderButton.setAlignmentY(JComponent.CENTER_ALIGNMENT); upFolderButton.setMargin(shrinkwrap); topButtonPanel.add(upFolderButton); topButtonPanel.add(Box.createRigidArea(hstrut5)); // Home Button FileObject homeDir = fsv.getHomeDirectory(); String toolTipText = homeFolderToolTipText; if (fsv.isRoot(homeDir)) { toolTipText = getFileView(fc).getName(homeDir); // Probably "Desktop". } JButton b = new JButton(homeFolderIcon); b.setToolTipText(toolTipText); b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, homeFolderAccessibleName); b.setAlignmentX(JComponent.LEFT_ALIGNMENT); b.setAlignmentY(JComponent.CENTER_ALIGNMENT); b.setMargin(shrinkwrap); b.addActionListener(getGoHomeAction()); topButtonPanel.add(b); topButtonPanel.add(Box.createRigidArea(hstrut5)); // New Directory Button if (!UIManager.getBoolean("FileChooser.readOnly")) { b = new JButton(filePane.getNewFolderAction()); b.setText(null); b.setIcon(newFolderIcon); b.setToolTipText(newFolderToolTipText); b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, newFolderAccessibleName); b.setAlignmentX(JComponent.LEFT_ALIGNMENT); b.setAlignmentY(JComponent.CENTER_ALIGNMENT); b.setMargin(shrinkwrap); } topButtonPanel.add(b); topButtonPanel.add(Box.createRigidArea(hstrut5)); // View button group ButtonGroup viewButtonGroup = new ButtonGroup(); // List Button listViewButton = new JToggleButton(listViewIcon); listViewButton.setToolTipText(listViewButtonToolTipText); listViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, listViewButtonAccessibleName); listViewButton.setSelected(true); listViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT); listViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT); listViewButton.setMargin(shrinkwrap); listViewButton.addActionListener(filePane.getViewTypeAction(VFSFilePane.VIEWTYPE_LIST)); topButtonPanel.add(listViewButton); viewButtonGroup.add(listViewButton); // Details Button detailsViewButton = new JToggleButton(detailsViewIcon); detailsViewButton.setToolTipText(detailsViewButtonToolTipText); detailsViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, detailsViewButtonAccessibleName); detailsViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT); detailsViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT); detailsViewButton.setMargin(shrinkwrap); detailsViewButton.addActionListener(filePane.getViewTypeAction(VFSFilePane.VIEWTYPE_DETAILS)); topButtonPanel.add(detailsViewButton); viewButtonGroup.add(detailsViewButton); filePane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if ("viewType".equals(e.getPropertyName())) { final int viewType = filePane.getViewType(); if (viewType == VFSFilePane.VIEWTYPE_LIST) { listViewButton.setSelected(true); } else if (viewType == VFSFilePane.VIEWTYPE_DETAILS) { detailsViewButton.setSelected(true); } } } }); // ************************************** // // ******* Add the directory pane ******* // // ************************************** // fc.add(getAccessoryPanel(), BorderLayout.AFTER_LINE_ENDS); JComponent accessory = fc.getAccessory(); if (accessory != null) { getAccessoryPanel().add(accessory); } filePane.setPreferredSize(LIST_PREF_SIZE); fc.add(filePane, BorderLayout.CENTER); // ********************************** // // **** Construct the bottom panel ** // // ********************************** // bottomPanel = getBottomPanel(); bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.Y_AXIS)); fc.add(bottomPanel, BorderLayout.SOUTH); // FileName label and textfield JPanel fileNamePanel = new JPanel(); fileNamePanel.setLayout(new BoxLayout(fileNamePanel, BoxLayout.LINE_AXIS)); bottomPanel.add(fileNamePanel); bottomPanel.add(Box.createRigidArea(vstrut5)); fileNameLabel = new AlignedLabel(); populateFileNameLabel(); fileNamePanel.add(fileNameLabel); fileNameTextField = new JTextField(35) { @Override public Dimension getMaximumSize() { return new Dimension(Short.MAX_VALUE, super.getPreferredSize().height); } }; PopupHandler.installDefaultMouseListener(fileNameTextField); fileNamePanel.add(fileNameTextField); fileNameLabel.setLabelFor(fileNameTextField); fileNameTextField.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { if (!getFileChooser().isMultiSelectionEnabled()) { filePane.clearSelection(); } } }); if (fc.isMultiSelectionEnabled()) { setFileName(fileNameString(fc.getSelectedFiles())); } else { setFileName(fileNameString(fc.getSelectedFile())); } // Filetype label and combobox JPanel filesOfTypePanel = new JPanel(); filesOfTypePanel.setLayout(new BoxLayout(filesOfTypePanel, BoxLayout.LINE_AXIS)); bottomPanel.add(filesOfTypePanel); AlignedLabel filesOfTypeLabel = new AlignedLabel(filesOfTypeLabelText); filesOfTypePanel.add(filesOfTypeLabel); filterComboBoxModel = createFilterComboBoxModel(); fc.addPropertyChangeListener(filterComboBoxModel); filterComboBox = new JComboBox(filterComboBoxModel); filterComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, filesOfTypeLabelText); filesOfTypeLabel.setLabelFor(filterComboBox); filterComboBox.setRenderer(createFilterComboBoxRenderer()); filesOfTypePanel.add(filterComboBox); // buttons getButtonPanel().setLayout(new ButtonAreaLayout()); approveButton = new JButton(getApproveButtonText(fc)); // Note: Metal does not use mnemonics for approve and cancel approveButton.addActionListener(getApproveSelectionAction()); fileNameTextField.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { getApproveSelectionAction().actionPerformed(null); } } }); approveButton.setToolTipText(getApproveButtonToolTipText(fc)); getButtonPanel().add(approveButton); cancelButton = new JButton(cancelButtonText); cancelButton.setToolTipText(cancelButtonToolTipText); cancelButton.addActionListener(getCancelSelectionAction()); getButtonPanel().add(cancelButton); if (fc.getControlButtonsAreShown()) { addControlButtons(); } groupLabels(new AlignedLabel[] { fileNameLabel, filesOfTypeLabel }); }
From source file:org.openconcerto.erp.core.sales.invoice.component.SaisieVenteFactureSQLComponent.java
public void addViews() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); this.checkPrevisionnelle = new JCheckBox(); this.checkComplement = new JCheckBox(); this.fieldTTC = new DeviseField(); final ComptaPropsConfiguration comptaPropsConfiguration = ((ComptaPropsConfiguration) Configuration .getInstance());/*from ww w .j a v a 2 s . c om*/ this.textAvoirTTC = new DeviseField(); // Champ Module c.gridx = 0; 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; if (getTable().contains("ID_POLE_PRODUIT")) { JLabel labelPole = new JLabel(getLabelFor("ID_POLE_PRODUIT")); labelPole.setHorizontalAlignment(SwingConstants.RIGHT); this.add(labelPole, c); c.gridx++; ElementComboBox pole = new ElementComboBox(); this.add(pole, c); this.addSQLObject(pole, "ID_POLE_PRODUIT"); c.gridy++; c.gridwidth = 1; c.gridx = 0; } /******************************************************************************************* * * RENSEIGNEMENTS ******************************************************************************************/ // Ligne 1 : Numero de facture JLabel labelNum = new JLabel(getLabelFor("NUMERO")); labelNum.setHorizontalAlignment(SwingConstants.RIGHT); c.gridx = 0; c.gridy++; c.weightx = 0; this.add(labelNum, c); this.textNumeroUnique = new JUniqueTextField(16); c.gridx++; c.weightx = 0; c.fill = GridBagConstraints.NONE; DefaultGridBagConstraints.lockMinimumSize(this.textNumeroUnique); this.add(textNumeroUnique, c); // Date c.gridx++; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel(getLabelFor("DATE"), SwingConstants.RIGHT), c); c.gridx++; c.weightx = 1; c.fill = GridBagConstraints.NONE; final JDate dateSaisie = new JDate(true); // listener permettant la mise jour du numro de facture en fonction de la date // slectionne dateSaisie.addValueListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (!isFilling() && dateSaisie.getValue() != null) { final String nextNumero = NumerotationAutoSQLElement .getNextNumero(SaisieVenteFactureSQLElement.class, dateSaisie.getValue()); if (textNumeroUnique.getText().trim().length() > 0 && !nextNumero.equalsIgnoreCase(textNumeroUnique.getText())) { int answer = JOptionPane.showConfirmDialog(SaisieVenteFactureSQLComponent.this, "Voulez vous actualiser le numro de la facture?", "Changement du numro de facture", JOptionPane.YES_NO_OPTION); if (answer == JOptionPane.NO_OPTION) { return; } } textNumeroUnique.setText(nextNumero); } } }); this.add(dateSaisie, c); // Ligne 2 : reference c.gridx = 0; c.gridwidth = 1; c.gridy++; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; JLabel labelLibelle = new JLabel(getLabelFor("NOM")); labelLibelle.setHorizontalAlignment(SwingConstants.RIGHT); this.add(labelLibelle, c); SQLTextCombo textLibelle = new SQLTextCombo(); c.gridx++; c.weightx = 1; c.fill = GridBagConstraints.BOTH; this.add(textLibelle, c); this.addSQLObject(textLibelle, "NOM"); c.fill = GridBagConstraints.HORIZONTAL; this.comboCommercial = new ElementComboBox(false); // Commercial String field; field = "ID_COMMERCIAL"; c.gridx++; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel(getLabelFor(field), SwingConstants.RIGHT), c); c.gridx++; c.weightx = 1; c.fill = GridBagConstraints.NONE; this.add(this.comboCommercial, c); this.addRequiredSQLObject(this.comboCommercial, field); // Client c.gridx = 0; c.gridy++; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel(getLabelFor("ID_CLIENT"), SwingConstants.RIGHT), c); c.gridx++; c.weightx = 1; c.fill = GridBagConstraints.NONE; this.comboClient = new ElementComboBox(); this.add(this.comboClient, c); if (getTable().contains("ID_ECHEANCIER_CCI")) { // Echeancier c.gridx++; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel(getLabelFor("ID_ECHEANCIER_CCI"), SwingConstants.RIGHT), c); c.gridx++; c.weightx = 1; c.fill = GridBagConstraints.NONE; final ElementComboBox echeancier = new ElementComboBox(); final SQLElement contactElement = Configuration.getInstance().getDirectory() .getElement("ECHEANCIER_CCI"); echeancier.init(contactElement, contactElement.getComboRequest(true)); DefaultGridBagConstraints.lockMinimumSize(echeancier); this.addView(echeancier, "ID_ECHEANCIER_CCI"); selAffaire.addValueListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent arg0) { // TODO Raccord de mthode auto-gnr if (selAffaire.getSelectedRow() != null) { echeancier.getRequest().setWhere(new Where(contactElement.getTable().getField("ID_AFFAIRE"), "=", selAffaire.getSelectedRow().getID())); if (!isFilling()) { SQLRow rowPole = selAffaire.getSelectedRow().getForeignRow("ID_POLE_PRODUIT"); comboCommercial.setValue(rowPole); } } else { echeancier.getRequest().setWhere(null); } } }); this.add(echeancier, c); } this.comboClient.addValueListener(this.changeClientListener); this.comboAdresse = new ElementComboBox(); this.comboAdresse.setAddIconVisible(false); this.comboAdresse.setListIconVisible(false); JLabel labelAdresse = new JLabel(getLabelFor("ID_ADRESSE"), SwingConstants.RIGHT); c.gridy++; c.gridx = 0; c.gridwidth = 1; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; labelAdresse.setHorizontalAlignment(SwingConstants.RIGHT); this.add(labelAdresse, c); c.gridx++; c.fill = GridBagConstraints.NONE; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1; this.add(this.comboAdresse, c); // Acompte this.checkAcompte = new JCheckBox(getLabelFor("ACOMPTE")); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; // this.add(this.checkAcompte, c); c.gridwidth = 1; this.addView(this.checkAcompte, "ACOMPTE"); // Compte Service this.checkCompteServiceAuto = new JCheckBox(getLabelFor("COMPTE_SERVICE_AUTO")); this.addSQLObject(this.checkCompteServiceAuto, "COMPTE_SERVICE_AUTO"); this.compteSelService = new ISQLCompteSelector(); this.labelCompteServ = new JLabel("Compte Service"); c.gridy++; c.gridx = 0; c.gridwidth = 1; c.weightx = 0; this.labelCompteServ.setHorizontalAlignment(SwingConstants.RIGHT); this.add(this.labelCompteServ, c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1; this.add(this.compteSelService, c); String valServ = DefaultNXProps.getInstance().getStringProperty("ArticleService"); Boolean bServ = Boolean.valueOf(valServ); this.checkCompteServiceAuto.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setCompteServiceVisible(!SaisieVenteFactureSQLComponent.this.checkCompteServiceAuto.isSelected()); } }); // FIXME A checker si utile pour Preventec ou KD setCompteServiceVisible(false); // setCompteServiceVisible(!(bServ != null && !bServ.booleanValue())); final JPanel pAcompte = new JPanel(); final DeviseField textAcompteHT = new DeviseField(); pAcompte.add(new JLabel("Acompte HT")); pAcompte.add(textAcompteHT); pAcompte.add(new JLabel("soit")); final JTextField textAcompte = new JTextField(5); pAcompte.add(textAcompte); pAcompte.add(new JLabel("%")); c.gridx = 0; c.gridy++; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; this.add(pAcompte, c); c.anchor = GridBagConstraints.WEST; this.addView(textAcompte, "POURCENT_ACOMPTE"); pAcompte.setVisible(false); /******************************************************************************************* * * DETAILS ******************************************************************************************/ this.tableFacture = new SaisieVenteFactureItemTable(); final ElementComboBox boxTarif = new ElementComboBox(); if (this.getTable().getFieldsName().contains("ID_TARIF")) { // TARIF c.gridy++; c.gridx = 0; c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel("Tarif appliquer", SwingConstants.RIGHT), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.NONE; c.weightx = 1; DefaultGridBagConstraints.lockMinimumSize(boxTarif); this.add(boxTarif, c); this.addView(boxTarif, "ID_TARIF"); boxTarif.addModelListener("wantedID", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { SQLRow selectedRow = boxTarif.getRequest().getPrimaryTable().getRow(boxTarif.getWantedID()); tableFacture.setTarif(selectedRow, false); } }); } c.gridy++; c.gridx = 0; c.weightx = 1; c.weighty = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.BOTH; ITextArea infos = new ITextArea(4, 4); this.add(this.tableFacture, c); // FIXME this.addView(this.tableFacture.getRowValuesTable(), ""); /******************************************************************************************* * * MODE DE REGLEMENT ******************************************************************************************/ JPanel panelBottom = new JPanel(new GridBagLayout()); GridBagConstraints cBottom = new DefaultGridBagConstraints(); cBottom.weightx = 1; cBottom.anchor = GridBagConstraints.NORTHWEST; // Mode de rglement this.addView("ID_MODE_REGLEMENT", REQ + ";" + DEC + ";" + SEP); this.eltModeRegl = (ElementSQLObject) this.getView("ID_MODE_REGLEMENT"); panelBottom.add(this.eltModeRegl, cBottom); /******************************************************************************************* * * FRAIS DE PORT ET REMISE ******************************************************************************************/ JPanel panelFrais = new JPanel(); panelFrais.setLayout(new GridBagLayout()); final GridBagConstraints cFrais = new DefaultGridBagConstraints(); this.textPortHT = new DeviseField(5); DefaultGridBagConstraints.lockMinimumSize(textPortHT); addSQLObject(this.textPortHT, "PORT_HT"); this.textRemiseHT = new DeviseField(5); DefaultGridBagConstraints.lockMinimumSize(textRemiseHT); addSQLObject(this.textRemiseHT, "REMISE_HT"); // Frais de port cFrais.gridheight = 1; cFrais.gridx = 1; SQLRequestComboBox boxTaxePort = new SQLRequestComboBox(false, 8); if (getTable().contains("ID_TAXE_PORT")) { JLabel labelPortHT = new JLabel(getLabelFor("PORT_HT")); labelPortHT.setHorizontalAlignment(SwingConstants.RIGHT); cFrais.gridy++; panelFrais.add(labelPortHT, cFrais); cFrais.gridx++; panelFrais.add(this.textPortHT, cFrais); JLabel labelTaxeHT = new JLabel(getLabelFor("ID_TAXE_PORT")); labelTaxeHT.setHorizontalAlignment(SwingConstants.RIGHT); cFrais.gridx = 1; cFrais.gridy++; panelFrais.add(labelTaxeHT, cFrais); cFrais.gridx++; panelFrais.add(boxTaxePort, cFrais); this.addView(boxTaxePort, "ID_TAXE_PORT", REQ); boxTaxePort.addValueListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { // TODO Raccord de mthode auto-gnr totalTTC.updateTotal(); } }); } // Remise JLabel labelRemiseHT = new JLabel(getLabelFor("REMISE_HT")); labelRemiseHT.setHorizontalAlignment(SwingConstants.RIGHT); cFrais.gridy++; cFrais.gridx = 1; panelFrais.add(labelRemiseHT, cFrais); cFrais.gridx++; panelFrais.add(this.textRemiseHT, cFrais); cFrais.gridy++; cBottom.gridx++; cBottom.weightx = 1; cBottom.anchor = GridBagConstraints.NORTHEAST; cBottom.fill = GridBagConstraints.NONE; panelBottom.add(panelFrais, cBottom); /******************************************************************************************* * * CALCUL DES TOTAUX ******************************************************************************************/ DeviseField fieldHT = new DeviseField(); final DeviseField fieldTVA = new DeviseField(); DeviseField fieldService = new DeviseField(); DeviseField fieldTHA = new DeviseField(); DeviseField fieldDevise = null; if (getTable().getFieldsName().contains("T_DEVISE")) { fieldDevise = new DeviseField(); addSQLObject(fieldDevise, "T_DEVISE"); } // FIXME was required but not displayed for KD addSQLObject(fieldTHA, "T_HA"); addRequiredSQLObject(fieldHT, "T_HT"); addRequiredSQLObject(fieldTVA, "T_TVA"); addRequiredSQLObject(this.fieldTTC, "T_TTC"); addRequiredSQLObject(fieldService, "T_SERVICE"); JTextField poids = new JTextField(); addSQLObject(poids, "T_POIDS"); totalTTC = new TotalPanel(this.tableFacture, fieldHT, fieldTVA, this.fieldTTC, this.textPortHT, this.textRemiseHT, fieldService, fieldTHA, fieldDevise, poids, null, (getTable().contains("ID_TAXE_PORT") ? boxTaxePort : null)); DefaultGridBagConstraints.lockMinimumSize(totalTTC); cBottom.gridx++; cBottom.weightx = 1; cBottom.anchor = GridBagConstraints.EAST; cBottom.fill = GridBagConstraints.HORIZONTAL; panelBottom.add(totalTTC, cBottom); c.anchor = GridBagConstraints.WEST; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy++; c.weighty = 0; this.add(panelBottom, c); // Ligne : Avoir c.gridy++; c.gridx = 0; c.weightx = 1; c.weighty = 0; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; this.add(createPanelAvoir(), c); // Infos c.gridy++; c.gridx = 0; c.gridwidth = 4; c.fill = GridBagConstraints.BOTH; this.add(new TitledSeparator(getLabelFor("INFOS")), c); c.gridy++; final JScrollPane comp = new JScrollPane(infos); infos.setBorder(null); DefaultGridBagConstraints.lockMinimumSize(comp); this.add(comp, c); this.panelOO = new PanelOOSQLComponent(this); c.gridy++; c.gridx = 0; c.weightx = 1; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.NORTHEAST; this.add(this.panelOO, c); this.addSQLObject(this.textAvoirTTC, "T_AVOIR_TTC"); this.addRequiredSQLObject(dateSaisie, "DATE"); this.addRequiredSQLObject(this.comboClient, "ID_CLIENT"); this.addSQLObject(this.comboAdresse, "ID_ADRESSE"); this.addRequiredSQLObject(this.textNumeroUnique, "NUMERO"); this.addSQLObject(infos, "INFOS"); this.addSQLObject(this.checkPrevisionnelle, "PREVISIONNELLE"); this.addSQLObject(this.checkComplement, "COMPLEMENT"); this.addSQLObject(this.selAvoir, "ID_AVOIR_CLIENT"); this.addSQLObject(this.compteSelService, "ID_COMPTE_PCE_SERVICE"); ModeDeReglementSQLComponent modeReglComp; modeReglComp = (ModeDeReglementSQLComponent) this.eltModeRegl.getSQLChild(); this.selAvoir.getRequest().setWhere(new Where(this.tableAvoir.getField("SOLDE"), "=", Boolean.FALSE)); this.selAvoir.fillCombo(); // Selection du compte de service int idCompteVenteService = rowPrefsCompte.getInt("ID_COMPTE_PCE_VENTE_SERVICE"); if (idCompteVenteService <= 1) { try { idCompteVenteService = ComptePCESQLElement.getIdComptePceDefault("VentesServices"); } catch (Exception e) { e.printStackTrace(); } } this.compteSelService.setValue(idCompteVenteService); // Lock DefaultGridBagConstraints.lockMinimumSize(this.comboClient); DefaultGridBagConstraints.lockMinimumSize(this.comboCommercial); DefaultGridBagConstraints.lockMinimumSize(this.comboAdresse); // Listeners this.comboClient.addValueListener(this.listenerModeReglDefaut); this.fieldTTC.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent e) { refreshText(); } }); this.selAvoir.addValueListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { refreshText(); } }); this.checkAcompte.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { pAcompte.setVisible(SaisieVenteFactureSQLComponent.this.checkAcompte.isSelected()); } }); this.changeClientListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (SaisieVenteFactureSQLComponent.this.comboClient.getValue() != null) { final SQLRow row = SaisieVenteFactureSQLComponent.this.comboClient.getSelectedRow(); final int id = row == null ? SQLRow.NONEXISTANT_ID : row.getID(); SaisieVenteFactureSQLComponent.this.defaultContactRowValues.putForeignID("ID_CLIENT", row); if (row != null) { if (SaisieVenteFactureSQLComponent.this.contact != null) { Where w = new Where( SaisieVenteFactureSQLComponent.this.eltContact.getTable().getField("ID_CLIENT"), "=", SQLRow.NONEXISTANT_ID); w = w.or(new Where( SaisieVenteFactureSQLComponent.this.eltContact.getTable().getField("ID_CLIENT"), "=", id)); SaisieVenteFactureSQLComponent.this.contact.getRequest().setWhere(w); } if (SaisieVenteFactureSQLComponent.this.comboAdresse != null) { Where w = new Where(SaisieVenteFactureSQLComponent.TABLE_ADRESSE.getKey(), "=", row.getInt("ID_ADRESSE")); w = w.or(new Where(SaisieVenteFactureSQLComponent.TABLE_ADRESSE.getKey(), "=", row.getInt("ID_ADRESSE_L"))); w = w.or(new Where(SaisieVenteFactureSQLComponent.TABLE_ADRESSE.getKey(), "=", row.getInt("ID_ADRESSE_F"))); SQLRow rowCli = row; w = w.or(new Where(SaisieVenteFactureSQLComponent.TABLE_ADRESSE.getField("ID_CLIENT"), "=", rowCli.getID())); SaisieVenteFactureSQLComponent.this.comboAdresse.getRequest().setWhere(w); } } else { if (SaisieVenteFactureSQLComponent.this.comboAdresse != null) { SaisieVenteFactureSQLComponent.this.comboAdresse.getRequest().setWhere(null); } } SaisieVenteFactureSQLComponent.this.previousClient = id; } } }; this.changeCompteListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { SQLSelect sel = new SQLSelect(getTable().getBase()); sel.addSelect(SaisieVenteFactureSQLComponent.this.client.getTable().getKey()); Where where = new Where( SaisieVenteFactureSQLComponent.this.client.getTable().getField("ID_COMPTE_PCE"), "=", SaisieVenteFactureSQLComponent.this.compteSel.getValue()); sel.setWhere(where); String req = sel.asString(); List l = getTable().getBase().getDataSource().execute(req); if (l != null) { if (l.size() == 1) { Map<String, Object> m = (Map<String, Object>) l.get(0); Object o = m.get(SaisieVenteFactureSQLComponent.this.client.getTable().getKey().getName()); System.err.println("Only one value match :: " + o); if (o != null) { SaisieVenteFactureSQLComponent.this.comboClient .setValue(Integer.valueOf(((Number) o).intValue())); } } } } }; this.textPortHT.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent e) { totalTTC.updateTotal(); } }); this.textRemiseHT.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent e) { totalTTC.updateTotal(); } }); this.comboClient.addValueListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (SaisieVenteFactureSQLComponent.this.isFilling()) return; final SQLRow row = ((SQLRequestComboBox) evt.getSource()).getSelectedRow(); if (row != null) { SaisieVenteFactureSQLComponent.this.defaultContactRowValues.putForeignID("ID_CLIENT", row); if (SaisieVenteFactureSQLComponent.this.client.getTable().contains("ID_TARIF")) { SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF"); if (foreignRow != null && !foreignRow.isUndefined() && (boxTarif.getSelectedRow() == null || boxTarif.getSelectedId() != foreignRow.getID()) && JOptionPane.showConfirmDialog(null, "Appliquer les tarifs associs au client?") == JOptionPane.YES_OPTION) { boxTarif.setValue(foreignRow.getID()); // SaisieVenteFactureSQLComponent.this.tableFacture.setTarif(foreignRow, // true); } else { boxTarif.setValue(foreignRow); } } int idCpt = row.getInt("ID_COMPTE_PCE"); if (idCpt <= 1) { // Select Compte client par defaut idCpt = rowPrefsCompte.getInt("ID_COMPTE_PCE_CLIENT"); if (idCpt <= 1) { try { idCpt = ComptePCESQLElement.getIdComptePceDefault("Clients"); } catch (Exception e) { e.printStackTrace(); } } } if (SaisieVenteFactureSQLComponent.this.compteSel != null) { Integer i = SaisieVenteFactureSQLComponent.this.compteSel.getValue(); if (i == null || i.intValue() != idCpt) { SaisieVenteFactureSQLComponent.this.compteSel.setValue(idCpt); } } } } }); }
From source file:org.pmedv.blackboard.board.BoardDesignerPerspective.java
@Override protected void initializeComponents() { setLayout(new BorderLayout()); toolTabPane = new JTabbedPane(JTabbedPane.BOTTOM); horizontalSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); ctx = AppContext.getContext();/*from w w w. j a v a 2 s .c o m*/ resources = ctx.getBean(ResourceService.class); advisor = ctx.getBean(ApplicationWindowAdvisor.class); final String position = (String) Preferences.values .get("org.pmedv.blackboard.BoardDesignerPerspective.layerPanelPlacement"); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { viewMap = new ViewMap(); rootWindow = DockingUtil.createRootWindow(viewMap, true); rootWindow.getWindowBar(Direction.DOWN).setEnabled(true); rootWindow.getWindowProperties().setMinimizeEnabled(true); DockingWindowsTheme theme = new SoftBlueIceDockingTheme(); rootWindow.getRootWindowProperties().addSuperObject(theme.getRootWindowProperties()); rootWindow.getWindowProperties().getTabProperties().getHighlightedButtonProperties() .getCloseButtonProperties().setVisible(false); rootWindow.getWindowProperties().getTabProperties().getNormalButtonProperties() .getCloseButtonProperties().setVisible(false); editorArea = new TabWindow(); editorArea.getWindowProperties().getTabProperties().getNormalButtonProperties() .getCloseButtonProperties().setVisible(false); editorArea.getWindowProperties().getTabProperties().getHighlightedButtonProperties() .getCloseButtonProperties().setVisible(false); editorArea.getWindowProperties().getTabProperties().getNormalButtonProperties() .getMinimizeButtonProperties().setVisible(true); editorArea.getWindowProperties().getTabProperties().getHighlightedButtonProperties() .getMinimizeButtonProperties().setVisible(true); DockingWindowAdapter dockingAdapter = new DockingWindowAdapter() { @Override public void windowClosing(DockingWindow window) throws OperationAbortedException { } }; editorArea.addListener(dockingAdapter); setDockingListener(dockingAdapter); rootWindow.setWindow(editorArea); if (position.equalsIgnoreCase("left")) { horizontalSplitPane.setRightComponent(rootWindow); } else { horizontalSplitPane.setLeftComponent(rootWindow); } advisor.setCurrentEditorArea(editorArea); } }); JXTaskPaneContainer taskpanecontainer = new JXTaskPaneContainer(); taskpanecontainer.setBackground(new Color(182, 191, 205)); JXTaskPane shapePane = new JXTaskPane(); shapePane.setTitle(resources.getResourceByKey("BoardDesignerPerspective.shapes.title")); shapePane.add(ctx.getBean(ShapePropertiesPanel.class)); taskpanecontainer.add(shapePane); ctx.getBean(ShapePropertiesPanel.class).getStartLineCombo().setSelectedItem(LineEdgeType.STRAIGHT); ctx.getBean(ShapePropertiesPanel.class).getEndLineCombo().setSelectedItem(LineEdgeType.STRAIGHT); ctx.getBean(ShapePropertiesPanel.class).getThicknessCombo().setSelectedItem(new BasicStroke(2.0f)); JXTaskPane layerPane = new JXTaskPane(); layerPane.setTitle(resources.getResourceByKey("BoardDesignerPerspective.layers")); layerPane.add(ctx.getBean(ShowLayersCommand.class).getLayerPanel()); taskpanecontainer.add(layerPane); JScrollPane scrollPane = new JScrollPane(taskpanecontainer); if (position.equalsIgnoreCase("left")) { horizontalSplitPane.setLeftComponent(toolTabPane); } else { horizontalSplitPane.setRightComponent(toolTabPane); } horizontalSplitPane.setOneTouchExpandable(true); horizontalSplitPane.setDividerSize(10); toolTabPane.addTab(resources.getResourceByKey("tooltab.forms"), resources.getIcon("icon.paint"), scrollPane); final SymbolListPanel symbolListPanel = ctx.getBean(SymbolListPanel.class); toolTabPane.addTab(resources.getResourceByKey("tooltab.symbols"), resources.getIcon("icon.symbols"), symbolListPanel); final ModelListPanel modelListPanel = ctx.getBean(ModelListPanel.class); toolTabPane.addTab(resources.getResourceByKey("tooltab.models"), resources.getIcon("icon.model"), modelListPanel); add(horizontalSplitPane, BorderLayout.CENTER); commandArea = new RSyntaxTextArea(); commandArea.setRows(1); commandArea.setColumns(100); JPanel commandPanel = new JPanel(new BorderLayout()); commandPanel.add(new JLabel("Command :"), BorderLayout.WEST); commandPanel.add(commandArea, BorderLayout.CENTER); commandArea.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2), BorderFactory.createLineBorder(Color.BLACK))); add(commandPanel, BorderLayout.NORTH); setupAutoComplete(); commandArea.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { if (commandArea.getText().startsWith("add ") && commandArea.getText().length() > 4 && commandArea.hasFocus()) { PartFactory pf = AppContext.getContext().getBean(PartFactory.class); String tokens[] = commandArea.getText().split(" "); StringBuffer partName = new StringBuffer(); for (int i = 1; i < tokens.length; i++) { partName.append(tokens[i] + " "); } String name = partName.toString().trim(); if (pf.getPartnames().contains(name)) { e.consume(); commandArea.setText(""); BoardUtil.addPart(name, EditorUtils.getCurrentActiveEditor()); } } else if (commandArea.getText().equals("new")) { e.consume(); commandArea.setText(""); AppContext.getContext().getBean(CreateBoardCommand.class).execute(null); } else if (commandArea.getText().equals("resistor")) { e.consume(); commandArea.setText(""); AppContext.getContext().getBean(AddResistorCommand.class).execute(null); } else if (commandArea.getText().equals("diode")) { e.consume(); commandArea.setText(""); AppContext.getContext().getBean(AddDiodeCommand.class).execute(null); } else if (commandArea.getText().equals("text")) { e.consume(); commandArea.setText(""); AppContext.getContext().getBean(AddTextCommand.class).execute(null); } else if (commandArea.getText().equals("open")) { e.consume(); commandArea.setText(""); new OpenBoardCommand().execute(null); } else if (commandArea.getText().equals("save")) { e.consume(); commandArea.setText(""); AppContext.getContext().getBean(SaveBoardCommand.class).execute(null); } else if (commandArea.getText().equals("color")) { e.consume(); commandArea.setText(""); AppContext.getContext().getBean(ChooseColorCommand.class).execute(null); } } } }); horizontalSplitPane.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equalsIgnoreCase("dividerLocation")) { configProvider.getConfig().setDividerLocation(horizontalSplitPane.getDividerLocation()); } } }); ctx.getBean(ShapePropertiesPanel.class).getObjectField() .setText(resources.getResourceByKey("ShapePropertiesPanel.items.none")); ctx.getBean(ShapePropertiesPanel.class).getRotationSpinner().setEnabled(false); ctx.getBean(ShapePropertiesPanel.class).getStartAngleSpinner().setEnabled(false); initListeners(); }
From source file:com.m4rc310.cb.builders.ComponentBuilder.java
private void buildAllComponents() { for (Map.Entry<Field, AbstractComponetAdapter> entrySet : adapters.entrySet()) { Field field = entrySet.getKey(); Acomponent ac = field.getDeclaredAnnotation(Acomponent.class); AbstractComponetAdapter adapter = entrySet.getValue(); Object target = getTargetForField(field); adapter.setComponentsBuilder(this); adapter.build(field, target);// w w w. j av a 2s . co m Adialog adialog = objectAnnotated.getClass().getDeclaredAnnotation(Adialog.class); if (adialog.debug()) { try { Object component = adapter.getComponent(); StringBuilder sgroup = new StringBuilder(); for (String group : ac.groups()) { sgroup.append("[ "); sgroup.append(group); sgroup.append(" ]"); } String toolTipText = String.format("Name: %s - ToolTipText: %s - Groups: %s", ac.ref(), ac.toolTipText(), sgroup); MethodUtils.method(component, "setToolTipText", String.class).invoke(toolTipText); } catch (Exception e) { infoError(e); } } else { Object component = adapter.getComponent(); MethodUtils.method(component, "setToolTipText", String.class).invoke(getString(ac.toolTipText())); } try { Object value = field.get(target); adapter.update(field, value); if (ac.type().equals(EnumComponentType.PANEL)) { Object component = adapter.getComponent(); // Object[] components = ((JPanel) component).getComponents(); // // for (Object c : components) { // boolean bvalue = (boolean) MethodUtils.method(c, "isEnabled").invoke(); // mc.put(c, bvalue); // } PropertyChangeListener pcl = new PropertyChangeListener() { Map<Object, Boolean> mc = new HashMap<>(); @Override public void propertyChange(PropertyChangeEvent evt) { Object[] components = ((JPanel) component).getComponents(); if (evt.getPropertyName().equals("enabled")) { boolean enable = (boolean) evt.getNewValue(); for (Object com : components) { if (!mc.containsKey(com)) { boolean bvalue = (boolean) MethodUtils.method(com, "isEnabled").invoke(); mc.put(com, bvalue); } if (enable) { MethodUtils.method(com, "setEnabled", boolean.class).invoke(mc.get(com)); } else { MethodUtils.method(com, "setEnabled", boolean.class).invoke(enable); } } } } }; MethodUtils.method(component, "addPropertyChangeListener", PropertyChangeListener.class) .invoke(pcl); putContainer(value.hashCode(), component); } } catch (IllegalArgumentException | IllegalAccessException e) { infoError(e); throw new UnsupportedOperationException(e); } } }
From source file:com.googlecode.vfsjfilechooser2.plaf.metal.MetalVFSFileChooserUI.java
@SuppressWarnings("serial") @Override/* w ww . j a v a2s .co m*/ public void installComponents(VFSJFileChooser fc) { AbstractVFSFileSystemView fsv = fc.getFileSystemView(); fc.setBorder(new EmptyBorder(12, 12, 11, 11)); fc.setLayout(new BorderLayout(0, 11)); filePane = new VFSFilePane(new MetalVFSFileChooserUIAccessor()); fc.addPropertyChangeListener(filePane); updateUseShellFolder(); // ********************************* // // **** Construct the top panel **** // // ********************************* // // Directory manipulation buttons JPanel topPanel = new JPanel(new BorderLayout(11, 0)); topButtonPanel = new JPanel(); topButtonPanel.setLayout(new BoxLayout(topButtonPanel, BoxLayout.LINE_AXIS)); topPanel.add(topButtonPanel, BorderLayout.AFTER_LINE_ENDS); // Add the top panel to the fileChooser fc.add(topPanel, BorderLayout.NORTH); // ComboBox Label lookInLabel = new JLabel(lookInLabelText); topPanel.add(lookInLabel, BorderLayout.BEFORE_LINE_BEGINS); // CurrentDir ComboBox directoryComboBox = new JComboBox() { @Override public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); // Must be small enough to not affect total width. d.width = 150; return d; } }; directoryComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, lookInLabelText); directoryComboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE); lookInLabel.setLabelFor(directoryComboBox); directoryComboBoxModel = createDirectoryComboBoxModel(fc); directoryComboBox.setModel(directoryComboBoxModel); directoryComboBox.addActionListener(directoryComboBoxAction); directoryComboBox.setRenderer(createDirectoryComboBoxRenderer(fc)); directoryComboBox.setAlignmentX(JComponent.LEFT_ALIGNMENT); directoryComboBox.setAlignmentY(JComponent.TOP_ALIGNMENT); directoryComboBox.setMaximumRowCount(8); topPanel.add(directoryComboBox, BorderLayout.CENTER); // Up Button upFolderButton = new JButton(getChangeToParentDirectoryAction()); upFolderButton.setText(null); upFolderButton.setIcon(upFolderIcon); upFolderButton.setToolTipText(upFolderToolTipText); upFolderButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, upFolderAccessibleName); upFolderButton.setAlignmentX(JComponent.LEFT_ALIGNMENT); upFolderButton.setAlignmentY(JComponent.CENTER_ALIGNMENT); upFolderButton.setMargin(shrinkwrap); topButtonPanel.add(upFolderButton); topButtonPanel.add(Box.createRigidArea(hstrut5)); // Home Button FileObject homeDir = fsv.getHomeDirectory(); String toolTipText = homeFolderToolTipText; if (fsv.isRoot(homeDir)) { toolTipText = getFileView(fc).getName(homeDir); // Probably "Desktop". } JButton b = new JButton(homeFolderIcon); b.setToolTipText(toolTipText); b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, homeFolderAccessibleName); b.setAlignmentX(JComponent.LEFT_ALIGNMENT); b.setAlignmentY(JComponent.CENTER_ALIGNMENT); b.setMargin(shrinkwrap); b.addActionListener(getGoHomeAction()); topButtonPanel.add(b); topButtonPanel.add(Box.createRigidArea(hstrut5)); // New Directory Button if (!UIManager.getBoolean("FileChooser.readOnly")) { b = new JButton(filePane.getNewFolderAction()); b.setText(null); b.setIcon(newFolderIcon); b.setToolTipText(newFolderToolTipText); b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, newFolderAccessibleName); b.setAlignmentX(JComponent.LEFT_ALIGNMENT); b.setAlignmentY(JComponent.CENTER_ALIGNMENT); b.setMargin(shrinkwrap); } topButtonPanel.add(b); topButtonPanel.add(Box.createRigidArea(hstrut5)); // View button group ButtonGroup viewButtonGroup = new ButtonGroup(); // List Button listViewButton = new JToggleButton(listViewIcon); listViewButton.setToolTipText(listViewButtonToolTipText); listViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, listViewButtonAccessibleName); listViewButton.setSelected(true); listViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT); listViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT); listViewButton.setMargin(shrinkwrap); listViewButton.addActionListener(filePane.getViewTypeAction(VFSFilePane.VIEWTYPE_LIST)); topButtonPanel.add(listViewButton); viewButtonGroup.add(listViewButton); // Details Button detailsViewButton = new JToggleButton(detailsViewIcon); detailsViewButton.setToolTipText(detailsViewButtonToolTipText); detailsViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, detailsViewButtonAccessibleName); detailsViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT); detailsViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT); detailsViewButton.setMargin(shrinkwrap); detailsViewButton.addActionListener(filePane.getViewTypeAction(VFSFilePane.VIEWTYPE_DETAILS)); topButtonPanel.add(detailsViewButton); viewButtonGroup.add(detailsViewButton); filePane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if ("viewType".equals(e.getPropertyName())) { final int viewType = filePane.getViewType(); if (viewType == VFSFilePane.VIEWTYPE_LIST) { listViewButton.setSelected(true); } else if (viewType == VFSFilePane.VIEWTYPE_DETAILS) { detailsViewButton.setSelected(true); } } } }); // ************************************** // // ******* Add the directory pane ******* // // ************************************** // fc.add(getAccessoryPanel(), BorderLayout.AFTER_LINE_ENDS); JComponent accessory = fc.getAccessory(); if (accessory != null) { getAccessoryPanel().add(accessory); } filePane.setPreferredSize(LIST_PREF_SIZE); fc.add(filePane, BorderLayout.CENTER); // ********************************** // // **** Construct the bottom panel ** // // ********************************** // bottomPanel = getBottomPanel(); bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.Y_AXIS)); fc.add(bottomPanel, BorderLayout.SOUTH); // FileName label and textfield JPanel fileNamePanel = new JPanel(); fileNamePanel.setLayout(new BoxLayout(fileNamePanel, BoxLayout.LINE_AXIS)); bottomPanel.add(fileNamePanel); bottomPanel.add(Box.createRigidArea(vstrut5)); fileNameLabel = new AlignedLabel(); populateFileNameLabel(); fileNamePanel.add(fileNameLabel); fileNameTextField = new JTextField(35) { @Override public Dimension getMaximumSize() { return new Dimension(Short.MAX_VALUE, super.getPreferredSize().height); } }; PopupHandler.installDefaultMouseListener(fileNameTextField); fileNamePanel.add(fileNameTextField); fileNameLabel.setLabelFor(fileNameTextField); fileNameTextField.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { if (!getFileChooser().isMultiSelectionEnabled()) { filePane.clearSelection(); } } }); if (fc.isMultiSelectionEnabled()) { setFileName(fileNameString(fc.getSelectedFileObjects())); } else { setFileName(fileNameString(fc.getSelectedFileObject())); } // Filetype label and combobox JPanel filesOfTypePanel = new JPanel(); filesOfTypePanel.setLayout(new BoxLayout(filesOfTypePanel, BoxLayout.LINE_AXIS)); bottomPanel.add(filesOfTypePanel); AlignedLabel filesOfTypeLabel = new AlignedLabel(filesOfTypeLabelText); filesOfTypePanel.add(filesOfTypeLabel); filterComboBoxModel = createFilterComboBoxModel(); fc.addPropertyChangeListener(filterComboBoxModel); filterComboBox = new JComboBox(filterComboBoxModel); filterComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, filesOfTypeLabelText); filesOfTypeLabel.setLabelFor(filterComboBox); filterComboBox.setRenderer(createFilterComboBoxRenderer()); filesOfTypePanel.add(filterComboBox); // buttons getButtonPanel().setLayout(new ButtonAreaLayout()); approveButton = new JButton(getApproveButtonText(fc)); // Note: Metal does not use mnemonics for approve and cancel approveButton.addActionListener(getApproveSelectionAction()); fileNameTextField.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { getApproveSelectionAction().actionPerformed(null); } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { getFileChooser().cancelSelection(); } } }); approveButton.setToolTipText(getApproveButtonToolTipText(fc)); getButtonPanel().add(approveButton); cancelButton = new JButton(cancelButtonText); cancelButton.setToolTipText(cancelButtonToolTipText); cancelButton.addActionListener(getCancelSelectionAction()); getButtonPanel().add(cancelButton); if (fc.getControlButtonsAreShown()) { addControlButtons(); } groupLabels(new AlignedLabel[] { fileNameLabel, filesOfTypeLabel }); }
From source file:org.openmicroscopy.shoola.agents.fsimporter.view.ImporterUIElement.java
/** Initializes the components. */ private void initialize() { filterButton = new JButton(SHOW_FAILURE); filterButton.setEnabled(false);/*from ww w .j a v a 2s . co m*/ filterButton.addActionListener(new ActionListener() { /** * Filters or not the import that did not fail. */ public void actionPerformed(ActionEvent evt) { filterFailures(); } }); sizeImport = 0; busyLabel = new JXBusyLabel(ICON_SIZE); numberOfImportLabel = UIUtilities.createComponent(null); foldersName = new LinkedHashMap<JLabel, Object>(); countUploadFailure = 0; countFailure = 0; countUploaded = 0; addPropertyChangeListener(controller); entries = new JPanel(); entries.setBackground(UIUtilities.BACKGROUND); components = new LinkedHashMap<String, FileImportComponent>(); List<ImportableFile> files = object.getFiles(); FileImportComponent c; File f; Iterator<ImportableFile> i = files.iterator(); ImportableFile importable; type = -1; List<Object> containers = object.getRefNodes(); if (containers != null && containers.size() > 0) { Iterator<Object> j = containers.iterator(); TreeImageDisplay node; Object h; while (j.hasNext()) { node = (TreeImageDisplay) j.next(); h = node.getUserObject(); if (h instanceof DatasetData) { type = FileImportComponent.DATASET_TYPE; } else if (h instanceof ScreenData) { type = FileImportComponent.SCREEN_TYPE; } else if (h instanceof ProjectData) { type = FileImportComponent.PROJECT_TYPE; } break; } } else { type = FileImportComponent.NO_CONTAINER; } JLabel l; boolean single = model.isSingleGroup(); while (i.hasNext()) { importable = i.next(); f = (File) importable.getFile(); c = new FileImportComponent(importable, !controller.isMaster(), single, getID(), object.getTags()); c.setType(type); c.addPropertyChangeListener(controller); c.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (FileImportComponent.BROWSE_PROPERTY.equals(name)) { List<Object> refNodes = object.getRefNodes(); Object node = null; if (refNodes != null && refNodes.size() > 0) node = refNodes.get(0); browse(evt.getNewValue(), node); } else if (FileImportComponent.IMPORT_FILES_NUMBER_PROPERTY.equals(name)) { //-1 to remove the entry for the folder. Integer v = (Integer) evt.getNewValue() - 1; totalToImport += v; setNumberOfImport(); } else if (FileImportComponent.LOAD_LOGFILEPROPERTY.equals(name)) { FileImportComponent fc = (FileImportComponent) evt.getNewValue(); if (fc == null) return; long logFileID = fc.getStatus().getLogFileID(); if (logFileID <= 0) { FilesetData data = fc.getStatus().getFileset(); if (data == null) return; model.fireImportLogFileLoading(data.getId(), fc.getIndex()); } else downloadLogFile(logFileID); } else if (FileImportComponent.RETRIEVE_LOGFILEPROPERTY.equals(name)) { FilesetData data = (FilesetData) evt.getNewValue(); if (data != null) model.fireImportLogFileLoading(data.getId(), id); } else if (FileImportComponent.CHECKSUM_DISPLAY_PROPERTY.equals(name)) { StatusLabel label = (StatusLabel) evt.getNewValue(); CheckSumDialog d = new CheckSumDialog(view, label); UIUtilities.centerAndShow(d); } else if (FileImportComponent.RETRY_PROPERTY.equals(name)) { controller.retryUpload((FileImportComponent) evt.getNewValue()); } else if (FileImportComponent.CANCEL_IMPORT_PROPERTY.equals(name)) { controller.cancel((FileImportComponent) evt.getNewValue()); } } }); if (f.isDirectory()) { if (importable.isFolderAsContainer()) { l = new JLabel(f.getName()); foldersName.put(l, c); } } else { if (importable.isFolderAsContainer()) { String name = f.getParentFile().getName(); //first check if the name is already there. Entry<JLabel, Object> entry; Iterator<Entry<JLabel, Object>> k = foldersName.entrySet().iterator(); boolean exist = false; while (k.hasNext()) { entry = k.next(); l = entry.getKey(); if (l.getText().equals(name)) { exist = true; break; } } if (!exist) { foldersName.put(new JLabel(name), c); } } } importable.setStatus(c.getStatus()); components.put(c.toString(), c); } totalToImport = files.size(); }
From source file:org.esa.beam.visat.toolviews.stat.ProfilePlotPanel.java
protected JPanel createMiddlePanel(BindingContext bindingContext) { final JLabel boxSizeLabel = new JLabel("Box size: "); final JSpinner boxSizeSpinner = new JSpinner(); final JCheckBox computeInBetweenPoints = new JCheckBox("Compute in-between points"); final JCheckBox useCorrelativeData = new JCheckBox("Use correlative data"); correlativeFieldSelector = new CorrelativeFieldSelector(bindingContext); final PropertyDescriptor boxSizeDescriptor = bindingContext.getPropertySet().getProperty("boxSize") .getDescriptor();//from www . java 2 s .c o m boxSizeDescriptor.setValueRange(new ValueRange(1, 101)); boxSizeDescriptor.setAttribute("stepSize", 2); boxSizeDescriptor.setValidator(new Validator() { @Override public void validateValue(Property property, Object value) throws ValidationException { if (((Number) value).intValue() % 2 == 0) { throw new ValidationException("Only odd values allowed as box size."); } } }); bindingContext.bind("boxSize", boxSizeSpinner); bindingContext.bind("computeInBetweenPoints", computeInBetweenPoints); bindingContext.bind("useCorrelativeData", useCorrelativeData); EnablePointDataCondition condition = new EnablePointDataCondition(); pointDataSourceEnablement = bindingContext.bindEnabledState("pointDataSource", true, condition); dataFieldEnablement = bindingContext.bindEnabledState("dataField", true, condition); bindingContext.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { updateDataSource(); updateDataSet(); updateUIState(); } }); JPanel dataSourceOptionsPanel = GridBagUtils.createPanel(); GridBagConstraints dataSourceOptionsConstraints = GridBagUtils .createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2"); GridBagUtils.addToPanel(dataSourceOptionsPanel, boxSizeLabel, dataSourceOptionsConstraints, "gridwidth=1,gridy=0,gridx=0,weightx=0,insets.left=4"); GridBagUtils.addToPanel(dataSourceOptionsPanel, boxSizeSpinner, dataSourceOptionsConstraints, "gridwidth=1,gridy=0,gridx=1,weightx=1,insets.left=0"); GridBagUtils.addToPanel(dataSourceOptionsPanel, computeInBetweenPoints, dataSourceOptionsConstraints, "gridwidth=2,gridy=1,gridx=0,weightx=2"); GridBagUtils.addToPanel(dataSourceOptionsPanel, useCorrelativeData, dataSourceOptionsConstraints, "gridy=2,insets.top=16"); GridBagUtils.addToPanel(dataSourceOptionsPanel, correlativeFieldSelector.pointDataSourceLabel, dataSourceOptionsConstraints, "gridy=3,insets.top=0,insets.left=4"); GridBagUtils.addToPanel(dataSourceOptionsPanel, correlativeFieldSelector.pointDataSourceList, dataSourceOptionsConstraints, "gridy=4,insets.left=4"); GridBagUtils.addToPanel(dataSourceOptionsPanel, correlativeFieldSelector.dataFieldLabel, dataSourceOptionsConstraints, "gridy=5,insets.left=4"); GridBagUtils.addToPanel(dataSourceOptionsPanel, correlativeFieldSelector.dataFieldList, dataSourceOptionsConstraints, "gridy=6,insets.left=4"); xAxisRangeControl.getBindingContext().bind(PROPERTY_NAME_MARK_SEGMENTS, new JCheckBox("Mark segments")); yAxisRangeControl.getBindingContext().bind(PROPERTY_NAME_LOG_SCALED, new JCheckBox("Log10 scaled")); JPanel displayOptionsPanel = GridBagUtils.createPanel(); GridBagConstraints displayOptionsConstraints = GridBagUtils .createConstraints("anchor=SOUTH,fill=HORIZONTAL,weightx=1"); GridBagUtils.addToPanel(displayOptionsPanel, xAxisRangeControl.getPanel(), displayOptionsConstraints, "gridy=0"); GridBagUtils.addToPanel(displayOptionsPanel, xAxisRangeControl.getBindingContext().getBinding(PROPERTY_NAME_MARK_SEGMENTS).getComponents()[0], displayOptionsConstraints, "gridy=1"); GridBagUtils.addToPanel(displayOptionsPanel, yAxisRangeControl.getPanel(), displayOptionsConstraints, "gridy=2"); GridBagUtils.addToPanel(displayOptionsPanel, yAxisRangeControl.getBindingContext().getBinding(PROPERTY_NAME_LOG_SCALED).getComponents()[0], displayOptionsConstraints, "gridy=3"); JPanel middlePanel = GridBagUtils.createPanel(); GridBagConstraints middlePanelConstraints = GridBagUtils .createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2,weightx=1"); GridBagUtils.addToPanel(middlePanel, dataSourceOptionsPanel, middlePanelConstraints, "gridy=0"); GridBagUtils.addToPanel(middlePanel, new JPanel(), middlePanelConstraints, "gridy=1,fill=VERTICAL,weighty=1"); GridBagUtils.addToPanel(middlePanel, displayOptionsPanel, middlePanelConstraints, "gridy=2,fill=HORIZONTAL,weighty=0"); return middlePanel; }
From source file:org.talend.designer.runprocess.ui.views.ProcessView.java
@Override public void createPartControl(Composite parent) { this.parent = parent; parent.setLayout(new FillLayout()); sash = new SashForm(parent, SWT.HORIZONTAL | SWT.SMOOTH); sash.setLayoutData(new GridData(GridData.FILL_BOTH)); sash.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE)); GridLayout layout = new GridLayout(); sash.setLayout(layout);/*from w ww. ja v a 2 s . co m*/ Composite left = new Composite(sash, SWT.NONE); left.setLayout(new FillLayout()); Composite right = new Composite(sash, SWT.NONE); right.setLayout(new FormLayout()); FormData layouDatag = new FormData(); layouDatag.left = new FormAttachment(0, 0); layouDatag.width = 32; layouDatag.top = new FormAttachment(0, 0); layouDatag.bottom = new FormAttachment(100, 0); final Composite buttonComposite = new Composite(right, SWT.ERROR); buttonComposite.setLayoutData(layouDatag); buttonComposite.setLayout(new GridLayout()); Composite cotextCom = new Composite(right, SWT.NONE); layouDatag = new FormData(); layouDatag.left = new FormAttachment(0, 32); layouDatag.right = new FormAttachment(100, 0); layouDatag.top = new FormAttachment(0, 0); layouDatag.bottom = new FormAttachment(100, 0); cotextCom.setLayoutData(layouDatag); cotextCom.setLayout(new GridLayout()); tabFactory.initComposite(left, false); moveButton = new Button(buttonComposite, SWT.PUSH); moveButton.setText(">>"); //$NON-NLS-1$ moveButton.setToolTipText(Messages.getString("ProcessComposite.hideContext")); final GridData layoutData = new GridData(); layoutData.verticalAlignment = GridData.CENTER; layoutData.horizontalAlignment = GridData.CENTER; layoutData.grabExcessHorizontalSpace = true; layoutData.grabExcessVerticalSpace = true; moveButton.setLayoutData(layoutData); addListeners(); sash.setSashWidth(5); sash.setWeights(new int[] { 18, 5 }); contextComposite = new ProcessContextComposite(cotextCom, SWT.NONE); contextComposite.setBackground(right.getDisplay().getSystemColor(SWT.COLOR_WHITE)); // processComposite = new ProcessComposite(tabFactory.getTabComposite(), SWT.H_SCROLL | SWT.V_SCROLL | // SWT.NO_FOCUS); // dc = processComposite; // createBasicComposite(tabFactory.getTabComposite(), element, null); tabFactory.getTabComposite().layout(); tabFactory.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); TalendPropertyTabDescriptor descriptor = (TalendPropertyTabDescriptor) selection.getFirstElement(); if (descriptor == null) { return; } if (currentSelectedTab != null && (currentSelectedTab.getCategory() != descriptor.getCategory())) { for (Control curControl : tabFactory.getTabComposite().getChildren()) { curControl.dispose(); } } if (currentSelectedTab == null || currentSelectedTab.getCategory() != descriptor.getCategory() || selectedPrimary) { currentSelectedTab = descriptor; selectedPrimary = false; createDynamicComposite(tabFactory.getTabComposite(), (Element) descriptor.getData(), descriptor.getCategory()); } } }); setElement(); IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class); IHandler handler1; IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault() .getService(IBrandingService.class); if (brandingService.getBrandingConfiguration().isAllowDebugMode()) { Action debugAction = new DebugAction(); handler1 = new ActionHandler(debugAction); handlerService.activateHandler(debugAction.getActionDefinitionId(), handler1); } Action killAction = new KillAction(); handler1 = new ActionHandler(killAction); handlerService.activateHandler(killAction.getActionDefinitionId(), handler1); FocusListener fl = new FocusListener() { @Override public void focusGained(FocusEvent e) { log.trace(Messages.getString("ProcessView.gainFocusLog")); //$NON-NLS-1$ IContextService contextService = (IContextService) RunProcessPlugin.getDefault().getWorkbench() .getAdapter(IContextService.class); ca = contextService.activateContext("talend.runProcess"); //$NON-NLS-1$ } @Override public void focusLost(FocusEvent e) { log.trace(Messages.getString("ProcessView.lostFocusLog")); //$NON-NLS-1$ if (ca != null) { IContextService contextService = (IContextService) RunProcessPlugin.getDefault().getWorkbench() .getAdapter(IContextService.class); contextService.deactivateContext(ca); } } }; addListenerOnChildren(parent, fl); rubjobManager.setProcessShell(getSite().getShell()); contextManagerListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (RunProcessContextManager.PROP_ACTIVE.equals(evt.getPropertyName())) { // rubjobManager.setBooleanTrace(false); runningProcessChanged(); } } }; RunProcessPlugin.getDefault().getRunProcessContextManager() .addPropertyChangeListener(contextManagerListener); runAction = new RunAction(); }
From source file:org.polymap.core.data.ui.featureselection.FeatureSelectionView.java
public void createPartControl(@SuppressWarnings("hiding") Composite parent) { if (initLayer.get() != null) { init(initLayer.get());//from w w w. j a va2 s . c o m } else { if (layer == null) { log.warn("No layer set. Closing view..."); Label msg = new Label(parent, SWT.NONE); msg.setText("No layer."); close(null); } else { init(layer); } } this.parent = parent; this.parent.setLayout(new FormLayout()); // check fs -> error message if (fs == null) { Label msg = new Label(parent, SWT.NONE); msg.setText("No feature pipeline for layer: " + (layer != null ? layer.getLabel() : "???")); return; } viewer = new FeatureTableViewer(parent, SWT.MULTI); viewer.getTable().setLayoutData(new SimpleFormData().fill().create()); viewer.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent ev) { if (ev.getPropertyName().equals(FeatureTableViewer.PROP_CONTENT_SIZE)) { Integer count = (Integer) ev.getNewValue(); setPartName(basePartName + " (" + count + ")"); } } }); viewer.addSelectionChangedListener(this); // double-click viewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent ev) { log.info("doubleClick(): " + ev); //IAction openHandler = getViewSite().getActionBars().getGlobalActionHandler( "org.polymap.rhei.OpenFormAction" ); if (openAction != null) { openAction.run(null); } } }); // columns assert fs != null : "fs not set. Call init() first."; SimpleFeatureType schema = fs.getSchema(); for (PropertyDescriptor prop : schema.getDescriptors()) { if (Geometry.class.isAssignableFrom(prop.getType().getBinding())) { // skip Geometry } else { viewer.addColumn(new DefaultFeatureTableColumn(prop)); } } viewer.getTable().pack(true); getSite().setSelectionProvider(viewer); hookContextMenu(); loadTable(filter); }
From source file:org.openmicroscopy.shoola.agents.treeviewer.view.TreeViewerComponent.java
/** * Moves the object./* w w w .j av a 2s. c o m*/ * * @param object The object to move. */ private void moveObject(ChgrpObject object) { GroupData group = object.getGroupData(); SecurityContext ctx = new SecurityContext(group.getId()); long userID = object.getUserID(); if (userID >= 0) { ExperimenterData exp = model.getExperimenter(); if (userID == exp.getId()) { Class<?> type = object.getDataType(); if (ImageData.class.equals(type) || DatasetData.class.equals(type)) type = ProjectData.class; else if (ProjectData.class.equals(type)) type = null; else if (PlateData.class.equals(type)) type = ScreenData.class; else if (ScreenData.class.equals(type)) type = null; else if (GroupData.class.equals(type) || ExperimenterData.class.equals(type)) type = null; if (type != null) { MoveGroupSelectionDialog dialog = new MoveGroupSelectionDialog(view, userID, object, true); dialog.addPropertyChangeListener(new PropertyChangeListener() { /** * Transfers the data. */ public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (MoveGroupSelectionDialog.TRANSFER_PROPERTY.equals(name)) { ChgrpObject v = (ChgrpObject) evt.getNewValue(); GroupData group = v.getGroupData(); SecurityContext ctx = new SecurityContext(group.getId()); moveData(ctx, v.getTarget(), v.getTransferable()); } } }); model.fireMoveDataLoading(ctx, dialog, type, userID); UIUtilities.centerAndShow(dialog); } } else moveData(ctx, object.getTarget(), object.getTransferable()); } else { moveData(ctx, object.getTarget(), object.getTransferable()); } }