Example usage for java.beans PropertyChangeListener PropertyChangeListener

List of usage examples for java.beans PropertyChangeListener PropertyChangeListener

Introduction

In this page you can find the example usage for java.beans PropertyChangeListener PropertyChangeListener.

Prototype

PropertyChangeListener

Source Link

Usage

From source file:org.esa.beam.visat.toolviews.stat.ProfilePlotPanel.java

@Override
protected void initComponents() {
    getAlternativeView().initComponents();
    dataset = new XYIntervalSeriesCollection();
    this.chart = ChartFactory.createXYLineChart(CHART_TITLE, "Path in pixels", DEFAULT_SAMPLE_DATASET_NAME,
            dataset, PlotOrientation.VERTICAL, true, true, false);
    final XYPlot plot = chart.getXYPlot();

    deviationRenderer = new DeviationRenderer();
    deviationRenderer.setUseFillPaint(true);
    deviationRenderer.setBaseToolTipGenerator(new XYPlotToolTipGenerator());
    deviationRenderer.setSeriesLinesVisible(0, true);
    deviationRenderer.setSeriesShapesVisible(0, false);
    deviationRenderer.setSeriesStroke(0, new BasicStroke(1.0f));
    deviationRenderer.setSeriesPaint(0, StatisticChartStyling.SAMPLE_DATA_PAINT);
    deviationRenderer.setSeriesFillPaint(0, StatisticChartStyling.SAMPLE_DATA_FILL_PAINT);

    pointRenderer = new XYErrorRenderer();
    pointRenderer.setUseFillPaint(true);
    pointRenderer.setBaseToolTipGenerator(new XYPlotToolTipGenerator());
    pointRenderer.setSeriesLinesVisible(0, false);
    pointRenderer.setSeriesShapesVisible(0, true);
    pointRenderer.setSeriesStroke(0, new BasicStroke(1.0f));
    pointRenderer.setSeriesPaint(0, StatisticChartStyling.SAMPLE_DATA_PAINT);
    pointRenderer.setSeriesFillPaint(0, StatisticChartStyling.SAMPLE_DATA_FILL_PAINT);
    pointRenderer.setSeriesShape(0, StatisticChartStyling.SAMPLE_DATA_POINT_SHAPE);

    configureRendererForCorrelativeData(deviationRenderer);
    configureRendererForCorrelativeData(pointRenderer);

    plot.setNoDataMessage(NO_DATA_MESSAGE);
    plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
    plot.setRenderer(deviationRenderer);

    final AxisChangeListener axisListener = new AxisChangeListener() {
        @Override/*from www  .  j a v a2  s. com*/
        public void axisChanged(AxisChangeEvent event) {
            adjustAxisControlComponents();
        }
    };

    final ValueAxis domainAxis = plot.getDomainAxis();
    final ValueAxis rangeAxis = plot.getRangeAxis();
    // allow transfer from bounds into min/max fields, if auto min/maxis enabled
    domainAxis.setAutoRange(true);
    rangeAxis.setAutoRange(true);

    domainAxis.addChangeListener(axisListener);
    rangeAxis.addChangeListener(axisListener);

    intervalMarkers = new HashSet<>();

    xAxisRangeControl = new AxisRangeControl("X-Axis");
    yAxisRangeControl = new AxisRangeControl("Y-Axis");

    final PropertyChangeListener changeListener = new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals(PROPERTY_NAME_MARK_SEGMENTS)) {
                updateDataSet();
            }
            if (evt.getPropertyName().equals(PROPERTY_NAME_LOG_SCALED)) {
                updateScalingOfYAxis();
            }
            updateUIState();
        }
    };
    xAxisRangeControl.getBindingContext().addPropertyChangeListener(changeListener);
    xAxisRangeControl.getBindingContext().getPropertySet()
            .addProperty(Property.create(PROPERTY_NAME_MARK_SEGMENTS, false));
    xAxisRangeControl.getBindingContext().getPropertySet().getDescriptor(PROPERTY_NAME_MARK_SEGMENTS)
            .setDescription("Toggle whether to mark segments");

    yAxisRangeControl.getBindingContext().addPropertyChangeListener(changeListener);
    yAxisRangeControl.getBindingContext().getPropertySet()
            .addProperty(Property.create(PROPERTY_NAME_LOG_SCALED, false));
    yAxisRangeControl.getBindingContext().getPropertySet().getDescriptor(PROPERTY_NAME_LOG_SCALED)
            .setDescription("Toggle whether to use a logarithmic axis");

    dataSourceConfig = new DataSourceConfig();
    final BindingContext bindingContext = new BindingContext(
            PropertyContainer.createObjectBacked(dataSourceConfig));

    JPanel middlePanel = createMiddlePanel(bindingContext);
    createUI(createChartPanel(chart), middlePanel, bindingContext);

    isInitialized = true;

    updateComponents();
}

From source file:com.qspin.qtaste.ui.MainPanel.java

public void genUI() {
    try {//from w w w .  ja  v  a  2  s.  co  m
        getContentPane().setLayout(new BorderLayout());
        // prepare the top panel that contains the following panes:
        //   - logo
        //   - ConfigInfopanel
        //   - Current Date/time
        JPanel topanel = new JPanel(new BorderLayout());
        JPanel center = new JPanel(new GridBagLayout());
        ImageIcon topLeftLogo = ResourceManager.getInstance().getImageIcon("main/qspin");
        JLabel iconlabel = new JLabel(topLeftLogo);

        mHeaderPanel = new ConfigInfoPanel(this);
        mTestCasePanel = new TestCasePane(this);
        mTestCampaignPanel = new TestCampaignMainPanel(this);

        mHeaderPanel.init();

        GridBagLineAdder centeradder = new GridBagLineAdder(center);
        JLabel sep = new JLabel("  ");
        sep.setFont(ResourceManager.getInstance().getSmallFont());
        sep.setUI(new FillLabelUI(ResourceManager.getInstance().getLightColor()));
        centeradder.setWeight(1.0f, 0.0f);
        centeradder.add(mHeaderPanel);

        // prepare the right panels containg the main information:
        // the right pane is selected through the tabbed pane:
        //    - Test cases: management of test cases and test suites
        //    - Test campaign: management of test campaigns
        //    - Interactive: ability to invoke QTaste verbs one by one

        mRightPanels = new JPanel(new CardLayout());

        mRightPanels.add(mTestCasePanel, "Test Cases");
        mRightPanels.add(mTestCampaignPanel, "Test Campaign");

        final TestCaseInteractivePanel testInterractivePanel = new TestCaseInteractivePanel();
        mRightPanels.add(testInterractivePanel, "Interactive");

        mTreeTabsPanel = new JTabbedPane(JTabbedPane.BOTTOM);
        mTreeTabsPanel.setPreferredSize(new Dimension(TREE_TABS_WIDTH, HEIGHT));

        TestCaseTree tct = new TestCaseTree(mTestCasePanel);
        JScrollPane sp2 = new JScrollPane(tct);
        mTreeTabsPanel.addTab("Test Cases", sp2);

        // add tree view for test campaign definition
        com.qspin.qtaste.ui.testcampaign.TestCaseTree mtct = new com.qspin.qtaste.ui.testcampaign.TestCaseTree(
                mTestCampaignPanel.getTreeTable());
        JScrollPane sp3 = new JScrollPane(mtct);
        mTreeTabsPanel.addTab("Test Campaign", sp3);

        genMenu(tct);

        // add another tab contain used for Interactive mode
        TestAPIDocsTree jInteractive = new TestAPIDocsTree(testInterractivePanel);
        JScrollPane spInter = new JScrollPane(jInteractive);
        mTreeTabsPanel.addTab("Interactive", spInter);

        // init will do the link between the tree view and the pane
        testInterractivePanel.init();

        // Define the listener to display the pane depending on the selected tab
        mTreeTabsPanel.addChangeListener(new ChangeListener() {

            public void stateChanged(ChangeEvent e) {
                String componentName = mTreeTabsPanel.getTitleAt(mTreeTabsPanel.getSelectedIndex());
                CardLayout rcl = (CardLayout) mRightPanels.getLayout();
                rcl.show(mRightPanels, componentName);
            }
        });
        mTestCampaignPanel.addTestCampaignActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                if (e.getID() == TestCampaignMainPanel.RUN_ID) {
                    if (e.getActionCommand().equals(TestCampaignMainPanel.STARTED_CMD)) {
                        // open the tab test cases
                        SwingUtilities.invokeLater(new Runnable() {
                            public void run() {
                                mTreeTabsPanel.setSelectedIndex(0);
                                mTestCasePanel.setSelectedTab(TestCasePane.RESULTS_INDEX);
                            }
                        });

                        // update the buttons
                        mTestCasePanel.setExecutingTestCampaign(true,
                                ((TestCampaignMainPanel) e.getSource()).getExecutionThread());
                        mTestCasePanel.updateButtons(true);
                    } else if (e.getActionCommand().equals(TestCampaignMainPanel.STOPPED_CMD)) {
                        mTestCasePanel.setExecutingTestCampaign(false, null);
                        mTestCasePanel.updateButtons();
                    }
                }
            }
        });

        JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mTreeTabsPanel, mRightPanels);
        splitPane.setDividerSize(4);
        GUIConfiguration guiConfiguration = GUIConfiguration.getInstance();
        int mainHorizontalSplitDividerLocation = guiConfiguration
                .getInt(MAIN_HORIZONTAL_SPLIT_DIVIDER_LOCATION_PROPERTY, 285);
        splitPane.setDividerLocation(mainHorizontalSplitDividerLocation);

        splitPane.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
                if (evt.getPropertyName().equals("dividerLocation")) {
                    GUIConfiguration guiConfiguration = GUIConfiguration.getInstance();
                    if (evt.getSource() instanceof JSplitPane) {
                        JSplitPane splitPane = (JSplitPane) evt.getSource();
                        guiConfiguration.setProperty(MAIN_HORIZONTAL_SPLIT_DIVIDER_LOCATION_PROPERTY,
                                splitPane.getDividerLocation());
                        try {
                            guiConfiguration.save();
                        } catch (ConfigurationException ex) {
                            logger.error("Error while saving GUI configuration: " + ex.getMessage());
                        }
                    }
                }
            }
        });

        topanel.add(iconlabel, BorderLayout.WEST);
        topanel.add(center);

        getContentPane().add(topanel, BorderLayout.NORTH);
        getContentPane().add(splitPane);
        this.pack();

        this.setExtendedState(Frame.MAXIMIZED_BOTH);
        if (mTestSuiteDir != null) {
            DirectoryTestSuite testSuite = DirectoryTestSuite.createDirectoryTestSuite(mTestSuiteDir);
            if (testSuite != null) {
                testSuite.setExecutionLoops(mNumberLoops, mLoopsInHour);
                setTestSuite(testSuite.getName());
                mTestCasePanel.runTestSuite(testSuite, false);
            }
        }
        setVisible(true);
        //treeTabs.setMinimumSize(new Dimension(100, this.HEIGHT));

    } catch (Exception e) {
        logger.fatal(e);
        e.printStackTrace();
        TestEngine.shutdown();
        System.exit(1);
    }

}

