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:dk.i2m.netbeans.modules.ldapexplorer.ui.ExplorerTopComponent.java

/**
 * Creates a new instance of {@link ExplorerTopComponent}.
 *///w ww. ja  v  a 2  s . c o m
public ExplorerTopComponent() {
    initComponents();
    this.addPropertyChangeListener("inQuery", new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent pce) {
            Boolean newValue = (Boolean) pce.getNewValue();
            assert (newValue != null);
            txtFilter.setEnabled(!newValue);
            btnFilter.setEnabled(!newValue);
            btnReset.setEnabled(!newValue);
            treePane.setEnabled(!newValue);
        }
    });
}

From source file:net.ftb.minecraft.MCInstaller.java

public static void setupNewStyle(final String installPath, final ModPack pack, final boolean isLegacy,
        final LoginResponse RESPONSE) {
    List<DownloadInfo> assets = gatherAssets(new File(installPath),
            pack.getMcVersion(Settings.getSettings().getPackVer(pack.getDir())), installPath);
    if (assets != null && assets.size() > 0) {
        Logger.logInfo("Checking/Downloading " + assets.size() + " assets, this may take a while...");

        final ProgressMonitor prog = new ProgressMonitor(LaunchFrame.getInstance(), "Downloading Files...", "",
                0, 100);/*from  w  w  w .ja  v a2s  .com*/
        prog.setMaximum(assets.size() * 100);

        final AssetDownloader downloader = new AssetDownloader(prog, assets) {
            @Override
            public void done() {
                try {
                    prog.close();
                    if (get()) {
                        Logger.logInfo("Asset downloading complete");
                        launchMinecraft(installPath, pack, RESPONSE, isLegacy);
                    } else {
                        ErrorUtils.tossError("Error occurred during downloading the assets");
                    }
                } catch (CancellationException e) {
                    Logger.logInfo("Asset download interrupted by user");
                } catch (Exception e) {
                    ErrorUtils.tossError("Failed to download files.", e);
                } finally {
                    LaunchFrame.getInstance().getEventBus().post(new EnableObjectsEvent());
                }
            }
        };

        downloader.addPropertyChangeListener(new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                if (prog.isCanceled()) {
                    downloader.cancel(false);
                    prog.close();
                } else if (!downloader.isCancelled()) {
                    if ("ready".equals(evt.getPropertyName()))
                        prog.setProgress(downloader.getReady());
                    if ("status".equals(evt.getPropertyName()))
                        prog.setNote(downloader.getStatus());
                }
            }
        });

        downloader.execute();
    } else if (assets == null) {
        LaunchFrame.getInstance().getEventBus().post(new EnableObjectsEvent());
    } else {
        launchMinecraft(installPath, pack, RESPONSE, isLegacy);
    }
}

From source file:ec.ui.view.res.ResidualsView.java

private void enableProperties() {
    this.addPropertyChangeListener(new PropertyChangeListener() {
        @Override//from  ww  w  . j  a va  2s  .  co  m
        public void propertyChange(PropertyChangeEvent evt) {
            switch (evt.getPropertyName()) {
            case "componentPopupMenu":
                onComponentPopupMenuChange();
                break;
            }
        }
    });
}

From source file:org.gitools.ui.app.heatmap.panel.details.boxes.DimensionBox.java

@Override
public void registerListeners() {
    dimension.addPropertyChangeListener(new PropertyChangeListener() {
        @Override/*  ww w.  j ava  2 s. c om*/
        public void propertyChange(PropertyChangeEvent evt) {
            if ((isAny(evt, HeatmapDimension.class, PROPERTY_FOCUS, PROPERTY_HEADERS, PROPERTY_SELECTED,
                    PROPERTY_SELECTED_HEADER, PROPERTY_VISIBLE))
                    || isAny(evt, HierarchicalClusterHeatmapHeader.class, PROPERTY_INTERACTION_LEVEL)) {
                update();
            }
        }
    });
}

From source file:com.stefanbrenner.droplet.ui.DevicePanel.java

/**
 * Create the panel./*from   w w w  . j av  a2 s.  c  om*/
 */
