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,85 @@
/*******************************************************************************
* 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.system;
import java.util.ArrayList;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import controller.site.Site;
@XmlSeeAlso( { Site.class } )
@XmlRootElement( name = "system" )
public class System
{
private String mName;
private ArrayList<Site> mSite = new ArrayList<Site>();
public System()
{
this( "New System" );
}
public System( String name )
{
mName = name;
}
@XmlAttribute
public String getName()
{
return mName;
}
public void setName( String name )
{
mName = name;
}
public ArrayList<Site> getSite()
{
return mSite;
}
public void setSite( ArrayList<Site> sites )
{
mSite = sites;
}
public void addSite( Site site )
{
mSite.add( site );
}
public void removeSite( Site site )
{
mSite.remove( site );
}
public void clearSites()
{
mSite.clear();
}
public String toString()
{
return mName;
}
}

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.system;
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 SystemEditor extends JPanel implements ActionListener
{
private static final long serialVersionUID = 1L;
private SystemNode mSystemNode;
private JLabel mLabelSystem;
private JTextField mTextSystem;
public SystemEditor( SystemNode system )
{
mSystemNode = system;
initGUI();
}
private void initGUI()
{
setLayout( new MigLayout() );
setBorder( BorderFactory.createTitledBorder( "System" ) );
mLabelSystem = new JLabel( "Name:" );
add( mLabelSystem, "align right" );
mTextSystem = new JTextField( mSystemNode.getSystem().getName() );
add( mTextSystem, "grow, wrap" );
JButton btnSave = new JButton( "Save" );
btnSave.addActionListener( SystemEditor.this );
add( btnSave );
JButton btnReset = new JButton( "Reset" );
btnReset.addActionListener( SystemEditor.this );
add( btnReset, "wrap" );
}
@Override
public void actionPerformed( ActionEvent e )
{
String command = e.getActionCommand();
if( command.contentEquals( "Save" ) )
{
boolean expanded = mSystemNode.getModel().getTree()
.isExpanded( new TreePath( mSystemNode ) );
String name = mTextSystem.getText();
if( name != null )
{
mSystemNode.getSystem().setName( name );
mSystemNode.save();
mSystemNode.show();
if( expanded )
{
mSystemNode.getModel().getTree().expandPath( new TreePath( mSystemNode ) );
}
}
else
{
JOptionPane.showMessageDialog( SystemEditor.this, "Please enter a system name" );
}
}
else if( command.contentEquals( "Reset" ) )
{
mTextSystem.setText( mSystemNode.getSystem().getName() );
}
}
}

View File

@@ -0,0 +1,60 @@
/*******************************************************************************
* 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.system;
import java.util.ArrayList;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
@XmlSeeAlso( { controller.system.System.class } )
@XmlRootElement( name = "system_list" )
public class SystemList
{
private ArrayList<System> mSystem = new ArrayList<System>();
public SystemList()
{
}
public ArrayList<System> getSystem()
{
return mSystem;
}
public void setSystem( ArrayList<System> systems )
{
mSystem = systems;
}
public void addSystem( System system )
{
mSystem.add( system );
}
public void removeSystem( System system )
{
mSystem.remove( system );
}
public void clearSystems()
{
mSystem.clear();
}
}

View File

@@ -0,0 +1,85 @@
/*******************************************************************************
* 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.system;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import controller.ConfigurableNode;
public class SystemListNode extends ConfigurableNode
{
private static final long serialVersionUID = 1L;
public SystemListNode( SystemList list )
{
super( list );
}
public SystemList getSystemList()
{
return (SystemList)getUserObject();
}
public void init()
{
for( System system: getSystemList().getSystem() )
{
SystemNode node = new SystemNode( system );
getModel().addNode( node, SystemListNode.this, getChildCount() );
node.init();
}
sort();
}
public String toString()
{
return "Systems [" + this.getChildCount() + "]";
}
public JPopupMenu getContextMenu()
{
JPopupMenu retVal = new JPopupMenu();
JMenuItem addSystemItem = new JMenuItem( "Add System" );
addSystemItem.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
System system = new System();
getSystemList().addSystem( system );
getModel().addNode( new SystemNode( system ),
SystemListNode.this,
SystemListNode.this.getChildCount() );
}
} );
retVal.add( addSystemItem );
return retVal;
}
}

View File

@@ -0,0 +1,165 @@
/*******************************************************************************
* 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.system;
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.site.Site;
import controller.site.SiteNode;
public class SystemNode extends ConfigurableNode
{
private static final long serialVersionUID = 1L;
public SystemNode( System system )
{
super( system );
}
public void init()
{
for( Site site: getSystem().getSite() )
{
SiteNode node = new SiteNode( site );
getModel().insertNodeInto( node, SystemNode.this, getChildCount() );
node.init();
}
sort();
}
@Override
public String getIconPath()
{
String retVal = "images/system.png";
@SuppressWarnings( "unchecked" )
Enumeration<DefaultMutableTreeNode> nodes = children();
while( nodes.hasMoreElements() )
{
SiteNode child = (SiteNode)nodes.nextElement();
if( child.getIconPath().contains( "green.png" ) )
{
return "images/system_green.png";
}
else if( child.getIconPath().contains( "red.png" ) )
{
retVal = "images/system_red.png";
}
}
return retVal;
}
@Override
public JPanel getEditor()
{
return new SystemEditor( this );
}
public System getSystem()
{
return (System)getUserObject();
}
public String toString()
{
return getSystem().getName();
}
public void delete()
{
for( int x = 0; x < getChildCount(); x++ )
{
((SiteNode)getChildAt( x )).delete();
}
SystemListNode parent = (SystemListNode)getParent();
parent.getSystemList().removeSystem( getSystem() );
save();
getModel().removeNodeFromParent( SystemNode.this );
/* Show the first child, if one exists so that we don't have a
* collapsed list */
if( parent.getChildCount() > 0 )
{
((ConfigurableNode)parent.getFirstChild()).show();
}
}
public JPopupMenu getContextMenu()
{
JPopupMenu retVal = new JPopupMenu();
JMenuItem addSiteItem = new JMenuItem( "Add Site" );
addSiteItem.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
Site site = new Site();
getSystem().addSite( site );
SiteNode node = new SiteNode( site );
getModel().addNode( node,
SystemNode.this,
SystemNode.this.getChildCount() );
sort();
node.show();
}
} );
retVal.add( addSiteItem );
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;
}
}