001 /******************************************************************************
002 * Copyright (C) MActor Developers. All rights reserved. *
003 * ---------------------------------------------------------------------------*
004 * This file is part of MActor. *
005 * *
006 * MActor is free software; you can redistribute it and/or modify *
007 * it under the terms of the GNU General Public License as published by *
008 * the Free Software Foundation; either version 2 of the License, or *
009 * (at your option) any later version. *
010 * *
011 * MActor is distributed in the hope that it will be useful, *
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
014 * GNU General Public License for more details. *
015 * *
016 * You should have received a copy of the GNU General Public License *
017 * along with MActor; if not, write to the Free Software *
018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
019 ******************************************************************************/
020 package org.mactor.ui.gui.project.editors;
021
022 import java.awt.FlowLayout;
023
024 import javax.swing.JLabel;
025 import javax.swing.JTextField;
026
027 import org.dom4j.Element;
028 import org.mactor.framework.MactorException;
029 import org.mactor.ui.gui.project.ProjectTreeNode;
030
031 public class MessageBrokerNodeEditor extends AbstractNodeEditor {
032 MessageBrokerImplementationsComboBox mbcImplCb = new MessageBrokerImplementationsComboBox();
033 BooleanComboBox archiveDlCb = new BooleanComboBox();
034 BooleanComboBox archiveCmCb = new BooleanComboBox();
035 JTextField messageReadInterval = new JTextField(5);
036 JTextField messageReadLimit = new JTextField(5);
037 GlobalDirSelector archivePathPanel = new GlobalDirSelector();
038 Element data;
039 public MessageBrokerNodeEditor() {
040 super(new FlowLayout());
041 SimpleFormPanel box = new SimpleFormPanel();
042 box.add(new JLabel("Message Broker Class:"));
043 box.add(mbcImplCb);
044 box.add(new JLabel("Archive Path:"));
045 box.add(archivePathPanel);
046 box.add(new JLabel("Archive Consumed Messages:"));
047 box.add(archiveCmCb);
048 box.add(new JLabel("Archive Consumed Messages:"));
049 box.add(archiveDlCb);
050 box.add(new JLabel("Message Read Interval (seconds):"));
051 box.add(messageReadInterval);
052 box.add(new JLabel("Message Read Limit (number of messages):"));
053 box.add(messageReadLimit);
054 add(box);
055 }
056 public void applyChanges() {
057 EditorUtil.setAttributeValue(data, "broker_class", mbcImplCb.getSelectedImplementation());
058 EditorUtil.setAttributeValue(data, "archive_path", archivePathPanel.getPath());
059 EditorUtil.setAttributeValue(data, "archive_dead_letter_messages", archiveDlCb.getSelectedValue());
060 EditorUtil.setAttributeValue(data, "archive_consumed_messages", archiveCmCb.getSelectedValue());
061 EditorUtil.setAttributeValue(data, "message_read_interval_seconds", messageReadInterval.getText());
062 EditorUtil.setAttributeValue(data, "message_read_limit", messageReadLimit.getText());
063 }
064 public void setData(ProjectTreeNode node) throws MactorException {
065 this.data = (Element) node.getModelObject();
066 mbcImplCb.getSelectedImplementation(EditorUtil.getAttributeValue(data, "broker_class"));
067 archivePathPanel.setPath(EditorUtil.getAttributeValue(data, "archive_path"));
068 archiveDlCb.setSelectedValue(EditorUtil.getAttributeValue(data, "archive_dead_letter_messages"));
069 archiveCmCb.setSelectedValue(EditorUtil.getAttributeValue(data, "archive_consumed_messages"));
070 messageReadInterval.setText(EditorUtil.getAttributeValue(data, "message_read_interval_seconds"));
071 messageReadLimit.setText(EditorUtil.getAttributeValue(data, "message_read_limit"));
072 }
073 public void setConfig(NodeEditorConfig config) {
074 }
075 }