List of usage examples for java.beans PropertyChangeEvent getSource
public Object getSource()
From source file:org.photovault.swingui.PhotoInfoEditor.java
/** PropertyChange method is called when a FormattedTextField is modified @param ev The event/*from w w w . j a v a2 s . c o m*/ */ public void propertyChange(PropertyChangeEvent ev) { if (ev.getPropertyName().equals("value")) { Object src = ev.getSource(); if (src.getClass() == JFormattedTextField.class) { PhotoInfoFields field = (PhotoInfoFields) ((JFormattedTextField) src).getClientProperty(FIELD); Object value = ((JFormattedTextField) src).getValue(); StringBuffer debugMsg = new StringBuffer(); debugMsg.append("valueChange ").append(field).append(": ").append(value); /* Field value is set to null (as it is when ctrl is controlling multiple photos which have differing value for te field) this is called every time the field is accessed, so we must not notify the controller. After the user has actually set the value it is no longer null. */ if (value != null) { log.debug("Property changed: " + field); ctrl.viewChanged(this, field, value); } } } }
From source file:org.tinymediamanager.ui.movies.MoviePanel.java
/** * further initializations.//from w w w.jav a 2 s. c o m */ private void init() { // build menu buildMenu(); // moviename column table.getColumnModel().getColumn(0).setCellRenderer(new BorderCellRenderer()); table.getColumnModel().getColumn(0).setIdentifier("title"); //$NON-NLS-1$ // year column int width = table.getFontMetrics(table.getFont()).stringWidth(" 2000"); int titleWidth = table.getFontMetrics(table.getFont()).stringWidth(BUNDLE.getString("metatag.year")); //$NON-NLS-1$ if (titleWidth > width) { width = titleWidth; } table.getTableHeader().getColumnModel().getColumn(1).setPreferredWidth(width); table.getTableHeader().getColumnModel().getColumn(1).setMinWidth(width); table.getTableHeader().getColumnModel().getColumn(1).setMaxWidth((int) (width * 1.5)); table.getTableHeader().getColumnModel().getColumn(1).setIdentifier("year"); //$NON-NLS-1$ // rating column width = table.getFontMetrics(table.getFont()).stringWidth(" 10.0"); titleWidth = table.getFontMetrics(table.getFont()).stringWidth(BUNDLE.getString("metatag.rating")); //$NON-NLS-1$ if (titleWidth > width) { width = titleWidth; } table.getTableHeader().getColumnModel().getColumn(2).setPreferredWidth((int) (width * 1.2)); table.getTableHeader().getColumnModel().getColumn(2).setMinWidth((int) (width * 1.2)); table.getTableHeader().getColumnModel().getColumn(2).setMaxWidth((int) (width * 1.5)); table.getTableHeader().getColumnModel().getColumn(2).setIdentifier("rating"); //$NON-NLS-1$ // date added column width = table.getFontMetrics(table.getFont()).stringWidth("01. Jan. 2000"); titleWidth = table.getFontMetrics(table.getFont()).stringWidth(BUNDLE.getString("metatag.dateadded")); //$NON-NLS-1$ if (titleWidth > width) { width = titleWidth; } table.getTableHeader().getColumnModel().getColumn(3).setPreferredWidth((int) (width * 1.2)); table.getTableHeader().getColumnModel().getColumn(3).setMinWidth((int) (width * 1.2)); table.getTableHeader().getColumnModel().getColumn(3).setMaxWidth((int) (width * 1.2)); table.getTableHeader().getColumnModel().getColumn(3).setIdentifier("dateadded"); //$NON-NLS-1$ // NFO column table.getTableHeader().getColumnModel().getColumn(4) .setHeaderRenderer(new IconRenderer(BUNDLE.getString("tmm.nfo"))); //$NON-NLS-1$ table.getTableHeader().getColumnModel().getColumn(4).setMaxWidth(20); table.getColumnModel().getColumn(4).setHeaderValue(IconManager.INFO); table.getTableHeader().getColumnModel().getColumn(4).setIdentifier("nfo"); //$NON-NLS-1$ // Meta data column table.getTableHeader().getColumnModel().getColumn(5) .setHeaderRenderer(new IconRenderer(BUNDLE.getString("tmm.metadata"))); //$NON-NLS-1$ table.getTableHeader().getColumnModel().getColumn(5).setMaxWidth(20); table.getColumnModel().getColumn(5).setHeaderValue(IconManager.SEARCH); table.getTableHeader().getColumnModel().getColumn(5).setIdentifier("metadata"); //$NON-NLS-1$ // Images column table.getTableHeader().getColumnModel().getColumn(6) .setHeaderRenderer(new IconRenderer(BUNDLE.getString("tmm.images"))); //$NON-NLS-1$ table.getTableHeader().getColumnModel().getColumn(6).setMaxWidth(20); table.getColumnModel().getColumn(6).setHeaderValue(IconManager.IMAGE); table.getTableHeader().getColumnModel().getColumn(6).setIdentifier("images"); //$NON-NLS-1$ // trailer column table.getTableHeader().getColumnModel().getColumn(7) .setHeaderRenderer(new IconRenderer(BUNDLE.getString("tmm.trailer"))); //$NON-NLS-1$ table.getTableHeader().getColumnModel().getColumn(7).setMaxWidth(20); table.getColumnModel().getColumn(7).setHeaderValue(IconManager.CLAPBOARD); table.getTableHeader().getColumnModel().getColumn(7).setIdentifier("trailer"); //$NON-NLS-1$ // subtitles column table.getTableHeader().getColumnModel().getColumn(8) .setHeaderRenderer(new IconRenderer(BUNDLE.getString("tmm.subtitles"))); //$NON-NLS-1$ table.getTableHeader().getColumnModel().getColumn(8).setMaxWidth(20); table.getColumnModel().getColumn(8).setHeaderValue(IconManager.SUBTITLE); table.getTableHeader().getColumnModel().getColumn(8).setIdentifier("subtitle"); //$NON-NLS-1$ // watched column table.getTableHeader().getColumnModel().getColumn(9) .setHeaderRenderer(new IconRenderer(BUNDLE.getString("metatag.watched"))); //$NON-NLS-1$ table.getTableHeader().getColumnModel().getColumn(9).setMaxWidth(20); table.getColumnModel().getColumn(9).setHeaderValue(IconManager.PLAY_SMALL); table.getTableHeader().getColumnModel().getColumn(9).setIdentifier("watched"); //$NON-NLS-1$ table.setSelectionModel(movieSelectionModel.getSelectionModel()); // selecting first movie at startup if (movieList.getMovies() != null && movieList.getMovies().size() > 0) { ListSelectionModel selectionModel = table.getSelectionModel(); if (selectionModel.isSelectionEmpty()) { selectionModel.setSelectionInterval(0, 0); } } // hide columns if needed if (!MovieModuleManager.MOVIE_SETTINGS.isYearColumnVisible()) { table.hideColumn("year"); //$NON-NLS-1$ } if (!MovieModuleManager.MOVIE_SETTINGS.isRatingColumnVisible()) { table.hideColumn("rating"); //$NON-NLS-1$ } if (!MovieModuleManager.MOVIE_SETTINGS.isDateAddedColumnVisible()) { table.hideColumn("dateadded"); //$NON-NLS-1$ } if (!MovieModuleManager.MOVIE_SETTINGS.isNfoColumnVisible()) { table.hideColumn("nfo"); //$NON-NLS-1$ } if (!MovieModuleManager.MOVIE_SETTINGS.isMetadataColumnVisible()) { table.hideColumn("metadata"); //$NON-NLS-1$ } if (!MovieModuleManager.MOVIE_SETTINGS.isImageColumnVisible()) { table.hideColumn("images"); //$NON-NLS-1$ } if (!MovieModuleManager.MOVIE_SETTINGS.isTrailerColumnVisible()) { table.hideColumn("trailer"); //$NON-NLS-1$ } if (!MovieModuleManager.MOVIE_SETTINGS.isSubtitleColumnVisible()) { table.hideColumn("subtitle"); //$NON-NLS-1$ } if (!MovieModuleManager.MOVIE_SETTINGS.isWatchedColumnVisible()) { table.hideColumn("watched"); //$NON-NLS-1$ } // and add a propertychangelistener to the columnhider PropertyChangeListener settingsPropertyChangeListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getSource() instanceof MovieSettings) { if ("yearColumnVisible".equals(evt.getPropertyName())) { setColumnVisibility("year", (Boolean) evt.getNewValue()); //$NON-NLS-1$ } if ("ratingColumnVisible".equals(evt.getPropertyName())) { setColumnVisibility("rating", (Boolean) evt.getNewValue()); //$NON-NLS-1$ } if ("nfoColumnVisible".equals(evt.getPropertyName())) { setColumnVisibility("nfo", (Boolean) evt.getNewValue()); } if ("metadataColumnVisible".equals(evt.getPropertyName())) { setColumnVisibility("metadata", (Boolean) evt.getNewValue()); } if ("dateAddedColumnVisible".equals(evt.getPropertyName())) { setColumnVisibility("dateadded", (Boolean) evt.getNewValue()); } if ("imageColumnVisible".equals(evt.getPropertyName())) { setColumnVisibility("images", (Boolean) evt.getNewValue()); //$NON-NLS-1$ } if ("trailerColumnVisible".equals(evt.getPropertyName())) { setColumnVisibility("trailer", (Boolean) evt.getNewValue()); //$NON-NLS-1$ } if ("subtitleColumnVisible".equals(evt.getPropertyName())) { setColumnVisibility("subtitle", (Boolean) evt.getNewValue()); //$NON-NLS-1$ } if ("watchedColumnVisible".equals(evt.getPropertyName())) { setColumnVisibility("watched", (Boolean) evt.getNewValue()); //$NON-NLS-1$ } } } private void setColumnVisibility(Object identifier, Boolean visible) { if (visible) { table.showColumn(identifier); } else { table.hideColumn(identifier); } } }; MovieModuleManager.MOVIE_SETTINGS.addPropertyChangeListener(settingsPropertyChangeListener); // initialize filteredCount lblMovieCountFiltered.setText(String.valueOf(movieTableModel.getRowCount())); addKeyListener(); }
From source file:ome.formats.importer.gui.FileQueueHandler.java
/** * Retrieve the file chooser's selected reader then iterate over * each of our supplied containers filtering out those whose format * do not match those of the selected reader. * //from w w w .j av a2 s . c o m * @param allContainers List of ImporterContainers */ private void handleFiles(List<ImportContainer> allContainers) { FileFilter selectedFilter = fileChooser.getFileFilter(); IFormatReader selectedReader = null; if (selectedFilter instanceof FormatFileFilter) { log.debug("Selected file filter: " + selectedFilter); selectedReader = ((FormatFileFilter) selectedFilter).getReader(); } List<ImportContainer> containers = new ArrayList<ImportContainer>(); for (ImportContainer ic : allContainers) { if (selectedReader == null) { // The user selected "All supported file types" containers = allContainers; break; } String a = selectedReader.getFormat(); String b = ic.getReader(); if (a.equals(b) || b == null) { containers.add(ic); } else { log.debug(String.format("Skipping %s (%s != %s)", ic.getFile().getAbsoluteFile(), a, b)); } } Boolean spw = spwOrNull(containers); if (containers.size() == 0 && !candidatesFormatException) { final JOptionPane optionPane = new JOptionPane("\nNo importable files found in this selection.", JOptionPane.WARNING_MESSAGE); final JDialog errorDialog = new JDialog(viewer, "No Importable Files Found", true); errorDialog.setContentPane(optionPane); optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (errorDialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) { errorDialog.dispose(); } } }); errorDialog.toFront(); errorDialog.pack(); errorDialog.setLocationRelativeTo(viewer); errorDialog.setVisible(true); } if (candidatesFormatException) { viewer.candidateErrorsCollected(viewer); candidatesFormatException = false; } if (spw == null) { addEnabled(true); containers.clear(); return; // Invalid containers. } if (getOMEROMetadataStoreClient() != null && spw.booleanValue()) { addEnabled(true); SPWDialog dialog = new SPWDialog(config, viewer, "Screen Import", true, getOMEROMetadataStoreClient()); if (dialog.cancelled == true || dialog.screen == null) return; for (ImportContainer ic : containers) { ic.setTarget(dialog.screen); String title = dialog.screen.getName().getValue(); addFileToQueue(ic, title, false, 0); } qTable.centerOnRow(qTable.getQueue().getRowCount() - 1); qTable.importBtn.requestFocus(); } else if (getOMEROMetadataStoreClient() != null) { addEnabled(true); ImportDialog dialog = new ImportDialog(config, viewer, "Image Import", true, getOMEROMetadataStoreClient()); if (dialog.cancelled == true || dialog.dataset == null) return; Double[] pixelSizes = new Double[] { dialog.pixelSizeX, dialog.pixelSizeY, dialog.pixelSizeZ }; Boolean useFullPath = config.useFullPath.get(); if (dialog.useCustomNamingChkBox.isSelected() == false) useFullPath = null; //use the default bio-formats naming for (ImportContainer ic : containers) { ic.setTarget(dialog.dataset); ic.setUserPixels(pixelSizes); ic.setArchive(dialog.archiveImage.isSelected()); String title = ""; if (dialog.project.getId() != null) { ic.setProjectID(dialog.project.getId().getValue()); title = dialog.project.getName().getValue() + " / " + dialog.dataset.getName().getValue(); } else { title = "none / " + dialog.dataset.getName().getValue(); } addFileToQueue(ic, title, useFullPath, config.numOfDirectories.get()); } qTable.centerOnRow(qTable.getQueue().getRowCount() - 1); qTable.importBtn.requestFocus(); } else { addEnabled(true); JOptionPane.showMessageDialog(viewer, "Due to an error the application is unable to \n" + "retrieve an OMEROMetadataStore and cannot continue." + "The most likely cause for this error is that you" + "are not logged in. Please try to login again."); } }
From source file:org.datavyu.controllers.component.TrackController.java
@Override public void propertyChange(final PropertyChangeEvent evt) { if (evt.getSource() == mixerModel.getViewportModel()) { view.repaint();// w w w.j a va2 s .co m } }
From source file:org.datavyu.controllers.component.MixerController.java
@Override public void propertyChange(final PropertyChangeEvent evt) { if (evt.getSource() == mixerModel.getViewportModel()) { final ViewportState oldViewport = (evt.getOldValue() instanceof ViewportState) ? (ViewportState) evt.getOldValue() : null;//from www . j ava 2 s . c om final ViewportState newViewport = (evt.getNewValue() instanceof ViewportState) ? (ViewportState) evt.getNewValue() : null; handleViewportChanged(oldViewport, newViewport); } }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.EditorControl.java
/** Brings up the folder chooser. */ private void download() { JFrame f = MetadataViewerAgent.getRegistry().getTaskBar().getFrame(); List<DataObject> list = view.getSelectedObjects(); ImageData image = view.getImage();//from www. jav a 2 s . c o m int type = FileChooser.SAVE; List<String> paths = new ArrayList<String>(); if (list != null && list.size() > 1) { type = FileChooser.FOLDER_CHOOSER; Iterator<DataObject> i = list.iterator(); DataObject data; while (i.hasNext()) { data = i.next(); if (data instanceof ImageData) { paths.add(FilenameUtils.getName(((ImageData) data).getName())); } } } FileChooser chooser = new FileChooser(f, type, FileChooser.DOWNLOAD_TEXT, FileChooser.DOWNLOAD_DESCRIPTION, null, true); try { File file = UIUtilities.getDefaultFolder(); if (file != null) chooser.setCurrentDirectory(file); } catch (Exception ex) { } if (type == FileChooser.SAVE) chooser.setSelectedFileFull(image.getName()); IconManager icons = IconManager.getInstance(); chooser.setTitleIcon(icons.getIcon(IconManager.DOWNLOAD_48)); chooser.setApproveButtonText(FileChooser.DOWNLOAD_TEXT); chooser.setCheckOverride(true); chooser.setSelectedFiles(paths); chooser.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); FileChooser src = (FileChooser) evt.getSource(); if (FileChooser.APPROVE_SELECTION_PROPERTY.equals(name)) { File path = null; if (src.getChooserType() == FileChooser.FOLDER_CHOOSER) { path = new File((String) evt.getNewValue()); } else { File[] files = (File[]) evt.getNewValue(); if (files == null || files.length == 0) return; path = files[0]; } if (path == null) { path = UIUtilities.getDefaultFolder(); } model.download(path, src.isOverride()); } } }); chooser.centerDialog(); }
From source file:org.apache.catalina.core.NamingContextListener.java
/** * Process property change events. Currently, only listens to such events * on the <code>NamingResources</code> instance for the global naming * resources./*from ww w. j av a2s .c o m*/ * * @param event The property change event that has occurred */ public void propertyChange(PropertyChangeEvent event) { if (!initialized) return; Object source = event.getSource(); if (source == namingResources) { // Setting the context in read/write mode ContextAccessController.setWritable(getName(), container); processGlobalResourcesChange(event.getPropertyName(), event.getOldValue(), event.getNewValue()); // Setting the context in read only mode ContextAccessController.setReadOnly(getName()); } }
From source file:org.openconcerto.erp.core.sales.shipment.component.BonDeLivraisonSQLComponent.java
public void addViews() { this.textTotalHT.setOpaque(false); this.textTotalTVA.setOpaque(false); this.textTotalTTC.setOpaque(false); this.selectCommande = new ElementComboBox(); this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); // Champ Module c.gridx = 0;//from w w w. j av a 2 s . c o m 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; // 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(textNumeroUnique); this.add(this.textNumeroUnique, c); // Date c.gridx++; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; this.add(new JLabel(getLabelFor("DATE"), SwingConstants.RIGHT), c); JDate date = new JDate(true); c.gridx++; c.weightx = 0; c.weighty = 0; c.fill = GridBagConstraints.NONE; this.add(date, c); // Reference c.gridy++; c.gridx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel(getLabelFor("NOM"), SwingConstants.RIGHT), c); c.gridx++; c.weightx = 1; this.add(this.textNom, c); if (getTable().contains("DATE_LIVRAISON")) { // Date livraison c.gridx++; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; this.add(new JLabel(getLabelFor("DATE_LIVRAISON"), SwingConstants.RIGHT), c); JDate dateLivraison = new JDate(true); c.gridx++; c.weightx = 0; c.weighty = 0; c.fill = GridBagConstraints.NONE; this.add(dateLivraison, c); this.addView(dateLivraison, "DATE_LIVRAISON"); } // Client JLabel labelClient = new JLabel(getLabelFor("ID_CLIENT"), SwingConstants.RIGHT); c.gridx = 0; c.gridy++; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; c.weighty = 0; this.add(labelClient, c); c.gridx++; c.weightx = 0; c.weighty = 0; c.fill = GridBagConstraints.NONE; this.comboClient = new ElementComboBox(); this.add(this.comboClient, c); if (getTable().contains("SPEC_LIVRAISON")) { // Date livraison c.gridx++; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; this.add(new JLabel(getLabelFor("SPEC_LIVRAISON"), SwingConstants.RIGHT), c); JTextField specLivraison = new JTextField(); c.gridx++; c.weightx = 0; c.weighty = 0; this.add(specLivraison, c); this.addView(specLivraison, "SPEC_LIVRAISON"); } final ElementComboBox boxTarif = new ElementComboBox(); this.comboClient.addValueListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (comboClient.getElement().getTable().contains("ID_TARIF")) { if (BonDeLivraisonSQLComponent.this.isFilling()) return; final SQLRow row = ((SQLRequestComboBox) evt.getSource()).getSelectedRow(); if (row != null) { // SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF"); // if (foreignRow.isUndefined() && // !row.getForeignRow("ID_DEVISE").isUndefined()) { // SQLRowValues rowValsD = new SQLRowValues(foreignRow.getTable()); // rowValsD.put("ID_DEVISE", row.getObject("ID_DEVISE")); // foreignRow = rowValsD; // // } // tableBonItem.setTarif(foreignRow, true); SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF"); if (!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.getID()); } } } } }); // Bouton tout livrer JButton boutonAll = new JButton("Tout livrer"); boutonAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { RowValuesTableModel m = BonDeLivraisonSQLComponent.this.tableBonItem.getModel(); // on livre tout les lments for (int i = 0; i < m.getRowCount(); i++) { SQLRowValues rowVals = m.getRowValuesAt(i); Object o = rowVals.getObject("QTE"); int qte = o == null ? 0 : ((Number) o).intValue(); m.putValue(qte, i, "QTE_LIVREE"); } } }); // Tarif if (this.getTable().getFieldsName().contains("ID_TARIF")) { // TARIF c.gridy++; c.gridx = 0; c.weightx = 0; c.weighty = 0; c.gridwidth = 1; this.add(new JLabel("Tarif appliquer"), c); c.gridx++; c.gridwidth = 1; c.weightx = 1; 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()); tableBonItem.setTarif(selectedRow, !isFilling()); } }); } if (getTable().contains("A_ATTENTION")) { // Date livraison c.gridx++; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; this.add(new JLabel(getLabelFor("A_ATTENTION"), SwingConstants.RIGHT), c); JTextField specLivraison = new JTextField(); c.gridx++; c.weightx = 0; c.weighty = 0; this.add(specLivraison, c); this.addView(specLivraison, "A_ATTENTION"); } // Element du bon List<JButton> l = new ArrayList<JButton>(); l.add(boutonAll); this.tableBonItem = new BonDeLivraisonItemTable(l); c.gridx = 0; c.gridy++; c.weightx = 1; c.weighty = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.BOTH; this.add(this.tableBonItem, c); 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; this.addSQLObject(this.textPoidsTotal, "TOTAL_POIDS"); this.addRequiredSQLObject(this.textTotalHT, "TOTAL_HT"); this.addRequiredSQLObject(this.textTotalTVA, "TOTAL_TVA"); this.addRequiredSQLObject(this.textTotalTTC, "TOTAL_TTC"); TotalPanel panelTotal = new TotalPanel(tableBonItem, textTotalHT, textTotalTVA, textTotalTTC, new DeviseField(), new DeviseField(), new DeviseField(), new DeviseField(), new DeviseField(), textPoidsTotal, null); c.gridx = 2; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 0; c.weighty = 0; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; this.add(panelTotal, 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); ITextArea textInfos = new ITextArea(4, 4); c.gridx = 0; c.gridy++; c.gridheight = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1; c.weighty = 0; c.fill = GridBagConstraints.BOTH; final JScrollPane scrollPane = new JScrollPane(textInfos); this.add(scrollPane, c); textInfos.setBorder(null); DefaultGridBagConstraints.lockMinimumSize(scrollPane); c.gridx = 0; c.gridy++; c.gridheight = 1; c.gridwidth = 4; c.weightx = 0; c.weighty = 0; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.EAST; this.panelOO = new PanelOOSQLComponent(this); this.add(this.panelOO, c); this.addRequiredSQLObject(date, "DATE"); this.addSQLObject(textInfos, "INFOS"); this.addSQLObject(this.textNom, "NOM"); this.addSQLObject(this.selectCommande, "ID_COMMANDE_CLIENT"); this.addRequiredSQLObject(this.textNumeroUnique, "NUMERO"); this.addRequiredSQLObject(this.comboClient, "ID_CLIENT"); // Doit etre lock a la fin DefaultGridBagConstraints.lockMinimumSize(comboClient); }
From source file:com.diversityarrays.kdxplore.field.FieldViewDialog.java
public FieldViewDialog(Window owner, String title, SampleGroupChoice sgcSamples, Trial trial, SampleGroupChoice sgcNewMedia, KDSmartDatabase db) throws IOException { super(owner, title, ModalityType.MODELESS); advanceRetreatControls = Box.createHorizontalBox(); advanceRetreatControls.add(new JButton(retreatAction)); advanceRetreatControls.add(new JButton(advanceAction)); autoAdvanceControls = Box.createHorizontalBox(); autoAdvanceControls.add(new JButton(autoAdvanceAction)); autoAdvanceOption.addActionListener(new ActionListener() { @Override/*from w w w. j a v a2 s. c o m*/ public void actionPerformed(ActionEvent e) { updateMovementControls(); } }); this.database = db; this.sampleGroupChoiceForSamples = sgcSamples; this.sampleGroupChoiceForNewMedia = sgcNewMedia; NumberSpinner fontSpinner = new NumberSpinner(new SpinnerNumberModel(), "0.00"); this.fieldViewPanel = FieldViewPanel.create(database, trial, SeparatorVisibilityOption.VISIBLE, null, Box.createHorizontalGlue(), new JButton(showInfoAction), Box.createHorizontalGlue(), new JLabel("Font Size:"), fontSpinner, Box.createHorizontalGlue(), advanceRetreatControls, autoAdvanceOption, autoAdvanceControls); initialiseAction(advanceAction, "ic_object_advance_black.png", "Auto-Advance"); this.xyProvider = fieldViewPanel.getXYprovider(); this.traitMap = fieldViewPanel.getTraitMap(); fieldLayoutTable = fieldViewPanel.getFieldLayoutTable(); JScrollPane scrollPane = fieldViewPanel.getFieldTableScrollPane(); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); fieldLayoutTable.setTransferHandler(flth); fieldLayoutTable.setDropMode(DropMode.ON); fieldLayoutTable.addMouseListener(new MouseAdapter() { JPopupMenu popupMenu; @Override public void mouseClicked(MouseEvent e) { if (!SwingUtilities.isRightMouseButton(e) || 1 != e.getClickCount()) { return; } Point pt = e.getPoint(); int row = fieldLayoutTable.rowAtPoint(pt); if (row >= 0) { int col = fieldLayoutTable.columnAtPoint(pt); if (col >= 0) { Plot plot = fieldViewPanel.getPlotAt(col, row); if (plot != null) { if (popupMenu == null) { popupMenu = new JPopupMenu("View Attachments"); } popupMenu.removeAll(); Set<File> set = plot.getMediaFiles(); if (Check.isEmpty(set)) { popupMenu.add(new JMenuItem("No Attachments available")); } else { for (File file : set) { Action a = new AbstractAction(file.getName()) { @Override public void actionPerformed(ActionEvent e) { try { Desktop.getDesktop().browse(file.toURI()); } catch (IOException e1) { MsgBox.warn(FieldViewDialog.this, e1, file.getName()); } } }; popupMenu.add(new JMenuItem(a)); } } popupMenu.show(fieldLayoutTable, pt.x, pt.y); } } } } }); Font font = fieldLayoutTable.getFont(); float fontSize = font.getSize2D(); fontSizeModel = new SpinnerNumberModel(fontSize, fontSize, 50.0, 1.0); fontSpinner.setModel(fontSizeModel); fontSizeModel.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { float fsize = fontSizeModel.getNumber().floatValue(); System.out.println("Using fontSize=" + fsize); Font font = fieldLayoutTable.getFont().deriveFont(fsize); fieldLayoutTable.setFont(font); FontMetrics fm = fieldLayoutTable.getFontMetrics(font); int lineHeight = fm.getMaxAscent() + fm.getMaxDescent(); fieldLayoutTable.setRowHeight(4 * lineHeight); // GuiUtil.initialiseTableColumnWidths(fieldLayoutTable, false); fieldLayoutTable.repaint(); } }); fieldLayoutTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); fieldLayoutTable.setResizable(true, true); fieldLayoutTable.getTableColumnResizer().setResizeAllColumns(true); advanceAction.setEnabled(false); fieldLayoutTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { handlePlotSelection(); } } }); TableColumnModel columnModel = fieldLayoutTable.getColumnModel(); columnModel.addColumnModelListener(new TableColumnModelListener() { @Override public void columnSelectionChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { handlePlotSelection(); } } @Override public void columnRemoved(TableColumnModelEvent e) { } @Override public void columnMoved(TableColumnModelEvent e) { } @Override public void columnMarginChanged(ChangeEvent e) { } @Override public void columnAdded(TableColumnModelEvent e) { } }); PropertyChangeListener listener = new PropertyChangeListener() { // Use a timer and redisplay other columns when delay is GT 100 ms Timer timer = new Timer(true); TimerTask timerTask; long lastActive; boolean busy = false; private int eventColumnWidth; private TableColumn eventColumn; @Override public void propertyChange(PropertyChangeEvent evt) { if (busy) { return; } if (evt.getSource() instanceof TableColumn && "width".equals(evt.getPropertyName())) { eventColumn = (TableColumn) evt.getSource(); eventColumnWidth = eventColumn.getWidth(); lastActive = System.currentTimeMillis(); if (timerTask == null) { timerTask = new TimerTask() { @Override public void run() { if (System.currentTimeMillis() - lastActive > 200) { timerTask.cancel(); timerTask = null; busy = true; try { for (Enumeration<TableColumn> en = columnModel.getColumns(); en .hasMoreElements();) { TableColumn tc = en.nextElement(); if (tc != eventColumn) { tc.setWidth(eventColumnWidth); } } } finally { busy = false; } } } }; timer.scheduleAtFixedRate(timerTask, 100, 150); } } } }; for (Enumeration<TableColumn> en = columnModel.getColumns(); en.hasMoreElements();) { TableColumn tc = en.nextElement(); tc.addPropertyChangeListener(listener); } Map<Integer, Plot> plotById = new HashMap<>(); for (Plot plot : fieldViewPanel.getFieldLayout()) { plotById.put(plot.getPlotId(), plot); } TrialItemVisitor<Sample> sampleVisitor = new TrialItemVisitor<Sample>() { @Override public void setExpectedItemCount(int count) { } @Override public boolean consumeItem(Sample sample) throws IOException { Plot plot = plotById.get(sample.getPlotId()); if (plot == null) { throw new IOException("Missing plot for plotId=" + sample.getPlotId() + " sampleIdent=" + Util.createUniqueSampleKey(sample)); } plot.addSample(sample); SampleCounts counts = countsByTraitId.get(sample.getTraitId()); if (counts == null) { counts = new SampleCounts(); countsByTraitId.put(sample.getTraitId(), counts); } if (sample.hasBeenScored()) { ++counts.scored; } else { ++counts.unscored; } return true; } }; database.visitSamplesForTrial(sampleGroupChoiceForSamples, trial.getTrialId(), SampleOrder.ALL_BY_PLOT_ID_THEN_TRAIT_ID_THEN_INSTANCE_NUMBER_ORDER_THEN_SPECIMEN_NUMBER, sampleVisitor); setDefaultCloseOperation(DISPOSE_ON_CLOSE); this.trial = trial; KDClientUtils.initAction(ImageId.SETTINGS_24, showInfoAction, "Trial Summary"); Action clear = new AbstractAction("Clear") { @Override public void actionPerformed(ActionEvent e) { infoTextArea.setText(""); } }; JPanel bottom = new JPanel(new BorderLayout()); bottom.add(GuiUtil.createLabelSeparator("Plot Details", new JButton(clear)), BorderLayout.NORTH); bottom.add(new JScrollPane(infoTextArea), BorderLayout.CENTER); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, fieldViewPanel, new JScrollPane(infoTextArea)); splitPane.setResizeWeight(0.0); splitPane.setOneTouchExpandable(true); setContentPane(splitPane); updateMovementControls(); pack(); }
From source file:org.jfree.data.time.TimeSeriesCollection.java
/** * Receives notification that the key for one of the series in the * collection has changed, and vetos it if the key is already present in * the collection.//from w w w . j a v a2 s. c o m * * @param e the event. * * @since 1.0.17 */ @Override public void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException { // if it is not the series name, then we have no interest if (!"Key".equals(e.getPropertyName())) { return; } // to be defensive, let's check that the source series does in fact // belong to this collection Series s = (Series) e.getSource(); if (getSeriesIndex(s.getKey()) == -1) { throw new IllegalStateException( "Receiving events from a series " + "that does not belong to this collection."); } // check if the new series name already exists for another series Comparable key = (Comparable) e.getNewValue(); if (getSeriesIndex(key) >= 0) { throw new PropertyVetoException("Duplicate key2", e); } }