public DevicePanel(final JComponent parent, final IDroplet droplet, final T device) {

    this.parent = parent;

    setDevice(device);

    setLayout(new BorderLayout(0, 5));
    setBorder(BorderFactory.createLineBorder(Color.BLACK));
    setBackground(DropletColors.getBackgroundColor(device));

    BeanAdapter<T> adapter = new BeanAdapter<T>(device, true);

    // device name textfield
    txtName = BasicComponentFactory.createTextField(adapter.getValueModel(IDevice.PROPERTY_NAME));
    txtName.setHorizontalAlignment(SwingConstants.CENTER);
    txtName.setColumns(1);
    txtName.setToolTipText(device.getName());
    adapter.addBeanPropertyChangeListener(IDevice.PROPERTY_NAME, new PropertyChangeListener() {

        @Override
        public void propertyChange(final PropertyChangeEvent event) {
            txtName.setToolTipText(device.getName());
        }
    });
    add(txtName, BorderLayout.NORTH);

    // actions panel with scroll pane
    actionsPanel = new JPanel();
    actionsPanel.setLayout(new BoxLayout(actionsPanel, BoxLayout.Y_AXIS));
    actionsPanel.setBackground(getBackground());

    JScrollPane scrollPane = new JScrollPane(actionsPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    // resize vertical scrollbar
    scrollPane.getVerticalScrollBar().putClientProperty("JComponent.sizeVariant", "mini"); //$NON-NLS-1$ //$NON-NLS-2$
    SwingUtilities.updateComponentTreeUI(scrollPane);
    // we need no border
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    add(scrollPane, BorderLayout.CENTER);

    {
        JPanel panel = new JPanel();
        panel.setLayout(new GridLayout(0, 1));

        createAddButton(panel);

        // remove button
        JButton btnRemove = new JButton(Messages.getString("ActionDevicePanel.removeDevice")); //$NON-NLS-1$
        btnRemove.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent action) {
                int retVal = JOptionPane.showConfirmDialog(DevicePanel.this,
                        Messages.getString("ActionDevicePanel.removeDevice") + " '" + device.getName() + "'?", //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
                        StringUtils.EMPTY, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
                if (retVal == JOptionPane.YES_OPTION) {
                    droplet.removeDevice(device);
                }
            }
        });
        btnRemove.setFocusable(false);
        panel.add(btnRemove);

        add(panel, BorderLayout.SOUTH);
    }

}

From source file:org.openconcerto.sql.view.listview.ListSQLView.java

public ListSQLView(SQLComponent parent, String name, ItemPoolFactory factory/*
                                                                             * , ListItemSQLView
                                                                             * style
                                                                             */) {
    this.parent = parent;
    this.name = name;
    this.pool = factory.create(this);

    this.supp = new PropertyChangeSupport(this);
    this.items = new ArrayList<ListItemSQLView>();

    this.addValidListener(new ValidListener() {
        public void validChange(ValidObject src, ValidState newValue) {
            // compChanged(); FIXME
        }//ww w. j  a va 2s. c o m
    });

    this.addValueListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            ListSQLView.this.addBtn.setEnabled(getPool().availableItem());
        }
    });

    this.helper = new EmptyChangeSupport(this);

    this.addBtn = new JButton("Ajout");
    // for when an item is removed the following ones go up
    this.itemsPanel = new JPanel(new GridBagLayout());
    this.itemsConstraints = new GridBagConstraints();
    this.uiInit();
}

From source file:fr.crnan.videso3d.ihm.PLNSPanel.java

/**
 * // www .j  a  v  a 2  s  .  co m
 * @param path
 *            Chemin vers la base de donnes
 */
public PLNSPanel(final String path) {
    this.setLayout(new BorderLayout());

    this.add(createToolbar(), BorderLayout.NORTH);

    desktop = new TilingDesktopPane();
    desktop.setPreferredSize(new Dimension(800, 600));
    this.add(desktop);

    chartPanels = new ArrayList<ChartPanel>();

    final ProgressMonitor progressMonitorT = new ProgressMonitor(this, "Extraction des donnes", "", 0, 100,
            false, true, false);
    progressMonitorT.setMillisToDecideToPopup(0);
    progressMonitorT.setMillisToPopup(0);
    progressMonitorT.setNote("Extraction des fichiers compresss...");

    plnsAnalyzer = new PLNSAnalyzer();

    //au cas o il faille importer les donnes, on coute le ProgressSupport et on ne lance la cration de la fentre qu' la fin
    plnsAnalyzer.addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals(ProgressSupport.TASK_STARTS)) {

            } else if (evt.getPropertyName().equals(ProgressSupport.TASK_PROGRESS)) {
                progressMonitorT.setProgress((Integer) evt.getNewValue());
            } else if (evt.getPropertyName().equals(ProgressSupport.TASK_INFO)) {
                progressMonitorT.setNote((String) evt.getNewValue());
            } else if (evt.getPropertyName().equals(ProgressSupport.TASK_ENDS)) {
                createIHM();
            }
        }
    });

    new SwingWorker<Void, Void>() {

        @Override
        protected Void doInBackground() throws Exception {
            plnsAnalyzer.setPath(path);
            return null;
        }
    }.execute();
}

