/*
* Copyright (C) 2013 Serdar
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.fub.maps.project.detector.model.inference.ui;
import de.fub.maps.project.detector.model.inference.AbstractInferenceModel;
import java.beans.PropertyVetoException;
import org.openide.explorer.ExplorerManager;
import org.openide.nodes.FilterNode;
import org.openide.nodes.Node;
import org.openide.util.Exceptions;
/**
*
* @author Serdar
*/
public class OptionPanel extends javax.swing.JPanel implements ExplorerManager.Provider {
private static final long serialVersionUID = 1L;
private final ExplorerManager explorerManager = new ExplorerManager();
private AbstractInferenceModel inferenceModel = null;
/**
* Creates new form OptionPanel
*/
public OptionPanel() {
initComponents();
propertySheetView1.setDescriptionAreaVisible(false);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings({"unchecked", "deprecation"})
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
propertySheetView1 = new org.openide.explorer.propertysheet.PropertySheetView();
setBackground(new java.awt.Color(255, 255, 255));
setLayout(new java.awt.BorderLayout());
propertySheetView1.setDescriptionAreaVisible(false);
propertySheetView1.setDisabledPropertyColor(javax.swing.UIManager.getDefaults().getColor("Button.foreground"));
add(propertySheetView1, java.awt.BorderLayout.CENTER);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private org.openide.explorer.propertysheet.PropertySheetView propertySheetView1;
// End of variables declaration//GEN-END:variables
@Override
public ExplorerManager getExplorerManager() {
return explorerManager;
}
public void setInferenceModel(AbstractInferenceModel inferenceModel) {
this.inferenceModel = inferenceModel;
if (this.inferenceModel != null) {
try {
FilterNode filterNode = new FilterNode(inferenceModel.getNodeDelegate());
getExplorerManager().setRootContext(filterNode);
getExplorerManager().setSelectedNodes(new Node[]{filterNode});
} catch (PropertyVetoException ex) {
Exceptions.printStackTrace(ex);
}
} else {
getExplorerManager().setRootContext(Node.EMPTY);
}
}
}