List of usage examples for java.beans PropertyChangeEvent getSource
public Object getSource()
From source file:org.openmicroscopy.shoola.agents.imviewer.util.player.MoviePlayerControl.java
/** * Sets the z-section interval and timepoint interval. * @see PropertyChangeListener#propertyChange(PropertyChangeEvent) *///from w w w . ja v a 2 s . c om public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); Object source = evt.getSource(); int s = -1; int e = -1; if (TwoKnobsSlider.LEFT_MOVED_PROPERTY.equals(name)) { if (source.equals(view.zSlider)) { s = view.zSlider.getStartValueAsInt(); model.setStartZ(s); view.setStartZ(s); } else if (source.equals(view.tSlider)) { s = view.tSlider.getStartValueAsInt(); model.setStartT(s); view.setStartT(s); } } else if (TwoKnobsSlider.RIGHT_MOVED_PROPERTY.equals(name)) { if (source.equals(view.zSlider)) { e = view.zSlider.getEndValueAsInt(); model.setEndZ(e); view.setEndZ(e); } else if (source.equals(view.tSlider)) { e = view.tSlider.getEndValueAsInt(); model.setEndT(e); view.setEndT(e); } } else if (NumericalTextField.TEXT_UPDATED_PROPERTY.equals(name)) { Number n; if (source.equals(view.startT)) { n = view.startT.getValueAsNumber(); if (n == null) return; s = n.intValue() - 1; if (s >= model.getEndT() || s < 0) return; model.setStartT(s); view.tSlider.setStartValue(s); } else if (source.equals(view.startZ)) { n = view.startZ.getValueAsNumber(); if (n == null) return; s = n.intValue() - 1; if (s >= model.getEndZ() || s < 0) return; model.setStartZ(s); view.zSlider.setStartValue(s); } else if (source.equals(view.endZ)) { n = view.endZ.getValueAsNumber(); if (n == null) return; s = n.intValue() - 1; if (s <= model.getStartZ() || s > model.getMaxZ()) return; model.setEndZ(s); view.zSlider.setEndValue(s); } else if (source.equals(view.endT)) { n = view.endT.getValueAsNumber(); if (n == null) return; s = n.intValue() - 1; if (s <= model.getStartT() || s > model.getMaxT()) return; model.setEndT(s); view.tSlider.setEndValue(s); } } }
From source file:ca.sqlpower.enterprise.DataSourceCollectionUpdater.java
/** * Handles changes to individual data sources by relaying their new * state to the server.//from w ww.j ava 2s . c om * <p> * <b>Implementation note:</b> Presently, all properties for the data * source are sent back to the server every time one of them changes. * This is not the desired behaviour, but without rethinking the * SPDataSource event system, there is little else we can do: the * property change events tell us JavaBeans property names, but in order * to send incremental updates, we's need to know the pl.ini property * key names. * * @param evt * The event describing the change. Its source must be the * data source object which was modified. */ public void propertyChange(PropertyChangeEvent evt) { // Updating all properties is less than ideal, but a property change event does // not tell us what the "pl.ini" key for the property is. Object source = evt.getSource(); if (source instanceof SPDataSource) { SPDataSource ds = (SPDataSource) source; ds.addPropertyChangeListener(this); List<NameValuePair> properties = new ArrayList<NameValuePair>(); for (Map.Entry<String, String> ent : ds.getPropertiesMap().entrySet()) { properties.add(new BasicNameValuePair(ent.getKey(), ent.getValue())); } propertyChange(evt, ds, properties); } if (source instanceof JDBCDataSourceType) { JDBCDataSourceType jdst = (JDBCDataSourceType) source; jdst.addPropertyChangeListener(this); List<NameValuePair> properties = new ArrayList<NameValuePair>(); for (String name : jdst.getPropertyNames()) { properties.add(new BasicNameValuePair(name, jdst.getProperty(name))); } postJDBCDataSourceTypeProperties(jdst, properties); } }
From source file:org.jcurl.demo.tactics.BroomPromptSwingBean.java
public void propertyChange(final PropertyChangeEvent evt) { if (log.isDebugEnabled()) log.debug(evt.getSource()); if (evt.getSource() == broom) { if ("idx16".equals(evt.getPropertyName())) syncM2V(broom == null ? -1 : broom.getIdx16()); else if ("outTurn".equals(evt.getPropertyName())) syncM2V(broom == null ? null : broom.getOutTurn()); else if ("splitTimeMillis".equals(evt.getPropertyName())) syncM2V(broom == null ? null : broom.getSplitTimeMillis()); else if ("broom".equals(evt.getPropertyName())) syncM2V(broom == null ? null : broom.getBroom()); } else if (evt.getSource() == x || evt.getSource() == y) { if ("valueIsAdjusting".equals(evt.getPropertyName())) if (Boolean.TRUE.equals(evt.getNewValue())) firstXY = new XYMemento(broom, broom.getBroom()); else { if (Boolean.FALSE.equals(evt.getNewValue())) getChanger().undoable(firstXY, new XYMemento(broom, x.getValue(), y.getValue())); firstXY = null;//www. j a va 2 s. c o m } } else log.warn("Unprocessed event from " + evt.getSource()); }
From source file:controlador.ControladorReportes.java
private boolean verificarRangoFechas(PropertyChangeEvent evt) { boolean respuesta = false; if (evt.getSource().equals(reportes.getJXDPDesde())) { respuesta = verificarRangoFechas(evt, reportes.getJXDPDesde()); } else if (evt.getSource().equals(reportes.getJXDPHasta())) { respuesta = verificarRangoFechas(evt, reportes.getJXDPHasta()); }/*from w w w . j a v a 2s . c o m*/ return respuesta; }
From source file:org.tinymediamanager.ui.movies.MovieMediaFilesPanel.java
/** * Instantiates a new movie media information panel. * //ww w .j av a 2 s . com * @param model * the model */ public MovieMediaFilesPanel(MovieSelectionModel model) { this.movieSelectionModel = model; mediaFileEventList = new ObservableElementList<>( GlazedLists.threadSafeList(new BasicEventList<MediaFile>()), GlazedLists.beanConnector(MediaFile.class)); setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("200px:grow"), FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.NARROW_LINE_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.NARROW_LINE_GAP_ROWSPEC, })); lblDateAddedT = new JLabel(BUNDLE.getString("metatag.dateadded")); //$NON-NLS-1$ add(lblDateAddedT, "2, 2"); lblDateAdded = new JLabel(""); add(lblDateAdded, "4, 2"); // btnPlay = new JButton("Play"); // btnPlay.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent arg0) { // try { // Desktop.getDesktop().open(movieSelectionModel.getSelectedMovie().getMediaFiles(MediaFileType.VIDEO).get(0).getFile()); // } // catch (Exception e) { // // } // } // if (!StringUtils.isEmpty(lblMoviePath.getNormalText())) { // // get the location from the label // StringBuilder movieFile = new // StringBuilder(lblMoviePath.getNormalText()); // movieFile.append(File.separator); // movieFile.append(movieSelectionModel.getSelectedMovie().getMediaFiles().get(0).getFilename()); // File f = new File(movieFile.toString()); // // try { // if (f.exists()) { // // String vlcF = f.getAbsolutePath(); // // F I X M E: german umlauts do not decode correctly; Bug in // // libDvdNav? so workaround; // if (vlcF.matches(".*[].*")) { // LOGGER.debug("VLC: workaround: german umlauts found - use system player"); // Desk4op.getDesktop().open(f); // } // else { // try { // // if (!vlcF.startsWith("/")) { // // add the missing 3rd / in not start with one (eg windows) // vlcF = "/" + vlcF; // } // String mrl = new FileMrl().file(vlcF).value(); // // final EmbeddedMediaPlayerComponent mediaPlayerComponent = new // EmbeddedMediaPlayerComponent(); // JFrame frame = new JFrame("player"); // frame.setLocation(100, 100); // frame.setSize(1050, 600); // frame.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE); // frame.setVisible(true); // frame.setContentPane(mediaPlayerComponent); // // mrl = mrl.replace("file://", ""); // does not work either // // LOGGER.debug("VLC: playing " + mrl); // Boolean ok = mediaPlayerComponent.getMediaPlayer().playMedia(mrl); // if (!ok) { // LOGGER.error("VLC: couldn't create player window!"); // } // } // catch (RuntimeException e) { // LOGGER.warn("VLC: has not been initialized on startup - use system player"); // Desktop.getDesktop().open(f); // } // catch (NoClassDefFoundError e) { // LOGGER.warn("VLC: has not been initialized on startup - use system player"); // Desktop.getDesktop().open(f); // } // // } // end else // } // end exists // } // end try // catch (IOException e) { // LOGGER.error("Error opening file", e); // } // } // end isEmpty // } // }); // add(btnPlay, "10, 2"); lblMoviePathT = new JLabel(BUNDLE.getString("metatag.path")); //$NON-NLS-1$ add(lblMoviePathT, "2, 4"); lblMoviePath = new LinkLabel(""); lblMoviePath.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (!StringUtils.isEmpty(lblMoviePath.getNormalText())) { Path path = Paths.get(lblMoviePath.getNormalText()); try { // get the location from the label // check whether this location exists if (Files.exists(path)) { TmmUIHelper.openFile(path); } } catch (Exception ex) { LOGGER.error("open filemanager", ex); MessageManager.instance.pushMessage(new Message(MessageLevel.ERROR, path, "message.erroropenfolder", new String[] { ":", ex.getLocalizedMessage() })); } } } }); lblMoviePathT.setLabelFor(lblMoviePath); lblMoviePathT.setLabelFor(lblMoviePath); add(lblMoviePath, "4, 4"); lblFilesT = new JLabel(BUNDLE.getString("metatag.files")); //$NON-NLS-1$ add(lblFilesT, "2, 6, default, top"); panelMediaFiles = new MediaFilesPanel(mediaFileEventList); add(panelMediaFiles, "4, 6, 1, 1, fill, fill"); initDataBindings(); // install the propertychangelistener PropertyChangeListener propertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { String property = propertyChangeEvent.getPropertyName(); Object source = propertyChangeEvent.getSource(); // react on selection of a movie and change of media files if ((source.getClass() == MovieSelectionModel.class && "selectedMovie".equals(property)) || (source.getClass() == Movie.class && MEDIA_FILES.equals(property))) { // this does sometimes not work. simply wrap it try { mediaFileEventList.getReadWriteLock().writeLock().lock(); mediaFileEventList.clear(); mediaFileEventList.addAll(movieSelectionModel.getSelectedMovie().getMediaFiles()); } catch (Exception e) { } finally { mediaFileEventList.getReadWriteLock().writeLock().unlock(); } try { panelMediaFiles.adjustColumns(); } catch (Exception e) { } } } }; movieSelectionModel.addPropertyChangeListener(propertyChangeListener); }
From source file:org.tinymediamanager.ui.tvshows.TvShowMediaInformationPanel.java
/** * Instantiates a new tv show media information panel. * /*from w ww . j a v a 2s . co m*/ * @param model * the model */ public TvShowMediaInformationPanel(TvShowSelectionModel model) { this.selectionModel = model; mediaFileEventList = new ObservableElementList<>( GlazedLists.threadSafeList(new BasicEventList<MediaFile>()), GlazedLists.beanConnector(MediaFile.class)); setLayout(new FormLayout(new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.NARROW_LINE_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.NARROW_LINE_GAP_ROWSPEC, })); lblDateAddedT = new JLabel(BUNDLE.getString("metatag.dateadded")); //$NON-NLS-1$ add(lblDateAddedT, "2, 2"); lblDateAdded = new JLabel(""); add(lblDateAdded, "4, 2"); lblWatchedT = new JLabel(BUNDLE.getString("metatag.watched")); //$NON-NLS-1$ add(lblWatchedT, "6, 2"); cbWatched = new JCheckBox(""); cbWatched.setEnabled(false); add(cbWatched, "8, 2"); // btnPlay = new JButton("Play"); // btnPlay.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent arg0) { // if (!StringUtils.isEmpty(lblMoviePath.getNormalText())) { // // get the location from the label // StringBuilder movieFile = new // StringBuilder(lblMoviePath.getNormalText()); // movieFile.append(File.separator); // movieFile.append(movieSelectionModel.getselectedTvShowEpisode().getMediaFiles().get(0).getFilename()); // File f = new File(movieFile.toString()); // // try { // if (f.exists()) { // // String vlcF = f.getAbsolutePath(); // // F I X M E: german umlauts do not decode correctly; Bug in // // libDvdNav? so workaround; // if (vlcF.matches(".*[].*")) { // LOGGER.debug("VLC: workaround: german umlauts found - use system player"); // Desktop.getDesktop().open(f); // } // else { // try { // // if (!vlcF.startsWith("/")) { // // add the missing 3rd / if not start with one (eg windows) // vlcF = "/" + vlcF; // } // String mrl = new FileMrl().file(vlcF).value(); // // final EmbeddedMediaPlayerComponent mediaPlayerComponent = new // EmbeddedMediaPlayerComponent(); // JFrame frame = new JFrame("player"); // frame.setLocation(100, 100); // frame.setSize(1050, 600); // frame.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE); // frame.setVisible(true); // frame.setContentPane(mediaPlayerComponent); // // mrl = mrl.replace("file://", ""); // does not work either // // LOGGER.debug("VLC: playing " + mrl); // Boolean ok = mediaPlayerComponent.getMediaPlayer().playMedia(mrl); // if (!ok) { // LOGGER.error("VLC: couldn't create player window!"); // } // } // catch (RuntimeException e) { // LOGGER.warn("VLC: has not been initialized on startup - use system player"); // Desktop.getDesktop().open(f); // } // catch (NoClassDefFoundError e) { // LOGGER.warn("VLC: has not been initialized on startup - use system player"); // Desktop.getDesktop().open(f); // } // // } // end else // } // end exists // } // end try // catch (IOException e) { // LOGGER.error("Error opening file", e); // } // } // end isEmpty // } // }); // add(btnPlay, "10, 2"); lblTvShowPathT = new JLabel(BUNDLE.getString("metatag.path")); //$NON-NLS-1$ add(lblTvShowPathT, "2, 4"); lblTvShowPath = new LinkLabel(""); lblTvShowPath.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (!StringUtils.isEmpty(lblTvShowPath.getNormalText())) { // get the location from the label Path path = Paths.get(lblTvShowPath.getNormalText()); try { // check whether this location exists if (Files.exists(path)) { TmmUIHelper.openFile(path); } } catch (Exception ex) { LOGGER.error("open filemanager", ex); MessageManager.instance.pushMessage(new Message(MessageLevel.ERROR, path, "message.erroropenfolder", new String[] { ":", ex.getLocalizedMessage() })); } } } }); lblTvShowPathT.setLabelFor(lblTvShowPath); lblTvShowPathT.setLabelFor(lblTvShowPath); add(lblTvShowPath, "4, 4, 5, 1"); panelMediaFiles = new MediaFilesPanel(mediaFileEventList); add(panelMediaFiles, "2, 6, 9, 1, fill, fill"); initDataBindings(); // install the propertychangelistener PropertyChangeListener propertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { String property = propertyChangeEvent.getPropertyName(); Object source = propertyChangeEvent.getSource(); // react on selection of a tv show and change of media files if ((source.getClass() == TvShowSelectionModel.class && "selectedTvShow".equals(property)) || (source.getClass() == TvShowEpisode.class && "mediaFiles".equals(property))) { try { mediaFileEventList.getReadWriteLock().writeLock().lock(); mediaFileEventList.clear(); mediaFileEventList.addAll(selectionModel.getSelectedTvShow().getMediaFiles()); } catch (Exception e) { } finally { mediaFileEventList.getReadWriteLock().writeLock().unlock(); } try { panelMediaFiles.adjustColumns(); } catch (Exception e) { } } } }; selectionModel.addPropertyChangeListener(propertyChangeListener); }
From source file:org.tinymediamanager.ui.movies.MovieTrailerPanel.java
/** * Instantiates a new movie details panel. * /*from w w w . j a v a2 s .c o m*/ * @param model * the model */ public MovieTrailerPanel(MovieSelectionModel model) { this.movieSelectionModel = model; setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), })); trailerEventList = new SortedList<>(GlazedLists.threadSafeList(new ObservableElementList<>( new BasicEventList<MovieTrailer>(), GlazedLists.beanConnector(MovieTrailer.class)))); trailerTableModel = new DefaultEventTableModel<>(GlazedListsSwing.swingThreadProxyList(trailerEventList), new TrailerTableFormat()); table = new ZebraJTable(trailerTableModel); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.setSelectionModel(new NullSelectionModel()); TableComparatorChooser.install(table, trailerEventList, TableComparatorChooser.SINGLE_COLUMN); JScrollPane scrollPane = ZebraJTable.createStripedJScrollPane(table); add(scrollPane, "2, 2, fill, fill"); scrollPane.setViewportView(table); LinkListener linkListener = new LinkListener(); table.addMouseListener(linkListener); table.addMouseMotionListener(linkListener); // install the propertychangelistener PropertyChangeListener propertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { String property = propertyChangeEvent.getPropertyName(); Object source = propertyChangeEvent.getSource(); // react on selection of a movie and change of a trailer if ((source.getClass() == MovieSelectionModel.class && "selectedMovie".equals(property)) || (source.getClass() == Movie.class && "trailer".equals(property))) { trailerEventList.clear(); trailerEventList.addAll(movieSelectionModel.getSelectedMovie().getTrailer()); try { TableColumnResizer.adjustColumnPreferredWidths(table, 7); } catch (Exception e) { } } } }; movieSelectionModel.addPropertyChangeListener(propertyChangeListener); }
From source file:org.tinymediamanager.ui.moviesets.MovieSetInformationPanel.java
/** * Instantiates a new movie set information panel. * /* w w w. ja v a2s. co m*/ * @param model * the model */ public MovieSetInformationPanel(MovieSetSelectionModel model) { this.selectionModel = model; movieEventList = new ObservableElementList<>( GlazedListsSwing.swingThreadProxyList(new BasicEventList<Movie>()), GlazedLists.beanConnector(Movie.class)); setLayout(new BorderLayout(0, 0)); panel = new JPanel(); add(panel, BorderLayout.CENTER); panel.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("180px:grow"), ColumnSpec.decode("1px"), }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("pref:grow"), RowSpec.decode("bottom:default"), })); lblMovieSetName = new JLabel(""); TmmFontHelper.changeFont(lblMovieSetName, 1.5, Font.BOLD); panel.add(lblMovieSetName, "2,1, fill, fill"); layeredPane = new JLayeredPane(); panel.add(layeredPane, "1, 3, 2, 1, fill, fill"); layeredPane.setLayout(new FormLayout( new ColumnSpec[] { ColumnSpec.decode("10px"), ColumnSpec.decode("120px"), ColumnSpec.decode("200px:grow"), }, new RowSpec[] { RowSpec.decode("10px"), RowSpec.decode("180px"), RowSpec.decode("default:grow"), })); lblMovieSetPoster = new ImageLabel(); lblMovieSetPoster.setAlternativeText(BUNDLE.getString("image.notfound.poster")); //$NON-NLS-1$ lblMovieSetPoster.enableLightbox(); layeredPane.setLayer(lblMovieSetPoster, 1); layeredPane.add(lblMovieSetPoster, "2, 2, fill, fill"); lblMovieSetFanart = new ImageLabel(false, true); lblMovieSetFanart.setAlternativeText(BUNDLE.getString("image.notfound.fanart")); //$NON-NLS-1$ lblMovieSetFanart.enableLightbox(); layeredPane.add(lblMovieSetFanart, "1, 1, 3, 3, fill, fill"); panelSouth = new JSplitPane(); panelSouth.setContinuousLayout(true); panelSouth.setResizeWeight(0.5); add(panelSouth, BorderLayout.SOUTH); panelOverview = new JPanel(); panelSouth.setLeftComponent(panelOverview); panelOverview.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("100px:grow"), }, new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("24px:grow"), })); lblOverview = new JLabel(BUNDLE.getString("metatag.plot")); //$NON-NLS-1$ panelOverview.add(lblOverview, "1, 2"); scrollPaneOverview = new JScrollPane(); panelOverview.add(scrollPaneOverview, "1, 4, fill, fill"); tpOverview = new JTextPane(); tpOverview.setEditable(false); scrollPaneOverview.setViewportView(tpOverview); JPanel panelMovies = new JPanel(); panelSouth.setRightComponent(panelMovies); panelMovies.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("200px:grow(3)"), }, new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("203px:grow"), })); movieTableModel = new DefaultEventTableModel<>(GlazedListsSwing.swingThreadProxyList(movieEventList), new MovieInMovieSetTableFormat()); // tableAssignedMovies = new JTable(movieTableModel); tableAssignedMovies = new ZebraJTable(movieTableModel); // JScrollPane scrollPaneMovies = new JScrollPane(); JScrollPane scrollPaneMovies = ZebraJTable.createStripedJScrollPane(tableAssignedMovies); panelMovies.add(scrollPaneMovies, "1, 2, fill, fill"); tableAssignedMovies.setPreferredScrollableViewportSize(new Dimension(450, 200)); scrollPaneMovies.setViewportView(tableAssignedMovies); initDataBindings(); // adjust table columns // year column int width = tableAssignedMovies.getFontMetrics(tableAssignedMovies.getFont()).stringWidth(" 2000"); int titleWidth = tableAssignedMovies.getFontMetrics(tableAssignedMovies.getFont()) .stringWidth(BUNDLE.getString("metatag.year")); //$NON-NLS-1$ if (titleWidth > width) { width = titleWidth; } tableAssignedMovies.getTableHeader().getColumnModel().getColumn(1).setPreferredWidth(width); tableAssignedMovies.getTableHeader().getColumnModel().getColumn(1).setMinWidth(width); tableAssignedMovies.getTableHeader().getColumnModel().getColumn(1).setMaxWidth((int) (width * 1.5)); // watched column tableAssignedMovies.getTableHeader().getColumnModel().getColumn(2).setPreferredWidth(70); tableAssignedMovies.getTableHeader().getColumnModel().getColumn(2).setMinWidth(70); tableAssignedMovies.getTableHeader().getColumnModel().getColumn(2).setMaxWidth(85); // install the propertychangelistener PropertyChangeListener propertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { String property = propertyChangeEvent.getPropertyName(); Object source = propertyChangeEvent.getSource(); // react on selection of a movie and change of media files if ((source.getClass() == MovieSetSelectionModel.class && "selectedMovieSet".equals(property)) || (source.getClass() == MovieSet.class && "movies".equals(property))) { movieEventList.clear(); movieEventList.addAll(selectionModel.getSelectedMovieSet().getMovies()); if (StringUtils.isNotBlank( selectionModel.getSelectedMovieSet().getArtworkFilename(MediaFileType.POSTER))) { lblMovieSetPoster.setImagePath( selectionModel.getSelectedMovieSet().getArtworkFilename(MediaFileType.POSTER)); } else { lblMovieSetPoster.setImagePath(""); lblMovieSetPoster.setImageUrl( selectionModel.getSelectedMovieSet().getArtworkUrl(MediaFileType.POSTER)); } if (StringUtils.isNotBlank( selectionModel.getSelectedMovieSet().getArtworkFilename(MediaFileType.FANART))) { lblMovieSetFanart.setImagePath( selectionModel.getSelectedMovieSet().getArtworkFilename(MediaFileType.FANART)); } else { lblMovieSetFanart.setImagePath(""); lblMovieSetFanart.setImageUrl( selectionModel.getSelectedMovieSet().getArtworkUrl(MediaFileType.FANART)); } } // react on changes of the images if ((source.getClass() == MovieSet.class && FANART.equals(property))) { MovieSet movieSet = (MovieSet) source; lblMovieSetFanart.clearImage(); lblMovieSetFanart.setImagePath(movieSet.getArtworkFilename(MediaFileType.FANART)); } if ((source.getClass() == MovieSet.class && POSTER.equals(property))) { MovieSet movieSet = (MovieSet) source; lblMovieSetPoster.clearImage(); lblMovieSetPoster.setImagePath(movieSet.getArtworkFilename(MediaFileType.POSTER)); } } }; selectionModel.addPropertyChangeListener(propertyChangeListener); }
From source file:org.jfree.chart.demo.CompassDemo.java
/** * Initialises the user interface.//from w w w .ja v a 2s . c o m * * @throws Exception if there are any exceptions. */ void jbInit() throws Exception { this.titledBorder1 = new TitledBorder(""); this.titledBorder2 = new TitledBorder(""); this.titledBorder3 = new TitledBorder(""); setLayout(this.gridLayout1); this.panelCompassHolder.setLayout(this.borderLayout); this.windNullCheckBox.setHorizontalTextPosition(SwingConstants.LEADING); this.windNullCheckBox.setText("Null"); this.windNullCheckBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final ActionEvent e) { checkWindNullActionPerformed(e); } }); this.shipNullCheckBox.setHorizontalTextPosition(SwingConstants.LEFT); this.shipNullCheckBox.setText("Null"); this.shipNullCheckBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final ActionEvent e) { checkShipNullActionPerformed(e); } }); this.spinShip.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { if (DEBUG) { System.out.println("compassDemo:spinShipPropertyChange"); } final Spinner spinner = (Spinner) evt.getSource(); if (spinner.isEnabled()) { shipData.setValue(new Double(spinner.getValue())); } } }); this.spinWind.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { if (DEBUG) { System.out.println("compassDemo:spinWindPropertyChange"); } final Spinner spinner = (Spinner) evt.getSource(); if (spinner.isEnabled()) { compassData.setValue(new Double(spinner.getValue())); } } }); this.jPanel12.setLayout(this.gridLayout2); this.jPanel2.setBorder(this.titledBorder1); this.jPanel2.setLayout(this.gridBagLayout2); this.jPanel1.setBorder(this.titledBorder2); this.jPanel1.setLayout(this.gridBagLayout1); this.titledBorder1.setTitle("Second Pointer"); this.titledBorder2.setTitle("First Pointer"); this.titledBorder3.setTitle("Plot Options"); this.pick2Pointer.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final ActionEvent e) { pick2PointerActionPerformed(e); } }); this.pick1Pointer.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final ActionEvent e) { pick1PointerActionPerformed(e); } }); add(this.panelCompassHolder, null); this.panelCompassHolder.add(this.jPanel12, BorderLayout.SOUTH); this.jPanel12.add(this.jPanel1, null); this.jPanel1.add(this.pick1Pointer, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); this.jPanel1.add(this.windNullCheckBox, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); this.jPanel1.add(this.spinWind, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); this.jPanel12.add(this.jPanel2, null); this.jPanel2.add(this.pick2Pointer, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); this.jPanel2.add(this.shipNullCheckBox, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); this.jPanel2.add(this.spinShip, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); this.panelCompassHolder.add(this.panelCompass, BorderLayout.CENTER); }
From source file:org.talend.designer.core.ui.editor.update.cmd.UpdateJobletNodeCommand.java
/** * qzhang Comment method "updateGraphicalNodesSchema". * /*from www . j a v a2s . co m*/ * this method is moved from class AbstractTalendEditor. * * @param evt */ @SuppressWarnings("unchecked") private void updateGraphicalNodesSchema(Process process, PropertyChangeEvent evt) { if (!(evt.getSource() instanceof INode)) { return; } INode sourceNode = (INode) evt.getSource(); String componentName = sourceNode.getComponent().getName(); IComponent newComponent = ComponentsFactoryProvider.getInstance().get(componentName, ComponentCategory.CATEGORY_4_DI.getName()); if (newComponent == null) { return; } Object[] newMetadataTables = (Object[]) evt.getNewValue(); List<IMetadataTable> newInputTableList = (List<IMetadataTable>) newMetadataTables[0]; List<IMetadataTable> newOutputTableList = (List<IMetadataTable>) newMetadataTables[1]; for (Node node : (List<Node>) process.getGraphicalNodes()) { if (node.getComponent().getName().equals(componentName)) { List<IElementParameter> outputElemParams = new ArrayList<IElementParameter>(); IElementParameter outputElemParam = null; List<? extends IElementParameter> elementParameters = node.getElementParameters(); for (IElementParameter elementParameter : elementParameters) { if (EParameterFieldType.SCHEMA_TYPE.equals(elementParameter.getFieldType())) { outputElemParams.add(elementParameter); } } ChangeMetadataCommand command; List<? extends IConnection> incomingConnections = node.getIncomingConnections(); if (incomingConnections.size() <= 1) { for (int i = 0; i < incomingConnections.size(); i++) { IConnection connection = incomingConnections.get(i); Node source = (Node) connection.getSource(); IMetadataTable metadataTable = connection.getMetadataTable(); IMetadataTable newInputMetadataTable = UpdateManagerUtils.getNewInputTableForConnection( newInputTableList, metadataTable.getAttachedConnector()); if (newInputMetadataTable != null && !metadataTable.sameMetadataAs(newInputMetadataTable)) { IElementParameter elementParam = source .getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE); command = new ChangeMetadataCommand(source, elementParam, metadataTable, newInputMetadataTable); command.execute(Boolean.FALSE); } } } else { for (IElementParameter param : node.getElementParameters()) { if (param.isShow(node.getElementParameters()) && param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE)) { IMetadataTable table = node.getMetadataFromConnector(param.getContext()); IElementParameter connParam = param.getChildParameters() .get(EParameterName.CONNECTION.getName()); if (table != null && connParam != null && !StringUtils.isEmpty((String) connParam.getValue())) { for (IConnection connection : incomingConnections) { if (connection.isActivate() && connection.getName().equals(connParam.getValue())) { if (!table.sameMetadataAs(connection.getMetadataTable(), IMetadataColumn.OPTIONS_IGNORE_KEY | IMetadataColumn.OPTIONS_IGNORE_NULLABLE | IMetadataColumn.OPTIONS_IGNORE_COMMENT | IMetadataColumn.OPTIONS_IGNORE_PATTERN | IMetadataColumn.OPTIONS_IGNORE_DBCOLUMNNAME | IMetadataColumn.OPTIONS_IGNORE_DBTYPE | IMetadataColumn.OPTIONS_IGNORE_DEFAULT | IMetadataColumn.OPTIONS_IGNORE_BIGGER_SIZE)) { Node source = (Node) connection.getSource(); IMetadataTable metadataTable = connection.getMetadataTable(); IElementParameter elementParam = source .getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE); command = new ChangeMetadataCommand(source, elementParam, metadataTable, table); command.execute(Boolean.FALSE); } } } } } } } List<? extends IConnection> outgoingConnections = node.getOutgoingConnections(); for (int i = 0; i < outgoingConnections.size(); i++) { IConnection connection = outgoingConnections.get(i); Node target = (Node) connection.getTarget(); IMetadataTable metadataTable = connection.getMetadataTable(); if (metadataTable != null) { IMetadataTable newOutputMetadataTable = UpdateManagerUtils.getNewOutputTableForConnection( newOutputTableList, metadataTable.getAttachedConnector()); if (newOutputMetadataTable != null && !metadataTable.sameMetadataAs(newOutputMetadataTable)) { IElementParameter elementParam = target .getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE); command = new ChangeMetadataCommand(target, elementParam, target.getMetadataFromConnector(metadataTable.getAttachedConnector()), newOutputMetadataTable); command.execute(Boolean.FALSE); } } } List<IMetadataTable> metadataList = node.getMetadataList(); for (IMetadataTable metadataTable : metadataList) { IMetadataTable newInputMetadataTable = UpdateManagerUtils .getNewInputTableForConnection(newInputTableList, metadataTable.getAttachedConnector()); IMetadataTable newOutputMetadataTable = UpdateManagerUtils.getNewOutputTableForConnection( newOutputTableList, metadataTable.getAttachedConnector()); outputElemParam = UpdateManagerUtils.getElemParam(outputElemParams, metadataTable.getAttachedConnector()); if (outputElemParam != null && newInputMetadataTable != null) { command = new ChangeMetadataCommand(node, outputElemParam, (IMetadataTable) outputElemParam.getValue(), newInputMetadataTable); command.execute(Boolean.FALSE); IMetadataTable metadataFromConnector = node .getMetadataFromConnector(outputElemParam.getContext()); MetadataToolHelper.copyTable(newInputMetadataTable, metadataFromConnector); } else if (outputElemParam != null && newOutputMetadataTable != null) { command = new ChangeMetadataCommand(node, outputElemParam, (IMetadataTable) outputElemParam.getValue(), newOutputMetadataTable); command.execute(Boolean.FALSE); IMetadataTable metadataFromConnector = node .getMetadataFromConnector(outputElemParam.getContext()); MetadataToolHelper.copyTable(newOutputMetadataTable, metadataFromConnector); } } } } }