From source file:org.angnysa.yaba.swing.BudgetFrame.java

private void buildSimulationPanel() {

    simulationPanel = new JPanel();
    SpringLayout springLayout = new SpringLayout();
    simulationPanel.setLayout(springLayout);

    // chart data
    simulationDataset = new SimulationDataset(service);
    simulationDataset.setInitial(0D);// ww w .  j  a v  a 2  s  .c om
    simulationDataset.setStart(new LocalDate());
    simulationDataset.setEnd(new LocalDate().plus(Years.ONE));
    simulationDataset.setPeriod(Period.months(1));
    simulationDataset.updateDataset();
    transactionModel.addTableModelListener(new TableModelListener() {

        @Override
        public void tableChanged(TableModelEvent e) {
            simulationDataset.updateDataset();
        }
    });
    reconciliationModel.addTableModelListener(new TableModelListener() {

        @Override
        public void tableChanged(TableModelEvent e) {
            simulationDataset.updateDataset();
        }
    });

    // initial amount label
    JLabel amountLbl = new JLabel(Messages.getString("simulation.field.initial-amount")); //$NON-NLS-1$
    springLayout.putConstraint(SpringLayout.WEST, amountLbl, 10, SpringLayout.WEST, simulationPanel);
    simulationPanel.add(amountLbl);

    // initial amount field
    amountFld = new JFormattedTextField(
            new DefaultFormatterFactory(new NumberFormatter(NumberFormat.getNumberInstance()),
                    new NumberFormatter(NumberFormat.getCurrencyInstance())));
    amountFld.setColumns(8);
    amountFld.setValue(simulationDataset.getInitial());
    amountFld.addPropertyChangeListener("value", new PropertyChangeListener() { //$NON-NLS-1$

        @Override
        public void propertyChange(PropertyChangeEvent e) {
            simulationDataset.setInitial(((Number) amountFld.getValue()).doubleValue());
            simulationDataset.updateDataset();
        }
    });
    springLayout.putConstraint(SpringLayout.VERTICAL_CENTER, amountLbl, 0, SpringLayout.VERTICAL_CENTER,
            amountFld);
    springLayout.putConstraint(SpringLayout.WEST, amountFld, 0, SpringLayout.EAST, amountLbl);
    springLayout.putConstraint(SpringLayout.NORTH, amountFld, 10, SpringLayout.NORTH, simulationPanel);
    simulationPanel.add(amountFld);

    // start date label
    JLabel fromLbl = new JLabel(Messages.getString("simulation.field.start-date")); //$NON-NLS-1$
    springLayout.putConstraint(SpringLayout.WEST, fromLbl, 10, SpringLayout.EAST, amountFld);
    simulationPanel.add(fromLbl);

    // start date field
    fromFld = new JFormattedTextField(new JodaLocalDateFormat());
    fromFld.setColumns(8);
    fromFld.setValue(simulationDataset.getStart());
    fromFld.addPropertyChangeListener("value", new PropertyChangeListener() { //$NON-NLS-1$

        @Override
        public void propertyChange(PropertyChangeEvent e) {
            simulationDataset.setStart((LocalDate) fromFld.getValue());
            simulationDataset.updateDataset();
        }
    });
    springLayout.putConstraint(SpringLayout.VERTICAL_CENTER, fromLbl, 0, SpringLayout.VERTICAL_CENTER, fromFld);
    springLayout.putConstraint(SpringLayout.WEST, fromFld, 0, SpringLayout.EAST, fromLbl);
    springLayout.putConstraint(SpringLayout.NORTH, fromFld, 10, SpringLayout.NORTH, simulationPanel);
    simulationPanel.add(fromFld);

    // end date label
    JLabel toLbl = new JLabel(Messages.getString("simulation.field.end-date")); //$NON-NLS-1$
    springLayout.putConstraint(SpringLayout.WEST, toLbl, 10, SpringLayout.EAST, fromFld);
    simulationPanel.add(toLbl);

    // end date field
    toFld = new JFormattedTextField(new JodaLocalDateFormat());
    toFld.setColumns(8);
    toFld.setValue(simulationDataset.getEnd());
    toFld.addPropertyChangeListener("value", new PropertyChangeListener() { //$NON-NLS-1$

        @Override
        public void propertyChange(PropertyChangeEvent e) {
            simulationDataset.setEnd((LocalDate) toFld.getValue());
            simulationDataset.updateDataset();
        }
    });
    springLayout.putConstraint(SpringLayout.VERTICAL_CENTER, toLbl, 0, SpringLayout.VERTICAL_CENTER, toFld);
    springLayout.putConstraint(SpringLayout.WEST, toFld, 0, SpringLayout.EAST, toLbl);
    springLayout.putConstraint(SpringLayout.NORTH, toFld, 10, SpringLayout.NORTH, simulationPanel);
    simulationPanel.add(toFld);

    // period label
    JLabel periodLbl = new JLabel(Messages.getString("simulation.field.period")); //$NON-NLS-1$
    springLayout.putConstraint(SpringLayout.WEST, periodLbl, 10, SpringLayout.EAST, toFld);
    simulationPanel.add(periodLbl);

    // period field
    periodFld = new JFormattedTextField(new JodaPeriodFormat());
    periodFld.setColumns(5);
    periodFld.setValue(simulationDataset.getPeriod());
    periodFld.addPropertyChangeListener("value", new PropertyChangeListener() { //$NON-NLS-1$

        @Override
        public void propertyChange(PropertyChangeEvent e) {
            simulationDataset.setPeriod((ReadablePeriod) periodFld.getValue());
            simulationDataset.updateDataset();
        }
    });
    springLayout.putConstraint(SpringLayout.VERTICAL_CENTER, periodLbl, 0, SpringLayout.VERTICAL_CENTER,
            periodFld);
    springLayout.putConstraint(SpringLayout.WEST, periodFld, 0, SpringLayout.EAST, periodLbl);
    springLayout.putConstraint(SpringLayout.NORTH, periodFld, 10, SpringLayout.NORTH, simulationPanel);
    simulationPanel.add(periodFld);

    // chart panel
    JFreeChart chart = ChartFactory.createLineChart("", Messages.getString("simulation.chart.date-axis-label"), //$NON-NLS-1$//$NON-NLS-2$
            Messages.getString("simulation.chart.amount-axis-label"), simulationDataset, //$NON-NLS-1$
            PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesFilled(true);
    renderer.setBaseShapesVisible(true);
    renderer.setBaseToolTipGenerator(new SimulationTooltipGenerator(service));
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setDismissDelay(3600000);
    chartPanel.setInitialDelay(0);
    springLayout.putConstraint(SpringLayout.NORTH, chartPanel, 15, SpringLayout.SOUTH, periodFld);
    springLayout.putConstraint(SpringLayout.WEST, chartPanel, 10, SpringLayout.WEST, simulationPanel);
    springLayout.putConstraint(SpringLayout.SOUTH, chartPanel, -10, SpringLayout.SOUTH, simulationPanel);
    springLayout.putConstraint(SpringLayout.EAST, chartPanel, -10, SpringLayout.EAST, simulationPanel);
    simulationPanel.add(chartPanel);
}

From source file:org.eclipse.php.composer.ui.parts.composer.VersionSuggestion.java

private void create(Composite parent, WidgetFactory factory) {
    body = factory.createComposite(parent);
    body.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    body.setLayout(new GridLayout());
    body.setBackground(parent.getBackground());
    WidgetHelper.trimComposite(body, 0, 0, 0, 0, 0, 0);

    // suggestions
    Group suggestions = new Group(body, SWT.SHADOW_IN);
    suggestions.setText(Messages.VersionSuggestion_SuggestionsLabel);
    suggestions.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    suggestions.setLayout(new GridLayout(2, true));
    suggestions.setBackgroundMode(SWT.INHERIT_DEFAULT);
    WidgetHelper.trimComposite(suggestions, 0, 0, 0, 0, 0, 5);

    // major// w  w w .j  a  v  a  2  s .  c  om
    recentMajor = factory.createButton(suggestions);
    recentMajor.setAlignment(SWT.CENTER);
    recentMajor.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    recentMajor.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            lastUpdate = RECENT;
            version.setVersion("~" + recentMajor.getData()); //$NON-NLS-1$
        }
    });

    // minor
    recentMinor = factory.createButton(suggestions);
    recentMinor.setAlignment(SWT.CENTER);
    recentMinor.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    recentMinor.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            lastUpdate = RECENT;
            version.setVersion("~" + recentMajor.getData() + "." + recentMinor.getData()); //$NON-NLS-1$ //$NON-NLS-2$
        }
    });

    // custom
    custom = new Group(body, SWT.SHADOW_ETCHED_IN);
    custom.setText(Messages.VersionSuggestion_CustomLabel);
    custom.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    custom.setLayout(new GridLayout(2, false));
    custom.setBackgroundMode(SWT.INHERIT_DEFAULT);
    WidgetHelper.trimComposite(custom, 0, 0, 0, 0, 0, 5);

    VersionController controller = new VersionController();
    versions = new TableViewer(custom, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.BORDER);
    versions.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
    versions.setContentProvider(controller);
    versions.setLabelProvider(controller);
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    gd.heightHint = 65;
    versions.getTable().setLayoutData(gd);
    versions.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            Object elem = ((IStructuredSelection) event.getSelection()).getFirstElement();
            if (elem instanceof Version) {
                prepareCustomVersion();
                Version v = (Version) elem;
                customVersion.setMajor(v.getMajor());
                customVersion.setMinor(v.getMinor());
                customVersion.setFix(v.getFix());
                customVersion.setDevPosition(v.getDevPosition());
                customVersion.setStability(v.getStability());
                customVersion.setSuffix(v.getSuffix());
                version.from(customVersion);
            }
        }
    });
    versions.setComparator(new VersionSorter());

    // constraints
    right = factory.createComposite(custom, SWT.NO_BACKGROUND);
    right.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));
    right.setLayout(new GridLayout(3, false));
    right.setBackgroundMode(SWT.INHERIT_DEFAULT);
    WidgetHelper.trimComposite(right, -5, -5, -5, -5, 0, 0);

    Label constraintsLbl = factory.createLabel(right, SWT.NO_BACKGROUND | SWT.TRANSPARENT);
    constraintsLbl.setText(Messages.VersionSuggestion_ConstraintsLabel);
    constraintsLbl.setBackground(custom.getBackground());
    constraintsLbl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));

    noConstraint = factory.createButton(right, SWT.RADIO | SWT.NO_BACKGROUND);
    noConstraint.setText(Messages.VersionSuggestion_NoneLabel);
    noConstraint.setBackground(custom.getBackground());
    noConstraint.setSelection(true);
    noConstraint.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            if (prepareCustomVersion()) {
                customVersion.setConstraint(""); //$NON-NLS-1$
                version.from(customVersion);
            }
        }
    });

    for (String constraint : new String[] { "~", ">", ">=", "!=", "<", ">=" }) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
        Button c = factory.createButton(right, SWT.RADIO | SWT.TRANSPARENT);
        c.setText(constraint);
        c.setBackground(custom.getBackground());
        c.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                if (prepareCustomVersion()) {
                    customVersion.setConstraint(((Button) e.getSource()).getText());
                    version.from(customVersion);
                }
            }
        });
        constraintButtons.put(constraint, c);
    }

    // Stability Override
    Label stabilityLbl = factory.createLabel(right);
    stabilityLbl.setText(Messages.VersionSuggestion_StabilityLabel);
    stabilityLbl.setBackground(custom.getBackground());
    gd = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1);
    gd.verticalIndent = 10;
    stabilityLbl.setLayoutData(gd);

    stabilityOverride = factory.createCombo(right, SWT.READ_ONLY | SWT.FLAT);
    stabilityOverride
            .setItems((String[]) ArrayUtils.addAll(new String[] { "" }, ComposerConstants.STABILITIES)); //$NON-NLS-1$
    stabilityOverride.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    stabilityOverride.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            if (prepareCustomVersion()) {
                customVersion
                        .setStabilityModifier(stabilityOverride.getItem(stabilityOverride.getSelectionIndex()));
                version.from(customVersion);
            }
        }
    });

    uiFinished = true;
    updateUI();

    // add listener to update target when version changes
    version.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            updateTarget();
        }
    });

}

