List of usage examples for java.beans PropertyChangeListener PropertyChangeListener
PropertyChangeListener
From source file:com.openbravo.pos.sales.restaurant.JTicketsBagRestaurantRes.java
/** Creates new form JPanelReservations */ public JTicketsBagRestaurantRes(AppView oApp, JTicketsBagRestaurantMap restaurantmap) { this.m_App = oApp; m_restaurantmap = restaurantmap;// w ww.ja va 2 s . c om dlCustomers = (DataLogicCustomers) oApp.getBean("com.openbravo.pos.customers.DataLogicCustomers"); initComponents(); //m_timereservation = new JTimePanel(m_App, null, JTimePanel.BUTTONS_MINUTE); //m_jPanelTime.add(m_timereservation, BorderLayout.CENTER); txtCustomer.addEditorKeys(m_jKeys); m_jtxtChairs.addEditorKeys(m_jKeys); m_jtxtDescription.addEditorKeys(m_jKeys); m_Dirty = new DirtyManager(); txtCustomer.addPropertyChangeListener("Text", m_Dirty); txtCustomer.addPropertyChangeListener("Text", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { customer = new CustomerInfo(null); customer.setTaxid(null); customer.setSearchkey(null); customer.setName(txtCustomer.getText()); } }); m_jtxtChairs.addPropertyChangeListener("Text", m_Dirty); m_jtxtDescription.addPropertyChangeListener("Text", m_Dirty); m_jFromDate.getDocument().addDocumentListener(m_Dirty); m_jTillDate.getDocument().addDocumentListener(m_Dirty); writeValueEOF(); ListProvider lpr = new ListProviderCreator(dlCustomers.getReservationsList(), new MyDateFilter()); SaveProvider spr = new SaveProvider(dlCustomers.getReservationsUpdate(), dlCustomers.getReservationsInsert(), dlCustomers.getReservationsDelete()); m_bd = new BrowsableEditableData(lpr, spr, new CompareReservations(), this, m_Dirty); JListNavigator nl = new JListNavigator(m_App, m_bd, true); nl.setCellRenderer(new JCalendarItemRenderer(m_App)); m_jPanelList.add(nl, BorderLayout.CENTER); // La Toolbar m_jToolbar.add(new JLabelDirty(m_Dirty)); //m_jToolbar.add(new JCounter(m_bd)); m_jToolbar.add(new JNavigator(m_App, m_bd, -1, null)); m_jToolbar.add(new JSaver(m_App, m_bd)); // m_jKeys.ScaleButtons(); ScaleButtons(); }
From source file:uk.ac.lkl.cram.ui.chart.HoursChartMaker.java
/** * Create a dataset from the module/*ww w . ja v a2 s. c om*/ * @return a category dataset that is used to produce a stacked bar chart */ @Override protected CategoryDataset createDataSet() { //Create a dataset to hold the data final DefaultCategoryDataset categoryDataset = new DefaultCategoryDataset(); //populate the dataset with the data populateDataset(categoryDataset, module); //Create a listener, which repopulates the dataset when anything changes final PropertyChangeListener presentationListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent pce) { //LOGGER.info("event propertyName: " + pce.getPropertyName() + " newValue: " + pce.getNewValue()); populateDataset(categoryDataset, module); } }; //Add the listener to each of the module presentations for (ModulePresentation modulePresentation : module.getModulePresentations()) { //Listen for when the number of home or overseas students changes //This means when the number of home or overseas students changes, the dataset will be repopulated modulePresentation.addPropertyChangeListener(ModulePresentation.PROP_HOME_STUDENT_COUNT, presentationListener); modulePresentation.addPropertyChangeListener(ModulePresentation.PROP_OVERSEAS_STUDENT_COUNT, presentationListener); //Add the listener to the support time and preparation time of //each of the module's tlaLineItems, for each presentation //This means that whenever a support time or a preparation time changes, //or its activity changes, the listener is triggered //Causing the dataset to be repopulated //Also add the listener to the activity for the tlaLineItem so that //when the tutor group size changes, the chart is updated for (TLALineItem lineItem : module.getTLALineItems()) { //LOGGER.info("adding listener to : " + lineItem.getName()); SupportTime st = lineItem.getSupportTime(modulePresentation); st.addPropertyChangeListener(presentationListener); PreparationTime pt = lineItem.getPreparationTime(modulePresentation); pt.addPropertyChangeListener(presentationListener); lineItem.getActivity().addPropertyChangeListener(TLActivity.PROP_MAX_GROUP_SIZE, presentationListener); } //Add the listener to the support time of each of the module's //module line items, for each presentation for (ModuleLineItem lineItem : module.getModuleItems()) { //LOGGER.info("adding listener to : " + lineItem.getName()); SupportTime st = lineItem.getSupportTime(modulePresentation); st.addPropertyChangeListener(presentationListener); } } //Add a listener to the module, listening for changes where a tlaLineItem is added or removed module.addPropertyChangeListener(Module.PROP_TLA_LINEITEM, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent pce) { //A tlaLineItem has been added or removed if (pce instanceof IndexedPropertyChangeEvent) { //LOGGER.info("indexed change: " + pce); if (pce.getOldValue() != null) { //This has been removed TLALineItem lineItem = (TLALineItem) pce.getOldValue(); //So remove the listener from the preparation and support time //for each presentation of this line item //LOGGER.info("removing listeners from: " + lineItem.getName()); for (ModulePresentation modulePresentation : module.getModulePresentations()) { SupportTime st = lineItem.getSupportTime(modulePresentation); st.removePropertyChangeListener(presentationListener); PreparationTime pt = lineItem.getPreparationTime(modulePresentation); pt.removePropertyChangeListener(presentationListener); } //Also remove the listener from the activity lineItem.removePropertyChangeListener(TLActivity.PROP_MAX_GROUP_SIZE, presentationListener); } if (pce.getNewValue() != null) { //This has been added TLALineItem lineItem = (TLALineItem) pce.getNewValue(); //So add the listener to the preparation and support time //For each presentation of this line item //LOGGER.info("adding listeners to: " + lineItem); for (ModulePresentation modulePresentation : module.getModulePresentations()) { SupportTime st = lineItem.getSupportTime(modulePresentation); st.addPropertyChangeListener(presentationListener); PreparationTime pt = lineItem.getPreparationTime(modulePresentation); pt.addPropertyChangeListener(presentationListener); } //Also add the listener to the activity lineItem.addPropertyChangeListener(TLActivity.PROP_MAX_GROUP_SIZE, presentationListener); } } //Assume the dataset is now out of date populateDataset(categoryDataset, module); } }); //Do the same as above for module line items module.addPropertyChangeListener(Module.PROP_MODULE_LINEITEM, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent pce) { if (pce instanceof IndexedPropertyChangeEvent) { //LOGGER.info("indexed change: " + pce); if (pce.getOldValue() != null) { //This has been removed ModuleLineItem lineItem = (ModuleLineItem) pce.getOldValue(); //LOGGER.info("removing listeners from: " + lineItem.getName()); for (ModulePresentation modulePresentation : module.getModulePresentations()) { SupportTime st = lineItem.getSupportTime(modulePresentation); st.removePropertyChangeListener(presentationListener); } } if (pce.getNewValue() != null) { //This has been added ModuleLineItem lineItem = (ModuleLineItem) pce.getNewValue(); //LOGGER.info("adding listeners to: " + lineItem); for (ModulePresentation modulePresentation : module.getModulePresentations()) { SupportTime st = lineItem.getSupportTime(modulePresentation); st.addPropertyChangeListener(presentationListener); } } } populateDataset(categoryDataset, module); } }); //Add the listner to be triggered if the tutor group size of the module changes module.addPropertyChangeListener(Module.PROP_GROUP_SIZE, presentationListener); return categoryDataset; }
From source file:misc.TrackFocusDemo.java
public TrackFocusDemo() { super(new BorderLayout()); JPanel mugshots = new JPanel(new GridLayout(2, 3)); pic1 = new Picture(createImageIcon("images/" + mayaString + ".jpg", mayaString).getImage()); pic1.setName("1"); mugshots.add(pic1);//from w w w . j a va 2s . c o m pic2 = new Picture(createImageIcon("images/" + anyaString + ".jpg", anyaString).getImage()); pic2.setName("2"); mugshots.add(pic2); pic3 = new Picture(createImageIcon("images/" + laineString + ".jpg", laineString).getImage()); pic3.setName("3"); mugshots.add(pic3); pic4 = new Picture(createImageIcon("images/" + cosmoString + ".jpg", cosmoString).getImage()); pic4.setName("4"); mugshots.add(pic4); pic5 = new Picture(createImageIcon("images/" + adeleString + ".jpg", adeleString).getImage()); pic5.setName("5"); mugshots.add(pic5); pic6 = new Picture(createImageIcon("images/" + alexiString + ".jpg", alexiString).getImage()); pic6.setName("6"); mugshots.add(pic6); info = new JLabel("Nothing selected"); setPreferredSize(new Dimension(450, 350)); add(mugshots, BorderLayout.CENTER); add(info, BorderLayout.PAGE_END); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); focusManager.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (("focusOwner".equals(prop)) && ((e.getNewValue()) instanceof Picture)) { Component comp = (Component) e.getNewValue(); String name = comp.getName(); Integer num = new Integer(name); int index = num.intValue(); if (index < 0 || index > comments.length) { index = 0; } info.setText(comments[index]); } } }); }
From source file:blue.automation.AutomationManager.java
private AutomationManager() { parameterActionListener = new ActionListener() { public void actionPerformed(ActionEvent ae) { if (data == null || selectedSoundLayer == null) { return; }//from w ww . j ava 2s. c o m JMenuItem menuItem = (JMenuItem) ae.getSource(); Parameter param = (Parameter) menuItem.getClientProperty("param"); parameterSelected(selectedSoundLayer, param); selectedSoundLayer = null; } }; renderTimeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent pce) { if (pce.getSource() == data) { if (pce.getPropertyName().equals("renderStartTime")) { updateValuesFromAutomations(); } } } }; }
From source file:de.tudarmstadt.ukp.clarin.webanno.webapp.standalone.StandaloneShutdownDialog.java
private void displayShutdownDialog() { String serverId = ServerDetector.getServerId(); log.info("Running in: " + (serverId != null ? serverId : "unknown server")); log.info("Console: " + ((System.console() != null) ? "available" : "not available")); log.info("Headless: " + (GraphicsEnvironment.isHeadless() ? "yes" : "no")); // Show this only when run from the standalone JAR via a double-click if (System.console() == null && !GraphicsEnvironment.isHeadless() && ServerDetector.isWinstone()) { log.info("If you are running WebAnno in a server environment, please use '-Djava.awt.headless=true'"); EventQueue.invokeLater(new Runnable() { @Override/*from ww w .j a v a 2 s.co m*/ public void run() { final JOptionPane optionPane = new JOptionPane(new JLabel( "<HTML>WebAnno is running now and can be accessed via <a href=\"http://localhost:8080\">http://localhost:8080</a>.<br>" + "WebAnno works best with the browsers Google Chrome or Safari.<br>" + "Use this dialog to shut WebAnno down.</HTML>"), JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_OPTION, null, new String[] { "Shutdown" }); final JDialog dialog = new JDialog((JFrame) null, "WebAnno", true); dialog.setContentPane(optionPane); dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); dialog.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent we) { // Avoid closing window by other means than button } }); optionPane.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent aEvt) { if (dialog.isVisible() && (aEvt.getSource() == optionPane) && (aEvt.getPropertyName().equals(JOptionPane.VALUE_PROPERTY))) { System.exit(0); } } }); dialog.pack(); dialog.setVisible(true); } }); } else { log.info("Running in server environment or from command line: disabling interactive shutdown dialog."); } }
From source file:MainWindow.java
public MainWindow() { // Login Routine loginDialog = new LoginDialog(); // loginDialog.nameField.setText("cornelius.preidel@googlemail.com"); // loginDialog.passwordField.setText("germany"); loginDialog.setSize(400, 150);/*from ww w.j a v a2s . c o m*/ loginDialog.setModal(true); loginDialog.setLocationRelativeTo(null); loginDialog.setVisible(true); // Get the connected ApiCore core = loginDialog._core; // Init the UI mainFrame = new JFrame("MainApplication"); mainFrame.setSize(500, 500); mainFrame.setLocationRelativeTo(null); mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainFrame.setLayout(new GridLayout(5, 1)); // WebProjectsList webprojectlist = new WebProjectsList(core); // mainFrame.add(webprojectlist); // Create the APIS Teams teamsAPI = new Teams(core); final Projects projectsAPI = new Projects(core); final Divisions divisionsAPI = new Divisions(core); final Attachments attachmentAPI = new Attachments(core); final Issues issueAPI = new Issues(core); // TEAMS List TeamsList teamList = new TeamsList(); teamList.setTeams(teamsAPI.GetTeams()); mainFrame.add(teamList); // PROJECTS List projectsList = new ProjectsList(); mainFrame.add(projectsList); // DIVISIONS List divisionsList = new DivisionsList(); // mainFrame.add(divisionsList); // DIVISIONS Table divisionsTable = new DivisionsTable(core); mainFrame.add(divisionsTable); // Attachments attachmentsList = new AttachmentsList(); mainFrame.add(attachmentsList); // Attachments issuesList = new IssuesList(); mainFrame.add(issuesList); PropertyChangeListener propertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { String property = propertyChangeEvent.getPropertyName(); if ("selectedTeam".equals(property)) { DtoTeam selectedTeam = (DtoTeam) propertyChangeEvent.getNewValue(); // Set the global slug core.currentTeam = selectedTeam; projectsList.setProjects(projectsAPI.GetProjects()); } else if ("selectedProject".equals(property)) { DtoProject selectedProject = (DtoProject) propertyChangeEvent.getNewValue(); // Divisions divisionsList.setDivisions(divisionsAPI.GetDivisions(selectedProject.GetId())); divisionsTable.setDivisions(divisionsAPI.GetDivisions(selectedProject.GetId())); // Attachments attachmentsList.setAttachments(attachmentAPI.GetAttachments(selectedProject.GetId())); // Issues issuesList.setIssues(issueAPI.GetIssues(selectedProject.GetId())); } else if ("selectedDivision".equals(property)) { DtoDivision selectedDivision = (DtoDivision) propertyChangeEvent.getNewValue(); // What to do with the division? } else if ("selectedIssue".equals(property)) { DtoIssue selectedDivision = (DtoIssue) propertyChangeEvent.getNewValue(); // What to do with the division? } else { if ("selectedAttachment".equals(property)) { DtoAttachment selectedAttachment = (DtoAttachment) propertyChangeEvent.getNewValue(); InputStream stream = attachmentAPI.DownloadAttachment(selectedAttachment.GetId()); try { byte[] bytes = IOUtils.toByteArray(stream); JFileChooser chooser = new JFileChooser(); int returnVal = chooser.showSaveDialog(chooser); File file = chooser.getSelectedFile(); FileOutputStream fos = new FileOutputStream(file); fos.write(bytes); fos.flush(); fos.close(); } catch (IOException e) { LOG.error(e.getMessage(), e); } } } } }; // Add Listener teamList.addPropertyChangeListener(propertyChangeListener); projectsList.addPropertyChangeListener(propertyChangeListener); divisionsList.addPropertyChangeListener(propertyChangeListener); divisionsTable.addPropertyChangeListener(propertyChangeListener); attachmentsList.addPropertyChangeListener(propertyChangeListener); issuesList.addPropertyChangeListener(propertyChangeListener); }
From source file:com.jaxzin.iraf.forecast.swing.JForecaster.java
@SuppressWarnings({ "FieldRepeatedlyAccessedInMethod" }) private void initialize() { // final GridBagLayout gridbag = new GridBagLayout(); setLayout(new GridBagLayout());//new BoxLayout(this, BoxLayout.PAGE_AXIS)); controlPanel = new JForecasterControl(domain); final JFreeChart chart = createJFreeChart(); final JPanel chartPanel = new ChartPanel(chart, true); final GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.weighty = 1.0;//from w w w .ja v a 2 s. c o m c.gridx = 0; c.gridy = 0; // gridbag.setConstraints(chartPanel, c); add(chartPanel, c); // todo: change to changelistener of JControlPanel domain.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent e) { chart.getXYPlot().setDataset(createDataset()); //noinspection CallToStringEquals if ("adjustForInflation".equals(e.getPropertyName())) { final String label; if (domain.isAdjustForInflation()) { label = "Account Value (Adjusted to Today's Value)"; } else { label = "Account Value"; } logAxis.setLabel(label); linearAxis.setLabel(label); } } }); controlPanel.addPropertyChangeListener("logScale", new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent e) { if (controlPanel.isLogScale()) { chart.getXYPlot().setRangeAxis(logAxis); } else { chart.getXYPlot().setRangeAxis(linearAxis); } } }); c.weighty = 0.0; c.gridx = 0; c.gridy = 1; c.anchor = GridBagConstraints.SOUTH; // gridbag.setConstraints(controlPanel, c1); add(controlPanel, c); }
From source file:ec.ui.view.AutoCorrelationsView.java
private void enableProperties() { addPropertyChangeListener(new PropertyChangeListener() { @Override/* w ww. ja va2 s . c o m*/ public void propertyChange(PropertyChangeEvent evt) { switch (evt.getPropertyName()) { case LENGTH_PROPERTY: onDataChange(); break; case KIND_PROPERTY: onDataChange(); break; case MEAN_CORRECTION_PROPERTY: onDataChange(); break; case AUTO_CORRELATIONS_PROPERTY: onDataChange(); break; case "componentPopupMenu": onComponentPopupMenuChange(); break; } } }); }
From source file:de.metas.procurement.webui.ui.view.DailyReportingView.java
public DailyReportingView() { super();//from w w w . ja v a 2 s . c o m addStyleName(STYLE); // // Top { final NavigationBar navigationBar = getNavigationBar(); navigationBar.setCaption(i18n.get("DailyReportingView.caption")); final NavigationButton logoutButton = new NavigationButton(i18n.get("Logout.caption")); logoutButton.setTargetView(this); logoutButton.addClickListener(new NavigationButtonClickListener() { @Override public void buttonClick(final NavigationButtonClickEvent event) { onLogout(); } }); navigationBar.setRightComponent(logoutButton); } // // Content { final VerticalLayout content = new VerticalLayout(); // Date { datePanel = new DateNavigation(); 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<ProductQtyReport>() { @Override protected Component createItemComponent(final BeanItem<ProductQtyReport> item) { final ProductItemButton itemComp = new ProductItemButton(); itemComp.setItem(item); return itemComp; }; }; content.addComponent(productButtons); setContent(content); } // // Toolbar (bottom) { final Button weekViewButton = new Button(i18n.get("DailyReportingView.weekViewButton")); weekViewButton.setStyleName("no-decoration"); weekViewButton.setIcon(FontAwesome.CALENDAR); weekViewButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { onWeekView(); } }); final Button addProductButton = new Button(i18n.get("DailyReportingView.addProductButton")); addProductButton.setStyleName("no-decoration"); addProductButton.setIcon(FontAwesome.PLUS); addProductButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { onProductAdd(); } }); final Button rfqButton = new Button(i18n.get("DailyReportingView.rfqButton")); rfqButton.setStyleName("no-decoration"); rfqButton.setIcon(FontAwesome.MONEY); rfqButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { onRfQ(); } }); final ISendService sendService = MFProcurementUI.getCurrentMFSession().getSendService(); final Button sendButton = new Button(i18n.get("DailyReportingView.sendButton")); sendButton.setStyleName("no-decoration"); sendButton.setIcon(FontAwesome.CHECK); final TextOverlay sendButtonOverlay = TextOverlay.extend(sendButton); sendButtonOverlay.setPropertyDataSource(sendService.getNotSentCounterProperty()); sendButtonOverlay.setConverter(TextOverlay.CONVERTER_PositiveCounterOrNull); sendButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { onSend(); } }); final Button infoButton = new Button(i18n.getWithDefault("InfoMessageView.caption.short", "Info")); infoButton.setStyleName("no-decoration"); infoButton.setIcon(FontAwesome.INFO); infoButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { onInfo(); } }); final Toolbar toolbar = new Toolbar(); toolbar.addComponents(weekViewButton, addProductButton, sendButton, infoButton, rfqButton); setToolbar(toolbar); } // // Initialize final Date today = DateUtils.getToday(); final Date date = DateUtils.addDays(today, +1); // tomorrow (FRESH-196) datePanel.setDate(date); }