List of usage examples for java.beans PropertyChangeListener PropertyChangeListener
PropertyChangeListener
From source file:org.tinymediamanager.ui.moviesets.MovieSetInformationPanel.java
/** * Instantiates a new movie set information panel. * // ww w.j a va 2 s . c o 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.isatools.isacreatorconfigurator.configui.DataEntryPanel.java
private void showMessagePane(String message, int messageType) { final JOptionPane optionPane = new JOptionPane("<html>" + message + "</html>", JOptionPane.OK_OPTION); UIHelper.renderComponent(optionPane, UIHelper.VER_12_PLAIN, UIHelper.DARK_GREEN_COLOR, false); if (messageType == JOptionPane.ERROR_MESSAGE) { optionPane.setIcon(warningIcon); } else {/*from w w w . java 2s .c o m*/ optionPane.setIcon(informationIcon); } optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) { applicationContainer.hideSheet(); } } }); SwingUtilities.invokeLater(new Runnable() { public void run() { applicationContainer.showJDialogAsSheet(optionPane.createDialog(getThis(), "Message")); } }); }
From source file:org.esa.beam.visat.toolviews.stat.ScatterPlotPanel.java
ScatterPlotPanel(ToolView parentDialog, String helpId) { super(parentDialog, helpId, CHART_TITLE, false); userSettingsMap = new HashMap<>(); productRemovedListener = new ProductManager.Listener() { @Override/*from ww w . j av a 2s . c o m*/ public void productAdded(ProductManager.Event event) { } @Override public void productRemoved(ProductManager.Event event) { final UserSettings userSettings = userSettingsMap.remove(event.getProduct()); if (userSettings != null) { userSettings.dispose(); } } }; xAxisRangeControl = new AxisRangeControl("X-Axis"); yAxisRangeControl = new AxisRangeControl("Y-Axis"); scatterPlotModel = new ScatterPlotModel(); bindingContext = new BindingContext(PropertyContainer.createObjectBacked(scatterPlotModel)); scatterpointsDataset = new XYIntervalSeriesCollection(); acceptableDeviationDataset = new XYIntervalSeriesCollection(); regressionDataset = new XYIntervalSeriesCollection(); r2Annotation = new XYTitleAnnotation(0, 0, new TextTitle("")); chart = ChartFactory.createScatterPlot(CHART_TITLE, "", "", scatterpointsDataset, PlotOrientation.VERTICAL, true, true, false); chart.getXYPlot().setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); createDomainAxisChangeListener(); final PropertyChangeListener userSettingsUpdateListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (getRaster() != null) { final VectorDataNode pointDataSourceValue = scatterPlotModel.pointDataSource; final AttributeDescriptor dataFieldValue = scatterPlotModel.dataField; final UserSettings userSettings = getUserSettings(getRaster().getProduct()); userSettings.set(getRaster().getName(), pointDataSourceValue, dataFieldValue); } } }; bindingContext.addPropertyChangeListener(PROPERTY_NAME_DATA_FIELD, userSettingsUpdateListener); bindingContext.addPropertyChangeListener(PROPERTY_NAME_POINT_DATA_SOURCE, userSettingsUpdateListener); }
From source file:ru.goodfil.catalog.ui.forms.MainWindow.java
private void miExportOeToExcelActionPerformed(ActionEvent e) { final ProgressMonitor progressMonitor = new ProgressMonitor(this, " ", ", ?? ", 0, 100); progressMonitor.setProgress(10);// ww w. ja va 2s . c o m progressMonitor.setMillisToPopup(0); ExportOeTask task = new ExportOeTask(); task.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("progress")) { Integer progress = new Integer(evt.getNewValue().toString()); progressMonitor.setProgress(progress); } } }); task.execute(); }
From source file:org.tinymediamanager.ui.tvshows.TvShowMediaInformationPanel.java
/** * Instantiates a new tv show media information panel. * /*from www . ja va 2s . c o 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:com.vgi.mafscaling.Rescale.java
private void createControlPanel(JPanel dataPanel) { JPanel cntlPanel = new JPanel(); GridBagConstraints gbl_ctrlPanel = new GridBagConstraints(); gbl_ctrlPanel.insets = insets3;//from www.j a v a 2 s .c om gbl_ctrlPanel.anchor = GridBagConstraints.PAGE_START; gbl_ctrlPanel.fill = GridBagConstraints.HORIZONTAL; gbl_ctrlPanel.weightx = 1.0; gbl_ctrlPanel.gridx = 0; gbl_ctrlPanel.gridy = 0; dataPanel.add(cntlPanel, gbl_ctrlPanel); GridBagLayout gbl_cntlPanel = new GridBagLayout(); gbl_cntlPanel.columnWidths = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; gbl_cntlPanel.rowHeights = new int[] { 0, 0 }; gbl_cntlPanel.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 }; gbl_cntlPanel.rowWeights = new double[] { 0 }; cntlPanel.setLayout(gbl_cntlPanel); NumberFormat doubleFmt = NumberFormat.getNumberInstance(); doubleFmt.setGroupingUsed(false); doubleFmt.setMaximumIntegerDigits(1); doubleFmt.setMinimumIntegerDigits(1); doubleFmt.setMaximumFractionDigits(3); doubleFmt.setMinimumFractionDigits(1); doubleFmt.setRoundingMode(RoundingMode.HALF_UP); NumberFormat scaleDoubleFmt = NumberFormat.getNumberInstance(); scaleDoubleFmt.setGroupingUsed(false); scaleDoubleFmt.setMaximumIntegerDigits(1); scaleDoubleFmt.setMinimumIntegerDigits(1); scaleDoubleFmt.setMaximumFractionDigits(8); scaleDoubleFmt.setMinimumFractionDigits(1); scaleDoubleFmt.setRoundingMode(RoundingMode.HALF_UP); GridBagConstraints gbc_cntlPanelLabel = new GridBagConstraints(); gbc_cntlPanelLabel.anchor = GridBagConstraints.EAST; gbc_cntlPanelLabel.insets = new Insets(2, 3, 2, 1); gbc_cntlPanelLabel.gridx = 0; gbc_cntlPanelLabel.gridy = 0; GridBagConstraints gbc_cntlPanelInput = new GridBagConstraints(); gbc_cntlPanelInput.anchor = GridBagConstraints.WEST; gbc_cntlPanelInput.insets = new Insets(2, 1, 2, 3); gbc_cntlPanelInput.gridx = 1; gbc_cntlPanelInput.gridy = 0; cntlPanel.add(new JLabel("New Max V"), gbc_cntlPanelLabel); newMaxVFmtTextBox = new JFormattedTextField(doubleFmt); newMaxVFmtTextBox.setColumns(7); newMaxVFmtTextBox.addPropertyChangeListener("value", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { Object source = e.getSource(); if (source == newMaxVFmtTextBox) updateNewMafScale(); } }); cntlPanel.add(newMaxVFmtTextBox, gbc_cntlPanelInput); gbc_cntlPanelLabel.gridx += 2; cntlPanel.add(new JLabel("Min V"), gbc_cntlPanelLabel); minVFmtTextBox = new JFormattedTextField(doubleFmt); minVFmtTextBox.setColumns(7); minVFmtTextBox.addPropertyChangeListener("value", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { Object source = e.getSource(); if (source == minVFmtTextBox) updateNewMafScale(); } }); gbc_cntlPanelInput.gridx += 2; cntlPanel.add(minVFmtTextBox, gbc_cntlPanelInput); gbc_cntlPanelLabel.gridx += 2; cntlPanel.add(new JLabel("Max Unchanged"), gbc_cntlPanelLabel); maxVUnchangedFmtTextBox = new JFormattedTextField(doubleFmt); maxVUnchangedFmtTextBox.setColumns(7); maxVUnchangedFmtTextBox.addPropertyChangeListener("value", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { Object source = e.getSource(); if (source == maxVUnchangedFmtTextBox) updateNewMafScale(); } }); gbc_cntlPanelInput.gridx += 2; cntlPanel.add(maxVUnchangedFmtTextBox, gbc_cntlPanelInput); gbc_cntlPanelLabel.gridx += 2; cntlPanel.add(new JLabel("Mode deltaV"), gbc_cntlPanelLabel); modeDeltaVFmtTextBox = new JFormattedTextField(scaleDoubleFmt); modeDeltaVFmtTextBox.setColumns(7); modeDeltaVFmtTextBox.setEditable(false); modeDeltaVFmtTextBox.setBackground(new Color(210, 210, 210)); gbc_cntlPanelInput.gridx += 2; cntlPanel.add(modeDeltaVFmtTextBox, gbc_cntlPanelInput); }
From source file:au.org.ala.delta.editor.ui.ActionSetsDialog.java
private void exportDirectivesAndRun() { DeltaEditor editor = (DeltaEditor) Application.getInstance(); ExportController exportController = new ExportController(editor); exportController.begin(new PropertyChangeListener() { @Override// ww w. j av a 2s . c o m public void propertyChange(PropertyChangeEvent evt) { if ("done".equals(evt.getPropertyName())) { if (Boolean.TRUE.equals(evt.getNewValue())) { fireRunDirectiveFileAction(); } } } }); }
From source file:net.sourceforge.processdash.ev.ui.chart.AbstractEVChart.java
protected PropertyChangeListener getPropertyChangeNotifier() { return new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { propertyChangeNotify(evt);/*from ww w . j a v a 2s . co m*/ fireStateChanged(); } }; }
From source file:Provider.GoogleMapsStatic.TestUI.MySample.java
/** * @author Nazmul/*from ww w .j av a2 s . c o m*/ * @param hook * @return */ private SwingUIHookAdapter _initHook(SwingUIHookAdapter hook) { hook.enableRecieveStatusNotification(checkboxRecvStatus.isSelected()); hook.enableSendStatusNotification(checkboxSendStatus.isSelected()); hook.setProgressMessage(ttfProgressMsg.getText()); PropertyChangeListener listener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { SwingUIHookAdapter.PropertyList type = ProgressMonitorUtils.parseTypeFrom(evt); int progress = ProgressMonitorUtils.parsePercentFrom(evt); String msg = ProgressMonitorUtils.parseMessageFrom(evt); progressBar.setValue(progress); progressBar.setString(type.toString()); sout(msg); } }; hook.addRecieveStatusListener(listener); hook.addSendStatusListener(listener); hook.addUnderlyingIOStreamInterruptedOrClosed(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { sout(evt.getPropertyName() + " fired!!!"); } }); return hook; }
From source file:org.pentaho.di.ui.repository.repositoryexplorer.controllers.BrowseController.java
protected void createBindings() { shell = ((SwtDialog) document.getElementById("repository-explorer-dialog")).getShell(); folderTree = (XulTree) document.getElementById("folder-tree"); fileTable = (XulTree) document.getElementById("file-table"); if (!repositoryDirectory.isVisible()) { folderTree.setHiddenrootnode(true); } else {//w ww . j a v a 2s . c om folderTree.setHiddenrootnode(false); } BindingConvertor<List<?>, Boolean> checkIfMultipleItemsAreSelected = new BindingConvertor<List<?>, Boolean>() { @Override public Boolean sourceToTarget(List<?> value) { return value != null && value.size() == 1 && value.get(0) != null; } @Override public List<?> targetToSource(Boolean value) { return null; } }; bf.setBindingType(Binding.Type.ONE_WAY); bf.createBinding(fileTable, "selectedItems", "file-context-rename", "!disabled", checkIfMultipleItemsAreSelected); bf.createBinding(fileTable, "selectedItems", this, "selectedFileItems"); // begin PDI-3326 hack PropertyChangeListener childrenListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { fireRepositoryDirectoryChange(); } }; repositoryDirectory.addPropertyChangeListener("children", childrenListener); // end PDI-3326 hack directoryBinding = createDirectoryBinding(); // Bind the selected index from the folder tree to the list of repository objects in the file table. bf.setBindingType(Binding.Type.ONE_WAY); bf.createBinding(folderTree, "selectedItems", this, "selectedFolderItems"); bf.setBindingType(Binding.Type.ONE_WAY); selectedItemsBinding = bf.createBinding(this, "selectedRepoDirChildren", fileTable, "elements"); // bindings can be added here in subclasses doCreateBindings(); try { // Fires the population of the repository tree of folders. directoryBinding.fireSourceChanged(); } catch (Exception e) { // convert to runtime exception so it bubbles up through the UI throw new RuntimeException(e); } try { // Set the initial selected directory as the users home directory RepositoryDirectoryInterface homeDir = repository.getUserHomeDirectory(); int currentDir = 0; String[] homePath = homeDir == null ? null : homeDir.getPathArray(); if (homePath != null) { UIRepositoryDirectory tempRoot = repositoryDirectory; // Check to see if the first item in homePath is the root directory if (homePath.length > 0 && tempRoot.getName().equalsIgnoreCase(homePath[currentDir])) { if (homePath.length == 1) { // The home directory is home root setSelectedFolderItems(Arrays.asList(tempRoot)); } // We have used the first element. Increment to the next currentDir++; } // Traverse the tree until we find our destination for (; currentDir < homePath.length; currentDir++) { for (UIRepositoryObject uiObj : tempRoot) { if (uiObj instanceof UIRepositoryDirectory) { if (uiObj.getName().equalsIgnoreCase(homePath[currentDir])) { // We have a match. Let's move on to the next tempRoot = (UIRepositoryDirectory) uiObj; break; } } } } // If we have traversed as many directories as there are in the path, we have found the directory if (homePath.length == currentDir) { setSelectedFolderItems(Arrays.asList(tempRoot)); folderTree.setSelectedItems(this.selectedFolderItems); } } } catch (Exception e) { throw new RuntimeException(e); } }