Initial code check in continued

This commit is contained in:
dennis.sheirer
2014-04-26 19:48:24 +00:00
parent 960a6f9952
commit 3dfedcf8d1
474 changed files with 76613 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014 Dennis Sheirer
*
* 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 controller.site;
import java.util.ArrayList;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import controller.channel.Channel;
@XmlSeeAlso( { Channel.class } )
@XmlRootElement( name = "site" )
public class Site
{
private String mName;
private ArrayList<Channel> mChannel = new ArrayList<Channel>();
public Site()
{
this( "New Site" );
}
public Site( String name )
{
mName = name;
}
public String toString()
{
return mName;
}
@XmlAttribute
public String getName()
{
return mName;
}
public void setName( String name )
{
mName = name;
}
public ArrayList<Channel> getChannel()
{
return mChannel;
}
public void setChannel( ArrayList<Channel> configs )
{
mChannel = configs;
}
public void addChannel( Channel channel )
{
mChannel.add( channel );
}
public void removeChannel( Channel channel )
{
mChannel.remove( channel );
}
public void removeAllChannels()
{
mChannel.clear();
}
}

View File

@@ -0,0 +1,101 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014 Dennis Sheirer
*
* 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 controller.site;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.tree.TreePath;
import net.miginfocom.swing.MigLayout;
public class SiteEditor extends JPanel implements ActionListener
{
private static final long serialVersionUID = 1L;
private SiteNode mSiteNode;
private JLabel mLabelName;
private JTextField mTextSite;
public SiteEditor( SiteNode site )
{
mSiteNode = site;
initGUI();
}
private void initGUI()
{
setLayout( new MigLayout() );
setBorder( BorderFactory.createTitledBorder( "Site" ) );
mLabelName = new JLabel( "Name:" );
add( mLabelName, "align right" );
mTextSite = new JTextField( mSiteNode.getSite().getName() );
add( mTextSite, "grow, wrap" );
JButton btnSave = new JButton( "Save" );
btnSave.addActionListener( SiteEditor.this );
add( btnSave );
JButton btnReset = new JButton( "Reset" );
btnReset.addActionListener( SiteEditor.this );
add( btnReset, "wrap" );
}
@Override
public void actionPerformed( ActionEvent e )
{
String command = e.getActionCommand();
if( command.contentEquals( "Save" ) )
{
boolean expanded = mSiteNode.getModel().getTree()
.isExpanded( new TreePath( mSiteNode ) );
String name = mTextSite.getText();
if( name != null )
{
mSiteNode.getSite().setName( name );
mSiteNode.save();
mSiteNode.show();
if( expanded )
{
mSiteNode.getModel().getTree().expandPath( new TreePath( mSiteNode ) );
}
}
else
{
JOptionPane.showMessageDialog( SiteEditor.this, "Please enter a system name" );
}
}
else if( command.contentEquals( "Reset" ) )
{
mTextSite.setText( mSiteNode.getSite().getName() );
}
}
}

View File

@@ -0,0 +1,167 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014 Dennis Sheirer
*
* 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 controller.site;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Enumeration;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JSeparator;
import javax.swing.tree.DefaultMutableTreeNode;
import controller.ConfigurableNode;
import controller.channel.Channel;
import controller.channel.ChannelNode;
import controller.system.System;
import controller.system.SystemNode;
public class SiteNode extends ConfigurableNode
{
private static final long serialVersionUID = 1L;
public SiteNode( Site site )
{
super( site );
}
public void init()
{
for( Channel channel: getSite().getChannel() )
{
ChannelNode node = new ChannelNode( channel );
getModel().insertNodeInto( node, SiteNode.this, getChildCount() );
node.init();
}
sort();
}
public String getIconPath()
{
String retVal = "images/site.png";
@SuppressWarnings( "unchecked" )
Enumeration<DefaultMutableTreeNode> nodes = children();
while( nodes.hasMoreElements() )
{
ChannelNode child = (ChannelNode)nodes.nextElement();
if( child.getIconPath().contains( "green.png" ) )
{
return "images/site_green.png";
}
else if( child.getIconPath().contains( "red.png" ) )
{
retVal = "images/site_red.png";
}
}
return retVal;
}
@Override
public JPanel getEditor()
{
return new SiteEditor( this );
}
public Site getSite()
{
return (Site)getUserObject();
}
public String toString()
{
return getSite().getName();
}
public void delete()
{
for( int x = 0; x < getChildCount(); x++ )
{
((ChannelNode)getChildAt( x )).delete();
}
((SystemNode)getParent()).getSystem().removeSite( getSite() );
save();
getModel().removeNodeFromParent( SiteNode.this );
}
public JPopupMenu getContextMenu()
{
JPopupMenu retVal = new JPopupMenu();
JMenuItem addChannelItem = new JMenuItem( "Add Channel" );
addChannelItem.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
System system = ((SystemNode)getParent()).getSystem();
Channel channel = new Channel();
channel.setSystem( system, false );
channel.setSite( getSite(), false );
getSite().addChannel( channel );
ChannelNode node = new ChannelNode( channel );
getModel().addNode( node,
SiteNode.this,
SiteNode.this.getChildCount() );
sort();
save();
node.show();
/* Give channel reference to the resource manager and the
* channel will register the listeners and send a channel
* add event */
channel.setResourceManager( getModel().getResourceManager() );
}
} );
retVal.add( addChannelItem );
retVal.add( new JSeparator() );
JMenuItem deleteItem = new JMenuItem( "Delete" );
deleteItem.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
delete();
}
} );
retVal.add( deleteItem );
return retVal;
}
}