An overview of Unitex/IDELing Java code
Sébastien Paumier
LIGM, Université Paris-Est
paumier@[Link] Tux taken from [Link] 1
Technical details
● use Java 1.6 and Swing
● both Unitex and IDELing have been
developed with Eclipse
● you must set Unitex as a required project for
IDELing:
paumier@[Link] 2
Unitex logic
● user vs system directories
● a directory per language
– you can't have different settings for two
tasks on the same language
● language-specific hard-coded constraints
(semitic mode, char-by-char mode, etc)
● you can work with one language at a time
paumier@[Link] 3
IDELing logic
● a workspace containing projects
● you can have several projects opened at the
same time
● similar projects can use common things
with the dependency system
● you can configure everything
● main goal: fixing all tiny annoying details
from Unitex
paumier@[Link] 4
The challenge
● how to reuse as much code as possible from
Unitex without breaking the previous
logics ?
● [Link] uses [Link] as a library
● introduction of an abstraction layer in
Unitex code so that IDELing can override
some configuration things
paumier@[Link] 5
ConfigModel
● this interface lists methods needed for
obtaining configuration information like:
public File getAlphabet(String language);
● language has the following meaning:
– Unitex: name of the current language
directory
– IDELing: name of the concerned project;
null means the current project
paumier@[Link] 6
ConfigManager
● to access to the actual information, you have
to ask to the ConfigManager:
[Link]().getAlphabet("biniou");
● in Unitex, an instance of ConfigManager is
used
● in IDELing, an instance of
ProjectPreferences is used
paumier@[Link] 7
Configuration storage
● in Unitex:
– a file named Config in the language
directory
– produced by the an instance of
Preferences
– some things are hard-coded
paumier@[Link] 8
Configuration storage
● in IDELing, there are 4 files:
– [Link]: maven configuration file
● [Link]
– project.local_config: user's private preferences (text
editor, last graphs used…)
● [Link]
– [Link]: Unitex preferences (font, …)
● [Link]
– project.versionable_config: project settings to be shared
on SVN (preprocessing config, …)
● [Link]
● top-level object: [Link] that
delegates to the previous classes
paumier@[Link] 9
Configuration storage
● in IDELing, the rule is to save configuration
files on every modification:
public void validateAndSave() {
if (validateConfiguration(project,false)) {
try {
[Link](false);
} catch (IOException e) {
[Link](null,
"Error while saving your project configuration:\n\n"
+[Link](), "Error", JOptionPane.ERROR_MESSAGE);
}
}
}
paumier@[Link] 10
Frames
● InternalFrameManager: allows each
project to have its own JDesktopPane in
IDELing
● FrameFactory objects to manage frames
● TabbableInternalFrame: used to provide
a tab access to frames in IDELing
● KeyedInternalFrame: identify frames with
a special value (often a File)
paumier@[Link] 11
Launching commands
● Launcher: launches command sets, with or
without console logging
● MultiCommands=list of
AbstractMethodCommand objects that can
be:
– Unitex programs: DicoCommand, etc
– other external programs: MvnCommand,
SvnCommand, etc
– method calls: CpCommand, MkdirCommand, etc
paumier@[Link] 12
Launching commands
● ProcessInfoFrame: runs commands and
displays their outputs into a frame
● you can run commands without this frame:
– ExecParameters: allows you to control what
to do with process output and error streams
– you can use it invoking directly
[Link]()
paumier@[Link] 13
Adding a new command
● create the XxxCommand class with methods
to setup the arguments
● make sure to use properly typed arguments
and not evil things like:
public XxxCommand input(String file) {
...
}
● if it is a command used by Unitex, add it in
HelpOnCommandFrame to make it visible in
the help frame
paumier@[Link] 14
Big files
● support for large text files and HTML
concordance files:
– BigTextArea, BigTextList
– BigConcordance, BigConcordanceDiff
● involves file mapping
● because of java bug #4715154, requires the
phantom reference trick as in
[Link]()
paumier@[Link] 15
SVN support
● [Link]: a standalone 1.7 SVN
client with only one .svn directory
● invoked from SvnCommand
● SvnExecutor:
– error message processing with
SvnCommandResult
– getSvnInfos: for each file, creates a
SvnInfo object describing the file status;
used to display information in the tree
paumier@[Link] 16
SVN support
● [Link] returns
a SvnStatusInfo instance that lists:
– unversioned files
– added files
– modified files
– removed files
– files in conflict
● used to refresh the tree and to prepare
commits
paumier@[Link] 17
SVN credentials
● for every svn operation, first try without
credentials
● on failure (the SvpOpResult value is
AUTHENTICATION_REQUIRED), we try again
with [Link]
● credentials are stored by the SVN client in
$HOME/.subversion/auth
paumier@[Link] 18
Ignore/add policy
● by default, ignore ..* *.fst2 *.bin
*.inf target dep build
project.local_config diff
– could be overriden by a manual svn add,
but you don't really want that
● .grf files are forced to be considered as
binary files in order to avoid svn diff3
merging them as text
● don't add any file above the src directory,
except gramlab configuration files
paumier@[Link] 19
$HOME/.gramlab
● global configuration file listing:
– known SVN repositories
– current workspace
– current project in current workspace
– other opened projects in current workspace
svn_repositories: 2
[Link]
[Link]
/home/paumier/my_gramlab
en
fr
paumier@[Link] 20
Maven support
● PomIO is responsible for I/O on [Link]
files
● for each project, a Pom object describes the
GAV and the dependencies, if any
● MvnCommand is used invoke mvn as an
external program:
– under Windows, we launch cmd /c mvn
because one cannot not really launch a
.bat file from a JVM
paumier@[Link] 21
Maven support
● we test if the two required gramlab artifacts
are installed
● if not, we install them:
– App/assembly/[Link]: pom used to
package projects as .zip artifacts
– App/[Link]: gramlab parent pom
● see [Link] methods
paumier@[Link] 22
Packaging a project
● we generate a ant task in the pom file that is
responsible to copy and/or compile files to
be packaged
● as this task may invoke UnitexToolLogger in
a portable way, the maven command has to
be invoked with its path as an argument:
mvn Dunitextoollogger=<path to it> ...
paumier@[Link] 23
Getting dependencies
● the command mvn dependency:unpack
dependencies places dependencies in the
dep directory
● dep is made read-only in order to prevent
users to try editing files in it
● it must be made writeable again before
modifying the project's dependencies
paumier@[Link] 24
Hornet nests
● graph display objects:
– GenericGraphicalZone, GraphicalZone,
TfstGraphicalZone
– GenericGraphBox, GraphBox,
TfstGraphBox
● IDELing workspace management:
– GramlabFrame, ProjectManager,
[Link].*
– workspace tree refresh is a nightmare!
paumier@[Link] 25