Commit b75f2b56 authored by Andrey Filippov's avatar Andrey Filippov

merged with current version of veditor

parents

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="_generated"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
bin
*.zip
*.jar
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_CLEAN_TARGETS" value="clean,"/>
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="true"/>
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/vdt"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.6.0_11"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.ant.internal.ui.antsupport.InternalAntRunner"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="vdt"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="false"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/veditor/buildjavacc.xml}"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,clean"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/veditor}"/>
<stringAttribute key="process_factory_id" value="org.eclipse.ant.ui.remoteAntProcessFactory"/>
</launchConfiguration>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>vdt</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/.externalToolBuilders/Ant Builder.launch</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
#Tue Sep 04 22:07:00 MDT 2007
eclipse.preferences.version=1
instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
#Tue Sep 04 22:07:00 MDT 2007
eclipse.preferences.version=1
instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true
#Fri Jun 29 11:16:50 MDT 2007
eclipse.preferences.version=1
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
To import the VDT plugin project into the Eclipse workspace:
1) Unzip the source archive file com.elphel.vdt_1.0.2-src.zip.
The 'com.elphel.vdt' directory shall appear.
2) Run Eclipse (the plugin was tested with Eclipse 3.2M4).
3) From the main menu, select "File" -> "Import" -> "General" -> "Existing Project into Workspace".
Click the "Next" button.
4) Select 'Select root directory' option and specify a path to the 'com.elphel.vdt' directory.
The 'com.elphel.vdt' name in the "Projects" list shall appear.
5) Ensure that it is selected and click the "Finish" button.
To build and run the VDT plugin from the Eclipse workspace:
1) Import the VDT plugin project into the Eclipse workspace.
2) In the "Package Explorer" window, expand the 'com.elphel.vdt' folder and double-click
the 'plugin.xml' file.
3) Select the "Overview" tab at the bottom of the appeared window.
4) Under the "Testing" label, click the "Launch an Eclipe application" link.
A new instance of Eclipse shall be run.
5) Now play with the plugin. To open the main perspective, select from the main menu
"Window" -> "Open Perspective" -> "Other" -> "Verilog".
To create a binary distribution package of the plugin:
1) Import the VDT plugin project into the Eclipse workspace.
2) In the "Package Explorer" window, expand the 'com.elphel.vdt' folder and double-click
the 'plugin.xml' file.
3) Select the "Overview" tab at the bottom of the appeared window.
4) Under the "Exporting" label, click the "Export Wizard" link.
The "Export" dialog shall appear.
5) Ensure that 'com.elphel.vdt (1.0.2)' is selected in the plugins list.
6) In the "Export Destination" field, enter an archive file name, for example:
'D:\com.elphel.vdt_1.0.2.zip'.
7) Click the "Finish" button. A distribution package 'D:\com.elphel.vdt_1.0.2.zip' shall be created.
Now you can just unpack it in the Eclipse installation directory and the plugin will work.
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: com.elphel.vdt.veditor; singleton:=true
Bundle-Version: 2.0
Bundle-ClassPath: veditor.jar
Bundle-Activator: com.elphel.vdt.veditor.VerilogPlugin
Bundle-Vendor: %Bundle-Vendor
Bundle-Localization: plugin
Export-Package:
com.elphel.vdt;uses:="org.eclipse.core.runtime,org.eclipse.core.resources",
com.elphel.vdt.core;uses:="org.eclipse.core.runtime,org.eclipse.core.resources",
com.elphel.vdt.core.launching;
uses:="org.eclipse.debug.core,
org.eclipse.core.runtime,
com.elphel.vdt.core.tools.params,
org.eclipse.core.resources,
org.eclipse.debug.core.model",
com.elphel.vdt.core.options;
uses:="org.eclipse.jface.preference,
com.elphel.vdt.core.tools.params,
org.eclipse.core.resources,
com.elphel.vdt.core.tools.params.types,
com.elphel.vdt.core.tools.contexts",
com.elphel.vdt.core.tools;
uses:="com.elphel.vdt.core.tools.menu,
com.elphel.vdt.core.tools.config,
com.elphel.vdt.core.tools.params,
com.elphel.vdt.core.tools.contexts",
com.elphel.vdt.core.tools.config;uses:="com.elphel.vdt.core.tools.menu,com.elphel.vdt.core.tools.params,com.elphel.vdt.core.tools.contexts",
com.elphel.vdt.core.tools.config.xml;
uses:="com.elphel.vdt.core.tools.config,
com.elphel.vdt.core.tools.params.conditions,
org.w3c.dom,
com.elphel.vdt.core.tools.contexts",
com.elphel.vdt.core.tools.contexts;
uses:="com.elphel.vdt.core.tools.menu,
com.elphel.vdt.core.tools.config,
com.elphel.vdt.core.tools.params,
com.elphel.vdt.core.tools.params.conditions",
com.elphel.vdt.core.tools.generators;uses:="com.elphel.vdt.core.tools.params",
com.elphel.vdt.core.tools.menu;uses:="com.elphel.vdt.core.tools,com.elphel.vdt.core.tools.config",
com.elphel.vdt.core.tools.params;
uses:="com.elphel.vdt.core.tools,
com.elphel.vdt.core.tools.config,
com.elphel.vdt.core.tools.params.conditions,
com.elphel.vdt.core.tools.params.types,
com.elphel.vdt.core.tools.contexts",
com.elphel.vdt.core.tools.params.conditions;uses:="com.elphel.vdt.core.tools,com.elphel.vdt.core.tools.contexts",
com.elphel.vdt.core.tools.params.recognizers;uses:="com.elphel.vdt.core.tools.generators,com.elphel.vdt.core.tools.params,com.elphel.vdt.core.tools.contexts",
com.elphel.vdt.core.tools.params.types;uses:="com.elphel.vdt.core.tools.params",
com.elphel.vdt.ui;
uses:="org.eclipse.core.runtime,
org.eclipse.jface.resource,
org.eclipse.swt.graphics,
com.elphel.vdt.core.tools.contexts",
com.elphel.vdt.ui.dialogs;
uses:="org.eclipse.core.runtime,
com.elphel.vdt.core.tools.menu,
com.elphel.vdt.core.tools.params,
org.eclipse.swt.graphics,
org.eclipse.jface.viewers,
org.eclipse.ui.dialogs,
org.eclipse.swt.widgets,
com.elphel.vdt.ui.tools,
com.elphel.vdt.core.tools.contexts,
org.eclipse.jface.dialogs",
com.elphel.vdt.ui.launching;
uses:="org.eclipse.debug.core,
org.eclipse.jface.action,
org.eclipse.debug.ui,
org.eclipse.debug.ui.actions,
com.elphel.vdt.core.tools.params,
org.eclipse.ui,
org.eclipse.jface.viewers,
com.elphel.vdt.ui.tools",
com.elphel.vdt.ui.options;
uses:="org.eclipse.jface.preference,
org.eclipse.jface.resource,
org.eclipse.ui,
com.elphel.vdt.core.tools.params,
org.eclipse.core.resources,
com.elphel.vdt.ui.preferences,
org.eclipse.swt.widgets,
org.eclipse.jface.dialogs,
com.elphel.vdt.ui.options.component,
com.elphel.vdt.core.tools.contexts",
com.elphel.vdt.ui.options.component;
uses:="org.eclipse.jface.preference,
org.eclipse.swt.events,
com.elphel.vdt.core.tools.params,
com.elphel.vdt.core.options,
org.eclipse.swt.graphics,
com.elphel.vdt.ui.dialogs,
org.eclipse.swt.widgets",
com.elphel.vdt.ui.options.fieldeditor;
uses:="org.eclipse.jface.preference,
com.elphel.vdt.core.tools.params,
org.eclipse.swt.widgets,
com.elphel.vdt.core.tools.contexts",
com.elphel.vdt.ui.options.project;
uses:="org.eclipse.jface.preference,
org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.ui.dialogs,
org.eclipse.swt.widgets",
com.elphel.vdt.ui.preferences;
uses:="org.eclipse.jface.preference,
org.eclipse.jface.resource,
com.elphel.vdt.core.tools.params,
org.eclipse.ui,
org.eclipse.swt.widgets,
org.eclipse.core.runtime.preferences,
com.elphel.vdt.ui.tools,
org.eclipse.ui.forms.widgets",
com.elphel.vdt.ui.texts,
com.elphel.vdt.ui.tools;
uses:="org.eclipse.debug.core,
org.eclipse.debug.ui,
com.elphel.vdt.core.tools,
com.elphel.vdt.core.tools.config,
com.elphel.vdt.core.tools.params,
org.eclipse.core.resources,
org.eclipse.swt.widgets",
com.elphel.vdt.ui.tools.params;
uses:="org.eclipse.debug.core,
org.eclipse.swt.events,
com.elphel.vdt.core.tools.params,
org.eclipse.swt.widgets,
com.elphel.vdt.ui.tools,
com.elphel.vdt.ui.options.component",
com.elphel.vdt.ui.variables;
uses:="org.eclipse.ui,
org.eclipse.core.resources,
org.eclipse.jface.viewers,
org.eclipse.swt.widgets,
org.eclipse.core.variables",
com.elphel.vdt.ui.views;
uses:="com.elphel.vdt.core.tools.config,
com.elphel.vdt.core.tools.params,
org.eclipse.ui,
org.eclipse.ui.part,
com.elphel.vdt.core.tools.contexts,
org.eclipse.jface.action,
com.elphel.vdt.core.tools.menu,
org.eclipse.core.resources,
org.eclipse.jface.viewers,
org.eclipse.swt.graphics,
org.eclipse.swt.widgets",
com.elphel.vdt.ui.wizards;
uses:="org.eclipse.jface.action,
org.eclipse.jface.wizard,
org.eclipse.ui,
org.eclipse.jface.viewers",
com.elphel.vdt.ui.wizards.module;
uses:="org.eclipse.jface.wizard,
org.eclipse.jface.operation,
org.eclipse.core.runtime,
org.eclipse.swt.events,
org.eclipse.ui,
org.eclipse.core.resources,
org.eclipse.jface.viewers,
com.elphel.vdt.ui.wizards,
org.eclipse.swt.widgets",
com.elphel.vdt.ui.wizards.project;
uses:="org.eclipse.jface.wizard,
org.eclipse.jface.operation,
org.eclipse.core.runtime,
com.elphel.vdt.core.tools.menu,
org.eclipse.ui,
org.eclipse.swt.events,
org.eclipse.core.resources,
org.eclipse.jface.viewers,
com.elphel.vdt.ui.wizards,
org.eclipse.swt.widgets",
com.elphel.vdt.util;uses:="org.eclipse.swt.widgets",
com.elphel.vdt.veditor;
uses:="org.eclipse.core.runtime,
org.eclipse.jface.resource,
org.eclipse.ui.console,
org.eclipse.ui,
org.eclipse.ui.plugin,
org.eclipse.jface.text.templates,
org.eclipse.jface.preference,
org.eclipse.core.resources,
org.eclipse.jface.text.templates.persistence,
org.eclipse.swt.graphics,
org.eclipse.ui.editors.text.templates,
org.eclipse.swt.widgets",
com.elphel.vdt.veditor.actions;
uses:="org.eclipse.jface.action,
org.eclipse.jface.text.source,
org.eclipse.jface.resource,
com.elphel.vdt.veditor.editor,
org.eclipse.ui,
org.eclipse.jface.viewers,
org.eclipse.swt.widgets",
com.elphel.vdt.veditor.builder;
uses:="org.eclipse.core.runtime,
org.eclipse.ui.console,
org.eclipse.core.resources,
org.eclipse.ui.dialogs,
org.eclipse.swt.widgets,
org.eclipse.jface.dialogs",
com.elphel.vdt.veditor.document;
uses:="org.eclipse.jface.text,
org.eclipse.core.runtime,
com.elphel.vdt.veditor.parser,
com.elphel.vdt.veditor.editor.scanner,
org.eclipse.core.resources,
org.eclipse.ui.editors.text",
com.elphel.vdt.veditor.editor;
uses:="org.eclipse.jface.text,
org.eclipse.jface.text.source,
org.eclipse.core.runtime,
com.elphel.vdt.veditor.editor.completionProposals,
com.elphel.vdt.veditor.parser,
com.elphel.vdt.veditor.parser.vhdl,
com.elphel.vdt.veditor.document,
org.eclipse.ui,
org.eclipse.ui.part,
org.eclipse.jface.text.contentassist,
org.eclipse.jface.text.templates,
org.eclipse.jface.action,
org.eclipse.ui.views.contentoutline,
org.eclipse.jface.text.presentation,
com.elphel.vdt.veditor.editor.scanner,
org.eclipse.core.resources,
org.eclipse.jface.viewers,
org.eclipse.swt.graphics,
org.eclipse.swt.widgets,
org.eclipse.ui.editors.text,
org.eclipse.jface.text.source.projection",
com.elphel.vdt.veditor.editor.completionProposals;
uses:="org.eclipse.jface.text,
com.elphel.vdt.veditor.parser,
com.elphel.vdt.veditor.parser.vhdl,
com.elphel.vdt.veditor.document,
org.eclipse.core.resources,
org.eclipse.swt.graphics,
org.eclipse.jface.text.contentassist,
org.eclipse.jface.text.templates",
com.elphel.vdt.veditor.editor.scanner;uses:="com.elphel.vdt.veditor.editor,org.eclipse.jface.text.rules",
com.elphel.vdt.veditor.editor.scanner.verilog;uses:="com.elphel.vdt.veditor.editor.scanner,org.eclipse.jface.text.rules",
com.elphel.vdt.veditor.editor.scanner.vhdl;uses:="com.elphel.vdt.veditor.editor.scanner,org.eclipse.jface.text.rules",
com.elphel.vdt.veditor.log;
uses:="org.eclipse.jface.text,
org.eclipse.core.runtime,
org.eclipse.jface.text.source,
org.eclipse.ui.editors.text",
com.elphel.vdt.veditor.parser,
com.elphel.vdt.veditor.parser.verilog,
com.elphel.vdt.veditor.parser.vhdl,
com.elphel.vdt.veditor.preference;
uses:="org.eclipse.ui.texteditor.templates,
org.eclipse.jface.text.source,
org.eclipse.jface.preference,
org.eclipse.ui,
org.eclipse.core.runtime.preferences,
org.eclipse.swt.widgets,
org.eclipse.jface.dialogs",
com.elphel.vdt.veditor.semanticwarnings;uses:="com.elphel.vdt.veditor.parser.vhdl,org.eclipse.core.resources",
com.elphel.vdt.veditor.templates;uses:="org.eclipse.jface.text.templates",
com.elphel.vdt.veditor.wizard;
uses:="org.eclipse.jface.wizard,
org.eclipse.jface.text.source,
org.eclipse.ui,
org.eclipse.jface.viewers,
org.eclipse.swt.widgets,
org.eclipse.jface.text.templates"
Require-Bundle:
org.eclipse.ui,
org.eclipse.ui.editors,
org.eclipse.ui.workbench.texteditor,
org.eclipse.core.runtime,
org.eclipse.jface.text,
org.eclipse.core.resources,
org.eclipse.ui.views,
org.eclipse.ui.ide,
org.eclipse.ui.console,
org.eclipse.core.filesystem,
org.eclipse.debug.ui,
org.eclipse.core.variables,
org.eclipse.ui.forms;bundle-version="3.6.1",
org.eclipse.ui.externaltools;bundle-version="3.2.200"
Eclipse-LazyStart: true
Please read basic installation instructions in the "INSTALL" file.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<title>About</title>
<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
</head>
<body lang="EN-US">
<h2>About This Content</h2>
<h3>License</h3>
<p>This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.</p>
<p>This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.</p>
<p>You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</p>
</body>
</html>
\ No newline at end of file
# VDT plug-in's labels and captions
#------------------------------------------------------------------------------
Property.Xilinx.Path.prompt = Xlinx ISE &location:
Property.Xilinx.Path.errorMessage = Value must be Xlinx ISE installation directory
Property.Xilinx.Path.browse = &Browse...
Property.Xilinx.Path.BrowseDialog.Message = Specify a directory with Xilinx ISE
Property.ToolLocation.errorMessage = 'Invalid location of "{0}" ({1})'
Property.ToolLocation.browse = &Browse...
Property.ToolShell.errorMessage = 'Invalid location of "{0}" ({1})'
Property.ToolShell.browse = &Browse...
PropertyPage.Verilog.label = Please give an absolut path to verilog tools:
Wizard.NewProject.Caption = New Verilog Project
Wizard.NewModule.Caption = New Verilog Module
WizardPage.NewProjectMain.caption = New Verilog project
WizardPage.NewProjectMain.description = Specify a name of the new Verilog project.
WizardPage.NewProjectMain.Name.prompt = &Project name:
WizardPage.NewProjectMain.Menu.prompt = &Design menu:
WizardPage.NewProjectOptions.caption = Verilog project properties
WizardPage.NewProjectOptions.description = Specify properties of the new Verilog project.
WizardPage.NewModuleMain.caption = Verilog Module
WizardPage.NewModuleMain.description = Create a new file for Verilog module.
WizardPage.NewModuleMain.Path.prompt = &Location:
WizardPage.NewModuleMain.Path.browse = &Browse...
WizardPage.NewModuleMain.Name.prompt = &File name:
WizardPage.NewModuleMain.Browse = &Browse...
WizardPage.NewModuleMain.Browse.message = Choose a folder:
WizardPage.NewModuleTemplate.caption = Verilog Module
WizardPage.NewModuleTemplate.description = Create a Verilog module.
WizardPage.NewModuleTemplate.Module.name = Module name:
WizardPage.NewModuleTemplate.Error.NoModuleName = Module name must be specified
WizardPage.NewModuleTemplate.ModuleInterface.prompt = Module interface:
WizardPage.NewModuleTemplate.AddPort = Add
WizardPage.NewModuleTemplate.RemovePort = Remove
WizardPage.NewModuleTemplate.MoveUpPort = Up
WizardPage.NewModuleTemplate.MoveDownPort = Down
Launch.Message.Launching = Launching VDT tool...
Launch.Message.ConstructingCommandLine = Constructing command line...
Launch.Message.Starting = Starting virtual machine...
Launch.Process.LabelFormat = '{0} ({1})'
Launch.Process.Error = An IProcess could not be created for the launch
Launch.JobName = Launching
Launch.Beginning = '{0}...'
Launch.CreatingToolArguments = Creating tool arguments...
Launch.Error.ToolNotNull = Tool to launch cannot be null
Launch.Error.InvalidWorkingDir = 'Specified working directory does not exist or is not a directory: {0}'
Launch.Error.ToolLocation = 'Tool location not specified by {0}'
Launch.Error.InvalidLocation = 'The file does not exist for the tool named {0}.'
Launch.Cancel.Message = 'Failed to launch {0}. Launching was cancelled.'
Action.ToolLounch.Error = 'Cannot launch "{0}".\n{1}'
Action.ToolLounch.Caption.Default = 'Run'
Action.ToolLounch.ToolTip.Default = 'Run selected tool'
Action.ToolLounch.Caption = 'Run for "{0}"'
Action.ToolLounch.ToolTip = 'Run {0} for "{1}"'
Action.OpenLaunchConfigDialog.Error = 'Cannot open launch configuration dialog for "{0}".\n{1}'
Action.OpenLaunchConfigDialog.Caption = 'Launch configuration'
Action.Context.Save.Error = 'Cannot save configuration "{0}".\n{1}'
Action.OpenInstallationPropertiesDialog.Error = 'Cannot save installation configuration.\n{0}'
Action.PackageProperties.Save.Error = 'Cannot save "{0}" package configuration.\n{1}'
Action.PackageProperties.Caption.Default = 'Package Parameters'
Action.PackageProperties.ToolTip.Default = 'Package Parameters'
Action.PackageProperties.Caption = 'Package Parameters of "{0}"'
Action.PackageProperties.ToolTip = 'Package Parameters of {0} for "{1}"'
Action.ProjectPropertiesDialog.Save.Error = 'Cannot save "{0}" project configuration.\n{1}'
Action.ProjectProperties.Caption.Default = 'Project Parameters'
Action.ProjectProperties.ToolTip.Default = 'Project Parameters'
Action.ProjectProperties.Caption = 'Project Parameters of "{0}"'
Action.ProjectProperties.ToolTip = 'Project Parameters of {0} for "{1}"'
MainTab.caption = Main
MainTab.Location.promt = Location:
MainTab.Location.browse = &Browse...
MainTab.Location.Message.Info = Please specify the location of the verilog tool you would like to launch.
MainTab.Location.Message.CannotBeEmpty = Tool location cannot be empty
MainTab.Location.Message.DoesNotExist = Tool location does not exist
MainTab.Location.Message.IsNotFile = Tool location specified is not a file
MainTab.Error.ReadConfiguration = Error reading configuration
LaunchTab.Message.Info = 'Please specify the value of the parameter "{0}"'
LaunchTab.Error.CannotBeEmpty = 'The value of the parameter "{0}" cannot be empty'
LaunchTab.Error.UndefinedType = 'Type "{0}" is undefined'
LaunchTab.Error.UnsupportedType = 'Type "{0}" is unsupported'
LaunchTab.Error.ToolLocation = '"{0}" location is incorrect: [{1}]'
LaunchTab.Error.ReadConfiguration = Error reading configuration
LaunchTab.Number.Error.IncorrectValue = 'The value of the parameter "{0}" should be between {1,number,integer} and {2,number,integer}'
LaunchTab.File.Message.Info = 'Please specify the location of the "{0}"'
LaunchTab.Location.Error.CannotBeEmpty = 'The location of "{0}" cannot be empty'
LaunchTab.Location.Error.DoesNotExist = 'The location of "{0}" does not exist'
LaunchTab.Location.Message.IsNotFile = 'Specified location of "{0}" is not a file'
Message.Error.Caption = Error
Message.FatalError.Caption = Fatal Error
Dialog.ToolSelection.Caption = Select Tool
Dialog.ToolSelection.Message = Select tool to launch:
Dialog.ProjectSelection.Caption = Select Project
Dialog.ProjectSelection.Message = Select project to launch:
Variable.Promp.Hint1 = 'Please input a value for {0}'
Variable.Promp.Hint2 = 'Please input a value'
Variable.Promp.Cancel.Message = 'Failed to expand {0}. Input was cancelled.'
Variable.Verilog.Promp.Dialog.Title = Select a Verilog file:
Variable.Verilog.Promp.Dialog.Message = Select a Verilog file for launching tool:
Error.Variable.Verilog.NotExist = 'Variable references non-existent resource : {0}'
Error.Variable.Verilog.NoSelection = 'Variable references empty selection: {0}'
Error.Variable.Verilog.Unknown ='Variable not recognized: {0}'
Dialog.ListPrompt.Button.Add = Add
Dialog.ListPrompt.Button.Remove = Remove
Dialog.ListPrompt.Button.MoveUp = Up
Dialog.ListPrompt.Button.MoveDown = Down
Dialog.ModuleSelection.Caption = Verilog Module Selection
Dialog.ModuleSelection.Message = Choose a main verilog module:
Dialog.ToolLocation.Message = 'Debug: Specify the location of "{0}" ({1})'
Option.XlinxDevice.GroupCaption = Device settings
Option.XlinxDevice.DeviceFamaly = Device famaly:
Option.XlinxDevice.Device = Device:
Option.XlinxDevice.DevicePackage = Package:
Option.XlinxDevice.DeviceSpeedGrade = Speed grade:
ContentAssistProposal.label=Content Assist
GotoMatchingBracket.label=Matching Bracket
OpenDeclaration.label=Open Declaration
CollapseAll.label=Collapse All
ExpandAll.label=Expand All
Format.label=Format
VhdlFormatAction.label=Format
VerilogFormatAction.label=Format
Compile.label=Compile File
Synthesize.label=Synthesize Files
Comment.label=Comment
Uncomment.label=Uncomment
ShowInHierarchy.label=Show In Hierarchy
ShowInOutline.label=Show In Outline
ShowInNavigator.label=Show In Navigator
ClearErrorMarkers.label=Clear Problem Markers
CompletionProcessor.ContextInfo.display.pattern=proposal {0} at position {1}
CompletionProcessor.ContextInfo.value.pattern=proposal {0} valid from {1} to {2}
CompletionProcessor.Proposal.ContextInfo.pattern={0} valid 5 characters around insertion point
CompletionProcessor.Proposal.hoverinfo.pattern=Java keyword: {0}
\ No newline at end of file
/*******************************************************************************
* Copyright (c) 2004, 2012 KOBAYASHI Tadashi and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* KOBAYASHI Tadashi - initial API and implementation
*******************************************************************************/
options {
JAVA_UNICODE_ESCAPE = true ;
STATIC = false ;
}
PARSER_BEGIN(VerilogParserCore)
package com.elphel.vdt.veditor.parser.verilog;
public abstract class VerilogParserCore
{
public static final int STATEMENT = 0;
public static final int ASSIGN_STMT = 1;
public static final int INITIAL_BLOCK = 2;
public static final int ALWAYS_BLOCK = 3;
protected abstract void begin(int mode);
protected abstract void end(int mode);
protected abstract void beginOutlineElement(Token begin, String name, String type);
protected abstract void endOutlineElement(Token end, String name, String type);
protected void beginOutlineElement(Token begin, String type) {
beginOutlineElement(begin, begin.image, type);
}
protected void endOutlineElement(Token end, String type) {
endOutlineElement(end, end.image, type);
}
protected abstract void addCollapsible(int startLine,int endLine);
protected abstract Expression operator(Expression arg, Token op);
protected abstract Expression operator(Expression arg1, Token op, Expression arg2);
protected abstract Expression operator(Expression arg1, Token op, Expression arg2, Expression arg3);
protected abstract Expression variableReference(Identifier ident);
protected abstract Expression functionReference(Identifier ident);
protected abstract void parameterAssignment(String name, Expression value);
protected abstract void variableAssignment(Identifier ident);
protected abstract void taskReference(Identifier ident);
protected abstract void variableConnection(Expression arg, String module, Identifier port);
protected abstract void variableConnection(Expression arg, String module, int portIndex);
protected abstract void evaluateAssignment(Token asn, int lvalue, Expression exp);
protected abstract void beginGenerateBlock(Identifier block);
protected abstract void endGenerateBlock(Identifier block);
}
PARSER_END(VerilogParserCore)
//
// operation for /* */
//
MORE :
{
"/*" : IN_MULTI_LINE_COMMENT
}
<IN_MULTI_LINE_COMMENT>
SKIP :
{
<MULTI_LINE_COMMENT: "*/"> : DEFAULT
}
<IN_MULTI_LINE_COMMENT>
MORE :
{
< ~[] >
}
//
// operation for (* *)
//
MORE :
{
<"(*" ~[")"]> : IN_PROPERTY
}
<IN_PROPERTY>
SKIP :
{
<PROPERTY_COMMENT: "*)"> : DEFAULT
}
<IN_PROPERTY>
MORE :
{
< ~[] >
}
SKIP :
{
" " | "\t" | "\r" | "\n" | "\f"
}
SPECIAL_TOKEN :
{
<SINGLE_LINE_COMMENT: "//" (~["\n"])* >
}
TOKEN :
{
<MODULE: "module">
| <ENDMODULE: "endmodule">
| <BEGIN: "begin">
| <END: "end">
| <FORK: "fork">
| <JOIN: "join">
| <SPECIFY: "specify">
| <ENDSPECIFY:"endspecify">
| <IF: "if">
| <ELSE: "else">
| <WHILE: "while">
| <FOR: "for">
| <FOREVER: "forever">
| <REPEAT: "repeat">
| <WAIT: "wait">
| <CASE: ("case" | "casex" | "casez") >
| <DEFAULT_LABEL: "default">
| <ENDCASE: "endcase">
| <FUNCTION: "function">
| <ENDFUNCTION: "endfunction">
| <TASK: "task">
| <ENDTASK: "endtask">
| <GENERATE: "generate">
| <ENDGENERATE: "endgenerate">
| <INPUT: "input">
| <OUTPUT: "output">
| <INOUT: "inout">
| <INTEGER: "integer">
| <REG: "reg">
| < WIRE: "wire" >
| <EVENT: "event">
| <GENVAR: "genvar">
| <REAL: "real">
| <PARAMETER: "parameter">
| <LOCALPARAM: "localparam">
| <SIGNED: "signed">
| <PROPERTY: "property" >
| <ENDPROPERTY: "endproperty" >
| <ASSERT: "assert" | "cover">
| <ASSIGN: "assign" >
| <DEASSIGN: "deassign" >
| <FORCE : "force" >
| <RELEASE: "release" >
| < TIME: "time" >
| < REALTIME: "realtime" >
| < DEFPARAM: "defparam" >
| < OR: "or" >
| < DISABLE: "disable" >
| <ALWAYS: "always" >
| <INITIAL: "initial" >
| < EDGE: ( "posedge" | "negedge" ) >
| < SUPPLY : ( "supply0" | "supply1" ) >
| < NET_TYPE: ( "tri" | "tri1" | "wand" | "triand" | "tri0" | "wor" | "trior" ) >
| < STRENGTH: ("strong0" | "strong1" | "pull0" | "pull1" | "weak0" | "weak1" |"highz0" | "highz1" ) >
| <PRIM_1IN_XOUT: ( "and" | "xor" | "nand" | "nor" | "xnor")>
| <PRIM_1OUT_XIN: ( "buf" | "not" )>
| <PRIM_1OUT_1IN_1CNTL: ( "bufif0" | "bufif1" | "notif0" | "notif1" | "pmos" | "nmos" | "rpmos" | "rnmos")>
| <PRIM_1OUT: ( "pullup" | "pulldown")>
| <PRIM_1OUT_1IN_NC_PC: ("cmos" | "rcmos" )>
| <PRIM_BI: ("tran" | "rtran" | "tranif0" | "rtranif0" | "rtranif1")>
| <LPAREN: "(" >
| <RPAREN: ")" >
| <LBRACE: "{" >
| <RBRACE: "}" >
| <LBRACKET: "[" >
| <RBRACKET: "]" >
| <EOS: ";" >
| <PARA: "#" >
| <AT: "@" >
| <DOLLAR: "$" >
| <COMMA: "," >
| < DOT: "." >
//| <OTHER: "[.]" >
}
TOKEN :
{
< AGN: "=" >
| < GT: ">" >
| < LT: "<" >
| < BANG: "!" >
| < TILDE: "~" >
| < HOOK: "?" >
| < COLON: ":" >
| < PCOLON: "+:" >
| < MCOLON: "-:" >
| < EQ: "==" >
| < LE: "<=" >
| < GE: ">=" >
| < NE: "!=" >
| < SC_OR: "||" >
| < SC_AND: "&&" >
| < PLUS: "+" >
| < MINUS: "-" >
| < STAR: "*" >
| < SLASH: "/" >
| < BIT_AND: "&" >
| < BIT_OR: "|" >
| < XOR: "^" >
| < REM: "%" >
| < LSHIFT: "<<" >
| < RSHIFT: ">>" >
| < NEG_AND: "~&" >
| < NEG_OR: "~|" >
| < NEG_XOR: "~^" >
| < XOR_NEG: "^~" >
| < EQ_C: "===" >
| < NE_C: "!==" >
| < POWER: "**" >
| < ALSHIFT: "<<<" >
| < ARSHIFT: ">>>" >
}
TOKEN :
{
< IDENT :
// No matching macro means simple identifier
("`")? < LETTER > (< LETTER > | ["0"-"9"] )*
| < BACKSLASH > (~[ " " ])+
>
| < SYSTEM_IDENT:
"$" < LETTER > (< LETTER > | ["0"-"9"])*
>
| < #LETTER : [ "a"-"z", "A"-"Z", "_" ] >
| < #BACKSLASH : "\\" >
}
TOKEN :
{
< INTEGER_LITERAL :
< NUMBER_LITERAL >
| < DECIMAL_LITERAL >
| < HEX_LITERAL >
| < OCTAL_LITERAL >
| < BINARY_LITERAL >
>
| < #NUMBER_LITERAL : ([ "0"-"9", "_" ])+ >
| < #DECIMAL_LITERAL : ([ "0"-"9" ])* "'" (["s", "S"])? [ "d", "D" ] ([" ", "\t"])* ([ "0"-"9", "_", "x", "X", "z", "Z", "?"])* >
| < #HEX_LITERAL : ([ "0"-"9" ])* "'" (["s", "S"])? [ "h", "H" ] ([" ", "\t"])* ([ "0"-"9", "a"-"f", "A"-"F", "_", "x", "X", "z", "Z", "?" ])+ >
| < #OCTAL_LITERAL : ([ "0"-"9" ])* "'" (["s", "S"])? [ "o", "O" ] ([" ", "\t"])* ([ "0"-"7", "_", "x", "X", "z", "Z", "?" ])* >
| < #BINARY_LITERAL : ([ "0"-"9" ])* "'" (["s", "S"])? [ "b", "B" ] ([" ", "\t"])* ([ "0"-"1", "_", "x", "X", "z", "Z", "?" ])* >
| < REAL_LITERAL :
([ "0"-"9" ])+ "." ([ "0"-"9" ])*
| ([ "0"-"9" ])+ ( "." ([ "0"-"9" ])*)? [ "e", "E" ] ([ "+", "-" ])? ([ "0"-"9" ])+ >
| < STRING_LITERAL:
"\""
( (~["\"","\n","\r"])
| ("\\"
( ["n","t","b","r","f","\\","'","\""]
| ["0"-"7"] ( ["0"-"7"] )?
| ["0"-"3"] ["0"-"7"] ["0"-"7"]
)
)
)*
"\"" >
}
void verilogText() :
{}
{
( moduleDecl() )*
}
void moduleDecl() :
{
Identifier name;
Token end;
}
{
( <IDENT>)* // ignore preprocessor directive
< MODULE > name = identifier()
{
beginOutlineElement(name, "module#");
}
[ "#" "(" [ parameterArg() ( "," parameterArg() )* ] ")" ]
[ "(" [ argument() ( "," argument() )* ] ")" ]
";"
( moduleItem() )*
end = < ENDMODULE >
{
endOutlineElement(end, name. image, "module#");
}
}
void parameterArg() :
{
Token name,value;
String mod, range;
}
{
<PARAMETER> mod = parameterModifier() range = bitRange()
parameterAssign("parameter", mod, range)
}
String parameterModifier() :
{
String ret = " ";
}
{
(
("real" | "integer" | "signed" )
{
ret += token.image + " ";
}
)*
{
return ret;
}
}
void parameterAssign(String type, String mod, String range) :
{
Identifier name;
Expression value;
}
{
name = identifier()
"="
value = constantExpression()
{
String types = type + "#" + mod + "#" + range + "#" + value.toString();
beginOutlineElement(name, types);
parameterAssignment(name.image, value);
endOutlineElement(name, types);
}
}
void argument() :
{
Token direction;
Identifier name;
String modifier="";
String range;
Token asn;
Expression exp;
}
{
// C++ style argument
( direction=<INPUT> | direction=<OUTPUT> | direction=<INOUT> )
modifier = variableModifier()
range = bitRange()
name = identifier()
{
String types = "port#" + direction.image + "#" + modifier + "#" + range;
beginOutlineElement(name, types);
endOutlineElement(name, types);
}
[
asn = "=" exp = expression()
{
variableAssignment(name);
evaluateAssignment(asn, name.getWidth(), exp);
}
]
|
// C style argument, portDecl will add it to OutlineContainer
identifier()
}
void moduleItem() :
{}
{
moduleOrGenerateItem()
| portDecl()
| <SPECIFY> {begin(STATEMENT);} skipTo( ENDSPECIFY ) {end(STATEMENT);}
| generate()
| <PROPERTY> skipTo(ENDPROPERTY)
}
void moduleOrGenerateItem() :
{}
{
variableDecl()
| parameterDecl()
| taskDecl()
| functionDecl()
| <DEFPARAM> {begin(STATEMENT);} skipTo( EOS ) {end(STATEMENT);}
| assign()
| primitiveInstance()
| LOOKAHEAD(3) moduleInstance()
| initialAlways() // initial and always
| <ASSERT> skipTo(EOS)
| identifier() ":" <ASSERT> skipTo(EOS)
| ";"
}
void portDecl() :
{
Token direction;
String modifier;
String range;
}
{
( direction=<INPUT> | direction=<OUTPUT> | direction=<INOUT> )
modifier = variableModifier()
{ begin(STATEMENT); }
range = bitRange()
portDeclSingle(direction, modifier, range)
("," portDeclSingle(direction, modifier, range))* ";"
{ end(STATEMENT); }
}
String variableModifier() :
{
String ret = "";
}
{
(
( "real" | "realtime" | "integer" | "wire" | "reg" | "signed" | "time" )
{
ret += token.image + " ";
}
)*
{
return ret;
}
}
void portDeclSingle(Token direction, String modifier, String range) :
{
Identifier name;
Token asn;
Expression exp;
}
{
name = identifier()
{
String type = "port#" + direction.image + "#" + modifier + "#" + range + "#cstyle";
beginOutlineElement(name, type);
endOutlineElement(name, type);
}
[
asn = "=" exp = expression()
{
variableAssignment(name);
evaluateAssignment(asn, name.getWidth(), exp);
}
]
}
void primitiveInstance():
{
String prim;
}
{
( <PRIM_1IN_XOUT> | "or"
| <PRIM_1OUT_XIN>
| <PRIM_1OUT_1IN_1CNTL>
| <PRIM_1OUT>
| <PRIM_1OUT_1IN_NC_PC>
| <PRIM_BI>
) { prim = token.image;}
[ LOOKAHEAD(2) strength() ] [ delay3() ]
[ identifier() bitRange() ] "(" portConnect(prim) ")"
( "," identifier() bitRange() "(" portConnect(prim) ")" )*
";"
}
void moduleInstance():
{
Identifier module, inst;
Token iend ;
}
{
module = identifier()
{ begin(STATEMENT); }
( //module instantiation
( [ "#" ( identifier() | number() | "(" parameterConnect() ")" ) ]
inst = identifier()
{
beginOutlineElement(module, inst.image, "instance#"+module.image);
}
[ "(" [ portConnect(module.image) ] ")" ]
iend = ";"
{
endOutlineElement(iend, inst.image, "instance#"+module.image);
addCollapsible(module.beginLine, iend.endLine);
}
)
| //user defined primitive
( "(" portConnect(module.image) ")"
iend = ";"
)
)
{ end(STATEMENT); }
}
void parameterConnect() :
{}
{
"." identifier() "(" [ constantExpression() ] ")" ( "," "." identifier() "(" [ constantExpression() ] ")" )*
| constantExpression() ( "," constantExpression() )*
}
void portConnect(String module) :
{
int count = 0;
}
{
count = portConnectSingle(module, count)
( "," count = portConnectSingle(module, count) )*
}
int portConnectSingle(String module, int count) :
{
Identifier port;
Expression arg = null;
}
{
"." port = identifier() "(" [ arg = expression() ] ")"
{
variableConnection(arg, module, port);
return count + 1;
}
| arg = expression()
{
variableConnection(arg, module, count);
return count + 1;
}
}
void assign() :
{
int width;
Token asn;
Expression exp;
}
{
"assign"
{begin(ASSIGN_STMT); }
[ strength() ] [ delay3() ]
width = lvalue() asn = "=" exp = expression()
{
evaluateAssignment(asn, width, exp);
}
(
"," width = lvalue() asn = "=" exp = expression()
{
evaluateAssignment(asn, width, exp);
}
)*
";"
{end(ASSIGN_STMT); }
}
void variableDecl():
{
Token variable;
String type;
String range;
}
{
type = variableType()
{ begin(STATEMENT); }
[ strength() ]
[ "signed" { type += " signed";} ]
range = bitRange()
[ delay3() ]
variableDeclSingle(type, range) ( "," variableDeclSingle(type, range) )* ";"
{ end(STATEMENT); }
}
String variableType() :
{
String type;
}
{
type = netType()
{
return type;
}
| ( "reg" | "real" | "integer" | "event" |"genvar" | "time" | "realtime" )
{
return token.image;
}
}
void variableDeclSingle(String mod, String range) :
{
Identifier variable;
Token asn;
Expression exp;
int dimension = 0;
}
{
variable = identifier()
("[" constantExpression() ":" constantExpression() "]" { dimension++; })*
{
String type = "variable#" + mod + "#" + range + "#" + dimension;
beginOutlineElement(variable, type);
endOutlineElement(variable, type);
}
[
asn = "=" exp = expression()
{
variableAssignment(variable);
evaluateAssignment(asn, variable.getWidth(), exp);
}
]
}
void delay3() :
{}
{
"#"
(
LOOKAHEAD(3)
delayValue()
| "(" minTypMaxExpresstion() [ "," minTypMaxExpresstion() ["," minTypMaxExpresstion() ] ] ")"
)
}
void parameterDecl():
{
String type;
String mod, range;
}
{
(
<PARAMETER> {type = "parameter";}
| <LOCALPARAM> {type = "localparam";}
)
mod = parameterModifier()
range = bitRange()
parameterAssign(type, mod, range) ( "," parameterAssign(type, mod, range) )* ";"
}
void initialAlways():
{
Token start;
}
{
( start = <INITIAL> | start = <ALWAYS> )
{
if (start.image.equals("initial"))
begin(INITIAL_BLOCK);
else
begin(ALWAYS_BLOCK);
}
statement()
{
if (start.image.equals("initial"))
end(INITIAL_BLOCK);
else
end(ALWAYS_BLOCK);
addCollapsible(start.beginLine,token.endLine);
}
}
void statement() :
{
Token end;
}
{
assignOrTaskEnable()
| proceduralContinuousAssignment()
| proceduralTimingControlStatement()
| ifStatement()
| caseStatement()
| whileStatement()
| forStatement()
| foreverStatement()
| repeatStatement()
| waitStatement()
| "disable" identifier() ";"
| "->" identifier() ";"
| block()
| ";"
}
void assignOrTaskEnable() :
{
Identifier ident;
Token asn;
Expression exp;
int width;
}
{
ident = complexIdentifier()
(
(asn = "=" | asn = "<=") [delayOrEventControl() ] exp = expression() ";"
{
variableAssignment(ident);
evaluateAssignment(asn, ident.getWidth(), exp);
}
| [ "(" expression() ("," expression())* ")"] ";"
{
taskReference(ident);
}
)
| width = lvalueConcatenation() (asn = "=" | asn = "<=") [delayOrEventControl() ] exp = expression() ";"
{
evaluateAssignment(asn, width, exp);
}
| <SYSTEM_IDENT> [ "(" expression() ("," expression())* ")"] ";"
}
void delayOrEventControl() :
{}
{
delayContol() | eventContol()
}
void delayContol() :
{}
{
"#" ( delayValue() | "(" minTypMaxExpresstion() ")" )
}
void delayValue() :
{}
{
number() | identifier()
}
void eventContol() :
{}
{
"@"
( identifier()
| "*"
| "(" (eventExpression() | "*" ) ")"
)
}
void eventExpression():
{}
{
( expression() | < EDGE > expression() )
( ("," | "or") ( expression() | < EDGE > expression() ) )*
// 'repeat' '(' expression ')' event_control -> ignored
}
void proceduralContinuousAssignment() :
{
int width;
Token asn;
Expression exp;
}
{
"assign" width = lvalue() asn = "=" exp = expression() ";"
{
evaluateAssignment(asn, width, exp);
}
| "deassign" lvalue() ";"
| "force" width = lvalue() asn = "=" exp = expression() ";"
{
evaluateAssignment(asn, width, exp);
}
| "release" lvalue() ";"
}
void proceduralTimingControlStatement() :
{}
{
delayOrEventControl() statement()
}
void ifStatement() :
{}
{
<IF> "(" expression() ")" statement()
[ LOOKAHEAD(1) <ELSE> statement() ]
}
void caseStatement() :
{}
{
<CASE>"(" expression() ")"
(
expression() ("," expression())* ":" statement()
| "default" [":"] statement()
)+
<ENDCASE>
}
void whileStatement() :
{}
{
<WHILE> "(" expression() ")" statement()
}
void forStatement() :
{}
{
<FOR> "("
lvalue() "=" expression() ";"
expression() ";"
lvalue() "=" expression() ")"
statement()
}
void foreverStatement() :
{}
{
<FOREVER> statement()
}
void repeatStatement() :
{}
{
<REPEAT> "(" expression() ")" statement()
}
void waitStatement() :
{}
{
<WAIT> "(" expression() ")" statement()
}
void block() :
{}
{
( <BEGIN> | <FORK> )
[ ":" identifier() ( blockItem() )* ]
( statement() )*
(<END> | <JOIN> )
}
void blockItem():
{}
{
parameterDecl()
| variableDecl()
}
void functionDecl():
{}
{
<FUNCTION> {begin(STATEMENT);} function() {end(STATEMENT);}
}
void taskDecl():
{}
{
<TASK> {begin(STATEMENT);} task() {end(STATEMENT);}
}
void function() :
{
String range;
Identifier name;
Token end ;
}
{
variableModifier() range = bitRange() name = identifier()
[ "(" skipTo(RPAREN) ]
";"
{
beginOutlineElement(name, "function#" + range);
}
end = skipTo( ENDFUNCTION )
{
endOutlineElement(end, name.image, "function#" + range);
addCollapsible(name.beginLine, end.endLine);
}
}
void task() :
{
Identifier name;
Token end ;
}
{
name = identifier() ";"
{
beginOutlineElement(name, "task#");
}
end = skipTo( ENDTASK )
{
endOutlineElement(end, name.image, "task#");
addCollapsible(name.beginLine, end.endLine);
}
}
void generate() :
{}
{
<GENERATE>
( generateItem() )*
<ENDGENERATE>
}
void generateItem() :
{
Identifier block = null;
}
{
moduleOrGenerateItem()
| generateIfStatement()
| generateCaseStatement()
| generateForStatement()
| (
<BEGIN> [ ":" block = identifier() ]
{
if (block != null)
beginGenerateBlock(block);
}
( generateItem() )*
<END>
{
if (block != null) {
endGenerateBlock(block);
}
}
)
}
void generateIfStatement() :
{}
{
<IF> "(" constantExpression() ")" generateItem()
[ LOOKAHEAD(1) <ELSE> generateItem() ]
}
void generateCaseStatement() :
{}
{
<CASE> "(" constantExpression() ")"
(
constantExpression() ("," constantExpression())* ":" generateItem()
| "default" ":" generateItem()
)+
<ENDCASE>
}
void generateForStatement() :
{}
{
<FOR> "("
lvalue() "=" expression() ";"
expression() ";"
lvalue() "=" expression() ")"
generateItem()
}
String netType() :
{}
{
( "wire" | < NET_TYPE > | < SUPPLY > )
{
return token.image;
}
}
void strength() :
{}
{
"(" ( < STRENGTH > | < SUPPLY > ) ["," ( < STRENGTH > | < SUPPLY > ) ]")"
}
int lvalue() :
{
int width;
Identifier ident;
}
{
ident = complexIdentifier()
{
variableAssignment(ident);
return ident.getWidth();
}
| width = lvalueConcatenation()
{
return width;
}
}
int lvalueConcatenation() :
{
int width;
int ret;
}
{
"{" ret = lvalue()
( ","
width = lvalue()
{
if (width == 0 || ret == 0)
ret = 0;
else
ret += width;
}
)*
"}"
{
return ret;
}
}
Identifier identifier() :
{
Token token;
}
{
token = < IDENT >
{
return new Identifier(token);
}
}
Expression constantExpression() :
{
Expression ret;
}
{
ret = expression()
{
return ret;
}
}
Expression expression() :
{
Expression ret, exp1, exp2;
Token op;
}
{
ret = logicalOrExpresstion()
[
op = "?" exp1 = expression() ":" exp2 = expression()
{
ret = operator(ret, op, exp1, exp2);
}
]
{
return ret;
}
}
Expression logicalOrExpresstion() :
{
Expression ret, exp;
Token op;
}
{
ret = logicalAndExpresstion()
( op = "||" exp = logicalAndExpresstion() { ret = operator(ret, op, exp); } )*
{
return ret;
}
}
Expression logicalAndExpresstion() :
{
Expression ret, exp;
Token op;
}
{
ret = bitOrExpresstion()
( op = "&&" exp = bitOrExpresstion() { ret = operator(ret, op, exp); } )*
{
return ret;
}
}
Expression bitOrExpresstion() :
{
Expression ret, exp;
Token op;
}
{
ret = bitAndExpresstion()
( op = "|" exp = bitAndExpresstion() { ret = operator(ret, op, exp); } )*
{
return ret;
}
}
Expression bitAndExpresstion() :
{
Expression ret, exp;
Token op;
}
{
ret = equalityExpression()
(
(op = "&" | op = "^" | op = "~^" | op = "^~")
exp = equalityExpression() { ret = operator(ret, op, exp); }
)*
{
return ret;
}
}
Expression equalityExpression() :
{
Expression ret, exp;
Token op;
}
{
ret = relationalExpression()
(
(op = "==" | op = "===" | op = "!=" | op = "!==")
exp = relationalExpression() { ret = operator(ret, op, exp); }
)*
{
return ret;
}
}
Expression relationalExpression() :
{
Expression ret, exp;
Token op;
}
{
ret = shiftExpression()
(
(op = "<" | op = "<=" | op = ">" | op = ">=")
exp = shiftExpression() { ret = operator(ret, op, exp); }
)*
{
return ret;
}
}
Expression shiftExpression() :
{
Expression ret, exp;
Token op;
}
{
ret = addExpression()
(
(op = "<<" | op = ">>" | op = "<<<" | op = ">>>")
exp = addExpression() { ret = operator(ret, op, exp); }
)*
{
return ret;
}
}
Expression addExpression() :
{
Expression ret, exp;
Token op;
}
{
ret = multiplyExpression()
(
(op = "+" | op = "-" )
exp = multiplyExpression() { ret = operator(ret, op, exp); }
)*
{
return ret;
}
}
Expression multiplyExpression() :
{
Expression ret, exp;
Token op;
}
{
ret = unaryExpression()
(
(op = "*" | op = "/" | op = "%" | op = "**")
exp = unaryExpression() { ret = operator(ret, op, exp); }
)*
{
return ret;
}
}
Expression unaryExpression() :
{
Expression ret, exp;
Token op = null;
}
{
[ op = unaryOperator() ]
ret = primary()
{
if (op != null)
return operator(ret, op);
else
return ret;
}
}
Expression primary() :
{
Expression ret;
Identifier ident;
boolean isFunc = false;
}
{
(
ret = number()
| ident = complexIdentifier() [ functionArgs() {isFunc = true; }]
{
if (isFunc) {
ret = functionReference(ident);
} else {
ret = variableReference(ident);
}
}
| < SYSTEM_IDENT > (<SYSTEM_IDENT >)* [ LOOKAHEAD(2) functionArgs()]
{
ret = new Expression();
}
| ret = concatenation()
| "(" ret = minTypMaxExpresstion() ")"
)
{
if (ret == null)
return new Expression();
else
return ret;
}
}
Identifier complexIdentifier() :
{
Identifier ident, concat;
}
{
ident = identifier() bitOrAry(ident)
(
"." concat = identifier() bitOrAry(concat)
{
ident.endLine = concat.endLine;
ident.endColumn = concat.endColumn;
ident.image += "." + concat.image;
ident.setWidth(concat.getWidth());
ident.setDimension(concat.getDimension());
}
)*
{
return ident;
}
}
Expression minTypMaxExpresstion() :
{
Expression exp;
}
{
exp = expression()
[
":" expression()
":" expression()
]
{
return exp;
}
}
void bitOrAry(Identifier ident) :
{
int width = 0;
int dim = 0;
Expression msb, lsb;
Token token;
}
{
(
"[" msb = expression() { width = 1; dim++; }
[
( token = ":" | token = "+:" | token = "-:" ) lsb = expression()
{
if (token.image.equals(":")) {
if (msb.isValid() && lsb.isValid())
width = msb.intValue() - lsb.intValue() + 1;
else
width = 0;
} else {
if (lsb.isValid())
width = lsb.intValue();
else
width = 0;
}
}
]
"]"
)*
{
ident.setWidth(width);
ident.setDimension(dim);
}
}
String bitRange() :
{
Expression msb, lsb;
}
{
[
"[" msb = expression() ":" lsb = expression() "]"
{
if (msb.isValid() && lsb.isValid())
return "[" + msb.intValue() + ":" + lsb.intValue() + "]";
else
return "";
}
]
{
return "";
}
}
Token unaryOperator() :
{}
{
( "~" | "+" | "-" | "!" | "&" | "~&" | "|" | "~|" | "^" | "~^" | "^~" )
{
return token;
}
}
Expression concatenation() :
{
int width;
int value;
boolean valid;
boolean assignable;
Expression exp;
Expression refs = new Expression();
}
{
"{" exp = expression()
{
width = exp.getWidth();
value = exp.intValue();
valid = exp.isValid();
assignable = exp.isAssignable();
refs.addReference(exp);
}
[
( "," exp = expression()
{
if (width == 0 || exp.getWidth() == 0)
width = 0;
else
width += exp.getWidth();
value = (value << width) | exp.intValue();
valid = valid && exp.isValid();
assignable = assignable && exp.isAssignable();
refs.addReference(exp);
}
)+
| "{" exp = expression() "}"
{
width = valid ? value : 0;
value = exp.intValue();
valid = exp.isValid();
assignable = exp.isAssignable();
refs = exp;
}
]
"}"
{
Expression ret = new Expression(width);
if (valid)
ret.setValue(value);
ret.setAssignable(assignable);
ret.addReference(refs);
return ret;
}
}
void functionArgs():
{}
{
"(" expression() ( "," expression() )* ")"
}
Expression number() :
{
Expression ret = new Expression();
}
{
(
< INTEGER_LITERAL > { ret.parseIntegerLiteral(token.image); }
| < REAL_LITERAL > { ret.parseRealLiteral(token.image); }
| < STRING_LITERAL > { ret.parseStringLiteral(token.image); }
)
{
return ret;
}
}
JAVACODE
void unexpectedEof(Token token)
{
ParseException ex = new ParseException("unexpected EOF");
ex.currentToken = token;
throw ex;
}
JAVACODE
Token skipTo(int skip)
{
Token current = token;
Token token ;
StringBuffer image = new StringBuffer();
for(;;)
{
token = getToken(1);
if (token.kind == EOF)
unexpectedEof(current);
if (token.kind == skip)
{
getNextToken();
break ;
}
image.append(token.image);
getNextToken();
}
token.image = image.toString();
return token ;
}
/**
*
* VHDL-93, VHDL-AMS grammar for JavaCC
* (c) 1997 Christoph Grimm
*
* EMail: grimm@ti.informatik.uni-frankfurt.de
* Address:
* Christoph Grimm
* J. W. Goethe-University Frankfurt
* Robert-Mayer-Strasse 11-15
* 60054 Frankfurt
* Germany
*
*
* By using this file, I agree with the following:
* -----------------------------------------------
*
* 1. This grammar is free for evaluation purposes.
*
* 2. You may use and modify it, but when distributing is, you must also
* include the original files and copyright notes from me.
*
* 3. For commercial use of derived works contact me.
*
* 4. The grammar is NOT optimized for speed. The aim is to keep the grammar
* similar to the original productions in the LRM.
*
* 5. Don't complain about errors - report them, maybe with fixes to me.
*
*/
options
{
// DEBUG_PARSER = true;
// CHOICE_AMBIGUITY_CHECK=3;
IGNORE_CASE=false;
NODE_SCOPE_HOOK=true;
MULTI=true;
}
/**
* The parser is instanciated in the file vhdl.java
*/
PARSER_BEGIN(VhdlParserCore)
package com.elphel.vdt.veditor.parser.vhdl;
@SuppressWarnings("all")
public class VhdlParserCore
{
/**
* Called, whenever a new node in jjtree is generated.
* - store first token of the production.
* - check, if production is supported in subsets that are to be
* checked.
*/
void jjtreeOpenNodeScope(Node n)
{
((SimpleNode) n).setFirstToken(getToken(1));
((SimpleNode) n).setParser(this);
}
/**
* Called, whenever a node in jjtree is closed.
*/
void jjtreeCloseNodeScope(Node n)
{
((SimpleNode) n).setLastToken(getToken(0));
}
public ErrorHandler getErrorHandler(){
return errs;
}
public SymbolTable getSymbolTable(){
return m_SymbolTable;
}
public void setSymbolTable(SymbolTable symbolTable){
m_SymbolTable=symbolTable;
}
ErrorHandler errs = new ErrorHandler(this);
SymbolTable m_SymbolTable=null;
}
PARSER_END(VhdlParserCore)
SKIP :
{
" "
| "\n"
| "\r"
| "\t"
| "\f"
}
SPECIAL_TOKEN :
{
<COMMENT: "--" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
}
/**
* Section 13: Lexical elements
* with extensions from IEEE 1076.1
*/
TOKEN [IGNORE_CASE] :
{
<ABS: "abs">
| <ACCESS: "access">
| <ACROSS: "across">
| <AFTER: "after">
| <ALIAS: "alias">
| <ALL: "all">
| <AND: "and">
| <ARCHITECTURE: "architecture">
| <ARRAY: "array">
| <ASSERT: "assert">
| <ATTRIBUTE: "attribute">
| <BEGIN: "begin">
| <BLOCK: "block">
| <BODY: "body">
| <BREAK: "break">
| <BUFFER: "buffer">
| <BUS: "bus">
| <CASE: "case">
| <COMPONENT: "component">
| <CONFIGURATION: "configuration">
| <CONSTANT: "constant">
| <DISCONNECT: "disconnect">
| <DOWNTO: "downto">
| <ELSE: "else">
| <ELSIF: "elsif">
| <END: "end">
| <ENTITY: "entity">
| <EXIT: "exit">
| <FILE: "file">
| <FOR: "for">
| <FUNCTION: "function">
| <GENERATE: "generate">
| <GENERIC: "generic">
| <GROUP: "group">
| <GUARDED: "guarded">
| <IF: "if">
| <IMPURE: "impure">
| <IN: "in">
| <INERTIAL: "inertial">
| <INOUT: "inout">
| <IS: "is">
| <LABEL: "label">
| <LIBRARY: "library">
| <LINKAGE: "linkage">
| <LITERAL: "literal">
| <LOOP: "loop">
| <MAP: "map">
| <MOD: "mod">
| <NAND: "nand">
| <NATURE: "nature">
| <NEW: "new">
| <NEXT: "next">
| <NOISE: "noise">
| <NOR: "nor">
| <NOT: "not">
| <NULL: "null">
| <OF: "of">
| <ON: "on">
| <OPEN: "open">
| <OR: "or">
| <OTHERS: "others">
| <OUT: "out">
| <PACKAGE: "package">
| <PORT: "port">
| <POSTPONED: "postponed">
| <PROCEDURAL: "procedural">
| <PROCEDURE: "procedure">
| <PROCESS: "process">
| <PROTECTED: "protected">
| <PURE: "pure">
| <QUANTITY: "quantity">
| <RANGE: "range">
| <RECORD: "record">
| <REGISTER: "register">
| <REJECT: "reject">
| <REM: "rem">
| <REPORT: "report">
| <RETURN: "return">
| <ROL: "rol">
| <ROR: "ror">
| <SELECT: "select">
| <SEVERITY: "severity">
| <SIGNAL: "signal">
| <SHARED: "shared">
| <SLA: "sla">
| <SLL: "sll">
| <SPECTRUM: "spectrum">
| <SRA: "sra">
| <SRL: "srl">
| <SUBNATURE: "subnature">
| <SUBTYPE: "subtype">
| <TERMINAL: "terminal">
| <THEN: "then">
| <THROUGH: "through">
| <TO: "to">
| <TOLERANCE: "tolerance">
| <TRANSPORT: "transport">
| <TYPE: "type">
| <UNAFFECTED: "unaffected">
| <UNITS: "units">
| <UNTIL: "until">
| <USE: "use">
| <VARIABLE: "variable">
| <WAIT: "wait">
| <WHEN: "when">
| <WHILE: "while">
| <WITH: "with">
| <XNOR: "xnor">
| <XOR: "xor">
}
TOKEN :
{
<#upper_case_letter: ["A"-"Z"]>
| <#lower_case_letter: ["a"-"z"]>
| <#digit: ["0"-"9"]>
| <#extended_digit: ["0"-"9","A"-"F","a"-"f"]>
| <#special_character: ["#","&","'","(",")","*","+",",","-",
".","/",":",";","<","=",">","[","]",
"_","|"]>
| <#other_special_character: ["!","$","%","@","?","^","`","{","}","~",
"\\"]>
| <#format_effector: ["\n","\t"]>
| <#base_specifier: ["B","O","X","b","o","x"]>
| <#underline: "_">
| <#letter: ["a"-"z","A"-"Z"]>
| <#letter_or_digit: ["a"-"z","A"-"Z","0"-"9"]>
| <#integer: <digit> (("_")? <digit>)*>
| <#base: <integer>>
| <#based_integer: (("_")? <extended_digit>)*>
| <based_literal: <base> "#" <based_integer> ("." <based_integer>)? "#" (<exponent>)?>
| <#basic_character: (<basic_graphic_character>|<format_effector>)>
| <#basic_graphic_character: (["A"-"Z"]|<digit>|<special_character>|" ")>
| <basic_identifier: <letter> ( ("_")? <letter_or_digit> )*>
| <bit_string_literal: <base_specifier> "\"" <bit_value> "\"">
| <#bit_value: <extended_digit> ( ("_")? <extended_digit>)*>
| <character_literal: "'" (<graphic_character>|"\"") "'">
| <decimal_literal: <integer> ( "." <integer>)? ( <exponent> )?>
| <#exponent: ("E" ("+")? <integer>) | ("E" "-" <integer>)>
| <extended_identifier: "\\" <graphic_character> ( <graphic_character> )* "\\">
| <#graphic_character: (<basic_graphic_character>
| <lower_case_letter>
| <other_special_character>)>
| <string_literal: "\"" (<graphic_character>|"\"\"")* "\"">
| <EXP: "**">
| <MUL: "*">
| <DIV: "/">
| <ADD: "+">
| <SUB: "-">
| <CONCAT: "&">
| <EQ: "=">
| <NEQ: "/=">
| <GE: ">=">
| <LE: "<=">
| <GT: ">">
| <LO: "<">
| <SEMICOLON: ";">
| <COLON: ":">
| <ASSIGN: ":=">
| <RARROW: "=>">
}
void abstract_literal() #void :
{}
{
<decimal_literal>
| <based_literal>
}
void access_type_definition() #void :
{}
{
<ACCESS> subtype_indication()
}
void actual_designator() #void :
{}
{
LOOKAHEAD(expression())
expression()
| LOOKAHEAD(signal_name())
signal_name()
| LOOKAHEAD(variable_name())
variable_name()
| LOOKAHEAD(file_name())
file_name()
| <OPEN>
// 1076.1 extensions:
| LOOKAHEAD(terminal_name())
terminal_name()
| quantity_name()
}
void actual_parameter_part() #void :
{}
{
parameter_association_list()
}
void actual_part() :
{}
{
LOOKAHEAD( function_name() "(" actual_designator() ")")
function_name() "(" actual_designator() ")"
| LOOKAHEAD( type_mark() "(" actual_designator() ")")
type_mark() "(" actual_designator() ")"
| actual_designator()
}
int adding_operator() #void :
{}
{
<ADD> { return ADD; }
| <SUB> { return SUB; }
| <CONCAT> { return CONCAT; }
}
void aggregate() :
{}
{
"(" element_association() ("," element_association())* ")"
}
void alias_declaration() :
{}
{
<ALIAS> alias_designator()
[ ":" subtype_indication() ] <IS> name() signature() ";"
}
void alias_designator() :
{}
{
identifier()
| <character_literal>
| operator_symbol()
}
void allocator() :
{}
{
<NEW>
(
LOOKAHEAD( type_mark() "'")
qualified_expression()
| subtype_indication()
)
}
void architecture_body() :
{}
{
<ARCHITECTURE> identifier() <OF> entity_name() <IS> { jjtThis.newBlock(); }
architecture_declarative_part()
<BEGIN>
architecture_statement_part()
<END> [ <ARCHITECTURE> ] [ architecture_simple_name() ] ";"
{
jjtThis.endBlock();
jjtThis.Check();
}
}
void architecture_declarative_part() :
{}
{
( block_declarative_item() )*
}
void architecture_statement_part() :
{}
{
( architecture_statement() )*
}
/**
* This rule also contains the concurrent statements.
*/
void architecture_statement() #void :
{}
{
//
// lookahead would really be annoying here. Therefore I have
// moved the concurrent statement into this rule.
// concurrent_statements:
//
try {
LOOKAHEAD([block_label() ":"] <BLOCK>)
block_statement()
| LOOKAHEAD([process_label() ":"] [<POSTPONED>] <PROCESS>)
process_statement()
| LOOKAHEAD([label() ":"] [<POSTPONED>] procedure_call() ";")
concurrent_procedure_call_statement()
| LOOKAHEAD([label() ":"] [<POSTPONED>] <ASSERT>)
concurrent_assertion_statement()
| LOOKAHEAD([label() ":"] [<POSTPONED>] conditional_signal_assignment()|
[label() ":"] [<POSTPONED>] selected_signal_assignment())
concurrent_signal_assignment_statement()
| LOOKAHEAD(instantiation_label() ":" instantiated_unit() )
component_instantiation_statement()
| LOOKAHEAD(generate_statement())
generate_statement()
/** 1076.1 extensions: */
| LOOKAHEAD(concurrent_break_statement())
concurrent_break_statement()
| simultaneous_statement()
}
/** Error handling: Skip until next semicolon */
catch(ParseException e)
{
error_skipto(SEMICOLON, "syntax error in statement");
}
}
/**
* 1076.1 extension:
*/
void array_nature_definition() #void :
{}
{
LOOKAHEAD(<ARRAY> "(" index_subtype_definition() )
unconstrained_nature_definition()
| constrained_nature_definition()
}
/**
* 1076.1 extension:
*/
void unconstrained_nature_definition() :
{}
{
<ARRAY> "(" index_subtype_definition() ("," index_subtype_definition())* ")"
<OF> subnature_indication()
}
/**
* 1076.1 extension:
*/
void constrained_nature_definition() :
{}
{
<ARRAY> index_constraint() <OF> subnature_indication()
}
void array_type_definition() #void:
{}
{
LOOKAHEAD(unconstrained_array_definition())
unconstrained_array_definition()
| constrained_array_definition()
}
void assertion() :
{}
{
<ASSERT> condition()
[ <REPORT> expression() ]
[ <SEVERITY> expression() ]
}
void assertion_statement() :
{}
{
[ label() ":" ] assertion() ";"
}
void association_element() :
{}
{
[ LOOKAHEAD( formal_part() "=>" ) formal_part() "=>" ]
actual_part()
}
void association_list() :
{}
{
association_element() ( "," association_element() )*
}
void attribute_declaration() :
{}
{
<ATTRIBUTE> identifier() ":" type_mark() ";"
}
void attribute_designator() #void :
{}
{
attribute_simple_name()
}
void attribute_name() :
{}
{
prefix() signature() "'" attribute_designator() [ "(" expression() ("," expression())* ")" ]
}
void attribute_specification() :
{}
{
<ATTRIBUTE> attribute_designator() <OF>
entity_specification() <IS> expression() ";"
}
void base_unit_declaration() #void :
{}
{
identifier() ";"
}
void binding_indication() :
{}
{
[ <USE> entity_aspect() ]
[ generic_map_aspect() ]
[ port_map_aspect() ]
}
void block_configuration() :
{}
{
<FOR> block_specification()
( use_clause() )*
( configuration_item() )*
<END> <FOR> ";"
}
void block_declarative_item() #void :
{}
{
try {
LOOKAHEAD(subprogram_declaration())
subprogram_declaration()
| subprogram_body()
| type_declaration()
| subtype_declaration()
| constant_declaration()
| signal_declaration()
| shared_variable_declaration()
| file_declaration()
| alias_declaration()
| component_declaration()
| LOOKAHEAD(attribute_declaration())
attribute_declaration()
| attribute_specification()
| configuration_specification()
| disconnection_specification()
| use_clause()
| LOOKAHEAD(<GROUP> identifier() <IS>)
group_template_declaration()
| group_declaration()
/** 1076.1 - Extensions: */
| nature_declaration()
| subnature_declaration()
| quantity_declaration()
| terminal_declaration()
}
// Error handling: skip until next semicolon
catch (ParseException e)
{
error_skipto(SEMICOLON, "syntax error in declarative item");
}
}
void block_declarative_part() :
{}
{
( block_declarative_item() )*
}
void block_header() :
{}
{
[ generic_clause() [ generic_map_aspect() ";" ] ]
[ port_clause() [ port_map_aspect() ";" ] ]
}
void block_specification() :
{}
{
LOOKAHEAD(architecture_name())
architecture_name()
| LOOKAHEAD(block_statement_label())
block_statement_label()
| LOOKAHEAD(generate_statement_label())
generate_statement_label() [ "(" index_specification() ")" ]
}
void block_statement() :
{}
{
block_label() ":"
<BLOCK> [ "(" guard_expression() ")" ] [ <IS> ]
block_header()
block_declarative_part()
<BEGIN>
block_statement_part()
<END> <BLOCK> [ block_label() ] ";"
}
void block_statement_part() :
{}
{
(architecture_statement() )*
}
/**
* Section 8.14: Break statement
* 1076.1 extension:
*/
void break_statement() :
{}
{
[label() ":"] <BREAK> [break_list()] [<WHEN> condition() ] ";"
}
/**
* 1076.1 extension:
*/
void break_list() :
{}
{
break_element() ("," break_element() )*
}
/**
* 1076.1 extension:
*/
void break_element() :
{}
{
[selector_clause() ] quantity_name() "=>" expression()
}
/**
* 1076.1 extension:
*/
void selector_clause() #void :
{}
{
<FOR> quantity_name() <USE>
}
void case_statement() :
{}
{
[ case_label() ":" ]
<CASE> expression() <IS>
case_statement_alternative()
( case_statement_alternative() )*
<END> <CASE> [ case_label() ] ";"
}
void case_statement_alternative() :
{}
{
<WHEN> choices() "=>"
sequence_of_statements()
}
void choice() :
{}
{
/** Dirty Solution */
LOOKAHEAD( discrete_range() ("=>" | "|" | ";" | ",") )
discrete_range()
| LOOKAHEAD( simple_expression() ("=>" | "|" | ";" | ",") )
simple_expression()
| element_simple_name()
| <OTHERS>
}
void choices() :
{}
{
choice() ( "|" choice() )*
}
void component_configuration() :
{}
{
<FOR> component_specification()
[ binding_indication() ";" ]
[ block_configuration() ]
<END> <FOR> ";"
}
void component_declaration() :
{}
{
<COMPONENT> identifier() [ <IS> ]
[ local_generic_clause() ]
[ local_port_clause() ]
<END> <COMPONENT> [ component_simple_name() ] ";"
}
void component_instantiation_statement() :
{}
{
instantiation_label() ":"
instantiated_unit()
[ generic_map_aspect() ]
[ port_map_aspect() ] ";"
}
// 1076.1 - extension:
void composite_nature_definition() #void :
{}
{
array_nature_definition()
| record_nature_definition()
}
void component_specification() :
{}
{
instantiation_list() ":" component_name()
}
void composite_type_definition() :
{}
{
array_type_definition()
| record_type_definition()
}
void concurrent_assertion_statement() :
{}
{
[ label() ":" ] [ <POSTPONED> ] assertion() ";"
}
void concurrent_procedure_call_statement() :
{}
{
[ LOOKAHEAD( label() ":") label() ":" ]
[ <POSTPONED> ] procedure_call() ";"
}
void concurrent_signal_assignment_statement() :
{}
{
[ LOOKAHEAD( label() ":") label() ":" ]
[ <POSTPONED> ]
( LOOKAHEAD( target() "<=" options_() conditional_waveforms() ";")
conditional_signal_assignment()
| selected_signal_assignment() )
}
void condition() #void :
{}
{
boolean_expression()
}
void condition_clause() #void :
{}
{
<UNTIL> condition()
}
void conditional_signal_assignment() :
{}
{
target() "<=" options_() conditional_waveforms() ";"
}
void conditional_waveforms() :
{}
{
//( waveform() <WHEN> condition() <ELSE> )*
//waveform() [ <WHEN> condition() ]
waveform()
( LOOKAHEAD( <WHEN> condition() <ELSE>)
<WHEN> condition() <ELSE> waveform() )*
[ <WHEN> condition() ]
}
void configuration_declaration() :
{}
{
<CONFIGURATION> identifier() <OF> entity_name() <IS>
configuration_declarative_part()
block_configuration()
<END> [ <CONFIGURATION> ] [ configuration_simple_name() ] ";"
}
void configuration_declarative_item() #void :
{}
{
try {
use_clause()
| attribute_specification()
| group_declaration()
}
catch(ParseException e)
{
error_skipto(SEMICOLON, "syntax error in declarative item");
}
}
void configuration_declarative_part() :
{}
{
( configuration_declarative_item() )*
}
void configuration_item() #void :
{}
{
LOOKAHEAD(block_configuration())
block_configuration()
| component_configuration()
}
void configuration_specification() :
{}
{
<FOR> component_specification() binding_indication() ";"
}
void constant_declaration() :
{}
{
<CONSTANT> identifier_list() ":" subtype_indication()
[ ":=" expression() ] ";"
}
void constrained_array_definition() :
{}
{
<ARRAY> index_constraint() <OF> element_subtype_indication()
}
void constraint() #void :
{}
{
range_constraint()
| index_constraint()
}
void context_clause() :
{}
{
( context_item() )*
}
void context_item() #void :
{}
{
library_clause()
| use_clause()
}
/**
* Section 4:
* Declarations
*/
/**
* 1076.1 extension:
*/
void terminal_declaration() :
{}
{
<TERMINAL> identifier_list() ":" subnature_indication() ";"
}
void terminal_aspect() :
{}
{
plus_terminal_name() [ <TO> minus_terminal_name() ]
}
void delay_mechanism() :
{}
{
<TRANSPORT>
| [ <REJECT> time_expression() ] <INERTIAL>
}
ASTdesign_file design_file() :
{}
{
( design_unit() )*
{ return jjtThis; }
}
void design_unit() :
{}
{
context_clause() library_unit()
}
void designator() #void :
{}
{
identifier()
| operator_symbol()
}
void direction() :
{}
{
<TO> | <DOWNTO>
}
void disconnection_specification() :
{}
{
<DISCONNECT> guarded_signal_specification() <AFTER>
time_expression() ";"
}
void discrete_range() #void :
{}
{
LOOKAHEAD(simple_expression() direction() )
range()
| LOOKAHEAD( discrete_subtype_indication() )
discrete_subtype_indication()
| range()
}
void element_association() #void :
{}
{
[ LOOKAHEAD(choices() "=>") choices() "=>" ]
expression()
}
void element_declaration() :
{}
{
identifier_list() ":" element_subtype_definition() ";"
}
void element_subtype_definition() #void :
{}
{
subtype_indication()
}
void entity_aspect() :
{}
{
<ENTITY> entity_name()
[ LOOKAHEAD("(" architecture_identifier() ")")
"(" architecture_identifier() ")" ]
| <CONFIGURATION> configuration_name()
| <OPEN>
}
/**
* Section 5: Specifications
*/
int entity_class() #void :
{}
{
<ENTITY> { return ENTITY; }
| <ARCHITECTURE> { return ARCHITECTURE; }
| <CONFIGURATION> { return CONFIGURATION; }
| <PROCEDURE> { return PROCEDURE; }
| <FUNCTION> { return FUNCTION; }
| <PACKAGE> { return PACKAGE; }
| <TYPE> { return TYPE; }
| <SUBTYPE> { return SUBTYPE; }
| <CONSTANT> { return CONSTANT; }
| <SIGNAL> { return SIGNAL; }
| <VARIABLE> { return VARIABLE; }
| <COMPONENT> { return COMPONENT; }
| <LABEL> { return LABEL; }
| <LITERAL> { return LITERAL; }
| <UNITS> { return UNITS; }
| <GROUP> { return GROUP; }
| <FILE> { return FILE; }
/** 1076.1 extensions: */
| <SUBNATURE> { return SUBNATURE; }
| <NATURE> { return NATURE; }
| <TERMINAL> { return TERMINAL; }
}
void entity_class_entry() :
{}
{
entity_class() [ "<>" ]
}
void entity_class_entry_list() :
{}
{
entity_class_entry() ( "," entity_class_entry() )*
}
void entity_declaration() :
{}
{
<ENTITY> identifier() <IS> { jjtThis.newBlock(); }
entity_header()
entity_declarative_part()
[ <BEGIN>
entity_statement_part() ]
<END> [ <ENTITY> ] [ entity_simple_name() ] ";"
{
jjtThis.Check();
jjtThis.endBlock();
}
}
void entity_declarative_item() #void :
{}
{
try {
LOOKAHEAD(subprogram_declaration())
subprogram_declaration()
| subprogram_body()
| type_declaration()
| subtype_declaration()
| constant_declaration()
| signal_declaration()
| shared_variable_declaration()
| file_declaration()
| alias_declaration()
| LOOKAHEAD(attribute_declaration())
attribute_declaration()
| attribute_specification()
| disconnection_specification()
| use_clause()
| LOOKAHEAD(<GROUP> identifier() <IS>)
group_template_declaration()
| group_declaration()
// 1076.1 - Extensions:
| nature_declaration()
| subnature_declaration()
| terminal_declaration()
}
catch( ParseException e )
{
error_skipto(SEMICOLON, "syntax error in declarative item");
}
}
/**
* 4.8: Nature Declaration
* 1076.1 extension
*/
void nature_declaration() :
{}
{
<NATURE> identifier() <IS> nature_definition() ";"
}
/**
* 1076.1 extension
*/
void nature_definition() #void :
{}
{
scalar_nature_definition()
| composite_nature_definition()
}
void subnature_declaration() :
{}
{
<SUBNATURE> identifier() <IS> subnature_indication() ";"
}
void subnature_indication() :
{}
{
nature_mark() [index_constraint() ]
[ <TOLERANCE> string_expression() <ACROSS> string_expression() <THROUGH>]
}
void nature_mark() #void :
{}
{
LOOKAHEAD(nature_name())
nature_name()
| LOOKAHEAD(subnature_name())
subnature_name()
}
void entity_declarative_part() :
{}
{
( entity_declarative_item() )*
}
void entity_designator() :
{}
{
entity_tag() signature()
}
void entity_header() :
{}
{
[ formal_generic_clause() ]
[ formal_port_clause() ]
}
void entity_name_list() :
{}
{
entity_designator() ( "," entity_designator() )*
| <OTHERS>
| <ALL>
}
void entity_specification() :
{}
{
entity_name_list() ":" entity_class()
}
void entity_statement() #void :
{}
{ LOOKAHEAD( concurrent_assertion_statement() )
concurrent_assertion_statement()
| LOOKAHEAD([process_label() ":"] [<POSTPONED>] <PROCESS>)
passive_process_statement()
| passive_concurrent_procedure_call_statement()
}
void entity_statement_part() :
{}
{
( entity_statement() )*
}
void entity_tag() :
{}
{
simple_name()
| <character_literal>
| operator_symbol()
}
void enumeration_literal() :
{}
{
<character_literal>
| identifier()
}
void enumeration_type_definition() :
{}
{
"(" enumeration_literal() ( "," enumeration_literal())* ")"
}
void exit_statement() :
{}
{
[ label() ":" ] <EXIT> [ loop_label() ]
[ <WHEN> condition() ] ";"
}
void expression() #void :
{ int op; }
{
/** relation() (
* ( <AND> relation() )* |
* ( <OR> relation() )* |
* ( <XOR> relation() )* |
* [ <NAND> relation() ] |
* [ <NOR> relation() ] |
* ( <XNOR> relation() )*
* )
*/
relation()
( LOOKAHEAD(1) op=logical_operator() relation()
#relation(2) )*
}
void factor() #void :
{}
{
<ABS> primary()
| <NOT> primary()
| primary() [ LOOKAHEAD("**" primary() ) <EXP> primary() #factor(2) ]
}
void file_declaration() :
{}
{
<FILE> identifier_list() ":" subtype_indication()
[ file_open_information() ] ";"
}
void file_logical_name() #void :
{}
{
string_expression()
}
void file_open_information() :
{}
{
<OPEN> file_open_kind_expression() <IS> file_logical_name()
| <IS> [ <IN> | <OUT> ] file_logical_name()
}
void file_type_definition() #void :
{}
{
<FILE> <OF> type_mark()
}
void floating_type_definition() #void :
{}
{
range_constraint()
}
void formal_designator() #void :
{}
{
LOOKAHEAD( generic_name() )
generic_name()
| LOOKAHEAD( port_name() )
port_name()
| parameter_name()
}
void formal_parameter_list() :
{}
{
parameter_interface_list()
}
void formal_part() #void :
{}
{
LOOKAHEAD( function_name() "(" formal_designator() ")")
function_name() "(" formal_designator() ")"
| LOOKAHEAD( type_mark() "(" formal_designator() ")")
type_mark() "(" formal_designator() ")"
| formal_designator()
}
void full_type_declaration() :
{}
{
<TYPE> identifier() <IS> type_definition() ";"
}
void function_call() :
{}
{
function_name()
[ LOOKAHEAD( "(" actual_parameter_part() ")" ) "(" actual_parameter_part() ")" ]
}
/**
* Section 9.7
*/
void generate_statement() :
{}
{
generate_label() ":"
generation_scheme() <GENERATE>
[ LOOKAHEAD(2) ( block_declarative_item() )* <BEGIN> ]
( architecture_statement() )*
<END> <GENERATE> [ generate_label() ] ";"
}
/** 1076.1 extension: */
void concurrent_break_statement() :
{}
{
[label() ":"] <BREAK> [break_list()] [sensitivity_clause() ] [ <WHEN> condition()] ";"
}
void generation_scheme() :
{}
{
<FOR> generate_parameter_specification()
| <IF> condition()
}
void generic_clause() :
{}
{
<GENERIC> "(" generic_list() ")" ";"
}
void generic_list() #void :
{}
{
generic_interface_list()
}
void generic_map_aspect() #void :
{}
{
<GENERIC> <MAP> "(" generic_association_list() ")"
}
void group_constituent() :
{}
{
name()
| <character_literal>
}
void group_constituent_list() :
{}
{
group_constituent() ( "," group_constituent() )*
}
void group_template_declaration() :
{}
{
<GROUP> identifier() <IS> "(" entity_class_entry_list() ")" ";"
}
void group_declaration() :
{}
{
<GROUP> identifier() ":" group_template_name()
"(" group_constituent_list() ")" ";"
}
void guarded_signal_specification() :
{}
{
guarded_signal_list() ":" type_mark()
}
void identifier() :
{ Token t; }
{
t=<basic_identifier> { jjtThis.name = t.image; }
| t=<extended_identifier> { jjtThis.name = t.image; }
}
void identifier_list() :
{}
{
identifier() ( "," identifier() )*
}
void if_statement() :
{}
{
[ if_label() ":" ]
<IF> condition() <THEN>
sequence_of_statements()
( <ELSIF> condition() <THEN>
sequence_of_statements() )*
[ <ELSE>
sequence_of_statements() ]
<END> <IF> [ if_label() ] ";"
}
void incomplete_type_declaration() :
{}
{
<TYPE> identifier() ";"
}
void index_constraint() :
{}
{
"(" discrete_range() ( "," discrete_range() )* ")"
}
void index_specification() :
{}
{
LOOKAHEAD( discrete_range() )
discrete_range()
| static_expression()
}
void index_subtype_definition() :
{}
{
type_mark() <RANGE> "<>"
}
void indexed_name() :
{}
{
prefix() "(" expression() ( "," expression() )* ")"
}
void instantiated_unit() :
{}
{
[ <COMPONENT> ] component_name()
| <ENTITY> entity_name() [ "(" architecture_identifier() ")" ]
| <CONFIGURATION> configuration_name()
}
void instantiation_list() :
{}
{
instantiation_label() ( "," instantiation_label() )*
| <OTHERS>
| <ALL>
}
void integer_type_definition() #void :
{}
{
range_constraint()
}
void interface_constant_declaration() :
{}
{
[ <CONSTANT> ] identifier_list() ":" [ <IN> ]
subtype_indication() [ ":=" static_expression() ]
}
/**
* Section 4.3.2:
*/
void interface_declaration() #void :
{}
{
LOOKAHEAD(interface_constant_declaration() )
interface_constant_declaration()
| LOOKAHEAD(interface_signal_declaration() )
interface_signal_declaration()
| LOOKAHEAD(interface_variable_declaration() )
interface_variable_declaration()
| LOOKAHEAD(interface_file_declaration() )
interface_file_declaration()
/** 1076.1 extensions: */
| interface_terminal_declaration()
| interface_quantity_declaration()
}
/**
* 1076.1 extension:
*/
void interface_terminal_declaration() :
{}
{
<TERMINAL> identifier_list() ":" subnature_indication()
}
/**
* 1076.1 extension:
*/
void interface_quantity_declaration() :
{}
{
<QUANTITY> identifier_list() ":"
[ <IN> | <OUT> ] subtype_indication() [ ":=" static_expression() ]
}
void interface_element() #void :
{}
{
interface_declaration()
}
void interface_file_declaration() :
{}
{
<FILE> identifier_list() ":" subtype_indication()
}
void interface_list() :
{}
{
interface_element() ( ";" interface_element() )*
}
void interface_signal_declaration() :
{}
{
[<SIGNAL>] identifier_list() ":"
[ mode() ] subtype_indication() [ <BUS> ] [ ":=" static_expression() ]
}
void interface_variable_declaration() :
{}
{
[<VARIABLE>] identifier_list() ":"
[ mode() ] subtype_indication() [ ":=" static_expression() ]
}
void iteration_scheme() :
{}
{
<WHILE> condition()
| <FOR> loop_parameter_specification()
}
void label() #void :
{}
{
identifier()
}
void library_clause() #void :
{}
{
<LIBRARY> logical_name_list() ";"
}
void library_unit() #void :
{}
{ LOOKAHEAD(<ENTITY> | <CONFIGURATION> | <PACKAGE> identifier() )
primary_unit()
| secondary_unit()
}
void literal() :
{}
{
LOOKAHEAD( numeric_literal() )
numeric_literal()
| enumeration_literal()
| <string_literal>
| <bit_string_literal>
| <NULL>
}
void logical_name() #void :
{}
{
identifier()
}
void logical_name_list() :
{}
{
logical_name() ( "," logical_name() )*
}
int logical_operator() #void :
{}
{
<AND> { return AND; }
| <OR> { return OR; }
| <NAND> { return NAND; }
| <NOR> { return NOR; }
| <XOR> { return XOR; }
| <XNOR> { return XNOR; }
}
void loop_statement() :
{}
{
[ loop_label() ":" ]
[ iteration_scheme() ] <LOOP>
sequence_of_statements()
<END> <LOOP> [ loop_label() ] ";"
}
int miscellaneous_operator() #void :
{}
{
<EXP> { return EXP; }
| <ABS> { return ABS; }
| <NOT> { return NOT; }
}
void mode() :
{}
{
<IN>
| <OUT>
| <INOUT>
| <BUFFER>
| <LINKAGE>
}
int multiplying_operator() #void :
{}
{
"*" { return MUL; }
| "/" { return DIV; }
| <MOD> { return MOD; }
| <REM> { return REM; }
}
void name() :
{}
{
/** simple_name()
* | operator_symbol()
* | selected_name()
* | indexed_name()
* | slice_name()
* | attribute_name()
*
* Kann ohne Linksrekursion wie folgt geschrieben werden:
*/
( simple_name() | operator_symbol() )
[ LOOKAHEAD(name_extension()) name_extension() ]
}
void name_extension() #void :
{}
{
(
LOOKAHEAD( signature() "'" )
signature() "'" attribute_designator()
[ LOOKAHEAD( "(" expression() ")") "(" expression() ")"]
| "." suffix()
| LOOKAHEAD( "(" discrete_range() ")" )
"(" discrete_range() ")"
| LOOKAHEAD( "(" expression() ("," expression() )* ")" )
"(" expression() ("," expression() )* ")"
/**
* The following production is already in sign. "'" ... ,
* since signature can be empty!
* | "'" attribute_designator() [ "(" expression() ")"]
*/
)
[ LOOKAHEAD(name_extension() ) name_extension() ]
}
/**
* 1076.1 extension:
*/
void nature_element_declaration() :
{}
{
identifier_list() ":" element_subnature_definition()
}
/**
* 1076.1 extension:
*/
void element_subnature_definition() #void :
{}
{
subnature_indication()
}
void next_statement() :
{}
{
[ label() ":" ] <NEXT> [ loop_label() ] [ <WHEN> condition() ] ";"
}
void null_statement() :
{}
{
[ label() ":" ] <NULL> ";"
}
void numeric_literal() #void :
{}
{
LOOKAHEAD(physical_literal())
physical_literal()
| abstract_literal()
}
void object_declaration() #void :
{}
{
try {
constant_declaration()
| signal_declaration()
| variable_declaration()
| file_declaration()
/** 1076.1 extensions: */
| terminal_declaration()
| quantity_declaration()
}
catch( ParseException e )
{
error_skipto(SEMICOLON, "syntax error in declaration");
}
}
void operator_symbol() :
{}
{
<string_literal>
}
void options_() :
{}
{
[ <GUARDED> ] [ delay_mechanism() ]
}
void package_body() :
{}
{
<PACKAGE> <BODY> package_simple_name() <IS>
package_body_declarative_part()
<END> [ <PACKAGE> <BODY> ] [ package_simple_name() ] ";"
}
void package_body_declarative_item() #void :
{}
{
try {
LOOKAHEAD(subprogram_declaration())
subprogram_declaration()
| subprogram_body()
| type_declaration()
| subtype_declaration()
| constant_declaration()
| shared_variable_declaration()
| file_declaration()
| alias_declaration()
| use_clause()
| LOOKAHEAD(<GROUP> identifier() <IS>)
group_template_declaration()
| group_declaration()
}
catch( ParseException e )
{
error_skipto(SEMICOLON, "syntax error in declarative item");
}
}
void package_body_declarative_part() :
{}
{
( package_body_declarative_item() )*
}
void package_declaration() :
{}
{
<PACKAGE> identifier() <IS>
package_declarative_part()
<END> [ <PACKAGE> ] [ package_simple_name() ] ";"
}
void package_declarative_item() #void :
{}
{
try {
subprogram_declaration()
| type_declaration()
| subtype_declaration()
| constant_declaration()
| signal_declaration()
| shared_variable_declaration()
| file_declaration()
| alias_declaration()
| component_declaration()
| LOOKAHEAD( attribute_declaration() )
attribute_declaration()
| attribute_specification()
| disconnection_specification()
| use_clause()
| LOOKAHEAD(<GROUP> identifier() <IS>)
group_template_declaration()
| group_declaration()
// 1076.1 extensions:
| nature_declaration()
| subnature_declaration()
| terminal_declaration()
}
catch(ParseException e)
{
error_skipto(SEMICOLON, "syntax error in declaration");
}
}
void package_declarative_part() :
{}
{
( package_declarative_item() )*
}
void parameter_specification() :
{}
{
identifier() <IN> discrete_range()
}
void physical_literal() :
{}
{
[ LOOKAHEAD(abstract_literal() unit_name() )
abstract_literal() ]
unit_name()
}
void physical_type_definition() :
{}
{
range_constraint()
<UNITS>
base_unit_declaration()
( secondary_unit_declaration() )*
<END> <UNITS> [ physical_type_simple_name() ]
}
void port_clause() :
{}
{
<PORT> "(" port_list() ")" ";"
}
void port_list() #void :
{}
{
port_interface_list()
}
void port_map_aspect() :
{}
{
<PORT> <MAP> "(" port_association_list() ")"
}
void prefix() :
{}
{
LOOKAHEAD( function_call() )
function_call()
| name()
}
void primary() #void :
{}
{
LOOKAHEAD( qualified_expression() )
qualified_expression()
| LOOKAHEAD( function_call() )
function_call()
| LOOKAHEAD(name())
name()
| LOOKAHEAD(literal())
literal()
| LOOKAHEAD( aggregate() )
aggregate()
| LOOKAHEAD( "(" expression() ")")
"(" expression() ")"
| LOOKAHEAD( type_conversion() )
type_conversion()
| allocator()
}
void primary_unit() #void :
{}
{
entity_declaration()
| configuration_declaration()
| LOOKAHEAD(<PACKAGE> identifier())
package_declaration()
}
void procedure_call() :
{}
{
procedure_name() [ "(" actual_parameter_part() ")" ]
}
void procedure_call_statement() :
{}
{
[ LOOKAHEAD( label() ":") label() ":" ]
procedure_call() ";"
}
void process_declarative_item() #void :
{}
{
LOOKAHEAD(subprogram_declaration())
subprogram_declaration()
| subprogram_body()
| type_declaration()
| subtype_declaration()
| constant_declaration()
| variable_declaration()
| file_declaration()
| alias_declaration()
| LOOKAHEAD( attribute_declaration() )
attribute_declaration()
| attribute_specification()
| use_clause()
| LOOKAHEAD( <GROUP> identifier() <IS> )
group_template_declaration()
| group_declaration()
}
void process_declarative_part() :
{}
{
( process_declarative_item() )*
}
void process_statement() :
{}
{
[ process_label() ":" ]
[ <POSTPONED> ] <PROCESS> { jjtThis.newBlock(); }
[ "(" sensitivity_list() ")" ] [ <IS> ]
process_declarative_part()
<BEGIN>
process_statement_part()
<END> [ <POSTPONED> ] <PROCESS> [ process_label() ] ";"
{
jjtThis.Check();
jjtThis.endBlock();
}
}
void process_statement_part() :
{}
{
( sequential_statement() )*
}
/*
VHDL 2002: protected types:
*/
void protected_type_body() #void :
{}
{
<PROTECTED> <BODY>
protected_type_body_declarative_part()
<END> <PROTECTED> <BODY> [ simple_name() ]
}
void protected_type_body_declarative_item() #void :
{}
{
LOOKAHEAD(subprogram_declaration())
subprogram_declaration()
| subprogram_body()
| type_declaration()
| subtype_declaration()
| constant_declaration()
| variable_declaration()
| file_declaration()
| alias_declaration()
| LOOKAHEAD(attribute_declaration())
attribute_declaration()
| attribute_specification()
| use_clause()
| LOOKAHEAD(group_template_declaration())
group_template_declaration()
| group_declaration()
}
void protected_type_body_declarative_part() #void :
{}
{
(protected_type_body_declarative_item())+
}
void protected_type_declaration() #void :
{}
{
<PROTECTED>
protected_type_declarative_part()
<END> <PROTECTED> [ simple_name() ]
}
void protected_type_declarative_item() #void :
{}
{
subprogram_declaration()
| attribute_declaration()
| use_clause()
}
void protected_type_declarative_part() #void :
{}
{
(protected_type_declarative_item())+
}
void protected_type_definition() #void :
{}
{
LOOKAHEAD(protected_type_body()) protected_type_body()
| protected_type_declaration()
}
void qualified_expression() :
{}
{
type_mark() "'"
( LOOKAHEAD( aggregate() )
aggregate()
| "(" expression() ")"
)
}
void range() :
{}
{
LOOKAHEAD( simple_expression() direction() )
simple_expression() direction() simple_expression()
| range_attribute_name()
}
void range_constraint() #void :
{}
{
<RANGE> range()
}
void record_nature_definition() :
{}
{
<RECORD>
( nature_element_declaration() )+
<END> <RECORD> [ record_nature_simple_name() ]
}
void record_type_definition() :
{}
{
<RECORD>
( element_declaration() )+
<END> <RECORD> [ record_type_simple_name() ]
}
void relation() #void :
{ int op; }
{
shift_expression()
[ LOOKAHEAD(1)
op=relational_operator()
shift_expression()
#shift_expression(2) ]
}
int relational_operator() #void :
{}
{
<EQ> { return EQ; }
| <NEQ> { return NEQ; }
| <LO> { return LO; }
| <LE> { return LE; }
| <GT> { return GT; }
| <GE> { return GE; }
}
void report_statement() :
{}
{
[ label() ":" ] <REPORT> expression()
[ <SEVERITY> expression() ] ";"
}
void return_statement() :
{}
{
[ label() ":" ] <RETURN> [ expression() ] ";"
}
// 1076.1 - extension:
void scalar_nature_definition() :
{}
{
type_mark() <ACROSS> type_mark() <THROUGH>
}
void scalar_type_definition() #void :
{}
{
LOOKAHEAD(range_constraint() <UNITS> )
physical_type_definition()
|
LOOKAHEAD(enumeration_type_definition())
enumeration_type_definition()
/** | integer_type_definition()
* | floating_type_definition()
* integer- and floating_type_definition are both range_constraint,
* thus:
*/
|
range_constraint()
}
void secondary_unit() #void :
{}
{
LOOKAHEAD( <ARCHITECTURE> )
architecture_body()
| LOOKAHEAD( <PACKAGE> <BODY> )
package_body()
}
void secondary_unit_declaration() :
{}
{
identifier() "=" physical_literal() ";"
}
void selected_name() :
{}
{
/**
* prefix() "." suffix()
* results in left-recursion...
* the follwoing does the same (i hope ...)
*/
( simple_name() | operator_symbol() )
[ LOOKAHEAD( name_extension() ) name_extension() ]
/**
* semantic analysis has to ensure that last production
* was "." suffix()
*/
}
void selected_signal_assignment() :
{}
{
<WITH> expression() <SELECT>
target() "<=" options_() selected_waveforms() ";"
}
void selected_waveforms() :
{}
{
waveform() <WHEN> choices()
("," waveform() <WHEN> choices() )*
}
void sensitivity_clause() #void :
{}
{
<ON> sensitivity_list()
}
void sensitivity_list() :
{}
{
signal_name() ( "," signal_name() )*
}
void sequence_of_statements() :
{}
{
( sequential_statement() )*
}
void sequential_statement() #void :
{}
{
try {
(
LOOKAHEAD(3)
wait_statement()
| LOOKAHEAD(3)
assertion_statement()
| LOOKAHEAD(3)
report_statement()
| LOOKAHEAD( [ label() ":" ] target() "<=" )
signal_assignment_statement()
| LOOKAHEAD( [ label() ":" ] target() ":=" )
variable_assignment_statement()
| LOOKAHEAD(3)
procedure_call_statement()
| LOOKAHEAD(3)
if_statement()
| LOOKAHEAD(3)
case_statement()
| LOOKAHEAD(3)
loop_statement()
| LOOKAHEAD(3)
next_statement()
| LOOKAHEAD(3)
exit_statement()
| LOOKAHEAD(3)
return_statement()
| LOOKAHEAD(3)
null_statement()
/** 1076.1 extensions: */
| break_statement()
)
}
// Error handling: skip till next semicolon.
catch (ParseException e)
{
error_skipto(SEMICOLON, "syntax error in sequential statement");
}
}
void shift_expression() #void :
{ int op; }
{
simple_expression()
[ LOOKAHEAD(2) op=shift_operator()
simple_expression() #simple_expression(2) ]
}
int shift_operator() #void :
{}
{
<SLL> { return SLL; }
| <SRL> { return SRL; }
| <SLA> { return SLA; }
| <SRA> { return SRA; }
| <ROL> { return ROL; }
| <ROR> { return ROR; }
}
void sign() :
{}
{
"+"
| "-"
}
void signal_assignment_statement() :
{}
{
[ LOOKAHEAD( label() ":") label() ":" ]
target() "<=" [ delay_mechanism() ] waveform() ";"
}
void signal_declaration() :
{}
{
<SIGNAL> identifier_list() ":"
subtype_indication() [ signal_kind() ] [ ":=" expression() ] ";"
}
void signal_kind() :
{}
{
<REGISTER>
| <BUS>
}
void signal_list() :
{}
{
signal_name() ( "," signal_name() )*
| <OTHERS>
| <ALL>
}
void signature() :
{}
{
[ type_mark() ( LOOKAHEAD( "," type_mark() ) "," type_mark() )* ]
[ <RETURN> type_mark() ]
}
void simple_expression() #void :
{ int op; }
{
[ sign() ] term()
( LOOKAHEAD(2) op=adding_operator() term()
#term(2) )*
}
void simple_name() #void :
{}
{
identifier()
}
void slice_name() :
{}
{
prefix() "(" discrete_range() ")"
}
void subprogram_body() :
{}
{
subprogram_specification() <IS>
subprogram_declarative_part()
<BEGIN>
subprogram_statement_part()
<END> [ subprogram_kind() ] [ designator() ] ";"
}
void subprogram_declaration() #void :
{}
{
subprogram_specification() ";"
}
void subprogram_declarative_item() #void :
{}
{
LOOKAHEAD(subprogram_declaration())
subprogram_declaration()
| subprogram_body()
| type_declaration()
| subtype_declaration()
| constant_declaration()
| variable_declaration()
| file_declaration()
| alias_declaration()
| LOOKAHEAD(attribute_declaration())
attribute_declaration()
| attribute_specification()
| use_clause()
| LOOKAHEAD( <GROUP> identifier() <IS>)
group_template_declaration()
| group_declaration()
}
void subprogram_declarative_part() :
{}
{
( subprogram_declarative_item() )*
}
int subprogram_kind() #void :
{}
{
<PROCEDURE> { return PROCEDURE; }
| <FUNCTION> { return FUNCTION; }
}
void subprogram_specification() :
{}
{
<PROCEDURE> designator() [ "(" formal_parameter_list() ")" ]
| [ <PURE> | <IMPURE> ] <FUNCTION> designator()
[ "(" formal_parameter_list() ")" ]
<RETURN> type_mark()
}
void subprogram_statement_part() :
{}
{
( sequential_statement() )*
}
void subtype_declaration() :
{}
{
<SUBTYPE> identifier() <IS> subtype_indication() ";"
}
/**
* Section 4.1:
*/
void subtype_indication() :
{}
{
/*
* enumeration resolves conflict ! After implementation of symbol tables
* this can be replaced by semantic lookahead.
*/
LOOKAHEAD(resolution_function_name() type_mark() constraint())
resolution_function_name() type_mark() constraint()
[ LOOKAHEAD(tolerance_aspect())tolerance_aspect() ]
| LOOKAHEAD( type_mark() constraint() )
type_mark() constraint()
[ LOOKAHEAD(tolerance_aspect()) tolerance_aspect() ]
| LOOKAHEAD( resolution_function_name() type_mark() )
resolution_function_name() type_mark()
[ LOOKAHEAD(tolerance_aspect())tolerance_aspect() ]
| LOOKAHEAD( type_mark() )
type_mark()
[ LOOKAHEAD(tolerance_aspect()) tolerance_aspect() ]
}
/**
* 1076.1 extension:
*/
void tolerance_aspect() #void :
{}
{
<TOLERANCE> string_expression()
}
/**
* Section 4.3.1.6: Quantity declaration
* 1076.1 extension:
*/
void quantity_declaration() #void :
{}
{
LOOKAHEAD(free_quantity_declaration() )
free_quantity_declaration()
| LOOKAHEAD(branch_quantity_declaration() )
branch_quantity_declaration()
| source_quantity_declaration()
}
/**
* 1076.1 extension:
*/
void free_quantity_declaration() :
{}
{
<QUANTITY> identifier_list() ":" subtype_indication() [":=" expression()] ";"
}
/**
* 1076.1 extension:
*/
void branch_quantity_declaration() :
{}
{
<QUANTITY> [LOOKAHEAD(across_aspect()) across_aspect()]
[LOOKAHEAD(through_aspect()) through_aspect()]
terminal_aspect() ";"
}
/**
* 1076.1 extension:
*/
void source_quantity_declaration() :
{}
{
<QUANTITY> identifier_list() ":" subtype_indication() source_aspect() ";"
}
/**
* 1076.1 extension:
*/
void across_aspect() :
{}
{
identifier_list() [ tolerance_aspect() ] [ ":=" expression() ] <ACROSS>
}
/**
* 1076.1 extension:
*/
void through_aspect() :
{}
{
identifier_list() [ tolerance_aspect() ] [ ":=" expression() ] <THROUGH>
}
/**
* 1076.1 extension:
*/
void source_aspect() :
{}
{
<SPECTRUM> magnitude_simple_expression() "," phase_simple_expression()
| <NOISE> magnitude_simple_expression()
}
void suffix() #void :
{}
{
simple_name()
| <character_literal>
| operator_symbol()
| <ALL>
}
void target() #void :
{}
{
name()
| aggregate()
}
void term() #void :
{ int op; }
{
factor() ( LOOKAHEAD(2) op = multiplying_operator() factor() #factor(2)
)*
}
void timeout_clause() #void :
{}
{
<FOR> time_or_real_expression()
}
void type_conversion() :
{}
{
type_mark() "(" expression() ")"
}
void type_declaration() #void :
{}
{
LOOKAHEAD( <TYPE> identifier() <IS> )
full_type_declaration()
| incomplete_type_declaration()
}
void type_definition() #void :
{}
{
scalar_type_definition()
| composite_type_definition()
| access_type_definition()
| file_type_definition()
| protected_type_definition()
}
void type_mark() #void :
{}
{
LOOKAHEAD(type_name())
type_name()
| LOOKAHEAD(subtype_name())
subtype_name()
}
void unconstrained_array_definition() :
{}
{
<ARRAY> "(" index_subtype_definition()
( "," index_subtype_definition() )* ")"
<OF> element_subtype_indication()
}
void use_clause() :
{}
{
<USE> selected_name() ( "," selected_name() )* ";"
}
void variable_assignment_statement() :
{}
{
[ LOOKAHEAD( label() ":") label() ":" ]
target() ":=" expression() ";"
}
void variable_declaration() :
{}
{
[ <SHARED> ] <VARIABLE> identifier_list() ":"
subtype_indication() [ ":=" expression() ] ";"
}
void wait_statement() :
{}
{
[ LOOKAHEAD( label() ) ":" label() ":"]
<WAIT> [ sensitivity_clause() ]
[ condition_clause() ] [ timeout_clause() ] ";"
}
void waveform() :
{}
{
waveform_element() ( "," waveform_element() )*
| <UNAFFECTED>
}
void waveform_element() :
{}
{
LOOKAHEAD(<NULL>)
<NULL> [<AFTER> time_expression() ]
| value_expression() [ <AFTER> time_expression() ]
}
/**
*Section 15: Simultaneous statements
* 1076.1 extension
*/
void simultaneous_statement_part() :
{}
{
( simultaneous_statement() )*
}
/**
* 1076.1 extension:
*/
void simultaneous_statement() #void :
{}
{
LOOKAHEAD(simple_simultaneous_statement())
simple_simultaneous_statement()
| LOOKAHEAD( [if_label()] ":" <IF> condition() <USE> )
simultaneous_if_statement()
| LOOKAHEAD(simultaneous_case_statement())
simultaneous_case_statement()
| LOOKAHEAD(4) // procedural is at least as 4th position...
simultaneous_procedural_statement()
| simultaneous_null_statement()
}
/**
* 1076.1 extension:
*/
void simple_simultaneous_statement() :
{}
{
[ LOOKAHEAD( label() ":") label() ":"]
[<PURE>|<IMPURE>] simple_expression()
"==" simple_expression() [ tolerance_aspect() ] ";"
}
/**
* 1076.1 extension:
*/
void simultaneous_if_statement() :
{}
{
[ if_label() ":"] <IF> condition() <USE>
simultaneous_statement_part()
( <ELSIF> condition() <USE> simultaneous_statement_part() )*
[ <ELSE> simultaneous_statement_part() ]
<END> <USE> [ if_label()] ";"
}
/**
* 1076.1 extension:
*/
void simultaneous_case_statement() :
{}
{
[ case_label() ":"] <CASE> expression() <USE>
(simultaneous_alternative())*
<END> <CASE> [ case_label() ] ";"
}
/**
* 1076.1 extension:
*/
void simultaneous_alternative() :
{}
{
<WHEN> choices() <USE> simultaneous_statement_part()
}
/**
* 1076.1 extension:
*/
void simultaneous_procedural_statement() :
{}
{
[procedural_label() ":"] [<PURE>|<IMPURE>] <PROCEDURAL> [<IS>]
procedural_declarative_part()
<BEGIN>
procedural_statement_part()
<END> <PROCEDURAL> [ procedural_label()] ";"
}
// 1076.1 extension:
void procedural_label() #void :
{}
{
label()
}
// 1076.1 extension:
void procedural_declarative_part() :
{}
{
( procedural_declarative_item() )*
}
/**
* 1076.1 extension:
*/
void procedural_declarative_item() #void :
{}
{
LOOKAHEAD(subprogram_declaration())
subprogram_declaration()
| subprogram_body()
| type_declaration()
| subtype_declaration()
| constant_declaration()
| variable_declaration()
| alias_declaration()
| LOOKAHEAD(attribute_declaration())
attribute_declaration()
| attribute_specification()
| use_clause()
| LOOKAHEAD(group_template_declaration())
group_template_declaration()
| group_declaration()
}
/**
* 1076.1 extension:
*/
void procedural_statement_part() :
{}
{
( sequential_statement() )*
}
// 1076.1 extension:
void simultaneous_null_statement() :
{}
{
[ label() ":"] <NULL> ";"
}
//
// parts of grammar, which have to be checked during semantic analysis
// by semantic lookahead:
//
void block_label() #void :
{}
{
label()
}
void block_statement_label() #void :
{}
{
label()
}
void case_label() #void :
{}
{
label()
}
void generate_label() #void :
{}
{
label()
}
void generate_statement_label() #void :
{}
{
label()
}
void if_label() #void :
{}
{
label()
}
void instantiation_label() #void :
{}
{
label()
}
void loop_label() #void :
{}
{
label()
}
void process_label() #void :
{}
{
label()
}
void architecture_simple_name() #void :
{}
{
simple_name()
}
void attribute_simple_name() #void :
{}
{
simple_name()
| <RANGE>
}
void component_simple_name() #void :
{}
{
simple_name()
}
void configuration_simple_name() #void :
{}
{
simple_name()
}
void element_simple_name() #void :
{}
{
simple_name()
}
void entity_simple_name() #void :
{}
{
simple_name()
}
void package_simple_name() #void :
{}
{
simple_name()
}
void architecture_name() #void :
{}
{
name()
}
void entity_name() #void :
{}
{
name()
}
void file_name() #void :
{}
{
name()
}
void function_name() #void :
{}
{
name()
}
void configuration_name() #void :
{}
{
name()
}
void component_name() #void :
{}
{
name()
}
void generic_name() #void :
{}
{
name()
}
void group_template_name() #void :
{}
{
name()
}
void parameter_name() #void :
{}
{
name()
}
void physical_type_simple_name() #void :
{}
{
simple_name()
}
void port_name() #void :
{}
{
name()
}
void procedure_name() #void :
{}
{
name()
}
void range_attribute_name() #void :
{}
{
name()
}
void signal_name() #void:
{}
{
name()
}
//
// Name, der einen Typen bezeichnet...
//
void type_name() #void:
{}
{
name()
}
// 1076.1 extension:
void record_nature_simple_name() #void :
{}
{
simple_name()
}
void record_type_simple_name() #void :
{}
{
simple_name()
}
void resolution_function_name() #void :
{}
{
name()
}
void subtype_name() #void :
{}
{
name()
}
void unit_name() #void :
{}
{
name()
}
void variable_name() #void :
{}
{
name()
}
void architecture_identifier() #void :
{}
{
identifier()
}
void static_expression() #void :
{}
{
expression()
}
void boolean_expression() #void :
{}
{
expression()
}
void file_open_kind_expression() #void :
{}
{
expression()
}
void guard_expression() #void :
{}
{
expression()
}
void time_expression() #void :
{}
{
expression() // unit_name()
// unit_name can be derived by expression!!!
}
// 1076.1 extension:
void time_or_real_expression() #void :
{}
{
expression() // unit_name()
// unit_name can be derived by expression!!!
}
void value_expression() #void :
{}
{
expression()
}
void string_expression() #void :
{}
{
expression()
}
void guarded_signal_list() #void :
{}
{
signal_list()
}
void parameter_association_list() #void :
{}
{
association_list()
}
void port_association_list() #void :
{}
{
association_list()
}
void generic_association_list() #void :
{}
{
association_list()
}
void generic_interface_list() #void :
{}
{
interface_list()
}
void parameter_interface_list() #void :
{}
{
interface_list()
}
void port_interface_list() #void :
{}
{
interface_list()
}
//
// fraglich:
//
void formal_port_clause() #void :
{}
{
port_clause()
}
void local_port_clause() #void :
{}
{
port_clause()
}
void formal_generic_clause() #void :
{}
{
generic_clause()
}
void local_generic_clause() #void :
{}
{
generic_clause()
}
void element_subtype_indication() #void :
{}
{
subtype_indication()
}
void discrete_subtype_indication() #void :
{}
{
subtype_indication()
}
void loop_parameter_specification() #void :
{}
{
parameter_specification()
}
void generate_parameter_specification() #void :
{}
{
parameter_specification()
}
void passive_concurrent_procedure_call_statement() #void :
{}
{
concurrent_procedure_call_statement()
}
void passive_process_statement() #void :
{}
{
process_statement()
}
void magnitude_simple_expression() #void :
{}
{
simple_expression()
}
void phase_simple_expression() #void :
{}
{
simple_expression()
}
void nature_name() #void :
{}
{
name()
}
void subnature_name() #void :
{}
{
name()
}
/**
* 1076.1 extension:
*/
void terminal_name() #void :
{}
{
name()
}
/**
* 1076.1 extension:
*/
void quantity_name() #void :
{}
{
name()
}
/**
* 1076.1 extension:
*/
void plus_terminal_name() #void :
{}
{
name()
}
/**
* 1076.1 extension:
*/
void minus_terminal_name() #void :
{}
{
name()
}
/**
* still missing:
*/
void shared_variable_declaration() :
{}
{
[ <SHARED> ] <VARIABLE> identifier_list() ":"
subtype_indication() [ ":=" expression() ] ";"
}
/**
*
* for error recovery:
*
*/
JAVACODE void error_skipto(int kind, String message)
{
errs.Error(message,null);
Token t;
do
{
t = getNextToken();
} while ((t.kind != kind) && t.next != null);
}
source.veditor.jar = src/,\
_generated/
output.veditor.jar = bin/
bin.includes = icons/,\
veditor.jar,\
plugin.xml,\
about_veditor.html,\
META-INF/,\
templates/,\
plugin.properties,\
tools/,\
README,\
about.html,\
LICENSE,\
INSTALL,\
CONTRIBUTORS_VEDITOR.txt,\
parsers/
#
# Set the following to override the environment
# variable settings for JAVACC_HOME and ECLIPSE_HOME
#
#javacc_dir=/home/ali/javacc-4.0
#eclipse_plugin_dir=/home/ali/eclipse/plugins
src.includes = .classpath,\
.cvsignore,\
.externalToolBuilders/,\
.project,\
.settings/,\
CONTRIBUTORS_VEDITOR.txt,\
ChangeLogVeditor.txt,\
META-INF/,\
_generated/,\
about_veditor.html,\
bin/,\
build.properties,\
buildjavacc.xml,\
icons/,\
plugin.properties,\
plugin.xml,\
plugins/,\
src/,\
templates/,\
tools/,\
parsers/,\
INSTALL,\
LICENSE,\
about.html,\
README
<?xml version="1.0" encoding="UTF-8"?>
<project name="veditor" default="compile" basedir=".">
<!-- Eclipse & JavaCC installation directry -->
<property file="build.properties"/>
<property environment="env"/>
<property name="eclipse_plugin_dir" value="/${env.ECLIPSE_HOME}/plugins"/>
<property name="javacc_dir" value="/${env.JAVACC_HOME}"/>
<!-- must be linked with plugin.xml -->
<property name="project" value="com.elphel.vdt.veditor"/>
<property name="plugin_version" value="1.1.1"/>
<property name="src" value="src"/>
<property name="dst" value="bin"/>
<property name="javacc_generated" value="_generated"/>
<property name="javacc_file_dir_verilog" value="net/sourceforge/veditor/parser/verilog"/>
<property name="javacc_file_dir_vhdl" value="net/sourceforge/veditor/parser/vhdl"/>
<property name="javacc_src_verilog" value="${src}/${javacc_file_dir_verilog}/VerilogParserCore.jj"/>
<property name="javacc_src_vhdl" value="${src}/${javacc_file_dir_vhdl}/vhdl.jj"/>
<property name="jtree_src_vhdl" value="${src}/${javacc_file_dir_vhdl}/vhdl.jjt"/>
<property name="javacc_dst_verilog" value="${javacc_generated}/${javacc_file_dir_verilog}"/>
<property name="javacc_dst_vhdl" value="${javacc_generated}/${javacc_file_dir_vhdl}"/>
<property name="jjtree_dst" value="${src}/${javacc_file_dir_vhdl}"/>
<property name="jar" value="veditor.jar"/>
<property name="project_version" value="${project}_${plugin_version}"/>
<property name="zip" value="${project_version}.jar"/>
<path id="compile.classpath">
<fileset dir="${eclipse_plugin_dir}">
<include name="**/*.jar"/>
</fileset>
</path>
<target name="jjtree">
<jjtree
javacchome="${javacc_dir}"
target="${jtree_src_vhdl}"
static="false"
outputdirectory="${jjtree_dst}" />
</target>
<target name="verilogParser">
<mkdir dir="${javacc_dst_verilog}" />
<javacc
javacchome="${javacc_dir}"
target="${javacc_src_verilog}"
outputdirectory="${javacc_dst_verilog}" />
</target>
<target name="vhdlParser" depends="jjtree">
<mkdir dir="${javacc_dst_vhdl}" />
<javacc
javacchome="${javacc_dir}"
target="${javacc_src_vhdl}"
static="false"
outputdirectory="${javacc_dst_vhdl}" />
</target>
<target name="compile" depends="verilogParser,vhdlParser">
<mkdir dir="plugins"/>
<mkdir dir="${dst}" />
<javac
target="1.5"
source="1.5"
debug="on"
srcdir="${src};${javacc_generated}"
destdir="${dst}">
<classpath refid="compile.classpath"/>
</javac>
<copy todir="${dst}" >
<fileset dir="${src}" includes="**/*.properties"/>
</copy>
</target>
<target name="jar" depends="compile">
<jar
jarfile="${jar}"
basedir="${dst}">
</jar>
</target>
<target name="export" depends="jar">
<mkdir dir="plugins"/>
<copydir src="icons" dest="plugins/icons"/>
<copydir src="templates" dest="plugins/templates"/>
<copydir src="META-INF" dest="plugins/META-INF"/>
<copy file="plugin.xml" todir="plugins"/>
<copy file="about.html" todir="plugins"/>
<copy file="${jar}" todir="plugins"/>
<zip
zipfile="${zip}"
basedir="plugins"
includes="**">
</zip>
<delete dir="plugins"/>
</target>
<target name="clean">
<delete dir="${javacc_dst_vhdl}"/>
<delete dir="${javacc_dst_verilog}"/>
<delete file="${javacc_src_vhdl}"/>
<delete dir="${dst}"/>
<delete file="${jar}"/>
<delete file="${zip}"/>
</target>
</project>
icons/P.gif

74 Bytes

icons/arch.gif

344 Bytes

icons/cver.gif

983 Bytes

icons/f.gif

70 Bytes

icons/nav.gif

144 Bytes

icons/obj.gif

193 Bytes

icons/ovr.gif

163 Bytes

icons/pers.gif

618 Bytes

icons/sort.gif

153 Bytes

icons/t.gif

93 Bytes

icons/vsrc.gif

217 Bytes

icons/xds.gif

137 Bytes

icons/xst.gif

159 Bytes

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>parsers</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?><pydev_project>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/${PROJECT_DIR_NAME}</path>
</pydev_pathproperty>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
</pydev_project>
#!/bin/bash
echo $0 $*
echo "Running: $0"
for i in $*; do
echo $i
done
#/bin/bash -s '/data/vdt/workspace_01/veditor/parsers/slow.sh | /data/vdt/workspace_01/veditor/parsers/parser01.py;'
#/data/vdt/workspace_01/veditor/parsers/slow.sh | grep "[a-z]";
/data/vdt/workspace_01/veditor/parsers/slow.sh;
exit 0;
#!/bin/bash
echo $0 $*
echo "Running: $0"
for i in $*; do
echo $i
done
echo "sleep 1"
sleep 1
echo "sleep 1"
sleep 1
echo "sleep 1"
sleep 1
echo "sleep 1"
sleep 1
echo "sleep 1"
sleep 1
echo "sleep 1"
sleep 1
echo "sleep 1"
sleep 1
ping -c 10 xission.co
exit 0;
Icarus Verilog Preprocessor version 0.9.7 (v0_9_7)
Copyright (c) 1999-2011 Stephen Williams (steve@icarus.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
/usr/lib/x86_64-linux-gnu/ivl/system.sft: Processing System Function Table file.
/usr/lib/x86_64-linux-gnu/ivl/v2005_math.sft: Processing System Function Table file.
/usr/lib/x86_64-linux-gnu/ivl/va_math.sft: Processing System Function Table file.
Using language generation: IEEE1364-2005,no-specify,xtypes,icarus-misc
PARSING INPUT
... done, 0.09 seconds.
ELABORATING DESIGN
imu_logger.v:314: warning: Port 10 (debug) of rs232_rcv expects 5 bits, got 4.
imu_logger.v:314: : Padding 1 high bits of the port.
x353.v:1432: warning: Port 13 (test1) of dma_fifo_sync expects 8 bits, got 4.
x353.v:1432: : Padding 4 high bits of the port.
x353.v:1432: warning: Port 14 (test2) of dma_fifo_sync expects 8 bits, got 4.
x353.v:1432: : Padding 4 high bits of the port.
RUNNING FUNCTORS
... done, 0.22 seconds.
-F cprop ...
-F nodangle ...
... 1 iterations deleted 4848 dangling signals and 0 events.
... 2 iterations deleted 4848 dangling signals and 1264 events.
CALCULATING ISLANDS
CODE GENERATION
... done, 0.04 seconds.
... invoking target_design
unisims/RAMB16_S18_S36.v:693: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S36.v:700: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S36.v:707: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S36.v:693: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S36.v:700: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S36.v:707: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S9_S36.v:667: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S9_S36.v:674: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S9_S36.v:681: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S36_S36.v:746: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S36_S36.v:753: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S36_S36.v:760: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S9_S9.v:588: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S9_S9.v:595: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S9_S9.v:602: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S9_S9.v:588: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S9_S9.v:595: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S9_S9.v:602: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S9_S9.v:588: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S9_S9.v:595: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S9_S9.v:602: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S9_S9.v:588: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S9_S9.v:595: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S9_S9.v:602: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S4_S18.v:591: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S4_S18.v:598: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S4_S18.v:605: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S9_S18.v:614: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S9_S18.v:621: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S9_S18.v:628: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S18.v:640: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S18.v:647: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S18.v:654: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S36.v:693: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S36.v:700: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S36.v:707: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S36.v:693: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S36.v:700: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S36.v:707: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S9_S9.v:588: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S9_S9.v:595: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S9_S9.v:602: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S9_S9.v:588: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S9_S9.v:595: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S9_S9.v:602: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S18.v:640: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S18.v:647: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S18.v:654: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S18.v:640: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S18.v:647: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S18.v:654: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S4_S18.v:591: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S4_S18.v:598: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S4_S18.v:605: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S18.v:640: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S18.v:647: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S18.v:654: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S18.v:640: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S18.v:647: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S18.v:654: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S18.v:640: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S18.v:647: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S18.v:654: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S36.v:693: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S36.v:700: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/RAMB16_S18_S36.v:707: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1379: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1379: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1379: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1379: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1415: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1417: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1432: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1455: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1415: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1417: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1432: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1455: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:495: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:509: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:526: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:773: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:782: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:782: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:782: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:788: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:788: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:788: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1379: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1379: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1379: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1379: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1415: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1417: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1432: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1455: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1415: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1417: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1432: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1455: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:495: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:509: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:526: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:773: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:782: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:782: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:782: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:788: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:788: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:788: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM_SP.v:1157: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM_SP.v:1157: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM_SP.v:1157: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM_SP.v:1157: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM_SP.v:1211: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM_SP.v:1212: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM_SP.v:1230: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM_SP.v:1211: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM_SP.v:1212: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM_SP.v:1230: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM_SP.v:516: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM_SP.v:530: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM_SP.v:547: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM_SP.v:803: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM_SP.v:812: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM_SP.v:812: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM_SP.v:812: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM_SP.v:818: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM_SP.v:818: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM_SP.v:818: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1379: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1379: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1379: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1379: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1415: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1417: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1432: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1455: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1415: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1417: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1432: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:1455: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:495: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
(null):0: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:509: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:526: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:773: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:782: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:782: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:782: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:788: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:788: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
unisims/DCM.v:788: tgt-vvp warning: V0.9 may give incorrect results when casting an unsigned value greater than 63 bits to a real value.
... done, 0.34 seconds.
STATISTICS
lex_string: add_count=20489 hit_count=70652
Icarus Verilog version 0.9.7 (v0_9_7)
Copyright 1998-2010 Stephen Williams
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
translate: /usr/lib/x86_64-linux-gnu/ivl/ivlpp -v -L -F"/tmp/ivrlg27fd21f64" -f"/tmp/ivrlg7fd21f64" -p"/tmp/ivrli7fd21f64" | /usr/lib/x86_64-linux-gnu/ivl/ivl -v -C"/tmp/ivrlh7fd21f64" -C"/usr/lib/x86_64-linux-gnu/ivl/vvp.conf" -- -
#!/usr/bin/env python
##/usr/bin/python -u
import sys
print "started"
n=1;
for line in iter(sys.stdin.readline,''):
sys.stdout.write ("%04d: %s"%(n,line))
# sys.stdout.flush()
n+=1
#!/bin/bash
echo "sleep 1"
sleep 1
echo "sleep 1"
sleep 1
echo "sleep 1"
sleep 1
echo "sleep 1"
sleep 1
echo "sleep 1"
sleep 1
echo "sleep 1"
sleep 1
echo "sleep 1"
sleep 1
ping -c 10 xmission.com
exit 0;
This source diff could not be displayed because it is too large. You can view the blob instead.
# From VDT, some properties are not needed
Plugin.name = Verilog Development Tools
Plugin.providerName = Elphel, Inc
Perspective.name = Verilog
PreferencePage.name = Verilog
VerilogNature.name = Verilog
Views.category = Verilog
Views.DesignMenu = Design Menu
Views.VerilogModules = Verilog Navigator
NewWizardCategory.name = Verilog
NewVerilogProject.name = Verilog Project
NewVerilogProject.description = Create a Verilog project
NewVerilogModule.name = Module
NewVerilogModule.description = Create a Verilog module
ActionDefinition.openVerilogToolsConfigurations.name = Verilog Tool...
ActionDefinition.openVerilogToolsConfigurations.description = Open verilog tools launch configuration dialog
Launch.Action.label = &Verilog Tools
Launch.ConfigurationType.name = Verilog Tool
LaunchConfigurationTabGroup.description = Run a verilog tool
LaunchGroup.label = &Verilog Tools
LaunchGroup.title = Select or configure an verilog tool to run
XlinxProjectOptions = Xlinx options
verilog_source_loc.description = Returns the absolute file system path of a verilog file. The target verilog file is the last selected verilog file when no argument is specified, or the verilog file identified by a workspace relative path.
verilog_source_path.description = Returns the workspace relative path of a verilog file. The target verilog file is the last selected verilog file when no argument is specified, or the verilog file identified by a workspace relative path.
verilog_source_name.description = Returns the name of a verilog file. The target verilog file is the selected verilog file when no argument is specified, or the verilog file identified by a workspace relative path.
verilog_source_prompt.description = Returns the workspace relative path of a verilog file chosen in a selection dialog.
OpenNewProjectWizardAction.label = Verilog &Project...
OpenNewProjectWizardAction.tooltip = New Verilog Project
OpenNewModuleWizardAction.label = Verilog &Module...
OpenNewModuleWizardAction.tooltip = New Verilog Module
editor.name = Verilog Editor
editor.name.0 = VHDL Editor
editor.name.1 = Verilog/VHDL Log Viewer
perspective.name = Verilog/VHDL
category.name = Verilog/VHDL Editor
view.name = Hierarchy
page.name = Verilog/VHDL Editor
page.name.0 = Color
page.name.1 = Templates
page.name.2 = Error Parser
page.name.3 = Code Style
page.name.4 = Verilog Code Style
page.name.5 = VHDL Code Style
page.name.6 = Warning
page.name.7 = Verilog Warning
page.name.8 = VHDL Warning
category.name.0 = Verilog/VHDL
wizard.name = Verilog file
wizard.name.0 = VHDL file
wizard.name.1 = Verilog/VHDL project
context.description = Editing Verilog/VHDL
context.name = Editing Verilog/VHDL
category.description = Verilog/VHDL editing commands
category.name.1 = Verilog/VHDL Editing
command.description = Format region
command.name = Format
command.description.0 = Compile
command.name.0 = Compile
command.description.1 = Synthesize
command.name.1 = Synthesize
command.description.2 = Goto Matching Bracket
command.name.2 = Matching Bracket
command.description.3 = Goto Open Declaration
command.name.3 = Open Declaration
command.description.4 = Collapse all foldable sections
command.name.4 = Collapse All
command.description.5 = Expand all foldable sections
command.name.5 = Expand All
command.description.6 = Shows the current element in the hierarchy
command.name.6 = Show in Hierarchy
command.description.7 = Shows the current element in the outline
command.name.7 = Show in Outline
command.description.8 = Comments a block of code
command.name.8 = Comment
command.description.9 = Remove block comments from code
command.name.9 = Uncomment
command.description.10 = Shows the current file in the navigator
command.name.10 = Show In Navigator
command.description.11 = Clears the error markers for this file
command.name.11 = Clear Error Markers
extension.name = VEdiot Builder
extension.name.0 = Verilog/VHDL Project Nature
page.name.9 = VEditor Builds
contextType.name = VHDL Global
contextType.name.0 = Verilog In Statement
contextType.name.1 = Verilog In Module
contextType.name.2 = Verilog Out of Module
contextType.name.3 = VHDL New File
contextType.name.4 = Verilog New File
content-type.name = Verilog Source File
content-type.name.0 = VHDL Source File
content-type.name.1 = Simulation Log File
extension.name.1 = Auto Task
extension.name.2 = Problem of the external builder
Bundle-Vendor = VEditor Team
Bundle-Name = Verilog/VHDL Plugin
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<plugin>
<extension
point="org.eclipse.ui.editors">
<editor
name="%editor.name"
icon="icons/vsrc.gif"
contributorClass="com.elphel.vdt.veditor.editor.HdlActionContributor"
class="com.elphel.vdt.veditor.editor.VerilogEditor"
id="com.elphel.vdt.veditor.editor.VerilogEditor">
<contentTypeBinding contentTypeId="com.elphel.vdt.veditor.verilogSource"/>
</editor>
</extension>
<extension
point="org.eclipse.ui.editors">
<editor
name="%editor.name.0"
icon="icons/vsrc.gif"
contributorClass="com.elphel.vdt.veditor.editor.HdlActionContributor"
class="com.elphel.vdt.veditor.editor.VhdlEditor"
id="com.elphel.vdt.veditor.editor.VhdlEditor">
<contentTypeBinding contentTypeId="com.elphel.vdt.veditor.vhdlSource"/>
</editor>
</extension>
<extension
point="org.eclipse.ui.editors">
<editor
name="%editor.name.1"
icon="icons/vsrc.gif"
class="com.elphel.vdt.veditor.log.LogEditor"
contributorClass="org.eclipse.ui.texteditor.BasicTextEditorActionContributor"
id="com.elphel.vdt.veditor.log.LogEditor">
<contentTypeBinding contentTypeId="com.elphel.vdt.veditor.simulationLog"/>
</editor>
</extension>
<extension
point="org.eclipse.ui.perspectives">
<perspective
name="%perspective.name"
icon="icons/pers.gif"
class="com.elphel.vdt.veditor.VerilogPerspective"
id="com.elphel.vdt.veditor.editor.perspective"
fixed="false"/>
</extension>
<extension
point="org.eclipse.ui.views">
<category
name="%category.name"
id="veditor">
</category>
<view
name="%view.name"
icon="icons/hierarchy.gif"
category="veditor"
class="com.elphel.vdt.veditor.editor.ModuleHierarchyView"
id="com.elphel.vdt.veditor.editor.ModuleHierarchyView">
</view>
<!-- -->
<view
name="%Views.DesignMenu"
category="veditor"
class="com.elphel.vdt.ui.views.DesignFlowView"
icon="icons/sample.gif"
id="com.elphel.vdt.ui.views.DesignFlowView">
</view>
<!-- -->
</extension>
<extension
point = "org.eclipse.ui.preferencePages">
<page
id="com.elphel.vdt.veditor.preference.TopPreferencePage"
class="com.elphel.vdt.veditor.preference.TopPreferencePage"
name="%page.name">
</page>
<page
category="com.elphel.vdt.veditor.preference.TopPreferencePage"
id="com.elphel.vdt.veditor.preference.ColorPreferencePage"
class="com.elphel.vdt.veditor.preference.ColorPreferencePage"
name="%page.name.0">
</page>
<page
category="com.elphel.vdt.veditor.preference.TopPreferencePage"
id="com.elphel.vdt.veditor.preference.TemplatePreferencePage"
class="com.elphel.vdt.veditor.preference.TemplatePreferencePage"
name="%page.name.1">
</page>
<page
category="com.elphel.vdt.veditor.preference.TopPreferencePage"
id="com.elphel.vdt.veditor.preference.ErrorParserPreferencePage"
class="com.elphel.vdt.veditor.preference.ErrorParserPreferencePage"
name="%page.name.2">
</page>
<page
category="com.elphel.vdt.veditor.preference.TopPreferencePage"
id="com.elphel.vdt.veditor.preference.CodeStylePreferencePage"
class="com.elphel.vdt.veditor.preference.CodeStylePreferencePage"
name="%page.name.3">
</page>
<page
category="com.elphel.vdt.veditor.preference.CodeStylePreferencePage"
id="com.elphel.vdt.veditor.preference.VerilogCodeStylePreferencePage"
class="com.elphel.vdt.veditor.preference.VerilogCodeStylePreferencePage"
name="%page.name.4">
</page>
<page
category="com.elphel.vdt.veditor.preference.CodeStylePreferencePage"
id="com.elphel.vdt.veditor.preference.VhdlCodeStylePreferencePage"
class="com.elphel.vdt.veditor.preference.VhdlCodeStylePreferencePage"
name="%page.name.5">
</page>
<page
category="com.elphel.vdt.veditor.preference.TopPreferencePage"
id="com.elphel.vdt.veditor.preference.WarningPreferencePage"
class="com.elphel.vdt.veditor.preference.WarningPreferencePage"
name="%page.name.6">
</page>
<page
category="com.elphel.vdt.veditor.preference.WarningPreferencePage"
id="com.elphel.vdt.veditor.preference.VerilogWarningPreferencePage"
class="com.elphel.vdt.veditor.preference.VerilogWarningPreferencePage"
name="%page.name.7">
</page>
<page
category="com.elphel.vdt.veditor.preference.WarningPreferencePage"
id="com.elphel.vdt.veditor.preference.VhdlWarningPreferencePage"
class="com.elphel.vdt.veditor.preference.VhdlWarningPreferencePage"
name="%page.name.8">
</page>
</extension>
<extension
point="org.eclipse.core.runtime.preferences">
<initializer class="com.elphel.vdt.veditor.preference.PreferenceInitializer"/>
</extension>
<extension
point="org.eclipse.ui.newWizards">
<category
name="%category.name.0"
id="com.elphel.vdt.veditor.wizard">
</category>
<wizard
name="%wizard.name"
icon="icons/vsrc.gif"
category="com.elphel.vdt.veditor.wizard"
class="com.elphel.vdt.veditor.wizard.NewVerilogWizard"
id="com.elphel.vdt.veditor.wizard.NewVerilogWizard">
</wizard>
<wizard
name="%wizard.name.0"
icon="icons/vsrc.gif"
category="com.elphel.vdt.veditor.wizard"
class="com.elphel.vdt.veditor.wizard.NewVhdlWizard"
id="com.elphel.vdt.veditor.wizard.NewVhdlWizard">
</wizard>
<wizard
name="%wizard.name.1"
icon="icons/vsrc.gif"
category="com.elphel.vdt.veditor.wizard"
class="com.elphel.vdt.veditor.wizard.NewProjectWizard"
project="true"
finalPerspective="com.elphel.vdt.veditor.editor.perspective"
id="com.elphel.vdt.veditor.wizard.NewProjectWizard">
</wizard>
</extension>
<extension
point="org.eclipse.ui.contexts">
<context
name="%context.name"
parentId="org.eclipse.ui.textEditorScope"
description="%context.description"
id="com.elphel.vdt.veditor.scope">
</context>
</extension>
<extension
point="org.eclipse.ui.commands">
<category
name="%category.name.1"
description="%category.description"
id="com.elphel.vdt.veditor.commands">
</category>
<command
name="%command.name"
description="%command.description"
categoryId="com.elphel.vdt.veditor.commands"
id="com.elphel.vdt.veditor.actions.Format">
</command>
<command
name="%command.name.0"
description="%command.description.0"
categoryId="com.elphel.vdt.veditor.commands"
id="com.elphel.vdt.veditor.actions.Compile">
</command>
<command
name="%command.name.1"
description="%command.description.1"
categoryId="com.elphel.vdt.veditor.commands"
id="com.elphel.vdt.veditor.actions.Synthesize">
</command>
<command
name="%command.name.2"
description="%command.description.2"
categoryId="com.elphel.vdt.veditor.commands"
id="com.elphel.vdt.veditor.actions.GotoMatchingBracket">
</command>
<command
name="%command.name.3"
description="%command.description.3"
categoryId="com.elphel.vdt.veditor.commands"
id="com.elphel.vdt.veditor.actions.OpenDeclaration">
</command>
<command
name="%command.name.4"
description="%command.description.4"
categoryId="com.elphel.vdt.veditor.commands"
id="com.elphel.vdt.veditor.actions.CollapseAll">
</command>
<command
name="%command.name.5"
description="%command.description.5"
categoryId="com.elphel.vdt.veditor.commands"
id="com.elphel.vdt.veditor.actions.ExpandAll">
</command>
<command
name="%command.name.6"
description="%command.description.6"
categoryId="com.elphel.vdt.veditor.commands"
id="com.elphel.vdt.veditor.actions.ShowInHierarchy">
</command>
<command
name="%command.name.7"
description="%command.description.7"
categoryId="com.elphel.vdt.veditor.commands"
id="com.elphel.vdt.veditor.actions.ShowInOutline">
</command>
<command
name="%command.name.8"
description="%command.description.8"
categoryId="com.elphel.vdt.veditor.commands"
id="com.elphel.vdt.veditor.actions.Comment">
</command>
<command
name="%command.name.9"
description="%command.description.9"
categoryId="com.elphel.vdt.veditor.commands"
id="com.elphel.vdt.veditor.actions.Uncomment">
</command>
<command
name="%command.name.10"
description="%command.description.10"
categoryId="com.elphel.vdt.veditor.commands"
id="com.elphel.vdt.veditor.actions.ShowInNavigator">
</command>
<command
name="%command.name.11"
description="%command.description.11"
categoryId="com.elphel.vdt.veditor.commands"
id="com.elphel.vdt.veditor.actions.ClearErrorMarkers">
</command>
</extension>
<extension
point="org.eclipse.ui.bindings">
<key
sequence="M1+M2+F"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
contextId="com.elphel.vdt.veditor.scope"
commandId="com.elphel.vdt.veditor.actions.Format">
</key>
<key
sequence="F7"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
contextId="com.elphel.vdt.veditor.scope"
commandId="com.elphel.vdt.veditor.actions.Compile">
</key>
<key
sequence="F8"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
contextId="com.elphel.vdt.veditor.scope"
commandId="com.elphel.vdt.veditor.actions.Synthesize">
</key>
<key
sequence="Esc ]"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
contextId="com.elphel.vdt.veditor.scope"
commandId="com.elphel.vdt.veditor.actions.GotoMatchingBracket">
</key>
<key
sequence="F3"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
contextId="com.elphel.vdt.veditor.scope"
commandId="com.elphel.vdt.veditor.actions.OpenDeclaration">
</key>
<key
sequence="M1+F12"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
contextId="com.elphel.vdt.veditor.scope"
commandId="com.elphel.vdt.veditor.actions.CollapseAll">
</key>
<key
sequence="M2+F12"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
contextId="com.elphel.vdt.veditor.scope"
commandId="com.elphel.vdt.veditor.actions.ExpandAll">
</key>
<key
sequence="M1+M2+/"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
contextId="com.elphel.vdt.veditor.scope"
commandId="com.elphel.vdt.veditor.actions.Comment">
</key>
<key
sequence="M1+M2+\"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
contextId="com.elphel.vdt.veditor.scope"
commandId="com.elphel.vdt.veditor.actions.Uncomment">
</key>
</extension>
<extension
point="org.eclipse.debug.core.launchConfigurationTypes">
<launchConfigurationType
delegate="com.elphel.vdt.core.launching.VDTLaunchConfigurationDelegate"
id="com.elphel.vdt.launchConfigurationType"
modes="run"
name="%Launch.ConfigurationType.name"/>
</extension>
<extension
point="org.eclipse.core.variables.dynamicVariables">
<variable
name="verilog_source_loc"
description="%verilog_source_loc.description"
resolver="com.elphel.vdt.ui.variables.VerilogResolver"
supportsArgument="true">
</variable>
<variable
name="verilog_source_path"
description="%verilog_source_path.description"
resolver="com.elphel.vdt.ui.variables.VerilogResolver"
supportsArgument="true">
</variable>
<variable
name="verilog_source_name"
description="%verilog_source_name.description"
resolver="com.elphel.vdt.ui.variables.VerilogResolver"
supportsArgument="true">
</variable>
<variable
name="verilog_source_prompt"
description="%verilog_source_prompt.description"
resolver="com.elphel.vdt.ui.variables.VerilogPrompt"
supportsArgument="true">
</variable>
</extension>
<extension
id="simulateBuilder"
name="%extension.name"
point="org.eclipse.core.resources.builders">
<builder
hasNature="true">
<run
class="com.elphel.vdt.veditor.builder.SimulateBuilder">
</run>
</builder>
</extension>
<extension
id="HdlNature"
name="%extension.name.0"
point="org.eclipse.core.resources.natures">
<runtime>
<run
class="com.elphel.vdt.veditor.HdlNature">
</run>
</runtime>
<builder
id="com.elphel.vdt.veditor.simulateBuilder">
</builder>
</extension>
<extension
point="org.eclipse.ui.ide.projectNatureImages">
<image
icon="icons/ovr.gif"
natureId="com.elphel.vdt.veditor.HdlNature"
id="com.elphel.vdt.veditor.natureImage">
</image>
</extension>
<extension
point="org.eclipse.ui.propertyPages">
<page
adaptable="true"
objectClass="org.eclipse.core.resources.IProject"
name="%page.name.9"
class="com.elphel.vdt.veditor.builder.SimulatorPropertyPage"
id="com.elphel.vdt.veditor.simulatorProperty">
<filter
name="nature"
value="com.elphel.vdt.veditor.HdlNature">
</filter>
</page>
</extension>
<extension point="org.eclipse.ui.editorActions">
<editorContribution
id="org.eclipse.ui.articles.action.contribution.editor"
targetID="com.elphel.vdt.veditor.editor.VhdlEditor">
</editorContribution>
<editorContribution
id="org.eclipse.ui.articles.action.contribution.editor"
targetID="com.elphel.vdt.veditor.editor.VerilogEditor">
</editorContribution>
</extension>
<extension
point="org.eclipse.ui.editors.templates">
<contextType
name="%contextType.name"
class="com.elphel.vdt.veditor.templates.VhdlGlobalContext"
id="com.elphel.vdt.veditor.templates.vhdl.context.global">
</contextType>
<contextType
name="%contextType.name.0"
class="com.elphel.vdt.veditor.templates.VerilogInStatementContextType"
id="com.elphel.vdt.veditor.verilogInStatement">
</contextType>
<contextType
name="%contextType.name.1"
class="com.elphel.vdt.veditor.templates.VerilogInModuleContextType"
id="com.elphel.vdt.veditor.verilogInModule">
</contextType>
<contextType
name="%contextType.name.2"
class="com.elphel.vdt.veditor.templates.VerilogOutModuleContextType"
id="com.elphel.vdt.veditor.verilogOutModule">
</contextType>
<include
file="templates/vhdl.xml">
</include>
<include
file="templates/verilog.xml">
</include>
<contextType
class="com.elphel.vdt.veditor.templates.VhdlNewFileContext"
id="com.elphel.vdt.veditor.templates.vhdl.context.newfile"
name="%contextType.name.3">
</contextType>
<contextType
class="com.elphel.vdt.veditor.templates.VerilogNewFileContext"
id="com.elphel.vdt.veditor.templates.verilog.context.newfile"
name="%contextType.name.4">
</contextType>
</extension>
<extension point="org.eclipse.core.runtime.contentTypes">
<content-type id="verilogSource" name="%content-type.name"
base-type="org.eclipse.core.runtime.text"
priority="high"/>
<content-type id="vhdlSource" name="%content-type.name.0"
base-type="org.eclipse.core.runtime.text"
priority="high"/>
<content-type id="simulationLog" name="%content-type.name.1"
base-type="org.eclipse.core.runtime.text"
priority="high"/>
</extension>
<extension point="org.eclipse.core.runtime.contentTypes">
<file-association
content-type="com.elphel.vdt.veditor.verilogSource"
file-extensions="v"/>
<file-association
content-type="com.elphel.vdt.veditor.verilogSource"
file-extensions="tf"/>
</extension>
<extension point="org.eclipse.core.runtime.contentTypes">
<file-association
content-type="com.elphel.vdt.veditor.vhdlSource"
file-extensions="vhd"/>
</extension>
<extension point="org.eclipse.core.runtime.contentTypes">
<file-association
content-type="com.elphel.vdt.veditor.vhdlSource"
file-extensions="vhdl"/>
</extension>
<extension point="org.eclipse.core.runtime.contentTypes">
<file-association
content-type="com.elphel.vdt.veditor.simulationLog"
file-extensions="log"/>
</extension>
<extension
id="autotaskmarker"
name="%extension.name.1"
point="org.eclipse.core.resources.markers">
<persistent value="true"/>
<super type="org.eclipse.core.resources.taskmarker"/>
</extension>
<extension
id="builderproblemmarker"
name="%extension.name.2"
point="org.eclipse.core.resources.markers">
<persistent value="true"/>
<super type="org.eclipse.core.resources.problemmarker"/>
</extension>
<extension
id="com.elphel.vdt.veditor.annotations"
point="org.eclipse.ui.editors.markerAnnotationSpecification">
<specification
annotationType="com.elphel.vdt.veditor.occurrences"
label="%OccurrenceAnnotation.label"
icon="$nl$/icons/full/obj16/searchm_obj.gif"
textPreferenceKey="occurrenceIndication"
textPreferenceValue="false"
highlightPreferenceKey="occurrenceHighlighting"
highlightPreferenceValue="true"
contributesToHeader="false"
overviewRulerPreferenceKey="occurrenceIndicationInOverviewRuler"
overviewRulerPreferenceValue="true"
verticalRulerPreferenceKey="occurrenceIndicationInVerticalRuler"
verticalRulerPreferenceValue="false"
colorPreferenceKey="occurrenceIndicationColor"
colorPreferenceValue="212,212,212"
presentationLayer="4"
showInNextPrevDropdownToolbarActionKey="showOccurrenceInNextPrevDropdownToolbarAction"
showInNextPrevDropdownToolbarAction="true"
isGoToNextNavigationTargetKey="isOccurrenceGoToNextNavigationTarget"
isGoToNextNavigationTarget="false"
isGoToPreviousNavigationTargetKey="isOccurrenceGoToPreviousNavigationTarget"
isGoToPreviousNavigationTarget="false"
textStylePreferenceKey="occurrenceTextStyle"
textStylePreferenceValue="NONE">
</specification>
<specification
annotationType="com.elphel.vdt.veditor.occurrences.write"
label="%WriteOccurrenceAnnotation.label"
textPreferenceKey="writeOccurrenceIndication"
textPreferenceValue="false"
highlightPreferenceKey="writeOccurrenceHighlighting"
highlightPreferenceValue="true"
overviewRulerPreferenceKey="writeOccurrenceIndicationInOverviewRuler"
overviewRulerPreferenceValue="true"
verticalRulerPreferenceKey="writeOccurrenceIndicationInVerticalRuler"
verticalRulerPreferenceValue="false"
colorPreferenceKey="writeOccurrenceIndicationColor"
colorPreferenceValue="240,216,168"
presentationLayer="4"
textStylePreferenceKey="writeOccurrenceTextStyle"
textStylePreferenceValue="NONE">
</specification>
</extension>
</plugin>
package com.elphel.vdt;
public class Module {
public SourceFile getSourceFile(){
System.out.println("Module.getSourceFile()");
return (new SourceFile());
}
// Just as a placeholder, will be removed
}
package com.elphel.vdt;
import org.eclipse.core.resources.IFile;
public class SourceFile {
public IFile getFile(){
System.out.println("SourceFile.getFile()");
return null;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt;
/** Txt - access to resource strings
*
* Comments: cut-and-paste from com.excelsior.wizard
*/
import java.text.*;
import java.util.*;
import com.elphel.vdt.ui.MessageUI;
public class Txt {
// private static ResourceBundle messageRB;
// static {
// messageRB = (System.getProperty("os.name").indexOf("Windows") >= 0)
// ? ResourceBundle.getBundle("com.excelsior.wizard.texts.Strings_win")
// : ResourceBundle.getBundle("com.excelsior.wizard.texts.Strings_linux") ;
// if (messageRB.getLocale().getLanguage().equals("")
// && ! Locale.getDefault().getLanguage().equals(Locale.ENGLISH.getLanguage()))
// {
// Locale.setDefault(Locale.ENGLISH);
// }
// }
private static ResourceBundle messageRB =
ResourceBundle.getBundle("com.elphel.vdt.ui.texts.Strings");
private static boolean wasErrors = false;
public static String s(String id) {
try {
String s = messageRB.getString(id).trim();
if( s.length() >= 2
&& s.charAt(0) == '\''
&& s.charAt(s.length()-1) == '\''
)
s = s.substring(1, s.length()-1);
return s;
} catch(MissingResourceException e) {
if (!wasErrors) {
wasErrors = true;
MessageUI.error("VDT message file broken: key = "+id, e);
}
return id;
}
}
public static String s(String id, String param) {
String template = s(id);
Object[] foo = new Object[]{param};
return MessageFormat.format(template, foo);
}
public static String s(String id, int param) {
String template = s(id);
Object[] foo = new Object[]{new Integer(param)};
return MessageFormat.format(template, foo);
}
public static String s(String id, Object[] params) {
String template = s(id);
return MessageFormat.format(template, params);
}
/**
* Silent version of s(). If key string does not exists, simply returns null.
*/
public static String getStringIfExists(String id) {
try {
String s = messageRB.getString(id).trim();
if( s.length() >= 2
&& s.charAt(0) == '\''
&& s.charAt(s.length()-1) == '\''
)
s = s.substring(1, s.length()-1);
return s;
} catch(MissingResourceException e) {
return null;
}
}
} // class Txt
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt;
import org.eclipse.core.runtime.QualifiedName;
/**
* Central access point for the VDT plug-in (id <code>"com.elphel.vdt.ui"</code>).
*
* Created: 02.12.2005
* @author Lvov Konstantin
*/
public class VDT {
private VDT() {
// prevent instantiation of JavaUI.
}
//-------------------------------------------------------------------------
// Plug-in Constant
//-------------------------------------------------------------------------
/** The id of the VDT plug-in */
public static final String ID_VDT = "com.elphel.vdt";
/** The id of the VDT perspective */
// public static final String ID_PERSPECTIVE = ID_VDT + ".ui.Perspective";
/** The identifier for the Verilog nature */
//??????????????????????????????
public static final String VERILOG_NATURE_ID = ID_VDT + ".VerilogNature";
public static final String PREFERENCE_PAGE_ID = ID_VDT + ".ui.preferences.PreferencePage";
//-------------------------------------------------------------------------
// View Identificators
//-------------------------------------------------------------------------
/** The id of the Design Flow view */
public static final String ID_DESINGFLOW_VIEW = ID_VDT + ".ui.views.DesignFlowView";
/** The id of the Verilog Navigator view */
// public static final String ID_NAVIGATOR_VIEW = ID_VDT + ".ui.views.VerilogModuleView";
//-------------------------------------------------------------------------
// Vizard Identificators
//-------------------------------------------------------------------------
/** The id of the New Verilog Project wizard */
// public static final String ID_NEW_PROJECT_WIZARD = ID_VDT + ".ui.wizards.NewProjectWizard";
/** The id of the New Verilog Module wizard */
// public static final String ID_NEW_MODULE_WIZARD = ID_VDT + ".ui.wizards.NewModuleWizard";
//-------------------------------------------------------------------------
// Launch Configuration Attribute
//-------------------------------------------------------------------------
/**
* Identifier for the VDT launch configuration type
* (value <code>"com.elphel.vdt.launchConfigurationType"</code>).
*/
public static final String ID_DEFAULT_LAUNCH_TYPE = ID_VDT + ".launchConfigurationType";
/**
* String attribute identifying the location of an external. Default value
* is <code>null</code>. Encoding is tool specific.
*/
public static final String ATTR_TOOL_TO_LAUNCH = ID_VDT + ".ATTR_TOOL_TO_LAUNCH";
public static final String ATTR_TOOL_IS_SHELL = ID_VDT + ".ATTR_TOOL_IS_SHELL";
public static final String ATTR_TOOL_ID = ID_VDT + ".ATTR_TOOL_ID";
public static final String ATTR_TOOL_COMMAND_LINE_ARGUMENTS = ID_VDT + ".ATTR_TOOL_COMMAND_LINE";
public static final String ATTR_RESOURCE_TO_LAUNCH = ID_VDT + ".ATTR_PROJECT_TO_LAUNCH";
public static final String ATTR_WORKING_DIRECTORY = ID_VDT + ".ATTR_WORKING_DIRECTORY";
public static final String ATTR_PROJECT_PATH = ID_VDT + ".ATTR_PROJECT_PATH";
public static final String ATTR_TOOL_ERRORS = ID_VDT + ".ATTR_TOOL_ERRORS";
public static final String ATTR_TOOL_WARNINGS = ID_VDT + ".ATTR_TOOL_WARNINGS";
public static final String ATTR_TOOL_INFO = ID_VDT + ".ATTR_TOOL_INFO";
/**
* Identifier for verilog tools launch configuration group. The verilog
* tools launch configuration group corresponds to the verilog tools
* category in run mode.
*/
public static final String ID_VERILOG_TOOLS_LAUNCH_GROUP = ID_VDT +".launchGroup";
public static final String COMMAND_OPEN_VERILOG_TOOLS_LAUNCH_DIALOG = ID_VDT +".commands.OpenVerilogToolsConfigurations";
public static final String ATTR_LIST_OF_PARAMETERS_ATTRIBUTE_NAMES = ID_VDT + ".ATTR_LIST_OF_PARAMETERS_ATTRIBUTE_NAMES";
public static final String VARIABLE_RESOURCE_NAME = "${folder_prompt}";
//-------------------------------------------------------------------------
// Persistent Options
//-------------------------------------------------------------------------
public static final String OPTION_PROJECT_MENU = ID_VDT + ".PROJECT_DESING_MENU";
public static final QualifiedName OPTION_XLINX_DEVICE_FAMALY = new QualifiedName(ID_VDT, "OPTION_XLINX_DEVICE_FAMALY");
public static final QualifiedName OPTION_XLINX_DEVICE = new QualifiedName(ID_VDT, "OPTION_XLINX_DEVICE");
public static final QualifiedName OPTION_XLINX_DEVICE_PACKAGE = new QualifiedName(ID_VDT, "OPTION_XLINX_DEVICE_PACKAGE");
public static final QualifiedName OPTION_XLINX_DEVICE_SPEED_GRADE = new QualifiedName(ID_VDT, "OPTION_XLINX_DEVICE_SPEED_GRADE");
//-------------------------------------------------------------------------
// Build in generators for tool description
//-------------------------------------------------------------------------
public static final String GENERATOR_ID_PROJECT_NAME = "ProjectName";
public static final String GENERATOR_ID_EXE_PATH = "ExePath";
public static final String GENERATOR_ID_PROJECT_PATH = "ProjectPath";
public static final String GENERATOR_ID_SOURCE_LIST = "SourceList";
public static final String GENERATOR_ID_FILE_LIST = "FileList";
public static final String GENERATOR_ID_TOP_MODULE = "TopModule";
public static final String GENERATOR_ID_TOP_MODULES = "TopModules";
public static final String GENERATOR_ID_CURRENT_FILE = "CurrentFile";
public static final String GENERATOR_ID_CURRENT_BASE = "CurrentFileBase";
public static final String GENERATOR_ID_OS_NAME = "OS";
} // class VDT
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Iterator;
import java.util.Set;
import java.util.Vector;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.document.HdlDocument;
import com.elphel.vdt.veditor.parser.OutlineContainer;
import com.elphel.vdt.veditor.parser.OutlineDatabase;
//import com.elphel.vdt.veditor.parser.vhdl.VhdlOutlineElementFactory.PackageDeclElement;
import com.elphel.vdt.veditor.parser.OutlineElement;
import com.elphel.vdt.veditor.preference.PreferenceStrings;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
/**
* Verilog file utilities.
*
* Created: 04.02.2006
* @author Lvov Konstantin
*/
public class VerilogUtils {
public static OutlineDatabase getVeditorOutlineDatabase(IProject project){
OutlineDatabase database=null;
HdlDocument hdlDocument=null;
try {
database = (OutlineDatabase)project.getSessionProperty(VerilogPlugin.getOutlineDatabaseId());
} catch (CoreException e) {
e.printStackTrace();
}
if (database !=null) return database;
System.out.println("database is null, looking for the HdlDocument");
try {
hdlDocument=(HdlDocument)project.getSessionProperty(VerilogPlugin.getHdlDocumentId());
} catch (CoreException e) {
e.printStackTrace();
}
if (hdlDocument!=null) return hdlDocument.getOutlineDatabase(); /* will create a new one if does not exist */
return null;
}
public static String [] getExtList(String str){
return str.split("[\\, ]+");
}
public static boolean isVerilogFile(IFile file){
String name=file.getName();
String [] patterns=getExtList(VerilogPlugin.getPreferenceString(PreferenceStrings.VERILOG_EXT));
for (int i=0;i<patterns.length;i++) if (name.endsWith(patterns[i])) return true;
return false;
}
public static boolean isVhdlFile(IFile file){
String name=file.getName();
String [] patterns=getExtList(VerilogPlugin.getPreferenceString(PreferenceStrings.VHDL_EXT));
for (int i=0;i<patterns.length;i++) if (name.endsWith(patterns[i])) return true;
return false;
}
public static boolean isHhdlFile(IFile file){
return isVerilogFile(file) || isVhdlFile(file);
}
/**
* Returns the top module(s) for given verilog file.
*/
public static String[] getTopModuleNames(IFile file) {
OutlineElement[] outlineElements= getTopModulesVeditor(file);
if (outlineElements==null) return null;
String [] list = new String[outlineElements.length];
for (int i=0;i<list.length;i++) {
list[i] = outlineElements[i].getName();
}
return list;
}
/**
* Returns the top module for given verilog file.
*/
public static OutlineElement getTopModuleVeditor(IFile file) {
OutlineElement[] outlineElements= getTopModulesVeditor(file);
if ((outlineElements!=null) && (outlineElements.length>0)) return outlineElements[0];
else
return null;
} // getTopModuleVeditor()
public static OutlineElement[] getTopModulesVeditor(IFile file) {
IProject project = file.getProject();
OutlineDatabase outlineDatabase=getVeditorOutlineDatabase(project);
OutlineContainer outlineContainer=outlineDatabase.getOutlineContainer(file);
if (outlineContainer != null) {
OutlineElement[] allTopElements=outlineContainer.getTopLevelElements();
ArrayList<OutlineElement> list = new ArrayList<OutlineElement>();
for (int i=0;i<allTopElements.length;i++){
if (allTopElements[i].getParent()==null) list.add(allTopElements[i]);
}
return list.toArray(new OutlineElement[0]);
} else
return null;
} // getTopModulesVeditor()
/**
* Returns dependency closure for given verilog file.
*/
public static IFile[] getDependencies(IFile [] topFiles) {
if (topFiles==null) return null;
IProject project = topFiles[0].getProject();
OutlineDatabase outlineDatabase=getVeditorOutlineDatabase(project);
return outlineDatabase.getClosureSorted(topFiles);
} // getDependencies()
public static IFile[] getDependencies(IFile topFile) {
return getDependencies(new IFile [] {topFile});
}
/* for now all modules, including library ones */
public static OutlineElement[] getModuleListVeditor(IProject project) {
OutlineDatabase database=getVeditorOutlineDatabase(project);
return database.findTopLevelElements(""); // get all top level elements
}
/**
* Returns all verilog modules from given file.
*/
public static OutlineElement[] getModuleListVeditor(IFile file) {
IProject project = file.getProject();
OutlineContainer outlineContainer=getVeditorOutlineDatabase(project).getOutlineContainer(file);
if (outlineContainer != null) {
return outlineContainer.getTopLevelElements();
} else
return null;
}
/**
* Returns true if module with such name elready exists in given file.
*/
/*
public static boolean existsModule(IFile file, String moduleName) {
IProject project = file.getProject();
getModuleListManager().setCurrent(project);
ModuleList projectModules = getModuleListManager().find(project);
Set<String> modules = new HashSet<String>();
for (Iterator<Module> i = projectModules.iterator(); i.hasNext(); ) {
Module module = i.next();
if (module.getSourceFile().getFile().getFullPath().equals(file.getFullPath()))
modules.add(module.getName());
}
return modules.contains(moduleName);
}
*/
/**
* Returns all verilog files in specified container.
*/
//Not used?
public static IFile[] getVerilogFiles(IContainer parent) {
List<IFile> files = new ArrayList<IFile>();
getVerilogFiles(parent, files);
return (IFile[])files.toArray(new IFile[files.size()]);
} // getVerilogFiles()
private static void getVerilogFiles(IContainer parent, List<IFile> list) {
try {
IResource[] members = parent.members();
for (int i = 0; i < members.length; i++) {
IResource resource = members[i];
if (resource instanceof IContainer) {
getVerilogFiles((IContainer)resource, list);
}
if (resource instanceof IFile) {
IFile file = (IFile)resource;
if (file.getName().endsWith(".v"))
list.add((IFile)resource);
}
}
} catch (CoreException e) {
}
} // getVerilogFiles()
/*
private static SourceFile getSourceFile(IFile file) {
IProject project = file.getProject();
getModuleListManager().setCurrent(project);
ModuleList projectModules = getModuleListManager().find(project);
SourceFile sourceFile = projectModules.findSourceFile(file);
return sourceFile;
} // getSourceFile()
public static final ModuleListManager getModuleListManager() {
return ModuleListManager.getDefault();
}
*/
} // class VerilogUtils
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core;
import java.util.*;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import com.elphel.vdt.ui.MessageUI;
/**
* Utilities for VDT Plud-in.
*
* Created: 22.12.2005
* @author Lvov Konstantin
*/
public class Utils {
public static final int OS_WINDOWS = 1;
public static final int OS_LINUX = 2;
private static int os;
public static boolean isWindows() {
return os == OS_WINDOWS;
}
public static boolean isLinux() {
return os == OS_LINUX;
}
/** Returns the pure file name without path and extensions. */
public static String getPureFileName(String fileName) {
if ((fileName == null) || (fileName.length() == 0))
return "";
int dot_pos = fileName.lastIndexOf(".");
if (dot_pos == -1)
return fileName;
else
return fileName.substring(0, dot_pos);
}
public static boolean stringContainsSpace(String s) {
return s.contains(" ") || s.contains("\n");
}
public static boolean stringEndsWithSpace(String s) {
return s.endsWith(" ") || s.endsWith("\n");
}
public static boolean stringStartsWithSpace(String s) {
return s.startsWith(" ") || s.startsWith("\n");
}
public static boolean isAlpha(char c) {
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
}
public static boolean isDigit(char c) {
return c >= '0' && c <= '9';
}
public static boolean isSpace(char ch) {
return ch == ' ' || ch == '\t';
}
public static boolean isNewLine(char ch) {
return ch == '\n';
}
public static int findBoundary(String s) {
return findBoundary(s, 0);
}
public static int findBoundary(String s, int from) {
for(int i = from; i < s.length(); i++) {
char ch = s.charAt(i);
if(!Utils.isAlpha(ch) && !Utils.isDigit(ch) && !isAuxStrChar(ch))
return i;
}
return s.length();
}
public static boolean containsStr(List<String> list, String str) {
for(Iterator<String> i = list.iterator(); i.hasNext();)
if(((String)i.next()).equals(str))
return true;
return false;
}
public static String listToString(List<String> list) {
String str = "";
for(Iterator<String> i = list.iterator(); i.hasNext();)
str += (String)i.next();
return str;
}
private static boolean isAuxStrChar(char ch) {
return ch == '_';
}
static {
String osName = System.getProperty("os.name");
if(osName.indexOf("Windows") >= 0)
os = OS_WINDOWS;
else if (osName.indexOf("Linux") >= 0)
os = OS_LINUX;
else
MessageUI.fatalError("Unknown os.name");
}
/**
* Add this nature to the project
*/
public static void addNature( String natureID
, IProject project
, IProgressMonitor monitor ) throws CoreException
{
if (monitor == null) {
monitor = new NullProgressMonitor();
} else if (monitor != null && monitor.isCanceled()) {
throw new OperationCanceledException();
}
if (!project.hasNature(natureID)) {
IProjectDescription description = project.getDescription();
String[] prevNatures= description.getNatureIds();
String[] newNatures= new String[prevNatures.length + 1];
System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
newNatures[prevNatures.length]= natureID;
description.setNatureIds(newNatures);
project.setDescription(description, monitor);
} else
monitor.worked(1);
}
/**
* Add this nature to the project
*/
public static void removeNature( String natureID
, IProject project
, IProgressMonitor monitor ) throws CoreException
{
if (monitor == null) {
monitor = new NullProgressMonitor();
} else if (monitor != null && monitor.isCanceled()) {
throw new OperationCanceledException();
}
if (project.hasNature(natureID)) {
IProjectDescription description = project.getDescription();
String[] prevNatures = description.getNatureIds();
String[] newNatures = new String[prevNatures.length - 1];
int i = 0;
for (String id : prevNatures) {
if (! natureID.equals(id))
newNatures[i] = id;
i++;
}
description.setNatureIds(newNatures);
project.setDescription(description, monitor);
} else
monitor.worked(1);
}
} // class Utils
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.launching;
import java.util.ArrayList;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
/**
* Launching Verilog development tools programmatically via
* Exteranl Tool plug-in.
*
* Created: 26.12.2005
* @author Lvov Konstantin
*/
public class ExternalToolLauncher {
public static void launch( final ExternalToolLauncherConfiguration config
) throws CoreException
{
// get external tools launch configuration
ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType type = manager.getLaunchConfigurationType(IExternalToolConstants.ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE);
// set external tools launch configuration
ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, config.getConfigurationName());
workingCopy.setAttribute(IExternalToolConstants.ATTR_LOCATION, config.getToolToLaunch());
workingCopy.setAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, config.getWorkingDirectory());
String toolArguments = "";
String[] argumentList = config.getToolArguments();
for (int i=0; i < argumentList.length; i++) {
toolArguments += argumentList[i] + " ";
}
workingCopy.setAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, toolArguments);
workingCopy.setAttribute(IDebugUIConstants.ATTR_PRIVATE, config.getPrivateMode());
workingCopy.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, true);
System.out.println( "*** Launching tool through vdt/core/launching/ExternalToolLauncher.java ****\n"+
"Tool ("+config.getToolToLaunch()+") arguments are: "+toolArguments);
// launch
ILaunchConfiguration extToolConfig = workingCopy.doSave();
DebugUITools.launch(extToolConfig, ILaunchManager.RUN_MODE);
} // launch
} // class ExternalToolLauncher
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.launching;
/**
* Verilog launch configuration to launch via Exteranl Tool plug-in.
*
* Created: 26.12.2005
* @author Lvov Konstantin
*/
public class ExternalToolLauncherConfiguration extends VDTRunnerConfiguration {
private String configurationName;
private boolean privateMode;
public ExternalToolLauncherConfiguration( String configurationName
, String toolToLaunch ) {
super(toolToLaunch);
this.configurationName = configurationName;
this.privateMode = false;
} // ExternalToolLauncherConfiguration
public String getConfigurationName() {
return configurationName;
}
public void setPrivateMode(boolean privateMode) {
this.privateMode = privateMode;
}
public boolean getPrivateMode() {
return privateMode;
}
} // class ExternalToolLauncherConfiguration
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.launching;
import java.util.*;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.Launch;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.swt.SWT;
import org.eclipse.ui.PlatformUI;
import com.elphel.vdt.Txt;
import com.elphel.vdt.VDT;
//import com.elphel.vdt.VDTPlugin;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.core.options.OptionsCore;
import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.core.tools.contexts.PackageContext;
import com.elphel.vdt.core.tools.params.Parameter;
import com.elphel.vdt.core.tools.params.Tool;
import com.elphel.vdt.core.tools.params.ToolException;
import com.elphel.vdt.ui.MessageUI;
import com.elphel.vdt.ui.dialogs.PackageLocationDialog;
import com.elphel.vdt.ui.dialogs.ToolLocationDialog;
import com.elphel.vdt.ui.preferences.PreferencePage;
/**
* Support for launching verilog development tools programmatically.
*
* Created: 22.12.2005
* @author Lvov Konstantin
*/
public class LaunchCore {
/**
* Construct attribute name for value of tool parameter. This attribute
* is used to show value in tab group.
*
* @return an attribute name for value of tool parameter
*/
public static String getValueAttributeName(Parameter toolParameter) {
return "ATTR_VALUE_" + toolParameter.getID();
}
public static void setResource( ILaunchConfigurationWorkingCopy workingCopy
, String resource )
{
workingCopy.setAttribute(VDT.ATTR_RESOURCE_TO_LAUNCH, resource);
} // setResource()
public static void setWorkingDirectory( ILaunchConfigurationWorkingCopy workingCopy
, IProject project )
{
workingCopy.setAttribute(VDT.ATTR_WORKING_DIRECTORY, project.getLocation().toOSString());
} // setWorkingDirectory()
/* TODO: For now they are the same, implement build directory differnt from project path */
/* Currently project path is only used to find launched project by it */
public static void setProjectPath ( ILaunchConfigurationWorkingCopy workingCopy
, IProject project )
{
workingCopy.setAttribute(VDT.ATTR_PROJECT_PATH, project.getLocation().toOSString());
} // setProjectPath()
public static void setToolToLaunch( ILaunchConfigurationWorkingCopy workingCopy
, Tool tool ) throws CoreException
{
workingCopy.setAttribute(VDT.ATTR_TOOL_ID, tool.getName());
String launchName = getToolLaunchName(tool);
workingCopy.setAttribute(VDT.ATTR_TOOL_TO_LAUNCH, launchName);
/* TODO: Will it be used ? probably not as the whole Tool object is cloned by the named */
workingCopy.setAttribute(VDT.ATTR_TOOL_IS_SHELL, tool.getIsShell());
workingCopy.setAttribute(VDT.ATTR_TOOL_ERRORS, tool.getPatternErrors());
workingCopy.setAttribute(VDT.ATTR_TOOL_WARNINGS, tool.getPatternWarnings());
workingCopy.setAttribute(VDT.ATTR_TOOL_INFO, tool.getPatternInfo());
}
public static void updateLaunchConfiguration( ILaunchConfigurationWorkingCopy workingCopy
, Tool tool ) throws CoreException
{
for (Iterator i = tool.getParams().iterator(); i.hasNext(); ) {
Parameter param = (Parameter)i.next();
String valueAttrName = LaunchCore.getValueAttributeName(param);
if(param.getType().isList())
workingCopy.setAttribute(valueAttrName, param.getValue());
else
workingCopy.setAttribute(valueAttrName, param.getValue().get(0));
}
setToolToLaunch(workingCopy, tool);
String launchType;
try {
launchType = workingCopy.getType().getIdentifier();
} catch (Exception e) {
launchType = VDT.ID_DEFAULT_LAUNCH_TYPE;
}
if (VDT.ID_DEFAULT_LAUNCH_TYPE.equals(launchType))
workingCopy.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true);
workingCopy.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, true);
} // updateLaunchConfiguration()
public static void updateContextOptions(Tool tool, IProject project) throws ToolException, CoreException {
PackageContext packageContext = tool.getParentPackage();
if (packageContext != null) {
OptionsCore.doLoadContextOptions(packageContext);
String location = OptionsCore.getPackageLocation(packageContext);
if (location == null) {
PackageLocationDialog dialog = new PackageLocationDialog(VerilogPlugin.getActiveWorkbenchShell(), SWT.OPEN, packageContext);
location = dialog.open();
if (location == null) {
throw new DebugException(new Status(IStatus.CANCEL, VDT.ID_VDT, IStatus.CANCEL, "Launching was cancelled", null));
}
OptionsCore.doStorePackageLocation(packageContext, location);
}
packageContext.setWorkingDirectory(project.getLocation().toOSString()); /* TODO - Modify for actual directory */
packageContext.buildParams();
}
Context context = tool.getParentProject();
if (context != null) {
OptionsCore.doLoadContextOptions(context, project);
context.setWorkingDirectory(project.getLocation().toOSString());
context.buildParams();
}
OptionsCore.doLoadContextOptions(tool, project);
OptionsCore.doLoadLocation(tool);
} // updateContextOptions()
public static ILaunchConfiguration createLaunchConfiguration( Tool tool
, IProject project
, String resource
) throws CoreException
{
// get tools launch configuration
ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
// String configName = tool.getLabel();
String configName = tool.getEscapedLabel();
String launchType = null;//tool.getLaunchType();
if (launchType == null)
launchType = VDT.ID_DEFAULT_LAUNCH_TYPE;
ILaunchConfigurationType type = manager.getLaunchConfigurationType(launchType);
// delete any existing launch configuration with the same name
ILaunchConfiguration[] configurations = manager.getLaunchConfigurations(type);
for (int i = 0; i < configurations.length; i++) {
ILaunchConfiguration configuration = configurations[i];
if (configName.equals(configuration.getName())) {
configuration.delete();
break;
}
}
// set tools launch configuration
try {
updateContextOptions(tool, project);
} catch (ToolException e) {
// MessageUI.error( "Cannot save configuration of \""+tool.getLabel()+"\"\n"
MessageUI.error( "Cannot save configuration of \""+tool.getEscapedLabel()+"\"\n"
+ e.getMessage(), e );
}
ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, configName);
updateLaunchConfiguration(workingCopy, tool);
setResource(workingCopy, resource);
setWorkingDirectory(workingCopy, project);
setProjectPath(workingCopy, project);
ILaunchConfiguration launchConfig = workingCopy.doSave();
return launchConfig;
} // createLaunchConfiguration()
public static void launch(Tool tool, IProject project) throws CoreException {
launch(tool, project, VDT.VARIABLE_RESOURCE_NAME);
}
public static void launch(Tool tool, IProject project, String resource) throws CoreException {
try {
ILaunchConfiguration launchConfig = createLaunchConfiguration(tool, project, resource);
DebugUITools.launch(launchConfig, ILaunchManager.RUN_MODE);
} catch (CoreException e) {
IStatus status = e.getStatus();
if (status.getSeverity() != IStatus.CANCEL)
throw e;
}
} // launch()
private static String getToolLaunchName(Tool tool) throws CoreException {
String location = tool.getExeName();
if (isValidLaunchName(location))
return location;
location = PreferencePage.getLocation(tool);
tool.setLocation(location);
location = tool.getExeName();
if (isValidLaunchName(location))
return location;
ToolLocationDialog dialog = new ToolLocationDialog(VerilogPlugin.getActiveWorkbenchShell(), SWT.OPEN, tool);
location = dialog.open();
if (location == null) {
throw new DebugException(new Status(IStatus.CANCEL, VDT.ID_VDT, IStatus.CANCEL, "Launching was cancelled", null));
}
PreferencePage.setLocation(tool, location);
return tool.getExeName();
} // getToolLaunchName()
private static boolean isValidLaunchName(final String location) {
if ((location == null) || (location.length() == 0))
return false;
File file = new File(location);
return file.isFile() && file.exists();
}
private static final String JOB_NAME = Txt.s("Launch.JobName");
/**
* Launches the given run configuration in a background Job with progress
* reported via the Job. Exceptions are reported in the Progress view.
*/
public static void launchInBackground(final VDTRunnerConfiguration configuration) {
if (!saveAllEditors(true)) {
return;
}
Job job = new Job(JOB_NAME) {
public IStatus run(final IProgressMonitor monitor) {
try {
if (!monitor.isCanceled()) {
launch(configuration, monitor);
}
} catch (CoreException e) {
final IStatus status= e.getStatus();
return status;
}
return Status.OK_STATUS;
}
};
job.setPriority(Job.INTERACTIVE);
job.schedule();
} // launchInBackground()
/**
* Launches the given run configuration in the foreground with a progress
* dialog. Reports any exceptions that occur in an error dialog.
*/
public static void launchInForeground(final VDTRunnerConfiguration configuration) {
if (!saveAllEditors(true)) {
return;
}
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
launch(configuration, monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
}
};
try {
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(runnable);
} catch (InvocationTargetException e) {
handleInvocationTargetException(e);
} catch (InterruptedException e) {
}
} // launchInForeground()
// public static void launch( final VDTRunnerConfiguration configuration
// ) throws CoreException
// {
// launch(configuration, null);
// }
private static void launch( final VDTRunnerConfiguration configuration
, IProgressMonitor monitor
) throws CoreException
{
ILaunch launch = new Launch(null, ILaunchManager.RUN_MODE, null);
launch.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, null);
DebugPlugin.getDefault().getLaunchManager().addLaunch(launch);
VDTRunner runner = VDTLaunchUtil.getRunner();
runner.run(configuration, launch, null);
} // launch()
/**
* Save all dirty editors in the workbench.
* Returns whether the operation succeeded.
*
* @return whether all saving was completed
*/
protected static boolean saveAllEditors(boolean confirm) {
if (VerilogPlugin.getActiveWorkbenchWindow() == null) {
return false;
}
return PlatformUI.getWorkbench().saveAllEditors(confirm);
}
private static void handleInvocationTargetException( InvocationTargetException e) {
Throwable targetException = e.getTargetException();
Throwable t = e;
if (targetException instanceof CoreException) {
t = targetException;
}
if (t instanceof CoreException) {
CoreException ce = (CoreException)t;
if ((ce.getStatus().getSeverity() & (IStatus.ERROR | IStatus.WARNING)) == 0) {
// If the exception is a CoreException with a status other
// than ERROR or WARNING, don't open an error dialog.
return;
}
}
MessageUI.error(t);
} // handleInvocationTargetException()
} // class LaunchCore
/*******************************************************************************
* Copyright (c) 2004, 2006 KOBAYASHI Tadashi and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* KOBAYASHI Tadashi - initial API and implementation
*******************************************************************************/
package com.elphel.vdt.core.launching;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.elphel.vdt.veditor.VerilogPlugin;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.ui.console.FileLink;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.ui.console.IPatternMatchListener;
import org.eclipse.ui.console.PatternMatchEvent;
import org.eclipse.ui.console.TextConsole;
public class VDTErrorParserControl
{
private void reportMissingFile(String filename){
String message = new String();
message=String.format("\"%s\" is not found in the project. MS Windows users, check filename case!!!", filename);
/*
try{
IMarker marker=project.createMarker("com.elphel.vdt.veditor.builderproblemmarker");
IMarker marker=new IMarker(); //project.createMarker("com.elphel.vdt.veditor.builderproblemmarker");
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
marker.setAttribute(IMarker.MESSAGE, message);
}
catch (CoreException e)
{
}
*/
}
private void setProblemMarker(String filename, int level, int lineNumber, String msg)
{
IResource file = getFile(filename);
if (file != null && lineNumber > 0){
VerilogPlugin.setExternalProblemMarker(file, level, lineNumber, msg);
}
else{
reportMissingFile(filename);
}
}
private IFile getFileRecursive(IContainer cont, IPath path) {
try {
for(IResource res: cont.members()) {
if(res instanceof IContainer) {
IFile result = getFileRecursive((IContainer)res,path);
if(result!=null) return result;
} else if(res instanceof IFile) {
IPath res_path = ((IFile)res).getLocation();
if(res_path.equals(path))
return (IFile)res;
}
}
} catch (CoreException e) {
}
return null;
}
// Christian R. aka supachris from http://www.mikrocontroller.net/topic/264288
// mg
private IResource getFile(String filename) {
File TestFile = new File(filename);
IResource test=null;
if(TestFile.isAbsolute())
{
IContainer project = ResourcesPlugin.getWorkspace().getRoot();
IPath projectPath = Path.fromOSString(TestFile.getAbsolutePath());
test = getFileRecursive(project, projectPath);
}
else
{
/*
IPath projectPath = project.getLocation().append(buildConfig.getWorkFolder());
projectPath = projectPath.append(filename);
IContainer project = ResourcesPlugin.getWorkspace().getRoot();
test = getFileRecursive(project,projectPath);
*/
}
return test;
}
public static class ParseErrorString {
private String regex;
// results of parse(String string);
public String filename;
public int linenr;
public String message;
public int startinmatchedstring;
public int endinmatchedstring;
public ParseErrorString(String regexpr) {
regex = regexpr;
}
/**
* Tries to parse string using regex
* @return boolean: parse succeeded
*/
public boolean parse(String string) {
Pattern errPattern = Pattern.compile(regex);
Matcher m = errPattern.matcher(string);
if (!m.matches()) return false;
int groupCount=m.groupCount();
if(groupCount < 3) return false;
int linenrindex = -1;
for(int i=2;i<=groupCount;i++) {
String group = m.group(i);
try {
linenr = Integer.parseInt(group);
linenrindex = i;
}
catch (NumberFormatException e) {
}
}
if(linenrindex==-1) return false;
// filename is now at linenrindex-1
filename = m.group(linenrindex-1);
// now search for the longest string to capture the message:
int length_win=-1;
int messageindex=-1;
for(int i=1;i<=groupCount;i++) {
if(i==linenrindex-1) continue;
if(i==linenrindex) continue;
String group = m.group(i);
if(group.length()>length_win) {
length_win = group.length();
messageindex = i;
}
}
if(messageindex==-1) return false;
message = m.group(messageindex); /* error message (w/o "error") */
startinmatchedstring = m.start(linenrindex-1); /* start of link */
endinmatchedstring = m.end(linenrindex); /* end of link */
return true;
}
}
public class ConsoleParser implements IPatternMatchListener {
private String regex;
private int problemlevel;
ConsoleParser(String regexpr, int level) {
regex = regexpr;
problemlevel = level;
System.out.println("New ConsoleParser(>"+regex+"<, "+level);
}
public int getCompilerFlags() {
return 0;
}
public String getLineQualifier() {
return null;
}
public String getPattern() {
return regex;
}
public void connect(TextConsole console) {
System.out.println("connect");
}
public void disconnect() {
System.out.println("disconnect");
}
public void matchFound(PatternMatchEvent event) {
int offset = event.getOffset();
int length = event.getLength();
Object object = event.getSource();
if(! (object instanceof TextConsole)) return;
TextConsole console = (TextConsole)object;
String consolecontent = console.getDocument().get();
String matchedstring = consolecontent.substring(offset, offset+length); /* matchstring - full matched string in console */
ParseErrorString parser = new ParseErrorString(regex);
boolean success = parser.parse(matchedstring);
if (!success) return;
setProblemMarker(parser.filename, problemlevel, parser.linenr, parser.message); /* liner - line in file */
IResource resource = getFile(parser.filename);
if(resource instanceof IFile) {
IFile file = (IFile) resource;
FileLink hyperlink = new FileLink(file,null,-1,-1,parser.linenr);
try {
console.addHyperlink(hyperlink, offset+parser.startinmatchedstring, /* here makes console blue (in debug mode it lags as is not redrawn immediately */
parser.endinmatchedstring-parser.startinmatchedstring+1);
} catch (BadLocationException e) {
}
} else {
//VerilogPlugin.println("Not a filename!");
}
}
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.launching;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
import com.elphel.vdt.Txt;
import com.elphel.vdt.ui.MessageUI;
/**
* Launch delegate for a Verilog development tools.
*
* Created: 23.12.2005
* @author Lvov Konstantin
*/
public class VDTLaunchConfigurationDelegate implements ILaunchConfigurationDelegate {
private void doLaunch( ILaunchConfiguration configuration
, String mode
, ILaunch launch
, IProgressMonitor monitor
) throws CoreException
{
if (monitor == null) {
monitor = new NullProgressMonitor();
}
monitor.beginTask(Txt.s("Launch.Beginning", new String[]{configuration.getName()}), 4);
if (monitor.isCanceled()) { // check for cancellation
return;
}
monitor.subTask(Txt.s("Launch.CreatingToolArguments"));
// resolve tool location
IPath toolToLaunch = VDTLaunchUtil.getToolToLaunch(configuration);
// Create run config
VDTRunnerConfiguration runConfig = new VDTRunnerConfiguration(toolToLaunch.toOSString());
// resolve environment
runConfig.setEnvironment(VDTLaunchUtil.getEnvironment(configuration));
// resolve working directory
runConfig.setWorkingDirectory(VDTLaunchUtil.getWorkingDirectory(configuration));
runConfig.setProjectPath(VDTLaunchUtil.getProjectPath(configuration));
// done the half of creating arguments phase
monitor.worked(1);
// resolve arguments
List<String> arguments = VDTLaunchUtil.getArguments(configuration);
// get tool is a shell
boolean isShell=VDTLaunchUtil.getIsShell(configuration);
// get patterns for Error parser
String patternErrors= VDTLaunchUtil.getPatternErrors(configuration);
String patternWarnings=VDTLaunchUtil.getPatternWarnings(configuration);
String patternInfo= VDTLaunchUtil.getPatternInfo(configuration);
// check for cancellation
if (monitor.isCanceled()) {
return;
}
// done the creating arguments phase
monitor.worked(2);
// resolve resources
// List<String> resources = VDTLaunchUtil.getResources(configuration);
// check for cancellation
if (monitor.isCanceled()) {
return;
}
// done the creating arguments phase
monitor.worked(3);
// resolve arguments
List<String> toolArguments = new ArrayList<String>();
if (arguments != null)
toolArguments.addAll(arguments);
// if (resources != null)
// toolArguments.addAll(resources);
runConfig.setToolArguments((String[])toolArguments.toArray(new String[toolArguments.size()]));
runConfig.setIsShell(isShell);
runConfig.setPatternErrors(patternErrors);
runConfig.setToolName(VDTLaunchUtil.getToolName(configuration));
runConfig.setPatternWarnings(patternWarnings);
runConfig.setPatternInfo(patternInfo);
runConfig.setToolProjectPath(VDTLaunchUtil.getToolProjectPath(configuration));
List<String> controlFiles = VDTLaunchUtil.getControlFiles(configuration);
runConfig.setControlFiles((String[])controlFiles.toArray(new String[controlFiles.size()]));
// Launch the configuration - 1 unit of work
VDTRunner runner = VDTLaunchUtil.getRunner();
runner.run(runConfig, launch, monitor);
// check for cancellation
if (monitor.isCanceled()) {
return;
}
monitor.done();
}
public void launch( ILaunchConfiguration configuration
, String mode
, ILaunch launch
, IProgressMonitor monitor
) throws CoreException
{
try {
doLaunch(configuration, mode, launch, monitor);
} catch(Exception e) {
MessageUI.error(e);
if(e instanceof CoreException)
throw (CoreException)e;
}
}
} // class VDTLaunchConfigurationDelegate
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.launching;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IFile;
//import org.eclipse.core.resources.IFolder;
//import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
//import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.variables.IStringVariableManager;
import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import com.elphel.vdt.Txt;
import com.elphel.vdt.VDT;
import com.elphel.vdt.VerilogUtils;
// import com.elphel.vdt.VDTPlugin;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.core.tools.ToolsCore;
import com.elphel.vdt.core.tools.params.Parameter;
import com.elphel.vdt.core.tools.params.Tool;
import com.elphel.vdt.core.tools.params.ToolException;
//import com.elphel.vdt.core.verilog.VerilogUtils;
import com.elphel.vdt.ui.MessageUI;
/**
* Utilities for Verilog development tool launch configurations.
*
* Created: 23.12.2005
* @author Lvov Konstantin
*/
public class VDTLaunchUtil {
private static VDTRunner toolRunner;
/**
* Returns the VDT runner.
*/
public static VDTRunner getRunner() {
if (toolRunner == null)
toolRunner = new VDTRunner();
return toolRunner;
}
/**
* Construct attribute name for command line representations of
* tool parameter.
*
* @return an attribute name for tool parameter
*/
public static String getLaunchAttributeName(Parameter toolParameter) {
return "ATTR_" + toolParameter.getID();
}
/**
* Expands and returns the location attribute of the given launch
* configuration. The location is verified to point to an existing
* file, in the local file system.
*
* @param configuration launch configuration
* @return an absolute path to a file in the local file system
* @throws CoreException if unable to retrieve the associated launch
* configuration attribute, if unable to resolve any variables, or if the
* resolved location does not point to an existing file in the local file
* system
*/
public static IPath getToolToLaunch(ILaunchConfiguration configuration) throws CoreException {
String location = configuration.getAttribute(VDT.ATTR_TOOL_TO_LAUNCH, (String) null);
if (location == null) {
abort(Txt.s("Launch.Error.ToolLocation", new String[] { configuration.getName()}), null);
} else {
String expandedLocation = getStringVariableManager().performStringSubstitution(location);
if (expandedLocation == null || expandedLocation.length() == 0) {
String msg = Txt.s("Launch.Error.InvalidLocation", new Object[] { configuration.getName()});
abort(msg, null);
} else {
File file = new File(expandedLocation);
if (file.isFile()) {
return new Path(expandedLocation);
}
String msg = Txt.s("Launch.Error.InvalidLocation", new Object[] { configuration.getName()});
abort(msg, null);
}
}
// execution will not reach here
return null;
} // getToolToLaunch
/**
* Returns the arguments attribute of the given launch
* configuration. Returns <code>null</code> if arguments are not specified.
*
* @param configuration launch configuration
* @return a list of resolved arguments, or <code>null</code> if unspecified
* @throws CoreException if unable to retrieve the associated launch
* configuration attribute, or if unable to resolve any variables
*/
public static List<String> getArguments(ILaunchConfiguration configuration) throws CoreException {
Tool tool = obtainTool(configuration);
for (Iterator i = tool.getParams().iterator(); i.hasNext(); ) {
Parameter param = (Parameter)i.next();
String valueAttrName = LaunchCore.getValueAttributeName(param);
try {
if(param.getType().isList()) {
List<String> value =
configuration.getAttribute(valueAttrName, param.getDefaultValue());
param.setCurrentValue(value);
} else {
String value = configuration.getAttribute(valueAttrName, param.getDefaultValue().get(0));
param.setCurrentValue(value);
}
} catch(ToolException e) {
MessageUI.error("Error occured during tool launch: " + e.getMessage(), e);
return null;
}
}
try {
String location = getWorkingDirectory(configuration);
tool.setWorkingDirectory(location);
String[] paramArray = tool.buildParams();
List<String> arguments = new ArrayList<String>(paramArray.length);
for(int i = 0; i < paramArray.length; i++) {
arguments.add(paramArray[i]);
}
return arguments;
} catch(ToolException e) {
MessageUI.error("Error occured during tool launch: " + e.getMessage(), e);
}
return null;
} // getArguments()
public static boolean getIsShell(ILaunchConfiguration configuration) throws CoreException {
Tool tool = obtainTool(configuration);
return tool.getIsShell();
}
public static String getToolProjectPath(ILaunchConfiguration configuration) throws CoreException {
Tool tool = obtainTool(configuration);
return tool.getToolProjectPath();
}
public static String getPatternErrors(ILaunchConfiguration configuration) throws CoreException {
Tool tool = obtainTool(configuration);
return tool.getPatternErrors();
}
public static String getToolName(ILaunchConfiguration configuration) throws CoreException {
Tool tool = obtainTool(configuration);
return tool.getName();
}
public static String getPatternWarnings(ILaunchConfiguration configuration) throws CoreException {
Tool tool = obtainTool(configuration);
return tool.getPatternWarnings();
}
public static String getPatternInfo(ILaunchConfiguration configuration) throws CoreException {
Tool tool = obtainTool(configuration);
return tool.getPatternInfo();
}
public static List<String> getControlFiles(ILaunchConfiguration configuration) throws CoreException {
Tool tool = obtainTool(configuration);
return tool.getCreatedControlFiles();
}
/**
* Returns the resources attribute of the given launch
* configuration. Returns <code>null</code> if resources are not specified.
*
* @param configuration launch configuration
* @return a list of resolved resources, or <code>null</code> if unspecified
* @throws CoreException if unable to retrieve the associated launch
* configuration attribute, or if unable to resolve any variables
*/
public static List<String> getResources(ILaunchConfiguration configuration) throws CoreException {
String resourceAttr = configuration.getAttribute(VDT.ATTR_RESOURCE_TO_LAUNCH, (String) null);
if (resourceAttr != null) {
String resourcePath = getStringVariableManager().performStringSubstitution(resourceAttr);
// IResource resource = VDTPlugin.getWorkspace().getRoot().findMember(resourcePath);
IResource resource = VerilogPlugin.getWorkspace().getRoot().findMember(resourcePath);
if (resource != null) {
// List<String> resources = new ArrayList<String>(1);
// resources.add(resource.getLocation().toOSString());
// return resources;
// return parseVerilogFile(resource);
if (resource instanceof IFile) {
List<String> resourcesLocation = getVerilogFileDependencies((IFile)resource);
// resourcesLocation.add(resource.getLocation().toOSString());
return resourcesLocation;
}
}
}
return null;
} // getResources()
private static List<String> getVerilogFileDependencies(IFile file) throws CoreException {
// StackTraceElement frame = new Exception().getStackTrace()[0];
// System.out.println("*** Broken core/tools/generators in "+frame.getFileName()+":"+frame.getLineNumber());
// return null;
IFile[] dependencies = VerilogUtils.getDependencies(file);
List<String> dependenciesLocation = new ArrayList<String>();
if(dependencies != null) {
for (int i=0; i < dependencies.length; i++) {
dependenciesLocation.add(dependencies[i].getLocation().toOSString());
// System.out.println(" "+dependencies[i].getName());
}
}
return dependenciesLocation;
}
/**
* Returns an array of environment variables to be used when
* launching the given configuration or <code>null</code> if unspecified.
*
* @param configuration launch configuration
* @throws CoreException if unable to access associated attribute or if
* unable to resolve a variable in an environment variable's value
*/
public static String[] getEnvironment(ILaunchConfiguration configuration) throws CoreException {
return DebugPlugin.getDefault().getLaunchManager().getEnvironment(configuration);
}
/**
* Expands and returns the working directory attribute of the given launch
* configuration. Returns <code>null</code> if a working directory is not
* specified. If specified, the working is verified to point to an existing
* directory in the local file system.
*
* @param configuration launch configuration
* @return an absolute path to a directory in the local file system, or
* <code>null</code> if unspecified
* @throws CoreException if unable to retrieve the associated launch
* configuration attribute, if unable to resolve any variables, or if the
* resolved location does not point to an existing directory in the local
* file system
*/
public static String getWorkingDirectory(ILaunchConfiguration configuration) throws CoreException {
String location = configuration.getAttribute(VDT.ATTR_WORKING_DIRECTORY, (String) null);
if (location != null) {
String expandedLocation = getStringVariableManager().performStringSubstitution(location);
if (expandedLocation.length() > 0) {
File path = new File(expandedLocation);
if (path.isDirectory()) {
return expandedLocation;
}
String message = "The working directory \""+expandedLocation+"\"does not exist for the external tool named "+configuration.getName()+".";
abort(message, null);
}
}
return null;
}
public static String getProjectPath(ILaunchConfiguration configuration) throws CoreException {
return configuration.getAttribute(VDT.ATTR_PROJECT_PATH, (String) null);
}
private static Tool obtainTool(ILaunchConfiguration configuration) throws CoreException {
String toolID = configuration.getAttribute(VDT.ATTR_TOOL_ID, (String) null);
if (toolID == null)
abort("Tool id is undefined in launch configuration "+configuration.getName(), null);
Tool tool = ToolsCore.getToolWorkingCopy(toolID);
if (tool == null)
abort("Tool \""+toolID+"\" is unknown", null);
return tool;
}
private static IStringVariableManager getStringVariableManager() {
return VariablesPlugin.getDefault().getStringVariableManager();
}
/**
* Throws a core exception with an error status object built from
* the given message, lower level exception, and error code.
*
* @param message the status message
* @param exception lower level exception associated with the
* error, or <code>null</code> if none
* @param code error code
*/
protected static void abort(String message, Throwable exception) throws CoreException {
throw new CoreException(new Status(IStatus.ERROR,
VDT.ID_VDT,
IStatus.ERROR,
message,
exception));
}
/*
private static VerilogProject getVerilogProject(String projectName) {
IProject projects[] = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for (int i=0; i < projects.length; i++) {
if ( projectName.equals(projects[i].getName()) ) {
return new VerilogProject(projects[i]);
}
}
return null;
} // getVerilogProject()
private static class VerilogProject {
private List<String> sourceFiles = new ArrayList<String>();
public VerilogProject(IProject project) {
// System.out.println("Projects file:");
findProjectSourceFile(project);
} // VerilogProject()
private void findProjectSourceFile(IProject project) {
IResource resources[];
try {
resources = project.members(0);
} catch (CoreException e) {
MessageUI.error(e);
return;
}
for (int i=0; i < resources.length; i++) {
IResource res = resources[i];
// System.out.println(" "+res.getLocation().toOSString());
switch (res.getType()) {
case IResource.FILE:
if (res.getName().endsWith(".v"))
sourceFiles.add(res.getLocation().toOSString());
break;
case IResource.FOLDER:
findFolderSourceFiles((IFolder)res);
default:
break;
}
}
} // findProjectSourceFile()
private void findFolderSourceFiles(IFolder folder) {
IResource resources[];
try {
resources = folder.members(0);
} catch (CoreException e) {
MessageUI.error(e);
return;
}
for (int i=0; i < resources.length; i++) {
IResource res = resources[i];
// System.out.println(" "+res.getLocation().toOSString());
switch (res.getType()) {
case IResource.FILE:
if (res.getName().endsWith(".v"))
sourceFiles.add(res.getLocation().toOSString());
break;
case IResource.FOLDER:
findFolderSourceFiles((IFolder)res);
default:
break;
}
}
} // findFolderSourceFiles()
public List<String> getSourceFiles() {
return sourceFiles;
}
} // class ProjectVerilogFiles
*/
} // class VDTLaunchUtil
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.launching;
import java.io.File;
import java.text.DateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsole;
import org.eclipse.ui.console.IConsoleManager;
import org.eclipse.ui.console.IPatternMatchListener;
import org.eclipse.ui.console.MessageConsole;
import com.elphel.vdt.Txt;
//import com.elphel.vdt.VDTPlugin;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.preference.PreferenceStrings;
import com.elphel.vdt.core.Utils;
/**
* Verilog development tool runner.
*
* Created: 22.12.2005
* @author Lvov Konstantin
*/
public class VDTRunner {
/**
* Returns a new process aborting if the process could not be created.
* @param launch the launch the process is contained in
* @param p the system process to wrap
* @param label the label assigned to the process
* @param attributes values for the attribute map
* @return the new process
* @throws CoreException problems occurred creating the process
*/
protected IProcess newProcess(ILaunch launch, Process p, String label, Map attributes) throws CoreException {
IProcess process= DebugPlugin.newProcess(launch, p, label, attributes);
if (process == null) {
p.destroy();
abort(Txt.s("Launch.Process.Error"), null, IStatus.ERROR);
}
return process;
}
/** @see DebugPlugin#exec(String[], File, String[]) */
protected Process exec(String[] cmdLine, File workingDirectory, String[] envp) throws CoreException {
return DebugPlugin.exec(cmdLine, workingDirectory, envp);
}
/**
* Launches a Verilog development tool as specified in the given
* configuration, contributing results (processes), to the given
* launch.
*
* @param configuration the configuration settings for this run
* @param launch the launch to contribute to
* @param monitor progress monitor or <code>null</code>
* @exception CoreException if an exception occurs while launching
*/
public void run( VDTRunnerConfiguration configuration
, ILaunch launch
, IProgressMonitor monitor
) throws CoreException
{
if (monitor == null) {
monitor = new NullProgressMonitor();
}
IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1);
subMonitor.beginTask(Txt.s("Launch.Message.Launching"), 2);
subMonitor.subTask(Txt.s("Launch.Message.ConstructingCommandLine"));
String toolTolaunch = configuration.getToolToLaunch();
String[] arguments = configuration.getToolArguments();
boolean isShell= configuration.getIsShell();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println("patternErrors= \""+ configuration.getPatternErrors()+"\"");
System.out.println("patternWarnings= \""+configuration.getPatternWarnings()+"\"");
System.out.println("patternInfo= \"" +configuration.getPatternInfo()+"\"");
System.out.println((isShell?"Shell":"Tool")+" to launch=\""+toolTolaunch+"\"");
if (arguments!=null){
for (int i=0;i<arguments.length;i++){
System.out.println("Argument "+i+" = \""+arguments[i]+"\"");
}
}
}
String[] cmdLine;
if (isShell && (arguments != null) && (arguments.length > 0)){ /* first argument is passed as a parameter to shell*/
StringBuilder builder = new StringBuilder();
cmdLine = new String[3];
cmdLine[0]=toolTolaunch;
cmdLine[1]=(arguments[0].equals("@EMPTY"))?"":arguments[0]; // Can not be set to empty
for (int i=1;i<arguments.length;i++) {
builder.append(" ");
builder.append(arguments[i]);
}
cmdLine[2]=builder.toString().trim();
} else {
int cmdLineLength = 1;
if (arguments != null) {
cmdLineLength += arguments.length;
}
cmdLine = new String[cmdLineLength];
cmdLine[0] = toolTolaunch;
if (arguments != null) {
System.arraycopy(arguments, 0, cmdLine, 1, arguments.length);
}
}
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
for (int i=0;i<cmdLine.length;i++){
System.out.println("cmdLine["+i+"] = \""+cmdLine[i]+"\"");
}
}
String[] controlFiles = configuration.getControlFiles();
log(cmdLine, controlFiles, false, true); /* Appears in the console of the target Eclipse (immediately erased) */
log(cmdLine, controlFiles, false, false); /* Appears in the console of the parent Eclipse */
String[] envp = configuration.getEnvironment();
subMonitor.worked(1);
// check for cancellation
if (monitor.isCanceled()) {
return;
}
subMonitor.subTask(Txt.s("Launch.Message.Starting"));
File workingDir = getWorkingDir(configuration); /* /data/vdt/runtime-EclipseApplication/x353 */
Process p = exec(cmdLine, workingDir, envp);
if (p == null) {
return;
}
// check for cancellation
if (monitor.isCanceled()) {
p.destroy();
return;
}
/* next actually launches the process */
/* IProcess may set/get client parameters */
VDTErrorParser parser= VerilogPlugin.getVDTErrorParser();
IProcess process= newProcess( launch
, p
, renderProcessLabel(cmdLine)
, getDefaultProcessAttrMap(configuration));
parser.parserSetup(
configuration,
process
);
subMonitor.worked(1);
subMonitor.done();
} // run()
private void log(String[] strings,
String[] controlFiles,
boolean formatColumn,
boolean printToUser)
{
println("Control files created:", printToUser);
if(controlFiles.length == 0) {
println("(none)", printToUser);
} else {
for(int i = 0; i < controlFiles.length; i++)
println(controlFiles[i], printToUser);
}
println(printToUser);
println("Launching:", printToUser);
if(formatColumn)
println(printToUser);
for(int i = 0; i < strings.length; i++)
if(formatColumn)
println("#" + i + ": '" + strings[i] + "'", printToUser);
else
print(strings[i] + " ", printToUser);
if(!formatColumn)
println(printToUser);
println(printToUser);
println("-----------------------------------------------------------------------", printToUser);
println(printToUser);
}
private void println(boolean printToUser) {
println("", printToUser);
}
private void println(String msg, boolean printToUser) {
print(msg + "\n", printToUser);
}
private void print(String msg, boolean printToUser) {
if(printToUser)
VerilogPlugin.print(msg);
else
System.out.print(msg);
}
/**
* Returns the default process attribute map for tool processes.
*
* @return default process attribute map for Java processes
*/
protected Map getDefaultProcessAttrMap(VDTRunnerConfiguration config) {
Map<String, String> map = new HashMap<String, String>();
map.put(IProcess.ATTR_PROCESS_TYPE, Utils.getPureFileName(config.getToolToLaunch()));
return map;
}
/**
* Returns the working directory to use for the launched tool,
* or <code>null</code> if the working directory is to be inherited
* from the current process.
*
* @return the working directory to use
* @exception CoreException if the working directory specified by
* the configuration does not exist or is not a directory
*/
protected File getWorkingDir(VDTRunnerConfiguration config) throws CoreException {
String path = config.getWorkingDirectory();
if (path == null) {
return null;
}
File dir = new File(path);
if (!dir.isDirectory()) {
abort(Txt.s("Launch.Error.InvalidWorkingDir", new String[] {path}), null, IStatus.ERROR);
}
return dir;
}
/**
* Throws a core exception with an error status object built from
* the given message, lower level exception, and error code.
*
* @param message the status message
* @param exception lower level exception associated with the
* error, or <code>null</code> if none
* @param code error code
* @throws CoreException The exception encapsulating the reason for the abort
*/
protected void abort(String message, Throwable exception, int code) throws CoreException {
throw new CoreException(new Status(IStatus.ERROR, VerilogPlugin.getVdtId(), code, message, exception));
}
public static String renderProcessLabel(String[] commandLine) {
String timestamp= DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(new Date(System.currentTimeMillis()));
return Txt.s("Launch.Process.LabelFormat", new String[] {commandLine[0], timestamp});
}
protected static String renderCommandLine(String[] commandLine) {
if (commandLine.length == 0)
return "";
return " " + new File(commandLine[0]).getName();
}
} // class VDTRunner
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.launching;
import com.elphel.vdt.Txt;
/**
* Holder for various arguments passed to a Verilog development tool runner.
* Mandatory parameters are passed in the constructor; optional arguments,
* via setters.
*
* Created: 22.12.2005
* @author Lvov Konstantin
*
* @see org.eclipse.jdt.launching.VMRunnerConfiguration
*/
public class VDTRunnerConfiguration {
private String toolToLaunch;
private String toolProjectPath;
private String[] toolArgs;
private String[] environment;
private String workingDirectory;
private String projectPath;
private String[] controlFiles;
private boolean isShell=false;
private String toolName;
private String toolErrors;
private String toolWarnings;
private String toolInfo;
private static final String[] empty= new String[0];
/**
* Creates a new configuration for launching a tool to run
* the given tool name.
*
* @param toolToLaunch The fully qualified name of the tool to launch. May not be null.
*/
public VDTRunnerConfiguration(String toolToLaunch) {
if (toolToLaunch == null) {
throw new IllegalArgumentException(Txt.s("Launch.Error.ToolNotNull"));
}
this.toolToLaunch = toolToLaunch;
}
/**
* Returns the name of the class to launch.
*
* @return The fully qualified name of the class to launch. Will not be <code>null</code>.
*/
public String getToolToLaunch() {
return toolToLaunch;
}
public String getToolProjectPath(){
return toolProjectPath;
}
public void setToolProjectPath(String toolProjectPath){
this.toolProjectPath=toolProjectPath;
}
/**
* Sets the custom tool arguments.
* These arguments will not be interpreted by a runner, the client is
* responsible for passing arguments compatible with a particular tool.
*
* @param args the list of arguments
*/
public void setToolArguments(String[] args) {
toolArgs= args;
}
public void setIsShell(boolean isShell) {
this.isShell= isShell;
}
public boolean getIsShell() {
return isShell;
}
public String getPatternErrors() {
return this.toolErrors;
}
public String getPatternWarnings() {
return this.toolWarnings;
}
public String getPatternInfo() {
return this.toolInfo;
}
public void setToolName(String str) {
this.toolName=str;
}
public String getToolName() {
return toolName;
}
public void setPatternErrors(String str) {
this.toolErrors=str;
}
public void setPatternWarnings(String str) {
this.toolWarnings=str;
}
public void setPatternInfo(String str) {
this.toolInfo=str;
}
/**
* Returns the arguments to the tool.
*
* @return The toll arguments. Default is an empty array. Will not be <code>null</code>.
* @see #setToolArguments(String[])
*/
public String[] getToolArguments() {
if (toolArgs == null) {
return empty;
}
return toolArgs;
}
/**
* Sets the environment for the tool. The tool will be
* launched in the given environment.
*
* @param environment the environment for the tool specified as an array
* of strings, each element specifying an environment variable setting in the
* format <i>name</i>=<i>value</i>
*/
public void setEnvironment(String[] environment) {
this.environment = environment;
}
/**
* Returns the environment for tool or <code>null</code>
*
* @return The tool environment. Default is <code>null</code>
* @see #setEnvironment(String[])
*/
public String[] getEnvironment() {
return environment;
}
/* Currently ProjectPath is just to locate the process by it */
public void setProjectPath(String path) {
projectPath = path;
}
public String getProjectPath() {
return projectPath;
}
/**
* Sets the working directory for a launched tool.
*
* @param path the absolute path to the working directory
* to be used by a launched tool, or <code>null</code> if
* the default working directory is to be inherited from the
* current process
*/
public void setWorkingDirectory(String path) {
workingDirectory = path;
}
/**
* Returns the working directory of a launched tool.
*
* @return the absolute path to the working directory
* of a launched tool, or <code>null</code> if the working
* directory is inherited from the current process
*/
public String getWorkingDirectory() {
return workingDirectory;
}
/**
* Sets the list of autogenerated control files.
*
* @controlFiles control files list
*/
public void setControlFiles(String[] controlFiles) {
this.controlFiles = controlFiles;
}
/**
* Returns the list of autogenerated control files.
*
* @return The control files list. Will not return <code>null</code>
* (an empty array will be returned instead).
*/
public String[] getControlFiles() {
if(controlFiles == null)
return empty;
return controlFiles;
}
} // class VDTRunnerConfiguration
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.options;
import org.eclipse.jface.preference.IPreferenceStore;
/**
* An abstract persistent option
*
* Created: 11.04.2006
* @author Lvov Konstantin
*/
public abstract class Option {
private String key;
private String contextID;
private IPreferenceStore store = null;
public Option(final String key, final String contextID) {
this.key = key;
this.contextID = contextID;
}
/**
* Return core option (optiuon without UI elements)
*/
public Option getOption() {
return this;
}
/**
* Sets the preference store which is used to store option.
*/
public void setPreferenceStore(IPreferenceStore store) {
this.store = store;
}
/**
* Set the option value
*/
public abstract void setValue(String value);
/**
* Sets the current value of the option back to its default value.
*/
public abstract void setToDefault();
/**
* Returns whether the current value of the option has the default value.
*/
public abstract boolean isDefault();
/**
* Returns whether the option value from persistent storage has the default value.
*/
public boolean isStoredDefault() {
if (store == null)
return isDefault();
return ! store.contains(key);
}
/**
* Load the option value from persistent storage
*/
public String doLoad() {
String value;
if (store == null) {
value = null;
} else if (store.contains(key)) {
value = store.getString(key);
setValue(value);
} else {
value = doLoadDefault();
}
return value;
}
/**
* Load the default option value from persistent storage
*/
public abstract String doLoadDefault();
// public String doLoadDefault() {
// if (store == null)
// return null;
//
// String value = store.getDefaultString(key);
// return value;
// }
/**
* Save value to persistent storage
*/
public boolean doStore(String value) {
if (store != null && value != null) {
store.setValue(key, value);
OptionsUtils.addOption(key, contextID, store);
}
return true;
}
/**
* Save current value to persistent storage
*/
public abstract boolean doStore();
/**
* Clear the current value in the preference store.
*/
public void doClear() {
setToDefault();
if ((store != null) && store.contains(key)) {
store.setToDefault(key);
OptionsUtils.removeOption(key, contextID, store);
}
}
} // class Option
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.options;
import java.io.File;
import java.io.IOException;
import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import com.elphel.vdt.VDT;
//import com.elphel.vdt.VDTPlugin;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.core.tools.contexts.PackageContext;
import com.elphel.vdt.core.tools.params.Parameter;
import com.elphel.vdt.core.tools.params.Tool;
/**
* Support for load/store of context options programmatically.
*
* Created: 13.04.2006
* @author Lvov Konstantin
*/
public class OptionsCore {
public static String getLocationPreferenceName(Tool tool) {
return VDT.ID_VDT+ ".Tool.Location." + tool.getName();
}
/*
public static String getShellPreferenceName(Tool tool) {
return VDT.ID_VDT+ ".Tool.Shell." + tool.getName();
}
*/
public static String getLocationPreferenceName(PackageContext context) {
return VDT.ID_VDT+ ".Package.Location" + context.getName();
}
public static boolean isLocationRelative(Tool tool) {
String location = tool.getExeName();
return isLocationRelative(location);
}
public static boolean isLocationRelative(String location) {
return location.startsWith("~");
}
public static void doStorePackageLocation(PackageContext context, String location) {
IPreferenceStore store = VerilogPlugin.getDefault().getPreferenceStore();
Option option = new ValueBasedOption( getLocationPreferenceName(context)
, location );
option.setPreferenceStore(store);
option.doStore();
finalizeDoStore(store);
}
public static String getPackageLocation(PackageContext context) {
IPreferenceStore store = VerilogPlugin.getDefault().getPreferenceStore();
return store.getString(getLocationPreferenceName(context));
}
public static String getAbsoluteLocation(PackageContext context, String location) {
String packageLocation = getPackageLocation(context);
return getAbsoluteLocation(packageLocation, location);
}
public static String getAbsoluteLocation(String packageLocation, String location) {
if (!isLocationRelative(location))
return location;
String toolLocation = location.substring("~".length());
toolLocation = packageLocation + toolLocation;
File file = new File(toolLocation);
return file.getAbsolutePath();
}
public static String getRelativeLocation(Tool tool) {
return getRelativeLocation( tool.getParentPackage()
, tool.getExeName() );
}
public static String getRelativeLocation(PackageContext context, String location) {
String packageLocation = getPackageLocation(context);
return getRelativeLocation(packageLocation, location);
}
public static String getRelativeLocation(String packageLocation, String location) {
if (isLocationRelative(location))
return location;
File file = new File(location);
if (!file.isAbsolute()) {
if (location.startsWith(File.separator))
return "~" + location;
else
return "~" + File.separator + location;
}
if (location.length() < packageLocation.length())
return location;
location = location.substring(packageLocation.length());
if (location.length() == 0)
return null;
if (!location.startsWith(File.separator))
location = File.separator + location;
location = "~" + location;
return location;
}
// public static void doStoreLocation(Tool tool) {
// IPreferenceStore store = VDTPlugin.getDefault().getPreferenceStore();
// store.setValue(getLocationPreferenceName(tool), tool.getExeName());
// }
public static void doLoadLocation(Tool tool) {
IPreferenceStore store = VerilogPlugin.getDefault().getPreferenceStore();
String location = store.getString(getLocationPreferenceName(tool));
if ((location != null) || (location.length() == 0)) {
if (isLocationRelative(location)) {
location = getAbsoluteLocation(tool.getParentPackage(), location);
}
tool.setLocation(location);
}
/*
boolean isShell = store.getBoolean(getShellPreferenceName(tool));
tool.setIsShell(isShell);
*/
}
private static IPreferenceStore getPreferenceStore(IProject project) {
return new ScopedPreferenceStore( new ProjectScope(project)
, VDT.ID_VDT
);
}
public static IPreferenceStore getPreferenceStore(Context context, IProject project) {
return new ScopedPreferenceStore( new ProjectScope(project)
, VDT.ID_VDT+"."+context.getName()
);
}
public static String doLoadOption(Option option, IProject project) {
IPreferenceStore store = getPreferenceStore(project);
option.setPreferenceStore(store);
return option.doLoad();
}
public static void doLoadContextOptions(Context context, IProject project) {
IPreferenceStore store = getPreferenceStore(context, project);
doLoadContextOptions(context, store);
}
public static void doLoadContextOptions(Context context) {
IPreferenceStore store = VerilogPlugin.getDefault().getPreferenceStore();
doLoadContextOptions(context, store);
}
public static void doLoadContextOptions(Context context, IPreferenceStore store) {
List<Parameter> list = context.getParams();
if (list.isEmpty())
return;
checkVersionCompatibility(context, store);
for (Parameter param : list) {
Option option;
if (param.getType().isList()) /* Null pointer here on error */
option = new ParamBasedListOption(param);
else
option = new ParamBasedOption(param);
option.setPreferenceStore(store);
option.doLoad();
}
}
public static void doStoreOption(String name, String value, IProject project) {
ValueBasedOption option = new ValueBasedOption(name);
option.setValue(value);
doStoreOption(option, project);
}
public static void doStoreOption(Option option, IProject project) {
IPreferenceStore store = getPreferenceStore(project);
option.setPreferenceStore(store);
option.doStore();
finalizeDoStore(store);
}
public static void doStoreContextOptions(Context context, IProject project) {
IPreferenceStore store = getPreferenceStore(context, project);
doStoreContextOptions(context, store);
}
public static void doStoreContextOptions(Context context) {
IPreferenceStore store = VerilogPlugin.getDefault().getPreferenceStore();
doStoreContextOptions(context, store);
}
public static void doStoreContextOptions(Context context, IPreferenceStore store) {
List<Parameter> list = context.getParams();
if (list.isEmpty())
return;
for (Parameter param : list ) {
Option option;
if (param.getType().isList())
option = new ParamBasedListOption(param);
else
option = new ParamBasedOption(param);
option.setPreferenceStore(store);
option.doStore();
}
OptionsUtils.setStoreVersion(context.getVersion(), context.getName(), store);
finalizeDoStore(store);
}
private static void finalizeDoStore(IPreferenceStore store) {
if (store instanceof ScopedPreferenceStore) {
try {
if (store.needsSaving())
((ScopedPreferenceStore)store).save();
} catch (IOException e) {
// Nothing do do, we don't need to bother the user
}
}
}
public static void doClearContextOptions(Context context) {
IPreferenceStore store = VerilogPlugin.getDefault().getPreferenceStore();
doClearContextOptions(context, store);
}
public static void doClearContextOptions(Context context, IProject project) {
IPreferenceStore store = getPreferenceStore(context, project);
doClearContextOptions(context, store);
}
public static void doClearContextOptions(Context context, IPreferenceStore store) {
List<Parameter> list = context.getParams();
if (list.isEmpty())
return;
for (Parameter param : list) {
Option option;
if (param.getType().isList())
option = new ParamBasedListOption(param);
else
option = new ParamBasedOption(param);
option.setPreferenceStore(store);
option.doClear();
}
OptionsUtils.clearStore(context.getName(), store);
finalizeDoStore(store);
}
private static void checkVersionCompatibility(Context context, IPreferenceStore store) {
if (OptionsUtils.isVersionCompatible(context.getVersion(), context.getName(), store))
return;
Shell shell = VerilogPlugin.getActiveWorkbenchShell();
String message = "Version of TSL description has been changed.\nDo you wish to delete stored values?";
MessageDialog messageBox = new MessageDialog( shell, "Warning", null
, message
, MessageDialog.WARNING
, new String[]{"Yes", "No"}
, 1);
messageBox.open();
if (messageBox.getReturnCode() == 0) {
OptionsUtils.clearStore(context.getName(), store);
finalizeDoStore(store);
}
}
} // class OptionsCore
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.options;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.eclipse.jface.preference.IPreferenceStore;
import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.core.tools.params.Parameter;
/**
* Utilities for ExDT options.
*
* Created: 16.05.2006
* @author Lvov Konstantin
*/
class OptionsUtils {
public static final String KEY_CONTENT = "com.elphel.store.context.";
public static final String KEY_VERSION = "com.elphel.store.version.";
private static final String SEPARATOR = "<-@##@->";
public static String convertListToString(List<String> list) {
String value = "";
Iterator i = list.iterator();
while(i.hasNext()) {
String str = (String)i.next();
value += str + SEPARATOR;
}
return value;
}
public static String convertListToString(String[] list) {
return convertListToString(Arrays.asList(list));
}
public static List<String> convertStringToList(String value) {
List<String> list;
if ((value == null) || (value.length() == 0 )) {
list = new ArrayList<String>();
} else {
String items[] = value.split(SEPARATOR);
list = new ArrayList<String>(items.length);
for (String item : items) {
list.add(item);
}
}
return list;
}
public static String toKey(Parameter param) {
Context context = param.getContext();
int index = context.getParams().indexOf(param);
return "" + param.getContext().getName() + "_" + index + "_" + param.getID();
}
public static void addOption( final String key
, final String contextID
, IPreferenceStore store)
{
final String contentKey = getContentKey(contextID);
if (contentKey.equals(key))
return;
List<String> context = new ArrayList<String>();
ValueBasedListOption option = new ValueBasedListOption(contentKey, contextID, context);
option.setPreferenceStore(store);
context = option.doLoadList();
if (! hasKey(key, context)) {
context.add(key);
option.doStore(context);
}
}
public static void removeOption( final String key
, final String contextID
, IPreferenceStore store)
{
final String contentKey = getContentKey(contextID);
if (contentKey.equals(key) || ! store.contains(contentKey)) {
return;
}
List<String> context = getStoreContext(contextID, store);
ValueBasedListOption option = new ValueBasedListOption(contentKey, contextID, context);
option.setPreferenceStore(store);
context = option.doLoadList();
if (hasKey(key, context)) {
context.remove(key);
if (context.isEmpty()) {
option.doClear();
store.setToDefault(contentKey);
} else {
option.doStore(context);
}
}
}
private static boolean hasKey(final String key, List<String> context) {
for (String item : context) {
if (key.equals(item))
return true;
}
return false;
}
private static final String getContentKey(String contextID) {
if ((contextID != null) && (contextID.length() > 0))
return KEY_CONTENT + contextID;
else
return KEY_CONTENT;
}
private static final String getVersionKey(String contextID) {
if ((contextID != null) && (contextID.length() > 0))
return KEY_VERSION + contextID;
else
return KEY_VERSION;
}
public static void clearStore(final String contextID, IPreferenceStore store) {
List<String> context = getStoreContext(contextID, store);
for (String key : context) {
store.setToDefault(key);
}
store.setToDefault(getContentKey(contextID));
store.setToDefault(getVersionKey(contextID));
}
public static void setStoreVersion( final String version
, final String contextID
, IPreferenceStore store)
{
final String contentKey = getContentKey(contextID);
final String versionKey = getVersionKey(contextID);
if ((version != null) && store.contains(contentKey))
store.setValue(versionKey, version);
else
store.setToDefault(versionKey);
}
public static boolean isVersionCompatible( final String version
, final String contextID
, IPreferenceStore store )
{
boolean compatible;
final String versionKey = getVersionKey(contextID);
if (version == null) {
compatible = ! store.contains(versionKey);
} else if (store.contains(versionKey)) {
compatible = version.equals(store.getString(versionKey));
} else {
compatible = ! store.contains(versionKey);
}
return compatible;
}
private static List<String> getStoreContext( final String contextID
, IPreferenceStore store ) {
List<String> context = new ArrayList<String>();
ValueBasedListOption option = new ValueBasedListOption(getContentKey(contextID), contextID, context);
option.setPreferenceStore(store);
context = option.doLoadList();
return context;
}
} // class OptionsUtils
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.options;
import java.util.List;
import com.elphel.vdt.core.tools.params.Parameter;
import com.elphel.vdt.core.tools.params.ToolException;
import com.elphel.vdt.ui.MessageUI;
/**
* Persistent option based on Context List Parameter
*
* Created: 11.04.2006
* @author Lvov Konstantin
*/
public class ParamBasedListOption extends ParamBasedOption {
public ParamBasedListOption(Parameter param) {
super(param);
}
/**
* Set the option value
*
* @param value the sequnce of the list items separated by SEPARATOR.
*/
public void setValue(String value) {
List<String> list = OptionsUtils.convertStringToList(value);
setValue(list);
}
public String getValue() {
return null;
}
protected void setValue(List<String> list) {
try {
param.setCurrentValue(list);
} catch(ToolException e) {
MessageUI.fatalError(e.getMessage());
}
}
public List<String> getValueList() {
return param.getValue();
}
public List<String> doLoadList() {
List<String> list;
String value = super.doLoad();
if (value == null)
list = getValueList();
else
list = OptionsUtils.convertStringToList(value);
return list;
}
/**
* Load the default option value from persistent storage
*
* @return the sequnce of the list items separated by SEPARATOR.
*/
public String doLoadDefault() {
List<String> list = doLoadDefaultList();
return OptionsUtils.convertListToString(list);
}
public List<String> doLoadDefaultList() {
List<String> list = param.getDefaultValue();
doClear();
return list;
}
/**
* Save value to persistent storage
*
* @param value the sequnce of the list items separated by SEPARATOR.
*/
public boolean doStore(String value) {
List<String> list = OptionsUtils.convertStringToList(value);
return doStore(list);
}
public boolean doStore(List<String> list) {
setValue(list);
String value = OptionsUtils.convertListToString(list);
return super.doStore(value);
}
public boolean doStore() {
if (param.isDefault()) {
super.doClear();
return true;
} else
return super.doStore(OptionsUtils.convertListToString(param.getValue()));
}
} // class ParamBasedOption
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.options;
import java.util.*;
import com.elphel.vdt.core.tools.params.Parameter;
import com.elphel.vdt.core.tools.params.ToolException;
import com.elphel.vdt.core.tools.params.types.ParamType;
import com.elphel.vdt.ui.MessageUI;
/**
* Persistent option based on Context Parameter
*
* Created: 11.04.2006
* @author Lvov Konstantin
*/
public class ParamBasedOption extends Option {
protected Parameter param;
public ParamBasedOption(Parameter param) {
super(OptionsUtils.toKey(param), param.getContext().getName());
this.param = param;
}
public void setValue(String value) {
try {
param.setCurrentValue(value);
} catch(ToolException e) {
MessageUI.error(e);
}
}
public String getValue() {
return param.getValue().get(0);
}
public Parameter getParam() {
return param;
}
public ParamType getType() {
return param.getType();
}
public String getLabel() {
return param.getLabel();
}
public boolean isDefault() {
return param.isDefault();
}
public void setToDefault() {
param.setToDefault();
}
public String doLoadDefault() {
String value = param.getDefaultValue().get(0);
doClear();
return value;
}
public String doLoad() {
String value = super.doLoad();
if (value == null)
value = getValue();
return value;
}
public boolean doStore(String value) {
setValue(value);
return super.doStore(value);
}
public boolean doStore() {
if (isDefault()) {
super.doClear();
return true;
} else {
List<String> currentValue = param.getCurrentValue();
String currentValueElem = null;
if(currentValue != null)
currentValueElem = currentValue.get(0);
return super.doStore(currentValueElem);
}
}
} // class ParamBasedOption
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.options;
import java.util.List;
/**
* Persistent option based on list of string value
*
* Created: 11.04.2006
* @author Lvov Konstantin
*/
public class ValueBasedListOption extends Option {
private List<String> currentValue;
private List<String> defaultValue;
public ValueBasedListOption(final String key, final List<String> defaultValue) {
this(key, null, defaultValue);
}
public ValueBasedListOption( final String key
, final String contextID
, final List<String> defaultValue ) {
super(key, contextID);
this.currentValue = null;
this.defaultValue = defaultValue;
}
/**
* Set the option value
*
* @param value the sequnce of the list items separated by SEPARATOR.
*/
public void setValue(String value) {
List<String> list = OptionsUtils.convertStringToList(value);
setValue(list);
}
protected void setValue(List<String> list) {
currentValue = list;
}
public List<String> getValueList() {
if (isDefault())
return defaultValue;
else
return currentValue;
}
public void setToDefault() {
currentValue = null;
}
public boolean isDefault() {
return currentValue == null;
}
public List<String> doLoadList() {
List<String> list;
String value = super.doLoad();
if (value == null)
list = getValueList();
else
list = OptionsUtils.convertStringToList(value);
return list;
}
/**
* Load the default option value from persistent storage
*
* @return the sequnce of the list items separated by SEPARATOR.
*/
public String doLoadDefault() {
List<String> list = doLoadDefaultList();
return OptionsUtils.convertListToString(list);
}
public List<String> doLoadDefaultList() {
List<String> list = defaultValue;
doClear();
return list;
}
/**
* Save value to persistent storage
*
* @param value the sequnce of the list items separated by SEPARATOR.
*/
public boolean doStore(String value) {
List<String> list = OptionsUtils.convertStringToList(value);
return doStore(list);
}
public boolean doStore(List<String> list) {
setValue(list);
String value = OptionsUtils.convertListToString(list);
return super.doStore(value);
}
public boolean doStore() {
if (isDefault()) {
super.doClear();
return true;
} else
return super.doStore(OptionsUtils.convertListToString(currentValue));
}
} // class ParamBasedOption
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.options;
/**
* Persistent option based on string value
*
* Created: 20.04.2006
* @author Lvov Konstantin
*/
public class ValueBasedOption extends Option {
private String currentValue;
private String defaultValue;
public ValueBasedOption(String key) {
this(key, null);
}
public ValueBasedOption(String key, String defaultValue) {
super(key, null);
this.currentValue = null;
this.defaultValue = defaultValue;
}
public void setValue(String value) {
currentValue = value;
}
public String getValue() {
if (isDefault())
return defaultValue;
else
return currentValue;
}
public boolean isDefault() {
return currentValue == null;
}
public void setToDefault() {
currentValue = null;
}
public String doLoadDefault() {
String value = defaultValue;
doClear();
return value;
}
public String doLoad() {
String value = super.doLoad();
if (value == null)
value = getValue();
return value;
}
public boolean doStore(String value) {
setValue(value);
return super.doStore(value);
}
public boolean doStore() {
if (isDefault()) {
super.doClear();
return true;
} else
return super.doStore(currentValue);
}
} // class ValueBasedOption
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools;
public class BooleanUtils {
public static final String VALUE_TRUE = Boolean.toString(true);
public static final String VALUE_FALSE = Boolean.toString(false);
public static boolean isTrue(String s) {
return s.equals(VALUE_TRUE);
}
public static boolean isFalse(String s) {
return s.equals(VALUE_FALSE);
}
public static boolean isBoolean(String s) {
return isTrue(s) || isFalse(s);
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import com.elphel.vdt.core.tools.config.ConfigException;
public class Checks {
public static void checkCyclicInheritance(Inheritable inheritanceChainMember, String entityName)
throws ConfigException
{
List<Inheritable> chain = new ArrayList<Inheritable>();
Inheritable chainItem = inheritanceChainMember;
while(chainItem != null) {
if(chain.contains(chainItem)) {
chain.add(chainItem);
String message = "Cyclic " + entityName + " inheritance detected: ";
for(Iterator<Inheritable> i = chain.iterator(); i.hasNext();) {
message += "'" + ((Inheritable)i.next()).getName() + "'";
if(i.hasNext())
message += " extends ";
}
throw new ConfigException(message);
}
chain.add(chainItem);
chainItem = chainItem.getBase();
}
}
public static void checkDuplicatedNames(List<? extends NamedEntity> objlist,
String entityName)
throws ConfigException
{
for(int i = 0; i < objlist.size() - 1; i++) {
NamedEntity obj1 = objlist.get(i);
for(int j = i+1; j < objlist.size(); j++) {
NamedEntity obj2 = (NamedEntity)objlist.get(j);
if(obj1.getName().equals(obj2.getName()))
throw new ConfigException("Element '" + obj1.getName() +
"' is duplicated in " + entityName);
}
}
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools;
import java.util.*;
import com.elphel.vdt.core.tools.config.ConfigException;
public class EntityUtils {
public static <T extends Updateable> void update(List<T> from, List<T> to)
throws ConfigException
{
List<T> updated = new ArrayList<T>();
// scan the base list; for each item, check if it is in the
// destination list. if so, update it; otherwise, just clone it
for(T baseItem : from) {
T itemToUpdate = null;
for(T toItem : to) {
if(baseItem.matches(toItem)) {
itemToUpdate = toItem;
break;
}
}
if(itemToUpdate != null) {
// this item is inherited but changed
// so just update its internals in the way it needs
itemToUpdate.update(baseItem);
updated.add(itemToUpdate);
} else {
// the item is purely inherited, so just copy it
updated.add((T)baseItem.clone());
}
}
// now what we should do is to add new items that are in the
// destination list and are't in the base list to the updated list
for(T toItem : to) {
boolean found = false;
for(T updatedItem : updated) {
if(updatedItem.matches(toItem)) {
found = true;
break;
}
}
if(!found)
updated.add(toItem);
}
to.clear();
to.addAll(updated);
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools;
public interface Inheritable extends NamedEntity {
public Inheritable getBase();
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools;
public interface NamedEntity {
public String getName();
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
//import com.elphel.vdt.VDTPlugin;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.core.options.OptionsCore;
import com.elphel.vdt.core.tools.config.Config;
import com.elphel.vdt.core.tools.config.xml.XMLConfig;
import com.elphel.vdt.core.tools.contexts.ContextManager;
import com.elphel.vdt.core.tools.contexts.InstallationContext;
import com.elphel.vdt.core.tools.contexts.PackageContext;
import com.elphel.vdt.core.tools.menu.DesignMenu;
import com.elphel.vdt.core.tools.menu.DesignMenuManager;
import com.elphel.vdt.core.tools.params.Tool;
import com.elphel.vdt.ui.MessageUI;
/**
* Manager of tools configuartion
*
* Created: 14.01.2006
* @author Lvov Konstantin
*/
public class ToolsCore {
// singleton
private static Config config;
private static final String CONFIG_DIR = "tools";
public static void updateConfig(String configFileName) {
try {
config = new XMLConfig(configFileName);
OptionsCore.doLoadContextOptions(config.getContextManager().getInstallationContext());
for (PackageContext packageContext : config.getContextManager().getPackageContexts())
OptionsCore.doLoadContextOptions(packageContext);
} catch(Exception e) {
MessageUI.error(e);
}
}
public static final Config getConfig() {
if (config == null)
updateConfig(VerilogPlugin.getInstallLocation() + File.separator + CONFIG_DIR);
return config;
}
public static Tool getTool(String toolID) {
for (Tool tool : getConfig().getContextManager().getToolList())
if (toolID.equals(tool.getName()))
return tool;
return null;
}
public static Tool getToolWorkingCopy(String toolID) {
Tool tool = getTool(toolID);
if (tool != null) {
return (Tool)tool.clone();
}
return null;
}
public static List<Tool> getTools(PackageContext context) {
List<Tool> list = new ArrayList<Tool>();
for (Tool tool : getContextManager().getToolList()) {
PackageContext toolPackage = tool.getParentPackage();
if (toolPackage == context ||
((toolPackage != null) && (context != null) && context.getName().equals(toolPackage.getName())))
{
list.add(tool);
}
}
return list;
}
public static List<Tool> getStandaloneTools() {
return getTools(null);
}
public static DesignMenu getDesignMenu() {
return getConfig().getContextManager().getDesignMenu();
}
public static DesignMenuManager getDesignMenuManager() {
return getConfig().getDesignMenuManager();
}
public static ContextManager getContextManager() {
return getConfig().getContextManager();
}
public static InstallationContext getInstallationContext() {
return getConfig().getContextManager().getInstallationContext();
}
} // class ToolsCore
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools;
import com.elphel.vdt.core.tools.config.ConfigException;
public interface Updateable extends Cloneable {
public void update(Updateable from) throws ConfigException;
public boolean matches(Updateable other);
public Object clone();
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.config;
import java.util.*;
import com.elphel.vdt.core.tools.params.*;
import com.elphel.vdt.core.tools.contexts.*;
import com.elphel.vdt.core.tools.menu.*;
public abstract class Config {
protected List<ControlInterface> controlInterfaceList = new ArrayList<ControlInterface>();
protected ContextManager contextManager = new ContextManager();
protected DesignMenuManager designMenuManager = new DesignMenuManager();
protected enum ContextKind {
INSTALLATION,
PROJECT,
PACKAGE,
TOOL
}
public abstract void logError(Exception e) throws ConfigException;
public List<ControlInterface> getControlInterfaceList() {
return controlInterfaceList;
}
public ContextManager getContextManager() {
return contextManager;
}
public DesignMenuManager getDesignMenuManager() {
return designMenuManager;
}
public ControlInterface findControlInterface(String name) {
for(Iterator ci = controlInterfaceList.iterator(); ci.hasNext();) {
ControlInterface interf = (ControlInterface)ci.next();
if(interf.getName().equals(name))
return interf;
}
return null;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.config;
public class ConfigException extends Exception {
public ConfigException(String message) {
super(message);
}
public ConfigException(String message, Throwable cause) {
super(message, cause);
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.config.xml;
import org.w3c.dom.Node;
import com.elphel.vdt.core.tools.config.ConfigException;
import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.core.tools.params.conditions.Condition;
public abstract class AbstractConditionNodeReader {
protected XMLConfig config;
protected Context context;
public AbstractConditionNodeReader(XMLConfig config, Context context) {
this.config = config;
this.context = context;
}
public abstract void readNode(Node node, Condition condition) throws ConfigException;
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.config.xml;
import java.util.*;
import org.w3c.dom.Node;
import com.elphel.vdt.core.tools.config.ConfigException;
import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.core.tools.params.CommandLinesBlock;
import com.elphel.vdt.core.tools.params.conditions.Condition;
import com.elphel.vdt.core.tools.params.conditions.ConditionalStringsList;
import com.elphel.vdt.core.tools.params.conditions.NamedConditionalStringsList;
public class CommandLinesNodeReader extends AbstractConditionNodeReader {
List<CommandLinesBlock> commandLinesBlocks = new ArrayList<CommandLinesBlock>();
public CommandLinesNodeReader(XMLConfig config, Context context) {
super(config, context);
}
public List<CommandLinesBlock> getCommandLinesBlocks() {
return commandLinesBlocks;
}
public void readNode(Node node, Condition condition) throws ConfigException {
if(XMLConfig.isElemNode(node, XMLConfig.CONTEXT_LINEBLOCK_TAG)) {
try {
commandLinesBlocks.add(readCommandLinesBlock(node, condition));
} catch(ConfigException e) {
config.logError(e);
}
}
}
private CommandLinesBlock readCommandLinesBlock(Node node, Condition condition)
throws ConfigException
{
String name = XMLConfig.getAttributeValue(node, XMLConfig.CONTEXT_LINEBLOCK_NAME_ATTR);
String dest = XMLConfig.getAttributeValue(node, XMLConfig.CONTEXT_LINEBLOCK_DEST_ATTR);
String sep = XMLConfig.getAttributeValue(node, XMLConfig.CONTEXT_LINEBLOCK_SEP_ATTR);
if(name == null)
throw new ConfigException("Unnamed lines block definition in context '" +
context.getName() + "' definition");
ConditionalStringsList lines =
config.readConditionalStringsNode(node, context, condition);
ConditionalStringsList deleteLines =
config.readDeleteStringsNode(node, context, condition);
List<NamedConditionalStringsList> insertLines =
config.readInsertStringsNode(node, context, condition);
return new CommandLinesBlock(context.getName(),
name,
dest,
sep,
lines,
deleteLines,
insertLines);
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.config.xml;
import org.w3c.dom.*;
import com.elphel.vdt.core.tools.config.ConfigException;
import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.core.tools.params.ParamUtils;
import com.elphel.vdt.core.tools.params.conditions.*;
public class ConditionNodeReader extends AbstractConditionNodeReader {
private AbstractConditionNodeReader nodeReader;
private Condition initialCondition;
public ConditionNodeReader(XMLConfig config,
Context context,
AbstractConditionNodeReader nodeReader)
{
this(config, context, nodeReader, null);
}
public ConditionNodeReader(XMLConfig config,
Context context,
AbstractConditionNodeReader nodeReader,
Condition initialCondition)
{
super(config, context);
this.nodeReader = nodeReader;
this.initialCondition = initialCondition;
}
public void readNode(Node node) throws ConfigException {
readNode(node, initialCondition);
}
public void readNode(Node node, Condition condition) throws ConfigException {
NodeList childNodes = node.getChildNodes();
for(int i = 0; i < childNodes.getLength(); i++) {
Node child = childNodes.item(i);
// read the data needed by the incapsulated node reader
nodeReader.readNode(child, condition);
// find condition nodes
// for each, create a condition object and call readNode(condNode, createdCondition)
Comparison.COMPARE_OP compareOp;
Condition.BOOL_OP boolOp;
if(XMLConfig.isElemNode(child, XMLConfig.CONDITION_IF_TAG)) {
compareOp = Comparison.COMPARE_OP.EQ;
boolOp = Condition.BOOL_OP.OR;
} else if(XMLConfig.isElemNode(child, XMLConfig.CONDITION_NOT_TAG)) {
compareOp = Comparison.COMPARE_OP.NEQ;
boolOp = Condition.BOOL_OP.AND;
} else if(XMLConfig.isElemNode(child, XMLConfig.CONDITION_AND_TAG)) {
compareOp = Comparison.COMPARE_OP.EQ;
boolOp = Condition.BOOL_OP.AND;
} else {
continue;
}
readNode(child, composeCondititon(condition, child, compareOp, boolOp));
}
}
private Condition composeCondititon(Condition topCondition,
Node conditionNode,
Comparison.COMPARE_OP nodeCompareOp,
Condition.BOOL_OP nodeBoolOp)
throws ConfigException
{
// read the nested condition and bind it with the top one
// using the "AND" boolean operation
Condition subCondition = readCondition(conditionNode, nodeCompareOp, nodeBoolOp);
if(topCondition != null)
return new Condition(Condition.BOOL_OP.AND,
topCondition,
subCondition);
else
return subCondition;
}
private Condition readCondition(Node node,
Comparison.COMPARE_OP compareOp,
Condition.BOOL_OP boolOp)
throws ConfigException
{
NamedNodeMap attributes = node.getAttributes();
if(attributes.getLength() == 0)
throw new ConfigException("Condition block '" + node.getNodeName() +
"' doesn't have any attribute");
Condition fullCondition = null;
for(int i = 0; i < attributes.getLength(); i++) {
Node attr = attributes.item(i);
String paramName = attr.getNodeName();
String paramValue = attr.getNodeValue();
Comparison comparison = new StringComparison(compareOp,
context,
ParamUtils.buildParamString(paramName),
paramValue);
if(fullCondition == null)
fullCondition = comparison;
else
fullCondition = new Condition(boolOp,
fullCondition,
comparison);
}
return fullCondition;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.config.xml;
import org.w3c.dom.Node;
import com.elphel.vdt.core.tools.config.ConfigException;
import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.core.tools.params.conditions.Condition;
import com.elphel.vdt.core.tools.params.conditions.ConditionalStringsList;
public class ConditionalStringsNodeReader extends AbstractConditionNodeReader {
ConditionalStringsList conditionalStrings = new ConditionalStringsList();
public ConditionalStringsNodeReader(XMLConfig config, Context context) {
super(config, context);
}
public ConditionalStringsList getConditionalStrings() {
return conditionalStrings;
}
public void readNode(Node node, Condition condition) throws ConfigException {
if(!XMLConfig.isTextNode(node))
return;
conditionalStrings.add(condition, XMLConfig.readStringsNode(node));
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.config.xml;
import java.util.*;
import org.w3c.dom.Node;
import com.elphel.vdt.core.tools.config.ConfigException;
import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.core.tools.params.ParamGroup;
import com.elphel.vdt.core.tools.params.conditions.Condition;
import com.elphel.vdt.core.tools.params.conditions.ConditionalStringsList;
import com.elphel.vdt.core.tools.params.conditions.NamedConditionalStringsList;
public class ParamGroupNodeReader extends AbstractConditionNodeReader {
List<ParamGroup> paramGroups = new ArrayList<ParamGroup>();
public ParamGroupNodeReader(XMLConfig config, Context context) {
super(config, context);
}
public List<ParamGroup> getParamGroups() {
return paramGroups;
}
public void readNode(Node node, Condition condition) throws ConfigException {
if(XMLConfig.isElemNode(node, XMLConfig.PARAMGROUP_TAG)) {
try {
paramGroups.add(readParamGroup(node, condition));
} catch(ConfigException e) {
config.logError(e);
}
}
}
private ParamGroup readParamGroup(Node node, Condition condition)
throws ConfigException
{
String name = XMLConfig.getAttributeValue(node, XMLConfig.PARAMGROUP_NAME_ATTR);
String label = XMLConfig.getAttributeValue(node, XMLConfig.PARAMGROUP_LABEL_ATTR);
String visible = XMLConfig.getAttributeValue(node, XMLConfig.PARAMGROUP_VISIBLE_ATTR);
if(name == null && label == null)
throw new ConfigException("Parameter group in context '" + context.getName() +
"' has neither name nor label attribute");
boolean isVisible;
if(visible != null) {
XMLConfig.checkBoolAttr(visible, XMLConfig.TYPEDEF_LIST_ATTR);
isVisible = XMLConfig.getBoolAttrValue(visible);
} else {
isVisible = true;
}
ConditionalStringsList params =
config.readConditionalStringsNode(node, context, condition);
ConditionalStringsList deleteParams =
config.readDeleteStringsNode(node, context, condition);
List<NamedConditionalStringsList> insertParams =
config.readInsertStringsNode(node, context, condition);
return new ParamGroup(name,
label,
isVisible,
params,
deleteParams,
insertParams,
condition);
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.config.xml;
import java.util.*;
import org.w3c.dom.Node;
import com.elphel.vdt.core.tools.config.ConfigException;
import com.elphel.vdt.core.tools.params.Parameter;
import com.elphel.vdt.core.tools.params.conditions.Condition;
import com.elphel.vdt.core.tools.contexts.Context;
public class ParamNodeReader extends AbstractConditionNodeReader {
private List<Parameter> paramList = new ArrayList<Parameter>();
public ParamNodeReader(XMLConfig config, Context context) {
super(config, context);
}
public void readNode(Node node, Condition condition) throws ConfigException {
if(XMLConfig.isElemNode(node, XMLConfig.PARAMETER_TAG)) {
try {
paramList.add(readParam(node, condition));
} catch(ConfigException e) {
config.logError(e);
}
}
}
public List<Parameter> getParamList() {
return paramList;
}
private Parameter readParam(Node paramNode, Condition condition)
throws ConfigException
{
String id = XMLConfig.getAttributeValue(paramNode, XMLConfig.PARAMETER_ID_ATTR);
String outid = XMLConfig.getAttributeValue(paramNode, XMLConfig.PARAMETER_OUTID_ATTR);
String typeName = XMLConfig.getAttributeValue(paramNode, XMLConfig.PARAMETER_TYPE_NAME_ATTR);
String formatName = XMLConfig.getAttributeValue(paramNode, XMLConfig.PARAMETER_FORMAT_NAME_ATTR);
String defaultValue = XMLConfig.getAttributeValue(paramNode, XMLConfig.PARAMETER_DEFAULT_VALUE_ATTR);
String omitValue = XMLConfig.getAttributeValue(paramNode, XMLConfig.PARAMETER_OMIT_VALUE_ATTR);
String label = XMLConfig.getAttributeValue(paramNode, XMLConfig.PARAMETER_LABEL_ATTR);
String readOnly = XMLConfig.getAttributeValue(paramNode, XMLConfig.PARAMETER_READONLY_ATTR);
String visible = XMLConfig.getAttributeValue(paramNode, XMLConfig.PARAMETER_VISIBLE_ATTR);
if(id == null)
throw new ConfigException("Context '" + context.getName() + ": Parameter id is absent");
return new Parameter(id,
outid,
typeName,
formatName,
defaultValue,
label,
omitValue,
readOnly,
visible,
condition);
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.config.xml;
import java.io.*;
import java.util.*;
import org.w3c.dom.*;
import org.xml.sax.SAXException;
import javax.xml.parsers.*;
import com.elphel.vdt.core.tools.BooleanUtils;
import com.elphel.vdt.core.tools.params.*;
import com.elphel.vdt.core.tools.params.conditions.*;
import com.elphel.vdt.core.tools.params.types.*;
import com.elphel.vdt.core.tools.config.*;
import com.elphel.vdt.core.tools.contexts.*;
import com.elphel.vdt.core.tools.menu.*;
import com.elphel.vdt.ui.MessageUI;
public class XMLConfig extends Config {
static final String CONFIG_EXTENSION = ".xml";
static final String ROOT_NODE_TAG = "vdt-project";
static final String ROOT_VERSION_ATTR = "version";
static final String INTERFACE_TAG = "interface";
static final String INTERFACE_NAME_ATTR = "name";
static final String INTERFACE_EXTENDS_ATTR = "extends";
static final String TYPEDEF_TAG = "typedef";
static final String TYPEDEF_NAME_ATTR = "name";
static final String TYPEDEF_LIST_ATTR = "list";
static final String TYPEDEF_PARAMTYPE_TAG = "paramtype";
static final String TYPEDEF_PARAMTYPE_KIND_ATTR = "kind";
static final String ENUM_ELEMENT_TAG = "item";
static final String SYNTAX_TAG = "syntax";
static final String SYNTAX_NAME_ATTR = "name";
static final String SYNTAX_FORMAT_ATTR = "format";
static final String SYNTAX_TYPE_ATTR = "type";
static final String PARAMGROUP_TAG = "group";
static final String PARAMGROUP_NAME_ATTR = "name";
static final String PARAMGROUP_LABEL_ATTR = "label";
static final String PARAMGROUP_VISIBLE_ATTR = "visible";
static final String PARAMETER_TAG = "parameter";
static final String PARAMETER_ID_ATTR = "id";
static final String PARAMETER_OUTID_ATTR = "outid";
static final String PARAMETER_TYPE_NAME_ATTR = "type";
static final String PARAMETER_FORMAT_NAME_ATTR = "format";
static final String PARAMETER_DEFAULT_VALUE_ATTR = "default";
static final String PARAMETER_OMIT_VALUE_ATTR = "omit";
static final String PARAMETER_LABEL_ATTR = "label";
static final String PARAMETER_READONLY_ATTR = "readonly";
static final String PARAMETER_VISIBLE_ATTR = "visible";
static final String CONTEXT_INSTALLATION_TAG = "installation";
static final String CONTEXT_PROJECT_TAG = "project";
static final String CONTEXT_PACKAGE_TAG = "package";
static final String CONTEXT_TOOL_TAG = "tool";
static final String CONTEXT_OUTPUT_SECTION_TAG = "output";
static final String CONTEXT_INPUT_SECTION_TAG = "input";
static final String CONTEXT_INPUT_SECTION_LABEL_ATTR = "label";
static final String CONTEXT_INTERFACE_ATTR = "interface";
static final String CONTEXT_LABEL_ATTR = "label";
static final String CONTEXT_ICON_ATTR = "icon";
static final String CONTEXT_NAME_ATTR = "name";
static final String CONTEXT_PROJECT_PACKAGE_ATTR = "package";
static final String CONTEXT_PROJECT_DESIGNMENU_ATTR = "menu";
static final String CONTEXT_TOOL_BASE_ATTR = "inherits";
static final String CONTEXT_TOOL_PACKAGE_ATTR = "package";
static final String CONTEXT_TOOL_PROJECT_ATTR = "project";
static final String CONTEXT_TOOL_EXE_ATTR = "exe";
static final String CONTEXT_TOOL_SHELL_ATTR = "shell";
static final String CONTEXT_TOOL_EXTENSIONS_LIST_TAG = "extensions-list";
static final String CONTEXT_TOOL_EXTENSION_TAG = "extension";
static final String CONTEXT_TOOL_EXTENSION_MASK_ATTR = "mask";
static final String CONTEXT_TOOL_SYNTAX_ERRORS = "errors";
static final String CONTEXT_TOOL_SYNTAX_WARNINGS= "warnings";
static final String CONTEXT_TOOL_SYNTAX_INFO = "info";
static final String CONTEXT_LINEBLOCK_TAG = "line";
static final String CONTEXT_LINEBLOCK_NAME_ATTR = "name";
static final String CONTEXT_LINEBLOCK_DEST_ATTR = "dest";
static final String CONTEXT_LINEBLOCK_SEP_ATTR = "sep";
static final String CONTEXT_STRINGS_DELETE_TAG = "delete";
static final String CONTEXT_STRINGS_INSERT_TAG = "insert";
static final String CONTEXT_STRINGS_INSERT_AFTER_ATTR = "after";
static final String MENU_TAG = "menu";
static final String MENU_INHERITS_ATTR = "inherits";
static final String MENU_AFTER_ATTR = "after";
static final String MENU_NAME_ATTR = "name";
static final String MENU_LABEL_ATTR = "label";
static final String MENU_ICON_ATTR = "icon";
static final String MENU_DESCRIPTION_ATTR = "tip";
static final String MENU_VISIBLE_ATTR = "visible";
static final String MENUITEM_TAG = "menuitem";
static final String MENUITEM_CALL_ATTR = "call";
static final String MENUITEM_NAME_ATTR = MENU_NAME_ATTR;
static final String MENUITEM_LABEL_ATTR = MENU_LABEL_ATTR;
static final String MENUITEM_ICON_ATTR = MENU_ICON_ATTR;
static final String MENUITEM_VISIBLE_ATTR = MENU_VISIBLE_ATTR;
static final String MENUITEM_AFTER_ATTR = MENU_AFTER_ATTR;
static final String CONDITION_IF_TAG = "if";
static final String CONDITION_AND_TAG = "if-and";
static final String CONDITION_NOT_TAG = "if-not";
private static final int MAX_ERRORS_TO_SHOW = 4;
private int errorCount = 0;
private Node rootNode;
private String currentConfigFileName;
private String currentFileVersion;
//
// publics
//
public XMLConfig(String configDirectoryName) {
try {
readConfig(configDirectoryName);
initConfig();
} catch(Exception e) {
MessageUI.error(e);
}
}
public void logError(Exception e) throws ConfigException {
if(errorCount++ < MAX_ERRORS_TO_SHOW) {
MessageUI.error("Error reading config file '" + currentConfigFileName + ". \n" +
"Reason: " + e.getMessage(), e);
}
}
//
// interface available in the package
//
ConditionalStringsList readConditionalStringsNode(Node node,
Context context,
Condition initialCondition)
throws ConfigException
{
ConditionalStringsNodeReader linesReader = new ConditionalStringsNodeReader(this, context);
new ConditionNodeReader(this, context, linesReader, initialCondition).readNode(node);
return linesReader.getConditionalStrings();
}
ConditionalStringsList readDeleteStringsNode(Node node,
Context context,
Condition initialCondition)
throws ConfigException
{
List<Node> deleteNodes = XMLConfig.findChildNodes(node, CONTEXT_STRINGS_DELETE_TAG);
if(deleteNodes.isEmpty())
return null;
else if(deleteNodes.size() > 1)
throw new ConfigException("More that one '" + CONTEXT_STRINGS_DELETE_TAG +
"' section in context '" + context.getName() +
"' definition");
return readConditionalStringsNode(deleteNodes.get(0), context, initialCondition);
}
List<NamedConditionalStringsList> readInsertStringsNode(Node node,
Context context,
Condition initialCondition)
throws ConfigException
{
List<Node> insertNodes = XMLConfig.findChildNodes(node, CONTEXT_STRINGS_INSERT_TAG);
if(insertNodes.isEmpty())
return null;
List<NamedConditionalStringsList> insertLinesList = new ArrayList<NamedConditionalStringsList>();
for(int i = 0; i < insertNodes.size(); i++) {
Node insertNode = insertNodes.get(i);
String after =
XMLConfig.getAttributeValue(insertNode, CONTEXT_STRINGS_INSERT_AFTER_ATTR);
if(after == null)
throw new ConfigException("Attribute '" + CONTEXT_STRINGS_INSERT_AFTER_ATTR +
"' in '" + CONTEXT_STRINGS_INSERT_TAG +
"' section in lines block definition of context '" +
context.getName() + "' definition is absent");
ConditionalStringsList insertLines =
readConditionalStringsNode(insertNode, context, initialCondition);
insertLinesList.add(new NamedConditionalStringsList(insertLines, after));
}
return insertLinesList;
}
static List<String> readStringsNode(Node node) {
List<String> stringList = new ArrayList<String>();
if(isTextNode(node)) {
// we need the raw text in this node
String text = node.getNodeValue();
String[] lines = text.split("\"");
// we need only lines enclosed in quotes
// so in the 'lines' array we need only odd elems (1, 3, 5, ...)
for(int k = 1; k < lines.length; k += 2)
stringList.add(lines[k]);
} else {
NodeList childNodes = node.getChildNodes();
for(int i = 0; i < childNodes.getLength(); i++) {
Node child = childNodes.item(i);
if(isTextNode(child))
stringList.addAll(readStringsNode(child));
}
}
return stringList;
}
static boolean isElemNode(Node node) {
return node.getNodeType() == Node.ELEMENT_NODE;
}
static boolean isElemNode(Node node, String name) {
return isElemNode(node) && (node.getNodeName().equals(name));
}
static boolean isTextNode(Node node) {
return node.getNodeType() == Node.TEXT_NODE;
}
static List<Node> findChildNodes(Node node, String childNodeName) {
return findChildNodes(node.getChildNodes(), childNodeName);
}
static List<Node> findChildNodes(NodeList nodes, String childNodeName) {
List<Node> found = new ArrayList<Node>();
for(int i = 0; i < nodes.getLength(); i++) {
Node child = nodes.item(i);
if(isElemNode(child, childNodeName))
found.add(child);
}
return found;
}
static String getAttributeValue(Node node, String attr) {
NamedNodeMap attributes = node.getAttributes();
if(attributes == null)
return null;
Node paramNode = attributes.getNamedItem(attr);
return paramNode != null? paramNode.getNodeValue() : null;
}
static void checkBoolAttr(String attr, String attrName) throws ConfigException {
if(!BooleanUtils.isBoolean(attr))
throw new ConfigException("Unknown value of the attribute '" +
attrName +
"': " +
attr);
}
static boolean getBoolAttrValue(String attr) {
return BooleanUtils.isTrue(attr);
}
//
// private stuff
//
private void readConfig(String directory) throws ConfigException,
IOException
{
File cfgDir = new File(directory);
if(!cfgDir.isDirectory())
throw new IOException("Cannot read config directory '" + directory + "'");
File[] configFiles = cfgDir.listFiles();
for(int i = 0; i < configFiles.length; i++) {
File configFile = configFiles[i];
if(configFile.isFile()) {
if(configFile.getName().toLowerCase().endsWith(CONFIG_EXTENSION.toLowerCase())) {
try {
readConfigFile(configFile);
} catch(Exception e) {
logError(e);
}
}
} else {
readConfig(configFile.getAbsolutePath());
}
}
}
private void initConfig() throws ConfigException {
try {
initControlInterfaces();
contextManager.init(this);
checkConfig();
designMenuManager.init(this);
} catch(ConfigException e) {
throw new ConfigException("Error initializing config: " + e.getMessage(), e);
}
if(errorCount > 0) {
throw new ConfigException("Some errors occured during config initialization.");
}
}
private void initControlInterfaces() throws ConfigException {
for(Iterator ci = controlInterfaceList.iterator(); ci.hasNext();)
((ControlInterface)ci.next()).init();
}
private void checkConfig() throws ConfigException {
for(Iterator ci = controlInterfaceList.iterator(); ci.hasNext();) {
ControlInterface interf = (ControlInterface)ci.next();
interf.check();
}
}
private void readConfigFile(File configFile) throws ConfigException,
ParserConfigurationException,
SAXException,
IOException
{
//System.out.println("Reading file '" + configFile + "'");
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(configFile);
currentConfigFileName = configFile.getAbsolutePath();
findRootNode(document);
// read and tie control interface list
List<ControlInterface> controlInterfaces = readInterfaceList(document);
try {
addControlInterfaceList(controlInterfaces);
} catch(ConfigException e) {
logError(e);
}
// try to find & read context layers
List<InstallationContext> installationContexts = readContextList(document, ContextKind.INSTALLATION);
List<ProjectContext> projectContexts = readContextList(document, ContextKind.PROJECT);
List<PackageContext> packageContexts = readContextList(document, ContextKind.PACKAGE);
List<Tool> toolContexts = readContextList(document, ContextKind.TOOL);
try {
contextManager.addInstallationContexts(installationContexts);
} catch(ConfigException e) {
logError(e);
}
try {
contextManager.addProjectContexts(projectContexts);
} catch(ConfigException e) {
logError(e);
}
try {
contextManager.addPackageContexts(packageContexts);
} catch(ConfigException e) {
logError(e);
}
try {
contextManager.addToolContexts(toolContexts);
} catch(ConfigException e) {
logError(e);
}
List<DesignMenu> menuComponents = readDesignMenu(document);
designMenuManager.addDesignMenuComponents(menuComponents);
}
private void addControlInterfaceList(List<ControlInterface> controlInterfaces)
throws ConfigException
{
for(Iterator<ControlInterface> i = controlInterfaces.iterator(); i.hasNext();) {
ControlInterface c = (ControlInterface)i.next();
if(findControlInterface(c.getName()) != null)
throw new ConfigException("Duplicating control interface '" + c.getName() + "'");
this.controlInterfaceList.add(c);
}
}
private String contextKindToTag(ContextKind contextKind) {
switch(contextKind) {
case INSTALLATION: return CONTEXT_INSTALLATION_TAG;
case PROJECT: return CONTEXT_PROJECT_TAG;
case PACKAGE: return CONTEXT_PACKAGE_TAG;
case TOOL: return CONTEXT_TOOL_TAG;
default:
assert false;
}
return null;
}
private <T extends Context> List<T> readContextList(Document document, ContextKind contextKind)
throws ConfigException
{
final String tag = contextKindToTag(contextKind);
List<T> contextList = new ArrayList<T>();
NodeList contextNodeList = document.getElementsByTagName(tag);
for(int i = 0; i < contextNodeList.getLength(); i++) {
Node contextNode = contextNodeList.item(i);
try {
contextList.add((T)readContextNode(contextNode, contextKind));
} catch(ConfigException e) {
logError(e);
}
}
return contextList;
}
private Context readContextNode(Node contextNode, ContextKind contextKind)
throws ConfigException
{
final String tag = contextKindToTag(contextKind);
final String contextName = getAttributeValue(contextNode, CONTEXT_NAME_ATTR);
if(contextName == null)
throw new ConfigException("Context of type '" + tag + "' definition is bad: " +
"attribute '" + CONTEXT_NAME_ATTR + "' is absent");
NoAttrError err = new NoAttrError() {
public String msg(String attr) {
return "Context '" + contextName +
"' (of type '" + tag +
"') definition is bad: attribute '" + attr +
"' is absent";
}
};
String contextIcon = getAttributeValue(contextNode, CONTEXT_ICON_ATTR);
String contextInterfaceName = getAttributeValue(contextNode, CONTEXT_INTERFACE_ATTR);
String contextLabel = getAttributeValue(contextNode, CONTEXT_LABEL_ATTR);
if(contextLabel == null)
throw new ConfigException(err.msg(CONTEXT_LABEL_ATTR));
Context context = null;
switch(contextKind) {
case INSTALLATION:
context = new InstallationContext(contextName,
contextInterfaceName,
contextLabel,
contextIcon,
null,
null,
null,
null);
break;
case PROJECT:
String packageName = getAttributeValue(contextNode, CONTEXT_PROJECT_PACKAGE_ATTR);
String projectMenu = getAttributeValue(contextNode, CONTEXT_PROJECT_DESIGNMENU_ATTR);
context = new ProjectContext(contextName,
contextInterfaceName,
contextLabel,
contextIcon,
null,
packageName,
null,
null,
null,
projectMenu);
break;
case PACKAGE:
context = new PackageContext(contextName,
contextInterfaceName,
contextLabel,
contextIcon,
null,
null,
null,
null);
break;
case TOOL:
String toolBase = getAttributeValue(contextNode, CONTEXT_TOOL_BASE_ATTR);
String toolPackage = getAttributeValue(contextNode, CONTEXT_TOOL_PACKAGE_ATTR);
String toolProject = getAttributeValue(contextNode, CONTEXT_TOOL_PROJECT_ATTR);
String toolExe = getAttributeValue(contextNode, CONTEXT_TOOL_EXE_ATTR);
String toolShell = getAttributeValue(contextNode, CONTEXT_TOOL_SHELL_ATTR);
String toolErrors = getAttributeValue(contextNode, CONTEXT_TOOL_SYNTAX_ERRORS);
String toolWarnings = getAttributeValue(contextNode, CONTEXT_TOOL_SYNTAX_WARNINGS);
String toolInfo = getAttributeValue(contextNode, CONTEXT_TOOL_SYNTAX_INFO);
boolean isShell=false;
if (toolShell != null){
toolExe=toolShell;
isShell=true;
}
if(toolExe == null)
throw new ConfigException(err.msg(CONTEXT_TOOL_EXE_ATTR));
// if(toolShell == null) toolShell="";
List<String> toolExtensionsList = readToolExtensionsList(contextNode, contextName);
context = new Tool(contextName,
contextInterfaceName,
contextLabel,
contextIcon,
toolBase,
null,
toolPackage,
toolProject,
toolExe,
isShell,
toolExtensionsList,
toolErrors,
toolWarnings,
toolInfo,
null,
null,
null);
break;
default:
throw new ConfigException("Internal error: unknown context kind '" + contextKind + "'");
}
//
// we must read some stuff after the context is created, because the
// creation routines really DO need to have a reference to the context
//
List<Parameter> contextParams = readParameters(contextNode, context);
List<CommandLinesBlock> contextCommandLinesBlocks = readCommandLinesBlocks(contextNode, context);
ContextInputDefinition contextInputDefinition = readContextInputDefinition(contextNode, context);
context.setParams(contextParams);
context.setParamGroups(contextInputDefinition.getParamGroups());
context.setInputDialogLabel(contextInputDefinition.getLabel());
context.setCommandLinesBlocks(contextCommandLinesBlocks);
context.setVersion(currentFileVersion);
return context;
}
private List<ControlInterface> readInterfaceList(Document document) throws ConfigException {
NodeList interfaceNodeList = document.getElementsByTagName(INTERFACE_TAG);
List<ControlInterface> controlInterfaceList = new ArrayList<ControlInterface>();
// now read interface definitions
for(int i = 0; i < interfaceNodeList.getLength(); i++) {
Node interfaceNode = interfaceNodeList.item(i);
if(interfaceNode.getNodeType() != Node.ELEMENT_NODE)
continue;
// extract interface name
String interfaceName =
getAttributeValue(interfaceNode, INTERFACE_NAME_ATTR);
if(interfaceName == null)
throw new ConfigException("Interface name is absent");
String baseInterface =
getAttributeValue(interfaceNode, INTERFACE_EXTENDS_ATTR);
// get and verify interface contents (it must be typedef and syntax lists)
NodeList interfaceContents = interfaceNode.getChildNodes();
try {
List<TypeDef> typeDefList = readTypeDefList(interfaceContents, interfaceName);
List<Syntax> syntaxList = readSyntaxList(interfaceContents, interfaceName);
controlInterfaceList.add(
new ControlInterface(this,
interfaceName,
baseInterface,
typeDefList,
syntaxList));
} catch(ConfigException e) {
logError(e);
}
}
return controlInterfaceList;
}
private List<TypeDef> readTypeDefList(NodeList interfaceContents, String interfaceName)
throws ConfigException
{
String interfaceInfo = "Interface '" + interfaceName + "'";
List<TypeDef> typeDefList = new ArrayList<TypeDef>();
List<Node> typedefNodes = findChildNodes(interfaceContents, TYPEDEF_TAG);
for(Iterator<Node> ni = typedefNodes.iterator(); ni.hasNext();) {
// extract and verify one type definition section
Node node = (Node)ni.next();
String nodeInfo = interfaceInfo + ", node '" + node.getNodeName() + "'";
String name = getAttributeValue(node, TYPEDEF_NAME_ATTR);
String isListAttr = getAttributeValue(node, TYPEDEF_LIST_ATTR);
boolean isList;
if(isListAttr != null) {
checkBoolAttr(isListAttr, TYPEDEF_LIST_ATTR);
isList = getBoolAttrValue(isListAttr);
} else {
isList = false;
}
if(name == null)
throw new ConfigException(nodeInfo + ": Type name is absent");
else if(name.length() == 0)
throw new ConfigException(nodeInfo + ": Empty type name");
// extract and verify the corresponding parameter type
List<Node> paramTypeNodes = findChildNodes(node, TYPEDEF_PARAMTYPE_TAG);
if(paramTypeNodes.isEmpty())
throw new ConfigException(nodeInfo + ": Parameter type is absent");
else if(paramTypeNodes.size() > 1)
throw new ConfigException(nodeInfo + ": There must be only one parameter type");
Node paramTypeNode = paramTypeNodes.get(0);
// now read the parameter type attributes from this definition
// and put it into the list
typeDefList.add(
new TypeDef(name, readParamTypeNode(paramTypeNode, isList, name)));
}
return typeDefList;
}
private ParamType readParamTypeNode(Node paramTypeNode, boolean isList, String typeName)
throws ConfigException
{
String kind = getAttributeValue(paramTypeNode, TYPEDEF_PARAMTYPE_KIND_ATTR);
if(kind == null)
throw new ConfigException("Kind of type '" + typeName + "' is absent");
ParamType paramType = null;
if(kind.equals(ParamTypeBool.NAME))
paramType = createParamTypeBool(paramTypeNode, typeName);
else if(kind.equals(ParamTypeEnum.NAME))
paramType = createParamTypeEnum(paramTypeNode, typeName);
else if(kind.equals(ParamTypeNumber.NAME))
paramType = createParamTypeNumber(paramTypeNode, typeName);
else if(kind.equals(ParamTypeString.NAME))
paramType = createParamTypeString(paramTypeNode, isList, typeName);
else
throw new ConfigException("Unknown parameter type kind: " + kind +
"' for type '" + typeName + "'");
return paramType;
}
private ParamType createParamTypeBool(Node paramTypeNode, String typeName)
throws ConfigException
{
String formatTrue = getAttributeValue(paramTypeNode, ParamTypeBool.FORMAT_TRUE_ID);
String formatFalse = getAttributeValue(paramTypeNode, ParamTypeBool.FORMAT_FALSE_ID);
if(formatTrue == null || formatFalse == null)
throw new ConfigException("Bad bool type '" + typeName + "' definition");
return new ParamTypeBool(formatTrue, formatFalse);
}
private ParamType createParamTypeEnum(Node paramTypeNode, String typeName)
throws ConfigException
{
String baseTypeName = getAttributeValue(paramTypeNode, ParamTypeEnum.BASETYPE_ID);
if(baseTypeName == null)
throw new ConfigException("Enum base type name is absent for type '" + typeName + "'");
NodeList enumDefNodes = paramTypeNode.getChildNodes();
List<String> enumElemLabels = new ArrayList<String>();
List<String> enumElemValues = new ArrayList<String>();
// read the enum definition block
for(int i = 0; i < enumDefNodes.getLength(); i++) {
Node node = enumDefNodes.item(i);
if(isElemNode(node, ENUM_ELEMENT_TAG)) {
String label = getAttributeValue(node, ParamTypeEnum.ELEM_LABEL_ID);
String value = getAttributeValue(node, ParamTypeEnum.ELEM_VALUE_ID);
if(value == null)
throw new ConfigException("Element value for enum type '" + typeName + "' is absent");
else if(enumElemLabels.contains(label))
throw new ConfigException("Element label for enum type '" + typeName + "' cannot be specified more than once");
// if label is not specified, use the read value instead
if(label == null)
label = new String(value);
enumElemLabels.add(label);
enumElemValues.add(value);
}
}
if(enumElemLabels.isEmpty())
throw new ConfigException("Enum label/value list is empty");
return new ParamTypeEnum(baseTypeName,
(String[])enumElemLabels.toArray(new String[enumElemLabels.size()]),
(String[])enumElemValues.toArray(new String[enumElemValues.size()]));
}
private ParamType createParamTypeNumber(Node paramTypeNode, String typeName)
throws ConfigException
{
String lo = getAttributeValue(paramTypeNode, ParamTypeNumber.LO_ID);
String hi = getAttributeValue(paramTypeNode, ParamTypeNumber.HI_ID);
String format = getAttributeValue(paramTypeNode, ParamTypeNumber.FORMAT_ID);
if(hi == null || lo == null || format == null)
throw new ConfigException("Bad number parameter type '" + typeName +
"' definition: one or more of attributes '" +
ParamTypeNumber.LO_ID + "', '" +
ParamTypeNumber.HI_ID + "', '" +
ParamTypeNumber.FORMAT_ID + "' are absent");
return new ParamTypeNumber(Integer.parseInt(lo),
Integer.parseInt(hi),
format);
}
private ParamType createParamTypeString(Node paramTypeNode, boolean isList, String typeName)
throws ConfigException
{
String maxLength = getAttributeValue(paramTypeNode, ParamTypeString.MAX_LENGTH_ID);
String caseSensitive = getAttributeValue(paramTypeNode, ParamTypeString.CASE_SENSITIVITY_ID);
String textKind = getAttributeValue(paramTypeNode, ParamTypeString.KIND_ID);
String filemask = getAttributeValue(paramTypeNode, ParamTypeString.FILEMASK_ID);
if(caseSensitive == null)
throw new ConfigException("Attribute '" + ParamTypeString.CASE_SENSITIVITY_ID +
"' of string type '" + typeName +
"' is absent");
ParamTypeString.CASE caseSensitiveFlag;
if(caseSensitive.equals(ParamTypeString.CASE_SENSITIVE_ID))
caseSensitiveFlag = ParamTypeString.CASE.SENSITIVE;
else if(caseSensitive.equals(ParamTypeString.CASE_INSENSITIVE_ID))
caseSensitiveFlag = ParamTypeString.CASE.INSENSITIVE;
else if(caseSensitive.equals(ParamTypeString.CASE_UPPERCASE_ID))
caseSensitiveFlag = ParamTypeString.CASE.UPPERCASE;
else if(caseSensitive.equals(ParamTypeString.CASE_LOWERCASE_ID))
caseSensitiveFlag = ParamTypeString.CASE.LOWERCASE;
else
throw new ConfigException("Unknown value of " +
ParamTypeString.CASE_SENSITIVE_ID +
" attribute in the type '" + typeName +
"' definition");
int maxLengthValue = maxLength != null? Integer.parseInt(maxLength) : ParamTypeString.DEFAULT_LENGTH;
if(textKind == null) {
return new ParamTypeString(isList, maxLengthValue, caseSensitiveFlag);
} else {
ParamTypeString.KIND textKindValue;
if(textKind.equals(ParamTypeString.KIND_FILE_ID))
textKindValue = ParamTypeString.KIND.FILE;
else if(textKind.equals(ParamTypeString.KIND_DIR_ID))
textKindValue = ParamTypeString.KIND.DIR;
else if(textKind.equals(ParamTypeString.KIND_TEXT_ID))
textKindValue = ParamTypeString.KIND.TEXT;
else
throw new ConfigException("Unknown value of " + ParamTypeString.KIND_ID +
" attribute in the type '" + typeName +
"' definition");
return new ParamTypeString(isList,
maxLengthValue,
caseSensitiveFlag,
textKindValue,
filemask);
}
}
private List<Syntax> readSyntaxList(NodeList interfaceContents, String interfaceName)
throws ConfigException
{
List<Syntax> syntaxList = new ArrayList<Syntax>();
List<Node> syntaxNodes = findChildNodes(interfaceContents, SYNTAX_TAG);
for(Iterator<Node> n = syntaxNodes.iterator(); n.hasNext();) {
try {
syntaxList.add(readSyntaxNode((Node)n.next(), interfaceName));
} catch(ConfigException e) {
logError(e);
}
}
return syntaxList;
}
private Syntax readSyntaxNode(Node syntaxNode, String interfaceName)
throws ConfigException
{
String nodeInfo = "Interface '" + interfaceName +
"', node '" + syntaxNode.getNodeName() + "'";
String name = getAttributeValue(syntaxNode, SYNTAX_NAME_ATTR);
String format = getAttributeValue(syntaxNode, SYNTAX_FORMAT_ATTR);
String type = getAttributeValue(syntaxNode, SYNTAX_TYPE_ATTR);
if(name == null)
throw new ConfigException(nodeInfo + ": Syntax name is absent");
else if(format == null)
throw new ConfigException(nodeInfo + ": Syntax format is absent");
return new Syntax(name, format, type);
}
private List<String> readToolExtensionsList(Node toolNode, String toolName)
throws ConfigException
{
String toolInfo = "Tool '" + toolName + "'";
List<String> extList = new ArrayList<String>();
List<Node> extListNodes = findChildNodes(toolNode, CONTEXT_TOOL_EXTENSIONS_LIST_TAG);
if(extListNodes.isEmpty())
return null;
// throw new ConfigException(toolInfo +
// " definition doesn't contain '" +
// CONTEXT_OUTPUT_SECTION_TAG +
// "' node");
if(extListNodes.size() > 1)
throw new ConfigException(toolInfo +
" definition cannot contain several '" +
CONTEXT_OUTPUT_SECTION_TAG +
"' nodes");
Node extListNode = extListNodes.get(0);
List<Node> extNodes = findChildNodes(extListNode, CONTEXT_TOOL_EXTENSION_TAG);
for(Iterator<Node> n = extNodes.iterator(); n.hasNext();) {
Node node = (Node)n.next();
String ext = getAttributeValue(node, CONTEXT_TOOL_EXTENSION_MASK_ATTR);
if(ext == null)
throw new ConfigException(toolInfo + ": Attribute '" + CONTEXT_TOOL_EXTENSION_MASK_ATTR + "' is absent");
extList.add(ext);
}
return extList;
}
private List<Parameter> readParameters(Node node, Context context)
throws ConfigException
{
ParamNodeReader paramNodeReader = new ParamNodeReader(this, context);
new ConditionNodeReader(this, context, paramNodeReader).readNode(node);
return paramNodeReader.getParamList();
}
/////
private List<DesignMenu> readDesignMenu(Document document) throws ConfigException {
List<Node> menuNodes = findChildNodes(rootNode, MENU_TAG);
List<DesignMenu> menuList = new ArrayList<DesignMenu>();
for(Iterator<Node> node = menuNodes.iterator(); node.hasNext();) {
try {
menuList.add(readDesignMenuNode((Node)node.next(), null));
} catch(ConfigException e) {
logError(e);
}
}
return menuList;
}
private DesignMenu readDesignMenuNode(Node menuNode, DesignMenu parentMenu)
throws ConfigException
{
final String menuName = getAttributeValue(menuNode, MENU_NAME_ATTR);
if(menuName == null)
throw new ConfigException("Menu must have '" + MENU_NAME_ATTR + "' attribute");
String menuInherits = getAttributeValue(menuNode, MENU_INHERITS_ATTR);
String menuAfter = getAttributeValue(menuNode, MENU_AFTER_ATTR);
String menuLabel = getAttributeValue(menuNode, MENU_LABEL_ATTR);
String menuIcon = getAttributeValue(menuNode, MENU_ICON_ATTR);
String menuDescr = getAttributeValue(menuNode, MENU_DESCRIPTION_ATTR);
String menuVisible = getAttributeValue(menuNode, MENU_VISIBLE_ATTR);
Boolean isVisible = null;
if(menuVisible != null) {
checkBoolAttr(menuVisible, MENU_VISIBLE_ATTR);
isVisible = getBoolAttrValue(menuVisible);
}
List<DesignMenuItem> menuItems = new ArrayList<DesignMenuItem>();
DesignMenu designMenu = new DesignMenu(this,
parentMenu,
menuInherits,
menuAfter,
menuName,
menuLabel,
menuIcon,
menuDescr,
isVisible,
menuItems);
for(int i = 0; i < menuNode.getChildNodes().getLength(); i++) {
Node child = menuNode.getChildNodes().item(i);
try {
if(isElemNode(child, MENUITEM_TAG)) {
menuItems.add(readDesignMenuItemNode(child, designMenu));
} else if(isElemNode(child, MENU_TAG)) {
menuItems.add(readDesignMenuNode(child, designMenu));
}
} catch(ConfigException e) {
logError(e);
}
}
return designMenu;
}
private DesignMenuItem readDesignMenuItemNode(Node menuItemNode, final DesignMenu parentMenu)
throws ConfigException
{
final String itemName = getAttributeValue(menuItemNode, MENUITEM_NAME_ATTR);
if(itemName == null)
throw new ConfigException("Menu '" + parentMenu.getName() +
"' item must have '" + MENUITEM_NAME_ATTR +
"' attribute");
String itemLabel = getAttributeValue(menuItemNode, MENUITEM_LABEL_ATTR);
String itemIcon = getAttributeValue(menuItemNode, MENUITEM_ICON_ATTR);
String itemCall = getAttributeValue(menuItemNode, MENUITEM_CALL_ATTR);
String itemVisible = getAttributeValue(menuItemNode, MENUITEM_VISIBLE_ATTR);
String itemAfter = getAttributeValue(menuItemNode, MENUITEM_AFTER_ATTR);
Boolean isVisible = null;
if(itemVisible != null) {
checkBoolAttr(itemVisible, MENUITEM_VISIBLE_ATTR);
isVisible = getBoolAttrValue(itemVisible);
}
return new DesignMenuToolItem(this,
parentMenu,
itemAfter,
itemName,
itemLabel,
itemIcon,
isVisible,
itemCall);
}
private List<CommandLinesBlock> readCommandLinesBlocks(Node node, Context context)
throws ConfigException
{
List<CommandLinesBlock> commandLinesBlocks = new ArrayList<CommandLinesBlock>();
List<Node> outputNodes = findChildNodes(node, CONTEXT_OUTPUT_SECTION_TAG);
if(outputNodes.isEmpty())
return commandLinesBlocks;
else if(outputNodes.size() > 1)
throw new ConfigException("Context '" + context.getName() +
"' definition cannot contain several '" +
CONTEXT_OUTPUT_SECTION_TAG +
"' nodes");
Node outputNode = outputNodes.get(0);
CommandLinesNodeReader commandLinesNodeReader = new CommandLinesNodeReader(this, context);
new ConditionNodeReader(this, context, commandLinesNodeReader).readNode(outputNode);
return commandLinesNodeReader.getCommandLinesBlocks();
}
private ContextInputDefinition readContextInputDefinition(Node node, Context context)
throws ConfigException
{
List<ParamGroup> paramGroups = new ArrayList<ParamGroup>();
List<Node> inputNodes = findChildNodes(node, CONTEXT_INPUT_SECTION_TAG);
if(inputNodes.isEmpty())
return new ContextInputDefinition(null, paramGroups);
else if(inputNodes.size() > 1)
throw new ConfigException("Context '" + context.getName() +
"' input definition cannot contain several '" +
CONTEXT_INPUT_SECTION_TAG +
"' nodes");
Node inputNode = inputNodes.get(0);
String label = getAttributeValue(inputNode, CONTEXT_INPUT_SECTION_LABEL_ATTR);
ParamGroupNodeReader paramGroupNodeReader = new ParamGroupNodeReader(this, context);
new ConditionNodeReader(this, context, paramGroupNodeReader).readNode(inputNode);
return new ContextInputDefinition(label, paramGroupNodeReader.getParamGroups());
}
/////
private void findRootNode(Document document) throws ConfigException {
NodeList roots = document.getChildNodes();
int rootsNum = 0;
for(int i = 0; i < roots.getLength(); i++) {
Node node = roots.item(i);
if(node.getNodeType() == Node.ELEMENT_NODE) {
if((++rootsNum > 1) || !node.getNodeName().equals(ROOT_NODE_TAG))
throw new ConfigException("Config file must contain only one root node '" +
ROOT_NODE_TAG + "'");
rootNode = node;
currentFileVersion = getAttributeValue(node, ROOT_VERSION_ATTR);
}
}
if(rootsNum == 0)
throw new ConfigException("Config file must contain root node '" +
ROOT_NODE_TAG + "'");
}
}
abstract class NoAttrError {
abstract String msg(String attr);
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.contexts;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.ArrayList;
import java.util.List;
import com.elphel.vdt.core.tools.config.Config;
import com.elphel.vdt.core.tools.config.ConfigException;
import com.elphel.vdt.core.tools.params.*;
import com.elphel.vdt.core.tools.params.recognizers.*;
import com.elphel.vdt.core.tools.params.types.ParamTypeString;
import com.elphel.vdt.core.tools.params.Parameter;
import com.elphel.vdt.core.tools.params.conditions.StringConditionParser;
import com.elphel.vdt.util.StringPair;
public abstract class Context {
protected String name;
protected String label;
protected String iconName;
protected String controlInterfaceName;
protected String inputDialogLabel;
protected ParameterContainer paramContainer;
protected ControlInterface controlInterface;
protected List<ParamGroup> paramGroups;
protected List<CommandLinesBlock> commandLinesBlocks;
protected List<ParamGroup> visibleParamGroups = new ArrayList<ParamGroup>();
protected Config config;
private StringConditionParser conditionParser = new StringConditionParser(this);
private List<String> createdControlFiles = new ArrayList<String>();
private boolean initialized = false;
private String workingDirectory;
private String version;
protected Context(String name,
String controlInterfaceName,
String label,
String iconName,
String inputDialogLabel,
List<Parameter> params,
List<ParamGroup> paramGroups,
List<CommandLinesBlock> commandLinesBlocks)
{
this.name = name;
this.controlInterfaceName = controlInterfaceName;
this.label = label;
this.iconName = iconName;
this.commandLinesBlocks = commandLinesBlocks;
this.inputDialogLabel = inputDialogLabel;
this.paramGroups = paramGroups;
this.paramContainer = new ParameterContainer(params);
}
public void init(Config config) throws ConfigException {
checkNotInitialized();
this.config = config;
initControlInterface();
initParams();
initCommandLines();
initialized = true;
}
public void setVersion(String version) {
this.version = version;
}
public String getVersion() {
return version;
}
public void setParams(List<Parameter> params) throws ConfigException {
checkNotInitialized();
this.paramContainer = new ParameterContainer(params);
}
public void setParamGroups(List<ParamGroup> paramGroups) throws ConfigException {
checkNotInitialized();
this.paramGroups = paramGroups;
}
public void setInputDialogLabel(String inputDialogLabel) throws ConfigException {
checkNotInitialized();
this.inputDialogLabel = inputDialogLabel;
}
public void setCommandLinesBlocks(List<CommandLinesBlock> commandLinesBlocks) throws ConfigException {
checkNotInitialized();
this.commandLinesBlocks = commandLinesBlocks;
}
public void setWorkingDirectory(String location) {
this.workingDirectory = location;
}
public String getName() {
return name;
}
public String getLabel() {
return label;
}
public String getEscapedLabel() {
return label.replace(" ", "_");
}
public String getNiceLabel() {
return label.replace("_", " ");
}
public String getIconName() {
return iconName;
}
public List<Parameter> getParams() {
return paramContainer.getParams();
}
public String getInputDialogLabel() {
return inputDialogLabel;
}
public ControlInterface getControlInterface() {
return controlInterface;
}
public List<ParamGroup> getParamGroups() {
return paramGroups;
}
public List<ParamGroup> getVisibleParamGroups() {
// try {
// initParamGroups();
// } catch(ConfigException e) {
// MessageUI.error(e);
// }
return visibleParamGroups;
}
public boolean isVisible() {
return !getVisibleParamGroups().isEmpty();
}
public Parameter findParam(String paramID) {
return paramContainer.findParam(paramID);
}
public StringConditionParser getConditionParser() {
return conditionParser;
}
public List<String> getCreatedControlFiles() {
return createdControlFiles;
}
// scans all the parameters that belong to the tool, checks those of them
// which need to be put into a control file, and puts them to that file
// all other needed params are built into command line array
// that array is then returned
public String[] buildParams() throws ToolException {
List<String> commandLineParams = new ArrayList<String>();
Iterator<CommandLinesBlock> commandLinesBlockIter = commandLinesBlocks.iterator();
createdControlFiles.clear();
while(commandLinesBlockIter.hasNext()) {
CommandLinesBlock commandLinesBlock = (CommandLinesBlock)commandLinesBlockIter.next();
if(!commandLinesBlock.isEnabled())
continue;
String paramName = commandLinesBlock.getDestination();
String sep = commandLinesBlock.getSeparator();
List<String> lines = commandLinesBlock.getLines();
List<List<String>> commandSequence = new ArrayList<List<String>>();
for(Iterator<String> lineIter = lines.iterator(); lineIter.hasNext();) {
String line = (String)lineIter.next();
commandSequence.add(buildCommandString(line));
}
if(paramName != null) {
Parameter commandFileParam = findParam(paramName);
String controlFileName = commandFileParam != null?
commandFileParam.getValue().get(0).trim() : null;
if(workingDirectory != null)
controlFileName = workingDirectory + File.separator + controlFileName;
// check param type first
if(!(commandFileParam.getType() instanceof ParamTypeString))
throw new ToolException("Parameter '" + commandFileParam.getID() +
"' specified in the description of context '" + name +
"' must be of type '" + ParamTypeString.NAME + "'");
// write strings to control file
boolean controlFileExists = controlFileExists(controlFileName);
printStringsToFile(controlFileName, controlFileExists, commandSequence, sep);
if(!controlFileExists)
createdControlFiles.add(controlFileName);
} else {
printStringsToCommandLine(commandLineParams, commandSequence);
}
}
return (String[])commandLineParams.toArray(new String[commandLineParams.size()]);
}
protected List<String> buildCommandString(String paramStringTemplate)
throws ToolException
{
FormatProcessor processor = new FormatProcessor(new Recognizer[] {
new SimpleGeneratorRecognizer(),
new RepeaterRecognizer()
// new ContextParamRecognizer(this),
// new ContextParamRepeaterRecognizer(this)
});
return processor.process(paramStringTemplate);
}
protected void initControlInterface() throws ConfigException {
if(controlInterfaceName != null) {
controlInterface = config.findControlInterface(controlInterfaceName);
if(controlInterface == null)
throw new ConfigException("No such control interface '" + controlInterfaceName +
"' (used in context '" + name +
"')");
}
}
protected void initCommandLines() throws ConfigException {
for(Iterator<CommandLinesBlock> i = commandLinesBlocks.iterator(); i.hasNext();)
((CommandLinesBlock)i.next()).init(config);
}
protected void initParams() throws ConfigException {
paramContainer.init(config, this);
// do the first init to detect most errors
initParamGroups();
}
protected void initParamGroups() throws ConfigException {
visibleParamGroups.clear();
List<StringPair> foundParams =
new ArrayList<StringPair>(paramContainer.getParams().size());
for(ParamGroup group : paramGroups) {
List<String> paramIDs = group.getParams();
// just ignore irrelevant param groups
if(!group.isRelevant())
continue;
for(String id : paramIDs) {
if(findParam(id) == null)
throw new ConfigException("Parameter '" + id +
"' in context '" + name +
"' referenced from parameter group '" + group.getName() +
"' is absent");
// check the presence of the given parameter
// in other param groups
for(StringPair pair : foundParams) {
String otherParamId = pair.getFirst();
String otherGroupName = pair.getSecond();
if(otherParamId.equals(id)) {
if(group.getName().equals(otherGroupName))
throw new ConfigException("Parameter '" + id +
"' in context '" + name +
"' is referenced from parameter group '" +
group.getName() +
"' more than once");
else
throw new ConfigException("Parameter '" + id +
"' in context '" + name +
"' is referenced from two parameter groups: '" +
group.getName() +
"' and '" +
otherGroupName +
"'");
}
}
foundParams.add(new StringPair(id, group.getName()));
}
if(group.isVisible())
visibleParamGroups.add(group);
}
}
private boolean controlFileExists(String controlFileName) {
for(Iterator<String> i = createdControlFiles.iterator(); i.hasNext();) {
if(controlFileName.equals(i.next()))
return true;
}
return false;
}
private void printStringsToFile(String controlFileName,
boolean append,
List<List<String>> commandString,
String separator)
throws ToolException
{
FileOutputStream outputStream = null;
try {
File file = new File(controlFileName);
outputStream = new FileOutputStream(file, append);
} catch(FileNotFoundException e) {
throw new ToolException("Cannot open file '" + controlFileName + "' for writing");
}
String sep = (separator != null? separator : " ");
PrintWriter out = new PrintWriter(new OutputStreamWriter(outputStream));
int written = 0;
for(Iterator<List<String>> li = commandString.iterator(); li.hasNext();) {
List<String> strList = (List<String>)li.next();
if(strList.size() > 0) {
int writtenNow = 0;
for(Iterator<String> si = strList.iterator(); si.hasNext();) {
String s = (String)si.next();
if(s.length() == 0)
continue;
out.print(s);
written += s.length();
writtenNow += s.length();
// try to avoid needless spaces
if(writtenNow > 0 && si.hasNext()) {
String stripped = s.
replace('\n', ' ').
replace('\t', ' ').
trim();
if(stripped.length() > 0)
out.print(" ");
}
}
if(writtenNow > 0 && li.hasNext())
out.print(sep);
}
}
if(written > 0)
out.println();
out.close();
}
private void printStringsToCommandLine(List<String> commandLineParams,
List<List<String>> commandSequence)
throws ToolException
{
for(Iterator<List<String>> li = commandSequence.iterator(); li.hasNext();) {
List<String> strList = (List<String>)li.next();
if(strList.size() > 0) {
for(Iterator<String> si = strList.iterator(); si.hasNext();) {
String s = ((String)si.next()).trim();
if(!s.equals(""))
commandLineParams.add(s);
}
}
}
}
private void checkNotInitialized() throws ConfigException {
if(initialized)
throw new ConfigException("Context cannot be re-initialized");
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.contexts;
import java.util.*;
import com.elphel.vdt.core.tools.config.Config;
import com.elphel.vdt.core.tools.params.Tool;
import com.elphel.vdt.core.tools.config.ConfigException;
import com.elphel.vdt.core.tools.menu.DesignMenu;
public class ContextManager {
private Config config;
private InstallationContext installationContext;
private List<ProjectContext> projectContexts = new ArrayList<ProjectContext>();
private List<PackageContext> packageContexts = new ArrayList<PackageContext>();
private List<Tool> toolContexts = new ArrayList<Tool>();
private final String cannotAddMessage = "Cannot add a context after initialization";
private boolean initialized = false;
public void init(Config config) throws ConfigException {
if(initialized)
throw new ConfigException("Context layer cannot be re-initialized");
this.config = config;
if(installationContext != null)
installationContext.init(config);
for(PackageContext packageContext : packageContexts)
packageContext.init(config);
for(ProjectContext projectContext : projectContexts)
projectContext.init(config);
for(Tool toolContext : toolContexts)
toolContext.init(config);
initialized = true;
}
public void addInstallationContexts(List<InstallationContext> contexts) throws ConfigException {
if(initialized)
throw new ConfigException(cannotAddMessage);
if(contexts.isEmpty())
return;
if(installationContext != null || contexts.size() > 1)
throw new ConfigException("There cannot be several installation contexts");
installationContext = contexts.get(0);
}
public void addProjectContexts(List<ProjectContext> contexts) throws ConfigException {
if(initialized)
throw new ConfigException(cannotAddMessage);
projectContexts.addAll(contexts);
}
public void addPackageContexts(List<PackageContext> contexts) throws ConfigException {
if(initialized)
throw new ConfigException(cannotAddMessage);
packageContexts.addAll(contexts);
}
public void addToolContexts(List<Tool> contexts) throws ConfigException {
if(initialized)
throw new ConfigException(cannotAddMessage);
toolContexts.addAll(contexts);
}
public Context findContext(String contextName) {
if(installationContext != null && installationContext.getName().equals(contextName))
return installationContext;
Context found = findContext(projectContexts, contextName);
if(found != null)
return found;
found = findContext(packageContexts, contextName);
if(found != null)
return found;
return findTool(contextName);
}
public InstallationContext getInstallationContext() {
return installationContext;
}
public ProjectContext getProjectContext(String projectName) {
Context projectContext = findContext(projectName);
if(projectContext != null) {
assert projectContext instanceof ProjectContext;
return (ProjectContext)projectContext;
}
return null;
}
public List<PackageContext> getPackageContexts() {
return packageContexts;
}
public List<ProjectContext> getProjectContexts() {
return projectContexts;
}
public List<Tool> getToolList() {
return toolContexts;
}
public Tool findTool(String toolName) {
return (Tool)findContext(toolContexts, toolName);
}
public DesignMenu getDesignMenu() {
DesignMenu menu = null;
//
// TODO
//
// if(projectContext != null) {
// menu = projectContext.getDesignMenu();
//
// if(menu != null)
// return menu;
// }
if(installationContext != null) {
menu = installationContext.getDesignMenu();
if(menu != null)
return menu;
}
return config.getDesignMenuManager().getRootDesignMenu();
}
private Context findContext(List<? extends Context> contexts, String name) {
for(Context context : contexts) {
if(context.getName().equals(name))
return context;
}
return null;
}
}
\ No newline at end of file
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.contexts;
import java.util.List;
import java.util.Iterator;
import com.elphel.vdt.core.tools.params.CommandLinesBlock;
import com.elphel.vdt.core.tools.params.ParamGroup;
import com.elphel.vdt.core.tools.params.Parameter;
import com.elphel.vdt.core.tools.config.ConfigException;
public abstract class ContextWithoutCommandLine extends Context {
protected ContextWithoutCommandLine(String name,
String controlInterfaceName,
String label,
String iconName,
String inputDialogLabel,
List<Parameter> params,
List<ParamGroup> paramGroups,
List<CommandLinesBlock> commandLinesBlocks)
throws ConfigException
{
super(name,
controlInterfaceName,
label,
iconName,
inputDialogLabel,
params,
paramGroups,
commandLinesBlocks);
checkCmdLine();
}
public void setCommandLinesBlocks(List<CommandLinesBlock> commandLinesBlocks) throws ConfigException {
super.setCommandLinesBlocks(commandLinesBlocks);
checkCmdLine();
}
private void checkCmdLine() throws ConfigException {
if(commandLinesBlocks != null) {
for(Iterator<CommandLinesBlock> i = commandLinesBlocks.iterator(); i.hasNext();) {
CommandLinesBlock block = (CommandLinesBlock)i.next();
String destination = block.getDestination();
if(destination == null || destination.equals(""))
throw new ConfigException("Context '" + name +
"' cannot contain command line, but destination of its '" +
block.getName() +
"' command block is not specified");
}
}
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.contexts;
import java.util.List;
import com.elphel.vdt.core.tools.menu.DesignMenu;
import com.elphel.vdt.core.tools.params.CommandLinesBlock;
import com.elphel.vdt.core.tools.params.ParamGroup;
import com.elphel.vdt.core.tools.params.Parameter;
import com.elphel.vdt.core.tools.config.Config;
import com.elphel.vdt.core.tools.config.ConfigException;
public class InstallationContext extends ContextWithoutCommandLine {
private DesignMenu designMenu;
public InstallationContext(String name,
String controlInterfaceName,
String label,
String iconName,
String inputDialogLabel,
List<Parameter> params,
List<ParamGroup> paramGroups,
List<CommandLinesBlock> commandLinesBlocks)
throws ConfigException
{
super(name,
controlInterfaceName,
label,
iconName,
inputDialogLabel,
params,
paramGroups,
commandLinesBlocks);
}
public void init(Config config) throws ConfigException {
super.init(config);
}
public DesignMenu getDesignMenu() {
return designMenu;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.contexts;
import java.util.List;
import com.elphel.vdt.core.tools.params.CommandLinesBlock;
import com.elphel.vdt.core.tools.params.ParamGroup;
import com.elphel.vdt.core.tools.params.Parameter;
import com.elphel.vdt.core.tools.config.ConfigException;
public class PackageContext extends ContextWithoutCommandLine {
public PackageContext(String name,
String controlInterfaceName,
String label,
String iconName,
String inputDialogLabel,
List<Parameter> params,
List<ParamGroup> paramGroups,
List<CommandLinesBlock> commandLinesBlocks)
throws ConfigException
{
super(name,
controlInterfaceName,
label,
iconName,
inputDialogLabel,
params,
paramGroups,
commandLinesBlocks);
}
public Parameter findParam(String paramID) {
Parameter param = super.findParam(paramID);
if(param == null) {
InstallationContext installation = config.getContextManager().getInstallationContext();
if(installation != null)
param = installation.findParam(paramID);
}
return param;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.contexts;
import java.util.List;
import com.elphel.vdt.core.tools.params.*;
import com.elphel.vdt.core.tools.config.Config;
import com.elphel.vdt.core.tools.config.ConfigException;
import com.elphel.vdt.core.tools.menu.DesignMenu;
public class ProjectContext extends Context {
private String parentPackageName;
private String designMenuName;
private DesignMenu designMenu;
private PackageContext parentPackage;
public ProjectContext(String name,
String controlInterfaceName,
String label,
String iconName,
String inputDialogLabel,
String parentPackageName,
List<Parameter> params,
List<ParamGroup> paramGroups,
List<CommandLinesBlock> commandLinesBlocks,
String designMenuName)
throws ConfigException
{
super(name,
controlInterfaceName,
label,
iconName,
inputDialogLabel,
params,
paramGroups,
commandLinesBlocks);
this.parentPackageName = parentPackageName;
this.designMenuName = designMenuName;
}
public void init(Config config) throws ConfigException {
super.init(config);
if(designMenuName != null) {
designMenu = config.getDesignMenuManager().findDesignMenu(designMenuName);
if(designMenu == null)
throw new ConfigException("Design menu '" + designMenuName +
"' used in project context '" + name +
"' is not found");
}
initParentPackage();
}
public DesignMenu getDesignMenu() {
return designMenu;
}
public PackageContext getParentPackage() {
return parentPackage;
}
public String getDesignMenuName() {
return designMenuName;
}
public Parameter findParam(String paramID) {
Parameter param = super.findParam(paramID);
if(param == null && parentPackage != null)
param = parentPackage.findParam(paramID);
if(param == null) {
InstallationContext installation = config.getContextManager().getInstallationContext();
if(installation != null)
param = installation.findParam(paramID);
}
return param;
}
private void initParentPackage() throws ConfigException {
if(parentPackageName != null) {
parentPackage =
(PackageContext)config.getContextManager().findContext(parentPackageName);
if(parentPackage == null) {
throw new ConfigException("Parent package context '" + parentPackageName +
"' of project '" + name +
"' is absent");
} else if(!ControlInterface.isInheritedOrSame(parentPackage.getControlInterface(), controlInterface)) {
throw new ConfigException("Control interface of parent package context '" + parentPackageName +
"' of project '" + name +
"' is neither equal to nor base of control interface of the project");
}
}
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.generators;
import com.elphel.vdt.core.Utils;
import com.elphel.vdt.ui.MessageUI;
/**
* Common engine for strings generation.
*
* Created: 21.02.2006
* @author Lvov Konstantin
*/
public abstract class AbstractGenerator {
protected final String prefix, suffix;
protected String separator;
private final boolean forcedMultiline;
public AbstractGenerator() {
this(false);
}
public AbstractGenerator(String prefix,
String suffix,
String separator)
{
this(prefix, suffix, separator, false);
}
protected AbstractGenerator(boolean forcedMultiline) {
this("", "", "", forcedMultiline);
}
protected AbstractGenerator(String prefix,
String suffix,
String sep,
boolean forcedMultiline)
{
this.prefix = prefix;
this.suffix = suffix;
this.forcedMultiline = forcedMultiline;
this.separator = sep;
separator = separator.replace("\\n", "\n");
separator = separator.replace("\\t", "\t");
}
public abstract String getName();
public String[] generate() {
boolean multiline = Utils.stringContainsSpace(separator);
String[] output;
if(multiline || forcedMultiline)
output = generateMultipleLine(prefix, suffix, separator);
else
output = generateSingleLine(prefix, suffix, separator);
return output;
}
protected String[] generateSingleLine(String prefix, String suffix, String separator) {
String[] values = getStringValues();
String output = "";
if((values != null) && (values.length > 0)) {
for(int i = 0; i < values.length; i++) {
// output += prefix + values[i] + suffix + separator;
output += prefix + values[i] + suffix; /*TODO: Check I did not break anything, but for a "repetitor" separator was duplicate*/
if(i < values.length-1)
output += separator;
}
}
return new String[]{output};
}
protected String[] generateMultipleLine(String prefix, String suffix, String separator) {
String[] values = getStringValues();
if((values == null) || (values.length == 0))
return new String[]{""};
final int outputLen = values.length*2 - 1;
String[] output = new String[outputLen];
for(int i = 0; i < values.length; i++) {
output[i*2] = prefix + values[i] + suffix;
if(i < values.length-1)
output[i*2+1] = separator;
}
return output;
}
protected void fault(String message) {
MessageUI.error("Generator '" + getName() + "' fault: " + message);
}
protected abstract String[] getStringValues();
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.generators;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import com.elphel.vdt.VDT;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
public class CurrentFileBaseGenerator extends AbstractGenerator {
public static final String NAME = VDT.GENERATOR_ID_CURRENT_BASE;
public String getName() {
return NAME;
}
protected String[] getStringValues() {
IResource resource = SelectedResourceManager.getDefault().getSelectedResource();
if((resource != null) && (resource.getType() == IResource.FILE)) {
String fullName=((IFile)resource).getLocation().toOSString();
int dot = fullName.lastIndexOf('.');
return new String[] { (dot <0) ? fullName : fullName.substring(0, dot) };
}
return new String[] { "" };
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.generators;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import com.elphel.vdt.VDT;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
public class CurrentFileGenerator extends AbstractGenerator {
private static final String NAME = VDT.GENERATOR_ID_CURRENT_FILE;
public String getName() {
return NAME;
}
protected String[] getStringValues() {
IResource resource = SelectedResourceManager.getDefault().getSelectedResource();
if((resource != null) && (resource.getType() == IResource.FILE))
return new String[] { ((IFile)resource).getLocation().toOSString() };
return new String[] { "" };
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.generators;
import java.util.*;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import com.elphel.vdt.VDT;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
public class FileListGenerator extends AbstractGenerator {
// public static final String NAME = VDT.GENERATOR_ID_FILE_LIST;
public static final String NAME = "FileList";
public FileListGenerator(String prefix,
String suffix,
String separator)
{
super(prefix, suffix, separator);
}
public String getName() {
return NAME;
}
protected String[] getStringValues() {
IProject project = SelectedResourceManager.getDefault().getSelectedProject();
List<String> files = getContainedFiles(project);
return files.toArray(new String[files.size()]);
}
private List<String> getContainedFiles(IContainer container) {
IResource[] members = null;
try {
members = container.members();
} catch (CoreException e) {
return null;
}
List<String> files = new ArrayList<String>(members.length);
for(int i = 0; i < members.length; i++) {
if(members[i] instanceof IContainer)
files.addAll(getContainedFiles((IContainer)members[i]));
else if(members[i] instanceof IFile)
files.add(((IFile)members[i]).getProjectRelativePath().toOSString());
//files.add(((IFile)members[i]).getLocation().toOSString());
}
return files;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.generators;
import com.elphel.vdt.VDT;
import com.elphel.vdt.ui.MessageUI;
public class OSNameGenerator extends AbstractGenerator {
public static final String NAME = VDT.GENERATOR_ID_OS_NAME;
private static final String OS_WINDOWS = "Windows";
private static final String OS_LINUX = "Linux";
public String getName() {
return NAME;
}
protected String[] getStringValues() {
String osName = System.getProperty("os.name");
if(osName.indexOf(OS_WINDOWS) >= 0) {
return new String[] { OS_WINDOWS };
} else if (osName.indexOf("Linux") >= 0) {
return new String[] { OS_LINUX };
} else {
MessageUI.error("Generator '" + getName() + "' failure: OS '" + osName + "' is unknown");
return null;
}
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.generators;
import org.eclipse.core.resources.IResource;
import com.elphel.vdt.VDT;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
/**
* Generate the name of current project.
*
* Created: 21.02.2006
* @author Lvov Konstantin
*/
public class ProjectNameGenerator extends AbstractGenerator {
public static final String NAME = VDT.GENERATOR_ID_PROJECT_NAME;
public String getName() {
return NAME;
}
protected String[] getStringValues() {
String[] value = null;
IResource resource = SelectedResourceManager.getDefault().getSelectedResource();
if (resource != null) {
String project_name = resource.getProject().getName();
value = new String[]{project_name};
} else {
fault("There is no selected project");
}
return value;
}
} // class ProjectNameGenerator
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.generators;
import java.io.File;
import org.eclipse.core.resources.IResource;
import com.elphel.vdt.VDT;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
/**
* Generate the absolute path of the current project.
*
* Created: 21.02.2006
* @author Lvov Konstantin
*/
public class ProjectPathGenerator extends AbstractGenerator {
public static final String NAME = VDT.GENERATOR_ID_PROJECT_PATH;
public String getName() {
return NAME;
}
protected String[] getStringValues() {
String[] value = null;
IResource resource = SelectedResourceManager.getDefault().getSelectedResource();
if (resource != null) {
String workspaceRoot=resource.getWorkspace().getRoot().getLocation().toString();
String project_name = workspaceRoot+resource.getProject().getFullPath().toString()+File.separator;
value = new String[]{project_name};
} else {
fault("There is no selected project");
}
return value;
}
} // class ProjectPathGenerator
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.generators;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
//import com.elphel.vdt.VDT;
import com.elphel.vdt.VerilogUtils;
//import com.elphel.vdt.core.verilog.VerilogUtils;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
/**
* Generate the file name list of dependency closure for last selected
* verilog source file.
*
* Created: 21.02.2006
* @author Lvov Konstantin
*/
public class SourceListGenerator extends AbstractGenerator {
// public static final String NAME = VDT.GENERATOR_ID_SOURCE_LIST;
public static final String NAME = "SourceList";
public SourceListGenerator(String prefix,
String suffix,
String separator)
{
super(prefix, suffix, separator);
}
public String getName() {
return NAME;
}
protected String[] getStringValues() {
String[] file_names = null;
IResource resource = SelectedResourceManager.getDefault().getSelectedVerilogFile();
if (resource != null && resource.getType() == IResource.FILE) {
IFile[] files = VerilogUtils.getDependencies((IFile)resource);
file_names = new String[files.length];
for (int i=0; i < files.length; i++)
file_names[i] = files[i].getProjectRelativePath().toOSString(); //.getName();
} else {
fault("There is no selected project");
}
return file_names;
}
} // class SourceListGenerator
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.generators;
public abstract class StringsGenerator extends AbstractGenerator {
private final String[] paramStrings;
public StringsGenerator(String[] paramStrings) {
super(true);
this.paramStrings = paramStrings;
}
protected String[] getStringValues() {
return paramStrings;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.generators;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import com.elphel.vdt.VDT;
import com.elphel.vdt.VerilogUtils;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
/**
* Generate the top module name from last selected verilog source file.
*
* Created: 21.02.2006
* @author Lvov Konstantin
*/
public class TopModuleNameGenerator extends AbstractGenerator {
private static final String NAME = VDT.GENERATOR_ID_TOP_MODULE;
public String getName() {
return NAME;
}
protected String[] getStringValues() {
IResource resource = SelectedResourceManager.getDefault().getSelectedVerilogFile();
if ((resource != null) && (resource.getType() == IResource.FILE)) {
String[] outlineElementsNames= VerilogUtils.getTopModuleNames((IFile)resource);
if ((outlineElementsNames!=null) && (outlineElementsNames.length>0)) return new String[] {outlineElementsNames[0]};
} else {
fault("There is no selected verilog file");
}
return null;
}
} // class TopModuleNameGenerator
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.generators;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
//import com.elphel.vdt.VDT;
import com.elphel.vdt.VerilogUtils;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
/**
* Generate the top module name from last selected verilog source file.
*
* Created: 21.02.2006
* @author Lvov Konstantin
*/
public class TopModulesNameGenerator extends AbstractGenerator {
public static final String NAME = "TopModules";
public TopModulesNameGenerator(String prefix,
String suffix,
String separator)
{
super(prefix, suffix, separator);
}
public String getName() {
return NAME;
}
protected String[] getStringValues() {
IResource resource = SelectedResourceManager.getDefault().getSelectedVerilogFile();
if ((resource != null) && (resource.getType() == IResource.FILE)) {
String[] outlineElementsNames= VerilogUtils.getTopModuleNames((IFile)resource);
if ((outlineElementsNames!=null) && (outlineElementsNames.length>0)) return outlineElementsNames;
} else {
fault("There are no selected verilog files");
}
return null;
}
} // class TopModulesNameGenerator
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.generators;
import java.util.*;
import com.elphel.vdt.core.tools.params.Parameter;
public class ValueGenerator extends AbstractGenerator {
private Parameter param;
public ValueGenerator(Parameter param,
String prefix,
String suffix,
String separator)
{
super(prefix, suffix, separator);
this.param = param;
}
public String getName() {
return "value of parameter '" + param.getID() +
"' of context '" + param.getContext().getName() +
"'";
}
protected String[] getStringValues() {
List<String> values = param.getValue();
return values.toArray(new String[values.size()]);
}
public String[] generate() {
if (!param.getType().isList())
return new String[]{prefix + param.getValue().get(0) + suffix};
else
return super.generate();
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.menu;
import java.util.ArrayList;
import java.util.List;
import java.util.Iterator;
import com.elphel.vdt.core.tools.Inheritable;
import com.elphel.vdt.core.tools.config.Config;
import com.elphel.vdt.core.tools.config.ConfigException;
import com.elphel.vdt.core.tools.EntityUtils;
import com.elphel.vdt.core.tools.Updateable;
import com.elphel.vdt.core.tools.Checks;
public class DesignMenu extends DesignMenuItem implements Inheritable {
private final static String FIRST_MARK = "first";
private String description;
private String inheritedMenuName;
private DesignMenu inheritedMenu;
private List<DesignMenuItem> items;
private boolean initialized = false;
private boolean updated = false;
private static int nestingInit = 0;
public DesignMenu(Config config,
DesignMenu parentMenu,
String inheritedMenuName,
String afterItem,
String name,
String label,
String icon,
String description,
Boolean visible,
List<DesignMenuItem> items)
{
super(config,
parentMenu,
afterItem,
name,
label,
icon,
visible);
this.description = description;
this.inheritedMenuName = inheritedMenuName;
this.items = items;
}
public void init() throws ConfigException {
if(initialized)
return;
// String spaces = "";
// for(int i = 0; i < nestingInit; i++)
// spaces += " ";
// System.out.println(spaces + name);
nestingInit++;
super.init();
if(inheritedMenuName != null) {
if(inheritedMenu == null) {
inheritedMenu = config.getDesignMenuManager().findDesignMenu(inheritedMenuName);
if(inheritedMenu == null)
throw new ConfigException("Base design menu '" + inheritedMenuName +
"' of menu '" + name +
"' is not found");
checkParentInheritance();
Checks.checkCyclicInheritance(this, "design menu");
if(inheritedMenu != null)
inheritedMenu.init();
inheritMenu();
} else {
if(!updated)
throw new ConfigException(
"Internal error: menu element '" + name +
(parentMenu != null? "' of design menu '" + parentMenu.getName() : "") +
"' is neigher initialized nor updated, but has already inherited menu '" + inheritedMenuName +
"'");
}
}
String commonMessagePart = " of menu '" + name +
(parentMenu != null? "' in menu '" + parentMenu.getName() : "'") +
" is absent";
if(label == null)
throw new ConfigException("Label" + commonMessagePart);
else if(parentMenu == null && description == null)
throw new ConfigException("Description" + commonMessagePart);
initItemsList();
nestingInit--;
initialized = true;
}
public Object clone() {
ArrayList<DesignMenuItem> newItems = new ArrayList<DesignMenuItem>(items);
DesignMenu newMenu = new DesignMenu(config,
parentMenu,
afterItem,
inheritedMenuName,
name,
label,
icon,
description,
visible,
newItems);
// we must avoid repeated initialization
newMenu.initialized = initialized;
newMenu.updated = updated;
newMenu.inheritedMenu = inheritedMenu;
return newMenu;
}
public String getDescription() {
return description;
}
public List<DesignMenuItem> getItems() {
return items;
}
public String getInheritedMenuName() {
return inheritedMenuName;
}
public Inheritable getBase() {
return inheritedMenu;
}
public List<String> getReferencedToolNames() {
List<String> toolList = new ArrayList<String>();
for(Iterator<DesignMenuItem> i = items.iterator(); i.hasNext();) {
DesignMenuItem it = (DesignMenuItem)i.next();
if(it instanceof DesignMenuToolItem)
toolList.add(((DesignMenuToolItem)it).getToolName());
else if(it instanceof DesignMenu)
toolList.addAll(((DesignMenu)it).getReferencedToolNames());
else
assert false;
}
return toolList;
}
private void inheritMenu() throws ConfigException {
ArrayList<DesignMenuItem> itemsBeforeUpdate =
new ArrayList<DesignMenuItem>(items);
inheritItems();
reorderItems(itemsBeforeUpdate);
}
public void update(Updateable other) throws ConfigException {
DesignMenuItem item = (DesignMenuItem)other;
super.update(item);
if(!(item instanceof DesignMenu))
throw new ClassCastException("Trying to update design menu from foreign object '" +
item.getName() + "'");
DesignMenu menuItem = (DesignMenu)item;
if(inheritedMenuName == null) {
inheritedMenuName = item.getName();
inheritedMenu = menuItem;
if(!inheritedMenu.initialized)
throw new ConfigException(
"Internal error: menu element '" + name +
(parentMenu != null? "' of design menu '" + parentMenu.getName() : "") +
"' updates menu element '" + item.getName() +
(item.parentMenu != null? "' of design menu '" + item.parentMenu.getName() : "") +
"' that is not initialized yet");
inheritMenu();
} else {
// we don't need anything to update
}
assert menuItem.initialized;
updated = true;
}
private void checkParentInheritance() throws ConfigException {
if(parentMenu == null)
return;
DesignMenu forerunner = null, parent = parentMenu;
while(parent != null) {
assert parent != this;
forerunner = parent;
parent = parent.getParentMenu();
}
assert forerunner != null;
if(forerunner == inheritedMenu)
throw new ConfigException("Menu '" + name +
"' inherits its forerunner menu '" + forerunner.getName() +
"'");
}
private void initItemsList() throws ConfigException {
if(items.isEmpty())
throw new ConfigException("Menu '" + name + "'" +
(parentMenu != null? " in menu '" + parentMenu.getName() : "'") +
" doesn't contain any items");
Checks.checkDuplicatedNames(items, "menu '" + name + "'");
for(Iterator<DesignMenuItem> i = items.iterator(); i.hasNext();)
((DesignMenuItem)i.next()).init();
}
private void inheritItems() throws ConfigException {
EntityUtils.update(inheritedMenu.items, items);
}
private void reorderItems(List<DesignMenuItem> itemsBeforeUpdate) throws ConfigException {
for(Iterator<DesignMenuItem> i = itemsBeforeUpdate.iterator(); i.hasNext();) {
DesignMenuItem item = (DesignMenuItem)i.next();
String after = item.afterItem;
if(after != null) {
int itemIndex = items.indexOf(item);
assert itemIndex >= 0;
int afterItemIndex = -1;
if(!after.equals(FIRST_MARK)) {
for(int j = 0; j < items.size(); j++) {
DesignMenuItem candidate = items.get(j);
if(candidate.getName().equals(after)) {
afterItemIndex = j;
break;
}
}
if(afterItemIndex < 0)
throw new ConfigException(
"Element '" + item.getName() +
"' of menu '" + name +
"' has attribute 'after' pointing to element '" + after +
"' that is unknown");
}
// we just need to put the 'item' at position j+1 in
// the list 'items' and remove it from the old pos
items.add(afterItemIndex + 1, item);
// in case if the item index > j, we need to increase it by 1
// before removing, because previous insertion increases
// the item position in the 'items' list
if(itemIndex > afterItemIndex)
itemIndex++;
items.remove(itemIndex);
}
}
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.menu;
import com.elphel.vdt.core.tools.config.Config;
import com.elphel.vdt.core.tools.config.ConfigException;
import com.elphel.vdt.core.tools.Updateable;
import com.elphel.vdt.core.tools.NamedEntity;
abstract public class DesignMenuItem implements Cloneable,
Updateable,
NamedEntity
{
protected Config config;
protected String name;
protected String label;
protected String icon;
protected Boolean visible;
protected DesignMenu parentMenu;
protected String afterItem;
public DesignMenuItem(Config config,
DesignMenu parentMenu,
String afterItem,
String name,
String label,
String icon,
Boolean visible)
{
this.config = config;
this.parentMenu = parentMenu;
this.afterItem = afterItem;
this.name = name;
this.label = label;
this.icon = icon;
this.visible = visible;
}
public void init() throws ConfigException {
if(afterItem != null) {
if(parentMenu == null)
throw new ConfigException("Menu element '" + name +
"' doesn't have parent menu, but its 'after' attribute is specified as '" +
afterItem + "'");
if(afterItem.equals(name))
throw new ConfigException("Menu element '" + name +
"' of menu '" + parentMenu +
"' has 'after' attribute that is the same as the element name");
}
}
public boolean matches(Updateable other) {
return name.equals(((DesignMenuItem)other).name);
}
public String getIcon() {
return icon;
}
public String getLabel() {
return label;
}
public String getName() {
return name;
}
public DesignMenu getParentMenu() {
return parentMenu;
}
public boolean isVisible() {
if(visible == null)
return true;
return visible.booleanValue();
}
public void update(Updateable other) throws ConfigException {
DesignMenuItem item = (DesignMenuItem)other;
if(name == null)
throw new NullPointerException("name == null");
if(label == null)
label = item.label;
if(visible == null)
visible = item.visible;
}
public abstract Object clone();
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.menu;
import java.util.*;
import com.elphel.vdt.core.tools.config.*;
import com.elphel.vdt.core.tools.params.*;
import com.elphel.vdt.core.tools.contexts.*;
public class DesignMenuManager {
private List<DesignMenu> designMenuComponents = new ArrayList<DesignMenu>();
private DesignMenu rootDesignMenu;
private Config config;
private boolean initialized = false;
private enum REF_CONTEXT {
PACKAGE,
PROJECT
}
public void init(Config config) throws ConfigException {
if(initialized)
throw new ConfigException("Context layer cannot be re-initialized");
this.config = config;
for(Iterator<DesignMenu> m = designMenuComponents.iterator(); m.hasNext();)
((DesignMenu)m.next()).init();
initialized = true;
}
public void addDesignMenuComponents(List<DesignMenu> menuList) {
designMenuComponents.addAll(menuList);
}
public List<DesignMenu> getDesignMenuList() {
return designMenuComponents;
}
public DesignMenu findDesignMenu(String menuName) {
for(Iterator<DesignMenu> i = designMenuComponents.iterator(); i.hasNext();) {
DesignMenu menu = (DesignMenu)i.next();
if(menu.getName().equals(menuName))
return menu;
}
return null;
}
public List<Context> getProjectContexts(DesignMenu designMenu) {
return getReferencedContexts(designMenu, REF_CONTEXT.PROJECT);
}
public List<Context> getPackageContexts(DesignMenu designMenu) {
return getReferencedContexts(designMenu, REF_CONTEXT.PACKAGE);
}
public DesignMenu getRootDesignMenu() {
return rootDesignMenu;
}
public List<Context> getReferencedContexts(DesignMenu designMenu, REF_CONTEXT refContexType) {
List<Context> refContexts = new ArrayList<Context>();
List<String> toolNames = designMenu.getReferencedToolNames();
for(Iterator<String> i = toolNames.iterator(); i.hasNext();) {
Tool tool = config.getContextManager().findTool((String)i.next());
Context parentContext = null;
switch(refContexType) {
case PACKAGE:
parentContext = tool.getParentPackage();
break;
case PROJECT:
parentContext = tool.getParentProject();
break;
default:
assert false;
}
if(parentContext != null && !refContexts.contains(parentContext))
refContexts.add(parentContext);
}
return refContexts;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.menu;
import com.elphel.vdt.core.tools.config.Config;
import com.elphel.vdt.core.tools.config.ConfigException;
import com.elphel.vdt.core.tools.params.Tool;
public class DesignMenuToolItem extends DesignMenuItem {
private String tcall;
public DesignMenuToolItem(Config config,
DesignMenu parentMenu,
String afterItem,
String name,
String label,
String icon,
Boolean visible,
String tcall)
{
super(config,
parentMenu,
afterItem,
name,
label,
icon,
visible);
this.tcall = tcall;
}
public void init() throws ConfigException {
super.init();
if(label == null)
throw new ConfigException("Label of item '" + name +
"' of menu '" + parentMenu.getName() +
"' is absent");
else if(tcall == null)
throw new ConfigException("Tool name in item '" + name +
"' of menu '" + parentMenu.getName() +
"' is absent");
Tool tool = config.getContextManager().findTool(tcall);
if(tool == null)
throw new ConfigException("Design menu '" + parentMenu.getName() +
"' item '" + name +
"' refers to non-existing tool '" + tcall +
"'");
}
public Object clone() {
return new DesignMenuToolItem(config,
parentMenu,
afterItem,
name,
label,
icon,
visible,
tcall);
}
public String getToolName() {
return tcall;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params;
import java.util.*;
import com.elphel.vdt.core.tools.Updateable;
import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.core.tools.config.Config;
import com.elphel.vdt.core.tools.config.ConfigException;
import com.elphel.vdt.core.tools.params.conditions.*;
import com.elphel.vdt.core.tools.params.types.ParamTypeString;
public class CommandLinesBlock extends UpdateableStringsContainer
implements Cloneable
{
private String contextName;
private String name;
private String destination;
private String separator;
public CommandLinesBlock(String contextName,
String name,
String destination,
String sep,
ConditionalStringsList lines,
ConditionalStringsList deleteLines,
List<NamedConditionalStringsList> insertLines)
{
super(lines, deleteLines, insertLines);
this.contextName = contextName;
this.name = name;
this.destination = destination;
this.separator = sep;
if(separator != null) {
separator = separator.replace("\\n", "\n");
separator = separator.replace("\\t", "\t");
}
}
public CommandLinesBlock(CommandLinesBlock block) {
this(block.contextName,
block.name,
block.destination,
block.separator,
block.strings != null?
(ConditionalStringsList)block.strings.clone() : null,
block.deleteStrings != null?
(ConditionalStringsList)block.deleteStrings.clone() : null,
block.insertStrings != null?
new ArrayList<NamedConditionalStringsList>(block.insertStrings) : null);
// TODO: review this line!!!
}
public void init(Config config) throws ConfigException {
Context context = config.getContextManager().findContext(contextName);
if(context == null)
throw new ConfigException("Internal fault: parent context '" + contextName +
"' of command block '" + name +
"' is not found in the configuration");
if(destination != null && !destination.equals("")) {
Parameter param = context.findParam(destination);
if(param == null) {
throw new ConfigException("Destination parameter '" + destination +
"' used for command line of context '" + context.getName() +
"' is absent");
} else if(!(param.getType() instanceof ParamTypeString)) {
throw new ConfigException("Destination parameter '" + destination +
"' used for command line of context '" + context.getName() +
"' must be of type '" + ParamTypeString.NAME +
"'");
} else if(((ParamTypeString)param.getType()).getKind() != ParamTypeString.KIND.FILE) {
throw new ConfigException("Destination parameter '" + destination +
"' of type '" + ParamTypeString.NAME +
"' used for command line of context '" + context.getName() +
"' must be of kind '" + ParamTypeString.KIND_FILE_ID +
"'");
}
}
}
public Object clone() {
return new CommandLinesBlock(this);
}
public boolean matches(Updateable other) {
return name.equals(((CommandLinesBlock)other).name);
}
public String getDestination() {
return destination;
}
public List<String> getLines() {
return ConditionUtils.resolveConditionStrings(strings);
}
public String getName() {
return name;
}
public String getSeparator() {
return separator;
}
public boolean isEnabled() {
if(destination == null) // command line
return true;
return !destination.equals("");
}
public void update(Updateable from) throws ConfigException {
CommandLinesBlock block = (CommandLinesBlock)from;
if(name == null)
throw new NullPointerException("name == null");
if(contextName == null)
contextName = block.contextName;
if(separator == null)
separator = block.separator;
super.update(from);
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params;
import java.util.List;
public class ContextInputDefinition {
private String label;
private List<ParamGroup> paramGroups;
public ContextInputDefinition(String label, List<ParamGroup> paramGroups) {
this.label = label;
this.paramGroups = paramGroups;
}
public String getLabel() {
return label;
}
public List<ParamGroup> getParamGroups() {
return paramGroups;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params;
import java.util.*;
import com.elphel.vdt.core.tools.Inheritable;
import com.elphel.vdt.core.tools.Checks;
import com.elphel.vdt.core.tools.config.Config;
import com.elphel.vdt.core.tools.config.ConfigException;
import com.elphel.vdt.core.tools.params.types.ParamType;
public class ControlInterface implements Inheritable {
public static final String BASIC_INTERFACE_NAME = "BasicInterface";
private String name;
private String baseInterfaceName;
private ControlInterface baseInterface;
private List<TypeDef> typedefList;
private List<Syntax> syntaxList;
private Config config;
private boolean initialized = false;
public ControlInterface(Config config, String name) {
this(config, name, null, null, null);
}
public ControlInterface(Config config,
String name,
String baseInterfaceName,
List<TypeDef> typedefList,
List<Syntax> syntaxList)
{
this.config = config;
this.name = name;
this.baseInterfaceName = baseInterfaceName;
this.typedefList = typedefList;
this.syntaxList = syntaxList;
}
public void init() throws ConfigException {
if(initialized)
throw new ConfigException("Control interface cannot be re-initialized");
if(!name.equals(BASIC_INTERFACE_NAME)) {
if(baseInterfaceName == null)
baseInterfaceName = BASIC_INTERFACE_NAME;
baseInterface = config.findControlInterface(baseInterfaceName);
if(baseInterface == null) {
if(!baseInterfaceName.equals(BASIC_INTERFACE_NAME))
throw new ConfigException("Base interface '" + baseInterfaceName +
"' of control interface '" + name +
"' is absent");
else
throw new ConfigException("The basic interface '" + BASIC_INTERFACE_NAME +
"' is absent");
}
} else {
// we don't check base interface absence, because in
// such a case a cyclic inheritance error would happen
}
for(Iterator ti = typedefList.iterator(); ti.hasNext();)
((TypeDef)ti.next()).init(this);
initialized = true;
}
public void check() throws ConfigException {
Checks.checkCyclicInheritance(this, "control interface");
for(int i = 0; i < syntaxList.size(); i++) {
String syntaxName = syntaxList.get(i).getFormatName();
for(int j = i+1; j < syntaxList.size(); j++) {
if(syntaxName.equals(syntaxList.get(j).getFormatName()))
throw new ConfigException("Syntax '" + syntaxName +
"' is duplicated in control interface '" + name + "'");
}
if(baseInterface != null) {
if(findSyntax(baseInterface, syntaxName) != null)
throw new ConfigException("Syntax '" + syntaxName +
"' duplicates syntax declared in its base control interface '" +
baseInterfaceName + "'");
}
}
for(int i = 0; i < typedefList.size(); i++) {
String typedefName = typedefList.get(i).getName();
for(int j = i+1; j < typedefList.size(); j++) {
if(typedefName.equals(typedefList.get(j).getName()))
throw new ConfigException("Type definition '" + typedefName +
"' is duplicated in control interface '" + name + "'");
}
if(baseInterface != null) {
if(findTypeDef(baseInterface, typedefName) != null)
throw new ConfigException("Type definition '" + typedefName +
"' in control interface '" + name +
"' duplicates one declared in its base control interface '" +
baseInterfaceName + "'");
}
}
}
public String getName() {
return name;
}
public Config getConfig() {
return config;
}
public ParamType findParamType(String typeName) {
for(Iterator ti = typedefList.iterator(); ti.hasNext();) {
TypeDef typeDef = (TypeDef)ti.next();
if(typeName.equals(typeDef.getName()))
return typeDef.getType();
}
if(baseInterface != null)
return baseInterface.findParamType(typeName);
return null;
}
public Syntax findSyntax(String formatName) {
return findSyntax(this, formatName);
}
boolean isInheritedFrom(ControlInterface baseControlInterface) {
if(baseControlInterface == null)
return true;
if(name.equals(baseControlInterface.getName()))
return true;
if(baseInterface == null)
return false;
return baseInterface.isInheritedFrom(baseControlInterface);
}
public Inheritable getBase() {
return baseInterface;
}
public static boolean isInheritedOrSame(ControlInterface ancestor, ControlInterface descendant) {
return ancestor == descendant || descendant.isInheritedFrom(ancestor);
}
private static Syntax findSyntax(ControlInterface interf, String formatName) {
for(Iterator si = interf.syntaxList.iterator(); si.hasNext();) {
Syntax syntax = (Syntax)si.next();
if(formatName.equals(syntax.getFormatName()))
return syntax;
}
if(interf.baseInterface != null)
return findSyntax(interf.baseInterface, formatName);
return null;
}
private static TypeDef findTypeDef(ControlInterface interf, String typedefName) {
for(Iterator ti = interf.typedefList.iterator(); ti.hasNext();) {
TypeDef typedef = (TypeDef)ti.next();
if(typedefName.equals(typedef.getName()))
return typedef;
}
if(interf.baseInterface != null)
return findTypeDef(interf.baseInterface, typedefName);
return null;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params;
import java.util.*;
import com.elphel.vdt.core.tools.generators.AbstractGenerator;
import com.elphel.vdt.core.tools.params.recognizers.Recognizer;
import com.elphel.vdt.core.tools.params.recognizers.RecognizerResult;
import com.elphel.vdt.core.Utils;
public class FormatProcessor {
private static final String CONTROL_SEQ = "%";
private static final int CONTROL_SEQ_LEN = CONTROL_SEQ.length();
private static List<String> expandedGenerators = new ArrayList<String>();
private static int callCount = 0;
private final boolean recursive = true;
private final boolean multiline;
private final Recognizer[] recognizers;
private String initialTemplate;
public FormatProcessor(Recognizer[] recognizers, boolean multiline) {
this.recognizers = recognizers;
this.multiline = multiline;
}
public FormatProcessor(Recognizer[] recognizers) {
this(recognizers, true);
}
public List<String> process(String template) throws ToolException {
if(callCount++ == 0)
expandedGenerators.clear();
initialTemplate = template;
List<String> outputLines = null;
try {
outputLines = processTemplate(template);
} finally {
callCount--;
}
if(!multiline) {
String str = Utils.listToString(outputLines);
outputLines.clear();
outputLines.add(str);
}
return outputLines;
}
private List<String> processTemplate(String template)
throws ToolException
{
List<String> outputLines = new ArrayList<String>();
int posAfterLastGen = 0, pos = 0;
while(pos < template.length()) {
if(template.startsWith(CONTROL_SEQ, pos)) {
pos += CONTROL_SEQ_LEN;
RecognizerResult result = recognize(template, pos);
if(result != null && result.getGenerator() != null) {
assert result.getNewPos() > pos;
String partBetweenGenerators =
template.substring(posAfterLastGen, pos - CONTROL_SEQ_LEN);
generateAndAdd(outputLines,
partBetweenGenerators,
result.getGenerator());
posAfterLastGen = result.getNewPos();
pos = posAfterLastGen;
} else {
// throw new ToolException("Cannot recognize control sequence '" +
// template.substring(pos - CONTROL_SEQ_LEN) + "'. " +
// "The full template string is '" + template + "'");
}
} else {
pos++;
}
}
String tail = template.substring(posAfterLastGen);
addLine(outputLines, tail);
return outputLines;
}
private RecognizerResult recognize(String template, int pos) throws ToolException {
for(int i = 0; i < recognizers.length; i++) {
RecognizerResult result = recognizers[i].recognize(template, pos);
assert result != null;
if(result.getGenerator() != null)
return result;
}
return null;
}
private void generateAndAdd(List<String> lines,
String firstLineToAdd,
AbstractGenerator generator)
throws ToolException
{
checkCyclic(generator);
// first, we have to add the explicitly given line
addLine(lines, firstLineToAdd);
pushGen(generator.getName());
// use generator
String[] generatedLines = generator.generate();
popGen();
int addFrom = 0;
if(generatedLines.length == 0)
return;
List<String> processedLines = null;
if(recursive) {
pushGen(generator.getName());
processedLines = processTemplate(generatedLines[0]);
for(int i = 1; i < generatedLines.length; i++)
processedLines.addAll(processTemplate(generatedLines[i]));
popGen();
} else {
processedLines = new ArrayList<String>(generatedLines.length);
for(int i = 0; i < generatedLines.length; i++)
processedLines.add(generatedLines[i]);
}
// we need to check if 'firstLineToAdd' ends with a blank space
// in such a case we just add all the generated lines in the list
// otherwise, we glue the line with first of additional ones
if(!Utils.stringEndsWithSpace(firstLineToAdd)) {
glueToLastLine(lines, processedLines.get(0));
addFrom = 1;
}
for(int i = addFrom; i < processedLines.size(); i++) {
String line = processedLines.get(i);
if(!line.equals(""))
lines.add(line);
}
}
private void addLine(List<String> lines, String additionalLine) {
if(lines.isEmpty()) {
lines.add(additionalLine);
} else if(multiline && Utils.stringStartsWithSpace(additionalLine)) {
String trimLine = additionalLine.trim();
if(!trimLine.equals(""))
lines.add(trimLine);
} else {
// in this case we need to glue last line and this line, as there is
// no blank space between the corresponding parts in the initial template
glueToLastLine(lines, additionalLine);
}
}
private void glueToLastLine(List<String> lines, String lineToGlue) {
int last = lines.size()-1;
String lastLine = lines.get(last);
lines.set(last, lastLine + lineToGlue);
}
private void checkCyclic(AbstractGenerator generator)
throws ToolException
{
if(Utils.containsStr(expandedGenerators, generator.getName()))
throw new ToolException(
"Pattern '" + generator.getName() +
"' expanded to a string containing this pattern itself. " +
"The initial string is '" + initialTemplate + "'.\n\n" +
"To understand and fix this error, check all uses of this parameter " +
"and try to detect the cyclic dependency by successively removing them.");
}
private static void pushGen(String genName) {
expandedGenerators.add(genName);
}
private static void popGen() {
expandedGenerators.remove(expandedGenerators.size()-1);
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params;
import java.util.*;
import com.elphel.vdt.core.tools.Updateable;
import com.elphel.vdt.core.tools.params.conditions.*;
import com.elphel.vdt.core.tools.config.ConfigException;
public class ParamGroup extends UpdateableStringsContainer
implements Cloneable
{
private String name;
private String label;
private boolean visible;
private Condition relevant;
public ParamGroup(String name,
String label,
boolean visible,
ConditionalStringsList params,
ConditionalStringsList deleteParams,
List<NamedConditionalStringsList> insertParams,
Condition relevant)
{
super(params, deleteParams, insertParams);
assert (label != null) || (name != null);
if(label != null)
this.label = label;
else
this.label = name;
if(name != null)
this.name = name;
else
this.name = label;
this.visible = visible;
this.relevant = relevant;
}
public ParamGroup(ParamGroup paramGroup) {
this(paramGroup.name,
paramGroup.label,
paramGroup.visible,
paramGroup.strings != null?
(ConditionalStringsList)paramGroup.strings.clone() : null,
paramGroup.deleteStrings != null?
(ConditionalStringsList)paramGroup.deleteStrings.clone() : null,
paramGroup.insertStrings != null?
new ArrayList<NamedConditionalStringsList>(paramGroup.insertStrings) : null,
// TODO: review this line!!!
paramGroup.relevant);
}
public Object clone() {
return new ParamGroup(this);
}
public boolean matches(Updateable other) {
ParamGroup otherGroup = (ParamGroup)other;
return ConditionUtils.conditionsEqual(relevant, otherGroup.relevant) &&
name.equals(otherGroup.name);
}
public String getLabel() {
return label;
}
public String getName() {
return name;
}
public boolean isVisible() {
return visible;
}
public boolean isRelevant() {
return relevant == null || relevant.isTrue();
}
public List<String> getParams() {
return ConditionUtils.resolveConditionStrings(strings);
}
public void update(Updateable from) throws ConfigException {
ParamGroup paramGroup = (ParamGroup)from;
if(name == null)
throw new NullPointerException("name == null");
if(label == null)
label = paramGroup.label;
super.update(from);
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params;
import com.elphel.vdt.core.Utils;
public class ParamUtils {
public static String buildParamString(String paramName) {
return "%" + paramName;
}
public static boolean isParamString(String paramString) {
return (paramString.length() > 1) &&
(paramString.charAt(0) == '%') &&
Utils.isAlpha(paramString.charAt(1));
}
public static String getParamID(String paramString) {
if (isParamString(paramString))
return paramString.substring(1);
else
return paramString;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params;
import java.util.*;
import com.elphel.vdt.core.tools.params.recognizers.*;
import com.elphel.vdt.core.tools.params.types.ParamType;
import com.elphel.vdt.core.tools.params.conditions.*;
import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.core.tools.config.ConfigException;
//import com.elphel.vdt.core.tools.generators.FileListGenerator;
//import com.elphel.vdt.core.tools.generators.SourceListGenerator;
import com.elphel.vdt.core.tools.*;
import com.elphel.vdt.ui.MessageUI;
public class Parameter implements Cloneable, Updateable {
private String id;
private String outid;
private String typeName;
private String syntaxName;
private String defaultValue;
private String label;
private String omitValue;
private String readonly;
private String visible;
private List<String> currentValue = new ArrayList<String>();
private Condition relevant;
private Context context;
private ParamType type;
private Syntax syntax;
private boolean hasDependentParameters;
public Parameter(String id,
String outid,
String typeName,
String syntaxName,
String defaultValue,
String label,
String omitValue,
String readonly,
String visible)
{
this(id,
outid,
typeName,
syntaxName,
defaultValue,
label,
omitValue,
readonly,
visible,
null);
}
public Parameter(String id,
String outid,
String typeName,
String syntaxName,
String defaultValue,
String label,
String omitValue,
String readonly,
String visible,
Condition relevant)
{
this.id = id;
this.outid = outid != null? outid : id;
this.typeName = typeName;
this.syntaxName = syntaxName;
this.defaultValue = defaultValue;
this.label = label;
this.omitValue = omitValue;
this.readonly = readonly;
this.visible = visible;
this.relevant = relevant;
this.hasDependentParameters = false;
}
protected Parameter(Parameter param) {
this(param.id,
param.outid,
param.typeName,
param.syntaxName,
param.defaultValue,
param.label,
param.omitValue,
param.readonly,
param.visible,
param.relevant);
this.type = param.type;
this.syntax = param.syntax;
}
public Object clone() {
return new Parameter(this);
}
public boolean matches(Updateable other) {
Parameter otherParam = (Parameter)other;
return ConditionUtils.conditionsEqual(relevant, otherParam.relevant) &&
id.equals(otherParam.id);
}
public void init(Context context) throws ConfigException {
if(this.context != null)
throw new ConfigException("Parameter ('" + id + "') cannot be re-initialized");
this.context = context;
String contextInfo = "Context '" + context.getName() + "'";
if(typeName == null)
throw new ConfigException(contextInfo + ": Type name of parameter '" + id + "' is absent");
else if(syntaxName == null)
throw new ConfigException(contextInfo + ": Syntax name of parameter '" + id + "' is absent");
else if(defaultValue == null)
throw new ConfigException(contextInfo + ": Default value of parameter '" + id + "' is absent");
if(readonly == null)
readonly = new String(BooleanUtils.VALUE_FALSE);
else
checkBoolInitialValue(readonly, "readonly");
if(visible == null)
visible = new String(BooleanUtils.VALUE_TRUE);
else
checkBoolInitialValue(visible, "visible");
if(!BooleanUtils.isFalse(visible)) {
if(label == null)
throw new ConfigException(contextInfo + ": Label of the parameter '" + id +
"' is absent, while visible attribute is not " +
BooleanUtils.VALUE_FALSE);
}
this.type = context.getControlInterface().findParamType(typeName);
if(this.type == null)
throw new ConfigException(contextInfo + ": Parameter type '" + typeName +
"' doesn't exist in control interface '" + context.getControlInterface().getName() +
"'");
this.syntax = context.getControlInterface().findSyntax(syntaxName);
if(this.syntax == null)
throw new ConfigException(contextInfo + ": Syntax '" + syntaxName +
"' doesn't exist in control interface '" + context.getControlInterface().getName() +
"'");
}
//
// getters section
//
public Context getContext() {
return context;
}
public boolean isVisible() {
return resolveBooleanFieldValue(visible, "visible");
}
public boolean isReadOnly() {
return resolveBooleanFieldValue(readonly, "readonly");
}
// checks whether the passed id belongs to this param's id
// it is only proper way to resolve parameter relevantness!
public boolean isSame(String paramID) {
if(paramID.equals(id)) {
if(relevant == null || relevant.isTrue())
return true;
}
return false;
}
public String getID() {
return id;
}
public String getOutID() {
return outid;
}
public String getLabel() {
return label;
}
public ParamType getType() {
return type;
}
public List<String> getDependencies() {
List<String> deps = new ArrayList<String>();
MultiConditionValue defaultValueCondition =
ConditionUtils.getContextCondition(context, defaultValue);
if(defaultValueCondition != null)
deps.addAll(defaultValueCondition.getDependencies());
if(relevant != null)
deps.addAll(relevant.getDependencies());
if(deps.isEmpty())
return null;
for(Iterator<String> depIter = deps.iterator(); depIter.hasNext();) {
if(!ParamUtils.isParamString(depIter.next()))
depIter.remove();
}
return deps;
}
//
// current and default values manipulations
//
public void setCurrentValue(String value) throws ToolException {
if(type.isList())
throw new ToolException("Assigning a non-list value to list parameter");
checkValue(value);
currentValue.clear();
currentValue.add(value);
canonicalizeValue(currentValue);
}
public void setCurrentValue(List<String> value) throws ToolException {
if(!type.isList())
throw new ToolException("Assigning a list value to non-list parameter");
checkValue(value);
currentValue = new ArrayList<String>(value);
canonicalizeValue(currentValue);
}
public List<String> getCurrentValue() {
if(currentValue.isEmpty())
return null;
return currentValue;
}
public List<String> getDefaultValue() {
String resolvedDefaultValue = ConditionUtils.resolveContextCondition(context, defaultValue);
String errmsg = "Parameter '" + id +
"' of context '" + context.getName() +
"' - error processing default value: ";
List<String> processedDefaultValue = null;
FormatProcessor processor = new FormatProcessor(new Recognizer[] {
//new RepeaterRecognizer(),
new SimpleGeneratorRecognizer(),
new ContextParamRecognizer(context)
});
try {
processedDefaultValue = processor.process(resolvedDefaultValue);
for(Iterator<String> i = processedDefaultValue.iterator(); i.hasNext();)
type.checkValue(i.next());
} catch(ToolException e) {
MessageUI.error(errmsg + e.getMessage(), e);
} catch(ConfigException e) {
MessageUI.error(errmsg + e.getMessage(), e);
}
canonicalizeValue(processedDefaultValue);
return processedDefaultValue;
}
// returns current value if it is set
// otherwise returns default value
public List<String> getValue() {
if(!currentValue.isEmpty())
return currentValue;
return getDefaultValue();
}
// returns external form of the current value unless it equals null;
// otherwise returns external form of the default value
public List<String> getExternalValueForm() {
List<String> externalFormValue = new ArrayList<String>();
for(Iterator<String> i = getValue().iterator(); i.hasNext();) {
String elem = type.toExternalForm((String)i.next());
if(elem == null)
throw new NullPointerException("Parameter '" + getID() + "' has bad external form");
externalFormValue.add(elem);
}
return externalFormValue;
}
public boolean isDefault() {
return getCurrentValue() == null;
}
public void setToDefault() {
currentValue.clear();
}
public String[] getCommandLine() throws ToolException {
String omit = getOmitValue();
List<String> value = getValue();
if(value.size() == 1) {
if(omit != null && type.equal(omit, value.get(0)))
return new String[]{""};
}
String format = syntax.getFormat();
FormatProcessor processor = new FormatProcessor(new Recognizer[] {
new ParamFormatRecognizer(this),
new ParamRepeaterRecognizer(this),
new SimpleGeneratorRecognizer(),
new RepeaterRecognizer(),
});
List<String> commandLine = processor.process(format);
return commandLine.toArray(new String[commandLine.size()]);
}
// initializes null fields (except id) from the corresponding
// fields of the given param
public void update(Updateable other) {
Parameter param = (Parameter)other;
if(id == null)
throw new NullPointerException("id == null");
if(outid == null)
outid = param.outid;
if(typeName == null)
typeName = param.typeName;
if(syntaxName == null)
syntaxName = param.syntaxName;
if(defaultValue == null)
defaultValue = param.defaultValue;
if(label == null)
label = param.label;
if(omitValue == null)
omitValue = param.omitValue;
if(readonly == null)
readonly = param.readonly;
if(visible == null)
visible = param.visible;
}
public void checkConsistency(String typeName, String value)
throws ToolException
{
List<String> valueList = new ArrayList<String>(1);
valueList.add(value);
checkConsistency(typeName, valueList);
}
private void checkValue(String value) throws ToolException {
List<String> valueList = new ArrayList<String>(1);
valueList.add(value);
checkValue(valueList);
}
private void checkValue(List<String> value) throws ToolException {
for(Iterator<String> i = value.iterator(); i.hasNext();) {
String v = (String)i.next();
try {
type.checkValue(v);
} catch(ConfigException e) {
throw new ToolException(getParamInfo() + ": " + e.getMessage());
}
}
}
private void checkConsistency(String typeName, List<String> value)
throws ToolException
{
if(!typeName.equals(this.typeName))
throw new ToolException(getParamInfo() +
" of type '" + this.typeName +
"' is not compatible with type '" + typeName);
checkValue(value);
}
private String getParamInfo() {
return "Parameter '" + id +
"' of context '" + context.getName() +
"'";
}
//
// private stuff below
//
private String getOmitValue() {
FormatProcessor processor = new FormatProcessor(new Recognizer[] {
new ContextParamRecognizer(context),
new SimpleGeneratorRecognizer()
},
false);
String resolvedOmitValue = ConditionUtils.resolveContextCondition(context, omitValue);
String result = null;
if(resolvedOmitValue != null) {
try {
result = processor.process(resolvedOmitValue).get(0);
} catch(ToolException e) {
MessageUI.error(e);
}
}
return result;
}
private boolean resolveBooleanFieldValue(String field, String fieldName) {
String fieldValue = ConditionUtils.resolveContextCondition(context, field);
if(!field.equals(fieldValue)) {
try {
checkBoolAfterResolving(fieldValue, fieldName);
} catch(ConfigException e) {
MessageUI.error(e);
}
}
return BooleanUtils.isTrue(fieldValue);
}
private void canonicalizeValue(List<String> value) {
for(int i = 0; i < value.size(); i++)
value.set(i, type.canonicalizeValue(value.get(i)));
}
private void checkBoolInitialValue(String boolAttr, String attrName)
throws ConfigException
{
if(!BooleanUtils.isBoolean(boolAttr) &&
!StringConditionParser.isConditionString(boolAttr))
{
throw new ConfigException("Context '" + context.getName() + "': " +
"Attribute '" + attrName +
"' of parameter '" + id +
"' has value that is neither " + BooleanUtils.VALUE_TRUE +
", nor " + BooleanUtils.VALUE_FALSE +
", nor a condition expression");
}
}
private void checkBoolAfterResolving(String boolValue, String attrName)
throws ConfigException
{
if(!BooleanUtils.isBoolean(boolValue)) {
throw new ConfigException("Context '" + context.getName() + "': " +
"After condition resolving, attribute '" + attrName +
"' of parameter '" + id +
"' has value '" + boolValue +
"' that is neither " + BooleanUtils.VALUE_TRUE +
", nor " + BooleanUtils.VALUE_FALSE);
}
}
public boolean hasDependentParameters() {
return hasDependentParameters;
}
public void checkDependentParametersPresents(List<Parameter> parameters) {
if (hasDependentParameters)
return;
for (Parameter param : parameters) {
if (param == this)
continue;
List<String> paramDependencies = param.getDependencies();
if (paramDependencies != null) {
for (String paramString : paramDependencies) {
if (isSame(ParamUtils.getParamID(paramString))) {
hasDependentParameters = true;
return;
}
}
}
}
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import com.elphel.vdt.core.tools.config.Config;
import com.elphel.vdt.core.tools.config.ConfigException;
import com.elphel.vdt.core.tools.contexts.Context;
public class ParameterContainer implements Cloneable {
private List<Parameter> params;
public ParameterContainer(List<Parameter> params) {
this.params = params;
}
public void init(Config config, Context context) throws ConfigException {
for(Iterator<Parameter> p = params.iterator(); p.hasNext();) {
try {
((Parameter)p.next()).init(context);
} catch(ConfigException e) {
config.logError(e);
}
}
}
public List<Parameter> getParams() {
return params;
}
public void addParam(Parameter param) {
params.add(param);
}
public Parameter findParam(String paramID) {
for (Iterator i = params.iterator(); i.hasNext(); ) {
Parameter param = (Parameter)i.next();
if(param.isSame(paramID))
return param;
}
return null;
}
public Object clone() {
ParameterContainer newContainer = null;
try {
newContainer = (ParameterContainer)super.clone();
} catch (CloneNotSupportedException e) {
assert false;
}
newContainer.params = new ArrayList<Parameter>();
for(Iterator<Parameter> pi = params.iterator(); pi.hasNext();)
newContainer.params.add((Parameter)(pi.next()).clone());
return newContainer;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params;
public class Syntax {
private String formatName;
private String format;
private String type;
public Syntax(String formatName, String format, String type) {
this.formatName = formatName;
this.format = format;
this.type = type;
}
public String getFormatName() {
return formatName;
}
public String getFormat() {
return format;
}
public String getType() {
return type;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params;
import java.util.*;
import java.io.*;
import com.elphel.vdt.core.tools.*;
import com.elphel.vdt.core.tools.contexts.*;
import com.elphel.vdt.core.tools.config.*;
import com.elphel.vdt.core.tools.params.conditions.ConditionUtils;
import com.elphel.vdt.core.tools.params.recognizers.*;
public class Tool extends Context implements Cloneable, Inheritable {
private String baseToolName;
private String parentPackageName;
private String parentProjectName;
private String exeName;
private String toolErrors;
private String toolWarnings;
private String toolInfo;
private List<String> extensions;
private Tool baseTool;
private PackageContext parentPackage;
private ProjectContext parentProject;
private String absoluteExeName = null;
private boolean locationSet = false;
private boolean isShell = false; /* Tool is a shell, preserve first argument, merge all others */
private String projectPath=null;
private boolean initialized = false;
public Tool(String name,
String controlInterfaceName,
String label,
String iconName,
String baseToolName,
String inputDialogLabel,
String parentPackageName,
String parentProjectName,
String exeName,
boolean isShell,
List<String> extensions,
String toolErrors,
String toolWarnings,
String toolInfo,
/* never used ??? */
List<Parameter> params,
List<ParamGroup> paramGroups,
List<CommandLinesBlock> commandLinesBlocks)
{
super(name,
controlInterfaceName,
label,
iconName,
inputDialogLabel,
params,
paramGroups,
commandLinesBlocks);
this.baseToolName = baseToolName;
this.label = label;
this.parentPackageName = parentPackageName;
this.parentProjectName = parentProjectName;
this.exeName = exeName;
this.isShell = isShell;
this.extensions = extensions;
this.toolErrors = toolErrors;
this.toolWarnings = toolWarnings;
this.toolInfo = toolInfo;
}
public void init(Config config) throws ConfigException {
if(initialized)
return;
this.config = config;
initControlInterface();
initBaseTool();
Checks.checkCyclicInheritance(this, "tool");
if(baseTool != null)
baseTool.init(config);
checkBaseTool();
initParentPackage();
initParentProject();
initParams();
initOtherAttributes();
initCommandLines();
initialized = true;
}
public void checkBaseTool() throws ConfigException {
if(baseToolName != null) {
ControlInterface baseToolInterface = baseTool.getControlInterface();
String baseToolInterfaceName = baseTool.getControlInterface().getName();
if(!controlInterface.isInheritedFrom(baseToolInterface))
throw new ConfigException(
"Tool '" + name +
"' inherited from tool '" + baseToolName +
"' has control interface '" + controlInterfaceName +
"' that is not inherited from control interface '" + baseToolInterfaceName +
"' of the base tool");
}
}
public Object clone() {
Tool newTool = null;
try {
newTool = (Tool)super.clone();
} catch (CloneNotSupportedException e) {
assert false;
}
return newTool;
}
public String getExeName() {
if(locationSet)
return absoluteExeName;
return getResolvedExeName();
}
public boolean getIsShell() {
return isShell;
}
/*
public void setIsShell(boolean isShell) {
this.isShell=isShell;
}
*/
public String getToolProjectPath() {
return projectPath;
}
public void setToolProjectPath(String projectPath) {
this.projectPath=projectPath;
}
public void setLocation(String path) {
String fileName = (new File(getResolvedExeName())).getName();
if ((path != null) && (path.length() > 0))
absoluteExeName = path + File.separator + fileName;
else
absoluteExeName = fileName;
locationSet = true;
}
/* Patterns for Error Parser */
public String getPatternErrors() {
return this.toolErrors;
}
public String getPatternWarnings() {
return this.toolWarnings;
}
public String getPatternInfo() {
return this.toolInfo;
}
public String[] getExtensions() {
if(extensions == null)
return null;
FormatProcessor processor = new FormatProcessor(
new Recognizer[] { new ContextParamRecognizer(this) });
String[] actualExtensions = new String[extensions.size()];
for(int i = 0; i < extensions.size(); i++) {
List<String> ext = null;
try {
ext = processor.process(extensions.get(i));
} catch(ToolException e) {
assert false;
}
assert ext.size() == 1;
actualExtensions[i] = ext.get(0);
}
return actualExtensions;
}
public List<Parameter> getParams() {
return paramContainer.getParams();
}
public PackageContext getParentPackage() {
return parentPackage;
}
public ProjectContext getParentProject() {
return parentProject;
}
public Parameter findParam(String paramID) {
Parameter param = super.findParam(paramID);
if(param != null)
return param;
if(baseTool != null) {
param = baseTool.findParam(paramID);
} else {
if(parentProject != null) {
param = parentProject.findParam(paramID);
} else if(parentPackage != null) {
param = parentPackage.findParam(paramID);
} else {
InstallationContext installation = config.getContextManager().getInstallationContext();
if(installation != null)
param = installation.findParam(paramID);
}
}
return param;
}
public Inheritable getBase() {
return baseTool;
}
public String[] buildParams() throws ToolException {
if(parentPackage != null)
parentPackage.buildParams();
if(parentProject != null)
parentProject.buildParams();
InstallationContext installation = config.getContextManager().getInstallationContext();
if(installation != null)
installation.buildParams();
return super.buildParams();
}
protected List<String> buildCommandString(String paramStringTemplate)
throws ToolException
{
FormatProcessor processor = new FormatProcessor(new Recognizer[] {
new ToolParamRecognizer(this),
new SimpleGeneratorRecognizer(),
new RepeaterRecognizer(),
new ContextParamRecognizer(this),
new ContextParamRepeaterRecognizer(this)
});
return processor.process(paramStringTemplate);
}
//
// below comes various non-public initialization stuff
//
protected void initParams() throws ConfigException {
if(parentProject != null)
inheritParams(parentProject);
if(parentPackage != null)
inheritParams(parentPackage);
//
// should we inherit params from installation context?
//
if(baseTool != null) {
assert baseTool.initialized;
// inherit stuff from the base tool
// note that the base tool is considered to be initialized
// as well as its params
inheritParams(baseTool);
inheritParamGroups();
}
paramContainer.init(config, this);
initParamGroups();
}
protected void initCommandLines() throws ConfigException {
if(baseTool != null) {
assert baseTool.initialized;
inheritCommandLines();
}
super.initCommandLines();
}
private void initParentPackage() throws ConfigException {
if(parentPackageName != null) {
parentPackage =
(PackageContext)config.getContextManager().findContext(parentPackageName);
if(parentPackage == null) {
throw new ConfigException("Parent package context '" + parentPackageName +
"' of tool '" + name +
"' is absent");
} else if(!ControlInterface.isInheritedOrSame(parentPackage.getControlInterface(), controlInterface)) {
throw new ConfigException("Control interface of parent package context '" + parentPackageName +
"' of tool '" + name +
"' is neither equal to nor base of control interface of the tool");
}
}
}
private void initParentProject() throws ConfigException {
if(parentProjectName == null)
return;
parentProject =
(ProjectContext)config.getContextManager().findContext(parentProjectName);
if(parentProject == null) {
throw new ConfigException("Parent project '" + parentProjectName +
"' of tool '" + name +
"' is absent");
} else if(!ControlInterface.isInheritedOrSame(parentProject.getControlInterface(), controlInterface)) {
throw new ConfigException("Control interface of parent project '" + parentProjectName +
"' of tool '" + name +
"' is neither equal to nor base of control interface of the tool");
} else {
if(parentPackage == null) {
if(parentProject.getParentPackage() != null)
throw new ConfigException(
"Parent project '" + parentProjectName +
"' of tool '" + name +
"' refers to package '" + parentProject.getParentPackage().getName() +
"', but the tool doesn't refer to a package");
} else if(parentProject != null) {
if(parentProject.getParentPackage() == null)
throw new ConfigException(
"Parent project '" + parentProjectName +
"' of tool '" + name +
"' doesn't refer to any package, but the tool refers to package '" +
parentPackageName + "'");
else if(!parentProject.getParentPackage().getName().equals(parentPackageName))
throw new ConfigException(
"Parent project '" + parentProjectName +
"' of tool '" + name +
"' refers to package '" + parentProject.getParentPackage().getName() +
"', but the tool refers to package '" + parentPackageName +
"'");
}
}
}
private void initOtherAttributes() {
if(inputDialogLabel == null) {
if(baseTool != null && baseTool.inputDialogLabel != null)
inputDialogLabel = baseTool.inputDialogLabel;
}
}
private void inheritParams(Context context) throws ConfigException {
EntityUtils.update(context.getParams(), paramContainer.getParams());
}
private void inheritParamGroups() throws ConfigException {
EntityUtils.update(baseTool.paramGroups, paramGroups);
}
private void inheritCommandLines() throws ConfigException {
EntityUtils.update(baseTool.commandLinesBlocks, commandLinesBlocks);
}
private void initBaseTool() throws ConfigException {
if(baseToolName != null) {
baseTool = config.getContextManager().findTool(baseToolName);
if(baseTool == null)
throw new ConfigException("Base tool '" + baseToolName +
"' of tool '" + name +
"' is absent");
}
}
//
// other stuff
//
private String getResolvedExeName() {
return ConditionUtils.resolveContextCondition(this, exeName);
}
/*
private String getResolvedShellName() {
return ConditionUtils.resolveContextCondition(this, shellName);
}
*/
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params;
public class ToolException extends Exception {
public ToolException(String message) {
super(message);
}
public ToolException(String message, Throwable cause) {
super(message, cause);
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params;
import com.elphel.vdt.core.tools.config.ConfigException;
import com.elphel.vdt.core.tools.params.types.ParamType;
public class TypeDef {
private String name;
private ParamType type;
public TypeDef(String name, ParamType type) {
this.name = name;
this.type = type;
}
public void init(ControlInterface controlInterface) throws ConfigException {
type.init(controlInterface, name);
}
public String getName() {
return name;
}
public ParamType getType() {
return type;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.conditions;
import java.util.List;
public interface AbstractConditonValue {
public abstract String getValue();
public abstract List<String> getDependencies();
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.conditions;
import java.util.List;
public abstract class Comparison extends Condition {
protected COMPARE_OP op;
public enum COMPARE_OP {
EQ, NEQ;
public boolean isTrue(String s1, String s2) {
switch(this) {
case EQ: return s1.equals(s2);
case NEQ: return !s1.equals(s2);
}
assert false;
return false;
}
}
public Comparison(COMPARE_OP op) {
this.op = op;
}
public abstract boolean equals(Object other);
public abstract boolean isTrue();
public abstract List<String> getDependencies();
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.conditions;
import java.util.*;
public class Condition {
private Condition left, right;
private BOOL_OP op;
public enum BOOL_OP {
AND, OR;
public boolean isTrue(boolean left, boolean right) {
switch(this) {
case AND: return left && right;
case OR: return left || right;
}
assert false;
return false;
}
}
protected Condition() {
}
public Condition(BOOL_OP op, Condition left, Condition right) {
this.op = op;
this.left = left;
this.right = right;
}
public boolean equals(Object other) {
if(this == other)
return true;
if(!(other instanceof Condition))
return false;
Condition otherCondition = (Condition)other;
return op.equals(otherCondition.op) &&
left.equals(otherCondition.left) &&
right.equals(otherCondition.right);
}
public boolean isTrue() {
return op.isTrue(left.isTrue(), right.isTrue());
}
public List<String> getDependencies() {
List<String> deps = left.getDependencies();
deps.addAll(right.getDependencies());
return deps;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.conditions;
import java.util.*;
public class ConditionString extends ConditionValue {
private String value;
public ConditionString(Condition condition, String value) {
super(condition);
this.value = value;
}
public String getValue() {
return condition.isTrue()? value : null;
}
public List<String> getDependencies() {
List<String> deps = condition.getDependencies();
deps.add(value);
return deps;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.conditions;
import java.util.*;
import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.ui.MessageUI;
public class ConditionUtils {
private static HashMap<Context, HashMap<String, MultiConditionValue>> contextConditions =
new HashMap<Context, HashMap<String, MultiConditionValue>>();
public static List<String> resolveConditionStrings(ConditionalStringsList condStrings) {
List<String> relevantStrings = new ArrayList<String>();
for(ConditionalStringsList.Entry entry : condStrings.getEntries()) {
Condition relevant = entry.getCondition();
List<String> strings = entry.getStrings();
if(relevant == null || relevant.isTrue())
relevantStrings.addAll(strings);
}
return relevantStrings;
}
public static MultiConditionValue getContextCondition(Context context, String condString) {
if(!StringConditionParser.isConditionString(condString))
return null;
// use hash map to avoid repeated parsing of same string
HashMap<String, MultiConditionValue> conditions = contextConditions.get(context);
if(conditions == null) {
conditions = new HashMap<String, MultiConditionValue>();
contextConditions.put(context, conditions);
}
MultiConditionValue condValue = conditions.get(condString);
if(condValue == null) {
try {
condValue = context.getConditionParser().parse(condString);
conditions.put(condString, condValue);
} catch(ParseError e) {
MessageUI.error(e);
}
}
return condValue;
}
public static String resolveContextCondition(Context context, String condString) {
MultiConditionValue condValue = getContextCondition(context, condString);
if(condValue != null)
return condValue.getValue();
return condString;
}
public static boolean conditionsEqual(Condition a, Condition b) {
if((a == null && b != null) || (a != null && b == null))
return false;
return (a == b) || a.equals(b);
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.conditions;
import java.util.List;
public abstract class ConditionValue implements AbstractConditonValue {
protected Condition condition;
public ConditionValue(Condition condition) {
this.condition = condition;
}
public abstract String getValue();
public abstract List<String> getDependencies();
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.conditions;
import java.util.*;
public class ConditionalStringsList implements Cloneable {
public static class Entry {
private Condition condition;
private List<String> strings;
Entry(Condition condition, List<String> strings) {
this.condition = condition;
this.strings = strings;
}
public Condition getCondition() {
return condition;
}
public List<String> getStrings() {
return strings;
}
public void setCondition(Condition condition) {
this.condition = condition;
}
}
private List<Entry> entries = new ArrayList<Entry>();
public ConditionalStringsList() {
}
protected ConditionalStringsList(List<Entry> entries) {
this.entries = entries;
}
public List<Entry> getEntries() {
return entries;
}
public boolean isEmpty() {
return entries.isEmpty();
}
public void add(Condition condition, List<String> strings) {
entries.add(new Entry(condition, strings));
}
public void add(ConditionalStringsList list) {
entries.addAll(list.entries);
}
public void add(int entryIndex, int listIndex, ConditionalStringsList list) {
if(entryIndex > entries.size() || entryIndex < 0)
throw new IndexOutOfBoundsException("Entry index: " + entryIndex +
", Size: " + entries.size());
Entry entry = entries.get(entryIndex);
List<String> strings = entry.getStrings();
if(listIndex > strings.size() || listIndex < 0)
throw new IndexOutOfBoundsException("List entry index: " + listIndex +
", List size: " + strings.size());
List<String> stringsHead = new ArrayList<String>(strings.subList(0, listIndex));
List<String> stringsTail = new ArrayList<String>(strings.subList(listIndex, strings.size()));
int index = entryIndex;
entries.set(index, new Entry(entry.getCondition(), stringsHead));
index = entryIndex + 1;
entries.addAll(index, list.getEntries());
index = entryIndex + list.getEntries().size() + 1;
entries.add(index, new Entry(entry.getCondition(), stringsTail));
}
public void strengthenConditions(Condition addCondition) {
if(addCondition == null)
return;
for(Entry entry : entries) {
Condition cond = entry.getCondition();
if(cond == null)
entry.setCondition(addCondition);
else
entry.setCondition(new Condition(Condition.BOOL_OP.AND,
addCondition,
cond));
}
}
public Object clone() {
return new ConditionalStringsList(new ArrayList<Entry>(entries));
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.conditions;
import java.util.*;
public class MultiConditionValue implements AbstractConditonValue {
private List<ConditionValue> conditionValues;
private String defaultString;
public MultiConditionValue(List<ConditionValue> conditionValues) {
this.conditionValues = conditionValues;
}
public MultiConditionValue(List<ConditionValue> conditionValues, String defaultString) {
this(conditionValues);
this.defaultString = defaultString;
}
public String getValue() {
for(Iterator<ConditionValue> i = conditionValues.iterator(); i.hasNext();) {
String value = ((ConditionValue)i.next()).getValue();
if(value != null)
return value;
}
if(defaultString != null)
return defaultString;
return null;
}
public List<String> getDependencies() {
List<String> deps = new ArrayList<String>();
for(ConditionValue conditionValue : conditionValues)
deps.addAll(conditionValue.getDependencies());
deps.add(defaultString);
return deps;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.conditions;
import java.util.ArrayList;
public class NamedConditionalStringsList extends ConditionalStringsList {
private String name;
public NamedConditionalStringsList(String name) {
this.name = name;
}
public NamedConditionalStringsList(ConditionalStringsList list, String name) {
super(new ArrayList<Entry>(list.getEntries()));
this.name = name;
}
public String getName() {
return name;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.conditions;
public class ParseError extends Exception {
public ParseError(String expression, String message) {
super("Parse error in expression '" + expression + "': " + message);
}
public ParseError(String expression, int pos, String message) {
super("Parse error in expression '" + expression +
"', near position " + pos +
": " + message);
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.conditions;
import java.util.ArrayList;
import java.util.List;
import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.core.tools.params.FormatProcessor;
import com.elphel.vdt.core.tools.params.ToolException;
import com.elphel.vdt.core.tools.params.recognizers.ContextParamRecognizer;
import com.elphel.vdt.core.tools.params.recognizers.Recognizer;
import com.elphel.vdt.core.tools.params.recognizers.SimpleGeneratorRecognizer;
import com.elphel.vdt.ui.MessageUI;
public class StringComparison extends Comparison {
private Context context;
private String left, right;
public StringComparison(COMPARE_OP op, String left, String right) {
this(op, null, left, right);
}
public StringComparison(COMPARE_OP op, Context context, String left, String right) {
super(op);
this.context = context;
this.left = left;
this.right = right;
}
public boolean equals(Object other) {
if(this == other)
return true;
if(!(other instanceof StringComparison))
return false;
StringComparison otherComparison = (StringComparison)other;
return (context == otherComparison.context) &&
op.equals(otherComparison.op) &&
left.equals(otherComparison.left) &&
right.equals(otherComparison.right);
}
public boolean isTrue() {
String actualLeft = left;
String actualRight = right;
if(context != null) {
FormatProcessor processor =
new FormatProcessor(new Recognizer[] {
new ContextParamRecognizer(context),
new SimpleGeneratorRecognizer()
});
try {
actualLeft = processor.process(left).get(0);
actualRight = processor.process(right).get(0);
} catch(ToolException e) {
MessageUI.error(e);
}
}
return op.isTrue(actualLeft, actualRight);
}
public List<String> getDependencies() {
List<String> deps = new ArrayList<String>();
deps.add(left);
deps.add(right);
return deps;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.conditions;
import java.util.ArrayList;
import java.util.List;
import java.util.Iterator;
import com.elphel.vdt.util.StringPair;
import com.elphel.vdt.core.Utils;
import com.elphel.vdt.core.tools.contexts.Context;
public class StringConditionParser {
private static final char TOK_EQ = '=';
private static final char TOK_NEQ = '#';
private static final char TOK_AND = '^';
private static final char TOK_OR = '|';
private static final char TOK_COLON = ':';
private static final char TOK_COMMA = ',';
private static final char TOK_BRAKET_OPEN = '(';
private static final char TOK_BRAKET_CLOSE = ')';
private static final char TOK_PERCENT = '%';
private MultiConditionValue result;
private List<StringPair> selValuePairs = new ArrayList<StringPair>();
private String defaultValue;
private String trueValue, falseValue;
private Context context;
private String expression;
private String token;
private int curpos;
private enum ConditionType {
BOOLEAN, // "<CONDITION_MARK>condition: val1,val2"
SWITCH // "<CONDITION_MARK>%param: sel1=val1,...,selN=valN,valDef"
}
//
// interface
//
public static final String CONDITION_MARK = "?";
public StringConditionParser(Context context) {
this.context = context;
}
public static boolean isConditionString(String s) {
return s != null && s.startsWith(CONDITION_MARK);
}
public MultiConditionValue parse(String expression) throws ParseError {
if(!isConditionString(expression))
return null;
this.expression = expression;
this.result = null;
switch(detectConditionType()) {
case BOOLEAN: parseBooleanCondition(); break;
case SWITCH: parseSwitchCondition(); break;
}
return result;
}
//
// below comes all the internal machinery
//
private ConditionType detectConditionType() throws ParseError {
resetPos();
if(!nextToken())
parseError("no expression");
ConditionType type = ConditionType.BOOLEAN;
if(tokenIsChar(TOK_PERCENT)) {
if(!nextToken() || (tokenIsSpec() && !tokenIsChar(TOK_PERCENT)))
parseError("expected param or generator");
if(tokenIsChar(TOK_PERCENT)) // assume generator %%GenName
nextToken();
nextToken();
expected(new char[]{TOK_EQ, TOK_NEQ, TOK_COLON});
if(tokenIsChar(TOK_COLON))
type = ConditionType.SWITCH;
}
return type;
}
//
// condition creators
//
private void parseBooleanCondition() throws ParseError {
resetPos();
nextToken();
Condition condition = parseExpression();
parseBooleanSelectorList();
List<ConditionValue> conditionValues = new ArrayList<ConditionValue>();
assert trueValue != null;
conditionValues.add(new ConditionString(condition, trueValue));
assert falseValue != null;
// just use falseValue as default
result = new MultiConditionValue(conditionValues, falseValue);
}
private void parseSwitchCondition() throws ParseError {
resetPos();
nextToken();
expected(TOK_PERCENT);
nextToken();
String str;
if(tokenIsChar(TOK_PERCENT)) {
// generator
nextToken();
str = "%%";
} else {
str = "%";
}
str += token;
nextToken();
parseSwitchSelectorList();
List<ConditionValue> conditionValues = new ArrayList<ConditionValue>();
for(Iterator<StringPair> i = selValuePairs.iterator(); i.hasNext();) {
StringPair selVal = (StringPair)i.next();
Comparison comparison = new StringComparison(Comparison.COMPARE_OP.EQ, context, str, selVal.getFirst());
ConditionValue condVal = new ConditionString(comparison, selVal.getSecond());
conditionValues.add(condVal);
}
if(defaultValue != null)
result = new MultiConditionValue(conditionValues, defaultValue);
else
result = new MultiConditionValue(conditionValues);
}
//
// selector list parsers
//
private void parseBooleanSelectorList() throws ParseError {
trueValue = null;
falseValue = null;
expected(TOK_COLON);
// process two separated values
for(int count = 0; count <= 1; count++) {
nextTokenTo(TOK_COMMA);
String value = token;
nextToken();
if(count == 0) {
expected(TOK_COMMA);
trueValue = value;
} else {
falseValue = value;
}
}
if(token != null)
parseError("expected end of expression");
}
private void parseSwitchSelectorList() throws ParseError {
selValuePairs.clear();
defaultValue = null;
expected(TOK_COLON);
for(;;) {
nextTokenTo(TOK_EQ);
String sel = token;
if(!nextToken()) {
// expression ended, so assume previous sel
// to be actually a default value
defaultValue = sel;
break;
}
expected(TOK_EQ);
nextTokenTo(TOK_COMMA);
selValuePairs.add(new StringPair(sel, token));
if(!nextToken()) {
defaultValue = "";
break;
}
expected(TOK_COMMA);
}
}
//
// boolean expression parser stuff
//
private Condition parseExpression() throws ParseError {
Condition condition = parseOr();
return condition;
}
private Condition parseOr() throws ParseError {
Condition left = parseAnd();
if(tokenIsChar(TOK_OR)) {
if(!nextToken())
parseError("no tokens after " + TOK_OR);
Condition right = parseExpression();
return new Condition(Condition.BOOL_OP.OR, left, right);
} else {
return left;
}
}
private Condition parseAnd() throws ParseError {
Condition left = null;
if(tokenIsChar(TOK_BRAKET_OPEN)) {
if(!nextToken())
parseError("no tokens after open braket");
left = parseBrakets();
} else {
left = parseComparison();
}
if(tokenIsChar(TOK_AND)) {
if(!nextToken())
parseError("no tokens after " + TOK_OR);
Condition right = parseExpression();
return new Condition(Condition.BOOL_OP.AND, left, right);
} else {
return left;
}
}
private Condition parseBrakets() throws ParseError {
Condition condition = parseExpression();
expected(TOK_BRAKET_CLOSE);
nextToken();
return condition;
}
private Comparison parseComparison() throws ParseError {
checkEndOfExpression();
String left = token;
char[] comparisonSymbols = new char[]{ TOK_EQ, TOK_NEQ };
if(!tokenIsChar(comparisonSymbols)) {
nextTokenTo(comparisonSymbols);
left += token;
}
nextToken();
expected(comparisonSymbols);
Comparison.COMPARE_OP op = null;
if(tokenIsChar(TOK_EQ))
op = Comparison.COMPARE_OP.EQ;
else if(tokenIsChar(TOK_NEQ))
op = Comparison.COMPARE_OP.NEQ;
else
assert false;
nextTokenTo(new char[]{ TOK_EQ,
TOK_NEQ,
TOK_AND,
TOK_OR,
TOK_COLON,
TOK_BRAKET_OPEN,
TOK_BRAKET_CLOSE });
checkEndOfExpression();
String right = token;
Comparison comparison = new StringComparison(op, context, left, right);
nextToken();
return comparison;
}
//
// general purpose routines
//
private void resetPos() {
curpos = CONDITION_MARK.length();
}
private boolean nextToken() {
while(curpos < expression.length() && Utils.isSpace(expression.charAt(curpos)))
curpos++;
if(curpos >= expression.length()) {
token = null;
return false;
}
char ch = expression.charAt(curpos++);
token = "" + ch;
if(isSpecChar(ch))
return true;
for(; curpos < expression.length(); curpos++) {
ch = expression.charAt(curpos);
if(isSpecChar(ch) || Utils.isSpace(ch))
break;
token += ch;
}
return true;
}
// reads text to one of the given symbols
// leading and trailing spaces are removed
private void nextTokenTo(char[] endchars) {
token = "";
scanExpression:
for(; curpos < expression.length(); curpos++) {
char ch = expression.charAt(curpos);
for(int i = 0; i < endchars.length; i++)
if(ch == endchars[i])
break scanExpression;
token += ch;
}
token = token.trim();
}
private void nextTokenTo(char endchar) {
nextTokenTo(new char[]{ endchar });
}
private boolean isSpecChar(char ch) {
switch(ch) {
case TOK_EQ:
case TOK_NEQ:
case TOK_AND:
case TOK_OR:
case TOK_COLON:
case TOK_COMMA:
case TOK_BRAKET_OPEN:
case TOK_BRAKET_CLOSE:
case TOK_PERCENT:
return true;
default:
return false;
}
}
private boolean tokenIsChar(char[] chars) {
if(token != null) {
for(int i = 0; i < chars.length; i++)
if(token.equals("" + chars[i]))
return true;
}
return false;
}
private boolean tokenIsChar(char ch) {
return tokenIsChar(new char[]{ch});
}
private boolean tokenIsSpec() {
return token != null && token.length() == 1 && isSpecChar(token.charAt(0));
}
private void parseError(String message) throws ParseError {
int pos = curpos;
if(token != null) {
pos -= token.length();
if(pos < 0)
pos = curpos;
}
throw new ParseError(expression, pos, message);
}
private void expected(char symbol) throws ParseError {
expected(new char[]{symbol});
}
private void expected(char[] symbols) throws ParseError {
if(token != null) {
for(int i = 0; i < symbols.length; i++)
if(token.equals("" + symbols[i]))
return;
}
String symbolsString = "'";
for(int i = 0; i < symbols.length-1; i++)
symbolsString += symbols[i] + "' or '";
symbolsString += symbols[symbols.length-1];
parseError(symbolsString + "' expected, but '" + token + "' found");
}
private void checkEndOfExpression() throws ParseError {
if(token == null)
parseError("unexpected end of expression");
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.conditions;
import java.util.Iterator;
import java.util.List;
import com.elphel.vdt.core.tools.Updateable;
import com.elphel.vdt.core.tools.config.ConfigException;
public abstract class UpdateableStringsContainer implements Updateable {
private final static String FIRST_MARK = "first";
protected ConditionalStringsList strings;
protected ConditionalStringsList deleteStrings;
protected List<NamedConditionalStringsList> insertStrings;
public UpdateableStringsContainer(ConditionalStringsList strings,
ConditionalStringsList deleteStrings,
List<NamedConditionalStringsList> insertStrings)
{
this.strings = strings;
this.deleteStrings = deleteStrings;
this.insertStrings = insertStrings;
}
public abstract boolean matches(Updateable other);
public abstract Object clone();
public void update(Updateable from) throws ConfigException {
UpdateableStringsContainer container = (UpdateableStringsContainer)from;
ConditionalStringsList oldStrings =
(ConditionalStringsList)container.strings.clone();
if(strings != null)
oldStrings.add(strings);
strings = oldStrings;
insertSpecifiedStrings();
deleteSpecifiedStrings();
}
private void insertSpecifiedStrings() throws ConfigException {
if(insertStrings == null)
return;
for(NamedConditionalStringsList insert : insertStrings) {
String after = insert.getName();
if(after.equals(FIRST_MARK)) {
strings.add(0, 0, insert);
continue;
}
FindAfter:
// try to find line 'after' in the strings list, with condition that is true
for(int entryIndex = 0; entryIndex < strings.getEntries().size(); entryIndex++) {
ConditionalStringsList.Entry entry = strings.getEntries().get(entryIndex);
for(int listIndex = 0; listIndex < entry.getStrings().size(); listIndex++) {
String s = entry.getStrings().get(listIndex);
if(!after.equals(s))
continue;
Condition cond = entry.getCondition();
if(cond != null && !cond.isTrue())
continue;
// okay, entry found, and the condition is met
// now, apply the found condition and insert the
// strings at the found position
insert.strengthenConditions(cond);
strings.add(entryIndex, listIndex+1, insert);
break FindAfter;
}
}
}
}
private void deleteSpecifiedStrings() throws ConfigException {
if(deleteStrings == null)
return;
for(ConditionalStringsList.Entry delStrings : deleteStrings.getEntries()) {
for(ConditionalStringsList.Entry thisStrings : strings.getEntries()) {
if(!ConditionUtils.conditionsEqual(thisStrings.getCondition(),
delStrings.getCondition()))
{
continue;
}
FindLineToDelete:
for(String lineToDelete : delStrings.getStrings()) {
for(Iterator<String> foundLineToDelete = thisStrings.getStrings().iterator();
foundLineToDelete.hasNext();)
{
if((foundLineToDelete.next().equals(lineToDelete))) {
foundLineToDelete.remove();
break FindLineToDelete;
}
}
//throw new ConfigException("Line '" + lineToDelete +
// "' specied in the 'delete' list of context '" + contextName +
// "' doesn't exist");
}
}
}
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.recognizers;
import com.elphel.vdt.core.tools.params.Parameter;
import com.elphel.vdt.core.tools.params.ToolException;
import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.core.tools.generators.AbstractGenerator;
import com.elphel.vdt.core.tools.generators.ValueGenerator;
public class ContextParamRecognizer extends ParamRecognizer {
private Context context;
public ContextParamRecognizer(Context context) {
this.context = context;
}
protected Parameter findParam(String paramID) {
return context.findParam(paramID);
}
protected AbstractGenerator getGenerator(Parameter param) throws ToolException {
return new ValueGenerator(param, "", "", "");
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.recognizers;
import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.core.tools.generators.AbstractGenerator;
import com.elphel.vdt.core.tools.generators.ValueGenerator;
import com.elphel.vdt.core.tools.params.Parameter;
public class ContextParamRepeaterRecognizer extends RepeaterRecognizer {
private Context context;
public ContextParamRepeaterRecognizer(Context context) {
this.context = context;
}
protected AbstractGenerator findGenerator(String paramID,
String repPrefix,
String repSuffix,
String separator)
{
Parameter param = context.findParam(paramID);
if(param != null)
return new ValueGenerator(param, repPrefix, repSuffix, separator);
return null;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.recognizers;
import com.elphel.vdt.core.Utils;
import com.elphel.vdt.core.tools.params.Parameter;
import com.elphel.vdt.core.tools.generators.AbstractGenerator;
public class ParamFormatRecognizer implements Recognizer {
static final String FORMAT_PARAM_NAME_MARK = "ParamName";
static final String FORMAT_PARAM_VALUE_MARK = "ParamValue";
private static final String FORMAT_MARKER = "%";
// private static final String FORMAT_MARKER_OPEN = "{";
// private static final String FORMAT_MARKER_CLOSE = "}";
private static final int FORMAT_MARKER_LEN = FORMAT_MARKER.length();
// private static final int FORMAT_MARKER_OPEN_LEN = FORMAT_MARKER_OPEN.length();
// private static final int FORMAT_MARKER_CLOSE_LEN = FORMAT_MARKER_CLOSE.length();
private final Parameter param;
public ParamFormatRecognizer(Parameter param) {
this.param = param;
}
public RecognizerResult recognize(String template, int startPos) {
RecognizerResult result = new RecognizerResult();
String genName;
int newPos = -1;
// if(template.startsWith(FORMAT_MARKER_OPEN, startPos)) {
// int endPos = template.indexOf(FORMAT_MARKER_CLOSE, startPos);
//
// if(endPos < 0)
// return result;
//
// // cut the identifier between open and close symbols
// genName = template.substring(startPos + FORMAT_MARKER_OPEN_LEN, endPos);
// newPos = endPos + FORMAT_MARKER_CLOSE_LEN;
// } else
if(template.startsWith(FORMAT_MARKER, startPos)){
startPos += FORMAT_MARKER_LEN;
newPos = Utils.findBoundary(template, startPos);
genName = template.substring(startPos, newPos);
} else {
return result;
}
assert genName != null;
assert newPos >= 0;
if(genName.equals(FORMAT_PARAM_NAME_MARK)) {
result.set(new AbstractGenerator() {
public String getName() {
return "ParamName (parameter '" + param.getID() +
"' of context '" + param.getContext().getName() +
"')";
}
protected String[] getStringValues() {
return new String[]{param.getOutID()};
}
},
newPos);
} else if(genName.equals(FORMAT_PARAM_VALUE_MARK)) {
result.set(new AbstractGenerator() {
public String getName() {
return "ParamValue (parameter '" + param.getID() +
"' of context '" + param.getContext().getName() +
"')";
}
protected String[] getStringValues() {
return new String[]{param.getExternalValueForm().get(0)};
}
},
newPos);
}
return result;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.recognizers;
import com.elphel.vdt.core.Utils;
import com.elphel.vdt.core.tools.generators.AbstractGenerator;
import com.elphel.vdt.core.tools.params.Parameter;
import com.elphel.vdt.core.tools.params.ToolException;
public abstract class ParamRecognizer implements Recognizer {
public RecognizerResult recognize(String template, int startPos) throws ToolException {
RecognizerResult result = new RecognizerResult();
int newPos = Utils.findBoundary(template, startPos);
String paramID = template.substring(startPos, newPos);
Parameter param = findParam(paramID);
if(param != null)
result.set(getGenerator(param), newPos);
return result;
}
protected abstract Parameter findParam(String paramID);
protected abstract AbstractGenerator getGenerator(Parameter param) throws ToolException;
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.recognizers;
import com.elphel.vdt.core.tools.generators.AbstractGenerator;
import com.elphel.vdt.core.tools.generators.FileListGenerator;
import com.elphel.vdt.core.tools.generators.SourceListGenerator;
import com.elphel.vdt.core.tools.generators.TopModulesNameGenerator;
import com.elphel.vdt.core.tools.generators.ValueGenerator;
import com.elphel.vdt.core.tools.params.Parameter;
public class ParamRepeaterRecognizer extends RepeaterRecognizer {
private final Parameter param;
public ParamRepeaterRecognizer(Parameter param) {
this.param = param;
}
protected AbstractGenerator findGenerator(String genName,
String repPrefix,
String repSuffix,
String separator)
{
if(genName.equals(ParamFormatRecognizer.FORMAT_PARAM_VALUE_MARK))
return new ValueGenerator(param, repPrefix, repSuffix, separator);
/* Trying to put these here */
if(genName.equals(SourceListGenerator.NAME))
return new SourceListGenerator(repPrefix, repSuffix, separator);
else if(genName.equals(FileListGenerator.NAME))
return new FileListGenerator(repPrefix, repSuffix, separator);
else if(genName.equals(TopModulesNameGenerator.NAME))
return new TopModulesNameGenerator(repPrefix, repSuffix, separator);
return null;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.recognizers;
import com.elphel.vdt.core.tools.params.ToolException;
public interface Recognizer {
public RecognizerResult recognize(String template, int startPos) throws ToolException;
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.recognizers;
import com.elphel.vdt.core.tools.generators.AbstractGenerator;
public class RecognizerResult {
private AbstractGenerator generator = null;
private int newPos = -1;
public void set(AbstractGenerator generator, int newPos) {
this.generator = generator;
this.newPos = newPos;
}
public AbstractGenerator getGenerator() {
return generator;
}
public int getNewPos() {
if(generator == null)
return -1;
return newPos;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.recognizers;
import com.elphel.vdt.core.Utils;
import com.elphel.vdt.core.tools.params.ToolException;
import com.elphel.vdt.core.tools.generators.AbstractGenerator;
import com.elphel.vdt.core.tools.generators.FileListGenerator;
import com.elphel.vdt.core.tools.generators.TopModulesNameGenerator;
import com.elphel.vdt.core.tools.generators.SourceListGenerator;
public class RepeaterRecognizer implements Recognizer {
private static final String FORMAT_REPEATER_NAME_MARK = "%%";
private static int FORMAT_REPEATER_NAME_MARK_LEN = FORMAT_REPEATER_NAME_MARK.length();
private static final String FORMAT_REPEATER_OPEN = "(";
private static final String FORMAT_REPEATER_SEP = "%|";
private static final String FORMAT_REPEATER_CLOSE = "%)";
private static final int FORMAT_REPEATER_OPEN_LEN = FORMAT_REPEATER_OPEN.length();
private static final int FORMAT_REPEATER_SEP_LEN = FORMAT_REPEATER_SEP.length();
private static final int FORMAT_REPEATER_CLOSE_LEN = FORMAT_REPEATER_CLOSE.length();
public RecognizerResult recognize(String template, int startPos)
throws ToolException
{
RecognizerResult result = new RecognizerResult();
if(!template.startsWith(FORMAT_REPEATER_OPEN, startPos))
return result;
startPos += FORMAT_REPEATER_OPEN_LEN;
int sepPos = template.indexOf(FORMAT_REPEATER_SEP, startPos);
int closePos = template.indexOf(FORMAT_REPEATER_CLOSE, startPos);
if(closePos < 0)
return result;
String repBody;
String sepBody;
if(sepPos >= 0 && sepPos < closePos) {
repBody = template.substring(startPos, sepPos);
sepBody = template.substring(sepPos + FORMAT_REPEATER_SEP_LEN, closePos);
} else {
repBody = template.substring(startPos, closePos);
sepBody = "";
}
int genNamePos = repBody.indexOf(FORMAT_REPEATER_NAME_MARK);
if(genNamePos < 0)
throw new ToolException("Generator name (i.e. sequence '" + FORMAT_REPEATER_NAME_MARK +
"NAME') not found");
int genNameEnd = Utils.findBoundary(repBody, genNamePos + FORMAT_REPEATER_NAME_MARK_LEN);
if(genNameEnd == genNamePos)
throw new ToolException("Generator name after '" + FORMAT_REPEATER_NAME_MARK +
"' mark is absent");
String repPrefix = repBody.substring(0, genNamePos);
String genName = repBody.substring(genNamePos + FORMAT_REPEATER_NAME_MARK_LEN, genNameEnd);
String repSuffix = repBody.substring(genNameEnd);
// System.out.println("Gen name: '" + genName +
// "', repPrefix: '" + repPrefix +
// "', repSuffix: '" + repSuffix +
// "', sepBody: '" + sepBody +
// "'");
result.set(findGenerator(genName, repPrefix, repSuffix, sepBody), /* Why did it miss FileListGenerator here? */
closePos + FORMAT_REPEATER_CLOSE_LEN);
if(result.getGenerator() == null)
throw new ToolException("Unknown generator '" + genName + "'");
return result;
}
protected AbstractGenerator findGenerator(String genName,
String repPrefix,
String repSuffix,
String separator)
{
System.out.println("Ever get here? RepeaterRecognizer.java:findGenerator()");
AbstractGenerator gen=new SourceListGenerator(repPrefix, repSuffix, separator);
if (genName.equals(gen.getName())) return gen;
gen=new FileListGenerator(repPrefix, repSuffix, separator);
if (genName.equals(gen.getName())) return gen;
gen=new TopModulesNameGenerator(repPrefix, repSuffix, separator);
if (genName.equals(gen.getName())) return gen;
/* ID, not name! */
/*
if(genName.equals(SourceListGenerator.NAME))
return new SourceListGenerator(repPrefix, repSuffix, separator);
else if(genName.equals(FileListGenerator.NAME))
return new FileListGenerator(repPrefix, repSuffix, separator);
else if(genName.equals(TopModulesNameGenerator.NAME))
return new TopModulesNameGenerator(repPrefix, repSuffix, separator);
*/
return null;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.recognizers;
import com.elphel.vdt.core.Utils;
import com.elphel.vdt.core.tools.generators.*;
public class SimpleGeneratorRecognizer implements Recognizer {
private static final String CONTROL_SEQ = "%";
private static final int CONTROL_SEQ_LEN = CONTROL_SEQ.length();
private static AbstractGenerator[] generators = new AbstractGenerator[] {
new OSNameGenerator(),
new ProjectNameGenerator(),
new ProjectPathGenerator(),
new TopModuleNameGenerator(),
new CurrentFileGenerator(),
new CurrentFileBaseGenerator()
};
public RecognizerResult recognize(String template, int startPos) {
RecognizerResult result = new RecognizerResult();
// first see if there is the control sequence
if(template.startsWith(CONTROL_SEQ, startPos)) {
startPos += CONTROL_SEQ_LEN;
// read the identifier from startPos
int newPos = Utils.findBoundary(template, startPos);
String genName = template.substring(startPos, newPos);
result.set(findGenerator(genName), newPos);
}
return result;
}
private AbstractGenerator findGenerator(String genName) {
for(int i = 0; i < generators.length; i++)
if(genName.equals(generators[i].getName()))
return generators[i];
return null;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.recognizers;
import com.elphel.vdt.core.tools.generators.AbstractGenerator;
import com.elphel.vdt.core.tools.generators.StringsGenerator;
import com.elphel.vdt.core.tools.params.Tool;
import com.elphel.vdt.core.tools.params.Parameter;
import com.elphel.vdt.core.tools.params.ToolException;
public class ToolParamRecognizer extends ParamRecognizer {
private Tool tool;
public ToolParamRecognizer(Tool tool) {
this.tool = tool;
}
protected Parameter findParam(String paramID) {
return tool.findParam(paramID);
}
protected AbstractGenerator getGenerator(final Parameter param) throws ToolException {
return new StringsGenerator(param.getCommandLine()) {
public String getName() {
return "Param '" + param +
"' of tool '" + tool.getName() +
"' command line";
}
};
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.types;
import com.elphel.vdt.core.tools.config.ConfigException;
import com.elphel.vdt.core.tools.params.ControlInterface;
public abstract class ParamType {
public abstract String getName();
public abstract boolean isList();
public abstract String toExternalForm(String paramValue);
public abstract void init(ControlInterface controlInterface, String typedefName) throws ConfigException;
public abstract void checkValue(String value) throws ConfigException;
public boolean equal(String value1, String value2) {
return value1.equals(value2);
}
public String canonicalizeValue(String value) {
return value;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.types;
import com.elphel.vdt.core.tools.config.ConfigException;
import com.elphel.vdt.core.tools.params.ControlInterface;
import com.elphel.vdt.core.tools.BooleanUtils;
public class ParamTypeBool extends ParamType {
public static final String NAME = "bool";
public static final String FORMAT_TRUE_ID = "formatTrue";
public static final String FORMAT_FALSE_ID = "formatFalse";
private String formatTrue;
private String formatFalse;
public ParamTypeBool(String formatTrue, String formatFalse) {
this.formatTrue = formatTrue;
this.formatFalse = formatFalse;
}
public void init(ControlInterface controlInterface, String typedefName)
throws ConfigException
{
}
public String getName() {
return NAME;
}
public boolean isList() {
return false;
}
public String getFormatFalse() {
return formatFalse;
}
public String getFormatTrue() {
return formatTrue;
}
public boolean toBoolean(String value) {
if(value.equals(BooleanUtils.VALUE_TRUE))
return true;
else
return false;
}
public String toExternalForm(String paramValue) {
if(BooleanUtils.isTrue(paramValue))
return formatTrue;
else if(BooleanUtils.isFalse(paramValue))
return formatFalse;
else
return null;
}
public void checkValue(String value) throws ConfigException {
assert !FORMAT_TRUE_ID.equals(FORMAT_FALSE_ID);
if(!BooleanUtils.isBoolean(value))
throw new ConfigException("Bad bool value '" + value +
"': must be either '" + BooleanUtils.VALUE_TRUE +
"' or '" + BooleanUtils.VALUE_FALSE +
"'");
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.types;
import com.elphel.vdt.core.tools.config.ConfigException;
import com.elphel.vdt.core.tools.params.ControlInterface;
public class ParamTypeEnum extends ParamType {
public static final String NAME = "enum";
public static final String ELEM_LABEL_ID = "label";
public static final String ELEM_VALUE_ID = "value";
public static final String BASETYPE_ID = "base";
private ParamType baseType;
private String baseTypeName;
private String[] labels;
private String[] values;
public ParamTypeEnum(String baseTypeName, String[] labels, String[] values) {
this.baseTypeName = baseTypeName;
this.labels = labels;
this.values = values;
}
public void init(ControlInterface controlInterface, String typedefName)
throws ConfigException
{
baseType = controlInterface.findParamType(baseTypeName);
if(baseType == null)
throw new ConfigException("Base type '" + baseTypeName +
"' of '" + NAME +
"' type '" + typedefName +
"' is not found in control interface '" +
controlInterface.getName() + "'");
assert labels.length == values.length;
for(int i = 0; i < labels.length; i++)
for(int j = i+1; j < labels.length; j++) {
if(labels[i].equals(labels[j]))
throw new ConfigException("Label '" + labels[i] +
"' in '" + NAME +
"' type '" + typedefName +
"' is duplicated");
if(values[i].equals(values[j]))
throw new ConfigException("Value '" + values[i] +
"' in '" + NAME +
"' type '" + typedefName +
"' is duplicated");
}
}
public String getName() {
return NAME;
}
public boolean isList() {
return false;
}
public String getBaseTypeName() {
return baseTypeName;
}
public String[] getLabels() {
return labels;
}
public String[] getValues() {
return values;
}
public int getLabelIndex(String label) {
for(int i = 0; i < labels.length; i++)
if(label.equals(labels[i]))
return i;
return -1;
}
public int getValueIndex(String paramValue) {
for(int i = 0; i < values.length; i++)
if(paramValue.equals(values[i]))
return i;
return -1;
}
public String toExternalForm(String paramValue) {
int valueIndex = getValueIndex(paramValue);
return valueIndex >= 0? values[valueIndex] : null;
}
public boolean equal(String value1, String value2) {
return baseType.equal(value1, value2);
}
public String canonicalizeValue(String value) {
return baseType.canonicalizeValue(value);
}
public void checkValue(String value) throws ConfigException {
if(getValueIndex(value) < 0)
throw new ConfigException("Value '" + value +
"' of type '" + NAME +
"' is not listed in the values list");
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.types;
import com.elphel.vdt.core.tools.config.ConfigException;
import com.elphel.vdt.core.tools.params.ControlInterface;
public class ParamTypeNumber extends ParamType {
public static final String NAME = "number";
public static final String LO_ID = "lo";
public static final String HI_ID = "hi";
public static final String FORMAT_ID = "format";
private int lo;
private int hi;
private String format;
public ParamTypeNumber(int lo, int hi, String format) {
this.lo = lo;
this.hi = hi;
this.format = format;
}
public void init(ControlInterface controlInterface, String typedefName)
throws ConfigException
{
if(lo > hi)
throw new ConfigException("Low bound (" + lo +
") of '" + NAME +
"' type '" + NAME +
"' is greater that the high bound (" + hi + ")");
}
public String getName() {
return NAME;
}
public boolean isList() {
return false;
}
public String getFormat() {
return format;
}
public int getLo() {
return lo;
}
public int getHi() {
return hi;
}
public String toExternalForm(String paramValue) {
return paramValue;
}
public void checkValue(String value) throws ConfigException {
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.types;
import com.elphel.vdt.core.tools.config.ConfigException;
import com.elphel.vdt.core.tools.params.ControlInterface;
public class ParamTypeString extends ParamType {
public static final String NAME = "string";
public static final int DEFAULT_LENGTH = 256;
public static final String MAX_LENGTH_ID = "maxlength";
public static final String CASE_SENSITIVITY_ID = "sensitivity";
public static final String CASE_SENSITIVE_ID = "sensitive";
public static final String CASE_INSENSITIVE_ID = "insensitive";
public static final String CASE_LOWERCASE_ID = "lowercase";
public static final String CASE_UPPERCASE_ID = "uppercase";
public static final String KIND_ID = "textkind";
public static final String KIND_TEXT_ID = "text";
public static final String KIND_FILE_ID = "file";
public static final String KIND_DIR_ID = "dir";
public static final String FILEMASK_ID = "filemask";
public enum CASE {
SENSITIVE,
INSENSITIVE,
LOWERCASE,
UPPERCASE
}
public enum KIND {
TEXT,
FILE,
DIR
}
private static final String DEFAULT_FILEMASK = "*";
private final KIND kind;
private final CASE caseSensitive;
private final int maxLength;
private final String filemask;
private final boolean is_list;
public ParamTypeString(boolean is_list,
int maxLength,
CASE caseSensitive)
{
this(is_list, maxLength, caseSensitive, KIND.TEXT);
}
public ParamTypeString(boolean is_list,
int maxLength,
CASE caseSensitive,
KIND kind)
{
this(is_list, maxLength, caseSensitive, kind, DEFAULT_FILEMASK);
}
public ParamTypeString(boolean is_list,
int maxLength,
CASE caseSensitive,
KIND kind,
String filemask)
{
this.maxLength = maxLength;
this.caseSensitive = caseSensitive;
this.filemask = filemask;
this.is_list = is_list;
this.kind = kind;
}
public void init(ControlInterface controlInterface, String typedefName)
throws ConfigException
{
if(maxLength <= 0)
throw new ConfigException("Maximum length (" + maxLength +
") in '" + NAME +
"' type '" + typedefName +
"' is bad: must be positive");
}
public String getName() {
return NAME;
}
public boolean isList() {
return is_list;
}
public KIND getKind() {
return kind;
}
public String getFilemask() {
return filemask;
}
public CASE getCaseSensitive() {
return caseSensitive;
}
public int getMaxLength() {
return maxLength;
}
public String toExternalForm(String paramValue) {
return paramValue;
}
public boolean equal(String value1, String value2) {
switch(caseSensitive) {
case SENSITIVE:
return value1.equals(value2);
default:
return value1.equalsIgnoreCase(value2);
}
}
public String canonicalizeValue(String value) {
switch(caseSensitive) {
case UPPERCASE:
return value.toUpperCase();
case LOWERCASE:
return value.toLowerCase();
default:
return value;
}
}
public void checkValue(String value) throws ConfigException {
if(value.length() > maxLength)
throw new ConfigException("Bad string '" + value +
"' value length " + value.length() +
": must be less or equal to " + maxLength);
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.ui;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.ui.model.IWorkbenchAdapter;
//import com.elphel.vdt.core.verilog.parser.Module;
//import com.elphel.vdt.ui.views.VerilogModuleElement;
/**
* Adapter factory for verilog module.
*
* Created: 23.03.2006
* @author Lvov Konstantin
*/
public class AdapterFactory implements IAdapterFactory {
/** The supported types that we can adapt to */
private static final Class[] types = {
IWorkbenchAdapter.class
, IResource.class
, IFile.class
};
public Object getAdapter(Object object, Class adapterType) {
System.out.println("*** Broken ui.AdapterFactory.getAdapter() for Verilog parser ***");
/*
if (object instanceof Module) {
Module module = (Module) object;
if (adapterType == IWorkbenchAdapter.class) {
return new VerilogModuleElement(module);
} else if (adapterType == IResource.class) {
return module.getSourceFile().getFile();
} else if (adapterType == IFile.class) {
return module.getSourceFile().getFile();
}
}
*/
return null;
}
/**
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
*/
public Class[] getAdapterList() {
return types;
}
} // class AdapterFactory
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.ui;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
//import com.elphel.vdt.VDTPlugin;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.Txt;
import com.elphel.vdt.ui.dialogs.VDTErrorDialog;
/**
* Output of user interface message/error
*
* Created: 14.12.2005
* @author Lvov Konstantin
*/
public class MessageUI {
static final String ERROR_CAPTION = Txt.s("Message.Error.Caption");
static final String FATAL_ERROR_CAPTION = Txt.s("Message.FatalError.Caption");
static public void error(final String message, final Throwable exception) {
showErrorMessage(message, exception, ERROR_CAPTION);
}
static public void error(final String message) {
showErrorMessage(message, ERROR_CAPTION);
}
static public void error(final Throwable exception) {
showErrorMessage(exception, ERROR_CAPTION);
}
static public void fatalError(String message) {
showErrorMessage(message, FATAL_ERROR_CAPTION);
}
static public void showErrorMessage(final String message,
final Throwable exception,
final String caption)
{
log(caption+":"+message);
log(exception);
openErrorMessageDialog(caption, message, exception);
} // showErrorMessage()
static public void showErrorMessage(final String message, final String caption) {
log(caption+":"+message);
openErrorMessageDialog(caption, message, null);
} // showErrorMessage()
static public void showErrorMessage(final Throwable exception, final String caption) {
log(exception);
openErrorMessageDialog(caption, null, exception);
} // showErrorMessage()
private static void openErrorMessageDialog( final String caption
, final String message
, final Throwable exception)
{
String actualMessage = message;
if(actualMessage == null) {
if(exception.getMessage() != null)
actualMessage = exception.getClass().getName() + ": " + exception.getMessage();
else
actualMessage = "Unhandled exception: " + exception.getClass().getName();
}
final IStatus status =
new Status(IStatus.ERROR,
VerilogPlugin.getVdtId(),
IStatus.ERROR,
actualMessage,
exception);
VerilogPlugin.getStandardDisplay().syncExec(new Runnable() {
public void run() {
VDTErrorDialog.openError(VerilogPlugin.getActiveWorkbenchShell(),
caption,
status);
}
});
}
//-------------------------------------------------------------------------
// Message Logging
//-------------------------------------------------------------------------
private static boolean loggingOn = true;
public static void log(IStatus status) {
if (loggingOn) {
System.out.println(status.getMessage());
if(status.getException() != null)
status.getException().printStackTrace();
VerilogPlugin.getDefault().getLog().log(status);
}
}
public static void log(String message) {
log(((IStatus) (new Status( IStatus.ERROR
, VerilogPlugin.getVdtId()
, IStatus.ERROR
, message, null
) )) );
}
public static void log(Throwable e) {
log(((IStatus) (new Status( IStatus.ERROR
, VerilogPlugin.getVdtId()
, IStatus.ERROR
, "Internal Error"
, e
) )) );
}
} // class MessageUI
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.ui;
import java.io.File;
import java.net.URL;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;
// TODO: remove this import?
import org.eclipse.debug.internal.ui.DebugPluginImages;
import com.elphel.vdt.VDT;
//import com.elphel.vdt.VDTPlugin;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.core.tools.contexts.PackageContext;
import com.elphel.vdt.core.tools.contexts.ProjectContext;
import com.elphel.vdt.core.tools.params.Tool;
/**
* Bundle of all images used by the EFD plugin.
*
* Created: 15.01.2006
* @author Lvov Konstantin
*/
public class VDTPluginImages {
/**
* The image registry containing <code>Image</code>s.
*/
private static ImageRegistry imageRegistry;
public final static String ICONS_PATH = "icons"+File.separator; //$NON-NLS-1$
public static final ImageDescriptor DESC_VERILOG_FILE = create(ICONS_PATH, "eview16"+File.separator+"verilog_file.gif", null);
public static final ImageDescriptor DESC_RUN_TOOL = create(ICONS_PATH, "obj16"+File.separator+"run_tool.gif", null);
public static final ImageDescriptor DESC_TOOL_PROPERTIES = create(ICONS_PATH, "obj16"+File.separator+"tool_prop.gif", null);
public static final ImageDescriptor DESC_LAUNCH_CONFIG = create(ICONS_PATH, "obj16"+File.separator+"vdt_tools.gif", null);
public static final ImageDescriptor DESC_INSTALL_PROPERTIES = create(ICONS_PATH, "obj16"+File.separator+"install_prop.gif", null);
public static final ImageDescriptor DESC_PACKAGE_PROPERTIES = create(ICONS_PATH, "obj16"+File.separator+"package_prop.gif", null);
public static final ImageDescriptor DESC_PROJECT_PROPERTIES = create(ICONS_PATH, "obj16"+File.separator+"project_prop.gif", null);
public static final ImageDescriptor DESC_DESIGM_MENU = create(ICONS_PATH, "obj16"+File.separator+"design_menu.gif", null);
public static final String CHECKBOX_ON = "CHECKBOX_ON";
public static final String CHECKBOX_OFF = "CHECKBOX_OFF";
public static final String CHECKBOX_ON_DISABLE = "CHECKBOX_ON_DISABLE";
public static final String CHECKBOX_OFF_DISABLE = "CHECKBOX_OFF_DISABLE";
public static final String CHECKBOX_ON_DEFAULT = "CHECKBOX_ON_DEFAULT";
public static final String CHECKBOX_OFF_DEFAULT = "CHECKBOX_OFF_DEFAULT";
public static final String CHECKBOX_ON_DEFAULT_DISABLE = "CHECKBOX_ON_DEFAULT_DISABLE";
public static final String CHECKBOX_OFF_DEFAULT_DISABLE = "CHECKBOX_OFF_DEFAULT_DISABLE";
public static final ImageDescriptor DESC_CHECKBOX_ON = create(ICONS_PATH, "obj16"+File.separator+"cb_on.gif", CHECKBOX_ON);
public static final ImageDescriptor DESC_CHECKBOX_OFF = create(ICONS_PATH, "obj16"+File.separator+"cb_off.gif", CHECKBOX_OFF);
public static final ImageDescriptor DESC_CHECKBOX_ON_DISABLE = create(ICONS_PATH, "obj16"+File.separator+"cb_on_disable.gif", CHECKBOX_ON_DISABLE);
public static final ImageDescriptor DESC_CHECKBOX_OFF_DISABLE = create(ICONS_PATH, "obj16"+File.separator+"cb_off_disable.gif", CHECKBOX_OFF_DISABLE);
public static final ImageDescriptor DESC_CHECKBOX_ON_DEFAULT = create(ICONS_PATH, "obj16"+File.separator+"cb_on_default.gif", CHECKBOX_ON_DEFAULT);
public static final ImageDescriptor DESC_CHECKBOX_OFF_DEFAULT = create(ICONS_PATH, "obj16"+File.separator+"cb_off_default.gif", CHECKBOX_OFF_DEFAULT);
public static final ImageDescriptor DESC_CHECKBOX_ON_DEFAULT_DISABLE = create(ICONS_PATH, "obj16"+File.separator+"cb_on_disable_default.gif", CHECKBOX_ON_DEFAULT_DISABLE);
public static final ImageDescriptor DESC_CHECKBOX_OFF_DEFAULT_DISABLE = create(ICONS_PATH, "obj16"+File.separator+"cb_off_disable_default.gif", CHECKBOX_OFF_DEFAULT_DISABLE);
private static ImageDescriptor create (String prefix, String name, String key) {
ImageDescriptor desc = ImageDescriptor.createFromURL(makeImageURL(prefix, name));
if (key != null)
getImageRegistry().put(key, desc);
return desc;
}
public static void addImage(String fileName, String key, String launchType) {
ImageDescriptor desc = null;
File file = new File(fileName);
if (file.isAbsolute()) {
desc = ImageDescriptor.createFromFile(null, fileName);
} else {
desc = ImageDescriptor.createFromURL(makeImageURL(ICONS_PATH, fileName));
}
if (key != null)
getImageRegistry().put(key, desc);
if ((launchType != null) && !VDT.ID_DEFAULT_LAUNCH_TYPE.equals(launchType))
DebugPluginImages.getImageRegistry().put(launchType, desc);
} // addImage()
private static URL makeImageURL(String prefix, String name) {
String path = "$nl$/" + prefix + name; //$NON-NLS-1$
/* TODO: fix deprecation */
URL url_try= org.eclipse.core.runtime.FileLocator.find(VerilogPlugin.getDefault().getBundle(), new Path(path), null);
return Platform.find(VerilogPlugin.getDefault().getBundle(), new Path(path));
}
/**
* Returns the <code>Image<code> identified by the given key,
* or <code>null</code> if it does not exist.
*/
public static Image getImage (String key) {
return getImageRegistry().get(key);
} // getImage()
/**
* Returns the <code>ImageDescriptor</code> identified by the given key,
* or <code>null</code> if it does not exist.
*/
public static ImageDescriptor getImageDescriptor(String key) {
return getImageRegistry().getDescriptor(key);
}
/**
* Returns the VDTPlugin ImageRegistry.
*/
public static ImageRegistry getImageRegistry () {
if (imageRegistry == null) {
imageRegistry = new ImageRegistry(VerilogPlugin.getStandardDisplay());
}
return imageRegistry;
} // getImageRegistry()
/**
* Returns the <code>ImageDescriptor</code> identified by the given context,
* or <code>null</code> if it does not exist.
*/
public static ImageDescriptor getImageDescriptor(Context context) {
String imageName = context.getIconName();
if (imageName != null) {
String imageKey = VDT.ID_VDT + ".ContextImage.";
if (context instanceof PackageContext)
imageKey = "Package.";
else if (context instanceof ProjectContext)
imageKey = "Project.";
else if (context instanceof Tool)
imageKey = "Tool.";
imageKey += context.getName();
ImageDescriptor image = VDTPluginImages.getImageDescriptor(imageKey);
if (image == null) {
VDTPluginImages.addImage(imageName, imageKey, null);
image = VDTPluginImages.getImageDescriptor(imageKey);
}
return image;
}
return null;
}
} // VDTPluginImages
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.ui.dialogs;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import com.elphel.vdt.Txt;
import com.elphel.vdt.core.tools.ToolsCore;
import com.elphel.vdt.core.tools.menu.DesignMenu;
public class DesignMenuSelectionDialog extends Dialog {
private static final String NONE_ITEM = "None";
private static final String NONE_ITEM_DESC = "No design menu for the project";
private Combo comboDesignMenu;
private Label labelDesignMenuDesc;
private List<DesignMenu> desigmMenus;
private DesignMenu selectedDesignMenu;
private String currentDesignMenuName;
public DesignMenuSelectionDialog(Shell parent) {
this(parent, null);
}
public DesignMenuSelectionDialog( Shell parent
, String currentDesignMenuName ) {
super(parent);
desigmMenus = ToolsCore.getDesignMenuManager().getDesignMenuList();
this.currentDesignMenuName = currentDesignMenuName;
}
public DesignMenu getSelectedDesignMenu() {
return selectedDesignMenu;
}
protected void okPressed() {
selectedDesignMenu = getDesignMenu();
super.okPressed();
}
protected Control createDialogArea(Composite parent) {
Composite panel = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = 15;
layout.marginWidth = 15;
layout.numColumns = 2;
layout.verticalSpacing = 9;
panel.setLayout(layout);
addProjectDesignMenu(panel);
applyDialogFont(panel);
getShell().setText("Select Design Menu");
return panel;
}
private void addProjectDesignMenu(Composite parent) {
createLabel(parent, Txt.s("WizardPage.NewProjectMain.Menu.prompt"));
comboDesignMenu = createCombo(parent);
ArrayList<String> items = new ArrayList<String>(desigmMenus.size()+1);
items.add(NONE_ITEM);
for (DesignMenu menu : desigmMenus) {
items.add(menu.getName());
}
comboDesignMenu.setItems((String[])items.toArray(new String[items.size()]));
createLabel(parent, "");
labelDesignMenuDesc = createLabel(parent, getMaximalDescription(NONE_ITEM_DESC));
setSelection(getIndexByName(currentDesignMenuName));
comboDesignMenu.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) {
setDescription(comboDesignMenu.getSelectionIndex());
}
});
}
private int getIndexByName(final String name) {
if (name == null)
return 0;
String items[] = comboDesignMenu.getItems();
for (int i=0; i < items.length; i++) {
if (name.equals(items[i]))
return i;
}
return 0;
}
private void setSelection(int index) {
comboDesignMenu.select(index);
setDescription(index);
}
private void setDescription(int index) {
String description;
switch (index) {
case 0:
selectedDesignMenu = null;
description = NONE_ITEM_DESC;
break;
default:
selectedDesignMenu = desigmMenus.get(index-1);
description = selectedDesignMenu.getDescription();
if (description == null)
description = "";
}
labelDesignMenuDesc.setText(description);
}
private DesignMenu getDesignMenu() {
int index = comboDesignMenu.getSelectionIndex();
switch (index) {
case 0:
return null;
default:
return (DesignMenu)desigmMenus.get(index-1);
}
}
private String getMaximalDescription(String text) {
String res = text;
int max_length = res.length();
for (DesignMenu menu : desigmMenus) {
String descrioption = menu.getDescription();
if ((descrioption != null) && (descrioption.length() > max_length)) {
res = descrioption;
max_length = res.length();
}
}
return res;
}
//-------------------------------------------------------------------------
protected static Label createLabel(Composite parent, String text ) {
Label label = new Label(parent, SWT.NONE);
label.setText(text);
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
data.minimumWidth = label.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
data.widthHint = label.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
label.setLayoutData(data);
return label;
} // createLabel()
protected static Combo createCombo(Composite parent) {
Combo combo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
combo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
return combo;
} // createCombo()
} // class DesignMenuSelectionDialog
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.ui.dialogs;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Shell;
/**
* Dialog to promt list of directories.
*
* Created: 14.02.2006
* @author Lvov Konstantin
*/
public class DirListPromptDialog extends ListPromptDialog {
public DirListPromptDialog( final Shell parentShell, String title) {
super( parentShell
, title
, new IAddAction() {
public String getNewValue() {
DirectoryDialog dialog = new DirectoryDialog(parentShell);
String selectedDir = dialog.open();
return selectedDir;
}
}
);
}
} // class DirListPromptDialog
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.ui.dialogs;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
/**
* Dialog to promt list of files.
*
* Created: 14.02.2006
* @author Lvov Konstantin
*/
public class FileListPromptDialog extends ListPromptDialog {
public FileListPromptDialog( final Shell parentShell, String title) {
this(parentShell, title, null);
}
public FileListPromptDialog( final Shell parentShell
, String title
, final String[] extensions)
{
super( parentShell
, title
, new IAddAction() {
public String getNewValue() {
FileDialog dialog = new FileDialog(parentShell);
dialog.setFilterExtensions(extensions);
String selectedFile = dialog.open();
return selectedFile;
}
}
);
}
} // class FileListPromptDialog
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.ui.dialogs;
import java.util.List;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import com.elphel.vdt.Txt;
/**
* Dialog to promt list of strings.
*
* Created: 13.02.2006
* @author Lvov Konstantin
*/
public class ListPromptDialog extends Dialog {
private String title;
private ListPromptViewer listPromptViewer;
private Button addButton;
private Button removeButton;
private Button upButton;
private Button downButton;
private List<String> listElements = null;
private IAddAction addAction;
public ListPromptDialog(final Shell parentShell, String title) {
this(parentShell, title, new IAddAction() {
public String getNewValue() {
TextPromptDialog d = new TextPromptDialog(parentShell);
d.create();
if(d.open() != Dialog.OK)
return null;
return d.getText();
}
});
}
public ListPromptDialog(Shell parentShell, String title, IAddAction addAction) {
super(parentShell);
this.title = title;
this.addAction = addAction;
}
protected Control createDialogArea(Composite parent) {
Composite panel = (Composite)super.createDialogArea(parent);
GridLayout layout = (GridLayout)panel.getLayout();
layout.numColumns = 2;
layout.makeColumnsEqualWidth = false;
// Create the table of entries
GridData gridData = new GridData( GridData.FILL_BOTH
| GridData.GRAB_HORIZONTAL
| GridData.GRAB_VERTICAL );
gridData.verticalSpan = 4;
listPromptViewer = new ListPromptViewer(panel, listElements);
listPromptViewer.setLayoutData(gridData);
// Create buttons tomodify list of entries
addButton = createButton(panel, Txt.s("Dialog.ListPrompt.Button.Add"));
removeButton = createButton(panel, Txt.s("Dialog.ListPrompt.Button.Remove"));
upButton = createButton(panel, Txt.s("Dialog.ListPrompt.Button.MoveUp"));
downButton = createButton(panel, Txt.s("Dialog.ListPrompt.Button.MoveDown"));
getShell().setText(title);
return panel;
} // createDialogArea()
private Button createButton(Composite parent, String caption) {
Button button = new Button(parent, SWT.PUSH);
button.setText(caption);
GridData gridData = new GridData( GridData.HORIZONTAL_ALIGN_FILL);
button.setLayoutData(gridData);
button.addSelectionListener(buttonListener);
return button;
}
private SelectionListener buttonListener = new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
ListPromptModel.Entry entry = (ListPromptModel.Entry) listPromptViewer.getSelection().getFirstElement();
Object source= e.getSource();
if (source == addButton) {
// Add a entry to the list and refresh the view
String value = addAction.getNewValue();
if (value != null)
listPromptViewer.getModel().addEntry(value);
} else if (source == removeButton) {
// Remove the selection and refresh the view
if (entry != null) {
listPromptViewer.getModel().removeEntry(entry);
}
} else if (source == upButton) {
if (entry != null) {
listPromptViewer.getModel().moveUpEntry(entry);
}
} else if (source == downButton) {
if (entry != null) {
listPromptViewer.getModel().moveDownEntry(entry);
}
}
} // widgetSelected()
};
private List<String> getList() {
return listPromptViewer.getModel().getList();
}
public void setList(List<String> list) {
listElements = list;
}
public List<String> open(List<String> list) {
setList(list);
if (super.open() == Window.OK)
return getList();
else
return listElements;
}
public interface IAddAction {
public String getNewValue();
} // interface IAddAction
} // class ListPromtDialog
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.ui.dialogs;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* Model of list of string entries.
*
* Created: 08.01.2006
* @author Lvov Konstantin
*/
public class ListPromptModel {
private List<Entry> entries = new ArrayList<Entry>();
private List<Listener> listeners = new ArrayList<Listener>();
public ListPromptModel() {}
public ListPromptModel(List<String> initialValues) {
if (initialValues != null) {
for (Iterator i = initialValues.iterator(); i.hasNext(); ) {
String value = (String)i.next();
addEntry(value);
}
}
}
public List<String> getList() {
List<String> list = new ArrayList<String>(entries.size());
for (Iterator i = entries.iterator(); i.hasNext(); ) {
Entry entry = (Entry)i.next();
list.add(entry.getValue());
}
return list;
}
public List<Entry> getEntries() {
return entries;
}
/**
* Add a new list entry
*/
public void addEntry(String value) {
Entry entry = new Entry(value);
entries.add(entry);
for (int i = 0; i < listeners.size(); i++)
((Listener)listeners.get(i)).entryAdded(entry);
}
/**
* Remove specified list entry
*/
public void removeEntry(Entry entry) {
entries.remove(entry);
for (int i = 0; i < listeners.size(); i++)
((Listener)listeners.get(i)).entryRemoved(entry);
}
/**
* Notify listener of changes of specified list entry
*/
public void updateEntry(Entry entry) {
for (int i = 0; i < listeners.size(); i++)
((Listener)listeners.get(i)).entryChanged(entry);
}
public void moveUpEntry(Entry entry) {
int position = entries.indexOf(entry);
if (position > 0) {
removeEntry(entry);
position--;
entries.add(position, entry);
for (int i = 0; i < listeners.size(); i++)
((Listener)listeners.get(i)).entryInserted(entry, position);
}
} // moveUpPort()
public void moveDownEntry(Entry entry) {
int position = entries.indexOf(entry);
if ((position >= 0) && (position != entries.size()-1)) {
removeEntry(entry);
position++;
entries.add(position, entry);
for (int i = 0; i < listeners.size(); i++)
((Listener)listeners.get(i)).entryInserted(entry, position);
}
} // moveDownPort()
public void addListener(Listener l) {
listeners.add(l);
}
public void removeListener(Listener l) {
listeners.remove(l);
}
public void removeAllListener() {
listeners.clear();
}
public interface Listener {
public void entryAdded(Entry entry);
public void entryRemoved(Entry entry);
public void entryChanged(Entry entry);
public void entryInserted(Entry entry, int position);
} // interface Listener
//-------------------------------------------------------------------------
// list promt entry
//-------------------------------------------------------------------------
class Entry {
private String value;
public Entry(String value) {
this.value = value;
}
public void setValue(String value) {
this.value = value;
}
public String getValue() {
return value;
}
public String toString() {
return value;
}
} // class Entry
} // class ListPromptModel
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.ui.dialogs;
import java.util.Arrays;
import java.util.List;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ICellModifier;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import com.elphel.vdt.util.SWTutils;
/**
* Viewer of list of string entries.
*
* Created: 14.02.2006
* @author Lvov Konstantin
*/
public class ListPromptViewer {
private Table table;
private TableViewer viewer;
private ListPromptModel model;
// Set the table column property names
private final String VALUE_COLUMN = "value";
// Set column names of ports table
private String[] tableColumnNames = new String[] {
VALUE_COLUMN
};
private List getColumnNames() {
return Arrays.asList(tableColumnNames);
}
public ListPromptModel getModel() { return model; }
public IStructuredSelection getSelection() {
return ((IStructuredSelection)viewer.getSelection());
}
public ListPromptViewer(Composite parent) {
this(parent, null);
}
public ListPromptViewer(Composite parent, List<String> initialValues) {
// Create the Table
table = createTable(parent);
// Create and setup the TableViewer of ports
viewer = createTableViewer(table);
viewer.setContentProvider(new ListContentProvider());
viewer.setLabelProvider(new ListLabelProvider());
// The input for the table viewer is the instance of ExampleTaskList
model = new ListPromptModel(initialValues);
viewer.setInput(model);
}
public void setLayoutData (Object layoutData) {
table.setLayoutData(layoutData);
}
private Table createTable(Composite parent) {
int style = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL |
SWT.FULL_SELECTION | SWT.HIDE_SELECTION;
Table table = new Table(parent, style);
GridData data= new GridData(GridData.FILL_BOTH);
data.widthHint= 400;
table.setLayoutData(data);
table.setLinesVisible(true);
table.setHeaderVisible(false);
// 1st column with port name
TableColumn column = new TableColumn(table, SWT.LEFT, 0);
// column.setText("Value");
column.setWidth(400);
SWTutils.configureTableResizing(table, new SWTutils.AllColumnResize(table));
return table;
} // createTable()
private TableViewer createTableViewer(Table table) {
TableViewer viewer = new TableViewer(table);
viewer.setUseHashlookup(true);
viewer.setColumnProperties(tableColumnNames);
CellEditor[] editors = new CellEditor[tableColumnNames.length];
// Column 1 : Name (Free text)
TextCellEditor textEditor = new TextCellEditor(table);
editors[0] = textEditor;
// Assign the cell editors to the viewer
viewer.setCellEditors(editors);
// Set the cell modifier for the viewer
viewer.setCellModifier(new CellModifier());
return viewer;
} // createTableViewer()
/**
* Proxy for the ModulePortList providing content for the portsTable.
* It implements the ModulePortList.Listener interface since it must
* register in the ModulePortList
*/
private class ListContentProvider implements IStructuredContentProvider
, ListPromptModel.Listener {
// --------------- IStructuredContentProvider -------------------------
public void inputChanged(Viewer v, Object oldInput, Object newInput) {
if (newInput != null)
((ListPromptModel) newInput).addListener(this);
if (oldInput != null)
((ListPromptModel) oldInput).removeListener(this);
}
public void dispose() {
model.removeListener(this);
}
// Return the ports as an array of Objects
public Object[] getElements(Object parent) {
return model.getEntries().toArray();
}
// --------------- ModulePortList.Listener ----------------------------
public void entryAdded(ListPromptModel.Entry entry) {
viewer.add(entry);
}
public void entryRemoved(ListPromptModel.Entry entry) {
viewer.remove(entry);
}
public void entryChanged(ListPromptModel.Entry entry) {
viewer.update(entry, null);
}
public void entryInserted(ListPromptModel.Entry entry, int position){
viewer.insert(entry, position);
}
} // class ListContentProvider
private class ListLabelProvider extends LabelProvider
implements ITableLabelProvider {
public String getColumnText(Object element, int columnIndex) {
String result = "";
ListPromptModel.Entry entry = (ListPromptModel.Entry) element;
switch (columnIndex) {
case 0:
result = entry.toString();
break;
default :
break;
}
return result;
} // getColumnText()
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
} // class ListLabelProvider
/**
* This class implements an ICellModifier
* An ICellModifier is called when the user modifes a cell in the
* tableViewer
*/
private class CellModifier implements ICellModifier {
public boolean canModify(Object element, String property) {
return true;
}
public Object getValue(Object element, String property) {
// Find the index of the column
int columnIndex = getColumnNames().indexOf(property);
Object result = null;
ListPromptModel.Entry entry = (ListPromptModel.Entry) element;
switch (columnIndex) {
case 0 : // VALUE_COLUMN
result = entry.getValue();
break;
default :
result = "";
}
return result;
} // getValue()
public void modify(Object element, String property, Object value) {
// Find the index of the column
int columnIndex = getColumnNames().indexOf(property);
TableItem item = (TableItem) element;
ListPromptModel.Entry entry = (ListPromptModel.Entry) item.getData();
String valueString;
switch (columnIndex) {
case 0 : // VALUE_COLUMN
valueString = ((String) value).trim();
entry.setValue(valueString);
break;
default :
}
model.updateEntry(entry);
} // modify()
} // class CellModifier
} // class ListPromptViewer
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.ui.dialogs;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import com.elphel.vdt.Txt;
//import com.elphel.vdt.core.verilog.parser.Module;
public class ModuleSelectionDialog extends ElementListSelectionDialog {
public ModuleSelectionDialog(Shell shell) {
this(shell, Txt.s("Dialog.ModuleSelection.Message"));
}
public ModuleSelectionDialog(Shell shell, String message) {
super(shell, new ModuleLabelProvider());
setTitle(Txt.s("Dialog.ModuleSelection.Caption"));
if (message != null)
setMessage(message);
setMultipleSelection(false);
setIgnoreCase(true);
}
private static class ModuleLabelProvider extends LabelProvider {
public String getText(Object element) {
System.out.println("*** Broken ui.dialogs.ModuleSelectionDialog.ModuleLabelProvider() for Verilog parser ***");
return "*** broken ***";
// return element == null ? "": ((Module)element).getName();
}
} // class ToolLabelProvider
/*
public Module open(Module[] modules) {
setElements(modules);
if (super.open() == Window.OK)
return (Module)getResult()[0];
else
return null;
}
*/
} // class ModuleSelectionDialog
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.ui.dialogs;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Shell;
import com.elphel.vdt.core.tools.contexts.PackageContext;
public class PackageLocationDialog {
private DirectoryDialog dialog;
public PackageLocationDialog(Shell parent, int style, PackageContext context) {
dialog = new DirectoryDialog(parent, style);
dialog.setMessage("Specify the location of \""+context.getLabel()+"\"");
}
public String open() {
return dialog.open();
}
} // class PackageLocationDialog
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.ui.dialogs;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class TextPromptDialog extends Dialog {
private Text text;
private String typedString = null;
public TextPromptDialog(Shell parent) {
super(parent);
}
public String getText() {
return typedString;
}
protected void okPressed() {
typedString = text.getText();
super.okPressed();
}
protected Control createDialogArea(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
composite.setLayout(layout);
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
text = new Text(composite, SWT.BORDER);
text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
applyDialogFont(composite);
getShell().setText("Type text");
return composite;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.ui.dialogs;
import java.io.File;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Shell;
import com.elphel.vdt.Txt;
import com.elphel.vdt.core.tools.params.Tool;
import com.elphel.vdt.ui.tools.ToolUI;
public class ToolLocationDialog {
private DirectoryDialog dialog;
public ToolLocationDialog(Shell parent, int style, ToolUI tool) {
this(parent, style, tool.getTool());
}
public ToolLocationDialog(Shell parent, int style, Tool tool) {
dialog = new DirectoryDialog(parent, style);
File file = new File(tool.getExeName());
// String toolExeName = file.getName();
String toolExeName= tool.getIsShell()?("Shell path ("+file.getName()+") to launch tools"):file.getName();
dialog.setMessage( Txt.s("Dialog.ToolLocation.Message"
, new String[]{tool.getLabel(), toolExeName}) );
}
public String open() {
return dialog.open();
}
} // class ToolLocationDialog
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.ui.dialogs;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.dialogs.IconAndMessageDialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
public class VDTErrorDialog extends IconAndMessageDialog {
private static final String NESTING_INDENT = " ";
private static final int MAX_DETAILS_LINES = 15;
private Button detailsButton;
private String title;
private Text text;
private boolean textCreated = false;
private int displayMask = 0xFFFF;
private IStatus status;
/**
* Creates an error dialog. Note that the dialog will have no visual
* representation (no widgets) until it is told to open.
* <p>
* Normally one should use <code>openError</code> to create and open one
* of these. This constructor is useful only if the error object being
* displayed contains child items <it>and </it> you need to specify a mask
* which will be used to filter the displaying of these children.
* </p>
*
* @param parentShell
* the shell under which to create this dialog
* @param dialogTitle
* the title to use for this dialog, or <code>null</code> to
* indicate that the default title should be used
* @param message
* the message to show in this dialog, or <code>null</code> to
* indicate that the error's message should be shown as the
* primary message
* @param status
* the error to show to the user
* @param displayMask
* the mask to use to filter the displaying of child items, as
* per <code>IStatus.matches</code>
* @see org.eclipse.core.runtime.IStatus#matches(int)
*/
public VDTErrorDialog(Shell parentShell,
String dialogTitle,
IStatus status,
int displayMask)
{
super(parentShell);
if(dialogTitle != null)
this.title = dialogTitle;
else
this.title = JFaceResources.getString("Problem_Occurred");
this.message = status.getMessage();
this.status = status;
this.displayMask = displayMask;
setShellStyle(getShellStyle() | SWT.RESIZE);
}
protected void buttonPressed(int id) {
if (id == IDialogConstants.DETAILS_ID) {
// was the details button pressed?
toggleDetailsArea();
} else {
super.buttonPressed(id);
}
}
protected void configureShell(Shell shell) {
super.configureShell(shell);
shell.setText(title);
}
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent,
IDialogConstants.OK_ID,
IDialogConstants.OK_LABEL,
true);
if (shouldShowDetailsButton())
detailsButton = createButton(parent,
IDialogConstants.DETAILS_ID,
IDialogConstants.SHOW_DETAILS_LABEL,
false);
}
protected Control createDialogArea(Composite parent) {
createMessageArea(parent);
// create a composite with standard margins and spacing
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
layout.numColumns = 2;
composite.setLayout(layout);
GridData childData = new GridData(GridData.FILL_BOTH);
childData.horizontalSpan = 2;
composite.setLayoutData(childData);
composite.setFont(parent.getFont());
return composite;
}
/*
* @see IconAndMessageDialog#createDialogAndButtonArea(Composite)
*/
protected void createDialogAndButtonArea(Composite parent) {
super.createDialogAndButtonArea(parent);
if (this.dialogArea instanceof Composite) {
//Create a label if there are no children to force a smaller layout
Composite dialogComposite = (Composite) dialogArea;
if (dialogComposite.getChildren().length == 0)
new Label(dialogComposite, SWT.NULL);
}
}
protected Image getImage() {
if (status != null) {
if (status.getSeverity() == IStatus.WARNING)
return getWarningImage();
if (status.getSeverity() == IStatus.INFO)
return getInfoImage();
}
//If it was not a warning or an error then return the error image
return getErrorImage();
}
private Text createDropDownText(Composite parent) {
// create the text
text = new Text(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
text.setFont(parent.getFont());
// fill the text
populateText(text);
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
data.heightHint = Math.min(MAX_DETAILS_LINES, text.getLineCount()) * text.getLineHeight();
data.horizontalSpan = 2;
text.setLayoutData(data);
text.setFont(parent.getFont());
textCreated = true;
return text;
}
/**
* Extends <code>Window.open()</code>. Opens an error dialog to display
* the error. If you specified a mask to filter the displaying of these
* children, the error dialog will only be displayed if there is at least
* one child status matching the mask.
*/
public int open() {
if (shouldDisplay(status, displayMask))
return super.open();
setReturnCode(OK);
return OK;
}
/**
* Opens an error dialog to display the given error. Use this method if the
* error object being displayed does not contain child items, or if you wish
* to display all such items without filtering.
*
* @param parent
* the parent shell of the dialog, or <code>null</code> if none
* @param dialogTitle
* the title to use for this dialog, or <code>null</code> to
* indicate that the default title should be used
* @param message
* the message to show in this dialog, or <code>null</code> to
* indicate that the error's message should be shown as the
* primary message
* @param status
* the error to show to the user
* @return the code of the button that was pressed that resulted in this
* dialog closing. This will be <code>Dialog.OK</code> if the OK
* button was pressed, or <code>Dialog.CANCEL</code> if this
* dialog's close window decoration or the ESC key was used.
*/
public static int openError(Shell parent,
String dialogTitle,
IStatus status)
{
return openError(parent,
dialogTitle,
status,
IStatus.OK |
IStatus.INFO |
IStatus.WARNING |
IStatus.ERROR);
}
/**
* Opens an error dialog to display the given error. Use this method if the
* error object being displayed contains child items <it>and </it> you wish
* to specify a mask which will be used to filter the displaying of these
* children. The error dialog will only be displayed if there is at least
* one child status matching the mask.
*
* @param parentShell
* the parent shell of the dialog, or <code>null</code> if none
* @param title
* the title to use for this dialog, or <code>null</code> to
* indicate that the default title should be used
* @param message
* the message to show in this dialog, or <code>null</code> to
* indicate that the error's message should be shown as the
* primary message
* @param status
* the error to show to the user
* @param displayMask
* the mask to use to filter the displaying of child items, as
* per <code>IStatus.matches</code>
* @return the code of the button that was pressed that resulted in this
* dialog closing. This will be <code>Dialog.OK</code> if the OK
* button was pressed, or <code>Dialog.CANCEL</code> if this
* dialog's close window decoration or the ESC key was used.
* @see org.eclipse.core.runtime.IStatus#matches(int)
*/
public static int openError(Shell parentShell,
String title,
IStatus status,
int displayMask)
{
VDTErrorDialog dialog = new VDTErrorDialog(parentShell,
title,
status,
displayMask);
return dialog.open();
}
private void populateText(Text textToPopulate) {
populateText(textToPopulate, status, 0, false);
}
/**
* Populate the text with the messages from the given status. Traverse the
* children of the status deeply and also traverse CoreExceptions that appear
* in the status.
* @param textToPopulate the text to populate
* @param buildingStatus the status being displayed
* @param nesting the nesting level (increases one level for each level of children)
* @param includeStatus whether to include the buildingStatus in the display or
* just its children
*/
private void populateText(Text textToPopulate,
IStatus buildingStatus,
int nesting,
boolean includeStatus)
{
if (!buildingStatus.matches(displayMask)) {
return;
}
Throwable t = buildingStatus.getException();
boolean isCoreException= t instanceof CoreException;
boolean incrementNesting= false;
String string = "";
if (includeStatus) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < nesting; i++) {
sb.append(NESTING_INDENT);
}
String message = buildingStatus.getMessage();
sb.append(message);
string += sb.toString();
incrementNesting = true;
}
if (!isCoreException && t != null) {
// print the stacktrace in the text field
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
t.printStackTrace(ps);
ps.flush();
baos.flush();
string += baos.toString();
} catch (IOException e) {
}
incrementNesting = true;
}
String oldString = textToPopulate.getText();
textToPopulate.setText(oldString + string);
if (incrementNesting)
nesting++;
// Look for a nested core exception
if (isCoreException) {
CoreException ce = (CoreException)t;
IStatus eStatus = ce.getStatus();
// Only print the exception message if it is not contained in the parent message
if (message == null || message.indexOf(eStatus.getMessage()) == -1) {
populateText(textToPopulate, eStatus, nesting, true);
}
}
// Look for child status
IStatus[] children = buildingStatus.getChildren();
for (int i = 0; i < children.length; i++) {
populateText(textToPopulate, children[i], nesting, true);
}
}
/**
* Returns whether the given status object should be displayed.
*
* @param status
* a status object
* @param mask
* a mask as per <code>IStatus.matches</code>
* @return <code>true</code> if the given status should be displayed, and
* <code>false</code> otherwise
* @see org.eclipse.core.runtime.IStatus#matches(int)
*/
private static boolean shouldDisplay(IStatus status, int mask) {
IStatus[] children = status.getChildren();
if (children == null || children.length == 0) {
return status.matches(mask);
}
for (int i = 0; i < children.length; i++) {
if (children[i].matches(mask))
return true;
}
return false;
}
/**
* Toggles the unfolding of the details area. This is triggered by the user
* pressing the details button.
*/
private void toggleDetailsArea() {
Point windowSize = getShell().getSize();
Point oldSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
if (textCreated) {
text.dispose();
textCreated = false;
detailsButton.setText(IDialogConstants.SHOW_DETAILS_LABEL);
} else {
text = createDropDownText((Composite) getContents());
detailsButton.setText(IDialogConstants.HIDE_DETAILS_LABEL);
}
Point newSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
getShell()
.setSize(
new Point(windowSize.x, windowSize.y
+ (newSize.y - oldSize.y)));
}
private boolean shouldShowDetailsButton() {
return status.isMultiStatus() || status.getException() != null;
}
}
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.ui.launching;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
import com.elphel.vdt.VDT;
import com.elphel.vdt.core.launching.LaunchCore;
import com.elphel.vdt.ui.tools.ToolUI;
/**
* Common engine for verilog launch configuration tab groups.
*
* Created: 30.12.2005
* @author Lvov Konstantin
*/
public abstract class AbstractToolUITabGroup extends AbstractLaunchConfigurationTabGroup {
private ToolUI toolUI;
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
super.setDefaults(configuration);
try {
LaunchCore.updateLaunchConfiguration(configuration, toolUI.getTool());
} catch (Exception e) {}
LaunchCore.setResource(configuration, VDT.VARIABLE_RESOURCE_NAME);
}
protected abstract ToolUI getToolUI();
/**
* @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String)
*/
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
toolUI = getToolUI();
ILaunchConfigurationTab[] tabs = toolUI.getLaunchConfigurationTabs();
setTabs(tabs);
// ILaunchConfigurationTab[] toolTabs = toolUI.getLaunchConfigurationTabs();
// ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[toolTabs.length+3];
// for (int i=0; i< toolTabs.length; i++)
// tabs[i] = toolTabs[i];
// tabs[toolTabs.length] = new RefreshTab();
// tabs[toolTabs.length+1] = new EnvironmentTab();
// tabs[toolTabs.length+2] = new CommonTab();
// setTabs(tabs);
}
} // class MyToolTabGroup
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.ui.launching;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.ui.ILaunchShortcut;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.ui.model.WorkbenchLabelProvider;
//import com.elphel.vdt.VDTPlugin;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.Txt;
import com.elphel.vdt.core.launching.LaunchCore;
import com.elphel.vdt.core.tools.params.Tool;
import com.elphel.vdt.ui.MessageUI;
public class LaunchShortcut implements ILaunchShortcut {
public void launch(ISelection selection, String mode) {
// TODO Auto-generated method stub
}
public void launch(IEditorPart editor, String mode) {
// TODO Auto-generated method stub
}
public static void launch(Tool tool) {
IProject project = getActiveProject();
try {
LaunchCore.launch(tool, project, project.getName());
} catch (CoreException e) {
MessageUI.error(Txt.s("Action.ToolLounch.Error",
new String[] {tool.getName(), e.getMessage()}),
e);
}
} // launch(Tool tool)
private static IProject getActiveProject(ISelection selection) {
if ((selection != null) && (selection instanceof IStructuredSelection)) {
IStructuredSelection ssel = (IStructuredSelection)selection;
if (!ssel.isEmpty()) {
Object object = ssel.getFirstElement();
if (object instanceof IAdaptable) {
IProject project = (IProject)((IAdaptable)object).getAdapter(IProject.class);
if (project != null && project.isOpen())
return project;
}
}
}
return null;
} // getActiveProject(ISelection)
private static IProject getActiveProject(IEditorPart editor) {
if (editor != null) {
IEditorInput input = editor.getEditorInput();
IResource res = (IResource)input.getAdapter(IResource.class);
return res.getProject();
}
return null;
} // getActiveProject(IEditorPart)
private static IProject getActiveProject(IViewPart view) {
if (view != null) {
ISelection selection = view.getViewSite().getSelectionProvider().getSelection();
return getActiveProject(selection);
}
return null;
} // getActiveProject(IViewPart)
private static IProject getActiveProject(IProject[] projects) {
if ((projects != null) && (projects.length > 0)) {
ElementListSelectionDialog dialog = createProjectSelectionDialog(projects);
if (dialog.open() == Window.OK) {
return (IProject)dialog.getResult()[0];
}
}
return null;
} // getActiveProject(IProject[])
private static IProject getActiveProject() {
IProject project = null;
IWorkbenchWindow wb = VerilogPlugin.getActiveWorkbenchWindow();
if (wb != null) {
IWorkbenchPage page = wb.getActivePage();
if (page != null) {
project = getActiveProject(page.getSelection());
if (project == null)
project = getActiveProject(page.getActiveEditor());
if (project == null)
project = getActiveProject(page.findView(IPageLayout.ID_RES_NAV));
}
}
if (project == null)
project = getActiveProject(VerilogPlugin.getWorkspace().getRoot().getProjects());
return project;
} // getActiveProject()
private static ElementListSelectionDialog createProjectSelectionDialog(IProject[] projects) {
ElementListSelectionDialog dialog = new ElementListSelectionDialog(
VerilogPlugin.getActiveWorkbenchShell()
, WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider()
);
dialog.setTitle(Txt.s("Dialog.ProjectSelection.Caption"));
dialog.setMessage(Txt.s("Dialog.ProjectSelection.Message"));
dialog.setMultipleSelection(false);
dialog.setIgnoreCase(true);
dialog.setElements(projects);
return dialog;
} // createProjectSelectionDialog()
} // class LaunchShortcut
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.ui.launching;
import com.elphel.vdt.ui.tools.ToolUI;
import com.elphel.vdt.ui.tools.ToolUIManager;
/**
* Load verilog tool UI and constructs coresssponding tab group.
*
* Created: 30.12.2005
* @author Lvov Konstantin
*/
public class MyToolTabGroup extends AbstractToolUITabGroup {
protected ToolUI getToolUI() {
return ToolUIManager.getToolUI("com.elphel.vdt.ui.launchType.MyTool");
}
} // class MyToolTabGroup
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.ui.launching;
import org.eclipse.debug.ui.actions.OpenLaunchDialogAction;
import com.elphel.vdt.VDT;
/**
* Opens the launch config dialog on the verilog tools launch group.
*
* Created: 23.12.2005
* @author lion
*/
public class OpenVerilogToolsConfigurations extends OpenLaunchDialogAction {
public OpenVerilogToolsConfigurations() {
super(VDT.ID_VERILOG_TOOLS_LAUNCH_GROUP);
}
} // class OpenVerilogToolsConfigurations
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.ui.launching;
import org.eclipse.debug.ui.actions.AbstractLaunchToolbarAction;
import org.eclipse.jface.action.IAction;
import com.elphel.vdt.VDT;
/**
* This action delegate is responsible for producing the
* Run > Verilog Tools sub menu contents, which includes
* an items to run last tool, favorite tools, and show the
* veroilog tools launch configuration dialog.
*
* Created: 23.12.2005
* @author lion
*/
public class VDTLaunchMenuDelegate extends AbstractLaunchToolbarAction {
/**
* Creates the action delegate
*/
public VDTLaunchMenuDelegate() {
super(VDT.ID_VERILOG_TOOLS_LAUNCH_GROUP);
}
/**
* @see org.eclipse.debug.ui.actions.AbstractLaunchToolbarAction#getOpenDialogAction()
*/
protected IAction getOpenDialogAction() {
IAction action= new OpenVerilogToolsConfigurations();
action.setActionDefinitionId(VDT.COMMAND_OPEN_VERILOG_TOOLS_LAUNCH_DIALOG);
return action;
} // getOpenDialogAction()
public static void openVDTConfigurationDialog() {
IAction action = new VDTLaunchMenuDelegate().getOpenDialogAction();
action.run();
}
} // class VDTLaunchMenuDelegate
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.ui.launching;
import com.elphel.vdt.ui.tools.ToolUI;
import com.elphel.vdt.ui.tools.ToolUIManager;
public class XilinxTool1TabGroup extends AbstractToolUITabGroup {
protected ToolUI getToolUI() {
return ToolUIManager.getToolUI("com.elphel.vdt.ui.launchType.XilinxTool1");
}
} // class XilinxTool1TabGroup
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.ui.options;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import com.elphel.vdt.Txt;
//import com.elphel.vdt.VDTPlugin;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.core.options.OptionsCore;
import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.core.tools.contexts.PackageContext;
import com.elphel.vdt.core.tools.params.ToolException;
import com.elphel.vdt.ui.MessageUI;
public class ContextOptionsDialog extends Dialog {
private String title;
private final Context context;
private IPreferenceStore store;
private OptionsBlock optionsBlock;
private String location;
public ContextOptionsDialog(Shell parent, Context context, IProject project) {
this( parent
, context
, OptionsCore.getPreferenceStore(context, project)
);
location = project.getLocation().toOSString();
}
public ContextOptionsDialog(Shell parent, Context context) {
this(parent, context, VerilogPlugin.getDefault().getPreferenceStore());
if (context instanceof PackageContext)
location = OptionsCore.getPackageLocation((PackageContext)context);
}
@SuppressWarnings("ucd")
public ContextOptionsDialog(Shell parent, Context context, IPreferenceStore store) {
super(parent);
this.context = context;
this.store = store;
OptionsCore.doLoadContextOptions(context, store);
setShellStyle(getShellStyle() | SWT.RESIZE);
}
protected void okPressed() {
optionsBlock.performApply();
OptionsCore.doStoreContextOptions(context, store);
context.setWorkingDirectory(location);
try {
context.buildParams();
} catch (ToolException e) {
MessageUI.error(Txt.s( "Action.Context.Save.Error"
, new String[] {context.getLabel(), e.getMessage()})
, e );
}
super.okPressed();
}
protected Control createDialogArea(Composite parent) {
GridLayout layout = new GridLayout(1, false);
layout.marginHeight = 5;
layout.marginWidth = 5;
layout.verticalSpacing = 0;
layout.horizontalSpacing = 0;
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
Composite panel = new Composite(parent, SWT.NONE);
panel.setLayout(layout);
panel.setLayoutData(gridData);
optionsBlock = new OptionsBlock(panel, context);
// final actions
applyDialogFont(panel);
getShell().setText(getTitle());
return panel;
}
public void setTitle(String title) {
this.title = title;
}
protected String getTitle() {
if ((context != null) && (context.getInputDialogLabel() != null))
title = context.getInputDialogLabel();
if (title == null)
title = "Parameters";
return title;
}
} // class ContextOptionsDialog
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.ui.options;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import com.elphel.vdt.Txt;
//import com.elphel.vdt.VDTPlugin;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.core.options.OptionsCore;
import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.core.tools.params.ToolException;
import com.elphel.vdt.ui.MessageUI;
import com.elphel.vdt.ui.preferences.ScrolledPageContent;
public class ContextOptionsPage extends PreferencePage
implements IWorkbenchPreferencePage
{
private Context context;
private OptionsBlock optionsBlock;
public ContextOptionsPage() {
super();
noDefaultAndApplyButton();
}
public ContextOptionsPage(String title, Context context) {
super(title);
this.context = context;
noDefaultAndApplyButton();
}
public void setContext(Context context) {
this.context = context;
setTitle(context.getLabel());
}
protected Control createContents(Composite parent) {
ScrolledPageContent panel = createScrolledPanel(parent);
optionsBlock = new OptionsBlock(panel.getBody(), context);
return panel;
}
private ScrolledPageContent createScrolledPanel(Composite parent) {
ScrolledPageContent panel = new ScrolledPageContent(parent);
panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
Composite content = panel.getBody();
GridLayout layout = new GridLayout();
content.setLayout(layout);
content.setFont(parent.getFont());
content.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
return panel;
}
public boolean performOk() {
optionsBlock.performApply();
OptionsCore.doStoreContextOptions(context, getPreferenceStore());
try {
context.buildParams();
} catch (ToolException e) {
MessageUI.error(Txt.s( "Action.Context.Save.Error"
, new String[] {context.getLabel(), e.getMessage()})
, e );
}
return super.performOk();
}
public void init(IWorkbench workbench) {
setPreferenceStore(VerilogPlugin.getDefault().getPreferenceStore());
OptionsCore.doLoadContextOptions(context, getPreferenceStore());
}
} // class ContextOptionsPage
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.ui.options;
import org.eclipse.jface.preference.PreferenceNode;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.PlatformUI;
import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.ui.MessageUI;
public class ContextPreferenceNode extends PreferenceNode {
private Context context;
public ContextPreferenceNode(String id, Context context) {
this(id, null, context);
}
public ContextPreferenceNode(String id, ImageDescriptor image, Context context) {
super(id, context.getLabel(), image, ContextOptionsPage.class.getName());
this.context = context;
}
public void createPage() {
try {
ContextOptionsPage page = ContextOptionsPage.class.newInstance();
page.setContext(context);
page.init(PlatformUI.getWorkbench());
setPage(page);
} catch (InstantiationException e) {
MessageUI.error(e);
} catch (IllegalAccessException e) {
MessageUI.error(e);
}
}
} // class PluginPreferenceNode
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.ui.options;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.core.tools.params.ParamGroup;
import com.elphel.vdt.core.tools.params.Parameter;
import com.elphel.vdt.core.tools.params.types.ParamType;
import com.elphel.vdt.core.tools.params.types.ParamTypeBool;
import com.elphel.vdt.core.tools.params.types.ParamTypeEnum;
import com.elphel.vdt.core.tools.params.types.ParamTypeNumber;
import com.elphel.vdt.core.tools.params.types.ParamTypeString;
import com.elphel.vdt.ui.options.component.BoolComponent;
import com.elphel.vdt.ui.options.component.ComboComponent;
import com.elphel.vdt.ui.options.component.Component;
import com.elphel.vdt.ui.options.component.DirComponent;
import com.elphel.vdt.ui.options.component.DirListComponent;
import com.elphel.vdt.ui.options.component.FileComponent;
import com.elphel.vdt.ui.options.component.FileListComponent;
import com.elphel.vdt.ui.options.component.NumberComponent;
import com.elphel.vdt.ui.options.component.StringListComponent;
import com.elphel.vdt.ui.options.component.TextComponent;
/**
* Fills in a panel with controls for editing option of the context.
*
* Created: 17.03.2006
* @author Lvov Konstantin
*/
public class OptionsBlock {
protected final Context context;
private Composite parent;
private Composite tabComposites[];
private ScrolledComposite scrolledComposite[];
private TabItem tabItems[];
private TabFolder tabFolder;
private HashMap<Parameter, Component> components = new HashMap<Parameter, Component>();
private List<Component> activeComponents = new ArrayList<Component>();
private ParameterValueChangeListener changeListener;
public OptionsBlock(Composite parent, Context context) {
this.parent = parent;
this.context = context;
createControl(parent);
for (Parameter param : context.getParams())
param.checkDependentParametersPresents(context.getParams());
}
public void performApply() {
Iterator<Entry<Parameter, Component>> i = components.entrySet().iterator();
while (i.hasNext()) {
Component component = i.next().getValue();
component.performApply();
}
}
private void createControl(Composite parent) {
ParamGroup paramGroups[] = getParamGroups();
tabComposites = new Composite[paramGroups.length];
scrolledComposite = new ScrolledComposite[paramGroups.length];
if (paramGroups.length > 1)
createTabFolder(parent, paramGroups);
else
createGroupPanel(parent, paramGroups[0]);
// add property controls
changeListener = new ParameterValueChangeListener();
addProperties(paramGroups);
for (int i = 0; i < paramGroups.length; i++) {
scrolledComposite[i].setContent(tabComposites[i]);
scrolledComposite[i].setMinSize(tabComposites[i].computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
} // createControl()
private void createGroupPanel(Composite parent, ParamGroup paramGroup) {
ScrolledComposite sc = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
sc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
sc.setExpandHorizontal(true);
sc.setExpandVertical(true);
Group panel = new Group(sc, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
layout.marginHeight = 3;
layout.marginWidth = 3;
layout.verticalSpacing = 0;
layout.horizontalSpacing = 5;
panel.setLayout(layout);
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
panel.setLayoutData(data);
panel.setText(paramGroup.getLabel());
tabComposites[0] = panel;
scrolledComposite[0] = sc;
} // createGroupPanel()
private void createTabFolder(Composite parent, ParamGroup paramGroups[]) {
tabFolder = new TabFolder(parent, SWT.NONE);
tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
tabItems = new TabItem[paramGroups.length];
for(int i = 0; i < paramGroups.length; i++) {
tabItems[i] = new TabItem(tabFolder, SWT.NONE);
tabItems[i].setText(paramGroups[i].getLabel());
}
for (int i = 0; i < paramGroups.length; i++) {
ScrolledComposite sc = new ScrolledComposite(tabFolder, SWT.H_SCROLL | SWT.V_SCROLL);
sc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
sc.setExpandHorizontal(true);
sc.setExpandVertical(true);
GridLayout layout = new GridLayout(2, false);
layout.marginHeight = 3;
layout.marginWidth = 3;
layout.verticalSpacing = 0;
layout.horizontalSpacing = 5;
GridData tabGridData = new GridData(SWT.FILL, SWT.FILL, true, false);
Composite panel = new Composite(sc, SWT.NONE);
panel.setLayout(layout);
panel.setLayoutData(tabGridData);
tabComposites[i] = panel;
scrolledComposite[i] = sc;
tabItems[i].setControl(sc);
}
} // createTabFolders()
protected Component createComponent(Parameter param) {
Component component = null;
ParamType paramType = param.getType();
if (paramType instanceof ParamTypeNumber) {
component = new NumberComponent(param);
} else if (paramType instanceof ParamTypeBool) {
component = new BoolComponent(param);
} else if (paramType instanceof ParamTypeString) {
if (((ParamTypeString)paramType).getKind() == ParamTypeString.KIND.FILE)
component = paramType.isList() ? new FileListComponent(param)
: new FileComponent(param);
else if (((ParamTypeString)paramType).getKind() == ParamTypeString.KIND.DIR)
component = paramType.isList() ? new DirListComponent(param)
: new DirComponent(param);
else
component = paramType.isList() ? new StringListComponent(param)
: new TextComponent(param);
} else if (paramType instanceof ParamTypeEnum) {
component = new ComboComponent(param);
} else {
System.out.println("Param type " + param.getType().getName() + " unknown (not implemented?)");
}
components.put(param, component);
return component;
} // createComponent()
private ParamGroup[] getParamGroups() {
if (context == null)
return new ParamGroup[0];
List<ParamGroup> paramGroups = context.getVisibleParamGroups();
return (ParamGroup[]) paramGroups.toArray(new ParamGroup[paramGroups.size()]);
}
protected void addProperties(ParamGroup paramGroups[]) {
activeComponents.clear();
for (int i = 0; i < paramGroups.length; i++) {
ParamGroup paramGroup = paramGroups[i];
for (Iterator<String> pi = paramGroup.getParams().iterator(); pi.hasNext();) {
String paramID = (String)pi.next();
Parameter param = context.findParam(paramID);
if (!param.isVisible())
continue;
Component component = components.get(param);
if (component == null)
component = createComponent(param);
if (component == null)
continue;
activeComponents.add(component);
// component.setPreferenceStore(store);
component.createControl(tabComposites[i]);
component.setChangeListener(changeListener);
}
}
} // addProperties()
private void disposeControl() {
for (Component component : activeComponents) {
component.suspendControl();
}
Control[] controls = parent.getChildren();
for (int i = 0; i < controls.length; i++) {
if (! controls[i].isDisposed())
controls[i].dispose();
}
} // disposeControl()
private void activateControl(Component selected) {
if (selected != null) {
selected.resumeControl();
selected.setFocus();
}
for (Component component : activeComponents) {
component.resumeControl();
}
if (selected != null) {
selected.setFocus();
}
}
//-------------------------------------------------------------------------
private class ParameterValueChangeListener implements Component.ChangeListener {
public void valueChanged(Component componenet) {
// System.out.println("");
// System.out.println("");
// System.out.println("OptionsBlock.valueChanged: start");
if ((parent != null) && ! parent.isDisposed()) {
parent.setRedraw(false);
int selectedTab = 0;
if (tabFolder != null)
selectedTab = tabFolder.getSelectionIndex();
disposeControl();
createControl(parent);
parent.layout();
if (tabFolder != null) {
tabFolder.setSelection(selectedTab);
}
activateControl(componenet);
parent.setRedraw(true);
}
// System.out.println("OptionsBlock.valueChanged: end");
}
} // class ParameterValueChangeListener
} // class OptionsBlock
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.ui.options;
import org.eclipse.jface.preference.PreferenceNode;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.PlatformUI;
import com.elphel.vdt.core.tools.contexts.PackageContext;
import com.elphel.vdt.ui.MessageUI;
public class PackageInstallNode extends PreferenceNode {
private PackageContext context;
public PackageInstallNode(String id, ImageDescriptor image, PackageContext context) {
super(id, context.getLabel(), image, PackageInstallPage.class.getName());
this.context = context;
}
public void createPage() {
try {
PackageInstallPage page = PackageInstallPage.class.newInstance();
page.setContext(context);
page.init(PlatformUI.getWorkbench());
setPage(page);
} catch (InstantiationException e) {
MessageUI.error(e);
} catch (IllegalAccessException e) {
MessageUI.error(e);
}
}
} // class PackageInstallNode
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in 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.
*
* Eclipse/VDT plug-in 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.ui.options;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
//import com.elphel.vdt.VDTPlugin;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.core.tools.contexts.PackageContext;
import com.elphel.vdt.ui.options.fieldeditor.LabelFieldEditor;
import com.elphel.vdt.ui.options.fieldeditor.PackageLocationFieldEditor;
import com.elphel.vdt.ui.options.fieldeditor.SpacerFieldEditor;
import com.elphel.vdt.ui.preferences.TabbedScrolledFieldEditorPreferencePage;
public class PackageInstallPage extends TabbedScrolledFieldEditorPreferencePage
implements IWorkbenchPreferencePage
{
private PackageContext context;
public PackageInstallPage() {
super(GRID);
noDefaultAndApplyButton();
}
public void setContext(PackageContext context) {
this.context = context;
setTitle(context.getLabel());
}
protected void createFieldEditors() {
addField(new LabelFieldEditor( "Please specify an absolute path to " + context.getLabel()
, getFieldEditorParent()) );
addField(new SpacerFieldEditor(getFieldEditorParent()));
addField(new PackageLocationFieldEditor( context
, getFieldEditorParent())
);
}
// public boolean isValid() {
// checkState();
// return super.isValid();
// }
public void init(IWorkbench workbench) {
setPreferenceStore(VerilogPlugin.getDefault().getPreferenceStore());
}
public static void doClear(PackageContext context) {
IPreferenceStore store = VerilogPlugin.getDefault().getPreferenceStore();
PackageLocationFieldEditor.doClear(context, store);
}
} // class PackageInstallPage
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment