/*
* Copyright (C) 2008 Universidade Federal de Campina Grande
*
* This file is part of OurGrid.
*
* OurGrid is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package org.ourgrid.peer.ui.async.gui;
import java.awt.Frame;
import javax.swing.ActionMap;
import javax.swing.JFrame;
import org.ourgrid.peer.ui.async.gui.actions.AddBrokerAction;
import org.ourgrid.peer.ui.async.gui.actions.IssueCertificateAction;
import org.ourgrid.peer.ui.async.gui.actions.StartPeerAction;
import org.ourgrid.peer.ui.async.gui.actions.StopPeerAction;
/**
* Panel that provide the actions to the peer.
*/
public class ActionsPanel extends javax.swing.JPanel {
private static final long serialVersionUID = 1L;
private static final String ADD_BROKER_ACTION_NAME = "peer.addBroker.action";
private StartPeerAction startPeerAction;
private StopPeerAction stopPeerAction;
private AddBrokerAction addBrokerAction;
private IssueCertificateAction issueCertificateAction;
/** Creates new form ActionsPanel */
public ActionsPanel(Frame frame) {
initComponents();
initActions(frame);
}
/**
* Initializes the Actions that will appear at this panel.
* @param frame The frame where this panel is, it is necessary to open
* other panels on it.
* @param componentClient The client of the peer.
*/
private void initActions(Frame frame) {
JFrame jFrame = (JFrame) frame;
startPeerAction = new StartPeerAction(jFrame.getContentPane());
controlTaskPane.add(startPeerAction);
stopPeerAction = new StopPeerAction(jFrame.getContentPane());
controlTaskPane.add(stopPeerAction);
addBrokerAction = new AddBrokerAction(frame);
brokersTaskPane.add(addBrokerAction);
issueCertificateAction = new IssueCertificateAction(frame);
brokersTaskPane.add(issueCertificateAction);
}
/**
* Enable the actions that are permited when the
* peer has been started.
*/
public void peerStarted() {
startPeerAction.setEnabled(false);
stopPeerAction.setEnabled(true);
addBrokerAction.setEnabled(true);
}
/**
* Enable the actions that are permited when the
* peer has been restarted.
*/
public void peerRestarted() {
startPeerAction.setEnabled(false);
stopPeerAction.setEnabled(true);
addBrokerAction.setEnabled(true);
}
/**
* Enable the actions that are permited when the
* peer has been stopped.
*/
public void peerStopped() {
startPeerAction.setEnabled(true);
stopPeerAction.setEnabled(false);
addBrokerAction.setEnabled(false);
}
/**
* Enable the actions that are permited when the
* peer has been inited.
*/
public void peerInited() {
startPeerAction.setEnabled(false);
stopPeerAction.setEnabled(false);
addBrokerAction.setEnabled(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.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jXTaskPaneContainer1 = new org.jdesktop.swingx.JXTaskPaneContainer();
controlTaskPane = new org.jdesktop.swingx.JXTaskPane();
brokersTaskPane = new org.jdesktop.swingx.JXTaskPane();
controlTaskPane.setTitle("Control"); // NOI18N
jXTaskPaneContainer1.add(controlTaskPane);
brokersTaskPane.setTitle("Actions");
jXTaskPaneContainer1.add(brokersTaskPane);
ActionMap actionMap = new ActionMap();
actionMap.put(ADD_BROKER_ACTION_NAME, addBrokerAction);
jXTaskPaneContainer1.setActionMap(actionMap);
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jXTaskPaneContainer1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jXTaskPaneContainer1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
);
}// </editor-fold>//GEN-END:initComponents
public void setStartEnabled(boolean enabled) {
startPeerAction.setEnabled(enabled);
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private org.jdesktop.swingx.JXTaskPane controlTaskPane;
private org.jdesktop.swingx.JXTaskPaneContainer jXTaskPaneContainer1;
private org.jdesktop.swingx.JXTaskPane brokersTaskPane;
// End of variables declaration//GEN-END:variables
}