Creation of OpenFOAM-dev repository 15/04/2008

This commit is contained in:
OpenFOAM-admin
2008-04-15 18:56:58 +01:00
commit 3170c7c0c9
9896 changed files with 4016171 additions and 0 deletions

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE attributes PUBLIC "-//NetBeans//DTD DefaultAttributes 1.0//EN" "http://www.netbeans.org/dtds/attributes-1_0.dtd">
<attributes version="1.0">
<fileobject name="App.java">
<attr name="NetBeansAttrArguments" serialvalue="aced0005757200135b4c6a6176612e6c616e672e537472696e673badd256e7e91d7b470200007870000000017400412d44466f616d582e436f6e666967506174683d2f686f6d652f70656e666f6c642f6d617474696a732f2e666f616d322e312f617070732f466f616d582f55736572"/>
</fileobject>
<fileobject name="ConfigureHostBrowser.java">
<attr name="class_dependency_FoamX.Util.FoamXListRenderer.FoamXListItem" stringvalue="ConfigureHostBrowser.HostNameListItem"/>
<attr name="class_dependency_javax.swing.JFrame" stringvalue="ConfigureHostBrowser"/>
</fileobject>
<fileobject name="FoamXException.java">
<attr name="class_dependency_java.lang.Exception" stringvalue="FoamXException"/>
</fileobject>
</attributes>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<attributes version="1.0">
<fileobject name="ActionManager.java">
<attr name="template" serialvalue="aced0005737200266f72672e6f70656e6964652e7574696c2e696f2e4e624d61727368616c6c65644f626a6563746cd5cc1aa397c0f2020002490004686173685b00086f626a42797465737400025b4278700000001170"/>
</fileobject>
<fileobject name="IActionProvider.java">
<attr name="EA-OpenIDE-Connection" serialvalue="aced0005737200146a6176612e7574696c2e4c696e6b65644c6973740c29535d4a60882203000078707704000000057372002a6f72672e6f70656e6964652e6c6f61646572732e436f6e6e656374696f6e537570706f72742450616972055f8af6f04a3bd80200024c00047479706574002b4c6f72672f6f70656e6964652f636f6f6b6965732f436f6e6e656374696f6e436f6f6b696524547970653b4c000576616c75657400124c6a6176612f6c616e672f4f626a6563743b78707372002e6f72672e6e65746265616e732e6d6f64756c65732e6a6176612e4a617661436f6e6e656374696f6e732454797065a83dd01001306d7402000149000666696c746572787000000050737200296f72672e6f70656e6964652e6c6f61646572732e446174614e6f6465244f626a65637448616e646c655bd0f82e01811d2e0200025a0005636c6f6e654c00036f626a7400244c6f72672f6f70656e6964652f66696c6573797374656d732f46696c654f626a6563743b787000737200326f72672e6f70656e6964652e66696c6573797374656d732e416273747261637446696c654f626a65637424496e76616c6964c0bb2fa0ec2461140200024c000866756c6c4e616d657400124c6a6176612f6c616e672f537472696e673b4c00046e616d6571007e000c787200226f72672e6f70656e6964652e66696c6573797374656d732e46696c654f626a656374012f10797d5a7af6020000787074002c466f616d582f57696e646f774d616e616765722f4d6f64756c6557696e646f774d616e616765722e6a6176617400184d6f64756c6557696e646f774d616e616765722e6a6176617371007e00027371007e0006000000507371007e0008007371007e000b740015466f616d582f466f616d584672616d652e6a61766174000f466f616d584672616d652e6a6176617371007e00027371007e0006000000507371007e000800737200326f72672e6f70656e6964652e66696c6573797374656d732e416273747261637446696c654f626a656374245265706c616365896fa1bce4b5219f0200024c000866696c654e616d6571007e000c4c000666734e616d6571007e000c7870740029466f616d582f57696e646f774d616e6167656d656e742f57696e646f774d616e616765722e6a6176617400422f686f6d652f70656e666f6c642f6d617474696a732f666f616d2f6d617474696a73322e312f6170706c69636174696f6e732f7574696c2f466f616d582f4a6176617371007e00027371007e0006000000507371007e0008007371007e001a74000e466f616d582f4170702e6a61766171007e001d7371007e00027371007e000600000050737200436f72672e6e65746265616e732e6d6f64756c65732e6a6176612e4a617661446174614f626a6563742450657273697374656e74436f6e6e656374696f6e48616e646c65ba16f1d2dd4c1cb60200014c000e646174614e6f646548616e646c6574001f4c6f72672f6f70656e6964652f6e6f6465732f4e6f64652448616e646c653b78707371007e00080071007e002178"/>
</fileobject>
</attributes>

View File

@ -0,0 +1,157 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.ActionManagement;
import java.lang.ref.*;
import java.util.*;
import javax.swing.*;
import FoamX.App;
public class ActionManager
extends Object
{
//--------------------------------------------------------------------------
protected Hashtable actionMap_;
//--------------------------------------------------------------------------
/** ActionManager constructor. */
public ActionManager()
{
actionMap_ = new Hashtable();
}
//--------------------------------------------------------------------------
public boolean isRegistered(String actionName)
{
return actionMap_.containsKey(actionName);
}
//--------------------------------------------------------------------------
public void registerAction(String actionName, Action action)
throws IllegalArgumentException
{
if (actionMap_.containsKey(actionName))
{
throw new IllegalArgumentException
(
"Duplication action name in ActionManager.registerAction"
+ " method call."
);
}
actionMap_.put(actionName, action);
}
//--------------------------------------------------------------------------
public void unregisterAction(String actionName)
throws IllegalArgumentException
{
if (!actionMap_.containsKey(actionName))
{
throw new IllegalArgumentException
(
"Duplication action name in ActionManager.unregisterAction"
+ " method call."
);
}
actionMap_.remove(actionName);
}
//--------------------------------------------------------------------------
public Action getAction(String actionName)
throws IllegalArgumentException
{
if (!actionMap_.containsKey(actionName))
{
throw new IllegalArgumentException
(
"Invalid action name in ActionManager.getAction method call."
);
}
return (Action)actionMap_.get(actionName);
}
//--------------------------------------------------------------------------
public void registerActions(IActionProvider provider)
{
try
{
// Get provider's prefix string.
String prefix = provider.getPrefix();
if (prefix != null)
{
prefix += ".";
} else {
prefix = "";
}
// Loop over all actions and register each.
javax.swing.Action[] actions = provider.getActions();
for (int i = 0; i <actions.length; i++)
{
Action action = actions[i];
String actionName =
prefix + (String)action.getValue(Action.NAME);
registerAction(actionName, action);
}
}
catch (IllegalArgumentException ex)
{
App.printMessage
(
"Illegal action name in ActionManager.registerProvider method"
+ " call."
);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,33 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.ActionManagement;
public interface IActionProvider
{
public String getPrefix();
public javax.swing.Action[] getActions();
}

View File

@ -0,0 +1,136 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.0" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<NonVisualComponents>
<Menu class="javax.swing.JMenuBar" name="menuBar_">
<SubComponents>
<Menu class="javax.swing.JMenu" name="jMenu2">
<Properties>
<Property name="text" type="java.lang.String" value="Menu"/>
</Properties>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem2">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Courier" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="Item"/>
</Properties>
</MenuItem>
</SubComponents>
</Menu>
</SubComponents>
</Menu>
<Menu class="javax.swing.JPopupMenu" name="contextMenu_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Courier" size="10" style="0"/>
</Property>
</Properties>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="mnuProperties">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Courier" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="Properties..."/>
</Properties>
</MenuItem>
</SubComponents>
</Menu>
</NonVisualComponents>
<Properties>
<Property name="defaultCloseOperation" type="int" value="0"/>
<Property name="title" type="java.lang.String" value="FoamX"/>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="ff" id="white" palette="0" red="ff" type="palette"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Courier" size="10" style="0"/>
</Property>
<Property name="name" type="java.lang.String" value="MainFrame"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/>
<SyntheticProperty name="formPosition" type="java.awt.Point" value="-84,-19,0,5,115,114,0,14,106,97,118,97,46,97,119,116,46,80,111,105,110,116,-74,-60,-118,114,52,126,-56,38,2,0,2,73,0,1,120,73,0,1,121,120,112,0,0,0,0,0,0,0,0"/>
<SyntheticProperty name="formSizePolicy" type="int" value="0"/>
<SyntheticProperty name="generatePosition" type="boolean" value="true"/>
<SyntheticProperty name="generateSize" type="boolean" value="true"/>
<SyntheticProperty name="generateCenter" type="boolean" value="true"/>
<SyntheticProperty name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/>
</SyntheticProperties>
<Events>
<EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="exitForm"/>
<EventHandler event="windowActivated" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="OnActivate"/>
</Events>
<AuxValues>
<AuxValue name="RADVisualFormContainer_MenuComponent" type="java.lang.String" value="jMenuBar1"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Container class="javax.swing.JSplitPane" name="horizontalSplitPane_">
<Properties>
<Property name="orientation" type="int" value="0"/>
<Property name="oneTouchExpandable" type="boolean" value="true"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
<SubComponents>
<Container class="javax.swing.JSplitPane" name="verticalSplitPane_">
<Properties>
<Property name="lastDividerLocation" type="int" value="-2"/>
<Property name="oneTouchExpandable" type="boolean" value="true"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="left"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
<SubComponents>
<Container class="javax.swing.JDesktopPane" name="desktopPanel_">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="right"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JLayeredPaneSupportLayout"/>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="statusPanel_">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder/>
</Border>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[10, 25]"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="2" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
<Property name="alignment" type="int" value="0"/>
<Property name="verticalGap" type="int" value="2"/>
</Layout>
</Container>
</SubComponents>
</Form>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE attributes PUBLIC "-//NetBeans//DTD DefaultAttributes 1.0//EN" "http://www.netbeans.org/dtds/attributes-1_0.dtd">
<attributes version="1.0">
<fileobject name="CaseBrowserModel.java">
<attr name="class_dependency_javax.swing.tree.DefaultTreeModel" stringvalue="CaseBrowserModel"/>
<attr name="template" serialvalue="aced0005737200266f72672e6f70656e6964652e7574696c2e696f2e4e624d61727368616c6c65644f626a6563746cd5cc1aa397c0f2020002490004686173685b00086f626a42797465737400025b4278700000001170"/>
</fileobject>
<fileobject name="CaseManagerListener.java">
<attr name="EA-OpenIDE-Connection" serialvalue="aced0005737200146a6176612e7574696c2e4c696e6b65644c6973740c29535d4a60882203000078707704000000037372002a6f72672e6f70656e6964652e6c6f61646572732e436f6e6e656374696f6e537570706f72742450616972055f8af6f04a3bd80200024c00047479706574002b4c6f72672f6f70656e6964652f636f6f6b6965732f436f6e6e656374696f6e436f6f6b696524547970653b4c000576616c75657400124c6a6176612f6c616e672f4f626a6563743b78707372002e6f72672e6e65746265616e732e6d6f64756c65732e6a6176612e4a617661436f6e6e656374696f6e732454797065a83dd01001306d7402000149000666696c746572787000000050737200296f72672e6f70656e6964652e6c6f61646572732e446174614e6f6465244f626a65637448616e646c655bd0f82e01811d2e0200025a0005636c6f6e654c00036f626a7400244c6f72672f6f70656e6964652f66696c6573797374656d732f46696c654f626a6563743b787000737200326f72672e6f70656e6964652e66696c6573797374656d732e416273747261637446696c654f626a656374245265706c616365896fa1bce4b5219f0200024c000866696c654e616d657400124c6a6176612f6c616e672f537472696e673b4c000666734e616d6571007e000c7870740025466f616d582f436173654d616e6167656d656e742f436173654d616e616765722e6a6176617400422f686f6d652f70656e666f6c642f6d617474696a732f666f616d2f6d617474696a73322e312f6170706c69636174696f6e732f7574696c2f466f616d582f4a6176617371007e00027371007e0006000000507371007e0008007371007e000b740025466f616d582f5265706f7274696e672f5265706f7274696e674d616e616765722e6a61766171007e000f7371007e00027371007e000600000050737200436f72672e6e65746265616e732e6d6f64756c65732e6a6176612e4a617661446174614f626a6563742450657273697374656e74436f6e6e656374696f6e48616e646c65ba16f1d2dd4c1cb60200014c000e646174614e6f646548616e646c6574001f4c6f72672f6f70656e6964652f6e6f6465732f4e6f64652448616e646c653b78707371007e00080071007e001378"/>
</fileobject>
<fileobject name="CreateCaseDialog.java">
<attr name="class_dependency_javax.swing.JDialog" stringvalue="CreateCaseDialog"/>
<attr name="template" serialvalue="aced0005737200266f72672e6f70656e6964652e7574696c2e696f2e4e624d61727368616c6c65644f626a6563746cd5cc1aa397c0f2020002490004686173685b00086f626a42797465737400025b4278700000001170"/>
</fileobject>
<fileobject name="CasePanel.java">
<attr name="class_dependency_javax.swing.JPanel" stringvalue="CasePanel"/>
<attr name="class_dependency_javax.swing.AbstractAction" stringvalue="CasePanel.StartCalculationAction;CasePanel.RunCalculationAction;CasePanel.SaveCaseAction;CasePanel.CloseCaseAction;CasePanel.StopCalculationAction"/>
<attr name="template" serialvalue="aced0005737200266f72672e6f70656e6964652e7574696c2e696f2e4e624d61727368616c6c65644f626a6563746cd5cc1aa397c0f2020002490004686173685b00086f626a42797465737400025b4278700000001170"/>
</fileobject>
<fileobject name="CloneCaseDialog.java">
<attr name="class_dependency_javax.swing.JDialog" stringvalue="CloneCaseDialog"/>
</fileobject>
<fileobject name="IModule.java">
<attr name="EA-OpenIDE-Connection" serialvalue="aced0005737200146a6176612e7574696c2e4c696e6b65644c6973740c29535d4a608822030000787077040000000078"/>
</fileobject>
<fileobject name="CaseStatusListener.java">
<attr name="EA-OpenIDE-Connection" serialvalue="aced0005737200146a6176612e7574696c2e4c696e6b65644c6973740c29535d4a60882203000078707704000000027372002a6f72672e6f70656e6964652e6c6f61646572732e436f6e6e656374696f6e537570706f72742450616972055f8af6f04a3bd80200024c00047479706574002b4c6f72672f6f70656e6964652f636f6f6b6965732f436f6e6e656374696f6e436f6f6b696524547970653b4c000576616c75657400124c6a6176612f6c616e672f4f626a6563743b78707372002e6f72672e6e65746265616e732e6d6f64756c65732e6a6176612e4a617661436f6e6e656374696f6e732454797065a83dd01001306d7402000149000666696c746572787000000050737200296f72672e6f70656e6964652e6c6f61646572732e446174614e6f6465244f626a65637448616e646c655bd0f82e01811d2e0200025a0005636c6f6e654c00036f626a7400244c6f72672f6f70656e6964652f66696c6573797374656d732f46696c654f626a6563743b787000737200326f72672e6f70656e6964652e66696c6573797374656d732e416273747261637446696c654f626a656374245265706c616365896fa1bce4b5219f0200024c000866696c654e616d657400124c6a6176612f6c616e672f537472696e673b4c000666734e616d6571007e000c7870740025466f616d582f436173654d616e6167656d656e742f436173654d616e616765722e6a6176617400422f686f6d652f70656e666f6c642f6d617474696a732f666f616d2f6d617474696a73322e312f6170706c69636174696f6e732f7574696c2f466f616d582f4a6176617371007e00027371007e000600000050737200436f72672e6e65746265616e732e6d6f64756c65732e6a6176612e4a617661446174614f626a6563742450657273697374656e74436f6e6e656374696f6e48616e646c65ba16f1d2dd4c1cb60200014c000e646174614e6f646548616e646c6574001f4c6f72672f6f70656e6964652f6e6f6465732f4e6f64652448616e646c653b78707371007e00080071007e000d78"/>
<attr name="template" serialvalue="aced0005737200266f72672e6f70656e6964652e7574696c2e696f2e4e624d61727368616c6c65644f626a6563746cd5cc1aa397c0f2020002490004686173685b00086f626a42797465737400025b4278700000001170"/>
</fileobject>
<fileobject name="CaseStatusEvent.java">
<attr name="template" serialvalue="aced0005737200266f72672e6f70656e6964652e7574696c2e696f2e4e624d61727368616c6c65644f626a6563746cd5cc1aa397c0f2020002490004686173685b00086f626a42797465737400025b4278700000001170"/>
</fileobject>
<fileobject name="CaseManager.java">
<attr name="class_dependency_javax.swing.JPanel" stringvalue="CaseManager"/>
<attr name="class_dependency_javax.swing.event.ChangeListener" stringvalue="CaseManager"/>
<attr name="template" serialvalue="aced0005737200266f72672e6f70656e6964652e7574696c2e696f2e4e624d61727368616c6c65644f626a6563746cd5cc1aa397c0f2020002490004686173685b00086f626a42797465737400025b4278700000001170"/>
</fileobject>
<fileobject name="ContextInfo.java">
<attr name="template" serialvalue="aced0005737200266f72672e6f70656e6964652e7574696c2e696f2e4e624d61727368616c6c65644f626a6563746cd5cc1aa397c0f2020002490004686173685b00086f626a42797465737400025b4278700000001170"/>
</fileobject>
<fileobject name="IFoamXModule.java">
<attr name="EA-OpenIDE-Connection" serialvalue="aced0005737200146a6176612e7574696c2e4c696e6b65644c6973740c29535d4a60882203000078707704000000077372002a6f72672e6f70656e6964652e6c6f61646572732e436f6e6e656374696f6e537570706f72742450616972055f8af6f04a3bd80200024c00047479706574002b4c6f72672f6f70656e6964652f636f6f6b6965732f436f6e6e656374696f6e436f6f6b696524547970653b4c000576616c75657400124c6a6176612f6c616e672f4f626a6563743b78707372002e6f72672e6e65746265616e732e6d6f64756c65732e6a6176612e4a617661436f6e6e656374696f6e732454797065a83dd01001306d7402000149000666696c746572787000000050737200296f72672e6f70656e6964652e6c6f61646572732e446174614e6f6465244f626a65637448616e646c655bd0f82e01811d2e0200025a0005636c6f6e654c00036f626a7400244c6f72672f6f70656e6964652f66696c6573797374656d732f46696c654f626a6563743b787000737200326f72672e6f70656e6964652e66696c6573797374656d732e416273747261637446696c654f626a65637424496e76616c6964c0bb2fa0ec2461140200024c000866756c6c4e616d657400124c6a6176612f6c616e672f537472696e673b4c00046e616d6571007e000c787200226f72672e6f70656e6964652e66696c6573797374656d732e46696c654f626a656374012f10797d5a7af60200007870740038466f616d582f4d6f64756c65732f536f6c7574696f6e506172616d65746572732f536f6c7574696f6e506172616d65746572732e6a617661740017536f6c7574696f6e506172616d65746572732e6a6176617371007e00027371007e0006000000507371007e0008007371007e000b740036466f616d582f4d6f64756c65732f44696374696f6e61727942726f777365722f44696374696f6e61727942726f777365722e6a61766174001644696374696f6e61727942726f777365722e6a6176617371007e00027371007e0006000000507371007e0008007371007e000b740032466f616d582f4d6f64756c65732f5061746368446566696e6974696f6e2f5061746368446566696e6974696f6e2e6a6176617400145061746368446566696e6974696f6e2e6a6176617371007e00027371007e0006000000507371007e0008007371007e000b740032466f616d582f44696374696f6e617279456469746f722f44696374696f6e617279456469746f724d6f64756c652e6a61766174001b44696374696f6e617279456469746f724d6f64756c652e6a6176617371007e00027371007e0006000000507371007e0008007371007e000b740038466f616d582f52617744696374696f6e617279456469746f722f52617744696374696f6e617279456469746f724d6f64756c652e6a61766174001e52617744696374696f6e617279456469746f724d6f64756c652e6a6176617371007e00027371007e0006000000507371007e000800737200326f72672e6f70656e6964652e66696c6573797374656d732e416273747261637446696c654f626a656374245265706c616365896fa1bce4b5219f0200024c000866696c654e616d6571007e000c4c000666734e616d6571007e000c7870740040466f616d582f4d6f64756c65732f52617744696374696f6e617279456469746f722f52617744696374696f6e617279456469746f724d6f64756c652e6a6176617400372f686f6d652f6470682f50726f6a656374732f666f616d322e302f6170706c69636174696f6e732f7574696c2f466f616d582f4a6176617371007e00027371007e0006000000507371007e0008007371007e002c74002e466f616d582f4d6f64756c65732f43617365456469746f722f43617365456469746f724d6f64756c652e6a61766171007e002f78"/>
</fileobject>
<fileobject name="CaseChooser2.java">
<attr name="class_dependency_FoamX.CaseManagement.CaseSelectionListener" stringvalue="CaseChooser"/>
<attr name="class_dependency_javax.swing.JDialog" stringvalue="CaseChooser"/>
</fileobject>
<fileobject name="HostChooserDlg.java">
<attr name="class_dependency_javax.swing.JDialog" stringvalue="HostChooserDlg"/>
</fileobject>
<fileobject name="CaseBrowserPanel.java">
<attr name="class_dependency_javax.swing.JPanel" stringvalue="CaseBrowserPanel"/>
<attr name="class_dependency_javax.swing.AbstractAction" stringvalue="CaseBrowserPanel.UnlockCaseAction;CaseBrowserPanel.StartCaseBrowserAction;CaseBrowserPanel.RefreshAction;CaseBrowserPanel.StopCaseBrowserAction;CaseBrowserPanel.SelectCaseAction;CaseBrowserPanel.OpenCaseAction;CaseBrowserPanel.CloneCaseAction;CaseBrowserPanel.EditApplicationClassesAction;CaseBrowserPanel.DeleteCaseAction;CaseBrowserPanel.ImportCaseAction;CaseBrowserPanel.SelectRootAction;CaseBrowserPanel.CreateCaseAction"/>
<attr name="class_dependency_FoamX.Util.TabSelection" stringvalue="CaseBrowserPanel"/>
<attr name="template" serialvalue="aced0005737200266f72672e6f70656e6964652e7574696c2e696f2e4e624d61727368616c6c65644f626a6563746cd5cc1aa397c0f2020002490004686173685b00086f626a42797465737400025b4278700000001170"/>
</fileobject>
<fileobject name="TreeNodeInfo.java">
<attr name="class_dependency_FoamX.Util.FoamXTreeRenderer.FoamXTreeItem" stringvalue="TreeNodeInfo"/>
</fileobject>
<fileobject name="IFoamXModuleHost.java">
<attr name="EA-OpenIDE-Connection" serialvalue="aced0005737200146a6176612e7574696c2e4c696e6b65644c6973740c29535d4a60882203000078707704000000027372002a6f72672e6f70656e6964652e6c6f61646572732e436f6e6e656374696f6e537570706f72742450616972055f8af6f04a3bd80200024c00047479706574002b4c6f72672f6f70656e6964652f636f6f6b6965732f436f6e6e656374696f6e436f6f6b696524547970653b4c000576616c75657400124c6a6176612f6c616e672f4f626a6563743b78707372002e6f72672e6e65746265616e732e6d6f64756c65732e6a6176612e4a617661436f6e6e656374696f6e732454797065a83dd01001306d7402000149000666696c746572787000000050737200296f72672e6f70656e6964652e6c6f61646572732e446174614e6f6465244f626a65637448616e646c655bd0f82e01811d2e0200025a0005636c6f6e654c00036f626a7400244c6f72672f6f70656e6964652f66696c6573797374656d732f46696c654f626a6563743b787000737200326f72672e6f70656e6964652e66696c6573797374656d732e416273747261637446696c654f626a656374245265706c616365896fa1bce4b5219f0200024c000866696c654e616d657400124c6a6176612f6c616e672f537472696e673b4c000666734e616d6571007e000c7870740023466f616d582f436173654d616e6167656d656e742f4361736550616e656c2e6a6176617400372f686f6d652f6470682f50726f6a656374732f666f616d322e302f6170706c69636174696f6e732f7574696c2f466f616d582f4a6176617371007e00027371007e000600000050737200436f72672e6e65746265616e732e6d6f64756c65732e6a6176612e4a617661446174614f626a6563742450657273697374656e74436f6e6e656374696f6e48616e646c65ba16f1d2dd4c1cb60200014c000e646174614e6f646548616e646c6574001f4c6f72672f6f70656e6964652f6e6f6465732f4e6f64652448616e646c653b78707371007e00080071007e000d78"/>
<attr name="template" serialvalue="aced0005737200266f72672e6f70656e6964652e7574696c2e696f2e4e624d61727368616c6c65644f626a6563746cd5cc1aa397c0f2020002490004686173685b00086f626a42797465737400025b4278700000001170"/>
</fileobject>
<fileobject name="CaseSelectionListener.java">
<attr name="EA-OpenIDE-Connection" serialvalue="aced0005737200146a6176612e7574696c2e4c696e6b65644c6973740c29535d4a60882203000078707704000000017372002a6f72672e6f70656e6964652e6c6f61646572732e436f6e6e656374696f6e537570706f72742450616972055f8af6f04a3bd80200024c00047479706574002b4c6f72672f6f70656e6964652f636f6f6b6965732f436f6e6e656374696f6e436f6f6b696524547970653b4c000576616c75657400124c6a6176612f6c616e672f4f626a6563743b78707372002e6f72672e6e65746265616e732e6d6f64756c65732e6a6176612e4a617661436f6e6e656374696f6e732454797065a83dd01001306d7402000149000666696c746572787000000050737200436f72672e6e65746265616e732e6d6f64756c65732e6a6176612e4a617661446174614f626a6563742450657273697374656e74436f6e6e656374696f6e48616e646c65ba16f1d2dd4c1cb60200014c000e646174614e6f646548616e646c6574001f4c6f72672f6f70656e6964652f6e6f6465732f4e6f64652448616e646c653b7870737200296f72672e6f70656e6964652e6c6f61646572732e446174614e6f6465244f626a65637448616e646c655bd0f82e01811d2e0200025a0005636c6f6e654c00036f626a7400244c6f72672f6f70656e6964652f66696c6573797374656d732f46696c654f626a6563743b787000737200326f72672e6f70656e6964652e66696c6573797374656d732e416273747261637446696c654f626a656374245265706c616365896fa1bce4b5219f0200024c000866696c654e616d657400124c6a6176612f6c616e672f537472696e673b4c000666734e616d6571007e000f787074001f436173654d616e6167656d656e742f4361736543686f6f7365722e6a6176617400482f686f6d652f70656e666f6c642f6d617474696a732f666f616d2f6d617474696a73322e312f6170706c69636174696f6e732f7574696c2f466f616d582f4a6176612f466f616d5878"/>
</fileobject>
</attributes>

View File

@ -0,0 +1,887 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.CaseManagement;
import java.util.Hashtable;
import java.util.Properties;
import java.util.Enumeration;
import javax.swing.*;
import javax.swing.tree.*;
import org.omg.CosNaming.*;
import FoamX.App;
import FoamX.Exceptions.FoamXException;
import FoamXServer.*;
import FoamXServer.CaseServer.*;
import FoamXServer.CaseBrowser.ICaseBrowser;
import FoamXServer.CaseBrowser.ICaseBrowserHolder;
import FoamXServer.CaseDescriptor;
import FoamXServer.FoamXError;
import FoamXServer.FoamXIOError;
import FoamXServer.HostBrowser.IHostBrowser;
public class CaseBrowserModel
extends DefaultTreeModel
{
//--------------------------------------------------------------------------
protected IHostBrowser hostBrowser_;
protected DefaultMutableTreeNode root_;
protected Hashtable hostMap_; // from host to treeNode
protected Hashtable rootDirMap_; // from root to treeNode
protected Hashtable keyMap_; // from key (root/case) to treeNode
protected ICaseBrowser caseBrowserCopy_;
//--------------------------------------------------------------------------
/** CaseManagerModel constructor. */
public CaseBrowserModel()
{
super(new DefaultMutableTreeNode());
try
{
// Get reference to root node.
root_ = (DefaultMutableTreeNode)getRoot();
// Create host map.
hostMap_ = new Hashtable(10);
rootDirMap_ = new Hashtable(10);
keyMap_ = new Hashtable(10);
// Initialise the model.
// Show only the Hosts node unless the model is refreshed.
hostBrowser_ = null;
root_.setUserObject
(
new ContextInfo("Hosts", ContextInfo.INVALID_REF)
);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
/** Initialise the (licenseHosts) tree model. */
protected void initialiseModel()
{
try
{
// Get host manager reference.
hostBrowser_ = App.getHostBrowser();
if (hostBrowser_ != null)
{
// Set root node's context info object.
root_.removeAllChildren();
root_.setUserObject
(
new ContextInfo("Hosts", ContextInfo.ROOTCONTEXT)
);
// Add a host node for each host.
HostDescriptor[] licensedHosts = hostBrowser_.hosts();
for (int i=0; i <licensedHosts.length; i++)
{
// Create new contextInfo object for this FoamX host.
ContextInfo contextInfo;
if (licensedHosts[i].alive)
{
contextInfo = new ContextInfo
(
licensedHosts[i].name,
ContextInfo.HOST
);
}
else
{
contextInfo = new ContextInfo
(
licensedHosts[i].name,
ContextInfo.HOSTOFFLINE
);
}
contextInfo.setStatusText
(
"FoamX Host : " + contextInfo.toString()
);
// Insert node into tree.
DefaultMutableTreeNode node = new DefaultMutableTreeNode
(
contextInfo,
true
);
insertNodeInto(node, root_, root_.getChildCount());
// Add to host map.
hostMap_.put(licensedHosts[i].name, node);
}
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
/**
* Refresh the tree model. Use forceReread only if reread from disk
*/
public void refresh(boolean forceReread)
{
try
{
// If we don't yet have a host manager reference,
// try and re-initialise the model.
if (hostBrowser_ == null) initialiseModel();
// Clear map from root/case to treeInfo
keyMap_.clear();
// Loop over all host nodes.
Enumeration enum = hostMap_.keys();
while (enum.hasMoreElements())
{
String hostName = (String)enum.nextElement();
// Get host node.
DefaultMutableTreeNode hostNode =
(DefaultMutableTreeNode)hostMap_.get(hostName);
ContextInfo context = (ContextInfo)hostNode.getUserObject();
// See if a case browser is running for this host.
if (context.getCaseBrowser() != null)
{
// Remove all child nodes from the host node.
hostNode.removeAllChildren();
if (forceReread)
{
// Refresh caseBrowser's information
context.getCaseBrowser().refreshCaseList();
}
// Re-initialise the hostnode.
addCaseBrowserNodes(hostNode);
}
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
/**
* Refresh the tree model for one root directory only.
*/
public void refreshRoot(String hostName, String caseRoot)
{
try
{
// If we don't yet have a host manager reference,
// try and re-initialise the model.
if (hostBrowser_ == null) initialiseModel();
// Find context for give host
DefaultMutableTreeNode hostNode =
(DefaultMutableTreeNode)hostMap_.get(hostName);
ContextInfo context = (ContextInfo)hostNode.getUserObject();
// See if a case browser is running for this host.
if (context.getCaseBrowser() != null)
{
if (!rootDirMap_.containsKey(caseRoot))
{
throw new FoamXException
(
"Invalid caseRoot '" + caseRoot + "'"
);
}
// Re-initialise the hostnode.
addRootDirNodes
(
hostNode,
caseRoot,
(DefaultMutableTreeNode)rootDirMap_.get(caseRoot));
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
/**
* Refresh the host tree model.
*/
public void refreshHosts()
{
try
{
// If we don't yet have a host manager reference,
// try and re-initialise the model.
if (hostBrowser_ == null) initialiseModel();
// Have hostbrowser determine accessability of hosts
hostBrowser_.refreshHostList();
// Update information on tree
HostDescriptor[] licensedHosts = hostBrowser_.hosts();
for (int i=0; i <licensedHosts.length; i++)
{
// Get host node.
DefaultMutableTreeNode hostNode =
(DefaultMutableTreeNode)hostMap_.get(licensedHosts[i].name);
if (hostNode == null)
{
throw new FoamXException
(
"Host not found in hostMap : " + licensedHosts[i].name
);
}
ContextInfo context = (ContextInfo)hostNode.getUserObject();
if (licensedHosts[i].alive)
{
context.setType(ContextInfo.HOST);
}
else
{
context.setType(ContextInfo.HOSTOFFLINE);
}
}
}
catch (FoamXError fxErr)
{
App.handleException(fxErr);
}
catch (FoamXException fxEx)
{
App.handleException(fxEx);
}
}
// //--------------------------------------------------------------------------
// /** Get hostName for given caseBrowser */
// public String getHostName(ICaseBrowser caseBrowser)
// {
//
// // Loop over all host nodes.
// Enumeration enum = hostMap_.keys();
// while (enum.hasMoreElements())
// {
// String hostName = (String)enum.nextElement();
//
// // Get host node.
// DefaultMutableTreeNode hostNode =
// (DefaultMutableTreeNode)hostMap_.get(hostName);
// ContextInfo context = (ContextInfo)hostNode.getUserObject();
//
// if (context.getCaseBrowser() == caseBrowser)
// {
// return hostName;
// }
// }
// return null;
// }
//--------------------------------------------------------------------------
// Connects to existing/starts new caseBrowser. Returns true if started.
static private void getCaseBrowserReference
(
final String hostName,
final IHostBrowser hostBrowser,
ICaseBrowserHolder browserHolder
) throws FoamXException, FoamXSYSError, FoamXError, FoamXIOError
{
boolean hostOK = false;
int sleep = Integer.parseInt
(
App.getOptions().getProperty("FoamX.Sleep", "500")
);
int nRetries = Integer.parseInt
(
App.getOptions().getProperty("FoamX.NRetries", "20")
);
// First try to connect to already running browser
hostOK = hostBrowser.getCaseBrowserReference
(
hostName,
browserHolder
);
if (hostOK)
{
ICaseBrowser caseBrowser = browserHolder.value;
String[] options = { "Use", "Cancel" };
int ret =
JOptionPane.showOptionDialog
(
App.getRootFrame(),
"Found running Case Browser"
+ "\nUse it ?",
"Case Browser",
JOptionPane.DEFAULT_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,
options,
options[0]
);
if (ret == 0) return;
}
// Start case browser
hostBrowser.openCaseBrowser(hostName);
// Go into loop to detect when it has registered.
for (;;)
{
for (int i=0; i<nRetries; i++)
{
try
{
Thread.currentThread().sleep(sleep);
}
catch (InterruptedException ie)
{}
hostOK = hostBrowser.getCaseBrowserReference
(
hostName,
browserHolder
);
if (hostOK) return;
}
if (!hostOK)
{
String[] options = { "Retry", "Exit" };
int ret =
JOptionPane.showOptionDialog
(
App.getRootFrame(),
"Case Browser cannot be contacted.",
"Case Browser",
JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE,
null,
options,
options[0]
);
if (ret != 0)
{
throw new FoamXException
(
"No caseBrowser started on "
+ hostName
);
}
}
}
}
//--------------------------------------------------------------------------
boolean startCaseBrowser(String hostName)
{
boolean ret = false;
try
{
// Lookup the host node.
if (!hostMap_.containsKey(hostName))
{
throw new FoamXException
(
"Invalid host name '" + hostName + "'"
);
}
DefaultMutableTreeNode hostNode =
(DefaultMutableTreeNode)hostMap_.get(hostName);
ContextInfo context = (ContextInfo)hostNode.getUserObject();
// Make sure that the case browser is not running on this host.
if (context.getCaseBrowser() != null)
{
throw new FoamXException
(
"Case browser already running on host'" + hostName + "'"
);
}
ICaseBrowserHolder holder = new ICaseBrowserHolder();
getCaseBrowserReference(hostName, hostBrowser_, holder);
// Attach the case browser object to the host node.
ICaseBrowser caseBrowser = holder.value;
context.setCaseBrowser(caseBrowser);
// Build the case details under this node.
addCaseBrowserNodes(hostNode);
// Return success code.
ret = true;
}
catch (FoamXSYSError sysErr)
{
App.handleException(sysErr);
}
catch (FoamXError fxErr)
{
App.handleException(fxErr);
}
catch (FoamXException fxEx)
{
App.handleException(fxEx);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return ret;
}
//--------------------------------------------------------------------------
// Change contextInfo to show host is inaccessible
void setHostOffLine(String hostName, String msg)
{
try
{
// Lookup the host node.
if (!hostMap_.containsKey(hostName))
{
throw new FoamXException
(
"Invalid host name '" + hostName + "'"
);
}
DefaultMutableTreeNode hostNode =
(DefaultMutableTreeNode)hostMap_.get(hostName);
ContextInfo context = (ContextInfo)hostNode.getUserObject();
// Mark this server as offline.
context.setType(ContextInfo.HOSTOFFLINE);
context.setStatusText(msg);
// Tell hostBrowser
hostBrowser_.hostIsDead(hostName);
}
catch (FoamXError fxErr)
{
App.handleException(fxErr);
}
catch (FoamXException fxEx)
{
App.handleException(fxEx);
}
}
//--------------------------------------------------------------------------
void stopCaseBrowser(String hostName)
{
try
{
// Lookup the host node.
if (!hostMap_.containsKey(hostName))
{
throw new FoamXException
(
"Invalid host name '" + hostName + "'"
);
}
DefaultMutableTreeNode hostNode =
(DefaultMutableTreeNode)hostMap_.get(hostName);
ContextInfo context = (ContextInfo)hostNode.getUserObject();
// Make sure that the case browser is running on this host.
ICaseBrowser caseBrowser = context.getCaseBrowser();
if (caseBrowser == null)
{
throw new FoamXException
(
"Case browser not running on host '" + hostName + "'"
);
}
// // Clear the cases map for cases managed by this caseBrowser.
// CaseDescriptor[] cases = caseBrowser.cases();
// for (int i = 0; i <cases.length; i++)
// {
// String key =
// cases[i].rootDir + "/" + cases[i].caseName;
//
// if (!keyMap_.containsKey(key))
// {
// throw new FoamXException
// (
// "Case not in tree : " + key
// );
// }
// keyMap_.remove(key);
// }
keyMap_.clear();
// Detach the case browser object from the host node.
context.setCaseBrowser(null);
// Close the C++ caseBrowser.
caseBrowser.close();
// Remove all child nodes from the host node.
hostNode.removeAllChildren();
}
catch (FoamXException fxEx)
{
App.handleException(fxEx);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
// Build caseRoot nodes for hostNode
protected void addCaseBrowserNodes(DefaultMutableTreeNode hostNode)
{
try
{
ContextInfo hostContext = (ContextInfo)hostNode.getUserObject();
ICaseBrowser caseBrowser = hostContext.getCaseBrowser();
if (caseBrowser == null)
{
throw new FoamXException("Invalid case browser reference.");
}
// Get a list of cases served by this case browser.
String[] roots =
caseBrowser.foamProperties().rootDirectories();
String[] rawRoots =
caseBrowser.foamProperties().rawRootDirectories();
// Loop over all case roots.
for (int i = 0; i <roots.length; i++)
{
// Add a new case root node.
// Use original name as display name but expanded one as
// case root.
ContextInfo caseRootContextInfo = new ContextInfo
(
caseBrowser,
roots[i],
rawRoots[i]
);
// Add a new case root node.
caseRootContextInfo.setStatusText
(
"Root Directory : " + rawRoots[i]
);
DefaultMutableTreeNode caseRootNode =
new DefaultMutableTreeNode
(
caseRootContextInfo,
true
);
insertNodeInto
(
caseRootNode,
hostNode,
hostNode.getChildCount()
);
// Store reference to node
rootDirMap_.put(roots[i], caseRootNode);
//
// // Add cases
// addRootDirNodes(hostNode, roots[i], caseRootNode);
}
}
catch (FoamXException fxEx)
{
App.handleException(fxEx);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
// Insert cases below caseRoot node
protected void addRootDirNodes
(
DefaultMutableTreeNode hostNode,
String caseRoot,
DefaultMutableTreeNode caseRootNode
)
{
try
{
ContextInfo hostContext = (ContextInfo)hostNode.getUserObject();
ICaseBrowser caseBrowser = hostContext.getCaseBrowser();
if (caseBrowser == null)
{
throw new FoamXException("Invalid case browser reference.");
}
// Refresh caseBrowser's information
caseBrowser.addToCaseList(caseRoot);
// Loop over all cases and add case nodes.
CaseDescriptor[] cases = caseBrowser.cases();
// Clear the caseRoot tree
caseRootNode.removeAllChildren();
for (int i = 0; i < cases.length; i++)
{
if (cases[i].rootDir.equals(caseRoot))
{
// Add case node.
ContextInfo caseNameContextInfo = new ContextInfo
(
caseBrowser,
cases[i]
);
caseNameContextInfo.setStatusText
(
"Case : " + cases[i].caseName
+ " (" + cases[i].app + ")"
);
DefaultMutableTreeNode caseNode = new DefaultMutableTreeNode
(
caseNameContextInfo,
false
);
insertNodeInto
(
caseNode,
caseRootNode,
caseRootNode.getChildCount()
);
// Update key to tree mapping
String key = cases[i].rootDir + "/" + cases[i].caseName;
keyMap_.put(key, caseNode);
}
}
}
catch (FoamXException fxEx)
{
App.handleException(fxEx);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
/** Updates single case node.
* Used for case closing only.
*/
protected void refreshCaseNode
(
String caseRoot,
String caseName
)
{
try
{
// See if we have a treeNode for this case.
String key = caseRoot + "/" + caseName;
if (!keyMap_.containsKey(key))
{
return;
}
DefaultMutableTreeNode caseNode =
(DefaultMutableTreeNode)keyMap_.get(key);
ContextInfo caseNameContextInfo =
(ContextInfo)caseNode.getUserObject();
ICaseBrowser caseBrowser = caseNameContextInfo.getCaseBrowser();
// Update contextinfo for caseNode
// Go back to caseBrowser list and look for caseDescriptor for
// my case
//caseBrowser.addToCaseList(caseRoot);
CaseDescriptor[] cases = caseBrowser.cases();
CaseDescriptor caseDescriptor = null;
for (int i = 0; i <cases.length; i++)
{
if
(
(caseRoot.equals(cases[i].rootDir))
&& (caseName.equals(cases[i].caseName))
)
{
caseDescriptor = cases[i];
break;
}
}
if (caseDescriptor == null)
{
throw new FoamXException
(
"Case not in caseBrowser : " + key
);
}
// Release old references.
cases = null;
caseNameContextInfo.setCaseBrowser(null);
caseNameContextInfo.setCaseDescriptor(null);
// Update user object on tree node with current caseDescriptor
caseNode.setUserObject
(
new ContextInfo(caseBrowser, caseDescriptor)
);
}
catch (FoamXException fxEx)
{
App.handleException(fxEx);
}
}
//--------------------------------------------------------------------------
/** Deletes single case node.
*/
protected void deleteCaseNode
(
String caseRoot,
String caseName
)
{
try
{
// See if we have a treeNode for this case.
String key = caseRoot + "/" + caseName;
if (!keyMap_.containsKey(key))
{
// Not in tree
throw new FoamXException
(
"Case not in caseBrowser : " + key
);
}
// Remove treeNode
DefaultMutableTreeNode caseNode =
(DefaultMutableTreeNode)keyMap_.get(key);
DefaultMutableTreeNode rootNode =
(DefaultMutableTreeNode)caseNode.getParent();
ContextInfo caseNameContextInfo =
(ContextInfo)caseNode.getUserObject();
// Release old references.
caseNameContextInfo.setCaseBrowser(null);
caseNameContextInfo.setCaseDescriptor(null);
// Remove caseNode from tree
rootNode.remove(caseNode);
}
catch (FoamXException fxEx)
{
App.handleException(fxEx);
}
}
//--------------------------------------------------------------------------
/** Close all case browsers. */
public void shutdown()
{
// Clear keyMap
keyMap_.clear();
// Loop over all host nodes.
Enumeration enum = hostMap_.keys();
while (enum.hasMoreElements())
{
String hostName = (String)enum.nextElement();
// Get host node.
DefaultMutableTreeNode hostNode =
(DefaultMutableTreeNode)hostMap_.get(hostName);
ContextInfo context = (ContextInfo)hostNode.getUserObject();
// See if a case browser is running on this host.
ICaseBrowser caseBrowser = context.getCaseBrowser();
if (caseBrowser != null)
{
// Close the case browser on this node.
caseBrowser.close();
}
}
}
}
//--------------------------------------------------------------------------

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<NonVisualComponents>
<Component class="javax.swing.JPopupMenu" name="contextMenu_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
</Component>
</NonVisualComponents>
<SyntheticProperties>
</SyntheticProperties>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="scrollPane_">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="16" fill="1" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTree" name="tree_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="showsRootHandles" type="boolean" value="true"/>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="OnMouseClicked"/>
<EventHandler event="treeExpanded" listener="javax.swing.event.TreeExpansionListener" parameters="javax.swing.event.TreeExpansionEvent" handler="OnTreeExpand"/>
<EventHandler event="treeWillExpand" listener="javax.swing.event.TreeWillExpandListener" parameters="javax.swing.event.TreeExpansionEvent" handler="OnTreeWillExpand"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@ -0,0 +1,238 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.CaseManagement;
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
import FoamX.App;
import FoamX.Exceptions.FoamXException;
import FoamX.CaseManagement.CaseBrowserPanel;
import FoamXServer.CaseBrowser.ICaseBrowser;
public class CaseChooserDlg
extends javax.swing.JDialog
implements CaseSelectionListener
{
//--------------------------------------------------------------------------
protected CaseBrowserPanel caseBrowserPanel_;
protected String hostName_;
protected String caseRoot_;
protected String caseName_;
protected ICaseBrowser caseBrowser_;
private static final int DEFAULT_WIDTH = 300;
private static final int DEFAULT_HEIGHT = 400;
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
/** CaseChooserDlg constructor. */
public CaseChooserDlg(java.awt.Frame parent, int selectMode)
{
super(parent, "Select Case", true);
try
{
// Get current caseBrowserModel from existing caseBrowserPanel
CaseManager caseManager = App.getCaseManager();
if (caseManager == null)
{
throw new FoamXException
(
"No caseManager in top-level App."
);
}
CaseBrowserModel model =
caseManager.getCaseBrowser().getModel();
// Open new caseBrowserPanel with existing model in
// case-selection mode.
caseBrowserPanel_ =
new CaseBrowserPanel(model, selectMode);
initComponents();
// Set title
if (selectMode == CaseBrowserPanel.SELECT_ROOT_MODE)
{
setTitle("Select Root");
}
else if (selectMode == CaseBrowserPanel.SELECT_CASE_MODE)
{
setTitle("Select Case");
}
else if (selectMode == CaseBrowserPanel.OPEN_CASE_MODE)
{
setTitle("Select Case");
}
// Clear all vars
clearSelection();
// Get warned of any selection
caseBrowserPanel_.addCaseSelectionListener(this);
}
catch (FoamXException ex)
{
App.handleAllExceptions(ex);
}
}
/** GUI initialisation */
private void initComponents()
{
getContentPane().add(caseBrowserPanel_);
addWindowListener
(
new java.awt.event.WindowAdapter()
{
public void windowClosing(java.awt.event.WindowEvent evt)
{
closeDialog(evt);
}
}
);
caseBrowserPanel_.setPreferredSize
(
new java.awt.Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT)
);
pack();
java.awt.Dimension screenSize =
java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setLocation
(
(screenSize.width-getSize().width)/2,
(screenSize.height-getSize().height)/2
);
}
private void closeDialog(java.awt.event.WindowEvent evt)
{
clearSelection();
exitWindow();
}
private void clearSelection()
{
hostName_ = null;
caseRoot_ = null;
caseName_ = null;
caseBrowser_ = null;
}
private void exitWindow()
{
//caseBrowserPanel_.shutdown();
setVisible(false);
dispose();
}
//--------------------------------------------------------------------------
//---- public accessors
//--------------------------------------------------------------------------
/** get selected host */
public String getHostName()
{
return hostName_;
}
/** get selected root */
public String getCaseRoot()
{
return caseRoot_;
}
/** get selected case name */
public String getCaseName()
{
return caseName_;
}
/** get selected ICaseBrowser */
public ICaseBrowser getCaseBrowser()
{
return caseBrowser_;
}
//--------------------------------------------------------------------------
//---- CaseSelectionListener Interface
//--------------------------------------------------------------------------
public void hostSelected(CaseSelectionEvent evt)
{
hostName_ = evt.hostName();
caseRoot_ = evt.caseRoot();
caseName_ = evt.caseName();
caseBrowser_ = evt.caseBrowser();
}
public void rootSelected(CaseSelectionEvent evt)
{
hostName_ = evt.hostName();
caseRoot_ = evt.caseRoot();
caseName_ = evt.caseName();
caseBrowser_ = evt.caseBrowser();
exitWindow();
}
public void caseSelected(CaseSelectionEvent evt)
{
hostName_ = evt.hostName();
caseRoot_ = evt.caseRoot();
caseName_ = evt.caseName();
caseBrowser_ = evt.caseBrowser();
exitWindow();
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<SyntheticProperties>
</SyntheticProperties>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Container class="javax.swing.JTabbedPane" name="tabbedPanel_">
<Properties>
<Property name="tabPlacement" type="int" value="3"/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="10" fill="1" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="0" insetsLeft="0" insetsRight="0" insetsTop="0" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
</Container>
</SubComponents>
</Form>

View File

@ -0,0 +1,990 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.CaseManagement;
import java.util.Hashtable;
import java.util.Enumeration;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import FoamX.App;
import FoamX.TaskManagement.Task;
import FoamX.ToolbarManagement.Toolbar;
import FoamX.Util.BusyCursor;
import FoamX.Exceptions.FoamXException;
import FoamX.Exceptions.CaseBrowserIOException;
import FoamXServer.*;
import FoamXServer.CaseServer.ICaseServer;
import FoamXServer.CasePostServer.ICasePostServer;
public class CaseManager
extends javax.swing.JPanel
implements CaseStatusListener, ChangeListener
{
//--------------------------------------------------------------------------
// Case browser panel object.
protected CaseBrowserPanel caseBrowserPanel_;
// Map of CasePanel objects.
protected Hashtable caseMap_;
// Map of CasePostPanel objects.
protected Hashtable casePostMap_;
// Objects interested in case manager events.
protected EventListenerList listenerList_;
protected Toolbar toolBar_;
//protected SaveCurrentCaseAction saveCurrentCaseAction_;
//protected CloseCurrentCaseAction closeCurrentCaseAction_;
//protected SaveAllCasesAction saveAllCasesAction_;
//protected CloseAllCasesAction closeAllCasesAction_;
//--------------------------------------------------------------------------
/** CaseManager constructor. */
public CaseManager()
{
try
{
// Initialise the GUI components.
initComponents();
// Create case map.
caseMap_ = new Hashtable();
casePostMap_ = new Hashtable();
// Create listener list.
listenerList_ = new EventListenerList();
// Initialise actions and toolbar.
//saveCurrentCaseAction_ = new SaveCurrentCaseAction();
//closeCurrentCaseAction_ = new CloseCurrentCaseAction();
//saveAllCasesAction_ = new SaveAllCasesAction();
//closeAllCasesAction_ = new CloseAllCasesAction();
//saveCurrentCaseAction_.setEnabled(false);
//closeCurrentCaseAction_.setEnabled(false);
//saveAllCasesAction_.setEnabled(false);
//closeAllCasesAction_.setEnabled(false);
// Add case browser tab. Have it start a new model.
caseBrowserPanel_ =
new CaseBrowserPanel(null, CaseBrowserPanel.OPEN_CASE_MODE);
tabbedPanel_.addTab("Case Browser", caseBrowserPanel_);
// Initialise toolbar with my actions
//toolBar_ =
// App.getToolbarManager().addToolbar
// (
// "CaseManager",
// "Case Manager"
// );
//addToolbarButton(saveCurrentCaseAction_);
//addToolbarButton(saveAllCasesAction_);
//toolBar_.addSeparator();
//addToolbarButton(closeCurrentCaseAction_);
//addToolbarButton(closeAllCasesAction_);
// Register this object as a tab selection changed listener.
tabbedPanel_.getModel().addChangeListener(this);
// Register this object as a CaseStatusListener.
caseBrowserPanel_.addCaseStatusListener(this);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
/** Close all open cases. */
public void closeAllCases()
{
try
{
// Create a task object to keep track of progress.
Task task = App.getTaskManager().createTask
(
"Closing All Cases",
0,
caseMap_.size()
);
int caseNo = 0;
// Close all cases.
Enumeration enum = caseMap_.elements();
while (enum.hasMoreElements())
{
// Get next case.
CasePanel casePanel = (CasePanel)enum.nextElement();
// Give option of saving if modified
casePanel.checkAndSave
(
false,
"Case has been changed. Save before closing?",
"Save Case"
);
// Do exactly if 'close case' on casePanel was pressed
caseClosed
(
new CaseStatusEvent
(
this,
casePanel.getCaseRoot(),
casePanel.getCaseName()
)
);
// Update the progress info.
task.setProgress(caseNo++);
}
//// Close all post processing in a similar way
//task = App.getTaskManager().createTask
// (
// "Closing All Postprocessing",
// 0,
// caseMap_.size()
// );
//caseNo = 0;
//// Close all cases.
//enum = casePostMap_.elements();
//while (enum.hasMoreElements())
//{
// // Get next case.
// CasePostPanel casePostPanel = (CasePostPanel)enum.nextElement();
//
// // Do exactly if 'close case' on casePostPanel was pressed
// casePostClosed
// (
// new CaseStatusEvent
// (
// this,
// casePanel.getCaseRoot(),
// casePanel.getCaseName()
// )
// );
//
// // Update the progress info.
// task.setProgress(caseNo++);
//}
// Refresh the case browser panel
caseBrowserPanel_.refreshCaseBrowser(false);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
finally
{
App.getTaskManager().endTask();
}
}
//--------------------------------------------------------------------------
/** Save open case. Ask first. */
public void saveCaseNice(String caseRoot, String caseName)
{
CasePanel casePanel = getCasePanel(caseRoot, caseName);
if (casePanel != null)
{
// Give option of saving if modified
casePanel.checkAndSave
(
false,
"Case " + caseName
+ " has been changed. Save before invoking utility?",
"Save Case"
);
}
}
//--------------------------------------------------------------------------
/** Shut down the CaseManager object and close all open cases. */
public void shutdown()
{
try
{
// Close all cases.
closeAllCases();
// Unregister as a CaseStatusListener.
caseBrowserPanel_.removeCaseStatusListener(this);
// Shutdown the case browser.
caseBrowserPanel_.shutdown();
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
public CaseBrowserPanel getCaseBrowser()
{
return caseBrowserPanel_;
}
//--------------------------------------------------------------------------
public CasePanel getCasePanel(String caseRoot, String caseName)
{
CasePanel casePanel = null;
String rootAndCase = caseRoot + "/" + caseName;
if (caseMap_.containsKey(rootAndCase))
{
// Create a new case panel object to manage the case.
casePanel = (CasePanel)caseMap_.get(rootAndCase);
}
return casePanel;
}
//--------------------------------------------------------------------------
protected void addToolbarButton(AbstractAction action)
{
// Add new button to the toolbar using the action object.
javax.swing.JButton button = toolBar_.add(action);
// Set the tooltip text.
button.setToolTipText((String)action.getValue
(
Action.SHORT_DESCRIPTION)
);
button.setText("");
button.setFont(toolBar_.getFont()); // Use same font as toolbar.
}
//--------------------------------------------------------------------------
//---- CaseManagerListener Interface
//--------------------------------------------------------------------------
public void addCaseManagerListener(CaseManagerListener l)
{
listenerList_.add(CaseManagerListener.class, l);
}
//--------------------------------------------------------------------------
public void removeCaseManagerListener(CaseManagerListener l)
{
listenerList_.remove(CaseManagerListener.class, l);
}
//--------------------------------------------------------------------------
protected void fireOpenCase
(
String caseRoot,
String caseName,
ICaseServer caseServer
)
{
// Create event object.
CaseManagerEvent evt = new CaseManagerEvent
(
this,
caseRoot,
caseName,
caseServer
);
// Process the listeners last to first, notifying those that are
// interested in this event.
Object[] listeners = listenerList_.getListenerList();
for (int i=listeners.length-2; i>= 0; i-=2)
{
if (listeners[i] == CaseManagerListener.class)
{
((CaseManagerListener)listeners[i+1]).caseOpened(evt);
}
}
}
//--------------------------------------------------------------------------
protected void fireOpenPostCase
(
String caseRoot,
String caseName,
ICasePostServer casePostServer
)
{
// Create event object.
CaseManagerEvent evt = new CaseManagerEvent
(
this,
caseRoot,
caseName,
casePostServer
);
// Process the listeners last to first, notifying those that are
// interested in this event.
Object[] listeners = listenerList_.getListenerList();
for (int i=listeners.length-2; i>= 0; i-=2)
{
if (listeners[i] == CaseManagerListener.class)
{
((CaseManagerListener)listeners[i+1]).casePostOpened(evt);
}
}
}
//--------------------------------------------------------------------------
protected void fireCloseCase(String caseRoot, String caseName)
{
// Create event object.
CaseManagerEvent evt = new CaseManagerEvent(this, caseRoot, caseName);
// Process the listeners last to first, notifying those that are
// interested in this event.
Object[] listeners = listenerList_.getListenerList();
for (int i=listeners.length-2; i>= 0; i-=2)
{
if (listeners[i] == CaseManagerListener.class)
{
((CaseManagerListener)listeners[i+1]).caseClosed(evt);
}
}
}
//--------------------------------------------------------------------------
protected void fireClosePostCase(String caseRoot, String caseName)
{
// Create event object.
CaseManagerEvent evt = new CaseManagerEvent(this, caseRoot, caseName);
// Process the listeners last to first, notifying those that are
// interested in this event.
Object[] listeners = listenerList_.getListenerList();
for (int i=listeners.length-2; i>= 0; i-=2)
{
if (listeners[i] == CaseManagerListener.class)
{
((CaseManagerListener)listeners[i+1]).casePostClosed(evt);
}
}
}
//--------------------------------------------------------------------------
protected void fireDeleteCase(String caseRoot, String caseName)
{
// Create event object.
CaseManagerEvent evt = new CaseManagerEvent(this, caseRoot, caseName);
// Process the listeners last to first, notifying those that are
// interested in this event.
Object[] listeners = listenerList_.getListenerList();
for (int i=listeners.length-2; i>= 0; i-=2)
{
if (listeners[i] == CaseManagerListener.class)
{
((CaseManagerListener)listeners[i+1]).caseDeleted(evt);
}
}
}
//--------------------------------------------------------------------------
protected void fireCasePanelSelected(String caseRoot, String caseName)
{
// Create event object.
CaseManagerEvent evt = new CaseManagerEvent(this, caseRoot, caseName);
// Process the listeners last to first, notifying those that are
// interested in this event.
Object[] listeners = listenerList_.getListenerList();
for (int i=listeners.length-2; i>= 0; i-=2)
{
if (listeners[i] == CaseManagerListener.class)
{
((CaseManagerListener)listeners[i+1]).casePanelSelected(evt);
}
}
}
//--------------------------------------------------------------------------
protected void fireCaseBrowserSelected()
{
// Create event object.
CaseManagerEvent evt = new CaseManagerEvent(this);
// Process the listeners last to first, notifying those that are
// interested in this event.
Object[] listeners = listenerList_.getListenerList();
for (int i=listeners.length-2; i>= 0; i-=2)
{
if (listeners[i] == CaseManagerListener.class)
{
((CaseManagerListener)listeners[i+1]).caseBrowserSelected(evt);
}
}
}
//--------------------------------------------------------------------------
/** 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 FormEditor.
*/
private void initComponents()//GEN-BEGIN:initComponents
{
tabbedPanel_ = new javax.swing.JTabbedPane();
setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints1;
tabbedPanel_.setTabPlacement(javax.swing.JTabbedPane.BOTTOM);
tabbedPanel_.setFont(new java.awt.Font("Dialog", 0, 10));
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints1.weightx = 1.0;
gridBagConstraints1.weighty = 1.0;
add(tabbedPanel_, gridBagConstraints1);
}//GEN-END:initComponents
//--------------------------------------------------------------------------
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTabbedPane tabbedPanel_;
// End of variables declaration//GEN-END:variables
//--------------------------------------------------------------------------
//---- CaseStatusListener Interface
//--------------------------------------------------------------------------
public void caseOpened(CaseStatusEvent evt)
{
try
{
// Make sure the event object has a case server reference.
if (evt.caseServer() != null)
{
// See if we already have this case.
String key = evt.caseRoot() + "/" + evt.caseName();
if (!caseMap_.containsKey(key))
{
// Create a new case panel object to manage the case.
// Note: will throw exception if case in error.
CasePanel casePanel = new CasePanel
(
evt.caseBrowser(),
evt.caseServer()
);
// Register this object as a CaseStatusListener.
casePanel.addCaseStatusListener(this);
// Add new tab.
tabbedPanel_.addTab(evt.caseName(), casePanel);
caseMap_.put(key, casePanel);
// Pop the new tab to the front.
tabbedPanel_.setSelectedComponent(casePanel);
// Inform case manager listeners.
fireOpenCase
(
evt.caseRoot(),
evt.caseName(),
evt.caseServer()
);
}
}
}
catch (FoamXIOError ioErr)
{
// io error. Add caseBrowser information
if (evt.caseBrowser() != null)
{
// Add caseBrowser info
App.handleAllExceptions
(
new CaseBrowserIOException
(
ioErr,
evt.caseBrowser()
)
);
}
else
{
App.handleAllExceptions(ioErr);
}
}
catch (Exception ex)
{
// caseBrowserPanel_.refreshCaseNode
// (
// evt.caseRoot(),
// evt.caseName()
// );
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
public void casePostOpened(CaseStatusEvent evt)
{
try
{
// Make sure the event object has a case server reference.
if (evt.casePostServer() == null)
{
return;
}
// See if we already have this case.
String key = evt.caseRoot() + "/" + evt.caseName();
if (casePostMap_.containsKey(key))
{
System.out.println("Already postprocessing case " + key);
}
else
{
System.out.println("Starting postprocessing case " + key);
}
//PostApp pp =
// new PostApp
// (
// evt.casePostServer(),
// evt.caseRoot(),
// evt.caseName()
// );
////MainFrame mf = new MainFrame(pp, 300, 600);
//
//// Register this object as a CaseStatusListener.
//pp.getPostWindow().addCaseStatusListener(this);
//
//casePostMap_.put(key, pp);
// Inform case manager listeners.
fireOpenPostCase
(
evt.caseRoot(),
evt.caseName(),
evt.casePostServer()
);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
public void caseClosed(CaseStatusEvent evt)
{
try
{
// See if we have this case.
String key = evt.caseRoot() + "/" + evt.caseName();
if (caseMap_.containsKey(key))
{
// Get CasePanel object for this case.
CasePanel casePanel = (CasePanel)caseMap_.get(key);
// Unregister as a CaseStatusListener.
casePanel.removeCaseStatusListener(this);
// Close the case.
casePanel.closeCase(CasePanel.KILL_SERVER);
// Remove tab.
tabbedPanel_.remove(casePanel);
caseMap_.remove(key);
// Pop the case browser tab to the front.
tabbedPanel_.setSelectedComponent(caseBrowserPanel_);
// Refresh the case browser panel
caseBrowserPanel_.refreshCaseNode
(
evt.caseRoot(),
evt.caseName()
);
// Inform case manager listeners.
fireCloseCase(evt.caseRoot(), evt.caseName());
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
public void casePostClosed(CaseStatusEvent evt)
{
try
{
//// See if we have this case.
//String key = evt.caseRoot() + "/" + evt.caseName();
//
//if (casePostMap_.containsKey(key))
//{
// System.out.println
// (
// "CaseManager:casePostClosed for " + evt.caseName()
// );
//
// PostApp pp = (PostApp)casePostMap_.get(key);
//
// PostWindow ps = pp.getPostWindow();
//
// // Unregister as a CaseStatusListener.
// ps.removeCaseStatusListener(this);
//
// pp.destroy();
//
// casePostMap_.remove(key);
//
// // Inform case manager listeners.
// fireClosePostCase(evt.caseRoot(), evt.caseName());
//}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
public void caseDeleted(CaseStatusEvent evt)
{
try
{
// See if we have this case.
String key = evt.caseRoot() + "/" + evt.caseName();
if (caseMap_.containsKey(key))
{
// Get CasePanel object for this case.
CasePanel casePanel = (CasePanel)caseMap_.get(key);
// Unregister as a CaseStatusListener.
casePanel.removeCaseStatusListener(this);
// Close the case.
casePanel.closeCase(CasePanel.KILL_SERVER);
// Remove tab.
tabbedPanel_.remove(casePanel);
caseMap_.remove(key);
// Pop the case browser tab to the front.
tabbedPanel_.setSelectedComponent(caseBrowserPanel_);
// Refresh the case browser.
caseBrowserPanel_.deleteCaseNode
(
evt.caseRoot(),
evt.caseName()
);
// Inform case manager listeners.
fireDeleteCase(evt.caseRoot(), evt.caseName());
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
//---- ChangeEventListener Interface
//--------------------------------------------------------------------------
public void stateChanged(javax.swing.event.ChangeEvent evt)
{
try
{
// See which tab has been selected;
Component comp = tabbedPanel_.getSelectedComponent();
if (comp instanceof CaseBrowserPanel)
{
// Tell the case browser tab that it's selected.
caseBrowserPanel_.tabSelected();
// Deselect all case tabs.
Component[] tabs = tabbedPanel_.getComponents();
for (int i = 0; i <tabs.length; i++)
{
if (tabs[i] instanceof CasePanel)
{
CasePanel cp = (CasePanel)tabs[i];
cp.tabDeselected();
}
}
// Fire a tab selection event to interested listeners.
fireCaseBrowserSelected();
}
else if (comp instanceof CasePanel)
{
// Deselect all case tabs and the case browser tab.
caseBrowserPanel_.tabDeselected();
Component[] tabs = tabbedPanel_.getComponents();
for (int i = 0; i <tabs.length; i++)
{
if (tabs[i] instanceof CasePanel)
{
CasePanel cp = (CasePanel)tabs[i];
cp.tabDeselected();
}
}
// Tell the case panel that it's selected.
CasePanel cp = (CasePanel)comp;
cp.tabSelected();
// Fire a tab selection event to interested listeners.
fireCasePanelSelected(cp.getCaseRoot(), cp.getCaseName());
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
//---- Action Classes
//--------------------------------------------------------------------------
// private class SaveCurrentCaseAction
// extends AbstractAction
// {
// SaveCurrentCaseAction()
// {
// putValue
// (
// Action.SMALL_ICON,
// App.getResources().getIcon
// (
// "CaseManager.SaveCurrentCaseImage"
// )
// );
// putValue(Action.NAME, "SaveCurrentCase");
// putValue(Action.SHORT_DESCRIPTION, "Save Current Case");
// putValue(Action.LONG_DESCRIPTION, "Save Current Case");
// }
//
// public void actionPerformed(ActionEvent evt)
// {
// // Show busy cursor.
// BusyCursor cursor = new BusyCursor(App.getRootFrame());
//
// try
// {
// Component comp = tabbedPanel_.getSelectedComponent();
// if (comp instanceof CasePanel)
// {
// CasePanel cp = (CasePanel)comp;
// cp.saveCase();
// }
// }
// catch (Exception ex)
// {
// App.handleAllExceptions(ex);
// }
// }
// }
//--------------------------------------------------------------------------
// private class SaveAllCasesAction
// extends AbstractAction
// {
// SaveAllCasesAction()
// {
// putValue
// (
// Action.SMALL_ICON,
// App.getResources().getIcon("CaseManager.SaveAllCasesImage")
// );
// putValue(Action.NAME, "SaveAllCases");
// putValue(Action.SHORT_DESCRIPTION, "Save All Cases");
// putValue(Action.LONG_DESCRIPTION, "Save All Cases");
// }
//
// public void actionPerformed(ActionEvent evt)
// {
// // Show busy cursor.
// BusyCursor cursor = new BusyCursor(App.getRootFrame());
//
// try
// {
// Component[] tabs = tabbedPanel_.getComponents();
// for (int i = 0; i <tabs.length; i++)
// {
// if (tabs[i] instanceof CasePanel)
// {
// CasePanel cp = (CasePanel)tabs[i];
// cp.saveCase();
// }
// }
// }
// catch (Exception ex)
// {
// App.handleAllExceptions(ex);
// }
// }
// }
//--------------------------------------------------------------------------
// private class CloseCurrentCaseAction
// extends AbstractAction
// {
// CloseCurrentCaseAction()
// {
// putValue
// (
// Action.SMALL_ICON,
// App.getResources().getIcon("CaseManager.CloseCurrentCaseImage")
// );
// putValue(Action.NAME, "CloseCurrentCase");
// putValue(Action.SHORT_DESCRIPTION, "Close Current Case");
// putValue(Action.LONG_DESCRIPTION, "Close Current Case");
// }
//
// public void actionPerformed(ActionEvent evt)
// {
// // Show busy cursor.
// BusyCursor cursor = new BusyCursor(App.getRootFrame());
//
// try
// {
// Component comp = tabbedPanel_.getSelectedComponent();
// if (comp instanceof CasePanel)
// {
// CasePanel cp = (CasePanel)comp;
// boolean doClose = cp.checkAndSave
// (
// true,
// "Case has been changed. Save before closing?",
// "Save Case"
// );
// if (doClose)
// {
// // Do exactly if 'close case' on casePanel was pressed
// caseClosed
// (
// new CaseStatusEvent
// (
// this,
// cp.getCaseRoot(),
// cp.getCaseName()
// )
// );
//
// }
// }
// }
// catch (Exception ex)
// {
// App.handleAllExceptions(ex);
// }
// }
// }
//--------------------------------------------------------------------------
// private class CloseAllCasesAction
// extends AbstractAction
// {
// CloseAllCasesAction()
// {
// putValue
// (
// Action.SMALL_ICON,
// App.getResources().getIcon("CaseManager.CloseAllCasesImage")
// );
// putValue(Action.NAME, "CloseAllCases");
// putValue(Action.SHORT_DESCRIPTION, "Close All Cases");
// putValue(Action.LONG_DESCRIPTION, "Close All Cases");
// }
//
// public void actionPerformed(ActionEvent evt)
// {
// // Show busy cursor.
// BusyCursor cursor = new BusyCursor(App.getRootFrame());
//
// try
// {
// closeAllCases();
// }
// catch (Exception ex)
// {
// App.handleAllExceptions(ex);
// }
// }
// }
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,115 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.CaseManagement;
import FoamXServer.CaseServer.ICaseServer;
import FoamXServer.CasePostServer.ICasePostServer;
public class CaseManagerEvent
extends java.util.EventObject
{
protected String caseRoot_;
protected String caseName_;
protected ICaseServer caseServer_;
protected ICasePostServer casePostServer_;
/** CaseBrowserEvent constructor. */
public CaseManagerEvent(Object source)
{
super(source);
caseRoot_ = "";
caseName_ = "";
caseServer_ = null;
casePostServer_ = null;
}
public CaseManagerEvent
(
Object source,
String caseRoot,
String caseName,
ICaseServer caseServer
)
{
super(source);
caseRoot_ = caseRoot;
caseName_ = caseName;
caseServer_ = caseServer;
casePostServer_ = null;
}
public CaseManagerEvent
(
Object source,
String caseRoot,
String caseName,
ICasePostServer casePostServer
)
{
super(source);
caseRoot_ = caseRoot;
caseName_ = caseName;
caseServer_ = null;
casePostServer_ = casePostServer;
}
public CaseManagerEvent(Object source, String caseRoot, String caseName)
{
super(source);
caseRoot_ = caseRoot;
caseName_ = caseName;
caseServer_ = null;
casePostServer_ = null;
}
public String toString()
{
return "CaseManagerEvent : " + caseRoot_ + " " + caseName_;
}
public String caseRoot()
{
return caseRoot_;
}
public String caseName()
{
return caseName_;
}
public ICaseServer caseServer()
{
return caseServer_;
}
public ICasePostServer casePostServer()
{
return casePostServer_;
}
}

View File

@ -0,0 +1,42 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.CaseManagement;
public interface CaseManagerListener
extends java.util.EventListener
{
public abstract void caseOpened(CaseManagerEvent evt);
public abstract void casePostOpened(CaseManagerEvent evt);
public abstract void caseClosed(CaseManagerEvent evt);
public abstract void casePostClosed(CaseManagerEvent evt);
public abstract void caseDeleted(CaseManagerEvent evt);
public abstract void casePanelSelected(CaseManagerEvent evt);
public abstract void caseBrowserSelected(CaseManagerEvent evt);
}

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<NonVisualComponents>
<Menu class="javax.swing.JPopupMenu" name="contextMenu_">
</Menu>
</NonVisualComponents>
<SyntheticProperties>
</SyntheticProperties>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="scrollPanel_">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="16" fill="1" gridHeight="1" gridWidth="1" gridX="0" gridY="1" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTree" name="tree_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="showsRootHandles" type="boolean" value="true"/>
<Property name="toggleClickCount" type="int" value="3"/>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="OnMouseClicked"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@ -0,0 +1,85 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.CaseManagement;
import FoamXServer.CaseServer.ICaseServer;
import FoamXServer.CaseBrowser.ICaseBrowser;
public class CaseSelectionEvent
extends java.util.EventObject
{
protected String hostName_;
protected String caseRoot_;
protected String caseName_;
protected ICaseBrowser caseBrowser_;
/** CaseSelectionEvent constructor. */
public CaseSelectionEvent
(
Object source,
String hostName,
String caseRoot,
String caseName,
ICaseBrowser caseBrowser
)
{
super(source);
hostName_ = hostName;
caseRoot_ = caseRoot;
caseName_ = caseName;
caseBrowser_ = caseBrowser;
}
public String toString()
{
return
"CaseSelectionEvent : " + hostName_ + ":" + caseRoot_
+ " " + caseName_;
}
public String hostName()
{
return hostName_;
}
public String caseRoot()
{
return caseRoot_;
}
public String caseName()
{
return caseName_;
}
public ICaseBrowser caseBrowser()
{
return caseBrowser_;
}
}

View File

@ -0,0 +1,38 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.CaseManagement;
public interface CaseSelectionListener
extends java.util.EventListener
{
public abstract void hostSelected(CaseSelectionEvent evt);
public abstract void rootSelected(CaseSelectionEvent evt);
public abstract void caseSelected(CaseSelectionEvent evt);
}

View File

@ -0,0 +1,125 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.CaseManagement;
import FoamXServer.CaseServer.ICaseServer;
import FoamXServer.CasePostServer.ICasePostServer;
import FoamXServer.CaseBrowser.ICaseBrowser;
public class CaseStatusEvent
extends java.util.EventObject
{
protected String caseRoot_;
protected String caseName_;
protected ICaseServer caseServer_;
protected ICasePostServer casePostServer_;
protected ICaseBrowser caseBrowser_;
/** CaseStatusEvent constructor. */
public CaseStatusEvent
(
Object source,
String caseRoot,
String caseName,
ICaseServer caseServer,
ICasePostServer casePostServer,
ICaseBrowser caseBrowser
)
{
super(source);
caseRoot_ = caseRoot;
caseName_ = caseName;
caseServer_ = caseServer;
casePostServer_ = casePostServer;
caseBrowser_ = caseBrowser;
}
/** CaseStatusEvent constructor. */
public CaseStatusEvent
(
Object source,
String caseRoot,
String caseName,
ICaseServer caseServer
)
{
this(source, caseRoot, caseName, caseServer, null, null);
}
public CaseStatusEvent
(
Object source,
String caseRoot,
String caseName,
ICasePostServer casePostServer
)
{
this(source, caseRoot, caseName, null, casePostServer, null);
}
public CaseStatusEvent
(
Object source,
String caseRoot,
String caseName
)
{
this(source, caseRoot, caseName, null, null, null);
}
public String toString()
{
return "CaseStatusEvent : " + caseRoot_ + " " + caseName_;
}
public String caseRoot()
{
return caseRoot_;
}
public String caseName()
{
return caseName_;
}
public ICaseServer caseServer()
{
return caseServer_;
}
public ICasePostServer casePostServer()
{
return casePostServer_;
}
public ICaseBrowser caseBrowser()
{
return caseBrowser_;
}
}

View File

@ -0,0 +1,41 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.CaseManagement;
public interface CaseStatusListener
extends java.util.EventListener
{
public abstract void caseOpened(CaseStatusEvent evt);
public abstract void caseClosed(CaseStatusEvent evt);
public abstract void caseDeleted(CaseStatusEvent evt);
public abstract void casePostOpened(CaseStatusEvent evt);
public abstract void casePostClosed(CaseStatusEvent evt);
}

View File

@ -0,0 +1,221 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.0" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="title" type="java.lang.String" value="Create New Case"/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="modal" type="boolean" value="true"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/>
<SyntheticProperty name="formPosition" type="java.awt.Point" value="-84,-19,0,5,115,114,0,14,106,97,118,97,46,97,119,116,46,80,111,105,110,116,-74,-60,-118,114,52,126,-56,38,2,0,2,73,0,1,120,73,0,1,121,120,112,0,0,0,0,0,0,0,0"/>
<SyntheticProperty name="formSizePolicy" type="int" value="0"/>
<SyntheticProperty name="generatePosition" type="boolean" value="true"/>
<SyntheticProperty name="generateSize" type="boolean" value="true"/>
<SyntheticProperty name="generateCenter" type="boolean" value="true"/>
<SyntheticProperty name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/>
</SyntheticProperties>
<Events>
<EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="closeDialog"/>
</Events>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="mainPanel_">
<Properties>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="null"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="null"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="11" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Component class="javax.swing.JLabel" name="label1_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" id="black" palette="0" red="0" type="palette"/>
</Property>
<Property name="text" type="java.lang.String" value="Class"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="3" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="10" insetsLeft="10" insetsBottom="5" insetsRight="5" anchor="17" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JComboBox" name="appClassCombo_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
<Events>
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="OnAppClassComboChanged"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="1" gridY="3" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="10" insetsLeft="5" insetsBottom="5" insetsRight="10" anchor="17" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JLabel" name="timeLabel">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" id="black" palette="0" red="0" type="palette"/>
</Property>
<Property name="text" type="java.lang.String" value="Times"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="2" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="10" insetsLeft="10" insetsBottom="5" insetsRight="5" anchor="17" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JComboBox" name="timeCombo_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="null"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="null"/>
</Property>
</Properties>
<Events>
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="onTimeComboChanged"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="1" gridY="2" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="10" insetsLeft="5" insetsBottom="5" insetsRight="10" anchor="17" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JLabel" name="label2_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" id="black" palette="0" red="0" type="palette"/>
</Property>
<Property name="text" type="java.lang.String" value="Case Root"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="5" insetsLeft="10" insetsBottom="5" insetsRight="5" anchor="17" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JComboBox" name="rootCombo_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
<Events>
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="OnRootComboChanged"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="1" gridY="0" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="5" insetsLeft="5" insetsBottom="5" insetsRight="10" anchor="17" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JLabel" name="label3_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" id="black" palette="0" red="0" type="palette"/>
</Property>
<Property name="text" type="java.lang.String" value="Case Name"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="5" insetsLeft="10" insetsBottom="10" insetsRight="5" anchor="17" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JTextField" name="caseNameTextField_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Default" size="10" style="0"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="1" gridY="1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="5" insetsLeft="5" insetsBottom="10" insetsRight="10" anchor="17" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="buttonPanel_">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder/>
</Border>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="15" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
<Property name="alignment" type="int" value="2"/>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="buttonOK_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="OK"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="OnOK"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonCancel_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="Cancel"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="OnCancel"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@ -0,0 +1,267 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.CaseManagement;
import javax.swing.Icon;
import FoamXServer.CaseBrowser.ICaseBrowser;
import FoamXServer.CaseDescriptor;
import FoamX.App;
public class ContextInfo
implements FoamX.Util.FoamXTreeRenderer.FoamXTreeItem
{
//--------------------------------------------------------------------------
// Symbolic constants for icon indexes.
protected static final int ROOTCONTEXT = 0;
protected static final int HOST = 1;
protected static final int HOSTOFFLINE = 2;
protected static final int CASEROOT = 3;
protected static final int CASENAME = 4;
protected static final int LOCKEDCASE = 5;
protected static final int MANAGEDCASE = 6;
protected static final int ERRORCASE = 7;
protected static final int INVALID_REF = 8;
protected int type_ = ROOTCONTEXT;
protected String name_ = "";
protected ICaseBrowser caseBrowser_ = null;
protected CaseDescriptor caseDescriptor_ = null;
protected String caseRoot_ = "";
protected String caseName_ = "";
protected String app_ = "";
protected String statusText_ = "";
protected boolean caseLocked_ = false;
protected boolean caseManaged_ = false;
protected boolean caseError_ = false;
protected static Icon[] icons_;
//--------------------------------------------------------------------------
static
{
try
{
// Load icons.
icons_ = new Icon[9];
icons_[ROOTCONTEXT] =
App.getResources().getIcon("CaseBrowser.RootContextImage");
icons_[HOST] =
App.getResources().getIcon("CaseBrowser.HostImage");
icons_[HOSTOFFLINE] =
App.getResources().getIcon("CaseBrowser.HostOfflineImage");
icons_[CASEROOT] =
App.getResources().getIcon("CaseBrowser.CaseRootImage");
icons_[CASENAME] =
App.getResources().getIcon("CaseBrowser.CaseNameImage");
icons_[LOCKEDCASE] =
App.getResources().getIcon("CaseBrowser.LockedCaseImage");
icons_[MANAGEDCASE] =
App.getResources().getIcon("CaseBrowser.ManagedCaseImage");
icons_[ERRORCASE] =
App.getResources().getIcon("CaseBrowser.InvalidRefImage");
icons_[INVALID_REF] =
App.getResources().getIcon("CaseBrowser.InvalidRefImage");
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
/** ContextInfo constructor. */
public ContextInfo(String name, int type)
{
name_ = name;
type_ = type;
}
public ContextInfo
(
ICaseBrowser caseBrowser,
String caseRoot,
String displayCaseRoot
)
{
name_ = displayCaseRoot;
type_ = CASEROOT;
caseBrowser_ = caseBrowser;
caseRoot_ = caseRoot;
}
public ContextInfo(ICaseBrowser caseBrowser, CaseDescriptor caseDescriptor)
{
caseBrowser_ = caseBrowser;
caseDescriptor_ = caseDescriptor;
name_ = caseDescriptor_.caseName;
type_ = CASENAME;
caseRoot_ = caseDescriptor_.rootDir;
caseName_ = caseDescriptor_.caseName;
app_ = caseDescriptor_.app;
caseLocked_ = caseDescriptor_.locked;
caseManaged_ = caseDescriptor_.managed;
caseError_ = caseDescriptor_.error;
}
//--------------------------------------------------------------------------
// FoamXTreeItem interface functions.
public Icon getIcon()
{
// See if this case is in error, locked or unmanaged.
if (type_ == CASENAME && caseError_)
{
return icons_[ERRORCASE];
}
else if (type_ == CASENAME && caseLocked_)
{
return icons_[LOCKEDCASE];
}
else if (type_ == CASENAME && caseManaged_)
{
return icons_[MANAGEDCASE];
}
return icons_[type_];
}
public String getText()
{
return toString();
}
//--------------------------------------------------------------------------
public String toString()
{
return name_;
}
public int getType()
{
return type_;
}
public void setType(int type)
{
type_ = type;
}
public ICaseBrowser getCaseBrowser()
{
return caseBrowser_;
}
public void setCaseBrowser(ICaseBrowser caseBrowser)
{
caseBrowser_ = caseBrowser;
}
public CaseDescriptor getCaseDescriptor()
{
return caseDescriptor_;
}
public void setCaseDescriptor(CaseDescriptor caseDescriptor)
{
caseDescriptor_ = caseDescriptor;
}
public String getCaseRoot()
{
return caseRoot_;
}
public String getCaseName()
{
return caseName_;
}
public String getAppClass()
{
return app_;
}
public String getStatusText()
{
return statusText_;
}
public void setStatusText(String text)
{
statusText_ = text;
}
public boolean isCaseLocked()
{
return caseLocked_;
}
public void setCaseLocked(boolean locked)
{
caseLocked_ = locked;
}
public boolean isCaseError()
{
return caseError_;
}
public void setCaseError(boolean error)
{
caseError_ = error;
}
public boolean isCaseManaged()
{
return caseManaged_;
}
public void setCaseManaged(boolean managed)
{
caseManaged_ = managed;
}
public boolean isRootContext()
{
return type_ == ROOTCONTEXT;
}
public boolean isHost()
{
return (type_ == HOST || type_ == HOSTOFFLINE);
}
public boolean isCaseRoot()
{
return type_ == CASEROOT;
}
public boolean isCaseName()
{
return type_ == CASENAME;
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,180 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.0" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="title" type="java.lang.String" value="Create New Case"/>
<Property name="modal" type="boolean" value="true"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="menuBar" type="java.lang.String" value="(No Menu)"/>
<SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/>
<SyntheticProperty name="formPosition" type="java.awt.Point" value="-84,-19,0,5,115,114,0,14,106,97,118,97,46,97,119,116,46,80,111,105,110,116,-74,-60,-118,114,52,126,-56,38,2,0,2,73,0,1,120,73,0,1,121,120,112,0,0,0,0,0,0,0,0"/>
<SyntheticProperty name="formSizePolicy" type="int" value="0"/>
<SyntheticProperty name="generatePosition" type="boolean" value="true"/>
<SyntheticProperty name="generateSize" type="boolean" value="true"/>
<SyntheticProperty name="generateCenter" type="boolean" value="true"/>
</SyntheticProperties>
<Events>
<EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="closeDialog"/>
</Events>
<AuxValues>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="mainPanel_">
<Properties>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[350, 100]"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="1" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="0" insetsLeft="0" insetsRight="0" insetsTop="0" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Component class="javax.swing.JLabel" name="label1_">
<Properties>
<Property name="text" type="java.lang.String" value="Class"/>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" id="black" palette="0" red="0" type="palette"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="17" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="5" insetsLeft="10" insetsRight="5" insetsTop="10" ipadX="0" ipadY="0" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JComboBox" name="appClassCombo_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
<Events>
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="OnAppClassComboChanged"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="17" fill="2" gridHeight="1" gridWidth="1" gridX="1" gridY="0" insetsBottom="5" insetsLeft="5" insetsRight="10" insetsTop="10" ipadX="0" ipadY="0" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JLabel" name="label2_">
<Properties>
<Property name="text" type="java.lang.String" value="Case Root"/>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" id="black" palette="0" red="0" type="palette"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="17" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="1" insetsBottom="5" insetsLeft="10" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JComboBox" name="rootCombo_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
<Events>
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="OnRootComboChanged"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="17" fill="2" gridHeight="1" gridWidth="1" gridX="1" gridY="1" insetsBottom="5" insetsLeft="5" insetsRight="10" insetsTop="5" ipadX="0" ipadY="0" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JLabel" name="label3_">
<Properties>
<Property name="text" type="java.lang.String" value="Case Name"/>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" id="black" palette="0" red="0" type="palette"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="17" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="2" insetsBottom="10" insetsLeft="10" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JTextField" name="caseNameTextField_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Default" size="10" style="0"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="17" fill="2" gridHeight="1" gridWidth="1" gridX="1" gridY="2" insetsBottom="10" insetsLeft="5" insetsRight="10" insetsTop="5" ipadX="0" ipadY="0" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="buttonPanel_">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder/>
</Border>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="15" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="1" insetsBottom="0" insetsLeft="0" insetsRight="0" insetsTop="0" ipadX="0" ipadY="0" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
<Property name="alignment" type="int" value="2"/>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="buttonOK_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="OK"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="OnOK"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonCancel_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="Cancel"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="OnCancel"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@ -0,0 +1,422 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.CaseManagement;
import java.util.*;
import javax.swing.*;
import FoamX.App;
import FoamXServer.ApplicationDescriptor;
public class CreateCaseDialog
extends javax.swing.JDialog
{
//--------------------------------------------------------------------------
protected boolean wasCancelled_;
protected String caseClass_;
protected String caseRoot_;
protected ApplicationDescriptor[] applicationes_;
//--------------------------------------------------------------------------
/** CreateCaseDialog constructor. */
public CreateCaseDialog
(
java.awt.Frame parent,
ApplicationDescriptor[] applicationes,
String[] caseRoots
)
{
super(parent, true); // Modal.
wasCancelled_ = false;
applicationes_ = applicationes;
// Initialise the default GUI.
initComponents();
// Initialise the application class combo box.
for (int i = 0; i <applicationes_.length; i++)
{
appCombo_.addItem(applicationes_[i].name);
}
// Initialise the case roots combo box.
for (int i = 0; i <caseRoots.length; i++)
{
rootCombo_.addItem(caseRoots[i]);
}
// Repack everything.
pack();
}
//--------------------------------------------------------------------------
// /** Initialise the application class combo box. */
// protected void buildAppsMenu
// (
// JComboBox appsMenu,
// ApplicationDescriptor[] applicationes
// )
// {
// // map from category to menu
// Hashtable appsMenuMap = new Hashtable(5);
//
// for (int i = 0; i <applicationes_.length; i++)
// {
// JComboBox menu = appsMenu;
//
// String appName = applicationes_[i].name;
// String appCat = applicationes_[i].category;
// if ((appCat != null) && (appCat.length() > 0))
// {
// // Has category. Build hierarchical submenus by splitting
// // category at '/'
// // Set menu to be submenu.
// StringTokenizer tok =
// new StringTokenizer(appCat, "/");
//
// String catKey = new String();
//
// while (tok.hasMoreTokens())
// {
// String category = tok.nextToken();
// catKey = catKey + category;
// if (appsMenuMap.containsKey(catKey))
// {
// // Menu already exists for this category
// menu = (JComboBox)appsMenuMap.get(catKey);
// }
// else
// {
// // No menu yet for this category
// JComboBox catMenu = new JComboBox(category);
// catMenu.setFont(appsMenu.getFont());
// menu.add(catMenu);
// appsMenuMap.put(catKey, catMenu);
// menu = catMenu;
// }
// }
// }
//
// // Handle item itself
//
// // Add a menu item for this utility.
// JComboItem comboItem = new JComboItem(appName);
// comboItem.setFont(appsMenu.getFont());
//
// // Add to menu (is either toplevel or category menu)
// menu.add(comboItem);
// }
//
// }
//--------------------------------------------------------------------------
public boolean wasCancelled()
{
return wasCancelled_;
}
//--------------------------------------------------------------------------
public String getCaseClass()
{
return caseClass_;
}
public void setCaseClass(String app)
{
// Update the application class combo box.
appCombo_.setSelectedItem(app);
}
//--------------------------------------------------------------------------
public String getCaseRoot()
{
return caseRoot_;
}
public void setCaseRoot(String root)
{
// Update the root combo box.
rootCombo_.setSelectedItem(root);
}
//--------------------------------------------------------------------------
public String getCaseName()
{
return caseNameTextField_.getText();
}
public void setCaseName(String name)
{
caseNameTextField_.setText(name);
}
//--------------------------------------------------------------------------
/** 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 FormEditor.
*/
private void initComponents() {//GEN-BEGIN:initComponents
mainPanel_ = new javax.swing.JPanel();
label1_ = new javax.swing.JLabel();
appCombo_ = new javax.swing.JComboBox();
label2_ = new javax.swing.JLabel();
rootCombo_ = new javax.swing.JComboBox();
label3_ = new javax.swing.JLabel();
caseNameTextField_ = new javax.swing.JTextField();
buttonPanel_ = new javax.swing.JPanel();
buttonOK_ = new javax.swing.JButton();
buttonCancel_ = new javax.swing.JButton();
getContentPane().setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints1;
setTitle("Create New Case");
setModal(true);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
closeDialog(evt);
}
});
mainPanel_.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints2;
mainPanel_.setPreferredSize(new java.awt.Dimension(350, 100));
label1_.setText("Class");
label1_.setForeground(java.awt.Color.black);
label1_.setFont(new java.awt.Font("Dialog", 0, 10));
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets(10, 10, 5, 5);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
mainPanel_.add(label1_, gridBagConstraints2);
appCombo_.setFont(new java.awt.Font("Dialog", 0, 10));
appCombo_.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
OnAppClassComboChanged(evt);
}
});
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 1;
gridBagConstraints2.gridy = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets(10, 5, 5, 10);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints2.weightx = 1.0;
mainPanel_.add(appCombo_, gridBagConstraints2);
label2_.setText("Case Root");
label2_.setForeground(java.awt.Color.black);
label2_.setFont(new java.awt.Font("Dialog", 0, 10));
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 1;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets(5, 10, 5, 5);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
mainPanel_.add(label2_, gridBagConstraints2);
rootCombo_.setFont(new java.awt.Font("Dialog", 0, 10));
rootCombo_.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
OnRootComboChanged(evt);
}
});
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 1;
gridBagConstraints2.gridy = 1;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets(5, 5, 5, 10);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints2.weightx = 1.0;
mainPanel_.add(rootCombo_, gridBagConstraints2);
label3_.setText("Case Name");
label3_.setForeground(java.awt.Color.black);
label3_.setFont(new java.awt.Font("Dialog", 0, 10));
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 2;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets(5, 10, 10, 5);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
mainPanel_.add(label3_, gridBagConstraints2);
caseNameTextField_.setFont(new java.awt.Font("Default", 0, 10));
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 1;
gridBagConstraints2.gridy = 2;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets(5, 5, 10, 10);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints2.weightx = 1.0;
mainPanel_.add(caseNameTextField_, gridBagConstraints2);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints1.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints1.weightx = 1.0;
gridBagConstraints1.weighty = 1.0;
getContentPane().add(mainPanel_, gridBagConstraints1);
buttonPanel_.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
buttonPanel_.setBorder(new javax.swing.border.EtchedBorder());
buttonOK_.setFont(new java.awt.Font("Dialog", 0, 10));
buttonOK_.setText("OK");
buttonOK_.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
OnOK(evt);
}
});
buttonPanel_.add(buttonOK_);
buttonCancel_.setFont(new java.awt.Font("Dialog", 0, 10));
buttonCancel_.setText("Cancel");
buttonCancel_.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
OnCancel(evt);
}
});
buttonPanel_.add(buttonCancel_);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 1;
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints1.anchor = java.awt.GridBagConstraints.SOUTH;
getContentPane().add(buttonPanel_, gridBagConstraints1);
pack();
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setSize(new java.awt.Dimension(400, 300));
setLocation((screenSize.width-400)/2,(screenSize.height-300)/2);
}//GEN-END:initComponents
//--------------------------------------------------------------------------
private void OnRootComboChanged (java.awt.event.ItemEvent evt)
{//GEN-FIRST:event_OnRootComboChanged
// Get the selected case root.
if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED)
{
caseRoot_ = (String)evt.getItem();
}
}//GEN-LAST:event_OnRootComboChanged
//--------------------------------------------------------------------------
private void OnAppClassComboChanged (java.awt.event.ItemEvent evt)
{//GEN-FIRST:event_OnAppClassComboChanged
// Get the selected application class.
if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED)
{
caseClass_ = (String)evt.getItem();
}
}//GEN-LAST:event_OnAppClassComboChanged
//--------------------------------------------------------------------------
private void OnCancel (java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_OnCancel
wasCancelled_ = true;
setVisible(false);
dispose();
}//GEN-LAST:event_OnCancel
//--------------------------------------------------------------------------
private void OnOK (java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_OnOK
//JTextField edit = (JTextField)rootCombo_.getEditor().getEditorComponent();
//edit.setText(caseRoot_);
// Only close if we have a case name entered.
if (getCaseName().trim().length()> 0)
{
wasCancelled_ = false;
setVisible(false);
dispose();
}
else
{
App.getRootFrame().getToolkit().getDefaultToolkit().beep();
}
}//GEN-LAST:event_OnOK
//--------------------------------------------------------------------------
/** Closes the dialog */
private void closeDialog(java.awt.event.WindowEvent evt)
{//GEN-FIRST:event_closeDialog
wasCancelled_ = true;
setVisible(false);
dispose();
}//GEN-LAST:event_closeDialog
//--------------------------------------------------------------------------
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel mainPanel_;
private javax.swing.JLabel label1_;
private javax.swing.JComboBox appCombo_;
private javax.swing.JLabel label2_;
private javax.swing.JComboBox rootCombo_;
private javax.swing.JLabel label3_;
private javax.swing.JTextField caseNameTextField_;
private javax.swing.JPanel buttonPanel_;
private javax.swing.JButton buttonOK_;
private javax.swing.JButton buttonCancel_;
// End of variables declaration//GEN-END:variables
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,180 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.CaseManagement;
import FoamX.App;
import FoamX.Exceptions.FoamXException;
import FoamX.CaseManagement.CaseBrowserPanel;
import FoamXServer.CaseBrowser.ICaseBrowser;
public class HostChooserDlg
extends javax.swing.JDialog
implements CaseSelectionListener
{
//--------------------------------------------------------------------------
protected CaseBrowserPanel caseBrowserPanel_;
protected String hostName_;
private static final int DEFAULT_WIDTH = 300;
private static final int DEFAULT_HEIGHT = 400;
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
/** HostChooserDlg constructor. */
public HostChooserDlg(java.awt.Frame parent)
{
super(parent, "Select Host", true);
try
{
// Get current caseBrowserModel from existing caseBrowserPanel
CaseManager caseManager = App.getCaseManager();
if (caseManager == null)
{
throw new FoamXException
(
"No caseManager in top-level App."
);
}
CaseBrowserModel model =
caseManager.getCaseBrowser().getModel();
// Open new caseBrowserPanel with existing model in
// case-selection mode.
caseBrowserPanel_ =
new CaseBrowserPanel(model, CaseBrowserPanel.SELECT_HOST_MODE);
initComponents();
// Get warned of any selection
caseBrowserPanel_.addCaseSelectionListener(this);
}
catch (FoamXException ex)
{
App.handleAllExceptions(ex);
}
}
/** GUI initialisation */
private void initComponents()
{
getContentPane().add(caseBrowserPanel_);
addWindowListener
(
new java.awt.event.WindowAdapter()
{
public void windowClosing(java.awt.event.WindowEvent evt)
{
closeDialog(evt);
}
}
);
caseBrowserPanel_.setPreferredSize
(
new java.awt.Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT)
);
pack();
java.awt.Dimension screenSize =
java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setLocation
(
(screenSize.width-getSize().width)/2,
(screenSize.height-getSize().height)/2
);
}
private void closeDialog(java.awt.event.WindowEvent evt)
{
clearSelection();
exitWindow();
}
private void clearSelection()
{
hostName_ = null;
}
private void exitWindow()
{
//caseBrowserPanel_.shutdown();
setVisible(false);
dispose();
}
//--------------------------------------------------------------------------
//---- public accessors
//--------------------------------------------------------------------------
/** get selected root */
public String getHostName()
{
return hostName_;
}
//--------------------------------------------------------------------------
//---- CaseSelectionListener Interface
//--------------------------------------------------------------------------
public void hostSelected(CaseSelectionEvent evt)
{
hostName_ = evt.hostName();
exitWindow();
}
public void rootSelected(CaseSelectionEvent evt)
{
}
public void caseSelected(CaseSelectionEvent evt)
{
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,46 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.CaseManagement;
import FoamXServer.*;
public interface IModule
extends java.beans.Visibility
{
public int getModuleID();
public String getModuleName();
public String getModuleDescription();
public boolean initialiseModule
(
IModuleHost moduleHost,
int moduleID
) throws Exception;
public boolean shutdownModule();
// Tell module not to do any actions (e.g. listen to file changes)
public boolean deactivate();
public boolean activate();
}

View File

@ -0,0 +1,66 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.CaseManagement;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.JFrame;
import FoamXServer.CaseServer.ICaseServer;
import FoamXServer.CaseBrowser.ICaseBrowser;
import FoamX.WindowManagement.FoamXInternalFrame;
public interface IModuleHost
{
// Miscellaneous methods.
public JFrame getRootFrame();
public ICaseServer getCaseServer();
public ICaseBrowser getCaseBrowser();
// Reporting methods.
public void printMessage(String message);
// Tree management methods.
public void setRootLabel(String label);
public String getRootLabel();
public int addNode(int parentNodeID, String nodeLabel, Icon icon);
public void removeNode(int nodeID);
// Add action as popup to treeNode
public void addNodeAction(int nodeID, Action action, String context);
// Retrieve stored action
public Action getAction(String actionName);
// Window management methods.
public int createWindow(javax.swing.JComponent component);
public FoamXInternalFrame getWindowFrame(int windowID);
public void closeWindow(int windowID);
public void showWindow(int windowID);
public void hideWindow(int windowID);
}

View File

@ -0,0 +1,199 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.CaseManagement;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
import FoamX.App;
import FoamX.Util.MenuItemActionChangedListener;
class TreeNodeInfo
implements FoamX.Util.FoamXTreeRenderer.FoamXTreeItem
{
//--------------------------------------------------------------------------
protected String nodeLabel_;
protected int nodeID_;
protected JPopupMenu popupMenu_;
protected Action defaultAction_;
protected String defaultContext_;
protected Icon icon_;
//--------------------------------------------------------------------------
/** ModuleTreeNode constructor. */
TreeNodeInfo(String nodeLabel, int nodeID, Icon icon)
{
nodeLabel_ = nodeLabel;
nodeID_ = nodeID;
popupMenu_ = null;
defaultAction_ = null;
icon_ = icon;
}
//--------------------------------------------------------------------------
public String toString()
{
return nodeLabel_;
}
String getNodeLabel()
{
return nodeLabel_;
}
void setNodeLabel(String label)
{
nodeLabel_ = label;
}
int getNodeID()
{
return nodeID_;
}
JPopupMenu getContextMenu()
{
return popupMenu_;
}
void setContextMenu(JPopupMenu contextMenu)
{
popupMenu_ = contextMenu;
}
//--------------------------------------------------------------------------
void addAction(Action action, String context)
{
try
{
// Create the popup menu if required.
if (popupMenu_ == null)
{
popupMenu_ = new JPopupMenu();
popupMenu_.setFont(new java.awt.Font("Dialog", 0, 10));
// First action is the default action.
defaultAction_ = action;
defaultContext_ = context;
}
// Add new menu item.
JMenuItem menuItem = popupMenu_.add(action);
menuItem.setFont(popupMenu_.getFont());
// Set action command and link up action listener object.
menuItem.setActionCommand(context);
action.addPropertyChangeListener
(
new MenuItemActionChangedListener(menuItem)
);
menuItem.setEnabled(action.isEnabled());
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
void clearActions()
{
popupMenu_ = null;
defaultAction_ = null;
defaultContext_ = null;
}
//
// //--------------------------------------------------------------------------
//
// Action getAction(String actionName)
// {
// if (popupMenu_ != null)
// {
// MenuElement[] menuElements = popupMenu_.getSubElements();
// for (int i = 0; i < menuElements.length; i++)
// {
// JMenuItem menuItem = menuElements[i].getComponent();
// }
// }
// }
//
//--------------------------------------------------------------------------
void invokeDefaultAction()
{
try
{
if (defaultAction_ != null)
{
ActionEvent evt = new ActionEvent
(
this,
nodeID_,
defaultContext_
);
defaultAction_.actionPerformed(evt);
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
void showPopupMenu(JComponent parent, int x, int y)
{
// Show the popup menu if we have one.
if (popupMenu_ != null)
{
popupMenu_.show(parent, x, y);
}
}
//--------------------------------------------------------------------------
//----- FoamXTreeRenderer.FoamXTreeItem Interface
//--------------------------------------------------------------------------
public String getText()
{
return nodeLabel_;
}
public Icon getIcon()
{
return icon_;
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE attributes PUBLIC "-//NetBeans//DTD DefaultAttributes 1.0//EN" "http://www.netbeans.org/dtds/attributes-1_0.dtd">
<attributes version="1.0">
<fileobject name="CompoundEditor.java">
<attr name="class_dependency_javax.swing.JDialog" stringvalue="CompoundEditor"/>
</fileobject>
<fileobject name="SelectionEditor.java">
<attr name="class_dependency_javax.swing.JDialog" stringvalue="SelectionEditor"/>
</fileobject>
<fileobject name="DimensionSetEditor.java">
<attr name="class_dependency_javax.swing.JDialog" stringvalue="DimensionSetEditor"/>
</fileobject>
<fileobject name="ListEditor.java">
<attr name="class_dependency_javax.swing.AbstractAction" stringvalue="ListEditor.AddElementAction;ListEditor.DeleteElementAction"/>
<attr name="class_dependency_javax.swing.JDialog" stringvalue="ListEditor"/>
</fileobject>
<fileobject name="StringListEditor.java">
<attr name="NetBeansAttrDataObjectCompilerManager" serialvalue="aced00057372001e6f72672e6f70656e6964652e53657276696365547970652448616e646c6564612acc871b81080300024c0009636c6173734e616d657400124c6a6176612f6c616e672f537472696e673b4c00046e616d6571007e00017870740015466173744a6176616320436f6d70696c6174696f6e74002f6f72672e6e65746265616e732e6d6f64756c65732e6a6176612e466173744a61766163436f6d70696c65725479706578"/>
<attr name="class_dependency_javax.swing.AbstractAction" stringvalue="StringListEditor.AddElementAction;StringListEditor.DeleteElementAction"/>
<attr name="class_dependency_javax.swing.JDialog" stringvalue="StringListEditor"/>
<attr name="class_dependency_javax.swing.table.AbstractTableModel" stringvalue="StringListEditor.ListEntryModel"/>
</fileobject>
<fileobject name="ChoiceEditor.java">
<attr name="class_dependency_javax.swing.JDialog" stringvalue="ChoiceEditor;CompoundEditor"/>
<attr name="class_dependency_FoamX.Editors.DictionaryEntryEditor.DictionaryEntryTableModel" stringvalue="CompoundEditor.CompoundEntryModel"/>
</fileobject>
<fileobject name="VectorSpaceEditor.java">
<attr name="class_dependency_javax.swing.JDialog" stringvalue="VectorSpaceEditor"/>
</fileobject>
</attributes>

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE attributes PUBLIC "-//NetBeans//DTD DefaultAttributes 1.0//EN" "http://www.netbeans.org/dtds/attributes-1_0.dtd">
<attributes version="1.0">
<fileobject name="ApplicationDetailsTab.java">
<attr name="class_dependency_javax.swing.JPanel" stringvalue="ApplicationDetailsTab"/>
</fileobject>
<fileobject name="FieldModelListener.java">
<attr name="EA-OpenIDE-Connection" serialvalue="aced0005737200146a6176612e7574696c2e4c696e6b65644c6973740c29535d4a608822030000787077040000000078"/>
</fileobject>
<fileobject name="BoundaryTypesTab.java">
<attr name="class_dependency_javax.swing.JPanel" stringvalue="BoundaryTypesTab"/>
<attr name="class_dependency_javax.swing.AbstractAction" stringvalue="BoundaryTypesTab.DeleteBoundaryTypeAction;BoundaryTypesTab.AddBoundaryTypeAction"/>
</fileobject>
<fileobject name="BoundaryDefinitionPanel.java">
<attr name="class_dependency_javax.swing.JPanel" stringvalue="BoundaryDefinitionPanel"/>
</fileobject>
<fileobject name="ApplicationClassExeption.java">
<attr name="template" serialvalue="aced0005737200266f72672e6f70656e6964652e7574696c2e696f2e4e624d61727368616c6c65644f626a6563746cd5cc1aa397c0f2020002490004686173685b00086f626a42797465737400025b4278700000001170"/>
</fileobject>
<fileobject name="ApplicationClassEditorDlg.java">
<attr name="class_dependency_javax.swing.JDialog" stringvalue="ApplicationClassEditorDlg"/>
</fileobject>
<fileobject name="BoundaryDefinitionModel.java">
<attr name="class_dependency_FoamX.Editors.ApplicationClassEditor.FieldModelListener" stringvalue="BoundaryDefinitionModel"/>
<attr name="class_dependency_javax.swing.table.AbstractTableModel" stringvalue="BoundaryDefinitionModel"/>
</fileobject>
<fileobject name="FieldsTab.java">
<attr name="class_dependency_javax.swing.JPanel" stringvalue="FieldsTab"/>
<attr name="class_dependency_javax.swing.AbstractAction" stringvalue="FieldsTab.DeleteFieldAction;FieldsTab.AddFieldAction"/>
</fileobject>
<fileobject name="ModulesTab.java">
<attr name="class_dependency_javax.swing.JPanel" stringvalue="ModulesTab"/>
</fileobject>
<fileobject name="BrowseApplicationClassesDlg.java">
<attr name="class_dependency_FoamX.Util.FoamXListRenderer.FoamXListItem" stringvalue="BrowseApplicationClassesDlg.AppClassListItem"/>
<attr name="class_dependency_javax.swing.JDialog" stringvalue="BrowseApplicationClassesDlg"/>
</fileobject>
</attributes>

View File

@ -0,0 +1,209 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<SyntheticProperties>
</SyntheticProperties>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="subPanel_">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="1" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="10" insetsLeft="10" insetsRight="10" insetsTop="10" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Component class="javax.swing.JLabel" name="classNameLabel_">
<Properties>
<Property name="text" type="java.lang.String" value="Application Class Name"/>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" id="black" palette="0" red="0" type="palette"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JTextField" name="appClassNameEdit_">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="SansSerif" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="appClassModel_.getAppClassName()" type="code"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="2" gridHeight="1" gridWidth="1" gridX="1" gridY="0" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JLabel" name="appDescriptionLabel_">
<Properties>
<Property name="text" type="java.lang.String" value="Description"/>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" id="black" palette="0" red="0" type="palette"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="1" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JTextField" name="appDescriptionEdit_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="SansSerif" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="appClassModel_.getAppDescription()" type="code"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="2" gridHeight="1" gridWidth="1" gridX="1" gridY="1" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JLabel" name="appNameLabel_">
<Properties>
<Property name="text" type="java.lang.String" value="Executable Name"/>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" id="black" palette="0" red="0" type="palette"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="2" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JTextField" name="appNameEdit_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="SansSerif" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="appClassModel_.getAppExeName()" type="code"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="2" gridHeight="1" gridWidth="1" gridX="1" gridY="2" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JLabel" name="argumentListLabel_">
<Properties>
<Property name="verticalAlignment" type="int" value="1"/>
<Property name="text" type="java.lang.String" value="Application Arguments"/>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" id="black" palette="0" red="0" type="palette"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="3" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Container class="javax.swing.JPanel" name="argPanel_">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="1" gridHeight="1" gridWidth="1" gridX="1" gridY="3" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="argListScroll_">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="1" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="0" insetsLeft="0" insetsRight="0" insetsTop="0" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JList" name="argumentList_">
<Properties>
<Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="listModel_" type="code"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="argButtonPanel_">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="0" gridHeight="1" gridWidth="1" gridX="1" gridY="0" insetsBottom="0" insetsLeft="10" insetsRight="0" insetsTop="0" ipadX="0" ipadY="0" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Component class="javax.swing.JButton" name="addButton_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="Add"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="addButtonActionPerformed_"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="5" insetsLeft="0" insetsRight="0" insetsTop="0" ipadX="0" ipadY="0" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JButton" name="removeButton_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="Remove"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="removeButtonActionPerformed_"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="1" insetsBottom="0" insetsLeft="0" insetsRight="0" insetsTop="5" ipadX="0" ipadY="0" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@ -0,0 +1,329 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.ApplicationEditor;
import java.util.Vector;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
public class ApplicationDetailsTab
extends javax.swing.JPanel
{
//--------------------------------------------------------------------------
private ApplicationModel appModel_;
private DefaultListModel listModel_;
//--------------------------------------------------------------------------
/** Creates a new AppClassPanel form. */
public ApplicationDetailsTab(ApplicationModel appModel)
{
appModel_ = appModel;
listModel_ = new DefaultListModel();
// Initialise the gui.
initComponents();
// Initialise the argument list.
Vector argVec = appModel_.getAppParameters();
for (int i=0; i <argVec.size(); i++)
{
listModel_.addElement(argVec.get(i));
}
// Don't allow the application class name to be edited.
appNameEdit_.setEditable(false);
}
//--------------------------------------------------------------------------
/** Updates the application class model object. */
public void updateModel()
{
// Update the application name and description.
appModel_.setAppClassName(appNameEdit_.getText());
appModel_.setAppDescription(appDescriptionEdit_.getText());
appModel_.setAppExeName(appNameEdit_.getText());
// Update the application arguments vector.
Vector argVec = appModel_.getAppParameters();
argVec.clear();
for (int i=0; i <listModel_.getSize(); i++)
{
argVec.add(i, (String)listModel_.getElementAt(i));
}
}
//--------------------------------------------------------------------------
/** 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 FormEditor.
*/
private void initComponents() {//GEN-BEGIN:initComponents
subPanel_ = new javax.swing.JPanel();
classNameLabel_ = new javax.swing.JLabel();
appNameEdit_ = new javax.swing.JTextField();
appDescriptionLabel_ = new javax.swing.JLabel();
appDescriptionEdit_ = new javax.swing.JTextField();
appNameLabel_ = new javax.swing.JLabel();
appNameEdit_ = new javax.swing.JTextField();
argumentListLabel_ = new javax.swing.JLabel();
argPanel_ = new javax.swing.JPanel();
argListScroll_ = new javax.swing.JScrollPane();
argumentList_ = new javax.swing.JList();
argButtonPanel_ = new javax.swing.JPanel();
addButton_ = new javax.swing.JButton();
removeButton_ = new javax.swing.JButton();
setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints1;
subPanel_.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints2;
classNameLabel_.setText("Application Class Name");
classNameLabel_.setForeground(java.awt.Color.black);
classNameLabel_.setFont(new java.awt.Font("Dialog", 0, 10));
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTH;
subPanel_.add(classNameLabel_, gridBagConstraints2);
appNameEdit_.setEditable(false);
appNameEdit_.setFont(new java.awt.Font("SansSerif", 0, 10));
appNameEdit_.setText(appModel_.getAppClassName());
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 1;
gridBagConstraints2.gridy = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints2.weightx = 1.0;
subPanel_.add(appNameEdit_, gridBagConstraints2);
appDescriptionLabel_.setText("Description");
appDescriptionLabel_.setForeground(java.awt.Color.black);
appDescriptionLabel_.setFont(new java.awt.Font("Dialog", 0, 10));
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 1;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTH;
subPanel_.add(appDescriptionLabel_, gridBagConstraints2);
appDescriptionEdit_.setFont(new java.awt.Font("SansSerif", 0, 10));
appDescriptionEdit_.setText(appModel_.getAppDescription());
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 1;
gridBagConstraints2.gridy = 1;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints2.weightx = 1.0;
subPanel_.add(appDescriptionEdit_, gridBagConstraints2);
appNameLabel_.setText("Executable Name");
appNameLabel_.setForeground(java.awt.Color.black);
appNameLabel_.setFont(new java.awt.Font("Dialog", 0, 10));
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 2;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTH;
subPanel_.add(appNameLabel_, gridBagConstraints2);
appNameEdit_.setFont(new java.awt.Font("SansSerif", 0, 10));
appNameEdit_.setText(appModel_.getAppExeName());
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 1;
gridBagConstraints2.gridy = 2;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints2.weightx = 1.0;
subPanel_.add(appNameEdit_, gridBagConstraints2);
argumentListLabel_.setVerticalAlignment(javax.swing.SwingConstants.TOP);
argumentListLabel_.setText("Application Arguments");
argumentListLabel_.setForeground(java.awt.Color.black);
argumentListLabel_.setFont(new java.awt.Font("Dialog", 0, 10));
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 3;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTH;
subPanel_.add(argumentListLabel_, gridBagConstraints2);
argPanel_.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints3;
argumentList_.setModel(listModel_);
argumentList_.setFont(new java.awt.Font("Dialog", 0, 10));
argListScroll_.setViewportView(argumentList_);
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 0;
gridBagConstraints3.gridy = 0;
gridBagConstraints3.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints3.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints3.weightx = 1.0;
gridBagConstraints3.weighty = 1.0;
argPanel_.add(argListScroll_, gridBagConstraints3);
argButtonPanel_.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints4;
addButton_.setFont(new java.awt.Font("Dialog", 0, 10));
addButton_.setText("Add");
addButton_.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
addButtonActionPerformed_(evt);
}
});
gridBagConstraints4 = new java.awt.GridBagConstraints();
gridBagConstraints4.gridx = 0;
gridBagConstraints4.gridy = 0;
gridBagConstraints4.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints4.insets = new java.awt.Insets(0, 0, 5, 0);
gridBagConstraints4.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints4.weightx = 1.0;
argButtonPanel_.add(addButton_, gridBagConstraints4);
removeButton_.setFont(new java.awt.Font("Dialog", 0, 10));
removeButton_.setText("Remove");
removeButton_.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
removeButtonActionPerformed_(evt);
}
});
gridBagConstraints4 = new java.awt.GridBagConstraints();
gridBagConstraints4.gridx = 0;
gridBagConstraints4.gridy = 1;
gridBagConstraints4.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints4.insets = new java.awt.Insets(5, 0, 0, 0);
gridBagConstraints4.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints4.weightx = 1.0;
argButtonPanel_.add(removeButton_, gridBagConstraints4);
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 1;
gridBagConstraints3.gridy = 0;
gridBagConstraints3.insets = new java.awt.Insets(0, 10, 0, 0);
gridBagConstraints3.anchor = java.awt.GridBagConstraints.NORTH;
argPanel_.add(argButtonPanel_, gridBagConstraints3);
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 1;
gridBagConstraints2.gridy = 3;
gridBagConstraints2.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints2.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints2.weightx = 1.0;
gridBagConstraints2.weighty = 1.0;
subPanel_.add(argPanel_, gridBagConstraints2);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints1.insets = new java.awt.Insets(10, 10, 10, 10);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints1.weightx = 1.0;
gridBagConstraints1.weighty = 1.0;
add(subPanel_, gridBagConstraints1);
}//GEN-END:initComponents
//--------------------------------------------------------------------------
private void removeButtonActionPerformed_ (java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_removeButtonActionPerformed_
// Remove the selected application arguments.
if (!argumentList_.getSelectionModel().isSelectionEmpty())
{
int minIndex = argumentList_.getSelectionModel().getMinSelectionIndex();
int maxIndex = argumentList_.getSelectionModel().getMaxSelectionIndex();
// Need to remove from the top so that it doesn't get its knickers in a twist.
for (int i=maxIndex; i>= minIndex; i--)
{
listModel_.removeElementAt(i);
}
}
}//GEN-LAST:event_removeButtonActionPerformed_
//--------------------------------------------------------------------------
private void addButtonActionPerformed_ (java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_addButtonActionPerformed_
// Add a new program argument.
String arg = (String)JOptionPane.showInputDialog(this,
"Enter Application Argument",
"FoamX...",
JOptionPane.PLAIN_MESSAGE, null, null, null);
if (arg != null && arg.trim().length()> 0)
{
listModel_.addElement(arg);
}
}//GEN-LAST:event_addButtonActionPerformed_
//--------------------------------------------------------------------------
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel subPanel_;
private javax.swing.JLabel classNameLabel_;
private javax.swing.JTextField appNameEdit_;
private javax.swing.JLabel appDescriptionLabel_;
private javax.swing.JTextField appDescriptionEdit_;
private javax.swing.JLabel appNameLabel_;
private javax.swing.JTextField appNameEdit_;
private javax.swing.JLabel argumentListLabel_;
private javax.swing.JPanel argPanel_;
private javax.swing.JScrollPane argListScroll_;
private javax.swing.JList argumentList_;
private javax.swing.JPanel argButtonPanel_;
private javax.swing.JButton addButton_;
private javax.swing.JButton removeButton_;
// End of variables declaration//GEN-END:variables
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.0" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="title" type="java.lang.String" value="Application Class Editor"/>
<Property name="defaultCloseOperation" type="int" value="0"/>
<Property name="name" type="java.lang.String" value=""/>
<Property name="modal" type="boolean" value="true"/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="menuBar" type="java.lang.String" value="(No Menu)"/>
<SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-62,0,0,2,-118"/>
<SyntheticProperty name="formPosition" type="java.awt.Point" value="-84,-19,0,5,115,114,0,14,106,97,118,97,46,97,119,116,46,80,111,105,110,116,-74,-60,-118,114,52,126,-56,38,2,0,2,73,0,1,120,73,0,1,121,120,112,0,0,0,0,0,0,0,0"/>
<SyntheticProperty name="formSizePolicy" type="int" value="0"/>
<SyntheticProperty name="generatePosition" type="boolean" value="true"/>
<SyntheticProperty name="generateSize" type="boolean" value="true"/>
<SyntheticProperty name="generateCenter" type="boolean" value="true"/>
</SyntheticProperties>
<Events>
<EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="OnWindowClosing"/>
</Events>
<AuxValues>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Container class="javax.swing.JTabbedPane" name="tabbedPane">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="autoscrolls" type="boolean" value="true"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="1" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="0" insetsLeft="0" insetsRight="0" insetsTop="0" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
</Container>
<Container class="javax.swing.JPanel" name="buttonPanel">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder bevelType="0"/>
</Border>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="15" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="1" insetsBottom="0" insetsLeft="0" insetsRight="0" insetsTop="0" ipadX="0" ipadY="0" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
<Property name="alignment" type="int" value="2"/>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="closeButton_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="label" type="java.lang.String" value="Close"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="OnClose"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@ -0,0 +1,300 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.ApplicationEditor;
import java.awt.*;
import java.util.Hashtable;
import javax.swing.*;
import javax.swing.table.*;
import FoamX.App;
import FoamX.Editors.TypeEditor.TypeEditorPanel;
import FoamX.Exceptions.FoamXException;
import FoamX.Util.BusyCursor;
import FoamXServer.CaseServer.IFoamProperties;
public class ApplicationEditorDlg
extends javax.swing.JDialog
{
//--------------------------------------------------------------------------
private ApplicationModel appModel_;
private Hashtable tabMap_;
private ApplicationDetailsTab appDetailsTab_;
private FieldsTab fieldsTab_;
private TypeEditorPanel dictionariesTab_;
private PatchPhysicalTypesTab patchPhysicalTypesTab_;
private ModulesTab modulesTab_;
private boolean cancelled_;
private boolean readOnly_;
//--------------------------------------------------------------------------
/** Creates a new ApplicationEditor dialog based on the specified application class object. */
public ApplicationEditorDlg(IFoamProperties foamSys, String appName, boolean readOnly) throws FoamXException
{
super(new javax.swing.JFrame(), true); // Modal.
try
{
// Set readonly flag.
readOnly_ = readOnly;
App.printMessage("Constructing Model...");
// Create application class model.
appModel_ = new ApplicationModel(foamSys);
App.printMessage("Loading Model...");
// Initialise the model object from the application class object.
appModel_.loadApplication(appName);
// Create tabs.
App.printMessage("Constructing App Details Tab...");
appDetailsTab_ = new ApplicationDetailsTab(appModel_);
App.printMessage("Constructing Field Tab...");
fieldsTab_ = new FieldsTab(appModel_);
App.printMessage("Constructing Boundary Types Tab...");
patchPhysicalTypesTab_ = new PatchPhysicalTypesTab(appModel_);
App.printMessage("Constructing Type Editor Tab...");
dictionariesTab_ = new TypeEditorPanel(appModel_.getAppClassDescriptor());
App.printMessage("Constructing Modules Tab...");
modulesTab_ = new ModulesTab(appModel_);
// Initialise components and add tabs.
initComponents();
tabbedPane.addTab("General", appDetailsTab_);
tabbedPane.addTab("Fields", fieldsTab_);
tabbedPane.addTab("Boundary Types", patchPhysicalTypesTab_);
tabbedPane.addTab("Dictionaries", dictionariesTab_);
tabbedPane.addTab("Modules", modulesTab_);
// Initialise tab map.
tabMap_ = new Hashtable(5);
tabMap_.put("General", appDetailsTab_);
tabMap_.put("Fields", fieldsTab_);
tabMap_.put("Boundary Types", patchPhysicalTypesTab_);
tabMap_.put("Dictionaries", dictionariesTab_);
tabMap_.put("Modules", modulesTab_);
cancelled_ = true;
App.printMessage("Fin...");
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
throw new FoamXException("Failed to construct ApplicationEditorDlg for class " + appName);
}
}
//--------------------------------------------------------------------------
public boolean wasCancelled()
{
return cancelled_;
}
//--------------------------------------------------------------------------
/** 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 FormEditor.
*/
private void initComponents()//GEN-BEGIN:initComponents
{
tabbedPane = new javax.swing.JTabbedPane();
buttonPanel = new javax.swing.JPanel();
closeButton_ = new javax.swing.JButton();
getContentPane().setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints1;
setTitle("Application Class Editor");
setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
setName("");
setModal(true);
setFont(new java.awt.Font("Dialog", 0, 10));
addWindowListener(new java.awt.event.WindowAdapter()
{
public void windowClosing(java.awt.event.WindowEvent evt)
{
OnWindowClosing(evt);
}
});
tabbedPane.setFont(new java.awt.Font("Dialog", 0, 10));
tabbedPane.setAutoscrolls(true);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints1.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints1.weightx = 1.0;
gridBagConstraints1.weighty = 1.0;
getContentPane().add(tabbedPane, gridBagConstraints1);
buttonPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
buttonPanel.setBorder(new javax.swing.border.EtchedBorder(javax.swing.border.EtchedBorder.RAISED));
closeButton_.setFont(new java.awt.Font("Dialog", 0, 10));
closeButton_.setLabel("Close");
closeButton_.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
OnClose(evt);
}
});
buttonPanel.add(closeButton_);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 1;
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints1.anchor = java.awt.GridBagConstraints.SOUTH;
getContentPane().add(buttonPanel, gridBagConstraints1);
pack();
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setSize(new java.awt.Dimension(650, 450));
setLocation((screenSize.width-650)/2,(screenSize.height-450)/2);
}//GEN-END:initComponents
//--------------------------------------------------------------------------
private void OnClose(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_OnClose
closeWindow();
}//GEN-LAST:event_OnClose
//--------------------------------------------------------------------------
/** Event handler for window closing event. */
private void OnWindowClosing (java.awt.event.WindowEvent evt)
{//GEN-FIRST:event_OnWindowClosing
closeWindow();
}//GEN-LAST:event_OnWindowClosing
//--------------------------------------------------------------------------
private void closeWindow()
{
try
{
if (!readOnly_)
{
int ret = JOptionPane.showConfirmDialog(this,
"Save changes to application class data?",
"FoamX...",
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE);
if (ret == JOptionPane.YES_OPTION)
{
if (!checkAndSaveData()) return;
}
else if (ret == JOptionPane.CANCEL_OPTION)
{
return;
}
}
setVisible(false);
dispose();
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
private boolean checkAndSaveData()
{
// Show busy cursor.
BusyCursor cursor = new BusyCursor(this);
// Get each tab to update the model.
appDetailsTab_.updateModel();
fieldsTab_.updateModel();
dictionariesTab_.updateModel();
patchPhysicalTypesTab_.updateModel();
modulesTab_.updateModel();
// Validate the model and see if it's happy.
try
{
appModel_.validate();
}
catch (ApplicationExeption ex)
{
JOptionPane.showMessageDialog(this,
"Error : " + ex.getMessage(),
"FoamX...",
JOptionPane.ERROR_MESSAGE);
// Select offending tab.
String tabName = ex.getTabName();
if (tabMap_.containsKey(tabName))
{
Component tab = (Component)tabMap_.get(tabName);
tabbedPane.setSelectedComponent(tab);
}
return false;
}
// Get model to serialise itself.
appModel_.saveApplication();
// Indicate that we have committed the data.
cancelled_ = false;
return true;
}
//--------------------------------------------------------------------------
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTabbedPane tabbedPane;
private javax.swing.JPanel buttonPanel;
private javax.swing.JButton closeButton_;
// End of variables declaration//GEN-END:variables
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,50 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.ApplicationEditor;
public class ApplicationExeption
extends java.lang.Exception
{
private String tabName_;
/**
* Constructs an <code>ApplicationExeption</code> with the specified detail message.
* @param msg the detail message.
*/
public ApplicationExeption(String tabName, String message)
{
super(message);
tabName_ = tabName;
}
public String getTabName()
{
return tabName_;
}
}

View File

@ -0,0 +1,415 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.ApplicationEditor;
import java.util.Vector;
import java.util.Hashtable;
import FoamX.App;
import FoamX.FoamXException.*;
import FoamXServer.CaseServer.IApplication;
import FoamXServer.CaseServer.IApplicationHolder;
import FoamXServer.CaseServer.IFoamProperties;
import FoamXServer.CaseServer.IGeometryDescriptor;
import FoamXServer.CaseServer.IGeometryDescriptorHolder;
import FoamXServer.CaseServer.IPatchDescriptor;
import FoamXServer.CaseServer.IPatchDescriptorHolder;
import FoamXServer.FoamXError;
import FoamXServer.FoamXIOError;
import FoamXServer.ITypeDescriptor;
import FoamXServer.ITypeDescriptorHolder;
import FoamXServer.ValidationError;
class ApplicationModel
{
//--------------------------------------------------------------------------
private IFoamProperties foamSys_;
private IApplication app_;
private boolean modified_;
// Simple application class properties.
private String appName_;
private String appDescription_;
private String appExeName_;
private Vector appParameters_;
private Vector appModules_;
private FieldDefinitionModel fieldModel_;
private BoundaryDefinitionModel boundaryModel_;
// Field, Geometry, Patch and PatchField type information,
private Hashtable fieldTypeMap_; // Map of ITypeDescriptor objects.
private Hashtable geometryTypeMap_; // Map of IGeometryDescriptor objects.
private Hashtable patchTypeMap_; // Map of IPatchDescriptor objects.
private Hashtable patchFieldTypeMap_; // Map of ITypeDescriptor objects.
// Simple lists of global FoamX type names.
private String[] availableModules_; // Available FoamX modules.
private String[] foamTypes_; // Field type names.
private String[] geometryTypes_; // Geometry type names.
private String[] patchTypes_; // Defined patch types.
private String[] patchFieldTypes_; // Defined patch field types.
//--------------------------------------------------------------------------
ApplicationModel(IFoamProperties foamSys)
{
try
{
// Extract FoamX global data.
foamSys_ = foamSys;
// Initialise available module list.
availableModules_ = foamSys_.availableModules();
// Initialise patch types - wall, patch, symmetry, etc.
patchTypeMap_ = new java.util.Hashtable();
patchTypes_ = foamSys_.patchTypes();
for (int i = 0; i <patchTypes_.length; i++)
{
// Get descriptor for this patch type.
IPatchDescriptorHolder holder = new IPatchDescriptorHolder();
foamSys_.getPatchType(patchTypes_[i], holder);
patchTypeMap_.put(patchTypes_[i], holder.value);
}
// Initialise patch field types - zeroGradient, fixedValue, etc.
patchFieldTypeMap_ = new java.util.Hashtable();
patchFieldTypes_ = foamSys_.patchFieldTypes();
for (int i = 0; i <patchFieldTypes_.length; i++)
{
// Get descriptor for this patch field type.
ITypeDescriptorHolder holder = new ITypeDescriptorHolder();
foamSys_.getPatchFieldType(patchFieldTypes_[i], holder);
patchFieldTypeMap_.put(patchFieldTypes_[i], holder.value);
}
// Field Types - Construct a map between the true type name and the display name.
fieldTypeMap_ = new java.util.Hashtable();
foamTypes_ = foamSys_.foamTypes();
for (int i = 0; i <foamTypes_.length; i++)
{
// Get descriptor for this field type.
ITypeDescriptorHolder holder = new ITypeDescriptorHolder();
foamSys_.getFoamType(foamTypes_[i], holder);
fieldTypeMap_.put(foamTypes_[i], holder.value);
}
// Geometry Types - Construct a map between the true geometry type name and the display name.
geometryTypeMap_ = new java.util.Hashtable();
geometryTypes_ = foamSys_.geometryTypes();
for (int i = 0; i <geometryTypes_.length; i++)
{
// Get descriptor for this geometry type.
IGeometryDescriptorHolder holder = new IGeometryDescriptorHolder();
foamSys_.getGeometryType(geometryTypes_[i], holder);
geometryTypeMap_.put(geometryTypes_[i], holder.value);
}
// Reset modified flag.
modified_ = false;
}
catch (FoamXIOError ioErr)
{
App.handleException(ioErr);
}
catch (FoamXError fxErr)
{
App.handleException(fxErr);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
void loadApplication(String appName)
{
try
{
// Open the specified application class object.
IApplicationHolder appHolder = new IApplicationHolder();
foamSys_.getApplication(appName, appHolder);
// Store reference to app class object.
app_ = appHolder.value;
// Extract application class details.
// Use specified name rather than the one defined (Overrides cloned application class name).
appName_ = appName;
appDescription_ = app_.description();
appExeName_ = app_.executableName();
// Initialise the parameter list.
String[] params = app_.parameters();
appParameters_ = new Vector(params.length);
for (int i = 0; i <params.length; i++)
{
appParameters_.add(params[i]);
}
// Initialise the modules list.
String[] modules = app_.modules();
appModules_ = new Vector(modules.length);
for (int i = 0; i <modules.length; i++)
{
appModules_.add(modules[i]);
}
// Create and initialise the field model.
fieldModel_ = new FieldDefinitionModel(this);
// Create and initialise the boundary definition model.
boundaryModel_ = new BoundaryDefinitionModel(this);
// Reset modified flag.
modified_ = false;
}
catch (FoamXIOError ioErr)
{
App.handleException(ioErr);
}
catch (FoamXError fxErr)
{
App.handleException(fxErr);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
void saveApplication()
{
try
{
// Make sure we have an application class object to save to.
if (app_ == null)
{
throw new FoamXException("Invalid application class in ApplicationModel::saveApplication.");
}
// Update the application class details.
app_.name(appName_);
app_.description(appDescription_);
app_.executableName(appExeName_);
// Update the parameter list.
String[] params = new String[appParameters_.size()];
appParameters_.copyInto(params);
app_.parameters(params);
// Update the modules list.
String[] modules = new String[appModules_.size()];
appModules_.copyInto(modules);
app_.modules(modules);
// Update the field information.
fieldModel_.updateApplication(app_);
// Update the boundary types.
boundaryModel_.updateApplication(app_);
// Finally, save the application class details to file.
app_.save();
}
catch (FoamXIOError ioErr)
{
App.handleException(ioErr);
}
catch (FoamXError fxErr)
{
App.handleException(fxErr);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
public void validate() throws ApplicationExeption
{
// Validate the general properties.
if (appName_.length() == 0) throw new ApplicationExeption("General", "Invalid application class name.");
if (appDescription_.length() == 0) throw new ApplicationExeption("General", "Invalid application class description.");
if (appExeName_.length() == 0) throw new ApplicationExeption("General", "Invalid application class executable name.");
// Validate the field definition model.
fieldModel_.validate();
// Validate the boundary definition model.
boundaryModel_.validate();
// Validate the dictionary type descriptors.
try
{
app_.validate();
}
catch (ValidationError vErr)
{
throw new ApplicationExeption
(
"Dictionaries",
vErr.errorMessage
);
}
catch (FoamXError fxErr)
{
throw new ApplicationExeption
(
"Dictionaries",
fxErr.errorMessage
);
}
catch (FoamXIOError ioErr)
{
throw new ApplicationExeption
(
"Dictionaries",
ioErr.errorMessage
);
}
}
//--------------------------------------------------------------------------
boolean isModified()
{
return modified_;
}
//--------------------------------------------------------------------------
IApplication getAppClassDescriptor()
{
return app_;
}
String getAppClassName()
{
return appName_;
}
void setAppClassName(String name)
{
appName_ = name.trim();
}
String getAppDescription()
{
return appDescription_;
}
void setAppDescription(String desc)
{
appDescription_ = desc.trim();
}
String getAppExeName()
{
return appExeName_;
}
void setAppExeName(String name)
{
appExeName_ = name.trim();
}
Vector getAppParameters()
{
return appParameters_;
}
Vector getAppModules()
{
return appModules_;
}
FieldDefinitionModel getFieldDefinitionModel()
{
return fieldModel_;
}
BoundaryDefinitionModel getBoundaryDefinitionModel()
{
return boundaryModel_;
}
String[] getAvailableModules()
{
return availableModules_;
}
String[] getFoamTypes()
{
return foamTypes_;
}
String[] getGeometryTypes()
{
return geometryTypes_;
}
String[] getPatchTypes()
{
return patchTypes_;
}
String[] getPatchFieldTypes()
{
return patchFieldTypes_;
}
//--------------------------------------------------------------------------
ITypeDescriptor getFoamType(String fieldTypeName)
{
return (ITypeDescriptor)fieldTypeMap_.get(fieldTypeName);
}
IGeometryDescriptor getGeometryType(String geometryTypeName)
{
return (IGeometryDescriptor)geometryTypeMap_.get(geometryTypeName);
}
IPatchDescriptor getPatchType(String patchTypeName)
{
return (IPatchDescriptor)patchTypeMap_.get(patchTypeName);
}
ITypeDescriptor getPatchFieldType(String patchFieldTypeName)
{
return (ITypeDescriptor)patchFieldTypeMap_.get(patchFieldTypeName);
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,546 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.ApplicationEditor;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import javax.swing.tree.*;
import java.util.Hashtable;
import java.util.Vector;
import java.util.Enumeration;
import java.lang.ref.WeakReference;
import org.omg.CORBA.StringHolder;
import FoamX.App;
import FoamX.Exceptions.FoamXException;
import FoamXServer.CaseServer.IApplication;
import FoamXServer.CaseServer.IPatchPhysicalTypeDescriptor;
import FoamXServer.CaseServer.IPatchPhysicalTypeDescriptorHolder;
import FoamXServer.CaseServer.IPatchDescriptor;
//import FoamXServer.CaseServer.IPatchFieldDescriptor;
class BoundaryDefinitionModel
extends AbstractTableModel
implements FieldModelListener
{
//--------------------------------------------------------------------------
// Table constants.
public static final int FIELD_NAME_INDEX = 0;
public static final int PATCH_FIELD_TYPE_INDEX = 1;
public static final String FIELD_NAME_COLUMN = "Field";
public static final String PATCH_FIELD_TYPE_COLUMN = "Patch Field Type";
protected static final String[] ColumnNames = {
FIELD_NAME_COLUMN, PATCH_FIELD_TYPE_COLUMN };
private WeakReference appModel_; // Weak reference to the application class model object.
private java.util.Hashtable patchNodeMap_; // Map of tree node objects for each defined patch type.
private java.util.Hashtable boundaryDefMap_; // Map of BoundaryDefinitionModelItem objects.
private BoundaryDefinitionModelItem currentboundaryDef_; // Current BoundaryDefinitionModelItem object.
private DefaultTreeModel treeModel_; // Tree model to support rendering of this model via a tree control.
private DefaultMutableTreeNode rootNode_; // Tree root node.
private java.util.Hashtable patchFieldTypeNameMap_; // Map between patch true and display type names.
//--------------------------------------------------------------------------
BoundaryDefinitionModel(ApplicationModel appModel)
{
try
{
appModel_ = new java.lang.ref.WeakReference(appModel);
patchNodeMap_ = new Hashtable();
boundaryDefMap_ = new Hashtable();
currentboundaryDef_ = null;
patchFieldTypeNameMap_ = new Hashtable();
// Initialise the tree model.
rootNode_ = new DefaultMutableTreeNode(new BoundaryDefinitionModelItem(), true);
treeModel_ = new DefaultTreeModel(rootNode_);
// Initialise the patch field type name map.
String[] patchFieldTypes = getAppClassModel().getPatchFieldTypes();
for (int i = 0; i <patchFieldTypes.length; i++)
{
FoamXServer.ITypeDescriptor patchFieldType = getAppClassModel().getPatchFieldType(patchFieldTypes[i]);
patchFieldTypeNameMap_.put(patchFieldTypes[i], patchFieldType.displayName());
patchFieldTypeNameMap_.put(patchFieldType.displayName(), patchFieldTypes[i]);
}
// Initialise patch type nodes.
initialisePatchTypes();
// Initialise rest of boundary types.
initialisePatchPhysicalTypes();
// Listen out for changes to the field model.
getAppClassModel().getFieldDefinitionModel().addFieldModelListener(this);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
DefaultTreeModel getTreeModel()
{
return treeModel_;
}
BoundaryDefinitionModelItem getCurrentBoundaryModelItem()
{
return currentboundaryDef_;
}
//--------------------------------------------------------------------------
void fireBoundaryDefinitionDataChanged()
{
// Update the boundary type desriptor objects.
Enumeration enum = boundaryDefMap_.elements();
while (enum.hasMoreElements())
{
DefaultMutableTreeNode node = (DefaultMutableTreeNode)enum.nextElement();
treeModel_.nodeChanged(node);
}
fireTableDataChanged();
}
//--------------------------------------------------------------------------
void select(DefaultMutableTreeNode node)
{
BoundaryDefinitionModelItem nodeInfo = (BoundaryDefinitionModelItem)node.getUserObject();
currentboundaryDef_ = nodeInfo;
// Since the selected boundary type has changed, the table's data has changed.
fireTableDataChanged();
}
//--------------------------------------------------------------------------
DefaultMutableTreeNode addBoundaryDefinitionNode(String patchPhysicalTypeName, DefaultMutableTreeNode parentNode)
{
DefaultMutableTreeNode newNode = null;
try
{
if (!boundaryDefMap_.containsKey(patchPhysicalTypeName))
{
// Create a new Boundary Type Descriptor object.
IPatchPhysicalTypeDescriptorHolder bndTypeDescHolder = new IPatchPhysicalTypeDescriptorHolder();
getAppClassModel().getAppClassDescriptor().addPatchPhysicalType(patchPhysicalTypeName, bndTypeDescHolder);
// Wrap it in a BoundaryDefinitionModelItem object and create node object.
BoundaryDefinitionModelItem nodeInfo = new BoundaryDefinitionModelItem(bndTypeDescHolder.value);
newNode = new DefaultMutableTreeNode(nodeInfo, true);
// Add to map.
boundaryDefMap_.put(patchPhysicalTypeName, newNode);
// Get parent details.
BoundaryDefinitionModelItem parentNodeInfo = (BoundaryDefinitionModelItem)parentNode.getUserObject();
// Initialise the new object.
nodeInfo.setDisplayName(patchPhysicalTypeName);
nodeInfo.setDescription(patchPhysicalTypeName);
nodeInfo.setPatchType(parentNodeInfo.getPatchType());
// See if this is a new sub-type.
if (parentNodeInfo.isBoundaryDefinition())
{
nodeInfo.setParentType(parentNodeInfo.getName());
}
// Add fields.
for (int i = 0; i <getAppClassModel().getFieldDefinitionModel().getRowCount(); i++)
{
FieldDescriptorCache fieldDesc = getAppClassModel().getFieldDefinitionModel().getFieldDescriptor(i);
// Set default patch field type.
String[] patchFieldTypes = getAppClassModel().getPatchFieldTypes();
nodeInfo.addField(fieldDesc.getFieldName(), patchFieldTypes[0]);
}
// Add node to tree.
treeModel_.insertNodeInto(newNode, parentNode, 0);
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return newNode;
}
//--------------------------------------------------------------------------
boolean deleteBoundaryDefinitionNode(DefaultMutableTreeNode nodeItem)
{
boolean bRet = false;
try
{
// See if the given node has any children or is a patch type.
BoundaryDefinitionModelItem nodeInfo = (BoundaryDefinitionModelItem)nodeItem.getUserObject();
if (nodeItem.getChildCount() == 0 && nodeInfo.isBoundaryDefinition())
{
// Delete boundary type in the application class.
getAppClassModel().getAppClassDescriptor().deletePatchPhysicalType(nodeInfo.getName());
// Remove from map and tree.
boundaryDefMap_.remove(nodeInfo.getName());
treeModel_.removeNodeFromParent(nodeItem);
bRet = true;
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return bRet;
}
//--------------------------------------------------------------------------
void updateApplication(IApplication app)
{
try
{
// Update the boundary type desriptor objects.
Enumeration enum = boundaryDefMap_.elements();
while (enum.hasMoreElements())
{
DefaultMutableTreeNode node = (DefaultMutableTreeNode)enum.nextElement();
BoundaryDefinitionModelItem nodeInfo = (BoundaryDefinitionModelItem)node.getUserObject();
nodeInfo.updatePatchPhysicalTypeDescriptor();
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
void validate() throws ApplicationExeption
{
// TODO : Validate boundary definitions.
}
//--------------------------------------------------------------------------
private ApplicationModel getAppClassModel()
{
return (ApplicationModel)appModel_.get();
}
//--------------------------------------------------------------------------
private void initialisePatchTypes()
{
try
{
String[] patchTypes = getAppClassModel().getPatchTypes();
for (int i = 0; i <patchTypes.length; i++)
{
IPatchDescriptor patchType = getAppClassModel().getPatchType(patchTypes[i]);
BoundaryDefinitionModelItem nodeInfo = new BoundaryDefinitionModelItem(patchType);
DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(nodeInfo, true);
treeModel_.insertNodeInto(newNode, rootNode_, i);
patchNodeMap_.put(patchTypes[i], newNode);
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
private void initialisePatchPhysicalTypes()
{
try
{
// Get defined boundary type names from the application class object.
String[] patchPhysicalTypes = getAppClassModel().getAppClassDescriptor().patchPhysicalTypes();
for (int i=0; i <patchPhysicalTypes.length; i++)
{
// Get Boundary Type Descriptor object.
IPatchPhysicalTypeDescriptorHolder bndTypeDescHolder = new IPatchPhysicalTypeDescriptorHolder();
getAppClassModel().getAppClassDescriptor().getPatchPhysicalType(patchPhysicalTypes[i], bndTypeDescHolder);
IPatchPhysicalTypeDescriptor bndTypeDesc = bndTypeDescHolder.value;
// Make sure this boundary definition has not been encountered before.
if (boundaryDefMap_.containsKey(bndTypeDesc.name()))
{
throw new FoamXException("Duplicate boundary definition in BoundaryDefinitionModel::initialisePatchPhysicalTypes.");
}
// Wrap it in a BoundaryDefinitionModelItem object and create node object.
BoundaryDefinitionModelItem nodeInfo = new BoundaryDefinitionModelItem(bndTypeDesc);
DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(nodeInfo, true);
// Add to map.
boundaryDefMap_.put(patchPhysicalTypes[i], newNode);
}
// Now that the map is initialised, build the tree.
Enumeration enum = boundaryDefMap_.elements();
while (enum.hasMoreElements())
{
DefaultMutableTreeNode node = (DefaultMutableTreeNode)enum.nextElement();
BoundaryDefinitionModelItem nodeInfo = (BoundaryDefinitionModelItem)node.getUserObject();
// Make sure this patch type is defined.
if (!patchNodeMap_.containsKey(nodeInfo.getPatchType()))
{
throw new FoamXException("Unknown patch type in BoundaryDefinitionModel::initialisePatchPhysicalTypes.");
}
// If we have a super type, make sure we have it in the map.
if (nodeInfo.getParentType().length()> 0 && !boundaryDefMap_.containsKey(nodeInfo.getParentType()))
{
throw new FoamXException("Invalid super type in boundary definition in BoundaryDefinitionModel::initialisePatchPhysicalTypes.");
}
// Get the parent node.
DefaultMutableTreeNode parentNode = null;
if (nodeInfo.getParentType().length()> 0)
{
// Sub-type boundary definition.
parentNode = (DefaultMutableTreeNode)boundaryDefMap_.get(nodeInfo.getParentType());
}
else
{
// Top-level boundary definition.
parentNode = (DefaultMutableTreeNode)patchNodeMap_.get(nodeInfo.getPatchType());
}
// Add new node to tree.
treeModel_.insertNodeInto(node, parentNode, 0);
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
//---- FieldModelListener Interface
//--------------------------------------------------------------------------
public void fieldAdded(FieldModelEvent evt)
{
try
{
Enumeration enum = boundaryDefMap_.elements();
while (enum.hasMoreElements())
{
DefaultMutableTreeNode node = (DefaultMutableTreeNode)enum.nextElement();
BoundaryDefinitionModelItem nodeInfo = (BoundaryDefinitionModelItem)node.getUserObject();
// Set default patch field type.
String[] patchFieldTypes = getAppClassModel().getPatchFieldTypes();
nodeInfo.addField(evt.getFieldName(), patchFieldTypes[0]);
}
// When the field table model changes, so does this one.
fireTableDataChanged();
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
public void fieldRemoved(FieldModelEvent evt)
{
try
{
Enumeration enum = boundaryDefMap_.elements();
while (enum.hasMoreElements())
{
DefaultMutableTreeNode node = (DefaultMutableTreeNode)enum.nextElement();
BoundaryDefinitionModelItem nodeInfo = (BoundaryDefinitionModelItem)node.getUserObject();
nodeInfo.deleteField(evt.getFieldName());
}
// When the field table model changes, so does this one.
fireTableDataChanged();
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
public void fieldRenamed(FieldModelEvent evt)
{
try
{
Enumeration enum = boundaryDefMap_.elements();
while (enum.hasMoreElements())
{
DefaultMutableTreeNode node = (DefaultMutableTreeNode)enum.nextElement();
BoundaryDefinitionModelItem nodeInfo = (BoundaryDefinitionModelItem)node.getUserObject();
//nodeInfo.renameField(evt.getOldFieldName(), evt.getFieldName());
}
// When the field table model changes, so does this one.
fireTableDataChanged();
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
//---- AbstractTableModel methods
//--------------------------------------------------------------------------
public int getRowCount()
{
// If we are not displaying a boundary definition, show no rows.
if (currentboundaryDef_ != null && currentboundaryDef_.isBoundaryDefinition())
{
return getAppClassModel().getFieldDefinitionModel().getRowCount();
}
else
{
return 0;
}
}
//--------------------------------------------------------------------------
public int getColumnCount()
{
return ColumnNames.length;
}
//--------------------------------------------------------------------------
public String getColumnName(int columnIndex)
{
return ColumnNames[columnIndex];
}
//--------------------------------------------------------------------------
public Class getColumnClass(int columnIndex)
{
// Everything is of type String.
return String.class;
}
//--------------------------------------------------------------------------
public boolean isCellEditable(int rowIndex, int columnIndex)
{
// Patch field type column is editable.
return (columnIndex == FIELD_NAME_INDEX) ? false : true;
}
//--------------------------------------------------------------------------
public Object getValueAt(int rowIndex, int columnIndex)
{
// Get field details.
FieldDescriptorCache fieldDesc = getAppClassModel().getFieldDefinitionModel().getFieldDescriptor(rowIndex);
switch (columnIndex)
{
case FIELD_NAME_INDEX:
return fieldDesc.getFieldName();
case PATCH_FIELD_TYPE_INDEX:
// Return the patch field type for this field.
if (currentboundaryDef_ != null && currentboundaryDef_.isBoundaryDefinition())
{
// Convert from true patch field type to display name.
String patchFieldType = currentboundaryDef_.getPatchFieldType(fieldDesc.getFieldName());
return (String)patchFieldTypeNameMap_.get(patchFieldType);
}
break;
default:
// Buggeration.
break;
}
return null;
}
//--------------------------------------------------------------------------
public void setValueAt(Object aValue, int rowIndex, int columnIndex)
{
// Get field details.
FieldDescriptorCache fieldDesc = getAppClassModel().getFieldDefinitionModel().getFieldDescriptor(rowIndex);
switch (columnIndex)
{
case FIELD_NAME_INDEX:
break;
case PATCH_FIELD_TYPE_INDEX:
if (currentboundaryDef_ != null && currentboundaryDef_.isBoundaryDefinition())
{
// Set the patch field type for the current BoundaryDefinition object.
String displayName = (String)aValue;
// Convert from display name to true patch field type.
String patchFieldType = (String)patchFieldTypeNameMap_.get(displayName);
currentboundaryDef_.setPatchFieldType(fieldDesc.getFieldName(), patchFieldType);
}
break;
default:
// Buggeration.
break;
}
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,343 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.ApplicationEditor;
import javax.swing.Icon;
import java.util.Enumeration;
import FoamX.App;
import FoamX.Exceptions.FoamXException;
import FoamXServer.CaseServer.IPatchPhysicalTypeDescriptor;
import FoamXServer.CaseServer.IPatchDescriptor;
import FoamXServer.StringPair;
public class BoundaryDefinitionModelItem
implements FoamX.Util.FoamXTreeRenderer.FoamXTreeItem
{
//--------------------------------------------------------------------------
private static final int NODE_TYPE_ROOT = 0;
private static final int NODE_TYPE_PATCHTYPE = 1;
private static final int NODE_TYPE_BOUNDARYDEF = 2;
private static Icon[] icons_;
private IPatchPhysicalTypeDescriptor patchPhysicalTypeDesc_;
private int type_; // Type of this node - Root, Patch or BoundaryDefinition.
private String name_;
private String displayName_;
private String description_;
private String parentType_;
private String patchType_;
private java.util.Hashtable patchFieldTypeMap_; // Map between field names and patch field types.
//--------------------------------------------------------------------------
static
{
try
{
icons_ = new Icon[3];
icons_[NODE_TYPE_ROOT] = App.getResources().getIcon("PatchRootImage");
icons_[NODE_TYPE_PATCHTYPE] = App.getResources().getIcon("PatchTypeImage");
icons_[NODE_TYPE_BOUNDARYDEF] = App.getResources().getIcon("BoundaryDefinitionImage");
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
/** Constructor for Root BoundaryDefinitionModelItem object. */
public BoundaryDefinitionModelItem()
{
type_ = NODE_TYPE_ROOT;
name_ = "Patch Types";
displayName_ = "Patch Types";
}
//--------------------------------------------------------------------------
/** Constructor for Patch Type BoundaryDefinitionModelItem object. */
public BoundaryDefinitionModelItem(IPatchDescriptor patchType)
{
try
{
type_ = NODE_TYPE_PATCHTYPE;
name_ = patchType.name();
displayName_ = patchType.displayName();
description_ = patchType.description();
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
/** Constructor for Boundary Definition Type BoundaryDefinitionModelItem object. */
public BoundaryDefinitionModelItem(IPatchPhysicalTypeDescriptor patchPhysicalType)
{
try
{
patchPhysicalTypeDesc_ = patchPhysicalType;
type_ = NODE_TYPE_BOUNDARYDEF;
name_ = patchPhysicalType.name();
displayName_ = patchPhysicalType.displayName();
description_ = patchPhysicalType.description();
parentType_ = patchPhysicalType.parentType();
patchType_ = patchPhysicalType.patchType();
patchFieldTypeMap_ = new java.util.Hashtable();
// Get the patch field types.
StringPair[] patchFieldTypes = patchPhysicalType.patchFieldTypes();
for (int j=0; j <patchFieldTypes.length; j++)
{
addField(patchFieldTypes[j].name, patchFieldTypes[j].value);
//setPatchFieldType(patchFieldTypes[j].name, patchFieldTypes[j].value);
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
// FoamXTreeItem interface methods.
public Icon getIcon()
{
return icons_[type_];
}
public String getText()
{
return toString();
}
//--------------------------------------------------------------------------
public String toString()
{
return displayName_;
}
public int getType()
{
return type_;
}
public String getName()
{
return name_;
}
public String getDisplayName()
{
return displayName_;
}
public String getDescription()
{
return description_;
}
public String getParentType()
{
return parentType_;
}
public String getPatchType()
{
return patchType_;
}
public void setName(String name)
{
name_ = name.trim();
}
public void setDisplayName(String displayName)
{
displayName_ = displayName.trim();
}
public void setDescription(String description)
{
description_ = description.trim();
}
public void setParentType(String parentType)
{
parentType_ = parentType.trim();
}
public void setPatchType(String patchType)
{
patchType_ = patchType.trim();
}
public boolean isRoot()
{
return type_ == NODE_TYPE_ROOT;
}
public boolean isPatchType()
{
return type_ == NODE_TYPE_PATCHTYPE;
}
public boolean isBoundaryDefinition()
{
return type_ == NODE_TYPE_BOUNDARYDEF;
}
//--------------------------------------------------------------------------
void addField(String fieldName, String patchFieldType)
{
try
{
if (patchFieldTypeMap_.containsKey(fieldName))
{
throw new FoamXException("Duplicate field name.");
}
patchFieldTypeMap_.put(fieldName, patchFieldType);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
void deleteField(String fieldName)
{
try
{
if (!patchFieldTypeMap_.containsKey(fieldName))
{
throw new FoamXException("Invalid field name.");
}
patchFieldTypeMap_.remove(fieldName);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
void renameField(String oldName, String newName)
{
try
{
if (!patchFieldTypeMap_.containsKey(oldName))
{
throw new FoamXException("Invalid field name.");
}
String patchFieldType = (String)patchFieldTypeMap_.get(oldName);
patchFieldTypeMap_.remove(oldName);
patchFieldTypeMap_.put(newName, patchFieldType);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
public String getPatchFieldType(String fieldName)
{
try
{
if (!patchFieldTypeMap_.containsKey(fieldName))
{
throw new FoamXException("Invalid field name.");
}
return (String)patchFieldTypeMap_.get(fieldName);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return "";
}
//--------------------------------------------------------------------------
public void setPatchFieldType(String fieldName, String patchFieldType)
{
try
{
if (!patchFieldTypeMap_.containsKey(fieldName))
{
throw new FoamXException("Invalid field name.");
}
patchFieldTypeMap_.put(fieldName, patchFieldType);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
/**
* Update the cached IPatchPhysicalTypeDescriptor object.
*/
public void updatePatchPhysicalTypeDescriptor()
{
try
{
if (patchPhysicalTypeDesc_ != null)
{
// Update the IPatchPhysicalTypeDescriptor object.
patchPhysicalTypeDesc_.name(name_);
patchPhysicalTypeDesc_.displayName(displayName_);
patchPhysicalTypeDesc_.description(description_);
patchPhysicalTypeDesc_.parentType(parentType_);
patchPhysicalTypeDesc_.patchType(patchType_);
// Set the patch field types.
Enumeration enum = patchFieldTypeMap_.keys();
StringPair[] patchFieldTypes = new StringPair[patchFieldTypeMap_.size()];
int nField = 0;
while (enum.hasMoreElements())
{
String fieldName = (String)enum.nextElement();
String patchFieldType = (String)patchFieldTypeMap_.get(fieldName);
patchFieldTypes[nField++] = new StringPair(fieldName, patchFieldType);
}
patchPhysicalTypeDesc_.patchFieldTypes(patchFieldTypes);
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,144 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<SyntheticProperties>
</SyntheticProperties>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="topPanel_">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Component class="javax.swing.JLabel" name="nameLabel_">
<Properties>
<Property name="text" type="java.lang.String" value="Name"/>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" id="black" palette="0" red="0" type="palette"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JTextField" name="nameEdit_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="SansSerif" size="10" style="0"/>
</Property>
</Properties>
<Events>
<EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="nameEditFocusLost"/>
<EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="nameEditKeyPressed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="2" gridHeight="1" gridWidth="1" gridX="1" gridY="0" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JLabel" name="displayNameLabel_">
<Properties>
<Property name="text" type="java.lang.String" value="Display Name"/>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" id="black" palette="0" red="0" type="palette"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="1" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JTextField" name="displayNameEdit_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="SansSerif" size="10" style="0"/>
</Property>
</Properties>
<Events>
<EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="displayNameEditFocusLost"/>
<EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="displayNameEditKeyPressed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="2" gridHeight="1" gridWidth="1" gridX="1" gridY="1" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JLabel" name="descriptionLabel_">
<Properties>
<Property name="text" type="java.lang.String" value="Description"/>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" id="black" palette="0" red="0" type="palette"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="2" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JTextField" name="descriptionEdit_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="SansSerif" size="10" style="0"/>
</Property>
</Properties>
<Events>
<EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="descriptionEditFocusLost"/>
<EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="descriptionEditKeyPressed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="2" gridHeight="1" gridWidth="1" gridX="1" gridY="2" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JScrollPane" name="scrollPane_">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="1" gridHeight="1" gridWidth="1" gridX="0" gridY="1" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTable" name="table_">
<Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="tableModel_" type="code"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="preferredScrollableViewportSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 0]"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@ -0,0 +1,402 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.ApplicationEditor;
import javax.swing.table.*;
import javax.swing.*;
import javax.swing.event.*;
import FoamX.App;
import FoamXServer.CaseServer.IPatchDescriptor;
import FoamXServer.ITypeDescriptor;
//import FoamXServer.CaseServer.IPatchFieldDescriptor;
public class BoundaryDefinitionPanel
extends javax.swing.JPanel
{
//--------------------------------------------------------------------------
private static final int DEFAULT_WIDTH = 100;
private ApplicationModel appModel_;
private BoundaryDefinitionModel tableModel_;
private DefaultCellEditor patchFieldTypeEditor_;
private JComboBox patchFieldTypeCombo_;
//--------------------------------------------------------------------------
/** Constructor for BoundaryDefinitionPanel. */
public BoundaryDefinitionPanel(ApplicationModel appModel)
{
try
{
appModel_ = appModel;
tableModel_ = appModel_.getBoundaryDefinitionModel();
// Initialise the gui.
initComponents();
// Resize table to show the defined rows only.
int height = (table_.getRowHeight() + table_.getRowMargin()) *
(tableModel_.getRowCount() + 1); // Add an extra row to account for the header control.
table_.setPreferredScrollableViewportSize(new java.awt.Dimension(DEFAULT_WIDTH, height));
// Initialise the patch field type editor.
patchFieldTypeCombo_ = new JComboBox();
String[] patchFieldTypes = appModel_.getPatchFieldTypes();
for (int i = 0; i <patchFieldTypes.length; i++)
{
ITypeDescriptor patchFieldType = appModel_.getPatchFieldType(patchFieldTypes[i]);
patchFieldTypeCombo_.addItem(patchFieldType.displayName());
}
patchFieldTypeCombo_.setFont(table_.getFont()); // Use same font as table.
patchFieldTypeEditor_ = new DefaultCellEditor(patchFieldTypeCombo_);
// Set cell editor for patch field type column.
table_.getColumn(BoundaryDefinitionModel.PATCH_FIELD_TYPE_COLUMN).setCellEditor(patchFieldTypeEditor_);
// Listen out for changes to the boundary definition model selection.
tableModel_.addTableModelListener
(
new TableModelListener()
{
public void tableChanged(TableModelEvent evt)
{
boundaryModelChanged(evt);
}
}
);
// Initialise the edit controls.
nameEdit_.setText("");
displayNameEdit_.setText("");
descriptionEdit_.setText("");
nameEdit_.setEnabled(false);
displayNameEdit_.setEnabled(false);
descriptionEdit_.setEnabled(false);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
private void boundaryModelChanged(TableModelEvent evt)
{
// Another boundary definition has been selected causing the table's data to change.
patchFieldTypeEditor_.cancelCellEditing();
BoundaryDefinitionModelItem currItem = tableModel_.getCurrentBoundaryModelItem();
if (currItem != null && currItem.isBoundaryDefinition())
{
nameEdit_.setEnabled(true);
displayNameEdit_.setEnabled(true);
descriptionEdit_.setEnabled(true);
// Update the description text fields.
nameEdit_.setText(currItem.getName());
displayNameEdit_.setText(currItem.getDisplayName());
descriptionEdit_.setText(currItem.getDescription());
// Update the patch field combo with the valid patch field types for this patch type.
patchFieldTypeCombo_.removeAllItems();
IPatchDescriptor patchType = appModel_.getPatchType(currItem.getPatchType());
String[] patchFieldTypes = patchType.patchFieldTypes();
for (int i = 0; i <patchFieldTypes.length; i++)
{
ITypeDescriptor patchFieldType = appModel_.getPatchFieldType(patchFieldTypes[i]);
patchFieldTypeCombo_.addItem(patchFieldType.displayName());
}
}
else
{
nameEdit_.setText("");
displayNameEdit_.setText("");
descriptionEdit_.setText("");
nameEdit_.setEnabled(false);
displayNameEdit_.setEnabled(false);
descriptionEdit_.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 FormEditor.
*/
private void initComponents() {//GEN-BEGIN:initComponents
topPanel_ = new javax.swing.JPanel();
nameLabel_ = new javax.swing.JLabel();
nameEdit_ = new javax.swing.JTextField();
displayNameLabel_ = new javax.swing.JLabel();
displayNameEdit_ = new javax.swing.JTextField();
descriptionLabel_ = new javax.swing.JLabel();
descriptionEdit_ = new javax.swing.JTextField();
scrollPane_ = new javax.swing.JScrollPane();
table_ = new javax.swing.JTable();
setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints1;
topPanel_.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints2;
nameLabel_.setText("Name");
nameLabel_.setForeground(java.awt.Color.black);
nameLabel_.setFont(new java.awt.Font("Dialog", 0, 10));
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTH;
topPanel_.add(nameLabel_, gridBagConstraints2);
nameEdit_.setFont(new java.awt.Font("SansSerif", 0, 10));
nameEdit_.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent evt) {
nameEditFocusLost(evt);
}
});
nameEdit_.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
nameEditKeyPressed(evt);
}
});
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 1;
gridBagConstraints2.gridy = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints2.weightx = 1.0;
topPanel_.add(nameEdit_, gridBagConstraints2);
displayNameLabel_.setText("Display Name");
displayNameLabel_.setForeground(java.awt.Color.black);
displayNameLabel_.setFont(new java.awt.Font("Dialog", 0, 10));
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 1;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTH;
topPanel_.add(displayNameLabel_, gridBagConstraints2);
displayNameEdit_.setFont(new java.awt.Font("SansSerif", 0, 10));
displayNameEdit_.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent evt) {
displayNameEditFocusLost(evt);
}
});
displayNameEdit_.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
displayNameEditKeyPressed(evt);
}
});
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 1;
gridBagConstraints2.gridy = 1;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints2.weightx = 1.0;
topPanel_.add(displayNameEdit_, gridBagConstraints2);
descriptionLabel_.setText("Description");
descriptionLabel_.setForeground(java.awt.Color.black);
descriptionLabel_.setFont(new java.awt.Font("Dialog", 0, 10));
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 2;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTH;
topPanel_.add(descriptionLabel_, gridBagConstraints2);
descriptionEdit_.setFont(new java.awt.Font("SansSerif", 0, 10));
descriptionEdit_.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent evt) {
descriptionEditFocusLost(evt);
}
});
descriptionEdit_.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
descriptionEditKeyPressed(evt);
}
});
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 1;
gridBagConstraints2.gridy = 2;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints2.weightx = 1.0;
topPanel_.add(descriptionEdit_, gridBagConstraints2);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints1.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints1.weightx = 1.0;
add(topPanel_, gridBagConstraints1);
table_.setModel(tableModel_);
table_.setFont(new java.awt.Font("Dialog", 0, 10));
table_.setPreferredScrollableViewportSize(new java.awt.Dimension(0, 0));
scrollPane_.setViewportView(table_);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 1;
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints1.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints1.weightx = 1.0;
gridBagConstraints1.weighty = 1.0;
add(scrollPane_, gridBagConstraints1);
}//GEN-END:initComponents
//--------------------------------------------------------------------------
private void descriptionEditKeyPressed(java.awt.event.KeyEvent evt)
{//GEN-FIRST:event_descriptionEditKeyPressed
if (evt.getKeyCode() == evt.VK_ENTER)
{
BoundaryDefinitionModelItem currItem = tableModel_.getCurrentBoundaryModelItem();
if (currItem != null && currItem.isBoundaryDefinition())
{
currItem.setDescription(descriptionEdit_.getText());
tableModel_.fireBoundaryDefinitionDataChanged();
}
}
}//GEN-LAST:event_descriptionEditKeyPressed
//--------------------------------------------------------------------------
private void displayNameEditKeyPressed(java.awt.event.KeyEvent evt)
{//GEN-FIRST:event_displayNameEditKeyPressed
if (evt.getKeyCode() == evt.VK_ENTER)
{
BoundaryDefinitionModelItem currItem = tableModel_.getCurrentBoundaryModelItem();
if (currItem != null && currItem.isBoundaryDefinition())
{
currItem.setDisplayName(displayNameEdit_.getText());
tableModel_.fireBoundaryDefinitionDataChanged();
}
}
}//GEN-LAST:event_displayNameEditKeyPressed
//--------------------------------------------------------------------------
private void nameEditKeyPressed(java.awt.event.KeyEvent evt)
{//GEN-FIRST:event_nameEditKeyPressed
if (evt.getKeyCode() == evt.VK_ENTER)
{
BoundaryDefinitionModelItem currItem = tableModel_.getCurrentBoundaryModelItem();
if (currItem != null && currItem.isBoundaryDefinition())
{
currItem.setName(nameEdit_.getText());
tableModel_.fireBoundaryDefinitionDataChanged();
}
}
}//GEN-LAST:event_nameEditKeyPressed
//--------------------------------------------------------------------------
private void nameEditFocusLost (java.awt.event.FocusEvent evt)
{//GEN-FIRST:event_nameEditFocusLost
// Update the boundary definition type name.
BoundaryDefinitionModelItem currItem = tableModel_.getCurrentBoundaryModelItem();
if (currItem != null && currItem.isBoundaryDefinition())
{
currItem.setName(nameEdit_.getText());
tableModel_.fireBoundaryDefinitionDataChanged();
}
}//GEN-LAST:event_nameEditFocusLost
//--------------------------------------------------------------------------
private void displayNameEditFocusLost (java.awt.event.FocusEvent evt)
{//GEN-FIRST:event_displayNameEditFocusLost
// Update the boundary definition type display name.
BoundaryDefinitionModelItem currItem = tableModel_.getCurrentBoundaryModelItem();
if (currItem != null && currItem.isBoundaryDefinition())
{
currItem.setDisplayName(displayNameEdit_.getText());
tableModel_.fireBoundaryDefinitionDataChanged();
}
}//GEN-LAST:event_displayNameEditFocusLost
//--------------------------------------------------------------------------
private void descriptionEditFocusLost (java.awt.event.FocusEvent evt)
{//GEN-FIRST:event_descriptionEditFocusLost
// Update the boundary definition type decription.
BoundaryDefinitionModelItem currItem = tableModel_.getCurrentBoundaryModelItem();
if (currItem != null && currItem.isBoundaryDefinition())
{
currItem.setDescription(descriptionEdit_.getText());
tableModel_.fireBoundaryDefinitionDataChanged();
}
}//GEN-LAST:event_descriptionEditFocusLost
//--------------------------------------------------------------------------
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel topPanel_;
private javax.swing.JLabel nameLabel_;
private javax.swing.JTextField nameEdit_;
private javax.swing.JLabel displayNameLabel_;
private javax.swing.JTextField displayNameEdit_;
private javax.swing.JLabel descriptionLabel_;
private javax.swing.JTextField descriptionEdit_;
private javax.swing.JScrollPane scrollPane_;
private javax.swing.JTable table_;
// End of variables declaration//GEN-END:variables
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,128 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.ApplicationEditor;
import javax.swing.*;
import javax.swing.tree.*;
import java.awt.Component;
import FoamX.App;
public class BoundaryDefinitionTreeRenderer
extends FoamX.Util.FoamXTreeRenderer
{
// Icons.
private Icon[] icons_;
// Symbolic constants for icon indices.
public static final int UNDEFINED_ICON = 0;
public static final int ROOT_ICON = 1;
public static final int PATCHTYPE_ICON = 2;
public static final int BOUNDARYDEF_ICON = 3;
//-----------------------------------------------------------------------------------------
public BoundaryDefinitionTreeRenderer()
{
try
{
// Load icons.
icons_ = new Icon[4];
icons_[UNDEFINED_ICON] = App.getResources().getIcon("UndefinedImage");
icons_[ROOT_ICON] = App.getResources().getIcon("PatchRootImage");
icons_[PATCHTYPE_ICON] = App.getResources().getIcon("PatchTypeImage");
icons_[BOUNDARYDEF_ICON] = App.getResources().getIcon("BoundaryDefinitionImage");
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//-----------------------------------------------------------------------------------------
public Component getTreeCellRendererComponent
(
JTree tree,
Object value,
boolean selected,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus
)
{
try
{
super.getTreeCellRendererComponent(tree,
value,
selected,
expanded,
leaf,
row,
hasFocus);
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)value;
BoundaryDefinitionModelItem nodeInfo = (BoundaryDefinitionModelItem)treeNode.getUserObject();
// Set label text.
setText(nodeInfo.toString());
// Set an appropriate icon according to the type of node.
if (nodeInfo.isRoot())
{
setIcon(icons_[ROOT_ICON]);
}
else if (nodeInfo.isPatchType())
{
setIcon(icons_[PATCHTYPE_ICON]);
}
else if (nodeInfo.isBoundaryDefinition())
{
setIcon(icons_[BOUNDARYDEF_ICON]);
}
else
{
setIcon(icons_[UNDEFINED_ICON]);
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return this;
}
//-----------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------
}

View File

@ -0,0 +1,133 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<NonVisualComponents>
<Menu class="javax.swing.JPopupMenu" name="contextMenu_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
</Menu>
</NonVisualComponents>
<SyntheticProperties>
</SyntheticProperties>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="subPanel_">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="10" fill="1" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="10" insetsLeft="10" insetsRight="10" insetsTop="10" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Container class="javax.swing.JSplitPane" name="splitPane_">
<Properties>
<Property name="dividerLocation" type="int" value="200"/>
<Property name="lastDividerLocation" type="int" value="200"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="1" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="scrollPaneRight_">
<Properties>
<Property name="autoscrolls" type="boolean" value="true"/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="scrollPaneRight_.setViewportView( boundaryDefinitionPanel_ );&#xa;"/>
<AuxValue name="JavaCodeGenerator_CreateCodePost" type="java.lang.String" value=""/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="right"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
</Container>
<Container class="javax.swing.JPanel" name="leftPanel_">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="left"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="buttonPanel_">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder/>
</Border>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="0" insetsLeft="0" insetsRight="0" insetsTop="0" ipadX="0" ipadY="0" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
<Property name="alignment" type="int" value="0"/>
</Layout>
<SubComponents>
<Container class="javax.swing.JToolBar" name="toolbar_">
<Properties>
<Property name="floatable" type="boolean" value="false"/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="8" style="0"/>
</Property>
</Properties>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
</Container>
</SubComponents>
</Container>
<Container class="javax.swing.JScrollPane" name="scrollPaneTree_">
<Properties>
<Property name="autoscrolls" type="boolean" value="true"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="15" fill="1" gridHeight="1" gridWidth="1" gridX="0" gridY="1" insetsBottom="0" insetsLeft="0" insetsRight="0" insetsTop="0" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTree" name="tree_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="showsRootHandles" type="boolean" value="true"/>
<Property name="model" type="javax.swing.tree.TreeModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code=" boundaryDefinitionModel_.getTreeModel() " type="code"/>
</Property>
<Property name="autoscrolls" type="boolean" value="true"/>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="OnTreeMouseClicked"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@ -0,0 +1,186 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.0" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="title" type="java.lang.String" value="FoamX Application Classes"/>
<Property name="name" type="java.lang.String" value="appClassesDlg"/>
<Property name="modal" type="boolean" value="true"/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="menuBar" type="java.lang.String" value="(No Menu)"/>
<SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-16,0,0,1,124"/>
<SyntheticProperty name="formPosition" type="java.awt.Point" value="-84,-19,0,5,115,114,0,14,106,97,118,97,46,97,119,116,46,80,111,105,110,116,-74,-60,-118,114,52,126,-56,38,2,0,2,73,0,1,120,73,0,1,121,120,112,0,0,0,0,0,0,0,0"/>
<SyntheticProperty name="formSizePolicy" type="int" value="0"/>
<SyntheticProperty name="generatePosition" type="boolean" value="true"/>
<SyntheticProperty name="generateSize" type="boolean" value="true"/>
<SyntheticProperty name="generateCenter" type="boolean" value="true"/>
</SyntheticProperties>
<Events>
<EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="closeDialog"/>
</Events>
<AuxValues>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="appClassListPanel_">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
<EmptyBorder bottom="10" left="10" right="10" top="10"/>
</Border>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="10" fill="1" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="0" insetsLeft="0" insetsRight="0" insetsTop="0" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="scrollPane_">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="18" fill="1" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JList" name="appClassList_">
<Properties>
<Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="listModel_" type="code"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="OnAppClassListMouseClicked"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="appClassButtonPanel_">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="0" gridHeight="1" gridWidth="1" gridX="1" gridY="0" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Component class="javax.swing.JButton" name="openAppClassButton_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="Open..."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="OnEditApplicationsClass"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="0" insetsLeft="0" insetsRight="0" insetsTop="0" ipadX="0" ipadY="0" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JButton" name="newAppClassButton_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="New..."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="OnNewApplication"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="1" insetsBottom="0" insetsLeft="0" insetsRight="0" insetsTop="0" ipadX="0" ipadY="0" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JButton" name="cloneAppClassButton_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="Clone..."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="OnCloneApplication"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="2" insetsBottom="0" insetsLeft="0" insetsRight="0" insetsTop="0" ipadX="0" ipadY="0" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JButton" name="delAppClassButton_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="Delete..."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="OnDeleteApplication"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="11" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="3" insetsBottom="0" insetsLeft="0" insetsRight="0" insetsTop="0" ipadX="0" ipadY="0" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="buttonPanel_">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder/>
</Border>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="10" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="1" insetsBottom="0" insetsLeft="0" insetsRight="0" insetsTop="0" ipadX="0" ipadY="0" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
<Property name="alignment" type="int" value="2"/>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="buttonOK_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="Close"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="OnOK"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@ -0,0 +1,735 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.ApplicationEditor;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import FoamX.App;
import FoamX.Util.BusyCursor;
import FoamXServer.ApplicationDescriptor;
import FoamXServer.CaseServer.IApplicationHolder;
import FoamXServer.CaseServer.IFoamProperties;
import FoamXServer.FoamXError;
import FoamXServer.FoamXIOError;
public class BrowseApplicationesDlg
extends javax.swing.JDialog
{
//--------------------------------------------------------------------------
private IFoamProperties foamSys_;
private DefaultListModel listModel_;
private boolean modified_;
//--------------------------------------------------------------------------
/** BrowseApplicationesDlg constructor. */
public BrowseApplicationesDlg(IFoamProperties foamSys)
{
super(new javax.swing.JFrame(), true);
try
{
modified_ = false;
// Take a reference to the foam properties object.
foamSys_ = foamSys;
// Initialise the list of defined application classes.
listModel_ = new DefaultListModel();
initialiseAppClassList();
// Initialise gui.
initComponents();
// Listen out for selection events.
appList_.getSelectionModel().addListSelectionListener
(
new ListSelectionListener()
{
public void valueChanged(ListSelectionEvent evt)
{
OnSelectionChanged(evt);
}
}
);
// Set the list renderer.
appList_.setCellRenderer(new FoamX.Util.FoamXListRenderer());
// Select first item.
if (listModel_.getSize()> 0)
{
appList_.getSelectionModel().setLeadSelectionIndex(0);
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
public boolean getModified()
{
return modified_;
}
//--------------------------------------------------------------------------
private void initialiseAppClassList()
{
try
{
listModel_.clear();
ApplicationDescriptor[] appes = foamSys_.applicationes();
// Add an entry for all defined application classes.
for (int i = 0; i <appes.length; i++)
{
listModel_.addElement(new AppClassListItem(appes[i]));
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
public void OnSelectionChanged(ListSelectionEvent evt)
{
try
{
// Get the node object for the current selection.
if (!appList_.getSelectionModel().isSelectionEmpty())
{
// Get the selected application class.
int index = appList_.getSelectionModel().getLeadSelectionIndex();
AppClassListItem item = (AppClassListItem)listModel_.getElementAt(index);
// Set the delete button status.
delAppClassButton_.setEnabled(!item.isSystemClass());
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
private String getNewAppClassName()
{
// Prompt user for a new Boundary Definition name.
return (String)JOptionPane.showInputDialog(this,
"Enter New Application Class Name",
"FoamX...",
JOptionPane.PLAIN_MESSAGE, null, null, null);
}
//--------------------------------------------------------------------------
/** 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 FormEditor.
*/
private void initComponents() {//GEN-BEGIN:initComponents
appListPanel_ = new javax.swing.JPanel();
scrollPane_ = new javax.swing.JScrollPane();
appList_ = new javax.swing.JList();
appButtonPanel_ = new javax.swing.JPanel();
openAppClassButton_ = new javax.swing.JButton();
newAppClassButton_ = new javax.swing.JButton();
cloneAppClassButton_ = new javax.swing.JButton();
delAppClassButton_ = new javax.swing.JButton();
buttonPanel_ = new javax.swing.JPanel();
buttonOK_ = new javax.swing.JButton();
getContentPane().setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints1;
setTitle("FoamX Application Classes");
setName("appesDlg");
setModal(true);
setFont(new java.awt.Font("Dialog", 0, 10));
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
closeDialog(evt);
}
});
appListPanel_.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints2;
appListPanel_.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(10, 10, 10, 10)));
appList_.setModel(listModel_);
appList_.setFont(new java.awt.Font("Dialog", 0, 10));
appList_.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
OnAppClassListMouseClicked(evt);
}
});
scrollPane_.setViewportView(appList_);
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints2.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints2.weightx = 1.0;
gridBagConstraints2.weighty = 1.0;
appListPanel_.add(scrollPane_, gridBagConstraints2);
appButtonPanel_.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints3;
openAppClassButton_.setFont(new java.awt.Font("Dialog", 0, 10));
openAppClassButton_.setText("Open...");
openAppClassButton_.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
OnEditApplicationsClass(evt);
}
});
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 0;
gridBagConstraints3.gridy = 0;
gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints3.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints3.weightx = 1.0;
appButtonPanel_.add(openAppClassButton_, gridBagConstraints3);
newAppClassButton_.setFont(new java.awt.Font("Dialog", 0, 10));
newAppClassButton_.setText("New...");
newAppClassButton_.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
OnNewApplication(evt);
}
});
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 0;
gridBagConstraints3.gridy = 1;
gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints3.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints3.weightx = 1.0;
appButtonPanel_.add(newAppClassButton_, gridBagConstraints3);
cloneAppClassButton_.setFont(new java.awt.Font("Dialog", 0, 10));
cloneAppClassButton_.setText("Clone...");
cloneAppClassButton_.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
OnCloneApplication(evt);
}
});
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 0;
gridBagConstraints3.gridy = 2;
gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints3.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints3.weightx = 1.0;
appButtonPanel_.add(cloneAppClassButton_, gridBagConstraints3);
delAppClassButton_.setFont(new java.awt.Font("Dialog", 0, 10));
delAppClassButton_.setText("Delete...");
delAppClassButton_.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
OnDeleteApplication(evt);
}
});
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 0;
gridBagConstraints3.gridy = 3;
gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints3.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints3.weightx = 1.0;
appButtonPanel_.add(delAppClassButton_, gridBagConstraints3);
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 1;
gridBagConstraints2.gridy = 0;
gridBagConstraints2.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTH;
appListPanel_.add(appButtonPanel_, gridBagConstraints2);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints1.weightx = 1.0;
gridBagConstraints1.weighty = 1.0;
getContentPane().add(appListPanel_, gridBagConstraints1);
buttonPanel_.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
buttonPanel_.setBorder(new javax.swing.border.EtchedBorder());
buttonOK_.setFont(new java.awt.Font("Dialog", 0, 10));
buttonOK_.setText("Close");
buttonOK_.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
OnOK(evt);
}
});
buttonPanel_.add(buttonOK_);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 1;
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints1.weightx = 1.0;
getContentPane().add(buttonPanel_, gridBagConstraints1);
pack();
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setSize(new java.awt.Dimension(380, 240));
setLocation((screenSize.width-380)/2,(screenSize.height-240)/2);
}//GEN-END:initComponents
//--------------------------------------------------------------------------
private void OnCloneApplication (java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_OnCloneApplication
try
{
// Show busy cursor.
BusyCursor cursor = new BusyCursor(this);
// Clone the selected application class.
if (!appList_.getSelectionModel().isSelectionEmpty())
{
// Get name of the selected application class.
int index = appList_.getSelectionModel().getLeadSelectionIndex();
AppClassListItem item = (AppClassListItem)listModel_.getElementAt(index);
String name = item.getText();
// Get new application class name.
String appName = getNewAppClassName();
if (appName != null && appName.trim().length()> 0)
{
try
{
// Create a new application class object by cloning the selected one.
IApplicationHolder appHolder = new IApplicationHolder();
foamSys_.cloneApplication(name, appName, appHolder);
}
catch (Exception ex)
{
Toolkit.getDefaultToolkit().beep();
JOptionPane.showMessageDialog(this,
"Application class clone operation failed.",
"FoamX...",
JOptionPane.ERROR_MESSAGE);
return;
}
// Show the application class editor dialog for the new class.
ApplicationEditorDlg dlg = new ApplicationEditorDlg(foamSys_, appName, false);
dlg.show();
// If dialog was cancelled, tidy up.
if (dlg.wasCancelled())
{
// Delete application class.
foamSys_.deleteApplication(appName);
}
else
{
// Add name to list.
AppClassListItem app = new AppClassListItem(appName);
listModel_.addElement(app);
}
// Set modified flag.
modified_ = true;
// Save user properties.
foamSys_.saveUserProperties();
}
}
}
catch (FoamXIOError ioErr)
{
App.handleException(ioErr);
}
catch (FoamXError fxErr)
{
App.handleException(fxErr);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}//GEN-LAST:event_OnCloneApplication
//--------------------------------------------------------------------------
private void OnAppClassListMouseClicked (java.awt.event.MouseEvent evt)
{//GEN-FIRST:event_OnAppClassListMouseClicked
try
{
// Show busy cursor.
BusyCursor cursor = new BusyCursor(this);
// Check for double click on a list item.
if (evt.getClickCount() == 2)
{
if (!appList_.getSelectionModel().isSelectionEmpty())
{
// Get name of application class to be edited.
int index = appList_.getSelectionModel().getLeadSelectionIndex();
AppClassListItem item = (AppClassListItem)listModel_.getElementAt(index);
// Show the application class editor dialog for this class.
ApplicationEditorDlg dlg = new ApplicationEditorDlg(foamSys_, item.getText(), item.isSystemClass());
dlg.show();
// Set modified flag.
modified_ = !dlg.wasCancelled();
// Save user properties.
foamSys_.saveUserProperties();
}
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}//GEN-LAST:event_OnAppClassListMouseClicked
//--------------------------------------------------------------------------
private void OnDeleteApplication (java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_OnDeleteApplication
try
{
// Show busy cursor.
BusyCursor cursor = new BusyCursor(this);
// Remove the selected application classes.
if (!appList_.getSelectionModel().isSelectionEmpty())
{
int minIndex = appList_.getSelectionModel().getMinSelectionIndex();
int maxIndex = appList_.getSelectionModel().getMaxSelectionIndex();
// Need to remove from the top so that it doesn't get its knickers in a twist.
for (int i=maxIndex; i>= minIndex; i--)
{
int index = appList_.getSelectionModel().getLeadSelectionIndex();
AppClassListItem item = (AppClassListItem)listModel_.getElementAt(index);
// Check whether this is a system class.
if (item.isSystemClass())
{
JOptionPane.showMessageDialog(this,
"Can't delete system application class '" + item.getText() + ".",
"FoamX...",
JOptionPane.ERROR_MESSAGE);
}
else
{
if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(this,
"Are you sure you wish to delete user application class '" + item.getText() + "'?",
"FoamX...",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE))
{
// Remove from kernel.
foamSys_.deleteApplication(item.getText());
// Remove from list.
listModel_.removeElementAt(i);
// Set modified flag.
modified_ = true;
}
}
}
}
}
catch (FoamXIOError ioErr)
{
App.handleException(ioErr);
}
catch (FoamXError fxErr)
{
App.handleException(fxErr);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}//GEN-LAST:event_OnDeleteApplication
//--------------------------------------------------------------------------
private void OnNewApplication (java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_OnNewApplication
try
{
// Show busy cursor.
BusyCursor cursor = new BusyCursor(this);
String appName = getNewAppClassName();
if (appName != null && appName.trim().length()> 0)
{
try
{
// Create a new application class object.
IApplicationHolder appHolder = new IApplicationHolder();
foamSys_.addApplication(appName, appHolder);
}
catch (Exception ex)
{
Toolkit.getDefaultToolkit().beep();
JOptionPane.showMessageDialog(this,
"Application class create operation failed.",
"FoamX...",
JOptionPane.ERROR_MESSAGE);
return;
}
// Show the application class editor dialog for this class.
ApplicationEditorDlg dlg = new ApplicationEditorDlg(foamSys_, appName, false);
dlg.show();
// If dialog was cancelled, tidy up.
if (dlg.wasCancelled())
{
// Delete application class.
foamSys_.deleteApplication(appName);
}
else
{
// Add name to list.
AppClassListItem app = new AppClassListItem(appName);
listModel_.addElement(app);
}
// Set modified flag.
modified_ = !dlg.wasCancelled();
// Save user properties.
foamSys_.saveUserProperties();
}
}
catch (FoamXIOError ioErr)
{
App.handleException(ioErr);
}
catch (FoamXError fxErr)
{
App.handleException(fxErr);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}//GEN-LAST:event_OnNewApplication
//--------------------------------------------------------------------------
private void OnEditApplicationsClass (java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_OnEditApplicationsClass
try
{
// Show busy cursor.
BusyCursor cursor = new BusyCursor(this);
// Edit the selected application class.
if (!appList_.getSelectionModel().isSelectionEmpty())
{
// Get name of application class to be edited.
int index = appList_.getSelectionModel().getLeadSelectionIndex();
AppClassListItem item = (AppClassListItem)listModel_.getElementAt(index);
// Show the application class editor dialog for this class.
ApplicationEditorDlg dlg = new ApplicationEditorDlg(foamSys_, item.getText(), item.isSystemClass());
dlg.show();
// Set modified flag.
modified_ = !dlg.wasCancelled();
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}//GEN-LAST:event_OnEditApplicationsClass
//--------------------------------------------------------------------------
private void OnOK (java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_OnOK
try
{
if (modified_)
{
foamSys_.saveUserProperties();
}
setVisible(false);
dispose();
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}//GEN-LAST:event_OnOK
//--------------------------------------------------------------------------
/** Closes the dialog */
private void closeDialog(java.awt.event.WindowEvent evt)
{//GEN-FIRST:event_closeDialog
try
{
if (modified_)
{
foamSys_.saveUserProperties();
}
setVisible(false);
dispose();
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}//GEN-LAST:event_closeDialog
//--------------------------------------------------------------------------
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel appListPanel_;
private javax.swing.JScrollPane scrollPane_;
private javax.swing.JList appList_;
private javax.swing.JPanel appButtonPanel_;
private javax.swing.JButton openAppClassButton_;
private javax.swing.JButton newAppClassButton_;
private javax.swing.JButton cloneAppClassButton_;
private javax.swing.JButton delAppClassButton_;
private javax.swing.JPanel buttonPanel_;
private javax.swing.JButton buttonOK_;
// End of variables declaration//GEN-END:variables
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
static private class AppClassListItem
implements FoamX.Util.FoamXListRenderer.FoamXListItem
{
//-----------------------------------------------------------------------------------------
protected String appName_;
protected boolean systemClass_;
protected static Icon[] icons_;
//--------------------------------------------------------------------------
static
{
try
{
// Load icons.
icons_ = new Icon[3];
icons_[0] = App.getResources().getIcon("SystemAppClassImage");
icons_[1] = App.getResources().getIcon("UserAppClassImage");
icons_[2] = App.getResources().getIcon("OverridenAppClassImage");
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//-----------------------------------------------------------------------------------------
public AppClassListItem(ApplicationDescriptor desc)
{
appName_ = desc.name;
systemClass_ = desc.systemClass;
}
//-----------------------------------------------------------------------------------------
public AppClassListItem(String appName)
{
appName_ = appName;
systemClass_ = false;
}
//-----------------------------------------------------------------------------------------
public Icon getIcon()
{
return systemClass_ ? icons_[0] : icons_[1];
}
//-----------------------------------------------------------------------------------------
public String getText()
{
return appName_;
}
//-----------------------------------------------------------------------------------------
public boolean isSystemClass()
{
return systemClass_;
}
//-----------------------------------------------------------------------------------------
}
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,465 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.ApplicationEditor;
import java.lang.ref.WeakReference;
import java.util.Vector;
import java.util.Hashtable;
import java.util.Enumeration;
import javax.swing.table.*;
import javax.swing.event.*;
import FoamX.App;
import FoamXServer.CaseServer.IApplication;
import FoamXServer.CaseServer.IGeometricFieldDescriptor;
import FoamXServer.CaseServer.IGeometricFieldDescriptorHolder;
import FoamXServer.CaseServer.IGeometryDescriptor;
import FoamXServer.DimensionSet;
import FoamXServer.FoamXError;
import FoamXServer.FoamXIOError;
import FoamXServer.ITypeDescriptor;
class FieldDefinitionModel
extends AbstractTableModel
{
//--------------------------------------------------------------------------
public static final int FIELDNAME_INDEX = 0;
public static final int FIELDDESC_INDEX = 1;
public static final int FIELDTYPE_INDEX = 2;
public static final int GEOMTYPE_INDEX = 3;
public static final int DIMENSION_INDEX = 4;
public static final String FIELDNAME_COLUMN = "Name";
public static final String FIELDDESC_COLUMN = "Description";
public static final String FIELDTYPE_COLUMN = "Type";
public static final String GEOMTYPE_COLUMN = "Geometry Type";
public static final String DIMENSION_COLUMN = "Dimension";
private static final String[] s_columnNames = {
FIELDNAME_COLUMN, FIELDDESC_COLUMN, FIELDTYPE_COLUMN, GEOMTYPE_COLUMN, DIMENSION_COLUMN };
private WeakReference appModel_; // Weak reference to the application class model object.
private EventListenerList listenerList_;
private java.util.Vector fieldDefList_; // List of FieldDescriptorCache objects.
private java.util.Hashtable fieldDefMap_; // Map of FieldDescriptorCache objects.
private java.util.Hashtable fieldTypeNameMap_; // Map between true and display field type names.
private java.util.Hashtable geomTypeNameMap_; // Map between true and display geometry type names.
//--------------------------------------------------------------------------
FieldDefinitionModel(ApplicationModel appModel)
{
try
{
appModel_ = new java.lang.ref.WeakReference(appModel);
fieldDefList_ = new java.util.Vector(5);
fieldDefMap_ = new java.util.Hashtable();
fieldTypeNameMap_ = new java.util.Hashtable();
geomTypeNameMap_ = new java.util.Hashtable();
// Create listener list.
listenerList_ = new EventListenerList();
// Initialise the field model.
String[] fieldList = getAppClassModel().getAppClassDescriptor().fields();
for (int i = 0; i <fieldList.length; i++)
{
IGeometricFieldDescriptorHolder fieldDescHolder = new IGeometricFieldDescriptorHolder();
getAppClassModel().getAppClassDescriptor().getField(fieldList[i], fieldDescHolder);
addField(fieldDescHolder.value);
}
// Initialise the field type name map.
String[] foamTypes = getAppClassModel().getFoamTypes();
for (int i = 0; i <foamTypes.length; i++)
{
ITypeDescriptor fieldType = getAppClassModel().getFoamType(foamTypes[i]);
fieldTypeNameMap_.put(foamTypes[i], fieldType.displayName());
fieldTypeNameMap_.put(fieldType.displayName(), foamTypes[i]);
}
// Initialise the geometry type name map.
String[] geometryTypes = getAppClassModel().getGeometryTypes();
for (int i = 0; i <geometryTypes.length; i++)
{
IGeometryDescriptor geomType = getAppClassModel().getGeometryType(geometryTypes[i]);
geomTypeNameMap_.put(geometryTypes[i], geomType.displayName());
geomTypeNameMap_.put(geomType.displayName(), geometryTypes[i]);
}
}
catch (FoamXIOError ioErr)
{
App.handleException(ioErr);
}
catch (FoamXError fxErr)
{
App.handleException(fxErr);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
void addField(IGeometricFieldDescriptor fieldDescriptor)
{
// Create a new field descriptor cache object and add to model.
FieldDescriptorCache fieldDesc = new FieldDescriptorCache(fieldDescriptor);
// Add to map and listy things.
fieldDefMap_.put(fieldDesc.getFieldName(), fieldDesc);
fieldDefList_.add(fieldDesc);
// Fire an event to update the table.
fireTableRowsInserted(fieldDefList_.size() - 1, fieldDefList_.size() - 1);
fireFieldAdded(fieldDesc.getFieldName());
}
//--------------------------------------------------------------------------
void addNewField()
{
try
{
// Create a name for the new field.
String fieldName = generateFieldName();
// Create a new field descriptor object.
IGeometricFieldDescriptorHolder fieldDescHolder = new IGeometricFieldDescriptorHolder();
getAppClassModel().getAppClassDescriptor().addField(fieldName, fieldDescHolder);
addField(fieldDescHolder.value);
}
catch (FoamXIOError ioErr)
{
App.handleException(ioErr);
}
catch (FoamXError fxErr)
{
App.handleException(fxErr);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
void removeField(int rowIndex)
{
try
{
// Remove field descriptor cache from application class, list and map.
FieldDescriptorCache fieldDesc = (FieldDescriptorCache)fieldDefList_.get(rowIndex);
getAppClassModel().getAppClassDescriptor().deleteField(fieldDesc.getFieldName());
fieldDefMap_.remove(fieldDesc.getFieldName());
fieldDefList_.remove(rowIndex);
// Fire an event to update the table.
fireTableRowsDeleted(rowIndex, rowIndex);
fireFieldRemoved(fieldDesc.getFieldName());
}
catch (FoamXIOError ioErr)
{
App.handleException(ioErr);
}
catch (FoamXError fxErr)
{
App.handleException(fxErr);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
FieldDescriptorCache getFieldDescriptor(int index)
{
FieldDescriptorCache fieldDesc = (FieldDescriptorCache)fieldDefList_.get(index);
return fieldDesc;
}
//--------------------------------------------------------------------------
void validate() throws ApplicationExeption
{
// Make sure at least one field is defined.
if (fieldDefList_.size() == 0)
{
throw new ApplicationExeption("Fields", "No Fields Defined.");
}
// Make sure all fields are properly defined.
Enumeration enum = fieldDefList_.elements();
while (enum.hasMoreElements())
{
FieldDescriptorCache fieldDesc = (FieldDescriptorCache)enum.nextElement();
if (fieldDesc.getFieldName().length() == 0) throw new ApplicationExeption("Fields", "Invalid Field Name.");
if (fieldDesc.getFieldDescription().length() == 0) throw new ApplicationExeption("Fields", "Invalid Field Description.");
if (fieldDesc.getFoamTypeName().length() == 0) throw new ApplicationExeption("Fields", "Invalid Field FoamXType.");
if (fieldDesc.getGeometryTypeName().length() == 0) throw new ApplicationExeption("Fields", "Invalid Field Geometry FoamXType.");
}
}
//--------------------------------------------------------------------------
void updateApplication(IApplication app)
{
try
{
// Update the field desriptor objects.
for (int i = 0; i <fieldDefList_.size(); i++)
{
FieldDescriptorCache fieldDesc = (FieldDescriptorCache)fieldDefList_.get(i);
fieldDesc.updateFieldDescriptor();
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
private ApplicationModel getAppClassModel()
{
return (ApplicationModel)appModel_.get();
}
//--------------------------------------------------------------------------
private String generateFieldName()
{
String fieldNameRoot = "Field";
String fieldName;
int i = fieldDefList_.size() + 1;
do
{
fieldName = fieldNameRoot + Integer.toString(i++);
}
while (fieldDefMap_.containsKey(fieldName));
return fieldName;
}
//--------------------------------------------------------------------------
//---- FieldModelListener Methods
//--------------------------------------------------------------------------
void addFieldModelListener(FieldModelListener l)
{
listenerList_.add(FieldModelListener.class, l);
}
//--------------------------------------------------------------------------
void removeFieldModelListener(FieldModelListener l)
{
listenerList_.remove(FieldModelListener.class, l);
}
//--------------------------------------------------------------------------
protected void fireFieldAdded(String fieldName)
{
// Create event object.
FieldModelEvent evt = new FieldModelEvent(this, fieldName);
// Process the listeners last to first, notifying those that are interested in this event.
Object[] listeners = listenerList_.getListenerList();
for (int i=listeners.length-2; i>= 0; i-=2)
{
if (listeners[i] == FieldModelListener.class)
{
((FieldModelListener)listeners[i+1]).fieldAdded(evt);
}
}
}
//--------------------------------------------------------------------------
protected void fireFieldRemoved(String fieldName)
{
// Create event object.
FieldModelEvent evt = new FieldModelEvent(this, fieldName);
// Process the listeners last to first, notifying those that are interested in this event.
Object[] listeners = listenerList_.getListenerList();
for (int i=listeners.length-2; i>= 0; i-=2)
{
if (listeners[i] == FieldModelListener.class)
{
((FieldModelListener)listeners[i+1]).fieldRemoved(evt);
}
}
}
//--------------------------------------------------------------------------
protected void fireFieldRenamed(String newName, String oldName)
{
// Create event object.
FieldModelEvent evt = new FieldModelEvent(this, newName, oldName);
// Process the listeners last to first, notifying those that are interested in this event.
Object[] listeners = listenerList_.getListenerList();
for (int i=listeners.length-2; i>= 0; i-=2)
{
if (listeners[i] == FieldModelListener.class)
{
((FieldModelListener)listeners[i+1]).fieldRenamed(evt);
}
}
}
//--------------------------------------------------------------------------
//---- AbstractTableModel methods
//--------------------------------------------------------------------------
public int getRowCount()
{
return fieldDefList_.size();
}
//--------------------------------------------------------------------------
public int getColumnCount()
{
return s_columnNames.length;
}
//--------------------------------------------------------------------------
public String getColumnName(int columnIndex)
{
return s_columnNames[columnIndex];
}
//--------------------------------------------------------------------------
public Class getColumnClass(int columnIndex)
{
// Check for dimension column.
if (columnIndex == DIMENSION_INDEX)
{
return DimensionSet.class;
}
// Everything else is of type String.
return String.class;
}
//--------------------------------------------------------------------------
public boolean isCellEditable(int rowIndex, int columnIndex)
{
// All columns are editable
return true;
}
//--------------------------------------------------------------------------
public Object getValueAt(int rowIndex, int columnIndex)
{
FieldDescriptorCache fieldDesc = (FieldDescriptorCache)fieldDefList_.get(rowIndex);
switch (columnIndex)
{
case FIELDNAME_INDEX:
return fieldDesc.getFieldName();
case FIELDDESC_INDEX:
return fieldDesc.getFieldDescription();
case FIELDTYPE_INDEX:
// Convert from the true type name to the display type name.
String typeName = (String)fieldTypeNameMap_.get(fieldDesc.getFoamTypeName());
return typeName;
case GEOMTYPE_INDEX:
// Convert from the true geometry name to the display geometry name.
String geomName = (String)geomTypeNameMap_.get(fieldDesc.getGeometryTypeName());
return geomName;
case DIMENSION_INDEX:
return fieldDesc.getFieldDimensions();
default:
// Bugger and damnation.
break;
}
return null;
}
//--------------------------------------------------------------------------
public void setValueAt(Object aValue, int rowIndex, int columnIndex)
{
FieldDescriptorCache fieldDesc = (FieldDescriptorCache)fieldDefList_.get(rowIndex);
switch (columnIndex)
{
case FIELDNAME_INDEX:
String oldName = fieldDesc.getFieldName();
String newName = (String)aValue;
if (!oldName.equals(newName))
{
fireFieldRenamed(newName, oldName);
}
fieldDesc.setFieldName((String)aValue); // Change name.
fireTableDataChanged();
break;
case FIELDDESC_INDEX:
fieldDesc.setFieldDescription((String)aValue);
fireTableDataChanged();
break;
case FIELDTYPE_INDEX:
// Convert from the display type name to the true type name.
String typeName = (String)fieldTypeNameMap_.get((String)aValue);
fieldDesc.setFieldTypeName(typeName);
fireTableDataChanged();
break;
case GEOMTYPE_INDEX:
// Convert from the display geometry name to the true geometry name.
String geomName = (String)geomTypeNameMap_.get((String)aValue);
fieldDesc.setGeometryTypeName(geomName);
fireTableDataChanged();
break;
case DIMENSION_INDEX:
fieldDesc.setFieldDimensions((DimensionSet)aValue);
fireTableDataChanged();
break;
default:
// Bugger.
break;
}
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,136 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.ApplicationEditor;
import FoamX.App;
import FoamXServer.CaseServer.IGeometricFieldDescriptor;
import FoamXServer.DimensionSet;
public class FieldDescriptorCache
extends Object
{
//--------------------------------------------------------------------------
private IGeometricFieldDescriptor fieldDescriptor_;
private String fieldName_;
private String fieldDescription_;
private String fieldTypeName_;
private String geometryTypeName_;
private DimensionSet fieldDimension_;
//--------------------------------------------------------------------------
/** FieldDescriptorCache constructor. */
public FieldDescriptorCache(IGeometricFieldDescriptor fieldDescriptor)
{
try
{
fieldDescriptor_ = fieldDescriptor;
fieldName_ = fieldDescriptor_.name();
fieldDescription_ = fieldDescriptor_.description();
fieldTypeName_ = fieldDescriptor_.fieldTypeName(); // True field type name.
geometryTypeName_ = fieldDescriptor_.geometryTypeName(); // True geometry type name.
fieldDimension_ = fieldDescriptor_.dimensions();
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
public String getFieldName()
{
return fieldName_;
}
public String getFieldDescription()
{
return fieldDescription_;
}
public String getFoamTypeName()
{
return fieldTypeName_;
}
public String getGeometryTypeName()
{
return geometryTypeName_;
}
public DimensionSet getFieldDimensions()
{
return fieldDimension_;
}
public void setFieldName(String fieldName)
{
fieldName_ = fieldName.trim();
}
public void setFieldDescription(String fieldDescription)
{
fieldDescription_ = fieldDescription.trim();
}
public void setFieldTypeName(String fieldTypeName)
{
fieldTypeName_ = fieldTypeName.trim();
}
public void setGeometryTypeName(String geometryTypeName)
{
geometryTypeName_ = geometryTypeName.trim();
}
public void setFieldDimensions(DimensionSet fieldDimension)
{
fieldDimension_ = fieldDimension;
}
//--------------------------------------------------------------------------
/**
* Update the cached IGeometricFieldDescriptor object.
*/
public void updateFieldDescriptor()
{
try
{
// Update the IGeometricFieldDescriptor object.
fieldDescriptor_.name(fieldName_);
fieldDescriptor_.description(fieldDescription_);
fieldDescriptor_.fieldTypeName(fieldTypeName_);
fieldDescriptor_.geometryTypeName(geometryTypeName_);
fieldDescriptor_.dimensions(fieldDimension_);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,285 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.ApplicationEditor;
import java.awt.Component;
import java.awt.event.*;
import java.awt.AWTEvent;
import java.text.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import java.util.EventObject;
import FoamX.App;
import FoamX.Util.FoamXAny;
import FoamX.Editors.DictionaryEntryEditor.DictionaryEntryCompoundPanel;
import FoamX.Editors.DimensionSetEditor;
import FoamXServer.DimensionSet;
public class FieldDimensionCellEditor
implements TableCellEditor
{
//--------------------------------------------------------------------------
protected DimensionSet dimensionSet_; // DimensionSet object being edited.
protected DictionaryEntryCompoundPanel panel_;
protected EventListenerList listenerList_;
transient protected ChangeEvent changeEvent_;
transient protected ActionEvent actionEvent_;
//--------------------------------------------------------------------------
/** FieldDimensionCellEditor constructor. */
public FieldDimensionCellEditor()
{
dimensionSet_ = null;
panel_ = new DictionaryEntryCompoundPanel();
listenerList_ = new EventListenerList();
// Subscribe to the edit button's action event so that we can forward
// the event to the action event listeners of this object.
panel_.EditButton().addActionListener
(
new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
editButtonActionPerformed(evt);
}
}
);
}
//--------------------------------------------------------------------------
// TableCellEditor interface functions.
//--------------------------------------------------------------------------
/** Implementation of TableCellEditor interface's getTableCellEditorComponent function. */
public Component getTableCellEditorComponent
(
JTable table,
Object value,
boolean isSelected,
int row,
int column
)
{
try
{
dimensionSet_ = (DimensionSet)value;
// Set the panel text.
setPanelText();
// Make sure the label is rendered properly.
if (isSelected)
{
panel_.Label().setForeground(table.getSelectionForeground());
panel_.Label().setBackground(table.getSelectionBackground());
} else {
panel_.Label().setForeground(table.getForeground());
panel_.Label().setBackground(table.getBackground());
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return panel_;
}
//--------------------------------------------------------------------------
private void setPanelText()
{
if (dimensionSet_ != null)
{
// Set the panel text.
panel_.Label().setText(FoamXAny.format(dimensionSet_));
}
}
//--------------------------------------------------------------------------
// CellEditor interface functions.
//--------------------------------------------------------------------------
public Object getCellEditorValue()
{
return dimensionSet_;
}
//--------------------------------------------------------------------------
public boolean stopCellEditing()
{
fireEditingStopped();
return true;
}
//--------------------------------------------------------------------------
public void cancelCellEditing()
{
fireEditingCanceled();
}
//--------------------------------------------------------------------------
public boolean isCellEditable(EventObject anEvent)
{
return true;
}
//--------------------------------------------------------------------------
public boolean shouldSelectCell(EventObject anEvent)
{
if (panel_ != null && anEvent instanceof MouseEvent &&
((MouseEvent)anEvent).getID() == MouseEvent.MOUSE_PRESSED)
{
Component dispatchComponent = SwingUtilities.getDeepestComponentAt(panel_, 3, 3);
MouseEvent e = (MouseEvent)anEvent;
MouseEvent e2 = new MouseEvent(dispatchComponent, MouseEvent.MOUSE_RELEASED,
e.getWhen() + 100000, e.getModifiers(), 3, 3, e.getClickCount(),
e.isPopupTrigger());
dispatchComponent.dispatchEvent(e2);
e2 = new MouseEvent(dispatchComponent, MouseEvent.MOUSE_CLICKED,
e.getWhen() + 100001, e.getModifiers(), 3, 3, 1,
e.isPopupTrigger());
dispatchComponent.dispatchEvent(e2);
}
return false;
}
//--------------------------------------------------------------------------
public void addCellEditorListener(CellEditorListener l)
{
listenerList_.add(CellEditorListener.class, l);
}
//--------------------------------------------------------------------------
public void removeCellEditorListener(CellEditorListener l)
{
listenerList_.remove(CellEditorListener.class, l);
}
//--------------------------------------------------------------------------
protected void fireEditingStopped()
{
Object[] listeners = listenerList_.getListenerList();
// Process the listeners last to first, notifying those that are interested in this event.
for (int i=listeners.length-2; i>= 0; i-=2)
{
if (listeners[i] == CellEditorListener.class)
{
// Lazily create the event:
if (changeEvent_ == null)
{
changeEvent_ = new ChangeEvent(this);
}
((CellEditorListener)listeners[i+1]).editingStopped(changeEvent_);
}
}
}
//--------------------------------------------------------------------------
protected void fireEditingCanceled()
{
// Guaranteed to return a non-null array
Object[] listeners = listenerList_.getListenerList();
// Process the listeners last to first, notifying those that are interested in this event.
for (int i=listeners.length-2; i>= 0; i-=2)
{
if (listeners[i] == CellEditorListener.class)
{
// Lazily create the event:
if (changeEvent_ == null)
{
changeEvent_ = new ChangeEvent(this);
}
((CellEditorListener)listeners[i+1]).editingCanceled(changeEvent_);
}
}
}
//--------------------------------------------------------------------------
public void addActionListener(ActionListener l)
{
listenerList_.add(ActionListener.class, l);
}
//--------------------------------------------------------------------------
public void removeActionListener(ActionListener l)
{
listenerList_.remove(ActionListener.class, l);
}
//--------------------------------------------------------------------------
protected void fireEditActionEvent()
{
Object[] listeners = listenerList_.getListenerList();
// Process the listeners last to first, notifying those that are interested in this event.
for (int i=listeners.length-2; i>= 0; i-=2)
{
if (listeners[i] == ActionListener.class)
{
// Lazily create the event:
if (actionEvent_ == null)
{
actionEvent_ = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "");
}
// Fire the event.
((ActionListener)listeners[i+1]).actionPerformed(actionEvent_);
}
}
}
//--------------------------------------------------------------------------
private void editButtonActionPerformed(java.awt.event.ActionEvent evt)
{
// Show the DimensionSet editor dialog.
DimensionSetEditor dlg = new DimensionSetEditor(null, dimensionSet_);
dlg.show();
// Update the panel text.
setPanelText();
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,85 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.ApplicationEditor;
import java.text.*;
import java.awt.Component;
import javax.swing.JTable;
import javax.swing.table.*;
import FoamX.App;
import FoamX.Util.FoamXAny;
import FoamXServer.DimensionSet;
public class FieldDimensionCellRenderer
extends DefaultTableCellRenderer
{
//--------------------------------------------------------------------------
/** FieldDimensionCellRenderer constructor. */
public FieldDimensionCellRenderer()
{}
//--------------------------------------------------------------------------
public Component getTableCellRendererComponent
(
JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column
)
{
Component comp = null;
try
{
comp = super.getTableCellRendererComponent
(
table,
FoamXAny.format((DimensionSet)value),
isSelected,
hasFocus,
row,
column
);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return comp;
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,66 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.ApplicationEditor;
public class FieldModelEvent
extends java.util.EventObject
{
protected String fieldName_;
protected String oldFieldName_;
/** FieldModelEvent constructor. */
public FieldModelEvent(Object source, String fieldName)
{
super(source);
fieldName_ = fieldName;
oldFieldName_ = "";
}
public FieldModelEvent(Object source, String fieldName, String oldFieldName)
{
super(source);
fieldName_ = fieldName;
oldFieldName_ = oldFieldName;
}
public String toString()
{
return "FieldModelEvent : " + fieldName_;
}
public String getFieldName()
{
return fieldName_;
}
public String getOldFieldName()
{
return oldFieldName_;
}
}

View File

@ -0,0 +1,38 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.ApplicationEditor;
public interface FieldModelListener
extends java.util.EventListener
{
public abstract void fieldAdded(FieldModelEvent evt);
public abstract void fieldRemoved(FieldModelEvent evt);
public abstract void fieldRenamed(FieldModelEvent evt);
}

View File

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<SyntheticProperties>
</SyntheticProperties>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="subPanel_">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="18" fill="1" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="10" insetsLeft="10" insetsRight="10" insetsTop="10" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="scrollPane_">
<Properties>
<Property name="autoscrolls" type="boolean" value="true"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="18" fill="1" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTable" name="table_">
<Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code=" appClassModel_.getFieldDefinitionModel() " type="code"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="buttonPanel_">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="12" fill="0" gridHeight="1" gridWidth="1" gridX="1" gridY="0" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
<Property name="axis" type="int" value="1"/>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="addButton_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="Add"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="removeButton_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="Remove"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@ -0,0 +1,294 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.ApplicationEditor;
import java.awt.event.ActionEvent;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.ListSelectionEvent;
import FoamX.App;
import FoamXServer.CaseServer.IGeometryDescriptor;
import FoamXServer.ITypeDescriptor;
public class FieldsTab
extends javax.swing.JPanel
{
//--------------------------------------------------------------------------
private static final int DEFAULT_WIDTH = 400;
private ApplicationModel appModel_;
private DefaultCellEditor stringEditor_;
private DefaultCellEditor fieldTypeEditor_;
private DefaultCellEditor geometryTypeEditor_;
private FieldDimensionCellEditor dimensionEditor_;
private FieldDimensionCellRenderer dimensionRenderer_;
private AddFieldAction addFieldAction_;
private DeleteFieldAction deleteFieldAction_;
//--------------------------------------------------------------------------
/** Constructor for PatchPhysicalTypePanel. */
public FieldsTab(ApplicationModel appModel)
{
try
{
appModel_ = appModel;
// Initialise the gui.
initComponents();
// Resize table to show the defined rows only.
int height = (table_.getRowHeight() + table_.getRowMargin()) *
(appModel_.getFieldDefinitionModel().getRowCount() + 1); // Add an extra row to account for the header control.
table_.setPreferredScrollableViewportSize(new java.awt.Dimension(DEFAULT_WIDTH, height));
// Initialise the field type, geometry type and dimension editors.
JComboBox fieldTypeCombo = new JComboBox();
fieldTypeCombo.setFont(table_.getFont()); // Use same font as table.
String[] foamTypes = appModel_.getFoamTypes();
for (int i = 0; i <foamTypes.length; i++)
{
ITypeDescriptor fieldType = appModel_.getFoamType(foamTypes[i]);
fieldTypeCombo.addItem(fieldType.displayName());
}
JComboBox geomTypeCombo = new JComboBox();
geomTypeCombo.setFont(table_.getFont()); // Use same font as table.
String[] geomTypes = appModel_.getGeometryTypes();
for (int i = 0; i <geomTypes.length; i++)
{
IGeometryDescriptor geomType = appModel_.getGeometryType(geomTypes[i]);
geomTypeCombo.addItem(geomType.displayName());
}
stringEditor_ = new DefaultCellEditor(new JTextField());
fieldTypeEditor_ = new DefaultCellEditor(fieldTypeCombo);
geometryTypeEditor_ = new DefaultCellEditor(geomTypeCombo);
dimensionEditor_ = new FieldDimensionCellEditor();
// Set cell editor for each column.
table_.getColumn(FieldDefinitionModel.FIELDNAME_COLUMN).setCellEditor(stringEditor_);
table_.getColumn(FieldDefinitionModel.FIELDDESC_COLUMN).setCellEditor(stringEditor_);
table_.getColumn(FieldDefinitionModel.FIELDTYPE_COLUMN).setCellEditor(fieldTypeEditor_);
table_.getColumn(FieldDefinitionModel.GEOMTYPE_COLUMN).setCellEditor(geometryTypeEditor_);
table_.getColumn(FieldDefinitionModel.DIMENSION_COLUMN).setCellEditor(dimensionEditor_);
// Set cell renderer for dimension column.
dimensionRenderer_ = new FieldDimensionCellRenderer();
table_.getColumn(FieldDefinitionModel.DIMENSION_COLUMN).setCellRenderer(dimensionRenderer_);
// Setup the selection listener.
table_.getSelectionModel().addListSelectionListener
(
new ListSelectionListener()
{
public void valueChanged(ListSelectionEvent evt)
{
if (!table_.getSelectionModel().isSelectionEmpty())
{
deleteFieldAction_.setEnabled(true);
} else {
deleteFieldAction_.setEnabled(false);
}
}
}
);
// Initialise actions and connect to buttons.
addFieldAction_ = new AddFieldAction();
deleteFieldAction_ = new DeleteFieldAction();
addButton_.addActionListener(addFieldAction_);
//? addFieldAction_.addPropertyChangeListener(new ButtonActionChangedListener(addButton_));
removeButton_.addActionListener(deleteFieldAction_);
//? deleteFieldAction_.addPropertyChangeListener(new ButtonActionChangedListener(removeButton_));
deleteFieldAction_.setEnabled(false);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
public void updateModel()
{
// No update here - App class model extracts info from field model.
}
//--------------------------------------------------------------------------
/**
* 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 FormEditor.
*/
private void initComponents() {//GEN-BEGIN:initComponents
subPanel_ = new javax.swing.JPanel();
scrollPane_ = new javax.swing.JScrollPane();
table_ = new javax.swing.JTable();
buttonPanel_ = new javax.swing.JPanel();
addButton_ = new javax.swing.JButton();
removeButton_ = new javax.swing.JButton();
setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints1;
subPanel_.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints2;
scrollPane_.setAutoscrolls(true);
table_.setModel( appModel_.getFieldDefinitionModel() );
table_.setFont(new java.awt.Font("Dialog", 0, 10));
scrollPane_.setViewportView(table_);
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints2.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints2.weightx = 1.0;
gridBagConstraints2.weighty = 1.0;
subPanel_.add(scrollPane_, gridBagConstraints2);
buttonPanel_.setLayout(new javax.swing.BoxLayout(buttonPanel_, javax.swing.BoxLayout.Y_AXIS));
addButton_.setFont(new java.awt.Font("Dialog", 0, 10));
addButton_.setText("Add");
addButton_.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
buttonPanel_.add(addButton_);
removeButton_.setFont(new java.awt.Font("Dialog", 0, 10));
removeButton_.setText("Remove");
removeButton_.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
buttonPanel_.add(removeButton_);
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 1;
gridBagConstraints2.gridy = 0;
gridBagConstraints2.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHEAST;
subPanel_.add(buttonPanel_, gridBagConstraints2);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints1.insets = new java.awt.Insets(10, 10, 10, 10);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints1.weightx = 1.0;
gridBagConstraints1.weighty = 1.0;
add(subPanel_, gridBagConstraints1);
}//GEN-END:initComponents
//--------------------------------------------------------------------------
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel subPanel_;
private javax.swing.JScrollPane scrollPane_;
private javax.swing.JTable table_;
private javax.swing.JPanel buttonPanel_;
private javax.swing.JButton addButton_;
private javax.swing.JButton removeButton_;
// End of variables declaration//GEN-END:variables
//--------------------------------------------------------------------------
class AddFieldAction
extends AbstractAction
{
AddFieldAction()
{
putValue(Action.SMALL_ICON, App.getResources().getIcon("AddFieldImage"));
putValue(Action.NAME, "Add Field");
putValue(Action.SHORT_DESCRIPTION, "Add Field");
putValue(Action.LONG_DESCRIPTION, "Add Field");
}
public void actionPerformed(ActionEvent e)
{
try
{
// Add a new field to the table. Easy-Peasy-Lemon-Squeezy.
appModel_.getFieldDefinitionModel().addNewField();
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
}
//--------------------------------------------------------------------------
class DeleteFieldAction
extends AbstractAction
{
DeleteFieldAction()
{
putValue(Action.NAME, "Delete Field");
putValue(Action.SMALL_ICON, App.getResources().getIcon("DeleteFieldImage"));
putValue(Action.SHORT_DESCRIPTION, "Delete Field");
putValue(Action.LONG_DESCRIPTION, "Delete Field");
}
public void actionPerformed(ActionEvent e)
{
// Delete the selected dictionary entry.
try
{
// Remove the selected field.
if (!table_.getSelectionModel().isSelectionEmpty())
{
int minIndex = table_.getSelectionModel().getMinSelectionIndex();
int maxIndex = table_.getSelectionModel().getMaxSelectionIndex();
// Need to remove from the top so that it doesn't get its knickers in a twist.
for (int i=maxIndex; i>= minIndex; i--)
{
appModel_.getFieldDefinitionModel().removeField(i);
}
table_.getSelectionModel().clearSelection();
deleteFieldAction_.setEnabled(false);
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,182 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
<SyntheticProperties>
</SyntheticProperties>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="availableModulesPanel_">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Available Modules">
<Font PropertyName="font" name="Dialog" size="10" style="0"/>
<Color PropertyName="color" blue="0" green="0" id="black" palette="0" red="0" type="palette"/>
</TitledBorder>
</Border>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="17" fill="1" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="10" insetsLeft="10" insetsRight="10" insetsTop="10" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="leftScrollPane_">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="10" fill="1" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JList" name="availableModulesList_">
<Properties>
<Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="availableModulesListModel_" type="code"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="buttonPanel_">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="10" fill="0" gridHeight="1" gridWidth="1" gridX="1" gridY="0" insetsBottom="10" insetsLeft="0" insetsRight="0" insetsTop="10" ipadX="0" ipadY="0" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Component class="javax.swing.JButton" name="addModuleButton_">
<Properties>
<Property name="toolTipText" type="java.lang.String" value="Add module"/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="&gt;"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="addModuleButtonActionPerformed_"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="10" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="5" insetsLeft="10" insetsRight="10" insetsTop="10" ipadX="0" ipadY="0" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JButton" name="addAllModulesButton_">
<Properties>
<Property name="toolTipText" type="java.lang.String" value="Add all modules"/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="&gt;&gt;"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="addAllModulesButtonActionPerformed_"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="10" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="1" insetsBottom="5" insetsLeft="10" insetsRight="10" insetsTop="5" ipadX="0" ipadY="0" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JButton" name="removeModuleButton_">
<Properties>
<Property name="toolTipText" type="java.lang.String" value="Remove module"/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="&lt;"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="removeModuleButtonActionPerformed_"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="10" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="2" insetsBottom="5" insetsLeft="10" insetsRight="10" insetsTop="25" ipadX="0" ipadY="0" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JButton" name="removeAllModulesButton_">
<Properties>
<Property name="toolTipText" type="java.lang.String" value="Remove all modules"/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="&lt;&lt;"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="removeAllModulesButtonActionPerformed_"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="10" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="3" insetsBottom="10" insetsLeft="10" insetsRight="10" insetsTop="5" ipadX="0" ipadY="0" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="selectedModulesPanel_">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Required Modules">
<Font PropertyName="font" name="Dialog" size="10" style="0"/>
<Color PropertyName="color" blue="0" green="0" id="black" palette="0" red="0" type="palette"/>
</TitledBorder>
</Border>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="13" fill="1" gridHeight="1" gridWidth="1" gridX="2" gridY="0" insetsBottom="10" insetsLeft="10" insetsRight="10" insetsTop="10" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="rightScrollPane_">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="10" fill="1" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JList" name="selectedModulesList_">
<Properties>
<Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="selectedModulesListModel_" type="code"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@ -0,0 +1,400 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.ApplicationEditor;
import java.util.Vector;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.DefaultListModel;
import FoamX.App;
public class ModulesTab
extends javax.swing.JPanel
{
//--------------------------------------------------------------------------
private ApplicationModel appModel_;
private DefaultListModel availableModulesListModel_;
private DefaultListModel selectedModulesListModel_;
//--------------------------------------------------------------------------
/** Constructor for ModulesTab. */
public ModulesTab(ApplicationModel appModel)
{
try
{
appModel_ = appModel;
availableModulesListModel_ = new DefaultListModel();
selectedModulesListModel_ = new DefaultListModel();
// Initialise the list of selected modules.
Vector appModules = appModel_.getAppModules();
for (int i=0; i <appModules.size(); i++)
{
selectedModulesListModel_.addElement(new ModuleDescriptor((String)appModules.get(i)));
}
// Initialise the list of available modules.
String[] modules = appModel_.getAvailableModules();
for (int i=0; i <modules.length; i++)
{
if (!appModules.contains(modules[i]))
{
availableModulesListModel_.addElement(new ModuleDescriptor(modules[i]));
}
}
initComponents();
// Setup listeners for add/remove buttons.
availableModulesList_.getSelectionModel().addListSelectionListener
(
new ListSelectionListener()
{
public void valueChanged(ListSelectionEvent evt)
{
updateButtons();
}
}
);
selectedModulesList_.getSelectionModel().addListSelectionListener
(
new ListSelectionListener()
{
public void valueChanged(ListSelectionEvent evt)
{
updateButtons();
}
}
);
// Set initial button state.
updateButtons();
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
public void updateModel()
{
// Update the application modules vector.
Vector modules = appModel_.getAppModules();
modules.removeAllElements();
for (int i=0; i <selectedModulesListModel_.getSize(); i++)
{
ModuleDescriptor moduleDesc = (ModuleDescriptor)selectedModulesListModel_.getElementAt(i);
modules.add(i, moduleDesc.getModuleName());
}
}
//--------------------------------------------------------------------------
private void updateButtons()
{
addModuleButton_.setEnabled(!availableModulesList_.getSelectionModel().isSelectionEmpty());
removeModuleButton_.setEnabled(!selectedModulesList_.getSelectionModel().isSelectionEmpty());
addAllModulesButton_.setEnabled(availableModulesListModel_.size()> 0);
removeAllModulesButton_.setEnabled(selectedModulesListModel_.size()> 0);
}
//--------------------------------------------------------------------------
/**
* 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 FormEditor.
*/
private void initComponents() {//GEN-BEGIN:initComponents
availableModulesPanel_ = new javax.swing.JPanel();
leftScrollPane_ = new javax.swing.JScrollPane();
availableModulesList_ = new javax.swing.JList();
buttonPanel_ = new javax.swing.JPanel();
addModuleButton_ = new javax.swing.JButton();
addAllModulesButton_ = new javax.swing.JButton();
removeModuleButton_ = new javax.swing.JButton();
removeAllModulesButton_ = new javax.swing.JButton();
selectedModulesPanel_ = new javax.swing.JPanel();
rightScrollPane_ = new javax.swing.JScrollPane();
selectedModulesList_ = new javax.swing.JList();
setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints1;
setFont(new java.awt.Font("Dialog", 0, 10));
availableModulesPanel_.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints2;
availableModulesPanel_.setBorder(new javax.swing.border.TitledBorder(null, "Available Modules", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 0, 10), java.awt.Color.black));
availableModulesList_.setModel(availableModulesListModel_);
availableModulesList_.setFont(new java.awt.Font("Dialog", 0, 10));
leftScrollPane_.setViewportView(availableModulesList_);
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints2.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints2.weightx = 1.0;
gridBagConstraints2.weighty = 1.0;
availableModulesPanel_.add(leftScrollPane_, gridBagConstraints2);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints1.insets = new java.awt.Insets(10, 10, 10, 10);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints1.weightx = 1.0;
gridBagConstraints1.weighty = 1.0;
add(availableModulesPanel_, gridBagConstraints1);
buttonPanel_.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints3;
addModuleButton_.setToolTipText("Add module");
addModuleButton_.setFont(new java.awt.Font("Dialog", 0, 10));
addModuleButton_.setText(">");
addModuleButton_.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
addModuleButtonActionPerformed_(evt);
}
});
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 0;
gridBagConstraints3.gridy = 0;
gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints3.insets = new java.awt.Insets(10, 10, 5, 10);
buttonPanel_.add(addModuleButton_, gridBagConstraints3);
addAllModulesButton_.setToolTipText("Add all modules");
addAllModulesButton_.setFont(new java.awt.Font("Dialog", 0, 10));
addAllModulesButton_.setText(">>");
addAllModulesButton_.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
addAllModulesButtonActionPerformed_(evt);
}
});
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 0;
gridBagConstraints3.gridy = 1;
gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints3.insets = new java.awt.Insets(5, 10, 5, 10);
buttonPanel_.add(addAllModulesButton_, gridBagConstraints3);
removeModuleButton_.setToolTipText("Remove module");
removeModuleButton_.setFont(new java.awt.Font("Dialog", 0, 10));
removeModuleButton_.setText("<");
removeModuleButton_.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
removeModuleButtonActionPerformed_(evt);
}
});
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 0;
gridBagConstraints3.gridy = 2;
gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints3.insets = new java.awt.Insets(25, 10, 5, 10);
buttonPanel_.add(removeModuleButton_, gridBagConstraints3);
removeAllModulesButton_.setToolTipText("Remove all modules");
removeAllModulesButton_.setFont(new java.awt.Font("Dialog", 0, 10));
removeAllModulesButton_.setText("<<");
removeAllModulesButton_.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
removeAllModulesButtonActionPerformed_(evt);
}
});
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 0;
gridBagConstraints3.gridy = 3;
gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints3.insets = new java.awt.Insets(5, 10, 10, 10);
buttonPanel_.add(removeAllModulesButton_, gridBagConstraints3);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 1;
gridBagConstraints1.gridy = 0;
gridBagConstraints1.insets = new java.awt.Insets(10, 0, 10, 0);
add(buttonPanel_, gridBagConstraints1);
selectedModulesPanel_.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints4;
selectedModulesPanel_.setBorder(new javax.swing.border.TitledBorder(null, "Required Modules", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 0, 10), java.awt.Color.black));
selectedModulesList_.setModel(selectedModulesListModel_);
selectedModulesList_.setFont(new java.awt.Font("Dialog", 0, 10));
rightScrollPane_.setViewportView(selectedModulesList_);
gridBagConstraints4 = new java.awt.GridBagConstraints();
gridBagConstraints4.gridx = 0;
gridBagConstraints4.gridy = 0;
gridBagConstraints4.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints4.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints4.weightx = 1.0;
gridBagConstraints4.weighty = 1.0;
selectedModulesPanel_.add(rightScrollPane_, gridBagConstraints4);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 2;
gridBagConstraints1.gridy = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints1.insets = new java.awt.Insets(10, 10, 10, 10);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.EAST;
gridBagConstraints1.weightx = 1.0;
gridBagConstraints1.weighty = 1.0;
add(selectedModulesPanel_, gridBagConstraints1);
}//GEN-END:initComponents
//--------------------------------------------------------------------------
private void removeAllModulesButtonActionPerformed_ (java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_removeAllModulesButtonActionPerformed_
// Remove all modules.
for (int i = 0; i <selectedModulesListModel_.size(); i++)
{
ModuleDescriptor moduleDesc = (ModuleDescriptor)selectedModulesListModel_.getElementAt(i);
availableModulesListModel_.addElement(moduleDesc);
}
selectedModulesListModel_.removeAllElements();
updateButtons();
}//GEN-LAST:event_removeAllModulesButtonActionPerformed_
//--------------------------------------------------------------------------
private void removeModuleButtonActionPerformed_ (java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_removeModuleButtonActionPerformed_
// Remove the selected module and add back into available list.
if (!selectedModulesList_.getSelectionModel().isSelectionEmpty())
{
int minIndex = selectedModulesList_.getSelectionModel().getMinSelectionIndex();
int maxIndex = selectedModulesList_.getSelectionModel().getMaxSelectionIndex();
// Need to remove from the top so that it doesn't get its knickers in a twist.
for (int i=maxIndex; i>= minIndex; i--)
{
ModuleDescriptor moduleDesc = (ModuleDescriptor)selectedModulesListModel_.getElementAt(i);
selectedModulesListModel_.removeElementAt(i);
availableModulesListModel_.addElement(moduleDesc);
}
}
selectedModulesList_.getSelectionModel().clearSelection();
updateButtons();
}//GEN-LAST:event_removeModuleButtonActionPerformed_
//--------------------------------------------------------------------------
private void addAllModulesButtonActionPerformed_ (java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_addAllModulesButtonActionPerformed_
// Add all modules.
for (int i = 0; i <availableModulesListModel_.size(); i++)
{
ModuleDescriptor moduleDesc = (ModuleDescriptor)availableModulesListModel_.getElementAt(i);
selectedModulesListModel_.addElement(moduleDesc);
}
availableModulesListModel_.removeAllElements();
updateButtons();
}//GEN-LAST:event_addAllModulesButtonActionPerformed_
//--------------------------------------------------------------------------
private void addModuleButtonActionPerformed_ (java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_addModuleButtonActionPerformed_
// Add the selected module.
if (!availableModulesList_.getSelectionModel().isSelectionEmpty())
{
int minIndex = availableModulesList_.getSelectionModel().getMinSelectionIndex();
int maxIndex = availableModulesList_.getSelectionModel().getMaxSelectionIndex();
// Need to remove from the top so that it doesn't get its knickers in a twist.
for (int i=maxIndex; i>= minIndex; i--)
{
ModuleDescriptor moduleDesc = (ModuleDescriptor)availableModulesListModel_.getElementAt(i);
availableModulesListModel_.removeElementAt(i);
selectedModulesListModel_.addElement(moduleDesc);
}
}
availableModulesList_.getSelectionModel().clearSelection();
updateButtons();
}//GEN-LAST:event_addModuleButtonActionPerformed_
//--------------------------------------------------------------------------
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel availableModulesPanel_;
private javax.swing.JScrollPane leftScrollPane_;
private javax.swing.JList availableModulesList_;
private javax.swing.JPanel buttonPanel_;
private javax.swing.JButton addModuleButton_;
private javax.swing.JButton addAllModulesButton_;
private javax.swing.JButton removeModuleButton_;
private javax.swing.JButton removeAllModulesButton_;
private javax.swing.JPanel selectedModulesPanel_;
private javax.swing.JScrollPane rightScrollPane_;
private javax.swing.JList selectedModulesList_;
// End of variables declaration//GEN-END:variables
//--------------------------------------------------------------------------
private class ModuleDescriptor
{
private String moduleName_;
public ModuleDescriptor(String moduleName)
{
moduleName_ = moduleName;
}
public String toString()
{
return moduleName_;
}
public String getModuleName()
{
return moduleName_;
}
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,417 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.ApplicationEditor;
import java.net.URL;
import java.util.Hashtable;
import java.awt.Component;
import java.awt.event.ActionEvent;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import FoamX.App;
import FoamX.Util.FoamXTreeRenderer;
public class PatchPhysicalTypesTab
extends javax.swing.JPanel
{
//--------------------------------------------------------------------------
private BoundaryDefinitionModel boundaryDefinitionModel_;
private BoundaryDefinitionPanel boundaryDefinitionPanel_;
private AddPatchPhysicalTypeAction addPatchPhysicalTypeAction_;
private DeletePatchPhysicalTypeAction deletePatchPhysicalTypeAction_;
//--------------------------------------------------------------------------
/** Constructor for DictionaryPanel. */
public PatchPhysicalTypesTab(ApplicationModel appModel)
{
try
{
boundaryDefinitionModel_ = appModel.getBoundaryDefinitionModel();
boundaryDefinitionPanel_ = new BoundaryDefinitionPanel(appModel);
// Initialise the gui.
initComponents();
// Set tree renderer.
tree_.setCellRenderer(new FoamXTreeRenderer());
tree_.putClientProperty("JTree.lineStyle", "Angled");
// Set single selection mode.
tree_.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
// Listen out for tree node selection events.
tree_.getSelectionModel().addTreeSelectionListener
(
new TreeSelectionListener()
{
public void valueChanged(TreeSelectionEvent evt)
{
OnSelectionChanged(evt);
}
}
);
// Make sure the tree is displayed properly.
tree_.updateUI();
// Initialise the toolbar. Create a button for each action.
addPatchPhysicalTypeAction_ = new AddPatchPhysicalTypeAction();
deletePatchPhysicalTypeAction_ = new DeletePatchPhysicalTypeAction();
addToolbarButton(addPatchPhysicalTypeAction_);
addToolbarButton(deletePatchPhysicalTypeAction_);
// Initialise actions
addPatchPhysicalTypeAction_.setEnabled(false);
deletePatchPhysicalTypeAction_.setEnabled(false);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
private void addToolbarButton(Action action)
{
// Add new button to the toolbar using the action object.
javax.swing.JButton button = toolbar_.add(action);
// Set the tooltip text.
button.setToolTipText((String)action.getValue(Action.SHORT_DESCRIPTION));
button.setText("");
button.setFont(toolbar_.getFont()); // Use same font as toolbar.
}
//--------------------------------------------------------------------------
public void updateModel()
{
}
//--------------------------------------------------------------------------
private String getNewBoundaryDefinitionName()
{
// Prompt user for a new Boundary Definition name.
return (String)JOptionPane.showInputDialog(this,
"Enter New Boundary Definition Name",
"Boundary Definition Name",
JOptionPane.PLAIN_MESSAGE, null, null, null);
}
//--------------------------------------------------------------------------
/**
* 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 FormEditor.
*/
private void initComponents() {//GEN-BEGIN:initComponents
contextMenu_ = new javax.swing.JPopupMenu();
subPanel_ = new javax.swing.JPanel();
splitPane_ = new javax.swing.JSplitPane();
scrollPaneRight_ = new javax.swing.JScrollPane();
leftPanel_ = new javax.swing.JPanel();
buttonPanel_ = new javax.swing.JPanel();
toolbar_ = new javax.swing.JToolBar();
scrollPaneTree_ = new javax.swing.JScrollPane();
tree_ = new javax.swing.JTree();
contextMenu_.setFont(new java.awt.Font("Dialog", 0, 10));
setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints1;
subPanel_.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints2;
splitPane_.setDividerLocation(200);
splitPane_.setLastDividerLocation(200);
scrollPaneRight_.setAutoscrolls(true);
scrollPaneRight_.setViewportView( boundaryDefinitionPanel_ );
splitPane_.setRightComponent(scrollPaneRight_);
leftPanel_.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints3;
buttonPanel_.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
buttonPanel_.setBorder(new javax.swing.border.EtchedBorder());
toolbar_.setFloatable(false);
toolbar_.setFont(new java.awt.Font("Dialog", 0, 8));
buttonPanel_.add(toolbar_);
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 0;
gridBagConstraints3.gridy = 0;
gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints3.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints3.weightx = 1.0;
leftPanel_.add(buttonPanel_, gridBagConstraints3);
scrollPaneTree_.setAutoscrolls(true);
tree_.setFont(new java.awt.Font("Dialog", 0, 10));
tree_.setShowsRootHandles(true);
tree_.setModel( boundaryDefinitionModel_.getTreeModel() );
tree_.setAutoscrolls(true);
tree_.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
OnTreeMouseClicked(evt);
}
});
scrollPaneTree_.setViewportView(tree_);
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 0;
gridBagConstraints3.gridy = 1;
gridBagConstraints3.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints3.anchor = java.awt.GridBagConstraints.SOUTH;
gridBagConstraints3.weightx = 1.0;
gridBagConstraints3.weighty = 1.0;
leftPanel_.add(scrollPaneTree_, gridBagConstraints3);
splitPane_.setLeftComponent(leftPanel_);
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints2.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints2.weightx = 1.0;
gridBagConstraints2.weighty = 1.0;
subPanel_.add(splitPane_, gridBagConstraints2);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints1.insets = new java.awt.Insets(10, 10, 10, 10);
gridBagConstraints1.weightx = 1.0;
gridBagConstraints1.weighty = 1.0;
add(subPanel_, gridBagConstraints1);
}//GEN-END:initComponents
//--------------------------------------------------------------------------
private void OnTreeMouseClicked (java.awt.event.MouseEvent evt)
{//GEN-FIRST:event_OnTreeMouseClicked
try
{
// Get the node object for the current selection.
TreePath tp = tree_.getPathForLocation(evt.getX(), evt.getY());
if (tp != null)
{
// Check for popup menu trigger.
//if (evt.isPopupTrigger())
if (evt.getModifiers() == evt.BUTTON3_MASK) // Check explicitly for right mouse click.
{
DefaultMutableTreeNode nodeItem = (DefaultMutableTreeNode)tp.getLastPathComponent();
BoundaryDefinitionModelItem nodeInfo = (BoundaryDefinitionModelItem)nodeItem.getUserObject();
// Construct an appropriate context menu,
contextMenu_.removeAll();
java.awt.Font font = contextMenu_.getFont();
if (nodeInfo.isPatchType())
{
contextMenu_.add(addPatchPhysicalTypeAction_).setFont(font);
}
else if (nodeInfo.isBoundaryDefinition())
{
contextMenu_.add(addPatchPhysicalTypeAction_).setFont(font);
contextMenu_.add(deletePatchPhysicalTypeAction_).setFont(font);
}
// Show context menu.
contextMenu_.show(tree_, evt.getX(), evt.getY());
}
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}//GEN-LAST:event_OnTreeMouseClicked
//--------------------------------------------------------------------------
public void OnSelectionChanged(TreeSelectionEvent evt)
{
try
{
// Get the node object for the current selection.
if (evt.isAddedPath()) // Has the new node been added to the selection?
{
TreePath tp = evt.getPath();
if (tp != null)
{
// Select this node in the model.
DefaultMutableTreeNode nodeItem = (DefaultMutableTreeNode)tp.getLastPathComponent();
BoundaryDefinitionModelItem nodeInfo = (BoundaryDefinitionModelItem)nodeItem.getUserObject();
// Set the action enabled/disabled status.
addPatchPhysicalTypeAction_.setEnabled(nodeInfo.isPatchType() || nodeInfo.isBoundaryDefinition());
deletePatchPhysicalTypeAction_.setEnabled(nodeInfo.isBoundaryDefinition() && nodeItem.getChildCount() == 0); // Can't delete anything with a child, yet.
boundaryDefinitionModel_.select(nodeItem);
}
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPopupMenu contextMenu_;
private javax.swing.JPanel subPanel_;
private javax.swing.JSplitPane splitPane_;
private javax.swing.JScrollPane scrollPaneRight_;
private javax.swing.JPanel leftPanel_;
private javax.swing.JPanel buttonPanel_;
private javax.swing.JToolBar toolbar_;
private javax.swing.JScrollPane scrollPaneTree_;
private javax.swing.JTree tree_;
// End of variables declaration//GEN-END:variables
//--------------------------------------------------------------------------
class AddPatchPhysicalTypeAction
extends AbstractAction
{
AddPatchPhysicalTypeAction()
{
putValue(Action.SMALL_ICON, App.getResources().getIcon("NewPatchPhysicalTypeImage"));
putValue(Action.NAME, "Add Boundary Type");
putValue(Action.SHORT_DESCRIPTION, "Add Boundary Type");
putValue(Action.LONG_DESCRIPTION, "Add Boundary Type");
}
public void actionPerformed(ActionEvent e)
{
// Add a new boundary type to the current selection.
try
{
// Get currently selected node.
TreePath tp = tree_.getSelectionModel().getSelectionPath();
if (tp != null)
{
// See if this is a patch node or a boundary definition node.
DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode)tp.getLastPathComponent();
BoundaryDefinitionModelItem nodeInfo = (BoundaryDefinitionModelItem)parentNode.getUserObject();
// Make sure the selected node is not the root node.
if (!nodeInfo.isRoot())
{
String name = getNewBoundaryDefinitionName();
if (name != null && name.length()> 0)
{
DefaultMutableTreeNode newNode = boundaryDefinitionModel_.addBoundaryDefinitionNode(name, parentNode);
if (newNode != null)
{
// If addition successful, select the new child node.
tree_.expandPath(tp);
TreePath childTP = new TreePath(newNode.getPath());
tree_.getSelectionModel().clearSelection();
tree_.getSelectionModel().setSelectionPath(childTP);
}
}
}
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
}
//--------------------------------------------------------------------------
class DeletePatchPhysicalTypeAction
extends AbstractAction
{
DeletePatchPhysicalTypeAction()
{
putValue(Action.SMALL_ICON, App.getResources().getIcon("DelPatchPhysicalTypeImage"));
putValue(Action.NAME, "Delete Boundary Type");
putValue(Action.SHORT_DESCRIPTION, "Delete Boundary Type");
putValue(Action.LONG_DESCRIPTION, "Delete Boundary Type");
}
public void actionPerformed(ActionEvent e)
{
// Delete the selected boundary definition.
try
{
// Get currently selected node.
TreePath tp = tree_.getSelectionModel().getSelectionPath();
if (tp != null)
{
// See if this is a patch node or a boundary definition node with children.
DefaultMutableTreeNode nodeItem = (DefaultMutableTreeNode)tp.getLastPathComponent();
BoundaryDefinitionModelItem nodeInfo = (BoundaryDefinitionModelItem)nodeItem.getUserObject();
// Make sure the selected node is a boundary type node.
if (nodeInfo.isBoundaryDefinition())
{
if (boundaryDefinitionModel_.deleteBoundaryDefinitionNode(nodeItem))
{
// If deletion successful, select the parent node.
tree_.getSelectionModel().clearSelection();
tree_.getSelectionModel().setSelectionPath(tp.getParentPath());
}
}
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.0" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="name" type="java.lang.String" value="Shape Editor"/>
<Property name="modal" type="boolean" value="true"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="menuBar" type="java.lang.String" value="(No Menu)"/>
<SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,94"/>
<SyntheticProperty name="formPosition" type="java.awt.Point" value="-84,-19,0,5,115,114,0,14,106,97,118,97,46,97,119,116,46,80,111,105,110,116,-74,-60,-118,114,52,126,-56,38,2,0,2,73,0,1,120,73,0,1,121,120,112,0,0,0,0,0,0,0,0"/>
<SyntheticProperty name="formSizePolicy" type="int" value="0"/>
<SyntheticProperty name="generatePosition" type="boolean" value="true"/>
<SyntheticProperty name="generateSize" type="boolean" value="true"/>
<SyntheticProperty name="generateCenter" type="boolean" value="true"/>
</SyntheticProperties>
<Events>
<EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="closeDialog"/>
</Events>
<AuxValues>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="buttonPanel_">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder/>
</Border>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="10" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="1" insetsBottom="0" insetsLeft="0" insetsRight="0" insetsTop="0" ipadX="0" ipadY="0" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
<Property name="alignment" type="int" value="2"/>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="closeButton_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="Close"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="closeButtonActionPerformed_"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="mainPanel_">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
<EmptyBorder bottom="10" left="10" right="10" top="10"/>
</Border>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="10" fill="1" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="tableScrollPane_">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="10" fill="1" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="0" insetsLeft="0" insetsRight="0" insetsTop="0" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTable" name="table_">
<Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="tableModel_" type="code"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@ -0,0 +1,226 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors;
import java.awt.event.ActionEvent;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.ListSelectionEvent;
import FoamX.App;
import FoamX.Editors.DictionaryEntryEditor.DictionaryEntry;
import FoamX.Editors.DictionaryEntryEditor.DictionaryEntryCellEditor;
import FoamX.Editors.DictionaryEntryEditor.DictionaryEntryCellRenderer;
import FoamX.Editors.DictionaryEntryEditor.DictionaryNameCellRenderer;
import FoamX.Editors.DictionaryEntryEditor.DictionaryEntryTableModel;
import FoamX.Editors.DictionaryEntryEditor.EntryCache.DictionaryEntryCache;
import FoamXServer.FoamXError;
import FoamXServer.FoamXIOError;
import FoamXServer.IDictionaryEntry;
public class CompoundEditor
extends javax.swing.JDialog
{
//--------------------------------------------------------------------------
private static final int DEFAULT_HEIGHT = 400;
private DictionaryEntryTableModel tableModel_;
//--------------------------------------------------------------------------
/** Creates new form CompoundEditor */
public CompoundEditor(java.awt.Frame parent, IDictionaryEntry entry)
{
super(parent, "Compound Editor", true);
// Initialise the table model.
tableModel_ = new DictionaryEntryTableModel(entry);
tableModel_.setNameColumnTitle("Item");
initComponents();
// Set cell renderer for name column.
table_.getColumn
(
tableModel_.getNameColumnTitle()
).setCellRenderer(new DictionaryNameCellRenderer());
// Set cell renderer and editor for value column.
table_.getColumn
(
tableModel_.getValueColumnTitle()
).setCellRenderer(new DictionaryEntryCellRenderer());
table_.getColumn
(
tableModel_.getValueColumnTitle()
).setCellEditor(new DictionaryEntryCellEditor());
// Resize to show the defined rows only.
// Calculate size: table + panel + extra(=1 row height)
int height =
table_.getRowHeight() * (tableModel_.getRowCount() + 1)
+ (int)getMinimumSize().height; // panel size
height = Math.min(height, DEFAULT_HEIGHT);
setSize(new java.awt.Dimension(getSize().width, height));
}
//--------------------------------------------------------------------------
/** Access to underlying model */
public DictionaryEntryTableModel getModel()
{
return tableModel_;
}
//--------------------------------------------------------------------------
/** 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 FormEditor.
*/
private void initComponents()//GEN-BEGIN:initComponents
{
buttonPanel_ = new javax.swing.JPanel();
closeButton_ = new javax.swing.JButton();
mainPanel_ = new javax.swing.JPanel();
tableScrollPane_ = new javax.swing.JScrollPane();
table_ = new javax.swing.JTable();
getContentPane().setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints1;
setName("Shape Editor");
setModal(true);
addWindowListener(new java.awt.event.WindowAdapter()
{
public void windowClosing(java.awt.event.WindowEvent evt)
{
closeDialog(evt);
}
});
buttonPanel_.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
buttonPanel_.setBorder(new javax.swing.border.EtchedBorder());
closeButton_.setFont(new java.awt.Font("Dialog", 0, 10));
closeButton_.setText("Close");
closeButton_.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
closeButtonActionPerformed_(evt);
}
});
buttonPanel_.add(closeButton_);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 1;
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints1.weightx = 1.0;
getContentPane().add(buttonPanel_, gridBagConstraints1);
mainPanel_.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints2;
mainPanel_.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(10, 10, 10, 10)));
table_.setModel(tableModel_);
table_.setFont(new java.awt.Font("Dialog", 0, 10));
tableScrollPane_.setViewportView(table_);
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints2.weightx = 1.0;
gridBagConstraints2.weighty = 1.0;
mainPanel_.add(tableScrollPane_, gridBagConstraints2);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints1.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints1.weightx = 1.0;
gridBagConstraints1.weighty = 1.0;
getContentPane().add(mainPanel_, gridBagConstraints1);
pack();
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setSize(new java.awt.Dimension(350, 300));
setLocation((screenSize.width-350)/2,(screenSize.height-300)/2);
}//GEN-END:initComponents
//--------------------------------------------------------------------------
private void shapeTypeComboActionPerformed (java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_shapeTypeComboActionPerformed
}//GEN-LAST:event_shapeTypeComboActionPerformed
//--------------------------------------------------------------------------
private void closeButtonActionPerformed_ (java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_closeButtonActionPerformed_
// Update the dictionary entry and close the dialog.
// Commit any pending edits.
table_.editingStopped(new ChangeEvent(this));
// Close this dialog.
setVisible(false);
dispose();
}//GEN-LAST:event_closeButtonActionPerformed_
//--------------------------------------------------------------------------
/** Closes the dialog */
private void closeDialog(java.awt.event.WindowEvent evt)
{//GEN-FIRST:event_closeDialog
setVisible(false);
dispose();
}//GEN-LAST:event_closeDialog
//--------------------------------------------------------------------------
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel buttonPanel_;
private javax.swing.JButton closeButton_;
private javax.swing.JPanel mainPanel_;
private javax.swing.JScrollPane tableScrollPane_;
private javax.swing.JTable table_;
// End of variables declaration//GEN-END:variables
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE attributes PUBLIC "-//NetBeans//DTD DefaultAttributes 1.0//EN" "http://www.netbeans.org/dtds/attributes-1_0.dtd">
<attributes version="1.0">
<fileobject name="DictionaryEntryCellRenderer.java">
<attr name="class_dependency_javax.swing.table.DefaultTableCellRenderer" stringvalue="DictionaryEntryCellRenderer"/>
</fileobject>
<fileobject name="DictionaryEditorPanel.java">
<attr name="class_dependency_javax.swing.JPanel" stringvalue="DictionaryEditorPanel"/>
</fileobject>
<fileobject name="CompoundEntryEvent.java">
<attr name="class_dependency_java.util.EventObject" stringvalue="CompoundEntryEvent"/>
<attr name="template" serialvalue="aced0005737200266f72672e6f70656e6964652e7574696c2e696f2e4e624d61727368616c6c65644f626a6563746cd5cc1aa397c0f2020002490004686173685b00086f626a42797465737400025b4278700000001170"/>
</fileobject>
<fileobject name="DictionaryEntryCompoundEditor.java">
<attr name="class_dependency_javax.swing.table.TableCellEditor" stringvalue="DictionaryEntryCompoundEditor"/>
</fileobject>
<fileobject name="DictionaryEntryCache.java">
<attr name="class_dependency_FoamX.Editors.DictionaryEntryEditor.DictionaryEntry" stringvalue="DictionaryEntryCache"/>
</fileobject>
<fileobject name="DictionaryEntryTableModel.java">
<attr name="EA-OpenIDE-Connection" serialvalue="aced0005737200146a6176612e7574696c2e4c696e6b65644c6973740c29535d4a608822030000787077040000000078"/>
<attr name="class_dependency_javax.swing.table.AbstractTableModel" stringvalue="DictionaryEntryTableModel"/>
</fileobject>
<fileobject name="SelectionTableModel.java">
<attr name="EA-OpenIDE-Connection" serialvalue="aced0005737200146a6176612e7574696c2e4c696e6b65644c6973740c29535d4a60882203000078707704000000047372002a6f72672e6f70656e6964652e6c6f61646572732e436f6e6e656374696f6e537570706f72742450616972055f8af6f04a3bd80200024c00047479706574002b4c6f72672f6f70656e6964652f636f6f6b6965732f436f6e6e656374696f6e436f6f6b696524547970653b4c000576616c75657400124c6a6176612f6c616e672f4f626a6563743b78707372002e6f72672e6e65746265616e732e6d6f64756c65732e6a6176612e4a617661436f6e6e656374696f6e732454797065a83dd01001306d7402000149000666696c746572787000000050737200436f72672e6e65746265616e732e6d6f64756c65732e6a6176612e4a617661446174614f626a6563742450657273697374656e74436f6e6e656374696f6e48616e646c65ba16f1d2dd4c1cb60200014c000e646174614e6f646548616e646c6574001f4c6f72672f6f70656e6964652f6e6f6465732f4e6f64652448616e646c653b7870737200296f72672e6f70656e6964652e6c6f61646572732e446174614e6f6465244f626a65637448616e646c655bd0f82e01811d2e0200025a0005636c6f6e654c00036f626a7400244c6f72672f6f70656e6964652f66696c6573797374656d732f46696c654f626a6563743b787000737200326f72672e6f70656e6964652e66696c6573797374656d732e416273747261637446696c654f626a656374245265706c616365896fa1bce4b5219f0200024c000866696c654e616d657400124c6a6176612f6c616e672f537472696e673b4c000666734e616d6571007e000f7870740033466f616d582f4d6f64756c65732f43617365456469746f722f4669656c6450726f7065727469657357696e646f772e6a6176617400422f686f6d652f70656e666f6c642f6d617474696a732f666f616d2f6d617474696a73322e312f6170706c69636174696f6e732f7574696c2f466f616d582f4a6176617371007e00027371007e0006000000507371007e00087371007e000b007371007e000e740021466f616d582f456469746f72732f436f6d706f756e64456469746f722e6a61766171007e00127371007e00027371007e0006000000507371007e00087371007e000b007371007e000e74001d466f616d582f456469746f72732f4c697374456469746f722e6a61766171007e00127371007e00027371007e0006000000507371007e00087371007e000b007371007e000e740024466f616d582f456469746f72732f566563746f725370616365456469746f722e6a61766171007e001278"/>
<attr name="class_dependency_javax.swing.table.AbstractTableModel" stringvalue="SelectionTableModel"/>
</fileobject>
<fileobject name="DictionaryEntryCellEditor.java">
<attr name="class_dependency_javax.swing.table.TableCellEditor" stringvalue="DictionaryEntryCellEditor"/>
</fileobject>
<fileobject name="CompoundEntryListener.java">
<attr name="EA-OpenIDE-Connection" serialvalue="aced0005737200146a6176612e7574696c2e4c696e6b65644c6973740c29535d4a60882203000078707704000000057372002a6f72672e6f70656e6964652e6c6f61646572732e436f6e6e656374696f6e537570706f72742450616972055f8af6f04a3bd80200024c00047479706574002b4c6f72672f6f70656e6964652f636f6f6b6965732f436f6e6e656374696f6e436f6f6b696524547970653b4c000576616c75657400124c6a6176612f6c616e672f4f626a6563743b78707372002e6f72672e6e65746265616e732e6d6f64756c65732e6a6176612e4a617661436f6e6e656374696f6e732454797065a83dd01001306d7402000149000666696c746572787000000050737200296f72672e6f70656e6964652e6c6f61646572732e446174614e6f6465244f626a65637448616e646c655bd0f82e01811d2e0200025a0005636c6f6e654c00036f626a7400244c6f72672f6f70656e6964652f66696c6573797374656d732f46696c654f626a6563743b787000737200326f72672e6f70656e6964652e66696c6573797374656d732e416273747261637446696c654f626a65637424496e76616c6964c0bb2fa0ec2461140200024c000866756c6c4e616d657400124c6a6176612f6c616e672f537472696e673b4c00046e616d6571007e000c787200226f72672e6f70656e6964652e66696c6573797374656d732e46696c654f626a656374012f10797d5a7af6020000787074002c466f616d582f4f7074696f6e732f44696374696f6e617279456e7472795461626c654d6f64656c2e6a61766174001e44696374696f6e617279456e7472795461626c654d6f64656c2e6a6176617371007e00027371007e0006000000507371007e000800737200326f72672e6f70656e6964652e66696c6573797374656d732e416273747261637446696c654f626a656374245265706c616365896fa1bce4b5219f0200024c000866696c654e616d6571007e000c4c000666734e616d6571007e000c7870740042466f616d582f456469746f72732f44696374696f6e617279456e747279456469746f722f44696374696f6e617279456e7472795461626c654d6f64656c2e6a6176617400422f686f6d652f70656e666f6c642f6d617474696a732f666f616d2f6d617474696a73322e312f6170706c69636174696f6e732f7574696c2f466f616d582f4a6176617371007e00027371007e0006000000507371007e0008007371007e001474002e466f616d582f4d6f64756c65732f43617365456469746f722f43617365456469746f724d6f64756c652e6a61766171007e00177371007e00027371007e000600000050737200436f72672e6e65746265616e732e6d6f64756c65732e6a6176612e4a617661446174614f626a6563742450657273697374656e74436f6e6e656374696f6e48616e646c65ba16f1d2dd4c1cb60200014c000e646174614e6f646548616e646c6574001f4c6f72672f6f70656e6964652f6e6f6465732f4e6f64652448616e646c653b78707371007e00080071007e001b7371007e00027371007e0006000000507371007e001f7371007e00080071007e001578"/>
<attr name="template" serialvalue="aced0005737200266f72672e6f70656e6964652e7574696c2e696f2e4e624d61727368616c6c65644f626a6563746cd5cc1aa397c0f2020002490004686173685b00086f626a42797465737400025b4278700000001170"/>
<attr name="class_dependency_java.util.EventListener" stringvalue="CompoundEntryListener"/>
</fileobject>
<fileobject name="DictionaryEntry.java">
<attr name="EA-OpenIDE-Connection" serialvalue="aced0005737200146a6176612e7574696c2e4c696e6b65644c6973740c29535d4a60882203000078707704000000037372002a6f72672e6f70656e6964652e6c6f61646572732e436f6e6e656374696f6e537570706f72742450616972055f8af6f04a3bd80200024c00047479706574002b4c6f72672f6f70656e6964652f636f6f6b6965732f436f6e6e656374696f6e436f6f6b696524547970653b4c000576616c75657400124c6a6176612f6c616e672f4f626a6563743b78707372002e6f72672e6e65746265616e732e6d6f64756c65732e6a6176612e4a617661436f6e6e656374696f6e732454797065a83dd01001306d7402000149000666696c746572787000000050737200296f72672e6f70656e6964652e6c6f61646572732e446174614e6f6465244f626a65637448616e646c655bd0f82e01811d2e0200025a0005636c6f6e654c00036f626a7400244c6f72672f6f70656e6964652f66696c6573797374656d732f46696c654f626a6563743b787000737200326f72672e6f70656e6964652e66696c6573797374656d732e416273747261637446696c654f626a656374245265706c616365896fa1bce4b5219f0200024c000866696c654e616d657400124c6a6176612f6c616e672f537472696e673b4c000666734e616d6571007e000c7870740028466f616d582f4d6f64756c65732f43617365456469746f722f5061746368456e7472792e6a6176617400422f686f6d652f70656e666f6c642f6d617474696a732f666f616d2f6d617474696a73322e312f6170706c69636174696f6e732f7574696c2f466f616d582f4a6176617371007e00027371007e0006000000507371007e0008007371007e000b74003d466f616d582f456469746f72732f44696374696f6e617279456e747279456469746f722f44696374696f6e617279456e74727943616368652e6a61766171007e000f7371007e00027371007e000600000050737200436f72672e6e65746265616e732e6d6f64756c65732e6a6176612e4a617661446174614f626a6563742450657273697374656e74436f6e6e656374696f6e48616e646c65ba16f1d2dd4c1cb60200014c000e646174614e6f646548616e646c6574001f4c6f72672f6f70656e6964652f6e6f6465732f4e6f64652448616e646c653b78707371007e00080071007e001378"/>
<attr name="template" serialvalue="aced0005737200266f72672e6f70656e6964652e7574696c2e696f2e4e624d61727368616c6c65644f626a6563746cd5cc1aa397c0f2020002490004686173685b00086f626a42797465737400025b4278700000001170"/>
</fileobject>
<fileobject name="DictionaryEntryCompoundPanel.java">
<attr name="class_dependency_javax.swing.JPanel" stringvalue="DictionaryEntryCompoundPanel"/>
</fileobject>
<fileobject name="DictionaryEntryBooleanRenderer.java">
<attr name="class_dependency_javax.swing.table.TableCellRenderer" stringvalue="DictionaryEntryBooleanRenderer"/>
<attr name="class_dependency_javax.swing.JCheckBox" stringvalue="DictionaryEntryBooleanRenderer"/>
</fileobject>
</attributes>

View File

@ -0,0 +1,58 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor;
import FoamX.App;
public class CompoundEntryEvent
extends java.util.EventObject
{
public static final int TYPE_PATCH = 0;
public static final int TYPE_DICTIONARY = 1;
protected int type_;
protected String name_;
/** CompoundEntryEvent constructor. */
public CompoundEntryEvent(Object source, int type, String name)
{
super(source);
type_ = type;
name_ = name;
}
public int getType()
{
return type_;
}
public String getName()
{
return name_;
}
}

View File

@ -0,0 +1,33 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor;
public interface CompoundEntryListener
extends java.util.EventListener
{
public boolean openSubDictionary(CompoundEntryEvent evt);
}

View File

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
<EmptyBorder bottom="10" left="10" right="10" top="10"/>
</Border>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="autoscrolls" type="boolean" value="true"/>
</Properties>
<SyntheticProperties>
</SyntheticProperties>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="scrollPane_">
<Properties>
<Property name="autoscrolls" type="boolean" value="true"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="10" fill="1" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTable" name="parameterTable_">
<Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="tableModel_" type="code"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="autoResizeMode" type="int" value="4"/>
</Properties>
<Events>
<EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="OnKeyPressed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="statusPanel_">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder/>
</Border>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[10, 25]"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="10" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="1" insetsBottom="0" insetsLeft="0" insetsRight="0" insetsTop="0" ipadX="0" ipadY="0" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Component class="javax.swing.JLabel" name="statusLabel_">
<Properties>
<Property name="text" type="java.lang.String" value=" "/>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" id="black" palette="0" red="0" type="palette"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="17" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="0" insetsLeft="0" insetsRight="0" insetsTop="0" ipadX="0" ipadY="0" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@ -0,0 +1,282 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor;
import javax.swing.table.*;
import javax.swing.event.*;
import java.awt.event.*;
import FoamX.App;
import FoamXServer.IDictionaryEntry;
import FoamXServer.ITypeDescriptor;
import FoamXServer.FoamXType;
public class DictionaryEditorPanel
extends javax.swing.JPanel
{
//--------------------------------------------------------------------------
protected static final int DEFAULT_WIDTH = 400;
protected DictionaryEntryTableModel tableModel_;
protected String tableName_;
//--------------------------------------------------------------------------
/** Creates a new DictionaryEditorPanel object. */
public DictionaryEditorPanel(IDictionaryEntry compoundEntry, String key)
{
try
{
// Initialise the table model.
tableModel_ = new DictionaryEntryTableModel(compoundEntry);
IDictionaryEntry[] subEntries = compoundEntry.subElements();
//tableName_ = compoundEntry.typeDescriptor().name();
tableName_ = key;
int type = compoundEntry.typeDescriptor().type().value();
tableModel_.setDictionaryKey(key);
// Initialise the table.
initComponents();
// Set single area selection mode.
parameterTable_.setSelectionMode(0);
// Use 'standard' renderer for name
parameterTable_.getColumn
(
tableModel_.getNameColumnTitle()
).setCellRenderer(new DictionaryNameCellRenderer());
// Set cell renderer and editor for value column.
parameterTable_.getColumn
(
tableModel_.getValueColumnTitle()
).setCellRenderer(new DictionaryEntryCellRenderer());
parameterTable_.getColumn
(
tableModel_.getValueColumnTitle()
).setCellEditor(new DictionaryEntryCellEditor());
// Subscribe to the list selection model event.
parameterTable_.getSelectionModel().addListSelectionListener
(
new ListSelectionListener()
{
public void valueChanged(ListSelectionEvent evt)
{
listSelectionChanged(evt);
}
}
);
// Select the first entry.
parameterTable_.clearSelection();
parameterTable_.getSelectionModel().setLeadSelectionIndex(0);
// Resize to show the defined rows only.
// Calculate size: table + panel + extra(=1 row height)
int height =
parameterTable_.getRowHeight()
* (tableModel_.getRowCount() + 2)
+ (int)getMinimumSize().getHeight(); // panel size
setPreferredSize(new java.awt.Dimension(DEFAULT_WIDTH, height));
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
/** Provide access to the table model object. */
public DictionaryEntryTableModel getTableModel()
{
return tableModel_;
}
//--------------------------------------------------------------------------
/** Used to set the title of the host internal frame window. */
public String toString()
{
return tableName_;
}
//--------------------------------------------------------------------------
protected void listSelectionChanged(ListSelectionEvent evt)
{
// Update the entry status label.
if (!evt.getValueIsAdjusting())
{
// Reset the entry status label.
statusLabel_.setText("");
int nSel =
parameterTable_.getSelectionModel().getMinSelectionIndex();
if (nSel <tableModel_.getRowCount() && nSel>= 0)
{
// Get the currently selected entry.
DictionaryEntry entry =
(DictionaryEntry)tableModel_.getValueAt
(
nSel,
DictionaryEntryTableModel.VALUE_COLUMN_INDEX
);
if (entry != null)
{
statusLabel_.setText(entry.getEntryDescription());
}
}
}
}
//--------------------------------------------------------------------------
public void selectEntry(String entryName)
{
try
{
// Get index of specified entry.
int index = tableModel_.getIndexOfEntry(entryName);
// Give table the focus.
parameterTable_.requestFocus();
// Set the specified entry.
parameterTable_.clearSelection();
parameterTable_.getSelectionModel().setLeadSelectionIndex(index);
parameterTable_.getSelectionModel().setSelectionInterval(index, index);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
/** 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 FormEditor.
*/
private void initComponents()//GEN-BEGIN:initComponents
{
scrollPane_ = new javax.swing.JScrollPane();
parameterTable_ = new javax.swing.JTable();
statusPanel_ = new javax.swing.JPanel();
statusLabel_ = new javax.swing.JLabel();
setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints1;
setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(10, 10, 10, 10)));
setFont(new java.awt.Font("Dialog", 0, 10));
setAutoscrolls(true);
scrollPane_.setAutoscrolls(true);
parameterTable_.setModel(tableModel_);
parameterTable_.setFont(new java.awt.Font("Dialog", 0, 10));
parameterTable_.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS);
parameterTable_.addKeyListener(new java.awt.event.KeyAdapter()
{
public void keyPressed(java.awt.event.KeyEvent evt)
{
OnKeyPressed(evt);
}
});
scrollPane_.setViewportView(parameterTable_);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints1.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints1.weightx = 1.0;
gridBagConstraints1.weighty = 1.0;
add(scrollPane_, gridBagConstraints1);
statusPanel_.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints2;
statusPanel_.setBorder(new javax.swing.border.EtchedBorder());
statusPanel_.setMinimumSize(new java.awt.Dimension(10, 25));
statusLabel_.setText(" ");
statusLabel_.setForeground(java.awt.Color.black);
statusLabel_.setFont(new java.awt.Font("Dialog", 0, 10));
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints2.weightx = 1.0;
statusPanel_.add(statusLabel_, gridBagConstraints2);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 1;
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
add(statusPanel_, gridBagConstraints1);
}//GEN-END:initComponents
//--------------------------------------------------------------------------
private void OnKeyPressed(java.awt.event.KeyEvent evt)
{//GEN-FIRST:event_OnKeyPressed
// Add your handling code here:
if (evt.getKeyCode() == KeyEvent.VK_TAB)
{
int nSel =
parameterTable_.getSelectionModel().getMinSelectionIndex();
if (nSel <tableModel_.getRowCount() && nSel>= 0)
{
boolean b = parameterTable_.editCellAt(0, 1);
if (b) App.printMessage("editCellAt true");
}
}
}//GEN-LAST:event_OnKeyPressed
//--------------------------------------------------------------------------
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JScrollPane scrollPane_;
private javax.swing.JTable parameterTable_;
private javax.swing.JPanel statusPanel_;
private javax.swing.JLabel statusLabel_;
// End of variables declaration//GEN-END:variables
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,47 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor;
import javax.swing.table.*;
public interface DictionaryEntry
{
public String getEntryName();
public String getEntryDescription();
public String getEntryValueString();
public boolean isEditable();
public boolean isCurrent(); // selected entry (e.g. in TYPE_SELECTION)
// Custom renderer and editor methods.
public TableCellRenderer getRenderer();
public TableCellEditor getEditor();
public boolean updateValue(Object value);
// Support for compound entry editing.
public void addCompoundEntryListener(CompoundEntryListener l);
public void removeCompoundEntryListener(CompoundEntryListener l);
}

View File

@ -0,0 +1,226 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor;
import java.awt.Component;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import java.util.EventObject;
import FoamX.App;
public class DictionaryEntryCellEditor
implements TableCellEditor
{
//--------------------------------------------------------------------------
// DictionaryEntry object being edited.
private DictionaryEntry dictEntry_;
// Editor being used to edit the current value.
private TableCellEditor currEditor_;
// Default cell editor object.
private DefaultCellEditor defaultEditor_;
//--------------------------------------------------------------------------
/** DictionaryEntryCellEditor constructor. */
public DictionaryEntryCellEditor()
{
dictEntry_ = null;
currEditor_ = null;
defaultEditor_ = null;
}
//--------------------------------------------------------------------------
//---- TableCellEditor Interface Methods
//--------------------------------------------------------------------------
/** Implementation of TableCellEditor interface's
* getTableCellEditorComponent function.
*/
public Component getTableCellEditorComponent
(
JTable table,
Object value,
boolean isSelected,
int row,
int column
)
{
Component comp = null;
try
{
// Incoming object must support the DictionaryEntry interface.
dictEntry_ = (DictionaryEntry)value;
// See if the DictionaryEntry has a custom editor.
if (dictEntry_.getEditor() != null)
{
currEditor_ = dictEntry_.getEditor();
}
else
{
// This item does not have a custom editor so use the
// string-based default.
if (defaultEditor_ == null)
{
// Create on demand.
defaultEditor_ =
new DefaultCellEditor(new JTextField());
}
currEditor_ = defaultEditor_;
}
comp = currEditor_.getTableCellEditorComponent
(
table,
value,
isSelected,
row,
column
);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return comp;
}
//--------------------------------------------------------------------------
// CellEditor interface functions.
//--------------------------------------------------------------------------
public Object getCellEditorValue()
{
// Intercept the "value" object from the editor.
// Of class String for DefaultCellEditor (JTextField) class.
// May be null for other editors.
try
{
Object objValue = currEditor_.getCellEditorValue();
// Update the DictionaryEntry object's value.
dictEntry_.updateValue(objValue);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
// Return the DictionaryEntry object being edited.
// This is the value that gets sent to the model.
return dictEntry_;
}
//--------------------------------------------------------------------------
public boolean stopCellEditing()
{
if (currEditor_ != null)
{
return currEditor_.stopCellEditing();
}
return true;
}
//--------------------------------------------------------------------------
public void cancelCellEditing()
{
if (currEditor_ != null)
{
currEditor_.cancelCellEditing();
}
}
//--------------------------------------------------------------------------
public boolean isCellEditable(EventObject anEvent)
{
// For mouse events, only initiate the editing process is the user
// has double clicked.
//if (anEvent instanceof MouseEvent)
//{
// MouseEvent evt = (MouseEvent)anEvent;
// return (evt.getID()
// == MouseEvent.MOUSE_PRESSED && evt.getClickCount()>= 2);
//}
return true;
}
//--------------------------------------------------------------------------
public boolean shouldSelectCell(EventObject anEvent)
{
// Called at the start of the editing process.
if (currEditor_ != null)
{
return currEditor_.shouldSelectCell(anEvent);
}
return true;
}
//--------------------------------------------------------------------------
public void addCellEditorListener(CellEditorListener l)
{
if (currEditor_ != null)
{
currEditor_.addCellEditorListener(l);
}
}
//--------------------------------------------------------------------------
public void removeCellEditorListener(CellEditorListener l)
{
if (currEditor_ != null)
{
currEditor_.removeCellEditorListener(l);
}
// Editing has finished. Reset the references.
currEditor_ = null;
dictEntry_ = null;
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,139 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor;
import javax.swing.JTable;
import javax.swing.table.*;
import java.awt.Component;
import FoamX.App;
public class DictionaryEntryCellRenderer
extends DefaultTableCellRenderer
{
//--------------------------------------------------------------------------
protected java.awt.Font selectedFont_;
protected java.awt.Color selectedColor_;
//--------------------------------------------------------------------------
/** DictionaryEntryCellRenderer constructor. */
public DictionaryEntryCellRenderer()
{
selectedFont_= new java.awt.Font("Dialog", java.awt.Font.BOLD, 10);
selectedColor_= new java.awt.Color(173, 255, 47);
}
//--------------------------------------------------------------------------
public Component getTableCellRendererComponent
(
JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column
)
{
Component comp = null;
// Incoming object must support the DictionaryEntry interface.
DictionaryEntry dictEntry = (DictionaryEntry)value;
// See if the DictionaryEntry has a custom renderer.
if (dictEntry.getRenderer() != null)
{
comp =
dictEntry.getRenderer().getTableCellRendererComponent
(
table,
value,
isSelected,
hasFocus,
row,
column
);
}
else
{
// This item does not have a custom renderer. Use the
// DictionaryEntry object
// to generate a string representation of the current value
// via the toString method.
comp =
super.getTableCellRendererComponent
(
table,
value,
isSelected,
hasFocus,
row,
column
);
}
// If this entry is read-only, grey it out.
if (!dictEntry.isEditable())
{
setForeground(java.awt.Color.gray);
}
else
{
setForeground(java.awt.Color.black);
}
// // Currently selected entry
// if (dictEntry.isCurrent())
// {
// //comp.setFont(selectedFont_);
// comp.setBackground(selectedColor_);
// }
// else
// {
// comp.setBackground(java.awt.Color.white);
// }
if (isSelected)
{
//comp.setFont(selectedFont_);
comp.setBackground(selectedColor_);
}
else
{
comp.setBackground(java.awt.Color.white);
}
return comp;
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,297 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor;
import java.awt.Component;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.TableCellEditor;
import java.util.EventObject;
import FoamX.App;
import FoamX.Editors.DictionaryEntryEditor.EntryCache.*;
public class DictionaryEntryCompoundEditor
implements TableCellEditor
{
//--------------------------------------------------------------------------
protected DictionaryEntryCompoundPanel panel_;
protected EventListenerList listenerList_;
protected boolean bAcceptEdit_;
transient protected ChangeEvent changeEvent_;
transient protected ActionEvent actionEvent_;
//--------------------------------------------------------------------------
/** DictionaryEntryCellEditor constructor. */
public DictionaryEntryCompoundEditor()
{
panel_ = new DictionaryEntryCompoundPanel();
listenerList_ = new EventListenerList();
bAcceptEdit_ = false;
// Subscribe to the edit button's action event so that we can forward
// the event to the action event listeners of this object.
panel_.EditButton().addActionListener
(
new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
// The edit button has been pressed. Inform any interested
// parties.
if (bAcceptEdit_) fireEditActionEvent();
bAcceptEdit_ = true;
}
}
);
}
//--------------------------------------------------------------------------
//---- TableCellEditor Interface methods
//--------------------------------------------------------------------------
/** Implementation of TableCellEditor interface's
* getTableCellEditorComponent method.
*/
public Component getTableCellEditorComponent
(
JTable table,
Object value,
boolean isSelected,
int row,
int column
)
{
try
{
// Incoming object must support the DictionaryEntry interface.
if (value instanceof DictionaryEntry)
{
DictionaryEntry dictEntry = (DictionaryEntry)value;
// Set the panel text.
panel_.Label().setText(dictEntry.getEntryValueString());
}
else
{
// Set the panel text.
panel_.Label().setText(value.toString());
}
// Make sure the label is rendered properly.
if (isSelected)
{
panel_.Label().setForeground(table.getSelectionForeground());
panel_.Label().setBackground(table.getSelectionBackground());
}
else
{
panel_.Label().setForeground(table.getForeground());
panel_.Label().setBackground(table.getBackground());
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return panel_;
}
//--------------------------------------------------------------------------
//---- CellEditor Interface Methods
//--------------------------------------------------------------------------
public Object getCellEditorValue()
{
return null;
}
//--------------------------------------------------------------------------
public boolean stopCellEditing()
{
fireEditingStopped();
return true;
}
//--------------------------------------------------------------------------
public void cancelCellEditing()
{
fireEditingCanceled();
}
//--------------------------------------------------------------------------
public boolean isCellEditable(EventObject anEvent)
{
// Always editable.
return true;
}
//--------------------------------------------------------------------------
public boolean shouldSelectCell(EventObject anEvent)
{
// Called at the start of the editing process.
/*
if (anEvent instanceof MouseEvent)
{
MouseEvent mevt = (MouseEvent)anEvent;
if
(
mevt.getID() == MouseEvent.MOUSE_PRESSED
&& mevt.getClickCount()>= 2
)
{
bAcceptEdit_ = false;
}
}
*/
bAcceptEdit_ = true;
// Make sure the panel is repainted. Don't know why
// but sometimes the panel is not rendererd properly
// despite the table being in edit mode!!
panel_.repaint();
return true;
}
//--------------------------------------------------------------------------
public void addCellEditorListener(CellEditorListener l)
{
listenerList_.add(CellEditorListener.class, l);
}
//--------------------------------------------------------------------------
public void removeCellEditorListener(CellEditorListener l)
{
listenerList_.remove(CellEditorListener.class, l);
}
//--------------------------------------------------------------------------
protected void fireEditingStopped()
{
Object[] listeners = listenerList_.getListenerList();
// Process the listeners last to first, notifying those that are
// interested in this event.
for (int i = listeners.length - 2; i>= 0; i -= 2)
{
if (listeners[i] == CellEditorListener.class)
{
// Lazily create the event:
if (changeEvent_ == null)
{
changeEvent_ = new ChangeEvent(this);
}
((CellEditorListener)listeners[i+1]).editingStopped
(
changeEvent_
);
}
}
}
//--------------------------------------------------------------------------
protected void fireEditingCanceled()
{
// Guaranteed to return a non-null array
Object[] listeners = listenerList_.getListenerList();
// Process the listeners last to first, notifying those that are
// interested in this event.
for (int i = listeners.length - 2; i>= 0; i -= 2)
{
if (listeners[i] == CellEditorListener.class)
{
// Lazily create the event:
if (changeEvent_ == null)
{
changeEvent_ = new ChangeEvent(this);
}
((CellEditorListener)listeners[i+1]).editingCanceled
(
changeEvent_
);
}
}
}
//--------------------------------------------------------------------------
public void addActionListener(ActionListener l)
{
listenerList_.add(ActionListener.class, l);
}
//--------------------------------------------------------------------------
public void removeActionListener(ActionListener l)
{
listenerList_.remove(ActionListener.class, l);
}
//--------------------------------------------------------------------------
protected void fireEditActionEvent()
{
Object[] listeners = listenerList_.getListenerList();
// Process the listeners last to first, notifying those that are
// interested in this event.
for (int i = listeners.length - 2; i>= 0; i -= 2)
{
if (listeners[i] == ActionListener.class)
{
// Lazily create the event:
if (actionEvent_ == null)
{
actionEvent_ = new ActionEvent
(
this,
ActionEvent.ACTION_PERFORMED,
""
);
}
// Fire the event.
((ActionListener)listeners[i+1]).actionPerformed(actionEvent_);
}
}
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<SyntheticProperties>
</SyntheticProperties>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Component class="javax.swing.JLabel" name="label">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="opaque" type="boolean" value="true"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JButton" name="editButton">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="..."/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="East"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Form>

View File

@ -0,0 +1,89 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor;
import javax.swing.*;
import FoamX.App;
public class DictionaryEntryCompoundPanel
extends javax.swing.JPanel
{
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
/** Creates new form DictionaryEntryCompoundPanel */
public DictionaryEntryCompoundPanel()
{
initComponents();
}
//--------------------------------------------------------------------------
public JLabel Label()
{
return label;
}
public JButton EditButton()
{
return editButton;
}
//--------------------------------------------------------------------------
/** 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 FormEditor.
*/
private void initComponents()//GEN-BEGIN:initComponents
{
label = new javax.swing.JLabel();
editButton = new javax.swing.JButton();
setLayout(new java.awt.BorderLayout());
label.setFont(new java.awt.Font("Dialog", 0, 10));
label.setOpaque(true);
add(label, java.awt.BorderLayout.CENTER);
editButton.setFont(new java.awt.Font("Dialog", 0, 10));
editButton.setText("...");
add(editButton, java.awt.BorderLayout.EAST);
}//GEN-END:initComponents
//--------------------------------------------------------------------------
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel label;
private javax.swing.JButton editButton;
// End of variables declaration//GEN-END:variables
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,372 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor;
import java.util.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import FoamX.App;
import FoamX.Editors.DictionaryEntryEditor.EntryCache.DictionaryEntryCache;
import FoamXServer.FoamXError;
import FoamXServer.FoamXIOError;
import FoamXServer.IDictionaryEntry;
public class DictionaryEntryTableModel
extends AbstractTableModel
implements CompoundEntryListener
{
//--------------------------------------------------------------------------
public static final int NAME_COLUMN_INDEX = 0;
public static final int VALUE_COLUMN_INDEX = 1;
// Root DictionaryEntry object for this table.
protected DictionaryEntryCache rootEntry_;
protected String dictionaryKey_;
// List of DictionaryEntry objects (so can be extended by e.g. ListEditor)
protected java.util.List dictEntryList_;
// Map of DictionaryEntry objects.
protected java.util.Hashtable dictEntryMap_;
protected EventListenerList listenerList_;
protected String[] columnNames_ = { "Name", "Value" };
//--------------------------------------------------------------------------
/** DictionaryEntryTableModel default constructor for derived classes..
*/
protected DictionaryEntryTableModel()
{
rootEntry_ = null;
dictionaryKey_ = "";
dictEntryList_ = new Vector(10);
dictEntryMap_ = new Hashtable();
listenerList_ = new EventListenerList();
}
//--------------------------------------------------------------------------
/**
* DictionaryEntryTableModel constructor for compound types.
* @param compoundEntry Reference to the compound entry object.
*/
public DictionaryEntryTableModel(IDictionaryEntry compoundEntry)
{
// Default construction.
this();
try
{
// Store reference to DictionaryEntryCache for this compound entry.
rootEntry_ = DictionaryEntryCache.New(compoundEntry);
// Default dictionary key.
dictionaryKey_ = rootEntry_.getTypeDescriptor().getName();
// Initialise event listener list.
listenerList_ = new EventListenerList();
// Create a DictionaryEntryCache object for each sub-entry.
DictionaryEntryCache[] subEntries = rootEntry_.getSubElements();
dictEntryList_ = new Vector(subEntries.length);
for (int i=0; i<subEntries.length; i++)
{
DictionaryEntry dictEntry = subEntries[i];
// Add to list.
dictEntryList_.add(i, dictEntry);
// Add to map.
dictEntryMap_.put(dictEntry.getEntryName(), dictEntry);
// Subscribe to the openSubDictionary event so that we can
// forward the event to the listeners of this object.
dictEntry.addCompoundEntryListener(this);
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
public String getNameColumnTitle()
{
return columnNames_[NAME_COLUMN_INDEX];
}
public void setNameColumnTitle(String title)
{
columnNames_[NAME_COLUMN_INDEX] = title;
}
public String getValueColumnTitle()
{
return columnNames_[VALUE_COLUMN_INDEX];
}
public void setValueColumnTitle(String title)
{
columnNames_[VALUE_COLUMN_INDEX] = title;
}
public String getDictionaryKey()
{
return dictionaryKey_;
}
public void setDictionaryKey(String key)
{
dictionaryKey_ = key;
}
public DictionaryEntry getDictEntry(Object key)
{
return (DictionaryEntry)dictEntryMap_.get(key);
}
public void setDictEntry(Object key, DictionaryEntry entry)
{
dictEntryMap_.put(key, entry);
}
//--------------------------------------------------------------------------
/** Returns the index of the specified entry. */
public int getIndexOfEntry(String entryName)
{
// Return zero by default.
int index = 0;
for (int i = 0; i <dictEntryList_.size(); i++)
{
DictionaryEntry dictEntry = (DictionaryEntry)dictEntryList_.get(i);
if (entryName.compareToIgnoreCase(dictEntry.getEntryName()) == 0)
{
index = i;
break;
}
}
return index;
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
public void addCompoundEntryListener(CompoundEntryListener l)
{
listenerList_.add(CompoundEntryListener.class, l);
}
//--------------------------------------------------------------------------
public void removeCompoundEntryListener(CompoundEntryListener l)
{
listenerList_.remove(CompoundEntryListener.class, l);
}
//--------------------------------------------------------------------------
protected boolean fireOpenSubDictionaryEvent(CompoundEntryEvent evt)
{
// Process the listeners last to first, notifying those that are
// interested in this event.
Object[] listeners = listenerList_.getListenerList();
// Prepend the dictionary key and send to the module.
String fullDictName = dictionaryKey_ + "/" + evt.getName();
// Create the event object.
CompoundEntryEvent event = new CompoundEntryEvent
(
this,
CompoundEntryEvent.TYPE_DICTIONARY,
fullDictName
);
// Fire the event.
if (evt != null)
{
for (int i = listeners.length - 2; i>= 0; i -= 2)
{
if (listeners[i] == CompoundEntryListener.class)
{
return
(
(CompoundEntryListener)listeners[i+1]
).openSubDictionary(event);
}
}
}
else
{
App.printMessage
(
"DictionaryEntryTableModel.fireOpenSubDictionaryEvent"
+ "(CompoundEntryEvent evt)"
+ " : cannot fire event"
);
}
return false;
}
//--------------------------------------------------------------------------
//--- CompoundEntryListener Interface Methods
//--------------------------------------------------------------------------
public boolean openSubDictionary(CompoundEntryEvent evt)
{
// Bounce the openSubDictionary event to any listeneres.
return fireOpenSubDictionaryEvent(evt);
}
//--------------------------------------------------------------------------
//--- Abstract AbststractTableModel Methods
//--------------------------------------------------------------------------
public int getRowCount()
{
return dictEntryList_.size();
}
//--------------------------------------------------------------------------
public int getColumnCount()
{
return columnNames_.length;
}
//--------------------------------------------------------------------------
public Object getValueAt(int rowIndex, int columnIndex)
{
Object obj = null;
try
{
// Check for valid row index.
if (rowIndex>= dictEntryList_.size())
{
throw new Exception("Invalid row index");
}
// Get DictionaryEntry object for this row.
DictionaryEntry dictEntry =
(DictionaryEntry)dictEntryList_.get(rowIndex);
if (columnIndex == NAME_COLUMN_INDEX)
{
// Return the DictionaryEntry display name.
obj = dictEntry.getEntryName();
}
else
{
// Return the DictionaryEntry object for this entry.
obj = dictEntry;
}
}
catch (FoamXIOError ioErr)
{
App.handleException(ioErr);
}
catch (FoamXError fxErr)
{
App.handleException(fxErr);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return obj;
}
//--------------------------------------------------------------------------
//--- Overriden AbststractTableModel Methods
//--------------------------------------------------------------------------
public String getColumnName(int columnIndex)
{
return columnNames_[columnIndex];
}
//--------------------------------------------------------------------------
public Class getColumnClass(int columnIndex)
{
// Value column is of type DictionaryEntry.
if (columnIndex == VALUE_COLUMN_INDEX)
{
return DictionaryEntry.class;
}
// Name column is of type String.
return String.class;
}
//--------------------------------------------------------------------------
public boolean isCellEditable(int rowIndex, int columnIndex)
{
boolean bEditable = false;
try
{
if (columnIndex == VALUE_COLUMN_INDEX)
{
// Get DictionaryEntry object for this row.
DictionaryEntry dictEntry =
(DictionaryEntry)dictEntryList_.get(rowIndex);
// Return the editable flag.
bEditable = dictEntry.isEditable();
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return bEditable;
}
//--------------------------------------------------------------------------
public void setValueAt(Object aValue, int rowIndex, int columnIndex)
{
// Ignore any incoming DictionaryEntry objects.
fireTableCellUpdated(rowIndex, columnIndex);
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,93 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor;
import javax.swing.JTable;
import javax.swing.table.*;
import java.awt.Component;
import FoamX.App;
public class DictionaryNameCellRenderer
extends DefaultTableCellRenderer
{
//--------------------------------------------------------------------------
protected java.awt.Font selectedFont_;
protected java.awt.Color selectedColor_;
//--------------------------------------------------------------------------
/** DictionaryNameCellRenderer constructor. */
public DictionaryNameCellRenderer()
{
selectedFont_= new java.awt.Font("Dialog", java.awt.Font.BOLD, 10);
selectedColor_= new java.awt.Color(173, 255, 47);
}
//--------------------------------------------------------------------------
public Component getTableCellRendererComponent
(
JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column
)
{
Component comp = super.getTableCellRendererComponent
(
table,
value,
isSelected,
hasFocus,
row,
column
);
if (isSelected)
{
//comp.setFont(selectedFont_);
comp.setBackground(selectedColor_);
}
else
{
comp.setBackground(java.awt.Color.white);
}
return comp;
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,158 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor.EntryCache;
import java.text.*;
import java.awt.Frame;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import FoamXServer.CaseServer.*;
import FoamXServer.IDictionaryEntry;
import FoamXServer.IDictionaryEntryHolder;
import FoamXServer.FoamXError;
import FoamXServer.FoamXIOError;
import FoamXServer.FoamXType;
import FoamX.App;
import FoamX.Exceptions.FoamXException;
import FoamX.Editors.TypeEditor.TypeDescriptorCache;
public class BooleanCache
extends DictionaryEntryCache
// implements DictionaryEntry
{
//--------------------------------------------------------------------------
/** BooleanCache constructor. */
public BooleanCache
(
IDictionaryEntry dictEntry,
TypeDescriptorCache typeDescriptor
)
{
super(dictEntry, typeDescriptor);
}
//--------------------------------------------------------------------------
/** BooleanCache constructor. */
public BooleanCache(IDictionaryEntry dictEntry)
{
// Invoke the other constructor.
this
(
dictEntry,
new TypeDescriptorCache(dictEntry.typeDescriptor(), false)
);
}
//--------------------------------------------------------------------------
/** BooleanCache constructor. */
public BooleanCache(IDictionaryEntry dictEntry, String displayName)
{
// Invoke the other constructor.
this(dictEntry);
// Use the given display name.
displayName_ = displayName;
}
//--------------------------------------------------------------------------
protected void initialiseEditor()
{
// Use a true/false combo box.
JComboBox combo = new JComboBox();
combo.setFont(new java.awt.Font("Dialog", 0, 10));
combo.addItem("True");
combo.addItem("False");
editor_ = new DefaultCellEditor(combo);
}
//--------------------------------------------------------------------------
//---- DictionaryEntry Interface Methods
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
/**
* Called by the DictionaryCellEditor's getCellEditorValue
* method to update the value of this item after editing.
* Will not be called by editors for compound types since e.g.
* dictionary elements cannot be added/removed in FoamX.
*/
public boolean updateValue(Object value)
{
boolean bRet = false;
// Incoming value object is a string.
String strValue = (String)value;
try
{
if (value != null)
{
// Update the Any object.
value_.setValue(strValue);
// Send the Any object to the dictionary entry object.
setEntryValue();
bRet = true;
}
}
catch (NumberFormatException ex)
{
App.handleAllExceptions
(
new FoamXException
(
"Number " + strValue + " not of correct type."
)
);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return bRet;
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,136 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor.EntryCache;
import java.text.*;
import java.awt.Frame;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import FoamXServer.CaseServer.*;
import FoamXServer.IDictionaryEntry;
import FoamXServer.IDictionaryEntryHolder;
import FoamXServer.FoamXError;
import FoamXServer.FoamXIOError;
import FoamXServer.FoamXType;
import FoamX.App;
import FoamX.Exceptions.FoamXException;
import FoamX.Util.FoamXAny;
import FoamX.Util.FoamXTypeEx;
import FoamX.Editors.TypeEditor.TypeDescriptorCache;
import FoamX.Editors.DictionaryEntryEditor.DictionaryEntryCompoundEditor;
import FoamX.CaseManagement.CaseChooserDlg;
import FoamX.CaseManagement.CaseBrowserPanel;
public class CaseNameCache
extends RootAndCaseCache
{
//--------------------------------------------------------------------------
/** CaseNameCache constructor. */
public CaseNameCache
(
IDictionaryEntry dictEntry,
TypeDescriptorCache typeDescriptor
)
{
super(dictEntry, typeDescriptor);
}
//--------------------------------------------------------------------------
/** CaseNameCache constructor. */
public CaseNameCache(IDictionaryEntry dictEntry)
{
// Invoke the other constructor.
this
(
dictEntry,
new TypeDescriptorCache(dictEntry.typeDescriptor(), false)
);
}
//--------------------------------------------------------------------------
/** CaseNameCache constructor. */
public CaseNameCache(IDictionaryEntry dictEntry, String displayName)
{
// Invoke the other constructor.
this(dictEntry);
// Use the given display name.
displayName_ = displayName;
}
//--------------------------------------------------------------------------
protected void editButtonActionPerformed(java.awt.event.ActionEvent evt)
{
// The edit button has been pressed. The user wants to edit this entry.
try
{
// Pop up case chooser panel
CaseChooserDlg caseChooser =
new CaseChooserDlg
(
App.getRootFrame(),
CaseBrowserPanel.SELECT_CASE_MODE
);
caseChooser.show();
if
(
(caseChooser.getCaseRoot() != null)
&& (caseChooser.getCaseName() != null)
&& (caseChooser.getCaseBrowser() != null)
)
{
updateValue(caseChooser.getCaseName());
// Signal that editing has stopped.
editor_.stopCellEditing();
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,142 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor.EntryCache;
import java.text.*;
import java.awt.Frame;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import FoamXServer.CaseServer.*;
import FoamXServer.IDictionaryEntry;
import FoamXServer.IDictionaryEntryHolder;
import FoamXServer.FoamXError;
import FoamXServer.FoamXIOError;
import FoamXServer.FoamXType;
import FoamX.App;
import FoamX.Exceptions.FoamXException;
import FoamX.Util.FoamXAny;
import FoamX.Util.FoamXTypeEx;
import FoamX.Editors.TypeEditor.TypeDescriptorCache;
public class CharCache
extends DictionaryEntryCache
// implements DictionaryEntry
{
//--------------------------------------------------------------------------
/** CharCache constructor. */
public CharCache
(
IDictionaryEntry dictEntry,
TypeDescriptorCache typeDescriptor
)
{
super(dictEntry, typeDescriptor);
}
//--------------------------------------------------------------------------
/** CharCache constructor. */
public CharCache(IDictionaryEntry dictEntry)
{
// Invoke the other constructor.
this
(
dictEntry,
new TypeDescriptorCache(dictEntry.typeDescriptor(), false)
);
}
//--------------------------------------------------------------------------
/** CharCache constructor. */
public CharCache(IDictionaryEntry dictEntry, String displayName)
{
// Invoke the other constructor.
this(dictEntry);
// Use the given display name.
displayName_ = displayName;
}
//--------------------------------------------------------------------------
protected void initialiseEditor()
{
// Give dictionaryEntryCache opportunity to install combo editor
super.initialiseEditor();
if (editor_ == null)
{
// No custom editor - use string-based
// DefaultCellEditor.
}
}
//--------------------------------------------------------------------------
//---- DictionaryEntry Interface Methods
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
/**
* Called by the DictionaryCellEditor's getCellEditorValue
* method to update the value of this item after editing.
* Will not be called by editors for compound types since e.g.
* dictionary elements cannot be added/removed in FoamX.
*/
public boolean updateValue(Object value)
{
boolean bRet = false;
String strValue;
try
{
if (value != null)
{
// Incoming value object is a string.
strValue = (String)value;
// Update the Any object.
value_.setValue(strValue);
// Send the Any object to the dictionary entry object.
setEntryValue();
bRet = true;
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return bRet;
}
}

View File

@ -0,0 +1,286 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor.EntryCache;
import java.text.*;
import java.awt.Frame;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import FoamXServer.CaseServer.*;
import FoamXServer.IDictionaryEntry;
import FoamXServer.IDictionaryEntryHolder;
import FoamXServer.FoamXError;
import FoamXServer.FoamXIOError;
import FoamXServer.FoamXType;
import FoamX.App;
import FoamX.Exceptions.FoamXException;
import FoamX.Editors.CompoundEditor;
import FoamX.Editors.SelectionEditor;
import FoamX.Editors.DimensionSetEditor;
import FoamX.Editors.ListEditor;
import FoamX.Editors.FixedListEditor;
import FoamX.Util.FoamXAny;
import FoamX.Util.FoamXTypeEx;
import FoamX.Editors.TypeEditor.TypeDescriptorCache;
import FoamX.Editors.DictionaryEntryEditor.DictionaryEntryCompoundEditor;
import FoamX.Editors.DictionaryEntryEditor.*;
public class CompoundCache
extends DictionaryEntryCache
// implements DictionaryEntry
{
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
/** CompoundCache constructor. */
public CompoundCache
(
IDictionaryEntry dictEntry,
TypeDescriptorCache typeDescriptor
)
{
super(dictEntry, typeDescriptor);
if (dictEntry_.subElements().length == 0)
{
editable_ = false;
}
}
//--------------------------------------------------------------------------
/** CompoundCache constructor. */
public CompoundCache(IDictionaryEntry dictEntry)
{
// Invoke the other constructor.
this
(
dictEntry,
new TypeDescriptorCache(dictEntry.typeDescriptor(), false)
);
}
//--------------------------------------------------------------------------
/** CompoundCache constructor. */
public CompoundCache(IDictionaryEntry dictEntry, String displayName)
{
// Invoke the other constructor.
this(dictEntry);
// Use the given display name.
displayName_ = displayName;
}
//--------------------------------------------------------------------------
public String toString()
{
// Initialise if required.
if (displayValue_.length() == 0)
{
displayValue_ = getCompoundDisplayString(3);
}
return displayValue_;
}
//--------------------------------------------------------------------------
/**
* Variant of toString which appends compound entries.
* Used to convert argument dictionary to argument string.
*/
public void toStringRaw(Vector argListVector)
{
getCompoundValueString(argListVector);
}
//--------------------------------------------------------------------------
// Update cached value from IDictionaryEntry
protected void getEntryValue()
{}
//--------------------------------------------------------------------------
// Update IDictionaryEntry value from cached value
protected void setEntryValue()
{}
//--------------------------------------------------------------------------
protected void initialiseEditor()
{
// Use compound editor.
DictionaryEntryCompoundEditor compEdit =
new DictionaryEntryCompoundEditor();
// Subscribe to the edit button's action event so
// that we can invoke the appropriate edit action for
// the compound types.
compEdit.addActionListener
(
new java.awt.event.ActionListener()
{
public void actionPerformed
(
java.awt.event.ActionEvent evt
)
{
editButtonActionPerformed(evt);
}
}
);
editor_ = compEdit;
}
//--------------------------------------------------------------------------
protected void editButtonActionPerformed(java.awt.event.ActionEvent evt)
{
// The edit button has been pressed. The user wants to edit this entry.
try
{
// Show modal compound editor dialog.
CompoundEditor editor = new CompoundEditor
(
App.getRootFrame(),
dictEntry_
);
editor.setTitle(displayName_);
editor.show();
// Update the cached display string.
displayValue_ = getCompoundDisplayString(3);
// Signal that editing has stopped.
editor_.stopCellEditing();
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
/* render compound by adding first maxEntries values, separated by ',' */
protected String getCompoundDisplayString(int maxEntries)
{
String vecString = "";
try
{
// Loop over sub-entries and generate a string representation of
// the vector.
IDictionaryEntry[] subEntries = dictEntry_.subElements();
for (int i=0; i <subEntries.length; i++)
{
DictionaryEntryCache dictEntryCache =
DictionaryEntryCache.New(subEntries[i]);
vecString += dictEntryCache.toString();
if (i < subEntries.length - 1 && i < maxEntries)
{
// Add comma if more values to follow.
vecString += ", ";
}
else if (i == maxEntries)
{
// Reached maximum number of values.
vecString += " ...";
break;
}
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return vecString;
}
//--------------------------------------------------------------------------
/* render compound by adding all values to vector */
protected void getCompoundValueString(Vector argListVector)
{
try
{
// Loop over sub-entries and generate a string representation of
// the vector.
IDictionaryEntry[] subEntries = dictEntry_.subElements();
for (int i = 0; i < subEntries.length; i++)
{
DictionaryEntryCache dictEntryCache =
DictionaryEntryCache.New(subEntries[i]);
dictEntryCache.toStringRaw(argListVector);
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
/**
* Called by the DictionaryCellEditor's getCellEditorValue
* method to update the value of this item after editing.
* Will not be called by editors for compound types since e.g.
* dictionary elements cannot be added/removed in FoamX.
*/
public boolean updateValue(Object value)
{
//try
//{
// throw new Exception("Invalid call to updateValue.");
//}
//catch (Exception ex)
//{
// App.handleAllExceptions(ex);
//}
return false;
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,184 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor.EntryCache;
import java.text.*;
import java.awt.Frame;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import FoamXServer.CaseServer.*;
import FoamXServer.IDictionaryEntry;
import FoamXServer.IDictionaryEntryHolder;
import FoamXServer.FoamXError;
import FoamXServer.FoamXIOError;
import FoamXServer.FoamXType;
import FoamX.App;
import FoamX.Exceptions.FoamXException;
import FoamX.Editors.CompoundEditor;
import FoamX.Editors.SelectionEditor;
import FoamX.Editors.DimensionSetEditor;
import FoamX.Editors.ListEditor;
import FoamX.Editors.FixedListEditor;
import FoamX.Util.FoamXAny;
import FoamX.Util.FoamXTypeEx;
import FoamX.Editors.TypeEditor.TypeDescriptorCache;
import FoamX.Editors.DictionaryEntryEditor.SelectionEntryCellRenderer;
import FoamX.Editors.DictionaryEntryEditor.CompoundEntryEvent;
import FoamX.Editors.DictionaryEntryEditor.CompoundEntryListener;
public class DictionaryCache
extends CompoundCache
// implements DictionaryEntry
{
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
/** DictionaryCache constructor. */
public DictionaryCache
(
IDictionaryEntry dictEntry,
TypeDescriptorCache typeDescriptor
)
{
super(dictEntry, typeDescriptor);
}
//--------------------------------------------------------------------------
/** DictionaryCache constructor. */
public DictionaryCache(IDictionaryEntry dictEntry)
{
// Invoke the other constructor.
this
(
dictEntry,
new TypeDescriptorCache(dictEntry.typeDescriptor(), false)
);
}
//--------------------------------------------------------------------------
/** DictionaryCache constructor. */
public DictionaryCache(IDictionaryEntry dictEntry, String displayName)
{
// Invoke the other constructor.
this(dictEntry);
// Use the given display name.
displayName_ = displayName;
}
//--------------------------------------------------------------------------
public String toString()
{
// Initialise if required.
if (displayValue_.length() == 0)
{
displayValue_ = "Dictionary...";
}
return displayValue_;
}
//--------------------------------------------------------------------------
protected void editButtonActionPerformed(java.awt.event.ActionEvent evt)
{
// The edit button has been pressed. The user wants to edit this entry.
try
{
if (!fireOpenSubDictionaryEvent())
{
// Show modal compound editor dialog.
CompoundEditor editor = new CompoundEditor
(
App.getRootFrame(),
dictEntry_
);
editor.setTitle(displayName_);
editor.show();
// Update the cached display string.
displayValue_ = getCompoundDisplayString(3);
// Signal that editing has stopped.
editor_.stopCellEditing();
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
protected boolean fireOpenSubDictionaryEvent()
{
// Send the sub-dictionary name to the module.
// Process the listeners last to first, notifying those that are
// interested in this event.
Object[] listeners = listenerList_.getListenerList();
// Create the event object.
CompoundEntryEvent event =
new CompoundEntryEvent
(
this,
CompoundEntryEvent.TYPE_DICTIONARY,
typeDescriptor_.getName()
);
// Fire the event.
for (int i = listeners.length - 2; i>= 0; i -= 2)
{
if (listeners[i] == CompoundEntryListener.class)
{
return
(
(CompoundEntryListener)listeners[i+1])
.openSubDictionary(event);
}
}
return false;
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,595 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor.EntryCache;
import java.text.*;
import java.awt.Frame;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import FoamXServer.CaseServer.*;
import FoamXServer.IDictionaryEntry;
import FoamXServer.IDictionaryEntryHolder;
import FoamXServer.FoamXError;
import FoamXServer.FoamXIOError;
import FoamXServer.FoamXType;
import FoamX.App;
import FoamX.Exceptions.FoamXException;
import FoamX.Editors.CompoundEditor;
import FoamX.Editors.SelectionEditor;
import FoamX.Editors.DimensionSetEditor;
import FoamX.Editors.ListEditor;
import FoamX.Editors.FixedListEditor;
import FoamX.Util.FoamXAny;
import FoamX.Util.FoamXTypeEx;
import FoamX.Editors.TypeEditor.TypeDescriptorCache;
import FoamX.Editors.DictionaryEntryEditor.SelectionEntryCellRenderer;
import FoamX.Editors.DictionaryEntryEditor.DictionaryEntry;
import FoamX.Editors.DictionaryEntryEditor.CompoundEntryListener;
import FoamX.Editors.DictionaryEntryEditor.CompoundEntryEvent;
import FoamX.Editors.DictionaryEntryEditor.DictionaryEntryCompoundEditor;
public class DictionaryEntryCache
implements DictionaryEntry
{
//--------------------------------------------------------------------------
// Reference to the dict entry object for this item.
protected IDictionaryEntry dictEntry_;
// Cached type descriptor for this entry.
protected TypeDescriptorCache typeDescriptor_;
// Cached value
protected FoamXAny value_;
// Cached type of type descriptor
protected int typeValue_;
// Name of this entry. Defaults to the display name specified by the
// type descriptor.
protected String displayName_;
// Cached String representation of the current value of this entry.
protected String displayValue_;
protected boolean editable_;
protected boolean current_;
protected boolean modified_;
// Custom renderer object.
protected TableCellRenderer renderer_;
// Custom editor object.
protected TableCellEditor editor_;
// Listeners for open sub dictionary events
protected EventListenerList listenerList_;
//--------------------------------------------------------------------------
/** DictionaryEntryCache constructor. */
public DictionaryEntryCache
(
IDictionaryEntry dictEntry,
TypeDescriptorCache typeDescriptor
)
{
try
{
// Store IDictionaryEntry reference.
dictEntry_ = dictEntry;
// Get TypeDescriptor information.
typeDescriptor_ = typeDescriptor;
FoamXType type = typeDescriptor_.getType();
typeValue_ = type.value();
displayName_ = typeDescriptor_.getDisplayName();
displayValue_ = "";
// Make sure that we have a name to display.
if (displayName_ == null || displayName_.length() == 0)
{
displayName_ = typeDescriptor_.getName();
}
// Initialise event listener list.
listenerList_ = new EventListenerList();
// Get current value if we have one. Need a value before we
// initialise the Renderer and Editor objects.
getEntryValue();
// Editable if typeDescriptor says so
editable_ = typeDescriptor_.isEditable();
// Now, initialise rest of member variables.
current_ = false;
modified_ = dictEntry.modified();
// Initialise the renderer and editor for this entry.
initialiseRenderer();
initialiseEditor();
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
/** DictionaryEntryCache constructor. */
public DictionaryEntryCache(IDictionaryEntry dictEntry)
{
// Invoke the other constructor.
this
(
dictEntry,
new TypeDescriptorCache(dictEntry.typeDescriptor(), false)
);
}
//--------------------------------------------------------------------------
/** DictionaryEntryCache constructor. */
public DictionaryEntryCache(IDictionaryEntry dictEntry, String displayName)
{
// Invoke the other constructor.
this(dictEntry);
// Use the given display name.
displayName_ = displayName;
}
//--------------------------------------------------------------------------
/** DictionaryEntryCache factory. */
static public DictionaryEntryCache New
(
IDictionaryEntry dictEntry,
TypeDescriptorCache typeDescriptor
)
{
try
{
int typeValue = typeDescriptor.getType().value();
switch (typeValue)
{
case FoamXType._Type_Boolean:
return new BooleanCache(dictEntry, typeDescriptor);
case FoamXType._Type_Label:
return new LabelCache(dictEntry, typeDescriptor);
case FoamXType._Type_Scalar:
return new ScalarCache(dictEntry, typeDescriptor);
case FoamXType._Type_Char:
return new CharCache(dictEntry, typeDescriptor);
case FoamXType._Type_Word:
return new WordCache(dictEntry, typeDescriptor);
case FoamXType._Type_String:
return new StringCache(dictEntry, typeDescriptor);
case FoamXType._Type_RootDir:
return new RootDirCache(dictEntry, typeDescriptor);
case FoamXType._Type_RootAndCase:
return new RootAndCaseCache(dictEntry, typeDescriptor);
case FoamXType._Type_CaseName:
return new CaseNameCache(dictEntry, typeDescriptor);
case FoamXType._Type_HostName:
return new HostNameCache(dictEntry, typeDescriptor);
case FoamXType._Type_File:
return new StringCache(dictEntry, typeDescriptor);
case FoamXType._Type_Directory:
return new StringCache(dictEntry, typeDescriptor);
case FoamXType._Type_Time:
return new TimeCache(dictEntry, typeDescriptor);
case FoamXType._Type_DimensionSet:
return new DimensionSetCache(dictEntry, typeDescriptor);
case FoamXType._Type_FixedList:
return new FixedListCache(dictEntry, typeDescriptor);
case FoamXType._Type_List:
return new ListCache(dictEntry, typeDescriptor);
case FoamXType._Type_Selection:
if (dictEntry.subElements().length == 1)
{
// Selection with one entry.
App.printMessage
(
App.DEBUGLEVEL_DEBUG,
"Skipping single element Selection " + dictEntry
);
return New
(
dictEntry.subElements()[0],
new TypeDescriptorCache
(
typeDescriptor.TypeDescriptor().subTypes()[0],
false
)
);
}
else
{
return new SelectionCache(dictEntry, typeDescriptor);
}
case FoamXType._Type_Dictionary:
return new DictionaryCache(dictEntry, typeDescriptor);
case FoamXType._Type_Compound:
return new CompoundCache(dictEntry, typeDescriptor);
default:
throw new Exception
(
"Invalid type in DictionaryEntryCache::New."
);
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return null;
}
//--------------------------------------------------------------------------
/** DictionaryEntryCache factory. */
static public DictionaryEntryCache New(IDictionaryEntry dictEntry)
{
// Invoke the other factory.
return New
(
dictEntry,
new TypeDescriptorCache(dictEntry.typeDescriptor(), false)
);
}
//--------------------------------------------------------------------------
/** DictionaryEntryCache constructor. */
static public DictionaryEntryCache New
(
IDictionaryEntry dictEntry,
String displayName
)
{
// Invoke the other constructor.
DictionaryEntryCache entry = New(dictEntry);
// Use the given display name.
entry.setEntryName(displayName);
return entry;
}
//--------------------------------------------------------------------------
public IDictionaryEntry getDictEntry()
{
return dictEntry_;
}
public TypeDescriptorCache getTypeDescriptor()
{
return typeDescriptor_;
}
public void setEditable(boolean editable)
{
editable_ = editable;
}
public void setCurrent(boolean current)
{
current_ = current;
}
public boolean isModified()
{
return modified_;
}
public void setEntryName(String displayName)
{
displayName_ = displayName;
}
//--------------------------------------------------------------------------
/**
* Get array of sub elements
*/
public DictionaryEntryCache[] getSubElements()
{
IDictionaryEntry[] subEntries = dictEntry_.subElements();
DictionaryEntryCache[] cachedElems =
new DictionaryEntryCache[subEntries.length];
for (int i=0; i<subEntries.length; i++)
{
cachedElems[i] = DictionaryEntryCache.New(subEntries[i]);
}
return cachedElems;
}
//--------------------------------------------------------------------------
/**
* Return subdictionary by name
*/
public DictionaryEntryCache getSubEntry
(
String subName
)
{
IDictionaryEntry[] subEntries = dictEntry_.subElements();
for (int i=0; i <subEntries.length; i++)
{
IDictionaryEntry subEntry = subEntries[i];
if (subEntry.typeDescriptor().name().equals(subName))
{
// Release Corba object
subEntries = null;
return DictionaryEntryCache.New(subEntry);
}
}
// Release Corba object
subEntries = null;
return null;
}
//--------------------------------------------------------------------------
/**
* Write for debugging.
*/
public void write()
{
try
{
System.out.println("displayName_:" + displayName_);
System.out.println("value_:" + value_);
System.out.println("typeValue_:" + typeValue_);
System.out.println("displayValue_:" + displayValue_);
System.out.println("editable_:" + editable_);
System.out.println("current_:" + current_);
System.out.println("modified_:" + modified_);
//System.out.println("dictEntry_:" + dictEntry_);
System.out.println("typeDescriptor_:" + typeDescriptor_);
String[] valueList = typeDescriptor_.getValueList();
if (valueList != null)
{
for (int i=0; i <valueList.length; i++)
{
System.out.println(" value:" + valueList[i]);
}
}
IDictionaryEntry[] subEntries = dictEntry_.subElements();
for (int i=0; i <subEntries.length; i++)
{
DictionaryEntryCache subEntry = new DictionaryEntryCache
(
subEntries[i]
);
System.out.println(" subEntry:" + subEntry);
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
/**
* Return an appropriate string representation of the
* current value in the unselected state. Used by the
* default cell renderer to set the text for the label.
*/
public String toString()
{
try
{
// Convert the Any object to a nice string.
displayValue_ = value_.toString();
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return displayValue_;
}
//--------------------------------------------------------------------------
/**
* Variant of toString which appends compound entries.
* Used to convert argument dictionary to argument string.
*/
public void toStringRaw(Vector argListVector)
{
try
{
// Convert the Any object to a nice string.
argListVector.addElement(value_.toString());
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
// Fill cached value
protected void getEntryValue()
{
value_ = new FoamXAny(dictEntry_.value());
}
//--------------------------------------------------------------------------
// Write cached value
protected void setEntryValue()
{
try
{
dictEntry_.value(value_.getAny());
modified_ = true;
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
protected void initialiseRenderer()
{
// No custom renderer - use DefaultTableCellRenderer wich
// renders the name of this object, via the toString method,
// into a JLabel object.
}
//--------------------------------------------------------------------------
protected void initialiseEditor()
{
try
{
// If this type has a constrained value list, use a combo box
// to edit it.
if (typeDescriptor_.getValueList().length > 0)
{
String[] valueList = typeDescriptor_.getValueList();
JComboBox combo = new JComboBox();
combo.setFont(new java.awt.Font("Dialog", 0, 10));
for (int i=0; i <valueList.length; i++)
{
combo.addItem(valueList[i]);
}
editor_ = new DefaultCellEditor(combo);
}
else
{
// No custom editor - use string-based
// DefaultCellEditor.
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
//---- DictionaryEntry Interface Methods
//--------------------------------------------------------------------------
public String getEntryName()
{
return displayName_;
}
public String getEntryDescription()
{
return typeDescriptor_.getDescription();
}
public String getEntryValueString()
{
return toString();
}
public boolean isEditable()
{
return editable_;
}
public boolean isCurrent()
{
return current_;
}
public TableCellRenderer getRenderer()
{
return renderer_;
}
public TableCellEditor getEditor()
{
return editor_;
}
//--------------------------------------------------------------------------
/**
* Called by the DictionaryCellEditor's getCellEditorValue
* method to update the value of this item after editing.
* Will not be called by editors for compound types since e.g.
* dictionary elements cannot be added/removed in FoamX.
*/
public boolean updateValue(Object value)
{
try
{
throw new Exception("updateValue not overloaded!");
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return false;
}
//--------------------------------------------------------------------------
public void addCompoundEntryListener(CompoundEntryListener l)
{
listenerList_.add(CompoundEntryListener.class, l);
}
//--------------------------------------------------------------------------
public void removeCompoundEntryListener(CompoundEntryListener l)
{
listenerList_.remove(CompoundEntryListener.class, l);
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,166 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor.EntryCache;
import java.text.*;
import java.awt.Frame;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import FoamXServer.CaseServer.*;
import FoamXServer.IDictionaryEntry;
import FoamXServer.IDictionaryEntryHolder;
import FoamXServer.FoamXError;
import FoamXServer.FoamXIOError;
import FoamXServer.FoamXType;
import FoamX.App;
import FoamX.Exceptions.FoamXException;
import FoamX.Editors.DimensionSetEditor;
import FoamX.Util.FoamXAny;
import FoamX.Util.FoamXTypeEx;
import FoamX.Editors.TypeEditor.TypeDescriptorCache;
public class DimensionSetCache
extends DictionaryEntryCache
{
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
/** DimensionSetCache constructor. */
public DimensionSetCache
(
IDictionaryEntry dictEntry,
TypeDescriptorCache typeDescriptor
)
{
super(dictEntry, typeDescriptor);
}
//--------------------------------------------------------------------------
/** DimensionSetCache constructor. */
public DimensionSetCache(IDictionaryEntry dictEntry)
{
// Invoke the other constructor.
this
(
dictEntry,
new TypeDescriptorCache(dictEntry.typeDescriptor(), false)
);
}
//--------------------------------------------------------------------------
/** DimensionSetCache constructor. */
public DimensionSetCache(IDictionaryEntry dictEntry, String displayName)
{
// Invoke the other constructor.
this(dictEntry);
// Use the given display name.
displayName_ = displayName;
}
//--------------------------------------------------------------------------
/**
* Return an appropriate string representation of the
* current value in the unselected state. Used by the
* default cell renderer to set the text for the label.
*/
public String toString()
{
try
{
// Convert the Any object to a nice string.
displayValue_ = value_.toString();
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return displayValue_;
}
//--------------------------------------------------------------------------
/**
* Variant of toString which appends compound entries.
* Used to convert argument dictionary to argument string.
*/
public void toStringRaw(Vector argListVector)
{
try
{
// Convert the Any object to a nice string.
argListVector.addElement(value_.toString());
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
protected void editButtonActionPerformed(java.awt.event.ActionEvent evt)
{
// The edit button has been pressed. The user wants to edit this entry.
try
{
// Show modal dimension set editor dialog.
DimensionSetEditor editor =
new DimensionSetEditor(App.getRootFrame(), dictEntry_);
editor.setTitle(displayName_);
editor.show();
// Update value in case it has been updated.
getEntryValue();
// Signal that editing has stopped.
editor_.stopCellEditing();
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,162 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor.EntryCache;
import java.text.*;
import java.awt.Frame;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import FoamXServer.CaseServer.*;
import FoamXServer.IDictionaryEntry;
import FoamXServer.IDictionaryEntryHolder;
import FoamXServer.FoamXError;
import FoamXServer.FoamXIOError;
import FoamXServer.FoamXType;
import FoamX.App;
import FoamX.Exceptions.FoamXException;
import FoamX.Editors.DimensionSetEditor;
import FoamX.Util.FoamXAny;
import FoamX.Util.FoamXTypeEx;
import FoamX.Editors.FixedListEditor;
import FoamX.Editors.TypeEditor.TypeDescriptorCache;
public class FixedListCache
extends CompoundCache
// implements DictionaryEntry
{
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
/** FixedListCache constructor. */
public FixedListCache
(
IDictionaryEntry dictEntry,
TypeDescriptorCache typeDescriptor
)
{
super(dictEntry, typeDescriptor);
}
//--------------------------------------------------------------------------
/** FixedListCache constructor. */
public FixedListCache(IDictionaryEntry dictEntry)
{
// Invoke the other constructor.
this
(
dictEntry,
new TypeDescriptorCache(dictEntry.typeDescriptor(), false)
);
}
//--------------------------------------------------------------------------
/** FixedListCache constructor. */
public FixedListCache(IDictionaryEntry dictEntry, String displayName)
{
// Invoke the other constructor.
this(dictEntry);
// Use the given display name.
displayName_ = displayName;
}
//--------------------------------------------------------------------------
/**
* Variant of toString which appends compound entries.
* Used to convert command line arguments dictionary to argument string.
* Note that now a FixedList will become one argument string.
*/
public void toStringRaw(Vector argListVector)
{
// Collect arguments into vector (only so we can reuse
// CompoundCache.toStringRaw functionality)
Vector subArgs = new Vector();
super.toStringRaw(subArgs);
// Compose single string out of arguments. Enclose in brackets.
String argString = "(";
for (int i = 0; i < subArgs.size(); i++)
{
if (i > 0)
{
argString += " ";
}
argString += (String)subArgs.elementAt(i);
}
argString += ")";
// Add as single argument
argListVector.addElement(argString);
}
//--------------------------------------------------------------------------
protected void editButtonActionPerformed(java.awt.event.ActionEvent evt)
{
// The edit button has been pressed. The user wants to edit this entry.
try
{
// Show modal vector space editor dialog.
FixedListEditor editor = new FixedListEditor
(
App.getRootFrame(),
dictEntry_,
typeDescriptor_
);
editor.setTitle(displayName_);
editor.show();
// Update the cached display string.
displayValue_ = getCompoundDisplayString(3);
// Signal that editing has stopped.
editor_.stopCellEditing();
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,195 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor.EntryCache;
import java.text.*;
import java.awt.Frame;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import FoamXServer.CaseServer.*;
import FoamXServer.IDictionaryEntry;
import FoamXServer.IDictionaryEntryHolder;
import FoamXServer.FoamXError;
import FoamXServer.FoamXIOError;
import FoamXServer.FoamXType;
import FoamX.App;
import FoamX.Exceptions.FoamXException;
import FoamX.Util.FoamXAny;
import FoamX.Util.FoamXTypeEx;
import FoamX.Editors.TypeEditor.TypeDescriptorCache;
import FoamX.Editors.DictionaryEntryEditor.DictionaryEntryCompoundEditor;
import FoamX.CaseManagement.HostChooserDlg;
public class HostNameCache
extends DictionaryEntryCache
// implements DictionaryEntry
{
//--------------------------------------------------------------------------
/** HostNameCache constructor. */
public HostNameCache
(
IDictionaryEntry dictEntry,
TypeDescriptorCache typeDescriptor
)
{
super(dictEntry, typeDescriptor);
}
//--------------------------------------------------------------------------
/** HostNameCache constructor. */
public HostNameCache(IDictionaryEntry dictEntry)
{
// Invoke the other constructor.
this
(
dictEntry,
new TypeDescriptorCache(dictEntry.typeDescriptor(), false)
);
}
//--------------------------------------------------------------------------
/** HostNameCache constructor. */
public HostNameCache(IDictionaryEntry dictEntry, String displayName)
{
// Invoke the other constructor.
this(dictEntry);
// Use the given display name.
displayName_ = displayName;
}
//--------------------------------------------------------------------------
protected void initialiseEditor()
{
// Use compound editor.
DictionaryEntryCompoundEditor compEdit =
new DictionaryEntryCompoundEditor();
// Subscribe to the edit button's action event so
// that we can invoke the appropriate edit action for
// the compound types.
compEdit.addActionListener
(
new java.awt.event.ActionListener()
{
public void actionPerformed
(
java.awt.event.ActionEvent evt
)
{
editButtonActionPerformed(evt);
}
}
);
editor_ = compEdit;
}
//--------------------------------------------------------------------------
protected void editButtonActionPerformed(java.awt.event.ActionEvent evt)
{
// The edit button has been pressed. The user wants to edit this entry.
try
{
// Pop up host chooser panel
HostChooserDlg hostChooser =
new HostChooserDlg(App.getRootFrame());
hostChooser.show();
if (hostChooser.getHostName() != null)
{
// Update the cached display string.
displayValue_ = hostChooser.getHostName();
// Signal that editing has stopped.
editor_.stopCellEditing();
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
//---- DictionaryEntry Interface Methods
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
/**
* Called by the DictionaryCellEditor's getCellEditorValue
* method to update the value of this item after editing.
* Will not be called by editors for compound types since e.g.
* dictionary elements cannot be added/removed in FoamX.
*/
public boolean updateValue(Object value)
{
boolean bRet = false;
String strValue;
try
{
if (value != null)
{
// Incoming value object is a string.
strValue = (String)value;
// Update the Any object.
value_.setValue(strValue);
// Send the Any object to the dictionary entry object.
setEntryValue();
bRet = true;
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return bRet;
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,193 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor.EntryCache;
import java.text.*;
import java.awt.Frame;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import FoamXServer.CaseServer.*;
import FoamXServer.IDictionaryEntry;
import FoamXServer.IDictionaryEntryHolder;
import FoamXServer.FoamXError;
import FoamXServer.FoamXIOError;
import FoamXServer.FoamXType;
import FoamX.App;
import FoamX.Exceptions.FoamXException;
import FoamX.Util.FoamXAny;
import FoamX.Util.FoamXTypeEx;
import FoamX.Editors.TypeEditor.TypeDescriptorCache;
public class LabelCache
extends DictionaryEntryCache
// implements DictionaryEntry
{
//--------------------------------------------------------------------------
/** LabelCache constructor. */
public LabelCache
(
IDictionaryEntry dictEntry,
TypeDescriptorCache typeDescriptor
)
{
super(dictEntry, typeDescriptor);
}
//--------------------------------------------------------------------------
/** LabelCache constructor. */
public LabelCache(IDictionaryEntry dictEntry)
{
// Invoke the other constructor.
this
(
dictEntry,
new TypeDescriptorCache(dictEntry.typeDescriptor(), false)
);
}
//--------------------------------------------------------------------------
/** LabelCache constructor. */
public LabelCache(IDictionaryEntry dictEntry, String displayName)
{
// Invoke the other constructor.
this(dictEntry);
// Use the given display name.
displayName_ = displayName;
}
//--------------------------------------------------------------------------
protected void initialiseEditor()
{
// Give dictionaryEntryCache opportunity to install combo editor
super.initialiseEditor();
if (editor_ == null)
{
// No custom editor - use string-based
// DefaultCellEditor.
}
}
//--------------------------------------------------------------------------
//---- DictionaryEntry Interface Methods
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
/**
* Called by the DictionaryCellEditor's getCellEditorValue
* method to update the value of this item after editing.
* Will not be called by editors for compound types since e.g.
* dictionary elements cannot be added/removed in FoamX.
*/
public boolean updateValue(Object value)
{
boolean bRet = false;
String strValue = "";
try
{
if (value != null)
{
// Incoming value object is a string.
strValue = (String)value;
// Check against type min and max if available
FoamXAny minVal = typeDescriptor_.getMinValue();
FoamXAny maxVal = typeDescriptor_.getMaxValue();
if
(
(
minVal.getAny().type.value()
== FoamXType._Type_Label
)
&&
(
maxVal.getAny().type.value()
== FoamXType._Type_Label
)
)
{
int intValue = Integer.parseInt(strValue);
int minValue = Integer.parseInt(minVal.toString());
int maxValue = Integer.parseInt(maxVal.toString());
if ((intValue < minValue) || (intValue > maxValue))
{
throw new FoamXException
(
"Label " + intValue + " out of range ["
+ minValue + " , " + maxValue + "]"
);
}
}
// Update the Any object.
value_.setValue(strValue);
// Send the Any object to the dictionary entry object.
setEntryValue();
bRet = true;
}
}
catch (NumberFormatException ex)
{
App.handleAllExceptions
(
new FoamXException
(
"Number " + strValue + " not of correct type."
)
);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return bRet;
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,273 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor.EntryCache;
import java.text.*;
import java.awt.Frame;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import FoamXServer.CaseServer.*;
import FoamXServer.IDictionaryEntry;
import FoamXServer.IDictionaryEntryHolder;
import FoamXServer.FoamXError;
import FoamXServer.FoamXIOError;
import FoamXServer.FoamXType;
import FoamX.App;
import FoamX.Exceptions.FoamXException;
import FoamX.Editors.CompoundEditor;
import FoamX.Editors.SelectionEditor;
import FoamX.Editors.DimensionSetEditor;
import FoamX.Editors.ListEditor;
import FoamX.Editors.FixedListEditor;
import FoamX.Util.FoamXAny;
import FoamX.Util.FoamXTypeEx;
import FoamX.Editors.TypeEditor.TypeDescriptorCache;
import FoamX.Editors.DictionaryEntryEditor.SelectionEntryCellRenderer;
public class ListCache
extends CompoundCache
// implements DictionaryEntry
{
//--------------------------------------------------------------------------
// Length of list before confirming edit.
public static final int MAX_EDIT_LENGTH = 100;
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
/** ListCache constructor. */
public ListCache
(
IDictionaryEntry dictEntry,
TypeDescriptorCache typeDescriptor
)
{
super(dictEntry, typeDescriptor);
// Reset editable. CompoundCache set it to false for zero element lists.
editable_ = typeDescriptor_.isEditable();
}
//--------------------------------------------------------------------------
/** ListCache constructor. */
public ListCache(IDictionaryEntry dictEntry)
{
// Invoke the other constructor.
this
(
dictEntry,
new TypeDescriptorCache(dictEntry.typeDescriptor(), false)
);
}
//--------------------------------------------------------------------------
/** ListCache constructor. */
public ListCache(IDictionaryEntry dictEntry, String displayName)
{
// Invoke the other constructor.
this(dictEntry);
// Use the given display name.
displayName_ = displayName;
}
//--------------------------------------------------------------------------
public String toString()
{
// Initialise if required.
if (displayValue_.length() == 0)
{
displayValue_ = "List...";
}
return displayValue_;
}
//--------------------------------------------------------------------------
/**
* Variant of toString which appends compound entries.
* Used to convert command line arguments dictionary to argument string.
* Note that now a List will become one argument string.
*/
public void toStringRaw(Vector argListVector)
{
// Collect arguments into vector (only so we can reuse
// CompoundCache.toStringRaw functionality)
Vector subArgs = new Vector();
super.toStringRaw(subArgs);
// Compose single string out of arguments. Enclose in brackets.
String argString = "(";
for (int i = 0; i < subArgs.size(); i++)
{
if (i > 0)
{
argString += " ";
}
argString += (String)subArgs.elementAt(i);
}
argString += ")";
// Add as single argument
argListVector.addElement(argString);
}
//--------------------------------------------------------------------------
protected void editButtonActionPerformed(java.awt.event.ActionEvent evt)
{
// The edit button has been pressed. The user wants to edit this entry.
try
{
// Check n elems and ask before editing.
boolean doEdit = true;
int nSubElements = dictEntry_.nSubElements();
if (nSubElements > MAX_EDIT_LENGTH)
{
if
(
JOptionPane.showConfirmDialog
(
App.getRootFrame(),
"List is large (" + nSubElements
+ " elements).\n"
+ "Are you sure you want to edit it?",
"Confirm Edit List",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE
)
!=
JOptionPane.OK_OPTION
)
{
doEdit = false;
}
}
// Start editing
if (doEdit)
{
// Show modal list editor dialog.
ListEditor editor = new ListEditor
(
App.getRootFrame(),
dictEntry_
);
editor.setTitle(displayName_);
editor.show();
// Signal that editing has stopped.
editor_.stopCellEditing();
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
public DictionaryEntryCache addListElement()
{
DictionaryEntryCache listElement = null;
try
{
// Add a new element to the list.
IDictionaryEntryHolder listElementHolder =
new IDictionaryEntryHolder();
dictEntry_.addElement(listElementHolder);
// If successful, create a new DictionaryEntryCache wrapper
// object and return it.
listElement = DictionaryEntryCache.New(listElementHolder.value);
}
catch (FoamXError fxErr)
{
App.handleException(fxErr);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return listElement;
}
//--------------------------------------------------------------------------
public boolean removeElement(DictionaryEntryCache listElement)
{
boolean bRet = false;
try
{
// Remove the specified sub-type.
dictEntry_.removeElement(listElement.getDictEntry());
// Return success.
bRet = true;
}
catch (FoamXError fxErr)
{
App.handleException(fxErr);
bRet = false;
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
bRet = false;
}
return bRet;
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,267 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor.EntryCache;
import java.text.*;
import java.awt.Frame;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import FoamXServer.CaseServer.*;
import FoamXServer.IDictionaryEntry;
import FoamXServer.IDictionaryEntryHolder;
import FoamXServer.FoamXError;
import FoamXServer.FoamXIOError;
import FoamXServer.FoamXType;
import FoamX.App;
import FoamX.Exceptions.FoamXException;
import FoamX.Util.FoamXAny;
import FoamX.Util.FoamXTypeEx;
import FoamX.Editors.TypeEditor.TypeDescriptorCache;
import FoamX.Editors.DictionaryEntryEditor.DictionaryEntryCompoundEditor;
import FoamX.CaseManagement.CaseChooserDlg;
import FoamX.CaseManagement.CaseBrowserPanel;
public class RootAndCaseCache
extends DictionaryEntryCache
// implements DictionaryEntry
{
//--------------------------------------------------------------------------
/** RootAndCaseCache constructor. */
public RootAndCaseCache
(
IDictionaryEntry dictEntry,
TypeDescriptorCache typeDescriptor
)
{
super(dictEntry, typeDescriptor);
}
//--------------------------------------------------------------------------
/** RootAndCaseCache constructor. */
public RootAndCaseCache(IDictionaryEntry dictEntry)
{
// Invoke the other constructor.
this
(
dictEntry,
new TypeDescriptorCache(dictEntry.typeDescriptor(), false)
);
}
//--------------------------------------------------------------------------
/** RootAndCaseCache constructor. */
public RootAndCaseCache(IDictionaryEntry dictEntry, String displayName)
{
// Invoke the other constructor.
this(dictEntry);
// Use the given display name.
displayName_ = displayName;
}
/**
* Display as <case>,<root>
*/
public String toString()
{
try
{
displayValue_ = value_.toString();
if (displayValue_.length() != 0)
{
int lastSlash = displayValue_.lastIndexOf('/');
if (lastSlash == -1)
{
throw new FoamXException
(
"RootAndCase " + displayValue_ + " cannot be split "
+ " into root directory and case name"
);
}
displayValue_ =
displayValue_.substring(lastSlash+1)
+ ','
+ displayValue_.substring(0, lastSlash);
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return displayValue_;
}
//--------------------------------------------------------------------------
/**
* For argument strings rootAndCase becomes space separated
*/
public void toStringRaw(Vector argListVector)
{
try
{
String rootAndCase = value_.toString();
if (rootAndCase.length() != 0)
{
argListVector.addElement("-case");
argListVector.addElement(rootAndCase);
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
protected void initialiseEditor()
{
// Use compound editor.
DictionaryEntryCompoundEditor compEdit =
new DictionaryEntryCompoundEditor();
// Subscribe to the edit button's action event so
// that we can invoke the appropriate edit action for
// the compound types.
compEdit.addActionListener
(
new java.awt.event.ActionListener()
{
public void actionPerformed
(
java.awt.event.ActionEvent evt
)
{
editButtonActionPerformed(evt);
}
}
);
editor_ = compEdit;
}
//--------------------------------------------------------------------------
protected void editButtonActionPerformed(java.awt.event.ActionEvent evt)
{
// The edit button has been pressed. The user wants to edit this entry.
try
{
// Pop up case chooser panel
CaseChooserDlg caseChooser =
new CaseChooserDlg
(
App.getRootFrame(),
CaseBrowserPanel.SELECT_CASE_MODE
);
caseChooser.show();
if
(
(caseChooser.getCaseRoot() != null)
&& (caseChooser.getCaseName() != null)
&& (caseChooser.getCaseBrowser() != null)
)
{
updateValue
(
caseChooser.getCaseRoot()
+ '/'
+ caseChooser.getCaseName()
);
// Signal that editing has stopped.
editor_.stopCellEditing();
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
//---- DictionaryEntry Interface Methods
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
/**
* Called by the DictionaryCellEditor's getCellEditorValue
* method to update the value of this item after editing.
* Will not be called by editors for compound types since e.g.
* dictionary elements cannot be added/removed in FoamX.
*/
public boolean updateValue(Object value)
{
boolean bRet = false;
String strValue;
try
{
if (value != null)
{
// Incoming value object is a string.
strValue = (String)value;
// Update the Any object.
value_.setValue(strValue);
// Send the Any object to the dictionary entry object.
setEntryValue();
bRet = true;
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return bRet;
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,203 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor.EntryCache;
import java.text.*;
import java.awt.Frame;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import FoamXServer.CaseServer.*;
import FoamXServer.IDictionaryEntry;
import FoamXServer.IDictionaryEntryHolder;
import FoamXServer.FoamXError;
import FoamXServer.FoamXIOError;
import FoamXServer.FoamXType;
import FoamX.App;
import FoamX.Exceptions.FoamXException;
import FoamX.Util.FoamXAny;
import FoamX.Util.FoamXTypeEx;
import FoamX.Editors.TypeEditor.TypeDescriptorCache;
import FoamX.Editors.DictionaryEntryEditor.DictionaryEntryCompoundEditor;
import FoamX.CaseManagement.CaseChooserDlg;
import FoamX.CaseManagement.CaseBrowserPanel;
public class RootDirCache
extends DictionaryEntryCache
// implements DictionaryEntry
{
//--------------------------------------------------------------------------
/** RootDirCache constructor. */
public RootDirCache
(
IDictionaryEntry dictEntry,
TypeDescriptorCache typeDescriptor
)
{
super(dictEntry, typeDescriptor);
}
//--------------------------------------------------------------------------
/** RootDirCache constructor. */
public RootDirCache(IDictionaryEntry dictEntry)
{
// Invoke the other constructor.
this
(
dictEntry,
new TypeDescriptorCache(dictEntry.typeDescriptor(), false)
);
}
//--------------------------------------------------------------------------
/** RootDirCache constructor. */
public RootDirCache(IDictionaryEntry dictEntry, String displayName)
{
// Invoke the other constructor.
this(dictEntry);
// Use the given display name.
displayName_ = displayName;
}
//--------------------------------------------------------------------------
protected void initialiseEditor()
{
// Use compound editor.
DictionaryEntryCompoundEditor compEdit =
new DictionaryEntryCompoundEditor();
// Subscribe to the edit button's action event so
// that we can invoke the appropriate edit action for
// the compound types.
compEdit.addActionListener
(
new java.awt.event.ActionListener()
{
public void actionPerformed
(
java.awt.event.ActionEvent evt
)
{
editButtonActionPerformed(evt);
}
}
);
editor_ = compEdit;
}
//--------------------------------------------------------------------------
protected void editButtonActionPerformed(java.awt.event.ActionEvent evt)
{
// The edit button has been pressed. The user wants to edit this entry.
try
{
// Pop up case chooser panel
CaseChooserDlg caseChooser =
new CaseChooserDlg
(
App.getRootFrame(),
CaseBrowserPanel.SELECT_ROOT_MODE
);
caseChooser.show();
if
(
(caseChooser.getCaseRoot() != null)
&& (caseChooser.getCaseBrowser() != null)
)
{
updateValue(caseChooser.getCaseRoot());
// Signal that editing has stopped.
editor_.stopCellEditing();
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
//---- DictionaryEntry Interface Methods
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
/**
* Called by the DictionaryCellEditor's getCellEditorValue
* method to update the value of this item after editing.
* Will not be called by editors for compound types since e.g.
* dictionary elements cannot be added/removed in FoamX.
*/
public boolean updateValue(Object value)
{
boolean bRet = false;
String strValue;
try
{
if (value != null)
{
// Incoming value object is a string.
strValue = (String)value;
// Update the Any object.
value_.setValue(strValue);
// Send the Any object to the dictionary entry object.
setEntryValue();
bRet = true;
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return bRet;
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,199 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor.EntryCache;
import java.text.*;
import java.awt.Frame;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import FoamXServer.CaseServer.*;
import FoamXServer.IDictionaryEntry;
import FoamXServer.IDictionaryEntryHolder;
import FoamXServer.FoamXError;
import FoamXServer.FoamXIOError;
import FoamXServer.FoamXType;
import FoamX.App;
import FoamX.Exceptions.FoamXException;
import FoamX.Util.FoamXAny;
import FoamX.Util.FoamXTypeEx;
import FoamX.Editors.TypeEditor.TypeDescriptorCache;
public class ScalarCache
extends DictionaryEntryCache
// implements DictionaryEntry
{
//--------------------------------------------------------------------------
/** ScalarCache constructor. */
public ScalarCache
(
IDictionaryEntry dictEntry,
TypeDescriptorCache typeDescriptor
)
{
super(dictEntry, typeDescriptor);
}
//--------------------------------------------------------------------------
/** ScalarCache constructor. */
public ScalarCache(IDictionaryEntry dictEntry)
{
// Invoke the other constructor.
this
(
dictEntry,
new TypeDescriptorCache(dictEntry.typeDescriptor(), false)
);
}
//--------------------------------------------------------------------------
/** ScalarCache constructor. */
public ScalarCache(IDictionaryEntry dictEntry, String displayName)
{
// Invoke the other constructor.
this(dictEntry);
// Use the given display name.
displayName_ = displayName;
}
//--------------------------------------------------------------------------
protected void initialiseEditor()
{
// Give dictionaryEntryCache opportunity to install combo editor
super.initialiseEditor();
if (editor_ == null)
{
// No custom editor - use string-based
// DefaultCellEditor.
}
}
//--------------------------------------------------------------------------
//---- DictionaryEntry Interface Methods
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
/**
* Called by the DictionaryCellEditor's getCellEditorValue
* method to update the value of this item after editing.
* Will not be called by editors for compound types since e.g.
* dictionary elements cannot be added/removed in FoamX.
*/
public boolean updateValue(Object value)
{
boolean bRet = false;
String strValue = "";
try
{
if (value != null)
{
// Incoming value object is a string.
strValue = (String)value;
// Check against type min and max if available
FoamXAny minVal = typeDescriptor_.getMinValue();
FoamXAny maxVal = typeDescriptor_.getMaxValue();
if
(
(
minVal.getAny().type.value()
== FoamXType._Type_Scalar
)
&& (
maxVal.getAny().type.value()
== FoamXType._Type_Scalar
)
)
{
double doubleValue =
Double.valueOf(strValue).doubleValue();
double minValue =
Double.valueOf(minVal.toString()).doubleValue();
double maxValue =
Double.valueOf(maxVal.toString()).doubleValue();
if
(
(doubleValue < minValue)
|| (doubleValue > maxValue)
)
{
throw new FoamXException
(
"Scalar " + doubleValue + " out of range ["
+ minValue + " , " + maxValue + "]"
);
}
}
// Update the Any object.
value_.setValue(strValue);
// Send the Any object to the dictionary entry object.
setEntryValue();
bRet = true;
}
}
catch (NumberFormatException ex)
{
App.handleAllExceptions
(
new FoamXException
(
"Number " + strValue + " not of correct type."
)
);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return bRet;
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,195 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor.EntryCache;
import java.text.*;
import java.awt.Frame;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import FoamXServer.CaseServer.*;
import FoamXServer.IDictionaryEntry;
import FoamXServer.IDictionaryEntryHolder;
import FoamXServer.FoamXError;
import FoamXServer.FoamXIOError;
import FoamXServer.FoamXType;
import FoamX.App;
import FoamX.Exceptions.FoamXException;
import FoamX.Editors.CompoundEditor;
import FoamX.Editors.SelectionEditor;
import FoamX.Editors.DimensionSetEditor;
import FoamX.Editors.ListEditor;
import FoamX.Editors.FixedListEditor;
import FoamX.Util.FoamXAny;
import FoamX.Util.FoamXTypeEx;
import FoamX.Editors.TypeEditor.TypeDescriptorCache;
import FoamX.Editors.DictionaryEntryEditor.SelectionEntryCellRenderer;
public class SelectionCache
extends CompoundCache
// implements DictionaryEntry
{
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
/** SelectionCache constructor. */
public SelectionCache
(
IDictionaryEntry dictEntry,
TypeDescriptorCache typeDescriptor
)
{
super(dictEntry, typeDescriptor);
}
//--------------------------------------------------------------------------
/** SelectionCache constructor. */
public SelectionCache(IDictionaryEntry dictEntry)
{
// Invoke the other constructor.
this
(
dictEntry,
new TypeDescriptorCache(dictEntry.typeDescriptor(), false)
);
}
//--------------------------------------------------------------------------
/** SelectionCache constructor. */
public SelectionCache(IDictionaryEntry dictEntry, String displayName)
{
// Invoke the other constructor.
this(dictEntry);
// Use the given display name.
displayName_ = displayName;
}
//--------------------------------------------------------------------------
public String toString()
{
// Initialise if required.
if (displayValue_.length() == 0)
{
displayValue_ = getSelectionDisplayString() + " ...";
}
return displayValue_;
}
//--------------------------------------------------------------------------
public void toStringRaw(Vector argListVector)
{
getSelectionValueString(argListVector);
}
//--------------------------------------------------------------------------
protected void editButtonActionPerformed(java.awt.event.ActionEvent evt)
{
// The edit button has been pressed. The user wants to edit this entry.
try
{
// Show modal selection editor dialog.
// Differs from compoundEditor only in tableModel used
SelectionEditor editor = new SelectionEditor
(
App.getRootFrame(),
dictEntry_
);
editor.setTitle(displayName_);
editor.show();
// Update the cached display string.
displayValue_ = getSelectionDisplayString();
// Signal that editing has stopped.
editor_.stopCellEditing();
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
/* render selection by returning name of selected entry */
protected String getSelectionDisplayString()
{
String renderedValue = "";
try
{
int i = dictEntry_.selection();
IDictionaryEntry subEntry = dictEntry_.subElements()[i];
renderedValue = subEntry.typeDescriptor().name();
subEntry = null;
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return renderedValue;
}
//--------------------------------------------------------------------------
/* render selection by adding value to vector */
protected void getSelectionValueString(Vector argListVector)
{
try
{
int i = dictEntry_.selection();
DictionaryEntryCache dictEntryCache =
DictionaryEntryCache.New(dictEntry_.subElements()[i]);
dictEntryCache.toStringRaw(argListVector);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,153 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor.EntryCache;
import java.text.*;
import java.awt.Frame;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import FoamXServer.CaseServer.*;
import FoamXServer.IDictionaryEntry;
import FoamXServer.IDictionaryEntryHolder;
import FoamXServer.FoamXError;
import FoamXServer.FoamXIOError;
import FoamXServer.FoamXType;
import FoamX.App;
import FoamX.Exceptions.FoamXException;
import FoamX.Util.FoamXAny;
import FoamX.Util.FoamXTypeEx;
import FoamX.Editors.TypeEditor.TypeDescriptorCache;
public class StringCache
extends DictionaryEntryCache
// implements DictionaryEntry
{
//--------------------------------------------------------------------------
/** StringCache constructor. */
public StringCache
(
IDictionaryEntry dictEntry,
TypeDescriptorCache typeDescriptor
)
{
super(dictEntry, typeDescriptor);
}
//--------------------------------------------------------------------------
/** StringCache constructor. */
public StringCache(IDictionaryEntry dictEntry)
{
// Invoke the other constructor.
this
(
dictEntry,
new TypeDescriptorCache(dictEntry.typeDescriptor(), false)
);
}
//--------------------------------------------------------------------------
/** StringCache constructor. */
public StringCache(IDictionaryEntry dictEntry, String displayName)
{
// Invoke the other constructor.
this(dictEntry);
// Use the given display name.
displayName_ = displayName;
}
//--------------------------------------------------------------------------
protected void initialiseEditor()
{
// Give dictionaryEntryCache opportunity to install combo editor
super.initialiseEditor();
if (editor_ == null)
{
// No custom editor - use string-based
// DefaultCellEditor.
}
}
//--------------------------------------------------------------------------
//---- DictionaryEntry Interface Methods
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
/**
* Called by the DictionaryCellEditor's getCellEditorValue
* method to update the value of this item after editing.
* Will not be called by editors for compound types since e.g.
* dictionary elements cannot be added/removed in FoamX.
*/
public boolean updateValue(Object value)
{
boolean bRet = false;
String strValue;
try
{
if (value != null)
{
// Incoming value object is a string.
strValue = (String)value;
// Update the Any object.
value_.setValue(strValue);
// Send the Any object to the dictionary entry object.
setEntryValue();
bRet = true;
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return bRet;
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,145 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor.EntryCache;
import java.text.*;
import java.awt.Frame;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import FoamXServer.CaseServer.*;
import FoamXServer.IDictionaryEntry;
import FoamXServer.IDictionaryEntryHolder;
import FoamXServer.FoamXError;
import FoamXServer.FoamXIOError;
import FoamXServer.FoamXType;
import FoamX.App;
import FoamX.Exceptions.FoamXException;
import FoamX.Util.FoamXAny;
import FoamX.Util.FoamXTypeEx;
import FoamX.Editors.TypeEditor.TypeDescriptorCache;
public class TimeCache
extends DictionaryEntryCache
// implements DictionaryEntry
{
//--------------------------------------------------------------------------
/** TimeCache constructor. */
public TimeCache
(
IDictionaryEntry dictEntry,
TypeDescriptorCache typeDescriptor
)
{
super(dictEntry, typeDescriptor);
}
//--------------------------------------------------------------------------
/** TimeCache constructor. */
public TimeCache(IDictionaryEntry dictEntry)
{
// Invoke the other constructor.
this
(
dictEntry,
new TypeDescriptorCache(dictEntry.typeDescriptor(), false)
);
}
//--------------------------------------------------------------------------
/** TimeCache constructor. */
public TimeCache(IDictionaryEntry dictEntry, String displayName)
{
// Invoke the other constructor.
this(dictEntry);
// Use the given display name.
displayName_ = displayName;
}
//--------------------------------------------------------------------------
protected void initialiseEditor()
{
// Give dictionaryEntryCache opportunity to install combo editor
super.initialiseEditor();
if (editor_ == null)
{
// No custom editor - use string-based
// DefaultCellEditor.
}
}
//--------------------------------------------------------------------------
//---- DictionaryEntry Interface Methods
//--------------------------------------------------------------------------
public boolean updateValue(Object value)
{
boolean bRet = false;
String strValue;
try
{
if (value != null)
{
// Incoming value object is a string.
strValue = (String)value;
// Update the Any object.
value_.setValue(strValue);
// Send the Any object to the dictionary entry object.
setEntryValue();
bRet = true;
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return bRet;
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,153 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor.EntryCache;
import java.text.*;
import java.awt.Frame;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import FoamXServer.CaseServer.*;
import FoamXServer.IDictionaryEntry;
import FoamXServer.IDictionaryEntryHolder;
import FoamXServer.FoamXError;
import FoamXServer.FoamXIOError;
import FoamXServer.FoamXType;
import FoamX.App;
import FoamX.Exceptions.FoamXException;
import FoamX.Util.FoamXAny;
import FoamX.Util.FoamXTypeEx;
import FoamX.Editors.TypeEditor.TypeDescriptorCache;
public class WordCache
extends DictionaryEntryCache
// implements DictionaryEntry
{
//--------------------------------------------------------------------------
/** WordCache constructor. */
public WordCache
(
IDictionaryEntry dictEntry,
TypeDescriptorCache typeDescriptor
)
{
super(dictEntry, typeDescriptor);
}
//--------------------------------------------------------------------------
/** WordCache constructor. */
public WordCache(IDictionaryEntry dictEntry)
{
// Invoke the other constructor.
this
(
dictEntry,
new TypeDescriptorCache(dictEntry.typeDescriptor(), false)
);
}
//--------------------------------------------------------------------------
/** WordCache constructor. */
public WordCache(IDictionaryEntry dictEntry, String displayName)
{
// Invoke the other constructor.
this(dictEntry);
// Use the given display name.
displayName_ = displayName;
}
//--------------------------------------------------------------------------
protected void initialiseEditor()
{
// Give dictionaryEntryCache opportunity to install combo editor
super.initialiseEditor();
if (editor_ == null)
{
// No custom editor - use string-based
// DefaultCellEditor.
}
}
//--------------------------------------------------------------------------
//---- DictionaryEntry Interface Methods
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
/**
* Called by the DictionaryCellEditor's getCellEditorValue
* method to update the value of this item after editing.
* Will not be called by editors for compound types since e.g.
* dictionary elements cannot be added/removed in FoamX.
*/
public boolean updateValue(Object value)
{
boolean bRet = false;
String strValue;
try
{
if (value != null)
{
// Incoming value object is a string.
strValue = (String)value;
// Update the Any object.
value_.setValue(strValue);
// Send the Any object to the dictionary entry object.
setEntryValue();
bRet = true;
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return bRet;
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,100 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor;
import javax.swing.JTable;
import javax.swing.table.*;
import java.awt.Component;
import FoamX.App;
public class SelectionEntryCellRenderer
extends DictionaryEntryCellRenderer
{
//--------------------------------------------------------------------------
protected java.awt.Color selectedColor_;
//--------------------------------------------------------------------------
/** SelectionEntryCellRenderer constructor. */
public SelectionEntryCellRenderer()
{
selectedColor_= new java.awt.Color(173, 255, 47);
}
//--------------------------------------------------------------------------
public Component getTableCellRendererComponent
(
JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column
)
{
Component comp = null;
try
{
// Use DictionaryEntryCellRenderer(handles read-only)
comp = super.getTableCellRendererComponent
(
table,
value,
isSelected,
hasFocus,
row,
column
);
if (isSelected)
{
//comp.setFont(selectedFont_);
comp.setBackground(selectedColor_);
}
else
{
comp.setBackground(java.awt.Color.white);
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return comp;
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,402 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors.DictionaryEntryEditor;
import java.util.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import FoamX.App;
import FoamXServer.FoamXError;
import FoamXServer.FoamXIOError;
import FoamXServer.IDictionaryEntry;
import FoamX.Editors.DictionaryEntryEditor.EntryCache.DictionaryEntryCache;
public class SelectionTableModel
extends AbstractTableModel
implements CompoundEntryListener
{
//--------------------------------------------------------------------------
public static final int NAME_COLUMN_INDEX = 0;
public static final int VALUE_COLUMN_INDEX = 1;
// Root DictionaryEntry object for this table.
protected DictionaryEntryCache rootEntry_;
protected String dictionaryKey_;
// List of DictionaryEntry objects.
protected java.util.List dictEntryList_;
// Map of DictionaryEntry objects.
protected java.util.Hashtable dictEntryMap_;
protected EventListenerList listenerList_;
protected String[] columnNames_ = { "Name", "Value"};
//--------------------------------------------------------------------------
/** SelectionTableModel default constructor for derived classes..
*/
protected SelectionTableModel()
{
try
{
rootEntry_ = null;
dictionaryKey_ = "";
dictEntryList_ = new Vector(10);
dictEntryMap_ = new Hashtable();
listenerList_ = new EventListenerList();
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
/**
* SelectionTableModel constructor for compound types.
* @param compoundEntry Reference to the compound entry object.
*/
public SelectionTableModel(IDictionaryEntry compoundEntry)
{
// Default construction.
this();
try
{
// Store reference to IDictionaryEntry for this compound entry.
rootEntry_ = DictionaryEntryCache.New(compoundEntry);
// Default dictionary key.
dictionaryKey_ = rootEntry_.getTypeDescriptor().getName();
// Initialise event listener list.
listenerList_ = new EventListenerList();
// Create a DictionaryEntryCache object for each sub-entry.
IDictionaryEntry[] subEntries = compoundEntry.subElements();
dictEntryList_ = new Vector(subEntries.length);
for (int i=0; i <subEntries.length; i++)
{
// Create DictionaryEntryCache object.
IDictionaryEntry subEntry = subEntries[i];
DictionaryEntry dictEntry = DictionaryEntryCache.New(subEntry);
// Add to list.
dictEntryList_.add(i, dictEntry);
// Add to map.
dictEntryMap_.put(dictEntry.getEntryName(), dictEntry);
// Subscribe to the openSubDictionary event so that we can
// forward the event to the listeners of this object.
dictEntry.addCompoundEntryListener(this);
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
public DictionaryEntryCache getRootEntry()
{
return rootEntry_;
}
public String getNameColumnTitle()
{
return columnNames_[NAME_COLUMN_INDEX];
}
public void setNameColumnTitle(String title)
{
columnNames_[NAME_COLUMN_INDEX] = title;
}
public String getValueColumnTitle()
{
return columnNames_[VALUE_COLUMN_INDEX];
}
public void setValueColumnTitle(String title)
{
columnNames_[VALUE_COLUMN_INDEX] = title;
}
public String getDictionaryKey()
{
return dictionaryKey_;
}
public void setDictionaryKey(String key)
{
dictionaryKey_ = key;
}
//--------------------------------------------------------------------------
/** Returns the index of the specified entry. */
public int getIndexOfEntry(String entryName)
{
// Return zero by default.
int index = 0;
for (int i = 0; i <dictEntryList_.size(); i++)
{
DictionaryEntryCache dictEntry =
(DictionaryEntryCache)dictEntryList_.get(i);
if (entryName.compareToIgnoreCase(dictEntry.getEntryName()) == 0)
{
index = i;
break;
}
}
return index;
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
public void addCompoundEntryListener(CompoundEntryListener l)
{
listenerList_.add(CompoundEntryListener.class, l);
}
//--------------------------------------------------------------------------
public void removeCompoundEntryListener(CompoundEntryListener l)
{
listenerList_.remove(CompoundEntryListener.class, l);
}
//--------------------------------------------------------------------------
protected boolean fireOpenSubDictionaryEvent(CompoundEntryEvent evt)
{
// Process the listeners last to first, notifying those that are
// interested in this event.
Object[] listeners = listenerList_.getListenerList();
// Prepend the dictionary key and send to the module.
String fullDictName = dictionaryKey_ + "/" + evt.getName();
// Create the event object.
CompoundEntryEvent event =
new CompoundEntryEvent
(
this,
CompoundEntryEvent.TYPE_DICTIONARY,
fullDictName
);
// Fire the event.
if (evt != null)
{
for (int i = listeners.length - 2; i>= 0; i -= 2)
{
if (listeners[i] == CompoundEntryListener.class)
{
return
(
(CompoundEntryListener)listeners[i+1]
).openSubDictionary(event);
}
}
}
else
{
App.printMessage
(
"SelectionTableModel.fireOpenSubDictionaryEvent"
+ "(CompoundEntryEvent evt)"
+ " : cannot fire event"
);
}
return false;
}
//--------------------------------------------------------------------------
//--- CompoundEntryListener Interface Methods
//--------------------------------------------------------------------------
public boolean openSubDictionary(CompoundEntryEvent evt)
{
// Bounce the openSubDictionary event to any listeners.
return fireOpenSubDictionaryEvent(evt);
}
//--------------------------------------------------------------------------
//--- Abstract AbststractTableModel Methods
//--------------------------------------------------------------------------
public int getRowCount()
{
return dictEntryList_.size();
}
//--------------------------------------------------------------------------
public int getColumnCount()
{
return columnNames_.length;
}
//--------------------------------------------------------------------------
public Object getValueAt(int rowIndex, int columnIndex)
{
Object obj = null;
try
{
// Check for valid row index.
if (rowIndex>= dictEntryList_.size())
{
throw new Exception("Invalid row index");
}
// Get DictionaryEntry object for this row.
DictionaryEntryCache dictEntry =
(DictionaryEntryCache)dictEntryList_.get(rowIndex);
if (columnIndex == NAME_COLUMN_INDEX)
{
// Return the DictionaryEntry display name.
obj = dictEntry.getEntryName();
}
else if (columnIndex == VALUE_COLUMN_INDEX)
{
obj = dictEntry;
}
else
{
throw new Exception("Invalid column index");
}
}
catch (FoamXIOError ioErr)
{
App.handleException(ioErr);
}
catch (FoamXError fxErr)
{
App.handleException(fxErr);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return obj;
}
//--------------------------------------------------------------------------
//--- Overriden AbststractTableModel Methods
//--------------------------------------------------------------------------
public String getColumnName(int columnIndex)
{
return columnNames_[columnIndex];
}
//--------------------------------------------------------------------------
public Class getColumnClass(int columnIndex)
{
// Render according to value of row 0 ( so 0=string, 1=bool)
return getValueAt(0, columnIndex).getClass();
}
//--------------------------------------------------------------------------
public boolean isCellEditable(int rowIndex, int columnIndex)
{
boolean bEditable = false;
try
{
if (columnIndex == VALUE_COLUMN_INDEX)
{
// Get DictionaryEntry object for this row.
DictionaryEntry dictEntry =
(DictionaryEntry)dictEntryList_.get(rowIndex);
// Return the editable flag.
bEditable = dictEntry.isEditable();
}
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return bEditable;
}
//--------------------------------------------------------------------------
public void setValueAt(Object aValue, int rowIndex, int columnIndex)
{
try
{
if (columnIndex == NAME_COLUMN_INDEX)
{
}
else if (columnIndex == VALUE_COLUMN_INDEX)
{
// No need to change current selection here
// (Current-selection set by selection changes, not by editing)
// Ignore any incoming DictionaryEntry objects.
fireTableCellUpdated(rowIndex, columnIndex);
}
else
{
throw new Exception("Invalid column index");
}
}
catch (FoamXIOError ioErr)
{
App.handleException(ioErr);
}
catch (FoamXError fxErr)
{
App.handleException(fxErr);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.0" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="name" type="java.lang.String" value="Dimension Set Editor"/>
<Property name="modal" type="boolean" value="true"/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="menuBar" type="java.lang.String" value="(No Menu)"/>
<SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-6,0,0,1,44"/>
<SyntheticProperty name="formPosition" type="java.awt.Point" value="-84,-19,0,5,115,114,0,14,106,97,118,97,46,97,119,116,46,80,111,105,110,116,-74,-60,-118,114,52,126,-56,38,2,0,2,73,0,1,120,73,0,1,121,120,112,0,0,0,0,0,0,0,0"/>
<SyntheticProperty name="formSizePolicy" type="int" value="0"/>
<SyntheticProperty name="generatePosition" type="boolean" value="true"/>
<SyntheticProperty name="generateSize" type="boolean" value="true"/>
<SyntheticProperty name="generateCenter" type="boolean" value="true"/>
</SyntheticProperties>
<Events>
<EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="closeDialog"/>
</Events>
<AuxValues>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="buttonPanel_">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder/>
</Border>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="South"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
<Property name="alignment" type="int" value="2"/>
<Property name="horizontalGap" type="int" value="10"/>
<Property name="verticalGap" type="int" value="10"/>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="btnOK">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="OK"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnOKActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnCancel">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="Cancel"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCancelActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="dimensionPanel_">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
<EmptyBorder bottom="10" left="10" right="10" top="10"/>
</Border>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
<Property name="rows" type="int" value="7"/>
<Property name="columns" type="int" value="2"/>
<Property name="horizontalGap" type="int" value="2"/>
<Property name="verticalGap" type="int" value="2"/>
</Layout>
</Container>
</SubComponents>
</Form>

View File

@ -0,0 +1,324 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.text.*;
import FoamX.App;
import FoamXServer.DimensionSet;
import FoamXServer.DimensionSetHelper;
import FoamXServer.IDictionaryEntry;
public class DimensionSetEditor
extends javax.swing.JDialog
{
//--------------------------------------------------------------------------
protected static final int MASS = 0;
protected static final int LENGTH = 1;
protected static final int TIME = 2;
protected static final int TEMPERATURE = 3;
protected static final int MOLES = 4;
protected static final int CURRENT = 5;
protected static final int LUMINOUSINTENSITY = 6;
private javax.swing.JLabel[] labels_ = new javax.swing.JLabel[7];
private javax.swing.JTextField[] textfields_ = new javax.swing.JTextField[7];
private IDictionaryEntry entry_;
private DimensionSet dimensionSet_;
//--------------------------------------------------------------------------
/** Constructor for DimensionSetEditor given a non-compound dictionary entry. */
public DimensionSetEditor(java.awt.Frame parent, IDictionaryEntry entry)
{
super(parent, "DimensionSet Editor", true); // Modal.
// Get the dimension set values from the entry.
entry_ = entry;
dimensionSet_ = DimensionSetHelper.extract(entry_.value().value);
// Common initialisation.
initialise();
// Set default dialog position to centre of parent frame.
if (parent != null)
{
setLocation(parent.getLocation().x + (parent.getSize().width - getSize().width)/2,
parent.getLocation().y + (parent.getSize().height - getSize().height)/2);
}
else
{
Dimension screen = getToolkit().getScreenSize();
setLocation((screen.getSize().width - getSize().width)/2,
(screen.getSize().height - getSize().height)/2);
}
}
//--------------------------------------------------------------------------
public DimensionSet getDimensionSet()
{
return dimensionSet_;
}
//--------------------------------------------------------------------------
/** Constructor for DimensionSetEditor given a DimensionSet. */
public DimensionSetEditor(java.awt.Frame parent, DimensionSet dimensionSet)
{
super(parent, "DimensionSet Editor", true);
dimensionSet_ = dimensionSet;
// Common initialisation.
initialise();
// Set default dialog position to centre of parent frame.
if (parent != null)
{
setLocation(parent.getLocation().x + (parent.getSize().width - getSize().width)/2,
parent.getLocation().y + (parent.getSize().height - getSize().height)/2);
}
else
{
Dimension screen = getToolkit().getScreenSize();
setLocation((screen.getSize().width - getSize().width)/2,
(screen.getSize().height - getSize().height)/2);
}
}
//--------------------------------------------------------------------------
/** Common initialisation. */
public void initialise()
{
initComponents();
// Construct Format object.
DecimalFormat format = new DecimalFormat();
format.setGroupingUsed(false);
format.setMaximumFractionDigits(6);
// Initialise the dimension edit controls.
labels_[0] = new javax.swing.JLabel("Mass");
labels_[1] = new javax.swing.JLabel("Length");
labels_[2] = new javax.swing.JLabel("Time");
labels_[3] = new javax.swing.JLabel("Temperature");
labels_[4] = new javax.swing.JLabel("Moles");
labels_[5] = new javax.swing.JLabel("Current");
labels_[6] = new javax.swing.JLabel("Luminous Intensity");
textfields_[MASS] = new javax.swing.JTextField();
textfields_[MASS].setText(format.format(dimensionSet_.mass));
textfields_[LENGTH] = new javax.swing.JTextField();
textfields_[LENGTH].setText(format.format(dimensionSet_.length));
textfields_[TIME] = new javax.swing.JTextField();
textfields_[TIME].setText(format.format(dimensionSet_.time));
textfields_[TEMPERATURE] = new javax.swing.JTextField();
textfields_[TEMPERATURE].setText(format.format(dimensionSet_.temperature));
textfields_[MOLES] = new javax.swing.JTextField();
textfields_[MOLES].setText(format.format(dimensionSet_.moles));
textfields_[CURRENT] = new javax.swing.JTextField();
textfields_[CURRENT].setText(format.format(dimensionSet_.current));
textfields_[LUMINOUSINTENSITY] = new javax.swing.JTextField();
textfields_[LUMINOUSINTENSITY].setText(format.format(dimensionSet_.luminousIntensity));
for (int i=0; i <7; i++)
{
labels_[i].setFont(getFont());
labels_[i].setForeground(java.awt.Color.black);
textfields_[i].setFont(getFont());
dimensionPanel_.add(labels_[i]);
dimensionPanel_.add(textfields_[i]);
}
// Resize dialog.
//pack();
}
//--------------------------------------------------------------------------
/** 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 FormEditor.
*/
private void initComponents()//GEN-BEGIN:initComponents
{
buttonPanel_ = new javax.swing.JPanel();
btnOK = new javax.swing.JButton();
btnCancel = new javax.swing.JButton();
dimensionPanel_ = new javax.swing.JPanel();
setName("Dimension Set Editor");
setModal(true);
setFont(new java.awt.Font("Dialog", 0, 10));
addWindowListener(new java.awt.event.WindowAdapter()
{
public void windowClosing(java.awt.event.WindowEvent evt)
{
closeDialog(evt);
}
});
buttonPanel_.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT, 10, 10));
buttonPanel_.setBorder(new javax.swing.border.EtchedBorder());
buttonPanel_.setFont(new java.awt.Font("Dialog", 0, 10));
btnOK.setFont(new java.awt.Font("Dialog", 0, 10));
btnOK.setText("OK");
btnOK.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
btnOKActionPerformed(evt);
}
});
buttonPanel_.add(btnOK);
btnCancel.setFont(new java.awt.Font("Dialog", 0, 10));
btnCancel.setText("Cancel");
btnCancel.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
btnCancelActionPerformed(evt);
}
});
buttonPanel_.add(btnCancel);
getContentPane().add(buttonPanel_, java.awt.BorderLayout.SOUTH);
dimensionPanel_.setLayout(new java.awt.GridLayout(7, 2, 2, 2));
dimensionPanel_.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(10, 10, 10, 10)));
dimensionPanel_.setFont(new java.awt.Font("Dialog", 0, 10));
getContentPane().add(dimensionPanel_, java.awt.BorderLayout.CENTER);
pack();
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setSize(new java.awt.Dimension(300, 250));
setLocation((screenSize.width-300)/2,(screenSize.height-250)/2);
}//GEN-END:initComponents
//--------------------------------------------------------------------------
/**
*/
private void btnCancelActionPerformed (java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_btnCancelActionPerformed
// Shutdown the dialog and return.
setVisible(false);
dispose();
}//GEN-LAST:event_btnCancelActionPerformed
//--------------------------------------------------------------------------
private double toDouble(int dimi)
{
try
{
return Double.parseDouble(textfields_[dimi].getText());
}
catch (NumberFormatException ex)
{
throw new IllegalArgumentException
(
textfields_[dimi].getText()
+ " is not a number for dimension "
+ labels_[dimi].getText()
);
}
}
//--------------------------------------------------------------------------
/**
*/
private void btnOKActionPerformed (java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_btnOKActionPerformed
try
{
// Get the values from the text controls and update the dimension set object.
dimensionSet_.mass = toDouble(MASS);
dimensionSet_.length = toDouble(LENGTH);
dimensionSet_.time = toDouble(TIME);
dimensionSet_.temperature = toDouble(TEMPERATURE);
dimensionSet_.current = toDouble(CURRENT);
dimensionSet_.moles = toDouble(MOLES);
dimensionSet_.luminousIntensity = toDouble(LUMINOUSINTENSITY);
if (entry_ != null)
{
// Insert the value into the Any object:
FoamXServer.FoamXAny value = entry_.value();
DimensionSetHelper.insert(value.value, dimensionSet_);
// Update the dictionary entry object.
entry_.value(value);
}
// Close this dialog down.
setVisible(false);
dispose();
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}//GEN-LAST:event_btnOKActionPerformed
//--------------------------------------------------------------------------
/** Closes the dialog */
private void closeDialog(java.awt.event.WindowEvent evt)
{//GEN-FIRST:event_closeDialog
// Shutdown the dialog and return.
setVisible(false);
dispose();
}//GEN-LAST:event_closeDialog
//--------------------------------------------------------------------------
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel buttonPanel_;
private javax.swing.JButton btnOK;
private javax.swing.JButton btnCancel;
private javax.swing.JPanel dimensionPanel_;
// End of variables declaration//GEN-END:variables
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,292 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import FoamX.App;
import FoamX.Editors.DictionaryEntryEditor.DictionaryEntry;
import FoamX.Editors.DictionaryEntryEditor.DictionaryEntryCellEditor;
import FoamX.Editors.DictionaryEntryEditor.DictionaryEntryCellRenderer;
import FoamX.Editors.DictionaryEntryEditor.DictionaryNameCellRenderer;
import FoamX.Editors.DictionaryEntryEditor.DictionaryEntryTableModel;
import FoamX.Editors.TypeEditor.TypeDescriptorCache;
import FoamXServer.FoamXError;
import FoamXServer.FoamXIOError;
import FoamXServer.IDictionaryEntry;
public class FixedListEditor
extends javax.swing.JDialog
{
//--------------------------------------------------------------------------
private static final int DEFAULT_WIDTH = 400;
private VectorTableModel tableModel_;
//--------------------------------------------------------------------------
/** FixedListEditor constructor. */
public FixedListEditor
(
java.awt.Frame parent,
IDictionaryEntry entry,
TypeDescriptorCache typeDescriptor
)
{
super(parent, "Vector Editor", true); // Modal.
// Initialise the table model.
tableModel_ = new VectorTableModel(entry, typeDescriptor);
initComponents();
// Use 'standard' renderer for name
elementTable_.getColumn
(
tableModel_.getNameColumnTitle()
).setCellRenderer(new DictionaryNameCellRenderer());
// Set cell renderer and editor for value column.
elementTable_.getColumn
(
tableModel_.getValueColumnTitle()
).setCellRenderer(new DictionaryEntryCellRenderer());
elementTable_.getColumn
(
tableModel_.getValueColumnTitle()
).setCellEditor(new DictionaryEntryCellEditor());
// Resize to show the defined rows only.
// Calculate size: table + some extra (= 1 row height) or
// space needed for panel itself (so with empty table)
int height =
elementTable_.getRowHeight() * (tableModel_.getRowCount() + 2)
+ (int)getMinimumSize().getHeight();
setSize(new java.awt.Dimension(DEFAULT_WIDTH, height));
}
//--------------------------------------------------------------------------
/** 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 FormEditor.
*/
private void initComponents()//GEN-BEGIN:initComponents
{
tablePanel_ = new javax.swing.JPanel();
tableScrollPane_ = new javax.swing.JScrollPane();
elementTable_ = new javax.swing.JTable();
buttonPanel_ = new javax.swing.JPanel();
btnOK_ = new javax.swing.JButton();
getContentPane().setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints1;
setName("Vector Space Editor");
setModal(true);
setFont(new java.awt.Font("Dialog", 0, 10));
addWindowListener(new java.awt.event.WindowAdapter()
{
public void windowClosing(java.awt.event.WindowEvent evt)
{
closeDialog(evt);
}
});
tablePanel_.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints2;
tablePanel_.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(10, 10, 10, 10)));
tableScrollPane_.setFont(new java.awt.Font("Dialog", 0, 10));
elementTable_.setModel(tableModel_);
elementTable_.setFont(new java.awt.Font("Dialog", 0, 10));
elementTable_.setPreferredScrollableViewportSize(new java.awt.Dimension(200, 50));
elementTable_.setMinimumSize(new java.awt.Dimension(100, 100));
tableScrollPane_.setViewportView(elementTable_);
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints2.weightx = 1.0;
gridBagConstraints2.weighty = 1.0;
tablePanel_.add(tableScrollPane_, gridBagConstraints2);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints1.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints1.weightx = 1.0;
gridBagConstraints1.weighty = 1.0;
getContentPane().add(tablePanel_, gridBagConstraints1);
buttonPanel_.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
buttonPanel_.setBorder(new javax.swing.border.EtchedBorder());
btnOK_.setFont(new java.awt.Font("Dialog", 0, 10));
btnOK_.setText("Close");
btnOK_.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
OnClose(evt);
}
});
buttonPanel_.add(btnOK_);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 1;
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints1.anchor = java.awt.GridBagConstraints.SOUTH;
gridBagConstraints1.weightx = 1.0;
getContentPane().add(buttonPanel_, gridBagConstraints1);
pack();
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setSize(new java.awt.Dimension(350, 300));
setLocation((screenSize.width-350)/2,(screenSize.height-300)/2);
}//GEN-END:initComponents
//--------------------------------------------------------------------------
private void shapeTypeComboActionPerformed (java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_shapeTypeComboActionPerformed
// Update the table to reflect the new shape type.
}//GEN-LAST:event_shapeTypeComboActionPerformed
//--------------------------------------------------------------------------
private void OnClose (java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_OnClose
// Commit any pending edits.
elementTable_.editingStopped(new ChangeEvent(this));
setVisible(false);
dispose();
}//GEN-LAST:event_OnClose
//--------------------------------------------------------------------------
/** Closes the dialog */
private void closeDialog(java.awt.event.WindowEvent evt)
{//GEN-FIRST:event_closeDialog
setVisible(false);
dispose();
}//GEN-LAST:event_closeDialog
//--------------------------------------------------------------------------
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel tablePanel_;
private javax.swing.JScrollPane tableScrollPane_;
private javax.swing.JTable elementTable_;
private javax.swing.JPanel buttonPanel_;
private javax.swing.JButton btnOK_;
// End of variables declaration//GEN-END:variables
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
private class VectorTableModel
extends DictionaryEntryTableModel
{
//--------------------------------------------------------------------------
private TypeDescriptorCache typeDescriptor_;
//--------------------------------------------------------------------------
/** VectorTableModel constructor for fixedList types.
* @param compoundEntry Reference to the fixedList entry object.
*/
public VectorTableModel
(
IDictionaryEntry compoundEntry,
TypeDescriptorCache typeDescriptor
)
{
super(compoundEntry);
setNameColumnTitle("Component");
typeDescriptor_ = typeDescriptor;
}
//--------------------------------------------------------------------------
public java.lang.Object getValueAt(int rowIndex, int columnIndex)
{
java.lang.Object obj = null;
try
{
// Check for valid row index.
if (rowIndex>= getRowCount()) throw new Exception("Invalid row index");
if (columnIndex == NAME_COLUMN_INDEX)
{
// Return a new string containing the component name.
obj = typeDescriptor_.getElementLabels()[rowIndex];
}
else
{
// Return the DictionaryEntry object for this entry.
DictionaryEntry dictEntry = (DictionaryEntry)dictEntryList_.get(rowIndex);
obj = dictEntry;
}
}
catch (FoamXIOError ioErr)
{
App.handleException(ioErr);
}
catch (FoamXError fxErr)
{
App.handleException(fxErr);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return obj;
}
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
}

View File

@ -0,0 +1,176 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.0" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="name" type="java.lang.String" value="List Editor"/>
<Property name="modal" type="boolean" value="true"/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="menuBar" type="java.lang.String" value="(No Menu)"/>
<SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,94"/>
<SyntheticProperty name="formPosition" type="java.awt.Point" value="-84,-19,0,5,115,114,0,14,106,97,118,97,46,97,119,116,46,80,111,105,110,116,-74,-60,-118,114,52,126,-56,38,2,0,2,73,0,1,120,73,0,1,121,120,112,0,0,0,0,0,0,0,0"/>
<SyntheticProperty name="formSizePolicy" type="int" value="0"/>
<SyntheticProperty name="generatePosition" type="boolean" value="true"/>
<SyntheticProperty name="generateSize" type="boolean" value="true"/>
<SyntheticProperty name="generateCenter" type="boolean" value="true"/>
</SyntheticProperties>
<Events>
<EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="closeDialog"/>
</Events>
<AuxValues>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="mainPanel_">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
<EmptyBorder bottom="10" left="10" right="10" top="10"/>
</Border>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="10" fill="1" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="tableScrollPane_">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="18" fill="1" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTable" name="listTable_">
<Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="tableModel_" type="code"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="java.awt.Panel" name="listButtonPanel_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="11" style="0"/>
</Property>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="cc" green="cc" red="cc" type="rgb"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" id="black" palette="0" red="0" type="palette"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="12" fill="0" gridHeight="1" gridWidth="1" gridX="1" gridY="0" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Component class="javax.swing.JButton" name="btnInsertElement_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="Insert..."/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="10" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="0" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JButton" name="btnDeleteElement_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="Delete..."/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="10" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="1" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="0" ipadX="0" ipadY="0" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JButton" name="btnMoveElementUp_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="Move Up"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="10" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="2" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="0" ipadX="0" ipadY="0" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JButton" name="btnMoveElementDown_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="Move Down"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="10" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="3" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="0" ipadX="0" ipadY="0" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="buttonPanel_">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder/>
</Border>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints anchor="10" fill="2" gridHeight="1" gridWidth="1" gridX="0" gridY="1" insetsBottom="0" insetsLeft="0" insetsRight="0" insetsTop="0" ipadX="0" ipadY="0" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
<Property name="alignment" type="int" value="2"/>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="closeButton_">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="Close"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="OnClose"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@ -0,0 +1,506 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
package FoamX.Editors;
import java.awt.event.ActionEvent;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.ListSelectionEvent;
import FoamX.App;
import FoamX.Editors.DictionaryEntryEditor.DictionaryEntry;
import FoamX.Editors.DictionaryEntryEditor.EntryCache.DictionaryEntryCache;
import FoamX.Editors.DictionaryEntryEditor.EntryCache.ListCache;
import FoamX.Editors.DictionaryEntryEditor.DictionaryEntryCellEditor;
import FoamX.Editors.DictionaryEntryEditor.DictionaryEntryCellRenderer;
import FoamX.Editors.DictionaryEntryEditor.DictionaryNameCellRenderer;
import FoamX.Editors.DictionaryEntryEditor.DictionaryEntryTableModel;
import FoamX.Util.ButtonActionChangedListener;
import FoamXServer.FoamXError;
import FoamXServer.FoamXIOError;
import FoamXServer.IDictionaryEntry;
public class ListEditor
extends javax.swing.JDialog
{
//--------------------------------------------------------------------------
private static final int DEFAULT_HEIGHT = 400;
private static final int DEFAULT_WIDTH = 400;
private ListEntryModel tableModel_;
private AddElementAction addElementAction_;
private DeleteElementAction deleteElementAction_;
//--------------------------------------------------------------------------
/** Creates new form ListEditor */
public ListEditor(java.awt.Frame parent, IDictionaryEntry entry)
{
super(parent, "List Editor", true); // Modal.
// Initialise the table model.
tableModel_ = new ListEntryModel(entry);
tableModel_.setNameColumnTitle("Item");
initComponents();
// Initialise actions and hookup to buttons.
addElementAction_ = new AddElementAction();
deleteElementAction_ = new DeleteElementAction();
btnInsertElement_.addActionListener(addElementAction_);
addElementAction_.addPropertyChangeListener
(
new ButtonActionChangedListener(btnInsertElement_)
);
btnDeleteElement_.addActionListener(deleteElementAction_);
deleteElementAction_.addPropertyChangeListener
(
new ButtonActionChangedListener(btnDeleteElement_)
);
// Listen out for selection events and enable the appropriate actions.
listTable_.getSelectionModel().addListSelectionListener
(
new ListSelectionListener()
{
public void valueChanged(ListSelectionEvent evt)
{
// Enabled if selection is not empty.
deleteElementAction_.setEnabled
(
!listTable_.getSelectionModel().isSelectionEmpty()
);
}
}
);
// Set cell renderer for name column.
listTable_.getColumn
(
tableModel_.getNameColumnTitle()
).setCellRenderer(new DictionaryNameCellRenderer());
// Set cell renderer and editor for value column.
listTable_.getColumn
(
tableModel_.getValueColumnTitle()
).setCellRenderer(new DictionaryEntryCellRenderer());
listTable_.getColumn
(
tableModel_.getValueColumnTitle()
).setCellEditor(new DictionaryEntryCellEditor());
// Resize to show the defined rows only.
// Calculate size: table + some extra (= 1 row height) or
// space needed for panel itself (so with empty table)
int height =
(
listTable_.getRowHeight() * (tableModel_.getRowCount() + 1)
+ (int)getMinimumSize().getHeight()
); // panel size
height = Math.min(height, DEFAULT_HEIGHT);
setSize(new java.awt.Dimension(DEFAULT_WIDTH, height));
}
//--------------------------------------------------------------------------
/** 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 FormEditor.
*/
private void initComponents()//GEN-BEGIN:initComponents
{
mainPanel_ = new javax.swing.JPanel();
tableScrollPane_ = new javax.swing.JScrollPane();
listTable_ = new javax.swing.JTable();
listButtonPanel_ = new java.awt.Panel();
btnInsertElement_ = new javax.swing.JButton();
btnDeleteElement_ = new javax.swing.JButton();
btnMoveElementUp_ = new javax.swing.JButton();
btnMoveElementDown_ = new javax.swing.JButton();
buttonPanel_ = new javax.swing.JPanel();
closeButton_ = new javax.swing.JButton();
getContentPane().setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints1;
setName("List Editor");
setModal(true);
setFont(new java.awt.Font("Dialog", 0, 10));
addWindowListener(new java.awt.event.WindowAdapter()
{
public void windowClosing(java.awt.event.WindowEvent evt)
{
closeDialog(evt);
}
});
mainPanel_.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints2;
mainPanel_.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(10, 10, 10, 10)));
listTable_.setModel(tableModel_);
listTable_.setFont(new java.awt.Font("Dialog", 0, 10));
tableScrollPane_.setViewportView(listTable_);
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints2.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints2.weightx = 1.0;
gridBagConstraints2.weighty = 1.0;
mainPanel_.add(tableScrollPane_, gridBagConstraints2);
listButtonPanel_.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints3;
listButtonPanel_.setFont(new java.awt.Font("Dialog", 0, 11));
listButtonPanel_.setBackground(new java.awt.Color(204, 204, 204));
listButtonPanel_.setForeground(java.awt.Color.black);
btnInsertElement_.setFont(new java.awt.Font("Dialog", 0, 10));
btnInsertElement_.setText("Insert...");
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 0;
gridBagConstraints3.gridy = 0;
gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints3.insets = new java.awt.Insets(5, 5, 5, 5);
listButtonPanel_.add(btnInsertElement_, gridBagConstraints3);
btnDeleteElement_.setFont(new java.awt.Font("Dialog", 0, 10));
btnDeleteElement_.setText("Delete...");
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 0;
gridBagConstraints3.gridy = 1;
gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints3.insets = new java.awt.Insets(0, 5, 5, 5);
listButtonPanel_.add(btnDeleteElement_, gridBagConstraints3);
btnMoveElementUp_.setFont(new java.awt.Font("Dialog", 0, 10));
btnMoveElementUp_.setText("Move Up");
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 0;
gridBagConstraints3.gridy = 2;
gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints3.insets = new java.awt.Insets(0, 5, 5, 5);
listButtonPanel_.add(btnMoveElementUp_, gridBagConstraints3);
btnMoveElementDown_.setFont(new java.awt.Font("Dialog", 0, 10));
btnMoveElementDown_.setText("Move Down");
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 0;
gridBagConstraints3.gridy = 3;
gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints3.insets = new java.awt.Insets(0, 5, 5, 5);
listButtonPanel_.add(btnMoveElementDown_, gridBagConstraints3);
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 1;
gridBagConstraints2.gridy = 0;
gridBagConstraints2.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHEAST;
mainPanel_.add(listButtonPanel_, gridBagConstraints2);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints1.insets = new java.awt.Insets(5, 5, 5, 5);
gridBagConstraints1.weightx = 1.0;
gridBagConstraints1.weighty = 1.0;
getContentPane().add(mainPanel_, gridBagConstraints1);
buttonPanel_.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
buttonPanel_.setBorder(new javax.swing.border.EtchedBorder());
closeButton_.setFont(new java.awt.Font("Dialog", 0, 10));
closeButton_.setText("Close");
closeButton_.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
OnClose(evt);
}
});
buttonPanel_.add(closeButton_);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 1;
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints1.weightx = 1.0;
getContentPane().add(buttonPanel_, gridBagConstraints1);
pack();
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setSize(new java.awt.Dimension(350, 300));
setLocation((screenSize.width-350)/2,(screenSize.height-300)/2);
}//GEN-END:initComponents
//--------------------------------------------------------------------------
private void shapeTypeComboActionPerformed (java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_shapeTypeComboActionPerformed
}//GEN-LAST:event_shapeTypeComboActionPerformed
//--------------------------------------------------------------------------
private void OnClose (java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_OnClose
// Commit any pending edits.
listTable_.editingStopped(new ChangeEvent(this));
// Close the dialog.
setVisible(false);
dispose();
}//GEN-LAST:event_OnClose
//--------------------------------------------------------------------------
/** Closes the dialog */
private void closeDialog(java.awt.event.WindowEvent evt)
{//GEN-FIRST:event_closeDialog
setVisible(false);
dispose();
}//GEN-LAST:event_closeDialog
//--------------------------------------------------------------------------
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel mainPanel_;
private javax.swing.JScrollPane tableScrollPane_;
private javax.swing.JTable listTable_;
private java.awt.Panel listButtonPanel_;
private javax.swing.JButton btnInsertElement_;
private javax.swing.JButton btnDeleteElement_;
private javax.swing.JButton btnMoveElementUp_;
private javax.swing.JButton btnMoveElementDown_;
private javax.swing.JPanel buttonPanel_;
private javax.swing.JButton closeButton_;
// End of variables declaration//GEN-END:variables
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
private class ListEntryModel
extends DictionaryEntryTableModel
{
//--------------------------------------------------------------------------
/** ListEntryModel constructor for list types.
* @param dictionaryEntry Reference to the dictionary entry object.
*/
public ListEntryModel(IDictionaryEntry compoundEntry)
{
super(compoundEntry);
}
//--------------------------------------------------------------------------
public java.lang.Object getValueAt(int rowIndex, int columnIndex)
{
java.lang.Object obj = null;
try
{
// Check for valid row index.
if (rowIndex>= getRowCount())
{
throw new Exception("Invalid row index");
}
if (columnIndex == NAME_COLUMN_INDEX)
{
// Return the row index as a string.
obj = Integer.toString(rowIndex);
}
else
{
// Return the DictionaryEntry object for this entry.
DictionaryEntry dictEntry =
(DictionaryEntry)dictEntryList_.get(rowIndex);
obj = dictEntry;
}
}
catch (FoamXIOError ioErr)
{
App.handleException(ioErr);
}
catch (FoamXError fxErr)
{
App.handleException(fxErr);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
return obj;
}
//--------------------------------------------------------------------------
public void addElement()
{
try
{
// Add new element to the list.
DictionaryEntryCache dictEntry =
((ListCache)rootEntry_).addListElement();
// Add to model.
dictEntryList_.add(dictEntry);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
//--------------------------------------------------------------------------
public void removeElement(int index)
{
try
{
// Check for valid row index.
if
(
index>= getRowCount()
)
{
throw new Exception("Invalid row index");
}
// Remove this entry from the model.
DictionaryEntryCache dictEntryCache
= (DictionaryEntryCache)dictEntryList_.get(index);
ListCache listRoot = (ListCache)rootEntry_;
listRoot.removeElement(dictEntryCache);
dictEntryList_.remove(index);
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
class AddElementAction
extends AbstractAction
{
public AddElementAction()
{
super("AddElement");
putValue(Action.NAME, "Add Element");
putValue(Action.SHORT_DESCRIPTION, "Add Element");
putValue(Action.LONG_DESCRIPTION, "Add Element");
}
public void actionPerformed(ActionEvent e)
{
try
{
tableModel_.addElement();
listTable_.updateUI();
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
}
//--------------------------------------------------------------------------
class DeleteElementAction
extends AbstractAction
{
public DeleteElementAction()
{
super("DeleteElement");
putValue(Action.NAME, "Delete Element");
putValue(Action.SHORT_DESCRIPTION, "Delete Element");
putValue(Action.LONG_DESCRIPTION, "Delete Element");
}
public void actionPerformed(ActionEvent e)
{
try
{
// Remove the selected elements.
if (!listTable_.getSelectionModel().isSelectionEmpty())
{
int minIndex =
listTable_.getSelectionModel().getMinSelectionIndex();
int maxIndex =
listTable_.getSelectionModel().getMaxSelectionIndex();
// Need to remove from the top so that it doesn't get its
// knickers in a twist.
for (int i=maxIndex; i>= minIndex; i--)
{
tableModel_.removeElement(i);
}
listTable_.getSelectionModel().clearSelection();
deleteElementAction_.setEnabled(false);
}
listTable_.updateUI();
}
catch (Exception ex)
{
App.handleAllExceptions(ex);
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More