List of usage examples for java.beans PropertyChangeEvent getSource
public Object getSource()
From source file:gda.gui.mca.McaGUI.java
private void makeTcaControlDialog() { if (tcaControlPanel == null) { tcaControlPanel = new TcaPanel(); tcaDialog = new JDialog(); Object[] options = { "OK" }; Object[] array = { tcaControlPanel }; // Create the JOptionPane. final JOptionPane optionPane = new JOptionPane(array, JOptionPane.PLAIN_MESSAGE, JOptionPane.YES_OPTION, null, options, options[0]); optionPane.addPropertyChangeListener(new PropertyChangeListener() { @Override/*from w w w .j a v a 2 s . c om*/ public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (isVisible() && (e.getSource() == optionPane) && (JOptionPane.VALUE_PROPERTY.equals(prop) || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) { Object value = optionPane.getValue(); if (value == JOptionPane.UNINITIALIZED_VALUE) { // ignore reset return; } // Reset the JOptionPane's value. // If you don't do this, then if the user // presses the same button next time, no // property change event will be fired. optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE); if ("OK".equals(value)) { tcaDialog.setVisible(false); } } } }); tcaDialog.setContentPane(optionPane); tcaDialog.pack(); tcaDialog.setTitle("TCA Controls"); tcaDialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); } }
From source file:gda.gui.mca.McaGUI.java
private void makeAdcControlDialog() { if (adcControlPanel == null) { adcControlPanel = new AdcPanel(); adcDialog = new JDialog(); Object[] options = { "OK" }; Object[] array = { adcControlPanel }; // Create the JOptionPane. final JOptionPane optionPane = new JOptionPane(array, JOptionPane.PLAIN_MESSAGE, JOptionPane.YES_OPTION, null, options, options[0]); optionPane.addPropertyChangeListener(new PropertyChangeListener() { @Override/*from w ww . j a v a 2 s .c o m*/ public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (isVisible() && (e.getSource() == optionPane) && (JOptionPane.VALUE_PROPERTY.equals(prop) || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) { Object value = optionPane.getValue(); if (value == JOptionPane.UNINITIALIZED_VALUE) { // ignore reset return; } // Reset the JOptionPane's value. // If you don't do this, then if the user // presses the same button next time, no // property change event will be fired. optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE); if ("OK".equals(value)) { adcDialog.setVisible(false); } } } }); adcDialog.setContentPane(optionPane); adcDialog.pack(); adcDialog.setTitle("ADC Controls"); adcDialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); } }
From source file:fr.ritaly.dungeonmaster.champion.Champion.java
@Override public void propertyChange(PropertyChangeEvent event) { if (event.getSource() != stats) { // On ignore cet vnement return;// w ww .j a v a 2 s .c om } if (Stats.PROPERTY_HEALTH.equals(event.getPropertyName())) { final int oldHealth = ((Integer) event.getOldValue()).intValue(); final int newHealth = ((Integer) event.getNewValue()).intValue(); if ((oldHealth > 0) && (newHealth == 0)) { // Le hros vient de mourir if (log.isDebugEnabled()) { log.debug(name + " is dying ..."); } kill(); } else if ((oldHealth == 0) && (newHealth > 0)) { if (log.isInfoEnabled()) { // Le hros vient de ressusciter log.info(name + " has been resurrected ..."); } // Inutile de le rintgrer au groupe, il y est dj ! } } }
From source file:at.becast.youploader.gui.FrmMain.java
public void initQueuetab() { JScrollPane TabQueues = new JScrollPane(); QueuePanel = new JPanel(); TabQueues.setViewportView(QueuePanel); QueuePanel.setLayout(new MigLayout("", "[875px,grow,fill]", "[][][][]")); JPanel buttonPanel = new JPanel(); GridBagConstraints gbc_panel_2 = new GridBagConstraints(); gbc_panel_2.fill = GridBagConstraints.BOTH; gbc_panel_2.gridx = 0;/* w w w .j ava 2 s. c o m*/ gbc_panel_2.gridy = 1; buttonPanel.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(39dlu;default)"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(92dlu;default)"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(46dlu;min)"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("left:max(22dlu;default)"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("max(0dlu;default)"), })); JButton btnStart = new JButton(LANG.getString("frmMain.start")); btnStart.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { startUploads(); } }); JLabel lblAfterUploadsFinish = new JLabel(LANG.getString("frmMain.afterfinish")); buttonPanel.add(lblAfterUploadsFinish, "10, 2, 7, 1"); buttonPanel.add(btnStart, "2, 4"); JButton btnStop = new JButton(LANG.getString("frmMain.stop")); btnStop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { UploadMgr.stop(); } }); buttonPanel.add(btnStop, "6, 4"); cmbAfterFinish = new JComboBox<Object>(); cmbAfterFinish.setModel(new DefaultComboBoxModel<Object>(new String[] { LANG.getString("frmMain.afterfinish.donothing"), LANG.getString("frmMain.afterfinish.suspend"), LANG.getString("frmMain.afterfinish.shutdown") })); buttonPanel.add(cmbAfterFinish, "10, 4, 7, 1, fill, default"); JLabel lblUploads = new JLabel(LANG.getString("frmMain.uploads") + ":"); buttonPanel.add(lblUploads, "18, 4, right, fill"); JSlider slider = new JSlider(); slider.setPaintTicks(true); slider.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { JSlider s = (JSlider) evt.getSource(); UploadMgr.setUploadlimit(s.getValue()); } }); slider.setMajorTickSpacing(1); slider.setMinorTickSpacing(1); slider.setMinimum(1); slider.setMaximum(5); slider.setValue(1); slider.setSnapToTicks(true); slider.setPaintLabels(true); buttonPanel.add(slider, "20, 4, fill, fill"); JLabel lblUploadSpeed = new JLabel(LANG.getString("frmMain.uploadspeed") + ":"); lblUploadSpeed.setHorizontalAlignment(SwingConstants.TRAILING); buttonPanel.add(lblUploadSpeed, "24, 4"); spinner = new JSpinner(); spinner.setModel(new SpinnerNumberModel(new Integer(0), new Integer(0), null, new Integer(10))); spinner.setEditor(new SpeedValuesSpinnerEditor(spinner)); spinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSpinner s = (JSpinner) e.getSource(); speed = Integer.parseInt(s.getValue().toString()); Main.s.put("speed", String.valueOf(speed)); UploadMgr.setLimit(speed); } }); spinner.setValue(speed); buttonPanel.add(spinner, "26, 4"); JLabel lblKbps = new JLabel("kbps"); buttonPanel.add(lblKbps, "28, 4"); JPanel TabQueue = new JPanel(); TabbedPane.addTab(LANG.getString("frmMain.Tabs.Queue"), null, TabQueue, null); TabQueue.setLayout(new BorderLayout(0, 0)); TabQueue.add(buttonPanel, BorderLayout.SOUTH); TabQueue.add(TabQueues, BorderLayout.CENTER); }
From source file:ro.nextreports.designer.chart.ChartPropertyPanel.java
@Override public void propertyChange(PropertyChangeEvent event) { Property prop = (Property) event.getSource(); String propName = prop.getName(); ChartTitle chartTitle = chart.getTitle(); ChartLayoutPanel layoutPanel = Globals.getChartLayoutPanel(); try {/*from w w w . j a v a2 s . com*/ if (TITLE_TEXT.equals(propName)) { String propValue = (String) prop.getValue(); chartTitle.setTitle(propValue); layoutPanel.setTitle(propValue); } else if (TITLE_FONT.equals(propName)) { Font propValue = (Font) prop.getValue(); chartTitle.setFont(propValue); layoutPanel.setTitleFont(propValue); } else if (TITLE_FOREGROUND.equals(propName)) { Color propValue = (Color) prop.getValue(); chartTitle.setColor(propValue); layoutPanel.setTitleColor(propValue); } else if (TITLE_ALIGNMENT.equals(propName)) { String propValue = (String) prop.getValue(); byte alignment = getAlignment(propValue); chartTitle.setAlignment(alignment); layoutPanel.setTitleAlignment(alignment); } else if (CHART_BACKGROUND.equals(propName)) { Color propValue = (Color) prop.getValue(); chart.setBackground(propValue); layoutPanel.setMainBackground(propValue); } else if (CHART_FOREGROUND.equals(propName)) { adjustForegroundColors(prop, 0); } else if (CHART_FOREGROUND_2.equals(propName)) { adjustForegroundColors(prop, 1); } else if (CHART_FOREGROUND_3.equals(propName)) { adjustForegroundColors(prop, 2); } else if (CHART_FOREGROUND_4.equals(propName)) { adjustForegroundColors(prop, 3); } else if (CHART_FOREGROUND_5.equals(propName)) { adjustForegroundColors(prop, 4); } else if (CHART_FOREGROUND_6.equals(propName)) { adjustForegroundColors(prop, 5); } else if (CHART_FOREGROUND_7.equals(propName)) { adjustForegroundColors(prop, 6); } else if (CHART_FOREGROUND_8.equals(propName)) { adjustForegroundColors(prop, 7); } else if (CHART_FOREGROUND_9.equals(propName)) { adjustForegroundColors(prop, 8); } else if (CHART_FOREGROUND_10.equals(propName)) { adjustForegroundColors(prop, 9); } else if (CHART_TYPE.equals(propName)) { String type = (String) prop.getValue(); ChartType chartType = getChartType(type); chart.setType(chartType); layoutPanel.setType(chartType.getType()); updateStyleProperty(); } else if (CHART_STYLE.equals(propName)) { String style = (String) prop.getValue(); chart.getType().setStyle(getStyle(style)); } else if (CHART_TRANSPARENCY.equals(propName)) { String transparency = (String) prop.getValue(); chart.setTransparency(getTransparency(transparency)); } else if (TOOLTIP_MESSAGE.equals(propName)) { String message = (String) prop.getValue(); chart.setTooltipMessage(message); } else if (X_AXIS_COLOR.equals(propName)) { Color color = (Color) prop.getValue(); chart.setxAxisColor(color); } else if (X_COLUMN_COL.equals(propName)) { String column = (String) prop.getValue(); chart.setXColumn(column); layoutPanel.setXColumn(column); } else if (X_COLUMN_COLOR.equals(propName)) { Color color = (Color) prop.getValue(); chart.setXColor(color); layoutPanel.setXColor(color); } else if (X_COLUMN_ORIENTATION.equals(propName)) { String orientation = (String) prop.getValue(); chart.setXorientation(getXOrientation(orientation)); } else if (X_AXIS_LABEL_FONT.equals(propName)) { Font font = (Font) prop.getValue(); chart.setXLabelFont(font); } else if (X_LEGEND_TEXT.equals(propName)) { String legend = (String) prop.getValue(); chart.getXLegend().setTitle(legend); } else if (X_LEGEND_FONT.equals(propName)) { Font font = (Font) prop.getValue(); chart.getXLegend().setFont(font); } else if (X_LEGEND_COLOR.equals(propName)) { Color color = (Color) prop.getValue(); chart.getXLegend().setColor(color); } else if (X_LEGEND_ALIGNMENT.equals(propName)) { String propValue = (String) prop.getValue(); byte alignment = getAlignment(propValue); chart.getXLegend().setAlignment(alignment); } else if (X_PATTERN.equals(propName)) { String propValue = (String) prop.getValue(); chart.setXPattern(propValue); } else if (X_GRID_COLOR.equals(propName)) { Color propValue = (Color) prop.getValue(); chart.setXGridColor(propValue); } else if (X_SHOW_GRID.equals(propName)) { Boolean propValue = (Boolean) prop.getValue(); chart.setXShowGrid(propValue); } else if (X_SHOW_LABEL.equals(propName)) { Boolean propValue = (Boolean) prop.getValue(); chart.setXShowLabel(propValue); } else if (Y_AXIS_COLOR.equals(propName)) { Color color = (Color) prop.getValue(); chart.setyAxisColor(color); } else if (Y_COLUMN_COL.equals(propName)) { String column = (String) prop.getValue(); adjustYColumns(prop, 0); layoutPanel.setYColumn(column); } else if (Y_COLUMN_COL_2.equals(propName)) { adjustYColumns(prop, 1); } else if (Y_COLUMN_COL_3.equals(propName)) { adjustYColumns(prop, 2); } else if (Y_COLUMN_COL_4.equals(propName)) { adjustYColumns(prop, 3); } else if (Y_COLUMN_COL_5.equals(propName)) { adjustYColumns(prop, 4); } else if (Y_COLUMN_COL_6.equals(propName)) { adjustYColumns(prop, 5); } else if (Y_COLUMN_COL_7.equals(propName)) { adjustYColumns(prop, 6); } else if (Y_COLUMN_COL_8.equals(propName)) { adjustYColumns(prop, 7); } else if (Y_COLUMN_COL_9.equals(propName)) { adjustYColumns(prop, 8); } else if (Y_COLUMN_COL_10.equals(propName)) { adjustYColumns(prop, 9); } else if (Y_DYNAMIC_COLUMN_QUERY.equals(propName)) { String query = (String) prop.getValue(); chart.setYColumnQuery(query); } else if (Y_COLUMN_LEGEND.equals(propName)) { adjustYColumnsLegends(prop, 0); } else if (Y_COLUMN_LEGEND_2.equals(propName)) { adjustYColumnsLegends(prop, 1); } else if (Y_COLUMN_LEGEND_3.equals(propName)) { adjustYColumnsLegends(prop, 2); } else if (Y_COLUMN_LEGEND_4.equals(propName)) { adjustYColumnsLegends(prop, 3); } else if (Y_COLUMN_LEGEND_5.equals(propName)) { adjustYColumnsLegends(prop, 4); } else if (Y_COLUMN_LEGEND_6.equals(propName)) { adjustYColumnsLegends(prop, 5); } else if (Y_COLUMN_LEGEND_7.equals(propName)) { adjustYColumnsLegends(prop, 6); } else if (Y_COLUMN_LEGEND_8.equals(propName)) { adjustYColumnsLegends(prop, 7); } else if (Y_COLUMN_LEGEND_9.equals(propName)) { adjustYColumnsLegends(prop, 8); } else if (Y_COLUMN_LEGEND_10.equals(propName)) { adjustYColumnsLegends(prop, 9); } else if (Y_COLUMN_COLOR.equals(propName)) { Color color = (Color) prop.getValue(); chart.setYColor(color); layoutPanel.setYColor(color); } else if (Y_LEGEND_TEXT.equals(propName)) { String legend = (String) prop.getValue(); chart.getYLegend().setTitle(legend); } else if (Y_LEGEND_FONT.equals(propName)) { Font font = (Font) prop.getValue(); chart.getYLegend().setFont(font); } else if (Y_LEGEND_COLOR.equals(propName)) { Color color = (Color) prop.getValue(); chart.getYLegend().setColor(color); } else if (Y_LEGEND_ALIGNMENT.equals(propName)) { String propValue = (String) prop.getValue(); byte alignment = getAlignment(propValue); chart.getYLegend().setAlignment(alignment); } else if (Y_DUAL_LEGEND_TEXT.equals(propName)) { String legend = (String) prop.getValue(); chart.getyDualLegend().setTitle(legend); } else if (Y_DUAL_LEGEND_FONT.equals(propName)) { Font font = (Font) prop.getValue(); chart.getyDualLegend().setFont(font); } else if (Y_DUAL_LEGEND_COLOR.equals(propName)) { Color color = (Color) prop.getValue(); chart.getyDualLegend().setColor(color); } else if (Y_GRID_COLOR.equals(propName)) { Color propValue = (Color) prop.getValue(); chart.setYGridColor(propValue); } else if (Y_SHOW_GRID.equals(propName)) { Boolean propValue = (Boolean) prop.getValue(); chart.setYShowGrid(propValue); } else if (Y_SHOW_LABEL.equals(propName)) { Boolean propValue = (Boolean) prop.getValue(); chart.setYShowLabel(propValue); } else if (Y_AXIS_LABEL_FONT.equals(propName)) { Font font = (Font) prop.getValue(); chart.setYLabelFont(font); } else if (SHOW_Y_VALUES_LABEL.equals(propName)) { Boolean propValue = (Boolean) prop.getValue(); chart.setShowYValuesOnChart(propValue); } else if (SHOW_Y_DUAL_AXIS_LABEL.equals(propName)) { Boolean propValue = (Boolean) prop.getValue(); chart.setShowDualAxis(propValue); } else if (Y2COUNT_LABEL.equals(propName)) { Integer propValue = (Integer) prop.getValue(); chart.setY2SeriesCount(propValue); } else if (Y_TOOLTIP_PATTERN.equals(propName)) { String propValue = (String) prop.getValue(); chart.setYTooltipPattern(propValue); } else if (MAIN_FONT.equals(propName)) { Font propValue = (Font) prop.getValue(); chart.setFont(propValue); } } catch (Exception e) { LOG.error(e.getMessage(), e); } }
From source file:ro.nextreports.designer.PropertyPanel.java
@Override public void propertyChange(PropertyChangeEvent event) { if (ignoreEvent) { return;/* w w w . j a v a 2 s.c o m*/ } if (isInit) { return; } Property prop = (Property) event.getSource(); String propName = prop.getName(); // report properties if (ORIENTATION_NAME.equals(propName)) { String propValue = (String) prop.getValue(); LayoutHelper.getReportLayout().setOrientation(getOrientation(propValue)); return; } else if (REPORT_TYPE_NAME.equals(propName)) { String propValue = (String) prop.getValue(); LayoutHelper.getReportLayout().setReportType(getReportType(propValue)); return; } else if (HEADER_NAME.equals(propName)) { Boolean propValue = (Boolean) prop.getValue(); LayoutHelper.getReportLayout().setHeaderOnEveryPage(propValue); return; } else if (PAGE_FORMAT_NAME.equals(propName)) { String propValue = (String) prop.getValue(); LayoutHelper.getReportLayout().setPageFormat(propValue); List<Property> props = getReportProperties(LayoutHelper.getReportLayout()); setProperties(props.toArray(new Property[props.size()])); return; } else if (TEMPLATE_NAME.equals(propName)) { String propValue = (String) prop.getValue(); LayoutHelper.getReportLayout().setTemplateName(propValue); return; } else if (TEMPLATE_SHEET_NAME.equals(propName)) { Integer propValue = (Integer) prop.getValue(); LayoutHelper.getReportLayout().setTemplateSheet(propValue); return; } else if (SHEET_NAME.equals(propName)) { String propValue = (String) prop.getValue(); LayoutHelper.getReportLayout().setSheetNames(propValue); return; } else if (CUSTOM_PAGE_FORMAT_DEF_NAME.equals(propName)) { PaperSize propValue = (PaperSize) prop.getValue(); LayoutHelper.getReportLayout().setPaperSize(propValue); return; } else if (PAGE_PADDING_NAME.equals(propName)) { Padding propValue = (Padding) prop.getValue(); LayoutHelper.getReportLayout().setPagePadding(propValue); return; } else if (BG_IMAGE_NAME.equals(propName)) { String propValue = (String) prop.getValue(); LayoutHelper.getReportLayout().setBackgroundImage(propValue); return; } // row properties for (Integer i : rows) { if (ROW_CONDITION_NAME.equals(propName)) { RowFormattingConditions propValue = (RowFormattingConditions) prop.getValue(); RowElement element = BandUtil.getRowElement(LayoutHelper.getReportLayout(), i); element.setFormattingConditions(propValue); } else if (ROW_NEW_PAGE_NAME.equals(propName)) { Boolean newPage = (Boolean) prop.getValue(); RowElement element = BandUtil.getRowElement(LayoutHelper.getReportLayout(), i); element.setStartOnNewPage(newPage); } } ReportGrid reportGrid = Globals.getReportGrid(); DefaultGridModel reportGridModel = (DefaultGridModel) reportGrid.getModel(); List<BandElement> oldElements = new ArrayList<BandElement>(); List<BandElement> elements = new ArrayList<BandElement>(); List<Integer> rows = new ArrayList<Integer>(); List<Integer> columns = new ArrayList<Integer>(); for (ReportGridCell reportGridCell : reportGridCells) { BandElement element = reportGridCell.getValue(); oldElements.add(ObjectCloner.silenceDeepCopy(element)); int row = reportGridCell.getRow(); rows.add(row); int column = reportGridCell.getColumn(); columns.add(column); try { if (TEXT_PARAM_NAME.equals(propName)) { String propValue = (String) prop.getValue(); element.setText(propValue); } else if (FONT_PARAM_NAME.equals(propName)) { Font propValue = (Font) prop.getValue(); element.setFont(propValue); } else if (BACKGROUND_PARAM_NAME.equals(propName)) { Color propValue = (Color) prop.getValue(); element.setBackground(propValue); } else if (FOREGROUND_PARAM_NAME.equals(propName)) { Color propValue = (Color) prop.getValue(); element.setForeground(propValue); } else if (ALIGNMENT_PARAM_NAME.equals(propName)) { String propValue = (String) prop.getValue(); if (CENTER.equals(propValue)) { element.setHorizontalAlign(BandElement.CENTER); } else if (RIGHT.equals(propValue)) { element.setHorizontalAlign(BandElement.RIGHT); } else { element.setHorizontalAlign(BandElement.LEFT); } } else if (V_ALIGNMENT_PARAM_NAME.equals(propName)) { String propValue = (String) prop.getValue(); if (MIDDLE.equals(propValue)) { element.setVerticalAlign(BandElement.MIDDLE); } else if (TOP.equals(propValue)) { element.setVerticalAlign(BandElement.TOP); } else { element.setVerticalAlign(BandElement.BOTTOM); } } else if (PATTERN_PARAM_NAME.equals(propName)) { String propValue = (String) prop.getValue(); ((FieldBandElement) element).setPattern(propValue); } else if (WIDTH_PARAM_NAME.equals(propName)) { Integer propValue = (Integer) prop.getValue(); if (element instanceof ImageBandElement) { ((ImageBandElement) element).setWidth(propValue); } else { ((ImageColumnBandElement) element).setWidth(propValue); } } else if (HEIGHT_PARAM_NAME.equals(propName)) { Integer propValue = (Integer) prop.getValue(); if (element instanceof ImageBandElement) { ((ImageBandElement) element).setHeight(propValue); } else { ((ImageColumnBandElement) element).setHeight(propValue); } } else if (URL_PARAM_NAME.equals(propName)) { Hyperlink propValue = (Hyperlink) prop.getValue(); ((HyperlinkBandElement) element).setHyperlink(propValue); } else if (PADDING_PARAM_NAME.equals(propName)) { Padding propValue = (Padding) prop.getValue(); element.setPadding(propValue); } else if (BORDER_PARAM_NAME.equals(propName)) { ro.nextreports.engine.band.Border propValue = (ro.nextreports.engine.band.Border) prop .getValue(); element.setBorder(propValue); } else if (CONDITION_NAME.equals(propName)) { FormattingConditions propValue = (FormattingConditions) prop.getValue(); element.setFormattingConditions(propValue); } else if (HTML_ACC_HEADERS.equals(propName)) { String propValue = (String) prop.getValue(); if ((propValue != null) && propValue.trim().equals("")) { propValue = null; } element.setHtmlAccHeaders(propValue); } else if (HTML_ACC_ID.equals(propName)) { String propValue = (String) prop.getValue(); if ((propValue != null) && propValue.trim().equals("")) { propValue = null; } element.setHtmlAccId(propValue); } else if (HTML_ACC_SCOPE.equals(propName)) { String propValue = (String) prop.getValue(); if (HTML_SCOPE_NONE.equals(propValue)) { element.setHtmlAccScope(null); } else { element.setHtmlAccScope(propValue); } } else if (WRAPTEXT_PARAM_NAME.equals(propName)) { Boolean propValue = (Boolean) prop.getValue(); element.setWrapText(propValue); } else if (TEXT_ROTATION_PARAM_NAME.equals(propName)) { Short propValue = (Short) prop.getValue(); element.setTextRotation(propValue); } else if (REPEATED_PARAM_NAME.equals(propName)) { Boolean propValue = (Boolean) prop.getValue(); element.setRepeatedValue(propValue); } else if (HIDE_WHEN_EXPRESSION_PARAM_NAME.equals(propName)) { String propValue = (String) prop.getValue(); if ((propValue != null) && propValue.trim().equals("")) { propValue = null; } element.setHideWhenExpression(propValue); } else if (ROW_CONDITION_NAME.equals(propName)) { // nothing to do here } else if (ROW_NEW_PAGE_NAME.equals(propName)) { // nothing to do here } else if (FOR_REPORT_PARAM_NAME.equals(propName)) { String propValue = (String) prop.getValue(); ((ForReportBandElement) element).setSql(propValue); } else { throw new RuntimeException("Invalid property name '" + propName + "'"); } elements.add(ObjectCloner.silenceDeepCopy(element)); } catch (Exception e) { LOG.error(e.getMessage(), e); } } int n = elements.size(); if (n > 0) { ignoreEvent = true; for (int i = 0; i < n; i++) { reportGridModel.fireGridCellUpdated(rows.get(i), columns.get(i)); } Globals.getReportUndoManager().addEdit(new ModifyElementsEdit(elements, oldElements, rows, columns)); ignoreEvent = false; } }
From source file:ucar.unidata.idv.control.chart.TimeSeriesChartWrapper.java
/** * Handle the event//from w w w.j av a2 s . c o m * * @param event the event */ public void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals(WayPoint.PROP_WAYPOINTVALUE)) { WayPoint source = (WayPoint) event.getSource(); if (source.canPlaySound()) { playSound(source); } if (getDriveTime() && (animationWidget != null)) { lastTimeWeDrove = System.currentTimeMillis(); animationWidget.setTimeFromUser(new Real(RealType.Time, source.getDomainValue() / 1000)); } } else if (event.getPropertyName().equals(PROP_SELECTEDTIME)) { Double dttm = (Double) event.getNewValue(); if (dttm != null) { setTime(dttm.doubleValue(), true); } } }
From source file:ucar.unidata.idv.control.chart.ChartWrapper.java
/** * Handle the event//from w w w.j a va2s. c o m * * @param event The event */ public void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals(PROP_TIMERANGE)) { try { loadData(); } catch (Exception exc) { LogUtil.logException("Error creating data set", exc); } return; } else if (event.getPropertyName().equals(PROP_REMOVED)) { Object source = event.getSource(); if (source == timeFilterSource) { setTimeFilterSource(null); } if (source == timeSelectSource) { setTimeSelectSource(null); } } super.propertyChange(event); }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.EditorControl.java
/** * Reacts to property change./* w ww . ja v a 2s. co m*/ * @see PropertyChangeListener#propertyChange(PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (SAVE_PROPERTY.equals(name) || DataComponent.DATA_MODIFIED_PROPERTY.equals(name) || PreviewPanel.PREVIEW_EDITED_PROPERTY.equals(name)) { view.setDataToSave(view.hasDataToSave()); } else if (MetadataViewer.SAVE_DATA_PROPERTY.equals(name)) { Boolean b = (Boolean) evt.getNewValue(); view.saveData(b.booleanValue()); } else if (MetadataViewer.CLEAR_SAVE_DATA_PROPERTY.equals(name) || MetadataViewer.ON_DATA_SAVE_PROPERTY.equals(name) || MetadataViewer.ADMIN_UPDATED_PROPERTY.equals(name)) { view.clearData(); } else if (UIUtilities.COLLAPSED_PROPERTY_JXTASKPANE.equals(name)) { view.handleTaskPaneCollapsed((JXTaskPane) evt.getSource()); } else if (FileChooser.APPROVE_SELECTION_PROPERTY.equals(name)) { File[] files = (File[]) evt.getNewValue(); view.attachFiles(files); } else if (AnnotationUI.REMOVE_ANNOTATION_PROPERTY.equals(name)) { Object object = evt.getNewValue(); if (object instanceof DocComponent) { DocComponent doc = (DocComponent) object; Object data = doc.getData(); if (data instanceof FileAnnotationData) { model.removeFileAnnotations(Collections.singletonList((FileAnnotationData) data)); } else if (data instanceof TagAnnotationData || data instanceof TermAnnotationData || data instanceof XMLAnnotationData || data instanceof LongAnnotationData || data instanceof DoubleAnnotationData || data instanceof BooleanAnnotationData) view.removeObject((DataObject) data); } else if (object instanceof TextualAnnotationComponent) { TextualAnnotationComponent doc = (TextualAnnotationComponent) object; view.removeObject(doc.getData()); } } else if (AnnotationUI.EDIT_TAG_PROPERTY.equals(name)) { Object object = evt.getNewValue(); if (object instanceof DocComponent) { //Save the tag w/o update. DataObject d = (DataObject) ((DocComponent) object).getData(); //Save the tag OmeroMetadataService svc = MetadataViewerAgent.getRegistry().getMetadataService(); long id = MetadataViewerAgent.getUserDetails().getId(); try { svc.saveData(model.getSecurityContext(), Arrays.asList(d), null, null, id); } catch (Exception e) { Logger l = MetadataViewerAgent.getRegistry().getLogger(); LogMessage msg = new LogMessage(); msg.print("Saving object"); msg.print(e); l.error(this, msg); } } } else if (OMEWikiComponent.WIKI_DATA_OBJECT_PROPERTY.equals(name)) { WikiDataObject object = (WikiDataObject) evt.getNewValue(); long id; switch (object.getIndex()) { case WikiDataObject.IMAGE: id = object.getId(); if (id < 0) viewImage(object.getName()); else viewImage(id); break; case WikiDataObject.PROTOCOL: viewProtocol(object.getId()); break; } } else if (SelectionWizard.SELECTED_ITEMS_PROPERTY.equals(name)) { Map m = (Map) evt.getNewValue(); if (m == null || m.size() != 1) return; Set set = m.entrySet(); Entry entry; Iterator i = set.iterator(); Class type; while (i.hasNext()) { entry = (Entry) i.next(); type = (Class) entry.getKey(); view.handleObjectsSelection(type, (Collection) entry.getValue()); } } else if (PreviewPanel.OPEN_FILE_PROPERTY.equals(name)) { Long id = (Long) evt.getNewValue(); if (id != null) viewProtocol(id.longValue()); } else if (MetadataViewer.SETTINGS_APPLIED_PROPERTY.equals(name)) { model.loadRenderingControl(RenderingControlLoader.RELOAD); view.onSettingsApplied(true); } else if (MetadataViewer.ACTIVITY_OPTIONS_PROPERTY.equals(name)) { List l = (List) evt.getNewValue(); view.activityOptions((Component) l.get(0), (Point) l.get(1), (Integer) l.get(2)); } else if (FigureDialog.CREATE_FIGURE_PROPERTY.equals(name)) { view.createFigure(evt.getNewValue()); } else if (FigureDialog.CLOSE_FIGURE_PROPERTY.equals(name)) { figureDialog = null; } else if (MetadataViewer.CLOSE_RENDERER_PROPERTY.equals(name)) { view.discardRenderer(evt.getNewValue()); } else if (MetadataViewer.RELATED_NODES_PROPERTY.equals(name)) { view.onRelatedNodesSet(); } else if (ScriptingDialog.RUN_SELECTED_SCRIPT_PROPERTY.equals(name)) { //view.manageScript((ScriptObject) evt.getNewValue(), // MetadataViewer.RUN); } else if (ScriptingDialog.DOWNLOAD_SELECTED_SCRIPT_PROPERTY.equals(name)) { Object value = evt.getNewValue(); if (value instanceof ScriptObject) view.manageScript((ScriptObject) value, MetadataViewer.DOWNLOAD); else if (value instanceof String) { ScriptObject script = view.getScriptFromName((String) value); if (script != null) view.manageScript(script, MetadataViewer.DOWNLOAD); } } else if (ScriptingDialog.VIEW_SELECTED_SCRIPT_PROPERTY.equals(name)) { Object value = evt.getNewValue(); if (value instanceof ScriptObject) view.manageScript((ScriptObject) value, MetadataViewer.VIEW); else if (value instanceof String) { ScriptObject script = view.getScriptFromName((String) value); if (script != null) view.manageScript(script, MetadataViewer.VIEW); } } else if (AnalysisResultsItem.ANALYSIS_RESULTS_DELETE.equals(name)) { AnalysisResultsItem item = (AnalysisResultsItem) evt.getNewValue(); List<FileAnnotationData> list = item.getAttachments(); view.fireAnnotationsDeletion(list); } else if (AnalysisResultsItem.ANALYSIS_RESULTS_VIEW.equals(name)) { AnalysisResultsItem item = (AnalysisResultsItem) evt.getNewValue(); if (view.getRndIndex() == MetadataViewer.RND_GENERAL) { model.displayAnalysisResults(item); /* ViewImage event = new ViewImage(item.getData(), null); event.setAnalysis(item); EventBus bus = MetadataViewerAgent.getRegistry().getEventBus(); bus.post(event); */ } else { model.displayAnalysisResults(item); } } else if (AnalysisResultsItem.ANALYSIS_RESULTS_CANCEL.equals(name)) { AnalysisResultsItem item = (AnalysisResultsItem) evt.getNewValue(); view.cancelAnalysisResultsLoading(item); } }
From source file:org.openconcerto.sql.model.SQLDataSource.java
private SQLDataSource(DBSystemRoot sysRoot) { this.sysRoot = sysRoot; // on a besoin d'une implementation synchronise this.handlers = new Hashtable<Thread, HandlersStack>(); // weak, since this is only a hint to avoid initializing the connection // on each borrowal this.schemaUptodate = new WeakHashMap<Connection, Object>(); this.uptodate = new WeakHashMap<Connection, Object>(); this.initialShemaSet = false; this.initialShema = null; // see #getNewConnection(boolean) this.setValidationQuery("SELECT 1"); this.setTestOnBorrow(false); this.setInitialSize(3); this.setMaxActive(48); // creating connections is quite costly so make sure we always have a couple free this.setMinIdle(2); // but not too much as it can lock out other users (the server has a max connection count) this.setMaxIdle(16); this.setBlockWhenExhausted(false); // check 5 connections every 4 seconds this.setTimeBetweenEvictionRunsMillis(4000); this.setNumTestsPerEvictionRun(5); // kill extra (above minIdle) connections after 40s this.setSoftMinEvictableIdleTimeMillis(TimeUnit.SECONDS.toMillis(40)); // kill idle connections after 30 minutes (even if it means re-creating some new ones // immediately afterwards to ensure minIdle connections) this.setMinEvictableIdleTimeMillis(TimeUnit.MINUTES.toMillis(30)); // the default of many systems this.txIsolation = Connection.TRANSACTION_READ_COMMITTED; // by definition unknown without a connection this.dbTxIsolation = null; // it's rare that DB configuration changes, and it's expensive to add a trip to the server // for each new connection this.checkOnceDBTxIsolation = true; // see #createDataSource() for properties not supported by this class this.tables = Collections.emptySet(); this.descL = new PropertyChangeListener() { @Override/*from www . j a va 2s.c o m*/ public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("descendants")) { // the dataSource must always have all tables, to listen to them for its cache setTables(((DBSystemRoot) evt.getSource()).getDescs(SQLTable.class)); } } }; this.sysRoot.addListener(this.descL); this.cache = null; this.cacheEnabled = false; }