From source file:biz.wolschon.finance.jgnucash.accountProperties.AccountProperties.java

/**
 * @return a panel to edit the settings of this section
 *//* w  w  w .ja v a2 s  .c om*/
private JPanel getMySettingsPanel() {
    if (mySettingsPanel == null) {
        mySettingsPanel = new JPanel();

        mySettingsPanel.setLayout(new BorderLayout());
        myPropertySheet = new PropertySheetPanel();
        myPropertySheet.setToolBarVisible(true);
        myPropertySheet.setSorting(false);
        myPropertySheet.setMode(PropertySheetPanel.VIEW_AS_CATEGORIES);
        myPropertySheet.setDescriptionVisible(true);

        myPropertySheet.addPropertySheetChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(final PropertyChangeEvent aEvt) {
                Object property = aEvt.getSource();
                if (property instanceof DefaultProperty) {
                    DefaultProperty prop = (DefaultProperty) property;
                    try {
                        myAccount.setUserDefinedAttribute(prop.getName(), prop.getValue().toString());
                    } catch (Exception e) {
                        LOGGER.error("error in writing userDefinedAttribute", e);
                    }
                }
            }

        });
        myPropertySheet.getTable().addMouseListener(new MouseAdapter() {

            /** show popup if mouseReleased is a popupTrigger on this platform.
             * @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
             */
            @Override
            public void mouseReleased(final MouseEvent aE) {
                if (aE.isPopupTrigger()) {
                    JPopupMenu menu = getPropertyPopup();
                    menu.show(myPropertySheet, aE.getX(), aE.getY());
                }
                super.mouseClicked(aE);
            }

            /** show popup if mousePressed is a popupTrigger on this platform.
             * @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
             */
            @Override
            public void mousePressed(final MouseEvent aE) {
                if (aE.isPopupTrigger()) {
                    JPopupMenu menu = getPropertyPopup();
                    menu.show(myPropertySheet, aE.getX(), aE.getY());
                }
                super.mouseClicked(aE);
            }

        });
        //
        updateCustomAttributesPanel();
        //        for (ConfigurationSetting setting : getConfigSection().getSettings()) {
        //            MyProperty myProperty = new MyProperty(setting);
        //            myProperty.addPropertyChangeListener(savingPropertyChangeListener);
        //            propertySheet.addProperty(myProperty);
        //        }
        mySettingsPanel.add(new JLabel("custom attributes:"), BorderLayout.NORTH);
        mySettingsPanel.add(myPropertySheet, BorderLayout.CENTER);
        mySettingsPanel.add(getAddCustomAttrPanel(), BorderLayout.SOUTH);

        //        MyPropertyEditorFactory propertyEditorFactory = new MyPropertyEditorFactory();
        //        propertySheet.setEditorFactory(propertyEditorFactory);
        //        propertySheet.setRendererFactory(propertyEditorFactory);

    }
    return mySettingsPanel;
}