From source file:hermes.renderers.RendererHelper.java

/**
 * Create a default renderer for a Config that just contains simple
 * properties (i.e. not 1:m relationships), the dialog will be a normal
 * property pane./*  w w  w.  j a va2 s  .c  o m*/
 * 
 * @param dialogProxy
 * @return @throws
 *         IllegalAccessException
 * @throws InvocationTargetException
 * @throws NoSuchMethodException
 */
public static JComponent createDefaultConfigPanel(final ConfigDialogProxy dialogProxy)
        throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
    final Config theConfig = dialogProxy.getConfig();
    final List<Property> list = new ArrayList<Property>();
    final Map properties = PropertyUtils.describe(theConfig);

    for (Iterator iter = properties.entrySet().iterator(); iter.hasNext();) {
        final Map.Entry entry = (Map.Entry) iter.next();
        final String propertyName = (String) entry.getKey();
        final Object propertyValue = entry.getValue();

        if (!propertyName.equals("class") && !propertyName.equals("name")) {
            Property displayProperty = new Property(propertyName,
                    theConfig.getPropertyDescription(propertyName), propertyValue.getClass()) {
                /**
                * 
                */
                private static final long serialVersionUID = -4650355524853942976L;

                public void setValue(Object value) {
                    try {
                        dialogProxy.setDirty();

                        PropertyUtils.setProperty(theConfig, propertyName, value);
                    } catch (Exception e) {
                        cat.error(e.getMessage(), e);
                    }
                }

                public Object getValue() {
                    try {
                        return PropertyUtils.getProperty(theConfig, propertyName);
                    } catch (Exception e) {
                        cat.error(e.getMessage(), e);
                    }

                    return null;
                }

                public boolean hasValue() {
                    return true;
                }
            };

            list.add(displayProperty);
        }
    }

    PropertyTableModel model = new PropertyTableModel(list);
    PropertyTable table = new PropertyTable(model);

    table.setAutoResizeMode(PropertyTable.AUTO_RESIZE_ALL_COLUMNS);

    PropertyPane pane = new PropertyPane(table);

    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            dialogProxy.setDirty();
        }
    });

    model.expandAll();

    return pane;
}

From source file:org.zkoss.ganttz.DependencyComponent.java

@Override
public void afterCompose() {
    if (listenerAdded) {
        return;/*  www . j av a2s  .  c  o m*/
    }

    listener = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            redrawDependency();
        }
    };

    this.source.getTask().addFundamentalPropertiesChangeListener(listener);
    this.destination.getTask().addFundamentalPropertiesChangeListener(listener);

    violationListener = Constraint.onlyOnZKExecution(new IConstraintViolationListener<GanttDate>() {

        @Override
        public void constraintViolated(Constraint<GanttDate> constraint, GanttDate value) {
            violated = true;
            sendCSSUpdate();
        }

        @Override
        public void constraintSatisfied(Constraint<GanttDate> constraint, GanttDate value) {
            violated = false;
            sendCSSUpdate();
        }
    });

    this.dependency.addConstraintViolationListener(violationListener, Mode.RECEIVE_PENDING);

    listenerAdded = true;
}

From source file:org.jcurl.model.ComputedPathsTest.java

public void testOneMovingEvents() throws FunctionEvaluationException {
    final ComputedPaths cp = new ComputedPaths();
    assertEquals(0, ec);//from w  ww .j  a  v  a 2s.  co m
    cp.getCurrentPos().addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            assertEquals("rock", e.getPropertyName());
            assertTrue(e.getSource() instanceof PositionSet);
            ec += pos;
        }
    });
    cp.getCurrentSpeed().addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            assertEquals("rock", e.getPropertyName());
            assertTrue(e.getSource() instanceof SpeedSet);
            ec += vel;
        }
    });
    assertEquals(0, ec);
    cp.getInitialSpeed().getLight(0).setY(-1);
    cp.getInitialSpeed().notifyChange();
    assertEquals((vel + pos) * 1, ec);
    cp.setCurrentT(1);
    assertEquals((vel + pos) * 2, ec);
    assertEquals("", 1.0, cp.getCurrentT(), 1e-9);
    cp.setCurrentT(Double.MAX_VALUE);
    assertEquals((vel + pos) * 3, ec);
    assertEquals("", Double.MAX_VALUE, cp.getCurrentT(), 1e-9);
    cp.setCurrentT(Double.POSITIVE_INFINITY);
    assertEquals((vel + pos) * 4, ec);
    assertEquals("", Double.POSITIVE_INFINITY, cp.getCurrentT(), 1e-9);
}