List of usage examples for java.beans PropertyChangeListener PropertyChangeListener
PropertyChangeListener
From source file:com.emr.schemas.SavedProcessesDataMover.java
/** * Constructor//www.ja va 2s .c o m */ public SavedProcessesDataMover() { initComponents(); this.setClosable(true); final Action processDelete = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { JTable table = (JTable) e.getSource(); int modelRow = Integer.valueOf(e.getActionCommand()); String foreignKeysTable = (String) tblProcesses.getModel().getValueAt(modelRow, 0); if (foreignKeysTable == null || "".equals(foreignKeysTable)) { JOptionPane.showMessageDialog(null, "Table is Empty", "Empty Table", JOptionPane.ERROR_MESSAGE); } else { } } }; final SQLiteGetProcesses sp = new SQLiteGetProcesses(); sp.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { switch (event.getPropertyName()) { case "progress": System.out.println("Fetching data from db"); break; case "state": switch ((SwingWorker.StateValue) event.getNewValue()) { case DONE: try { model = sp.get(); tblProcesses.setModel(model); tblProcesses.getColumnModel().getColumn(0).setMaxWidth(300); //hide irrelevant columns tblProcesses.getColumnModel().getColumn(2).setMinWidth(0); tblProcesses.getColumnModel().getColumn(2).setMaxWidth(0); tblProcesses.getColumnModel().getColumn(3).setMinWidth(0); tblProcesses.getColumnModel().getColumn(3).setMaxWidth(0); tblProcesses.getColumnModel().getColumn(4).setMinWidth(0); tblProcesses.getColumnModel().getColumn(4).setMaxWidth(0); tblProcesses.getColumnModel().getColumn(5).setMinWidth(0); tblProcesses.getColumnModel().getColumn(5).setMaxWidth(0); tblProcesses.getColumnModel().getColumn(6).setMinWidth(0); tblProcesses.getColumnModel().getColumn(6).setMaxWidth(0); ButtonColumn buttonColumn = new ButtonColumn(tblProcesses, processDelete, 7, "Delete"); } catch (final CancellationException ex) { Logger.getLogger(SavedProcessesDataMover.class.getName()).log(Level.SEVERE, null, ex); } catch (InterruptedException ex) { Logger.getLogger(SavedProcessesDataMover.class.getName()).log(Level.SEVERE, null, ex); } catch (ExecutionException ex) { Logger.getLogger(SavedProcessesDataMover.class.getName()).log(Level.SEVERE, null, ex); } break; } break; } } }); sp.execute(); tblProcesses.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { JTable target = (JTable) e.getSource(); int rowIndex = target.getSelectedRow(); String selectQry = (String) target.getModel().getValueAt(rowIndex, 2); String destinationTable = (String) target.getModel().getValueAt(rowIndex, 3); String truncateFirst = (String) target.getModel().getValueAt(rowIndex, 4); String destinationColumns = (String) target.getModel().getValueAt(rowIndex, 5); String columnsToBeMapped = (String) target.getModel().getValueAt(rowIndex, 6); lblUpdateText.setText("<html><b color='red'>Moving Data</b></html>"); dbProgressBar.setIndeterminate(true); new DBUpdater(selectQry, destinationTable, truncateFirst, destinationColumns, columnsToBeMapped) .execute(); } } @Override public void mousePressed(MouseEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void mouseReleased(MouseEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void mouseEntered(MouseEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void mouseExited(MouseEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); }
From source file:com.example.app.ui.PictureEditor.java
/** * Create an instance.// w ww . j a v a 2 s . co m */ public PictureEditor() { super(); addClassName("prop"); _picture.setImageCaching(false); _fileField.setAccept("image/*"); _fileField.addPropertyChangeListener(FileField.PROP_FILE_ITEMS, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { @SuppressWarnings("unchecked") final List<FileItem> files = (List<FileItem>) evt.getNewValue(); if (files != null && files.size() > 0) { _uiValue = files.get(0); _picture.setImage(new Image(_uiValue)); _modified = true; } _fileField.resetFile(); } }); _defaultProfilePicture = _classPathResourceLibraryHelper .createResource(_classPathResourceLibraryHelper.createLibrary("default-profile-picture.png")); }
From source file:org.gitools.ui.app.heatmap.panel.details.boxes.HeatmapInfoBox.java
@Override public void registerListeners() { PropertyChangeListener dimensionListener = new PropertyChangeListener() { @Override/*from w ww. j a v a 2s . c om*/ public void propertyChange(PropertyChangeEvent evt) { if ((isAny(evt, HeatmapDimension.class, PROPERTY_HEADERS, PROPERTY_VISIBLE))) { update(); } } }; getHeatmap().addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { update(); } }); getHeatmap().getRows().addPropertyChangeListener(dimensionListener); getHeatmap().getColumns().addPropertyChangeListener(dimensionListener); }
From source file:org.drugis.addis.presentation.wizard.AbstractAnalysisWizardPresentation.java
public AbstractAnalysisWizardPresentation(Domain d, final List<Analysis> categoryContents) { d_domain = d;//from w ww . j a va 2s . c o m d_categoryContents = categoryContents; d_indicationHolder = new ModifiableHolder<Indication>(); d_name = new ModifiableHolder<String>(); d_name.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { NameEqualsPredicate pred = new NameEqualsPredicate(d_name.getValue()); d_nameValidModel.setValue(getNameModel().getValue() != null && !getNameModel().getValue().isEmpty() && CollectionUtils.find(categoryContents, pred) == null); } }); d_nameValidModel = new ModifiableHolder<Boolean>(false); }
From source file:com.diversityarrays.kdxplore.vistool.VisToolbarFactory.java
static public VisToolToolBar create(final String title, final JComponent comp, final Closure<File> snapshotter, final VisToolDataProvider visToolDataProvider, boolean floatable, final String[] imageSuffixes) { Window window = GuiUtil.getOwnerWindow(comp); boolean anyButtons = false; final JCheckBox keepOnTop; if (window == null) { keepOnTop = null;/*from ww w . ja v a 2s . c o m*/ } else { anyButtons = true; keepOnTop = new JCheckBox(Msg.OPTION_KEEP_ON_TOP(), true); keepOnTop.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { window.setAlwaysOnTop(keepOnTop.isSelected()); } }); window.setAlwaysOnTop(keepOnTop.isSelected()); // buttons.add(keepOnTop); final PropertyChangeListener alwaysOnTopListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { keepOnTop.setSelected(window.isAlwaysOnTop()); } }; window.addPropertyChangeListener(PROPERTY_ALWAYS_ON_TOP, alwaysOnTopListener); window.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { window.removeWindowListener(this); window.removePropertyChangeListener(PROPERTY_ALWAYS_ON_TOP, alwaysOnTopListener); } }); } final JButton cameraButton; if (snapshotter == null) { cameraButton = null; } else { Action cameraAction = new AbstractAction(Msg.ACTION_SNAPSHOT()) { @Override public void actionPerformed(ActionEvent e) { if (chooser == null) { chooser = new JFileChooser(); chooser.setFileFilter(new FileFilter() { @Override public boolean accept(File f) { if (!f.isFile()) { return true; } String loname = f.getName().toLowerCase(); for (String sfx : imageSuffixes) { if (loname.endsWith(sfx)) { return true; } } return false; } @Override public String getDescription() { return Msg.DESC_IMAGE_FILE(); } }); chooser.setMultiSelectionEnabled(false); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); } if (JFileChooser.APPROVE_OPTION == chooser.showSaveDialog(comp)) { File file = chooser.getSelectedFile(); snapshotter.execute(file); } } }; ImageIcon icon = loadIcon("camera-24.png"); //$NON-NLS-1$ if (icon != null) { cameraAction.putValue(Action.SMALL_ICON, icon); cameraAction.putValue(Action.NAME, null); } anyButtons = true; cameraButton = new JButton(cameraAction); } final JButton refreshButton; if (visToolDataProvider == null) { refreshButton = null; } else { anyButtons = true; refreshButton = new JButton(Msg.ACTION_REFRESH()); ImageIcon icon = loadIcon("refresh-24.png"); //$NON-NLS-1$ if (icon != null) { refreshButton.setIcon(icon); // don't remove the name } refreshButton.setForeground(Color.RED); refreshButton.setEnabled(false); refreshButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (visToolDataProvider.refreshData()) { refreshButton.setEnabled(false); } } }); visToolDataProvider.addVisToolDataChangedListener(new VisToolDataChangedListener() { @Override public void visToolDataChanged(Object source) { refreshButton.setEnabled(true); } }); } VisToolToolBar toolBar = null; if (anyButtons) { toolBar = new VisToolToolBar(keepOnTop, cameraButton, refreshButton); toolBar.setFloatable(floatable); } return toolBar; }
From source file:de.metas.procurement.webui.ui.view.WeeklyReportingView.java
public WeeklyReportingView(final Date date) { super();/* w w w .j a va 2 s . c om*/ addStyleName(STYLE); final NavigationBar navigationBar = getNavigationBar(); navigationBar.setCaption(i18n.get("WeeklyReportingView.caption")); // // Content { final VerticalLayout content = new VerticalLayout(); // Date { datePanel = new DateNavigation(); datePanel.setDateHandler(DateNavigation.DATEHANDLER_Week); datePanel.addDateChangedListener(new PropertyChangeListener() { @Override public void propertyChange(final PropertyChangeEvent evt) { onDayChanged(datePanel.getDate()); } }); final VerticalComponentGroup datePanelGroup = new VerticalComponentGroup(); datePanelGroup.addComponent(datePanel); content.addComponent(datePanelGroup); } // Product buttons productButtons = new BeansVerticalComponentGroup<WeekProductQtyReport>() { @Override protected Component createItemComponent(final BeanItem<WeekProductQtyReport> item) { final ProductItemButton itemComp = new ProductItemButton(); itemComp.setItem(item); return itemComp; }; }; content.addComponent(productButtons); setContent(content); } // // Toolbar (bottom) { } // // Load datePanel.setDate(date); }
From source file:com.emr.schemas.SchemerMapper.java
/** * Constructor// www . j a va 2s .c o m * @param emrConn {@link Connection} Connection to the EMR database * @param emrDbName {@link String} Database name */ public SchemerMapper(Connection emrConn, String emrDbName) { this.emrConn = emrConn; this.emrDbName = emrDbName; listModel = new DefaultListModel<String>(); initComponents(); this.setClosable(true); SourceTablesListener listSelectionListener = new SourceTablesListener(txtSelectedTables, listOfTables); sourceTablesList.setCellRenderer(new CheckboxListCellRenderer()); sourceTablesList.addListSelectionListener(listSelectionListener); sourceTablesList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); sourceTablesList.setSelectionModel(new DefaultListSelectionModel() { @Override public void setSelectionInterval(int index0, int index1) { if (isSelectedIndex(index0)) super.removeSelectionInterval(index0, index1); else super.addSelectionInterval(index0, index1); } }); //getDatabaseMetaData(); final ListUpdater lu = new ListUpdater(); lu.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { switch (event.getPropertyName()) { case "progress": System.out.println("Fetching data from db"); break; case "state": switch ((SwingWorker.StateValue) event.getNewValue()) { case DONE: try { listModel = lu.get(); sourceTablesList.setModel(listModel); } catch (final CancellationException ex) { Logger.getLogger(SourceDataPreview.class.getName()).log(Level.SEVERE, null, ex); } catch (InterruptedException ex) { Logger.getLogger(SourceDataPreview.class.getName()).log(Level.SEVERE, null, ex); } catch (ExecutionException ex) { Logger.getLogger(SourceDataPreview.class.getName()).log(Level.SEVERE, null, ex); } break; } break; } } }); lu.execute(); }
From source file:org.yccheok.jstock.gui.analysis.ObjectInspectorJPanel.java
/** Creates a new instance of ObjectInspectorJPanel */ public ObjectInspectorJPanel(Object bean) { this.bean = bean; BeanInfo beanInfo = null;/* w ww. j a v a2 s. c o m*/ try { beanInfo = Introspector.getBeanInfo(bean.getClass()); } catch (IntrospectionException exp) { log.error(null, exp); } this.getTable().setEditorFactory(new PropertyEditorRegistryEx()); PropertyEditorRegistry editor = (PropertyEditorRegistry) this.getTable().getEditorFactory(); PropertyRendererRegistry renderer = (PropertyRendererRegistry) this.getTable().getRendererFactory(); editor.registerEditor(Enum.class, new EnumComboBoxPropertyEditor()); DefaultCellRenderer r = new DefaultCellRenderer(); r.setShowOddAndEvenRows(false); renderer.registerRenderer(Enum.class, r); this.setMode(PropertySheet.VIEW_AS_FLAT_LIST); this.setToolBarVisible(false); this.setDescriptionVisible(false); this.setToolBarVisible(true); this.setBeanInfo(beanInfo); Property[] properties = this.getProperties(); for (int i = 0, c = properties.length; i < c; i++) { properties[i].readFromObject(bean); } PropertyChangeListener listener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { Property prop = (Property) evt.getSource(); prop.writeToObject(ObjectInspectorJPanel.this.bean); } }; this.addPropertySheetChangeListener(listener); }
From source file:pe.gob.sunat.tecnologia3.arquitectura.framework.desktop.core.LoginForm.java
private void actionListeners() { cancel.addActionListener(new ActionListener() { @Override//from www . jav a2s. c om public void actionPerformed(ActionEvent event) { log.log(Level.INFO, "Boton::: cancel "); exit(); } }); ok.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { LoginController controller = (LoginController) jfxPanel.getController(); String mensajeError = controller.autenticacionFx(); if (mensajeError != null) { mostrarMensajeError(mensajeError); // controller.setLabelUser(mensajeError); } else { mensajeError = LoginSeguridad.autenticacionSeguridad(getUsuarioPrincipal(controller)); if (StringUtils.isNotBlank(mensajeError)) { mostrarMensajeError(mensajeError); } } } }); this.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (NotifyDescriptor.CLOSED_OPTION.equals(evt.getNewValue())) { exit(); } } }); }