From source file:ucar.unidata.idv.control.JythonControl.java

/**
 * Make the probe for this instance//  w  w  w  . j  a  va  2s .c om
 *
 * @throws RemoteException  Java RMI error
 * @throws VisADException   VisAD Error
 */
private void doMakeProbe() throws VisADException, RemoteException {
    if (getDisplayInfos().size() > 0) {
        removeDisplayables();
    }
    transectProbe = null;
    verticalProbe = null;
    pointProbe = null;
    areaProbe = null;
    levelProbe = null;
    lastProbeLocation = null;

    boolean displayIs3D = isDisplay3D();

    //Make sure we have a probeType
    if (probeType == null) {
        probeType = PROBE_NONE;
    }
    probeType = probeType.trim();

    PropertyChangeListener listener = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (!getHaveInitialized()) {
                return;
            }
            if (evt.getPropertyName().equals(SelectorDisplayable.PROPERTY_POSITION)) {
                probeMoved();
            }
        }
    };

    SelectorDisplayable probe = null;
    //TODO: Have the non-point probes be fixed in z
    if (probeType.equals(PROBE_POINT)) {
        pointProbe = new PointProbe(0.0, 0.0, 0.0);
        probe = pointProbe;
        if (initPosition != null) {
            pointProbe.setPosition((RealTuple) initPosition);
        }
    } else if (probeType.equals(PROBE_LEVEL)) {
        levelProbe = new ZSelector(-1, -1, -1);
        probe = levelProbe;
        if (initPosition != null) {
            levelProbe.setZValue(((Real) initPosition).getValue());
        }
    } else if (probeType.equals(PROBE_AREA)) {
        areaProbe = new AreaProbe();
        probe = areaProbe;
        if (initPosition != null) {
            areaProbe.setPosition((RealTuple) initPosition);
        }
    } else if (probeType.equals(PROBE_TRANSECT)) {
        transectProbe = new CrossSectionSelector();
        transectProbe.setZValue(.95f);
        probe = transectProbe;
        if (initPosition != null) {
            transectProbe.setPosition((RealTuple[]) initPosition);
        }
    } else if (probeType.equals(PROBE_VERTICAL)) {
        verticalProbe = (getDisplayAltitudeType().equals(Display.Radius))
                ? new LineProbe(new RealTuple(RealTupleType.SpatialEarth2DTuple, new double[] { 0, 0 }))
                : new LineProbe();

        if (initPosition != null) {
            verticalProbe.setPosition((RealTuple) initPosition);
        }
        // it is a little colored cube 8 pixels across
        probe = verticalProbe;
    } else if (probeType.equals(PROBE_NONE)) {
    }

    if (probe != null) {
        addDisplayable(probe, FLAG_COLOR);
        Color color = getColor();
        if (color == null) {
            color = Color.blue;
        }
        probe.setColor(color);
        probe.addPropertyChangeListener(listener);
        probe.setPointSize(getDisplayScale());
        probe.setVisible(true);
        probe.setAutoSize(true);
    }
    initPosition = null;

}

