List of usage examples for java.beans PropertyChangeListener PropertyChangeListener
PropertyChangeListener
From source file:org.drugis.addis.presentation.wizard.NetworkMetaAnalysisWizardPM.java
public NetworkMetaAnalysisWizardPM(Domain d, PresentationModelFactory pmf) { super(d, d.getMetaAnalyses()); d_pmf = pmf;// w w w .ja v a 2s . c o m d_outcomeHolder = new ModifiableHolder<OutcomeMeasure>(); d_indicationHolder.addPropertyChangeListener(new ClearValueModelsOnPropertyChangeListener(d_outcomeHolder)); updateOutcomes(); d_indicationHolder.addValueChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { updateOutcomes(); } }); d_studiesEndpointIndication = createStudiesIndicationOutcome(); d_studiesEndpointIndication.addListDataListener(new IndifferentListDataListener() { protected void update() { d_rebuildRawNeeded = true; } }); d_rawTreatmentDefinitions = new ArrayListModel<TreatmentDefinition>(); d_rawAlternativesGraph = buildRawAlternativesGraph(); d_refinedTreatmentDefinitions = new ArrayListModel<TreatmentDefinition>(); d_refinedAlternativesGraph = buildRefinedAlternativesGraph(); getSelectedRefinedTreatmentDefinitions().addListDataListener(new IndifferentListDataListener() { protected void update() { d_armSelectionRebuildNeeded = true; } }); d_studiesMeasuringValueModel = new StudiesMeasuringValueModel(); d_selectedArms = new HashMap<Study, Map<TreatmentDefinition, ModifiableHolder<Arm>>>(); d_selectableStudyListPm = createSelectableStudyListPm(); d_overviewGraph = new TreatmentDefinitionsGraphModel(getSelectedStudies(), getSelectedRefinedTreatmentDefinitions(), getOutcomeMeasureModel()); d_selectedStudyGraphConnectedModel = new StudySelectionCompleteListener(); }
From source file:tufts.vue.action.ActionUtil.java
public static File selectFile(String title, final String fileType) { File picked = null;//from w w w. j a v a 2 s . c o m saveChooser = VueFileChooser.getVueFileChooser(); saveChooser.setDialogTitle(title); saveChooser.setAcceptAllFileFilterUsed(false); //chooser.set if (fileType != null && !fileType.equals("export")) saveChooser.setFileFilter(new VueFileFilter(fileType)); else if (fileType != null && fileType.equals("export")) { saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.JPEG_DESCRIPTION)); saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.PNG_DESCRIPTION)); saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.SVG_DESCRIPTION)); saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.IMS_DESCRIPTION)); saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.IMAGEMAP_DESCRIPTION)); // chooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.ZIP_DESCRIPTION)); } else { VueFileFilter defaultFilter = new VueFileFilter(VueFileFilter.VUE_DESCRIPTION); saveChooser.addChoosableFileFilter(defaultFilter); saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.VPK_DESCRIPTION)); //SIMILE chooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.SIMILE_DESCRIPTION)); saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.IMAGEMAP_DESCRIPTION)); saveChooser.addChoosableFileFilter(new VueFileFilter("PDF")); saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.JPEG_DESCRIPTION)); saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.PNG_DESCRIPTION)); saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.SVG_DESCRIPTION)); //chooser.addChoosableFileFilter(new VueFileFilter("html")); saveChooser.addChoosableFileFilter(new VueFileFilter("RDF")); saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.IMS_DESCRIPTION)); // chooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.ZIP_DESCRIPTION)); //chooser.addChoosableFileFilter(new VueFileFilter("HTML Outline", "htm")); saveChooser.setFileFilter(defaultFilter); } saveChooser.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent arg0) { if (arg0.getPropertyName() == VueFileChooser.FILE_FILTER_CHANGED_PROPERTY) { adjustExtension(); } } }); adjustExtension(); int option = saveChooser.showSaveDialog(VUE.getDialogParentAsFrame());//, VueResources.getString("dialog.save.title")); if (option == VueFileChooser.APPROVE_OPTION) { picked = saveChooser.getSelectedFile(); String fileName = picked.getAbsolutePath(); /** * 2009-10-16 There was a bug in here that sliced up the filename, I think removing this block * of code should fix the issue. If you had a name like Object.Generic-Tufts, VUE would get * all confused and put files in the wrong directory or make a file called Object the filename * slicing seemed unnecessary. -MK * */ String extension = ((VueFileFilter) saveChooser.getFileFilter()).getExtensions()[0]; //if it isn't a file name with the right extension if (!picked.getName().endsWith("." + extension)) { fileName += "." + extension; picked = new File(fileName); } if (picked.exists()) { int n = VueUtil.confirm(null, VueResources.getString("replaceFile.text") + " \'" + picked.getName() + "\'", VueResources.getString("replaceFile.title"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (n == JOptionPane.NO_OPTION) { picked = null; saveChooser.showDialog(VUE.getDialogParentAsFrame(), VueResources.getString("dialog.save.title")); } } if (picked != null) VueUtil.setCurrentDirectoryPath(picked.getParent()); } return picked; }
From source file:org.zeromeaner.gui.reskin.StandaloneFrame.java
private void createCards() { introPanel = new StandaloneLicensePanel(); content.add(introPanel, CARD_INTRO); playCard = new JPanel(new BorderLayout()); content.add(playCard, CARD_PLAY);//from ww w .j ava 2 s . c o m JPanel confirm = new JPanel(new GridBagLayout()); JOptionPane option = new JOptionPane("A game is in open. End this game?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); option.addPropertyChangeListener(JOptionPane.VALUE_PROPERTY, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (!CARD_PLAY_END.equals(currentCard)) return; if (evt.getNewValue().equals(JOptionPane.YES_OPTION)) { gamePanel.shutdown(); try { gamePanel.shutdownWait(); } catch (InterruptedException ie) { } contentCards.show(content, nextCard); currentCard = nextCard; } if (evt.getNewValue().equals(JOptionPane.NO_OPTION)) { contentCards.show(content, CARD_PLAY); currentCard = CARD_PLAY; playButton.setSelected(true); } ((JOptionPane) evt.getSource()).setValue(-1); } }); GridBagConstraints cx = new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0); confirm.add(option, cx); content.add(confirm, CARD_PLAY_END); content.add(new StandaloneModeselectPanel(), CARD_MODESELECT); netplayCard = new JPanel(new BorderLayout()); netplayCard.add(netLobby, BorderLayout.SOUTH); content.add(netplayCard, CARD_NETPLAY); confirm = new JPanel(new GridBagLayout()); option = new JOptionPane("A netplay game is open. End this game and disconnect?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); option.addPropertyChangeListener(JOptionPane.VALUE_PROPERTY, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (!CARD_NETPLAY_END.equals(currentCard)) return; if (evt.getNewValue().equals(JOptionPane.YES_OPTION)) { gamePanel.shutdown(); try { gamePanel.shutdownWait(); } catch (InterruptedException ie) { } netLobby.disconnect(); contentCards.show(content, nextCard); currentCard = nextCard; } if (evt.getNewValue().equals(JOptionPane.NO_OPTION)) { contentCards.show(content, CARD_NETPLAY); currentCard = CARD_NETPLAY; netplayButton.setSelected(true); } ((JOptionPane) evt.getSource()).setValue(-1); } }); cx = new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0); confirm.add(option, cx); content.add(confirm, CARD_NETPLAY_END); StandaloneKeyConfig kc = new StandaloneKeyConfig(this); kc.load(0); content.add(kc, CARD_KEYS_1P); kc = new StandaloneKeyConfig(this); kc.load(1); content.add(kc, CARD_KEYS_2P); StandaloneGameTuningPanel gt = new StandaloneGameTuningPanel(); gt.load(0); content.add(gt, CARD_TUNING_1P); gt = new StandaloneGameTuningPanel(); gt.load(1); content.add(gt, CARD_TUNING_2P); StandaloneAISelectPanel ai = new StandaloneAISelectPanel(); ai.load(0); content.add(ai, CARD_AI_1P); ai = new StandaloneAISelectPanel(); ai.load(1); content.add(ai, CARD_AI_2P); StandaloneGeneralConfigPanel gc = new StandaloneGeneralConfigPanel(); gc.load(); content.add(gc, CARD_GENERAL); final JFileChooser fc = FileSystemViews.get().fileChooser("replay/"); fc.setFileFilter(new FileFilter() { @Override public String getDescription() { return "Zeromeaner Replay Files"; } @Override public boolean accept(File f) { return f.isDirectory() || f.getName().endsWith(".zrep"); } }); fc.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!e.getActionCommand().equals(JFileChooser.APPROVE_SELECTION)) return; JFileChooser fc = (JFileChooser) e.getSource(); String path = fc.getSelectedFile().getPath(); if (!path.contains("replay/")) path = "replay/" + path; startReplayGame(path); } }); fc.addComponentListener(new ComponentAdapter() { @Override public void componentShown(ComponentEvent e) { fc.rescanCurrentDirectory(); } }); content.add(fc, CARD_OPEN); content.add(new StandaloneFeedbackPanel(), CARD_FEEDBACK); }
From source file:co.com.soinsoftware.hotelero.view.JFRoom.java
private void watchPropertyChangeForJDateChooserControls() { this.jdcInitialDate.getDateEditor().addPropertyChangeListener(new PropertyChangeListener() { @Override// www. j a va2s . c o m public void propertyChange(PropertyChangeEvent e) { if ("date".equals(e.getPropertyName())) { final Date selectedDate = (Date) e.getNewValue(); final Calendar calendar = Calendar.getInstance(); calendar.setTime(selectedDate); setFinalDate(calendar); } } }); this.jdcFinalDate.getDateEditor().addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent e) { if ("date".equals(e.getPropertyName())) { if (validateFinalDate()) { refreshNotEnabledSet(); } } } }); }
From source file:org.openconcerto.erp.core.sales.order.component.CommandeClientSQLComponent.java
public void addViews() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); // Numero du commande c.gridx = 0;// ww w. jav a2 s .c o m this.add(new JLabel(getLabelFor("NUMERO"), SwingConstants.RIGHT), c); this.numeroUniqueCommande = new JUniqueTextField(16); c.fill = GridBagConstraints.NONE; c.gridx++; c.weightx = 1; this.add(this.numeroUniqueCommande, c); // Date JLabel labelDate = new JLabel(getLabelFor("DATE")); labelDate.setHorizontalAlignment(SwingConstants.RIGHT); c.gridx = 2; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; this.add(labelDate, c); JDate dateCommande = new JDate(true); c.gridx++; c.fill = GridBagConstraints.NONE; this.add(dateCommande, c); // Champ Module c.gridx = 0; c.gridy++; c.gridwidth = GridBagConstraints.REMAINDER; final JPanel addP = ComptaSQLConfElement.createAdditionalPanel(); this.setAdditionalFieldsPanel(new FormLayouter(addP, 2)); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; this.add(addP, c); c.gridy++; c.gridwidth = 1; this.comboDevis = new ElementComboBox(); // Reference c.gridx = 0; c.gridy++; c.gridwidth = 1; c.gridwidth = 1; c.gridheight = 1; c.fill = GridBagConstraints.HORIZONTAL; JLabel labelObjet = new JLabel(getLabelFor("NOM")); labelObjet.setHorizontalAlignment(SwingConstants.RIGHT); c.weightx = 0; this.add(labelObjet, c); c.gridx++; c.weightx = 1; c.fill = GridBagConstraints.BOTH; this.add(this.textObjet, c); String field; field = "ID_COMMERCIAL"; c.fill = GridBagConstraints.HORIZONTAL; // Commercial JLabel labelCommercial = new JLabel(getLabelFor(field)); labelCommercial.setHorizontalAlignment(SwingConstants.RIGHT); c.gridx++; c.weightx = 0; this.add(labelCommercial, c); this.comboCommercial = new ElementComboBox(false, 25); this.comboCommercial.setListIconVisible(false); c.gridx++; c.fill = GridBagConstraints.NONE; c.weightx = 1; this.add(this.comboCommercial, c); addRequiredSQLObject(this.comboCommercial, field); // Ligne 3: Client c.gridx = 0; c.gridy++; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel(getLabelFor("ID_CLIENT"), SwingConstants.RIGHT), c); this.comboClient = new ElementComboBox(); c.gridx = GridBagConstraints.RELATIVE; c.gridwidth = 3; c.weightx = 1; c.weighty = 0; c.fill = GridBagConstraints.NONE; this.add(this.comboClient, c); final ElementComboBox boxTarif = new ElementComboBox(); this.comboClient.addValueListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (!isFilling() && comboClient.getValue() != null) { Integer id = comboClient.getValue(); if (id > 1) { SQLRow row = comboClient.getElement().getTable().getRow(id); if (comboClient.getElement().getTable().getFieldsName().contains("ID_TARIF")) { SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF"); if (!foreignRow.isUndefined() && (boxTarif.getSelectedRow() == null || boxTarif.getSelectedId() != foreignRow.getID()) && JOptionPane.showConfirmDialog(null, "Appliquer les tarifs associs au client?") == JOptionPane.YES_OPTION) { boxTarif.setValue(foreignRow.getID()); // SaisieVenteFactureSQLComponent.this.tableFacture.setTarif(foreignRow, // true); } else { boxTarif.setValue(foreignRow.getID()); } // SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF"); // if (foreignRow.isUndefined() && // !row.getForeignRow("ID_DEVISE").isUndefined()) { // SQLRowValues rowValsD = new SQLRowValues(foreignRow.getTable()); // rowValsD.put("ID_DEVISE", row.getObject("ID_DEVISE")); // foreignRow = rowValsD; // // } // table.setTarif(foreignRow, true); } } } } }); // tarif if (this.getTable().getFieldsName().contains("ID_TARIF")) { // TARIF c.gridy++; c.gridx = 0; c.weightx = 0; c.weighty = 0; c.gridwidth = 1; this.add(new JLabel("Tarif appliquer"), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1; this.add(boxTarif, c); this.addView(boxTarif, "ID_TARIF"); boxTarif.addModelListener("wantedID", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { SQLRow selectedRow = boxTarif.getRequest().getPrimaryTable().getRow(boxTarif.getWantedID()); table.setTarif(selectedRow, false); } }); } // Table d'lment this.table = new CommandeClientItemTable(); c.fill = GridBagConstraints.BOTH; c.gridy++; c.gridx = 0; c.weightx = 1; c.weighty = 1; c.gridwidth = GridBagConstraints.REMAINDER; this.add(this.table, c); DeviseField textPortHT = new DeviseField(); DeviseField textRemiseHT = new DeviseField(); // INfos c.gridx = 0; c.gridy++; c.gridheight = 1; c.weighty = 0; c.weightx = 1; c.anchor = GridBagConstraints.WEST; c.gridwidth = 2; this.add(new TitledSeparator(getLabelFor("INFOS")), c); c.gridy++; c.weightx = 1; c.weighty = 0; c.fill = GridBagConstraints.BOTH; final JScrollPane scrollPane = new JScrollPane(this.infos); scrollPane.setBorder(null); this.add(scrollPane, c); // Poids c.gridwidth = 1; DefaultProps props = DefaultNXProps.getInstance(); Boolean b = props.getBooleanValue("ArticleShowPoids"); final JTextField textPoidsTotal = new JTextField(8); if (b) { JPanel panel = new JPanel(); panel.add(new JLabel(getLabelFor("T_POIDS")), c); textPoidsTotal.setEnabled(false); textPoidsTotal.setHorizontalAlignment(JTextField.RIGHT); textPoidsTotal.setDisabledTextColor(Color.BLACK); panel.add(textPoidsTotal, c); panel.setOpaque(false); DefaultGridBagConstraints.lockMinimumSize(panel); c.gridx = 2; c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.NORTHEAST; this.add(panel, c); } // Total DeviseField fieldHT = new DeviseField(); DeviseField fieldTVA = new DeviseField(); DeviseField fieldTTC = new DeviseField(); DeviseField fieldDevise = new DeviseField(); DeviseField fieldService = new DeviseField(); DeviseField fieldHA = new DeviseField(); fieldHT.setOpaque(false); fieldHA.setOpaque(false); fieldTVA.setOpaque(false); fieldTTC.setOpaque(false); fieldService.setOpaque(false); addSQLObject(fieldDevise, "T_DEVISE"); addRequiredSQLObject(fieldHT, "T_HT"); addRequiredSQLObject(fieldTVA, "T_TVA"); addRequiredSQLObject(fieldTTC, "T_TTC"); addRequiredSQLObject(fieldService, "T_SERVICE"); if (getTable().contains("PREBILAN")) { addSQLObject(fieldHA, "PREBILAN"); } else if (getTable().contains("T_HA")) { addSQLObject(fieldHA, "T_HA"); } JTextField poids = new JTextField(); // addSQLObject(poids, "T_POIDS"); final TotalPanel totalTTC = new TotalPanel(this.table, fieldHT, fieldTVA, fieldTTC, textPortHT, textRemiseHT, fieldService, fieldHA, fieldDevise, poids, null); c.gridx = GridBagConstraints.RELATIVE; c.gridy--; c.gridwidth = GridBagConstraints.REMAINDER; c.gridheight = 2; c.anchor = GridBagConstraints.NORTHEAST; c.fill = GridBagConstraints.NONE; c.weighty = 0; this.add(totalTTC, c); this.panelOO = new PanelOOSQLComponent(this); c.gridwidth = 1; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.EAST; c.gridx = 0; c.gridy += 3; c.weightx = 0; c.gridwidth = GridBagConstraints.REMAINDER; this.add(this.panelOO, c); textPortHT.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { totalTTC.updateTotal(); } public void removeUpdate(DocumentEvent e) { totalTTC.updateTotal(); } public void insertUpdate(DocumentEvent e) { totalTTC.updateTotal(); } }); textRemiseHT.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { totalTTC.updateTotal(); } public void removeUpdate(DocumentEvent e) { totalTTC.updateTotal(); } public void insertUpdate(DocumentEvent e) { totalTTC.updateTotal(); } }); addRequiredSQLObject(this.comboClient, "ID_CLIENT"); addSQLObject(this.textObjet, "NOM"); addSQLObject(textPoidsTotal, "T_POIDS"); addRequiredSQLObject(dateCommande, "DATE"); // addRequiredSQLObject(radioEtat, "ID_ETAT_DEVIS"); addRequiredSQLObject(this.numeroUniqueCommande, "NUMERO"); addSQLObject(this.infos, "INFOS"); addSQLObject(this.comboDevis, "ID_DEVIS"); this.numeroUniqueCommande .setText(NumerotationAutoSQLElement.getNextNumero(CommandeClientSQLElement.class, new Date())); this.table.getModel().addTableModelListener(new TableModelListener() { public void tableChanged(TableModelEvent e) { textPoidsTotal.setText(String.valueOf(CommandeClientSQLComponent.this.table.getPoidsTotal())); } }); DefaultGridBagConstraints.lockMinimumSize(comboClient); DefaultGridBagConstraints.lockMinimumSize(comboCommercial); DefaultGridBagConstraints.lockMinimumSize(comboDevis); DefaultGridBagConstraints.lockMinimumSize(totalTTC); DefaultGridBagConstraints.lockMaximumSize(totalTTC); DefaultGridBagConstraints.lockMinimumSize(numeroUniqueCommande); }
From source file:edu.ku.brc.specify.config.FixAttachments.java
/** * @param resultsHashMap/* w ww.j a va2 s .c om*/ * @param tableHash * @param totalFiles */ private void reattachFiles(final HashMap<Integer, Vector<Object[]>> resultsHashMap, final HashMap<Integer, AttchTableModel> tableHash, final int totalFiles) { final String CNT = "CNT"; final SwingWorker<Integer, Integer> worker = new SwingWorker<Integer, Integer>() { int filesCnt = 0; @Override protected Integer doInBackground() throws Exception { DataProviderSessionIFace session = DataProviderFactory.getInstance().createSession(); if (session != null) { try { for (int tblId : resultsHashMap.keySet()) { AttchTableModel model = tableHash.get(tblId); int cnt = 0; for (int r = 0; r < model.getRowCount(); r++) { if (model.isRecoverable(r)) { Thread.sleep(100); session.beginTransaction(); Integer attachID = model.getAttachmentId(r); Attachment attachment = session.get(Attachment.class, attachID); AttachmentUtils.getAttachmentManager() .setStorageLocationIntoAttachment(attachment, false); try { attachment.storeFile(true); // false means do not display an error dialog session.saveOrUpdate(attachment); session.commit(); model.setRecovered(r, true); filesCnt++; } catch (IOException ex) { session.rollback(); } } cnt++; firePropertyChange(CNT, 0, (int) ((double) cnt / (double) totalFiles * 100.0)); } } } catch (Exception ex) { session.rollback(); } finally { session.close(); } } return null; } @Override protected void done() { UIRegistry.clearSimpleGlassPaneMsg(); UIRegistry.displayInfoMsgDlg(String.format("Files recovered: %d / %d", filesCnt, totalFiles)); File file = produceSummaryReport(resultsHashMap, tableHash, totalFiles); if (file != null) { try { AttachmentUtils.openFile(file); } catch (Exception e) { } } if (getNumberofBadAttachments() == 0) { AppPreferences.getGlobalPrefs().putBoolean("CHECK_ATTCH_ERR", true); } super.done(); } }; final SimpleGlassPane glassPane = UIRegistry .writeSimpleGlassPaneMsg(String.format("Recovering %d files.", totalFiles), 24); glassPane.setProgress(0); worker.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { if (CNT.equals(evt.getPropertyName())) { glassPane.setProgress((Integer) evt.getNewValue()); } } }); worker.execute(); }
From source file:de.tntinteractive.portalsammler.gui.MainDialog.java
private void poll(final Gui gui) { this.pollButton.setEnabled(false); final Settings settings = this.getStore().getSettings().deepClone(); final ProgressMonitor progress = new ProgressMonitor(this, "Sammle Daten aus den Quell-Portalen...", "...", 0, settings.getSize());/*from w ww .j a v a2 s . co m*/ progress.setMillisToDecideToPopup(0); progress.setMillisToPopup(0); progress.setProgress(0); final SwingWorker<String, String> task = new SwingWorker<String, String>() { @Override protected String doInBackground() throws Exception { final StringBuilder summary = new StringBuilder(); int cnt = 0; for (final String id : settings.getAllSettingIds()) { if (this.isCancelled()) { break; } cnt++; this.publish(cnt + ": " + id); final Pair<Integer, Integer> counts = MainDialog.this.pollSingleSource(settings, id); summary.append(id).append(": "); if (counts != null) { summary.append(counts.getLeft()).append(" neu, ").append(counts.getRight()) .append(" schon bekannt\n"); } else { summary.append("Fehler!\n"); } this.setProgress(cnt); } MainDialog.this.getStore().writeMetadata(); return summary.toString(); } @Override protected void process(final List<String> ids) { progress.setNote(ids.get(ids.size() - 1)); } @Override public void done() { MainDialog.this.pollButton.setEnabled(true); MainDialog.this.table.refreshContents(); try { final String summary = this.get(); JOptionPane.showMessageDialog(MainDialog.this, summary, "Abruf-Zusammenfassung", JOptionPane.INFORMATION_MESSAGE); } catch (final Exception e) { gui.showError(e); } } }; task.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(final PropertyChangeEvent evt) { if ("progress".equals(evt.getPropertyName())) { progress.setProgress((Integer) evt.getNewValue()); } if (progress.isCanceled()) { task.cancel(true); } } }); task.execute(); }
From source file:org.rdv.viz.dial.DialPanel.java
private void initModelListener() { model.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent pce) { if (pce.getPropertyName().equals("value")) { Number value = (Number) pce.getNewValue(); dataset.setValue(value); } else if (pce.getPropertyName().equals("name")) { String name = (String) pce.getNewValue(); dialValueIndicator.setVisible(name != null); if (name != null) { dialTextAnnotation.setLabel(name); }//from ww w . ja v a 2 s . co m } else if (pce.getPropertyName().equals("unit")) { String unit = (String) pce.getNewValue(); engineeringFormatWithUnit.setUnit(unit); } else if (pce.getPropertyName().equals("range")) { updateRange(); } else if (pce.getPropertyName().equals("warningThreshold") || pce.getPropertyName().equals("criticalThreshold")) { updateThresholdRanges(); } } }); }
From source file:VASL.build.module.map.ASLBoardPicker.java
public void addTo(Buildable b) { DirectoryConfigurer config = new VASSAL.configure.DirectoryConfigurer(BOARD_DIR, "Board Directory"); final GameModule g = GameModule.getGameModule(); g.getPrefs().addOption(config);//from w w w. j a v a 2 s . c om String storedValue = g.getPrefs().getStoredValue(BOARD_DIR); if (storedValue == null || !new File(storedValue).exists()) { File archive = new File(g.getDataArchive().getName()); File dir = archive.getParentFile(); File defaultDir = new File(dir, "boards"); if (!defaultDir.exists()) { defaultDir.mkdir(); } config.setValue(defaultDir); } setBoardDir((File) g.getPrefs().getValue(BOARD_DIR)); g.getPrefs().getOption(BOARD_DIR).addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { setBoardDir((File) evt.getNewValue()); } }); super.addTo(b); }
From source file:EditorPaneExample11.java
public EditorPaneExample11() { super("JEditorPane Example 11"); pane = new JEditorPane(); pane.setEditable(false); // Read-only getContentPane().add(new JScrollPane(pane), "Center"); // Build the panel of controls JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridwidth = 1;/*ww w. ja va 2s . com*/ c.gridheight = 1; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; c.weightx = 0.0; c.weighty = 0.0; JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT); panel.add(urlLabel, c); JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT); c.gridy = 1; panel.add(loadingLabel, c); JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT); c.gridy = 2; panel.add(typeLabel, c); c.gridy = 3; panel.add(new JLabel(LOAD_TIME), c); c.gridy = 4; c.gridwidth = 2; c.weightx = 1.0; c.anchor = GridBagConstraints.WEST; onlineLoad = new JCheckBox("Online Load"); panel.add(onlineLoad, c); onlineLoad.setSelected(true); onlineLoad.setForeground(typeLabel.getForeground()); c.gridx = 1; c.gridy = 0; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; urlCombo = new JComboBox(); panel.add(urlCombo, c); urlCombo.setEditable(true); loadingState = new JLabel(spaces, JLabel.LEFT); loadingState.setForeground(Color.black); c.gridy = 1; panel.add(loadingState, c); loadedType = new JLabel(spaces, JLabel.LEFT); loadedType.setForeground(Color.black); c.gridy = 2; panel.add(loadedType, c); timeLabel = new JLabel(""); c.gridy = 3; panel.add(timeLabel, c); getContentPane().add(panel, "South"); // Allocate the empty tree model DefaultMutableTreeNode emptyRootNode = new DefaultMutableTreeNode("Empty"); emptyModel = new DefaultTreeModel(emptyRootNode); // Create and place the heading tree tree = new JTree(emptyModel); tree.setPreferredSize(new Dimension(200, 200)); getContentPane().add(new JScrollPane(tree), "East"); // Change page based on combo selection urlCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (populatingCombo == true) { return; } Object selection = urlCombo.getSelectedItem(); try { // Check if the new page and the old // page are the same. URL url; if (selection instanceof URL) { url = (URL) selection; } else { url = new URL((String) selection); } URL loadedURL = pane.getPage(); if (loadedURL != null && loadedURL.sameFile(url)) { return; } // Try to display the page urlCombo.setEnabled(false); // Disable input urlCombo.paintImmediately(0, 0, urlCombo.getSize().width, urlCombo.getSize().height); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); // Busy cursor loadingState.setText("Loading..."); loadingState.paintImmediately(0, 0, loadingState.getSize().width, loadingState.getSize().height); loadedType.setText(""); loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height); timeLabel.setText(""); timeLabel.paintImmediately(0, 0, timeLabel.getSize().width, timeLabel.getSize().height); // Display an empty tree while loading tree.setModel(emptyModel); tree.paintImmediately(0, 0, tree.getSize().width, tree.getSize().height); startTime = System.currentTimeMillis(); // Choose the loading method if (onlineLoad.isSelected()) { // Usual load via setPage pane.setPage(url); loadedType.setText(pane.getContentType()); } else { pane.setContentType("text/html"); loadedType.setText(pane.getContentType()); if (loader == null) { loader = new HTMLDocumentLoader(); } HTMLDocument doc = loader.loadDocument(url); loadComplete(); pane.setDocument(doc); displayLoadTime(); populateCombo(findLinks(doc, null)); TreeNode node = buildHeadingTree(doc); tree.setModel(new DefaultTreeModel(node)); enableInput(); } } catch (Exception e) { System.out.println(e); JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", selection.toString() }, "File Open Error", JOptionPane.ERROR_MESSAGE); loadingState.setText("Failed"); enableInput(); } } }); // Listen for page load to complete pane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("page")) { loadComplete(); displayLoadTime(); populateCombo(findLinks(pane.getDocument(), null)); TreeNode node = buildHeadingTree(pane.getDocument()); tree.setModel(new DefaultTreeModel(node)); enableInput(); } } }); // Listener for tree selection tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent evt) { TreePath path = evt.getNewLeadSelectionPath(); if (path != null) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); Object userObject = node.getUserObject(); if (userObject instanceof Heading) { Heading heading = (Heading) userObject; try { Rectangle textRect = pane.modelToView(heading.getOffset()); textRect.y += 3 * textRect.height; pane.scrollRectToVisible(textRect); } catch (BadLocationException e) { } } } } }); }