org.praxislive.ide.video.options.CaptureOptionsPanelController Maven / Gradle / Ivy
The newest version!
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2015 Neil C Smith.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 3 for more details.
*
* You should have received a copy of the GNU General Public License version 3
* along with this work; if not, see http://www.gnu.org/licenses/
*
*
* Please visit https://www.praxislive.org if you need additional information or
* have any questions.
*/
package org.praxislive.ide.video.options;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import javax.swing.JComponent;
import org.netbeans.spi.options.OptionsPanelController;
import org.openide.util.HelpCtx;
import org.openide.util.Lookup;
@OptionsPanelController.SubRegistration(location = "Video",
id = "Capture",
displayName = "#AdvancedOption_DisplayName_Capture",
keywords = "#AdvancedOption_Keywords_Capture",
keywordsCategory = "Video/Capture",
position = 100)
public final class CaptureOptionsPanelController extends OptionsPanelController {
private CapturePanel panel;
private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
private boolean changed;
public void update() {
getPanel().load();
changed = false;
}
public void applyChanges() {
getPanel().store();
changed = false;
}
public void cancel() {
// need not do anything special, if no changes have been persisted yet
}
public boolean isValid() {
return getPanel().valid();
}
public boolean isChanged() {
return changed;
}
public HelpCtx getHelpCtx() {
return null; // new HelpCtx("...ID") if you have a help set
}
public JComponent getComponent(Lookup masterLookup) {
return getPanel();
}
public void addPropertyChangeListener(PropertyChangeListener l) {
pcs.addPropertyChangeListener(l);
}
public void removePropertyChangeListener(PropertyChangeListener l) {
pcs.removePropertyChangeListener(l);
}
private CapturePanel getPanel() {
if (panel == null) {
panel = new CapturePanel(this);
}
return panel;
}
void changed() {
if (!changed) {
changed = true;
pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true);
}
pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
}
}