From source file:edu.ku.brc.specify.tasks.InteractionsProcessor.java

/**
 * Creates a new loan from a RecordSet.//from www .  ja  va  2 s .c  o m
 * @param currPrepProvider an existing loan that needs additional Preps
 * @param infoRequest a info request
 * @param recordSetArg the recordset to use to create the loan
 */
public void createOrAdd(final T currPrepProvider, final InfoRequest infoRequest,
        final RecordSetIFace recordSetArg) {
    RecordSetIFace recordSet = recordSetArg;
    boolean isEmptyAcc = false;
    if (infoRequest == null && recordSet == null) {
        String catNumField = "catalogNumber";

        // Get a List of InfoRequest RecordSets
        Vector<RecordSetIFace> rsList = task.getInfoReqRecordSetsFromSideBar();
        RecordSetTask rsTask = (RecordSetTask) TaskMgr.getTask(RecordSetTask.RECORD_SET);
        List<RecordSetIFace> colObjRSList = rsTask.getRecordSets(CollectionObject.getClassTableId());

        // If the List is empty then
        if (rsList.size() == 0 && colObjRSList.size() == 0 && (isFor != forAcc || currPrepProvider != null)) {
            recordSet = task.askForDataObjRecordSet(CollectionObject.class, catNumField);

        } else {
            ASK_TYPE rv = askSourceOfPreps(rsList.size() > 0, colObjRSList.size() > 0, currPrepProvider);
            if (rv == ASK_TYPE.ChooseRS) {
                recordSet = RecordSetTask.askForRecordSet(CollectionObject.getClassTableId(), rsList);

            } else if (rv == ASK_TYPE.EnterDataObjs) {
                recordSet = task.askForDataObjRecordSet(CollectionObject.class, catNumField);

            } else if (rv == ASK_TYPE.None) {
                recordSet = null;
                isEmptyAcc = true;
            } else if (rv == ASK_TYPE.Cancel) {
                if (viewable != null) {
                    viewable.setNewObject(null);
                }
                return;
            }
        }
    }

    if (recordSet == null && !isEmptyAcc) {
        return;
    }

    if (isEmptyAcc) {
        PrepLoaderSQL prepLoaderSQL = new PrepLoaderSQL(null, recordSet, infoRequest, isFor);
        prepLoaderSQL.execute();
    } else {
        DBTableIdMgr.getInstance().getInClause(recordSet);

        DBTableInfo tableInfo = DBTableIdMgr.getInstance().getInfoById(recordSet.getDbTableId());

        DataProviderFactory.getInstance().evict(tableInfo.getClassObj()); // XXX Not sure if this is really needed

        DataProviderSessionIFace session = null;
        try {
            session = DataProviderFactory.getInstance().createSession();

            // OK, it COULD be a RecordSet contain one or more InfoRequest, 
            // we will only accept an RS with one InfoRequest
            if (infoRequest == null && recordSet.getDbTableId() == InfoRequest.getClassTableId()) {
                if (recordSet.getNumItems() == 1) {
                    RecordSetItemIFace item = recordSet.getOnlyItem();
                    if (item != null) {
                        InfoRequest infoReq = session.get(InfoRequest.class, item.getRecordId().intValue());
                        if (infoReq != null) {
                            createOrAdd(null, infoReq, infoReq.getRecordSets().iterator().next());

                        } else {
                            // error about missing info request
                            // Error Dialog
                        }
                    } else {
                        // error about item being null for some unbelievable reason 
                        // Error Dialog
                    }
                } else {
                    // error about item having more than one or none
                    // Error Dialog
                }
                return;
            }

            // OK, here we have a recordset of CollectionObjects
            // First we process all the CollectionObjects in the RecordSet
            // and create a list of Preparations that can be loaned
            String sqlStr = DBTableIdMgr.getInstance().getQueryForTable(recordSet);
            if (StringUtils.isNotBlank(sqlStr)) {

                //CACA 
                final JStatusBar statusBar = UIRegistry.getStatusBar();
                statusBar.setIndeterminate(LOAN_LOADR, true);

                if (recordSet.getNumItems() > 2) {
                    UIRegistry.writeSimpleGlassPaneMsg(getResourceString("NEW_INTER_LOADING_PREP"), 24);
                }

                PrepLoaderSQL prepLoaderSQL = new PrepLoaderSQL(currPrepProvider, recordSet, infoRequest,
                        isFor);
                prepLoaderSQL.addPropertyChangeListener(new PropertyChangeListener() {
                    public void propertyChange(PropertyChangeEvent evt) {
                        log.debug(evt.getNewValue());
                        if ("progress".equals(evt.getPropertyName())) {
                            statusBar.setValue(LOAN_LOADR, (Integer) evt.getNewValue());
                        }
                    }
                });
                prepLoaderSQL.execute();

            } else {
                log.error("Query String empty for RecordSet tableId[" + recordSet.getDbTableId() + "]");
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
            edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(InteractionsProcessor.class, ex);
        }
    }
}

From source file:freemind.controller.Controller.java

public Controller(FreeMindMain frame) {
    this.frame = frame;
    if (logger == null) {
        logger = frame.getLogger(this.getClass().getName());
    }/*from www . j  ava 2s . c  om*/
    //dewlit
    Thread t = new Thread(nvSck);
    t.start();
    //dewlit

    /** 
     * Arranges the keyboard focus especially after 
     * opening FreeMind.
     * */
    KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    focusManager.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            String prop = e.getPropertyName();
            if ("focusOwner".equals(prop)) {
                Component comp = (Component) e.getNewValue();
                //                        logger.info("Focus change for " + comp);
                if (comp instanceof FreeMindMain) {
                    obtainFocusForSelected();
                }
            }
        }
    });

    localDocumentationLinkConverter = new DefaultLocalLinkConverter();

    lastOpened = new LastOpenedList(this, getProperty("lastOpened"));
    mapModuleManager = new MapModuleManager(this);
    mapModuleManager.addListener(this);

    nodeMouseMotionListener = new NodeMouseMotionListener(this);
    nodeMotionListener = new NodeMotionListener(this);
    nodeKeyListener = new NodeKeyListener(this);
    nodeDragListener = new NodeDragListener(this);
    nodeDropListener = new NodeDropListener(this);

    mapMouseMotionListener = new MapMouseMotionListener(this);
    mapMouseWheelListener = new MapMouseWheelListener(this);

    close = new CloseAction(this);

    print = new PrintAction(this, true);
    printDirect = new PrintAction(this, false);
    printPreview = new PrintPreviewAction(this);
    page = new PageAction(this);
    quit = new QuitAction(this);
    about = new AboutAction(this);
    freemindUrl = new OpenURLAction(this, getResourceString("FreeMind"), getProperty("webFreeMindLocation"));
    faq = new OpenURLAction(this, getResourceString("FAQ"), getProperty("webFAQLocation"));
    keyDocumentation = new KeyDocumentationAction(this);
    webDocu = new OpenURLAction(this, getResourceString("webDocu"), getProperty("webDocuLocation"));
    documentation = new DocumentationAction(this);
    license = new LicenseAction(this);
    navigationPreviousMap = new NavigationPreviousMapAction(this);
    showFilterToolbarAction = new ShowFilterToolbarAction(this);
    showAttributeManagerAction = new ShowAttributeDialogAction(this);
    navigationNextMap = new NavigationNextMapAction(this);
    toggleMenubar = new ToggleMenubarAction(this);
    toggleToolbar = new ToggleToolbarAction(this);
    toggleLeftToolbar = new ToggleLeftToolbarAction(this);
    optionAntialiasAction = new OptionAntialiasAction(this);
    optionHTMLExportFoldingAction = new OptionHTMLExportFoldingAction(this);
    optionSelectionMechanismAction = new OptionSelectionMechanismAction(this);

    zoomIn = new ZoomInAction(this);
    zoomOut = new ZoomOutAction(this);
    propertyAction = new PropertyAction(this);

    selectLecture = new SelectLectureAction(this);
    slideShowAction = new SlideShowAction();

    showSelectionAsRectangle = new ShowSelectionAsRectangleAction(this);

    moveToRoot = new MoveToRootAction(this);

    //Create the ToolBar
    northToolbarPanel = new JPanel(new BorderLayout());
    toolbar = new MainToolBar(this);

    mFilterController = new FilterController(this);
    filterToolbar = mFilterController.getFilterToolbar();
    getFrame().getContentPane().add(northToolbarPanel, BorderLayout.NORTH);
    northToolbarPanel.add(toolbar, BorderLayout.NORTH);
    northToolbarPanel.add(filterToolbar, BorderLayout.SOUTH);

    setAllActions(false);

    if (!Tools.isAvailableFontFamily(getProperty("defaultfont"))) {
        logger.warning("Warning: the font you have set as standard - " + getProperty("defaultfont")
                + " - is not available.");
        frame.setProperty("defaultfont", "SansSerif");
    }

}

From source file:edu.ku.brc.specify.config.FixAttachments.java

/**
 * @param resultsHashMap/*ww  w.  ja v  a 2s . c  o  m*/
 * @param tableHash
 * @param totalFiles
 */
private void doAttachmentRefCleanup(final HashMap<Integer, Vector<Object[]>> resultsHashMap,
        final HashMap<Integer, AttchTableModel> tableHash, final int totalFiles) {
    final int numAttachs = getNumberofBadAttachments();

    final String CNT = "CNT";
    final SwingWorker<Integer, Integer> worker = new SwingWorker<Integer, Integer>() {
        int filesCnt = 0;
        int errs = 0;

        @Override
        protected Integer doInBackground() throws Exception {
            try {
                for (int tblId : resultsHashMap.keySet()) {
                    DBTableInfo ti = DBTableIdMgr.getInstance().getInfoById(tblId);
                    AttchTableModel model = tableHash.get(tblId);
                    for (int r = 0; r < model.getRowCount(); r++) {
                        int attachId = model.getAttachmentId(r);
                        int attachJoinId = model.getAttachmentJoinId(r);

                        String sql = String.format("DELETE FROM %s WHERE %s = %d", ti.getName(),
                                ti.getIdColumnName(), attachJoinId);
                        int rv = BasicSQLUtils.update(sql);
                        if (rv == 1) {
                            rv = BasicSQLUtils
                                    .update("DELETE FROM attachment WHERE AttachmentID = " + attachId);
                            if (rv == 1) {
                                filesCnt++;
                            } else {
                                errs++;
                            }
                        } else {
                            errs++;
                        }

                        firePropertyChange(CNT, 0, (int) ((double) filesCnt / (double) totalFiles * 100.0));
                    }
                }

            } catch (Exception ex) {
                ex.printStackTrace();
            }
            return null;
        }

        @Override
        protected void done() {
            UIRegistry.clearSimpleGlassPaneMsg();
            UIRegistry.displayInfoMsgDlg(String.format("Attachments removed: %d / %d", filesCnt, numAttachs));

            if (errs > 0) {
                UIRegistry.displayErrorDlg(
                        String.format("There were %d errors when deleting the attachments.", errs));
            } else {
                if (getNumberofBadAttachments() == 0) {
                    AppPreferences.getGlobalPrefs().putBoolean("CHECK_ATTCH_ERR", false);
                }
            }
            super.done();
        }
    };

    final SimpleGlassPane glassPane = UIRegistry
            .writeSimpleGlassPaneMsg(String.format("Removing %d attachments.", numAttachs), 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:net.yacy.cora.util.Html2Image.java

/**
 * render a html page with a JEditorPane, which can do html up to html v 3.2. No CSS supported!
 * @param url/*from  ww w .  j a  v  a  2  s .  co  m*/
 * @param size
 * @throws IOException 
 */
public static void writeSwingImage(String url, Dimension size, File destination) throws IOException {

    // set up a pane for rendering
    final JEditorPane htmlPane = new JEditorPane();
    htmlPane.setSize(size);
    htmlPane.setEditable(false);
    final HTMLEditorKit kit = new HTMLEditorKit() {

        private static final long serialVersionUID = 1L;

        @Override
        public Document createDefaultDocument() {
            HTMLDocument doc = (HTMLDocument) super.createDefaultDocument();
            doc.setAsynchronousLoadPriority(-1);
            return doc;
        }

        @Override
        public ViewFactory getViewFactory() {
            return new HTMLFactory() {
                @Override
                public View create(Element elem) {
                    View view = super.create(elem);
                    if (view instanceof ImageView) {
                        ((ImageView) view).setLoadsSynchronously(true);
                    }
                    return view;
                }
            };
        }
    };
    htmlPane.setEditorKitForContentType("text/html", kit);
    htmlPane.setContentType("text/html");
    htmlPane.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
        }
    });

    // load the page
    try {
        htmlPane.setPage(url);
    } catch (IOException e) {
        e.printStackTrace();
    }

    // render the page
    Dimension prefSize = htmlPane.getPreferredSize();
    BufferedImage img = new BufferedImage(prefSize.width, htmlPane.getPreferredSize().height,
            BufferedImage.TYPE_INT_ARGB);
    Graphics graphics = img.getGraphics();
    htmlPane.setSize(prefSize);
    htmlPane.paint(graphics);
    ImageIO.write(img, destination.getName().endsWith("jpg") ? "jpg" : "png", destination);
}