Revision 41990

View differences:

tags/org.gvsig.desktop-2.0.81/org.gvsig.desktop/org.gvsig.desktop.framework/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3

  
4
    <modelVersion>4.0.0</modelVersion>
5
    <artifactId>org.gvsig.desktop.framework</artifactId>
6
    <packaging>pom</packaging>
7
    <name>${project.artifactId}</name>
8
    <parent>
9
        <groupId>org.gvsig</groupId>
10
        <artifactId>org.gvsig.desktop</artifactId>
11
        <version>2.0.81</version>
12
    </parent>
13

  
14
    <modules>
15
        <module>org.gvsig.andami</module>
16
        <module>org.gvsig.andami.updater</module>
17
    </modules>
18

  
19
    <description>Contains the launcher and plugin framework used in gvSIG.</description>
20
</project>
21

  
0 22

  
tags/org.gvsig.desktop-2.0.81/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/test/java/org/gvsig/andami/AllTests.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.andami;
25

  
26
import junit.framework.Test;
27
import junit.framework.TestSuite;
28

  
29
public class AllTests {
30

  
31
	public static Test suite() {
32
		TestSuite suite = new TestSuite("Test for com.iver.andami");
33
		//$JUnit-BEGIN$
34

  
35
		//$JUnit-END$
36
		return suite;
37
	}
38

  
39
}
0 40

  
tags/org.gvsig.desktop-2.0.81/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/assembly/gvsig-andami-package.xml
1
<!--
2

  
3
    gvSIG. Desktop Geographic Information System.
4

  
5
    Copyright (C) 2007-2013 gvSIG Association.
6

  
7
    This program is free software; you can redistribute it and/or
8
    modify it under the terms of the GNU General Public License
9
    as published by the Free Software Foundation; either version 3
10
    of the License, or (at your option) any later version.
11

  
12
    This program is distributed in the hope that it will be useful,
13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
    GNU General Public License for more details.
16

  
17
    You should have received a copy of the GNU General Public License
18
    along with this program; if not, write to the Free Software
19
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
    MA  02110-1301, USA.
21

  
22
    For any additional information, do not hesitate to contact us
23
    at info AT gvsig.com, or visit our website www.gvsig.com.
24

  
25
-->
26
<assembly>
27
  <id>gvsig-andami-package</id>
28
  <formats>
29
    <format>zip</format>
30
  </formats>
31
  <baseDirectory>.</baseDirectory>
32
  <!-- 
33
  <includeBaseDirectory>true</includeBaseDirectory>
34
   -->
35
  <files>
36
    <file>
37
      <source>target/${project.artifactId}-${project.version}.jar</source>
38
      <outputDirectory>lib</outputDirectory>
39
    </file>
40
    <file>
41
      <source>src/main/resources/default-log4j/log4j.properties</source>
42
      <outputDirectory>.</outputDirectory>
43
    </file>  
44
  </files>
45
  <fileSets>
46
    <fileSet>
47
      <directory>src/main/resources-application</directory>
48
      <outputDirectory>.</outputDirectory>
49
    </fileSet>
50
    <fileSet>
51
      <directory>src/main/resources/org/gvsig/andami</directory>
52
      <outputDirectory>i18n/andami</outputDirectory>
53
    </fileSet>
54
  </fileSets>
55
  
56
  <dependencySets>
57
    <dependencySet>
58
      <useProjectArtifact>false</useProjectArtifact>
59
      <useTransitiveDependencies>true</useTransitiveDependencies>
60
      <outputDirectory>lib</outputDirectory>
61
    </dependencySet>
62
  </dependencySets>
63

  
64
</assembly>
65

  
0 66

  
tags/org.gvsig.desktop-2.0.81/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/PluginServices.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.andami;
25

  
26
import java.awt.Component;
27
import java.awt.Frame;
28
import java.awt.KeyEventDispatcher;
29
import java.awt.Toolkit;
30
import java.awt.datatransfer.DataFlavor;
31
import java.awt.datatransfer.StringSelection;
32
import java.awt.datatransfer.UnsupportedFlavorException;
33
import java.awt.event.ActionListener;
34
import java.io.File;
35
import java.io.FileInputStream;
36
import java.io.FileNotFoundException;
37
import java.io.FileOutputStream;
38
import java.io.IOException;
39
import java.lang.reflect.InvocationTargetException;
40
import java.util.ArrayList;
41
import java.util.Arrays;
42
import java.util.HashMap;
43
import java.util.Iterator;
44
import java.util.Properties;
45

  
46
import javax.swing.JOptionPane;
47
import javax.swing.KeyStroke;
48
import javax.swing.SwingUtilities;
49
import javax.swing.Timer;
50

  
51
import org.gvsig.andami.messages.NotificationManager;
52
import org.gvsig.andami.plugins.ExclusiveUIExtension;
53
import org.gvsig.andami.plugins.ExtensionDecorator;
54
import org.gvsig.andami.plugins.IExtension;
55
import org.gvsig.andami.plugins.PluginClassLoader;
56
import org.gvsig.andami.preferences.DlgPreferences;
57
import org.gvsig.andami.ui.mdiFrame.MDIFrame;
58
import org.gvsig.andami.ui.mdiFrame.MainFrame;
59
import org.gvsig.andami.ui.mdiManager.MDIManager;
60
import org.gvsig.i18n.Messages;
61
import org.gvsig.tools.ToolsLocator;
62
import org.gvsig.tools.dynobject.DynObject;
63
import org.gvsig.tools.dynobject.DynStruct;
64
import org.gvsig.tools.exception.BaseRuntimeException;
65
import org.gvsig.tools.persistence.PersistenceManager;
66
import org.gvsig.tools.persistence.PersistentState;
67
import org.gvsig.tools.persistence.exception.AddDefinitionException;
68
import org.gvsig.tools.swing.api.ToolsSwingLocator;
69
import org.gvsig.tools.swing.icontheme.IconTheme;
70
import org.gvsig.tools.swing.icontheme.IconThemeManager;
71
import org.gvsig.utils.XMLEntity;
72
import org.gvsig.utils.swing.threads.IMonitorableTask;
73
import org.gvsig.utils.swing.threads.IProgressMonitorIF;
74
import org.gvsig.utils.swing.threads.TaskMonitorTimerListener;
75
import org.gvsig.utils.swing.threads.UndefinedProgressMonitor;
76
import org.slf4j.Logger;
77
import org.slf4j.LoggerFactory;
78

  
79
/**
80
 * Provides services to Plugins. Each plugin has an associated PluginServices
81
 * object, which provides specific services. Main of them: translations,
82
 * logging, access to plugin's resources, background tasks, clipboard access
83
 * and data persistence.
84
 * 
85
 * @author Fernando Gonz�lez Cort�s
86
 */
87
public class PluginServices {
88

  
89
    private static Logger logger =
90
        LoggerFactory.getLogger(PluginServices.class);
91

  
92
    private static String[] arguments;
93

  
94
    private static ExclusiveUIExtension exclusiveUIExtension = null;
95

  
96
    private PluginClassLoader loader;
97

  
98
    private XMLEntity persistentXML;
99

  
100
    private DynObject pluginPersistence = null;
101

  
102
    private String[] alternativeNames = null;
103
    /**
104
     * Creates a new PluginServices objetct.
105
     * 
106
     * @param loader
107
     *            The Plugin's ClassLoader.
108
     */
109
    public PluginServices(PluginClassLoader loader) {
110
        this.loader = loader;
111
    }
112

  
113
    public PluginServices(PluginClassLoader loader, String[] alternativeNames) {
114
    	this(loader);
115
        this.alternativeNames = alternativeNames;
116
    }
117

  
118
    public String[] getAlternativeNames() {
119
    	return this.alternativeNames;
120
    }
121
    
122
    /**
123
     * Returns the message in the current's locale language
124
     * corresponding to the provided translation key.
125
     * The key-message pairs are obtained from the plugin's
126
     * translation files (text_xx.properties files).
127
     * 
128
     * @param key
129
     *            Translation key whose associated message is to be obtained
130
     * 
131
     * @return The message associated with the provided key, in one of the
132
     *         current locale languages, or the key if the translation is not
133
     *         found.
134
     */
135
    public String getText(String key) {
136
        if (key == null)
137
            return null;
138
        String translation = org.gvsig.i18n.Messages.getText(key, false);
139
        if (translation != null)
140
            return translation;
141
        else {
142
            logger.debug("Can't find translation for ''{}'' in plugin ''{}''.",
143
                key,
144
                getPluginName());
145
            return key;
146
        }
147
    }
148

  
149
    /**
150
     * Gets the plugin's classloader.
151
     * 
152
     * @return Returns the loader.
153
     */
154
    public PluginClassLoader getClassLoader() {
155
        return loader;
156
    }
157

  
158
    /**
159
     * Gets the plugin's name
160
     * 
161
     * @return The plugin's name
162
     */
163
    public String getPluginName() {
164
        return loader.getPluginName();
165
    }
166

  
167
    /**
168
     * Gets a reference to the PluginServices object associated with the
169
     * plugin containing the provided class.
170
     * 
171
     * Obtienen una referencia al PluginServices del plugin cuyo nombre se pasa
172
     * como par�metro
173
     * 
174
     * @param pluginClassInstance
175
     *            An instance of a class. This class is contained in a plugin,
176
     *            whose
177
     *            services are to be obtained
178
     * 
179
     * @return The PluginServices object associated to the containing plugin
180
     * 
181
     * @throws RuntimeException
182
     *             If the parameter was not loaded from a plugin
183
     */
184
    public static PluginServices getPluginServices(Object pluginClassInstance) {
185
        try {
186
        	PluginClassLoader loader;
187
    		if( pluginClassInstance instanceof Class ) {
188
    			loader = (PluginClassLoader) ((Class) pluginClassInstance).getClassLoader();
189
    		} else {
190
    			loader = (PluginClassLoader) pluginClassInstance.getClass().getClassLoader();
191
    		}
192
            return Launcher.getPluginServices(loader.getPluginName());
193
        } catch (ClassCastException e) {
194
            /*
195
             * throw new RuntimeException( "Parameter is not a plugin class
196
             * instance");
197
             */
198
            return null;
199
        }
200
    }
201

  
202
    /**
203
     * Gets a reference to the PluginServices object associated with the
204
     * provided plugin.
205
     * 
206
     * @param pluginName
207
     *            Plugin's name whose services are going to be used
208
     * 
209
     * @return The PluginServices object associated with the provided plugin.
210
     */
211
    public static PluginServices getPluginServices(String pluginName) {
212
        return Launcher.getPluginServices(pluginName);
213
    }
214

  
215
    /**
216
     * Gets the window manager (MDIManager).
217
     * 
218
     * @return A reference to the window manager (MDIManager).
219
     */
220
    public static MDIManager getMDIManager() {
221
        return Launcher.getFrame().getMDIManager();
222
    }
223

  
224
    /**
225
     * Gets the application's main frame.
226
     * 
227
     * @return A reference to the application's main window
228
     */
229
    public static MainFrame getMainFrame() {
230
        return Launcher.getFrame();
231
    }
232

  
233
    public static void registerKeyStroke(KeyStroke key, KeyEventDispatcher a) {
234
        GlobalKeyEventDispatcher.getInstance().registerKeyStroke(key, a);
235
    }
236

  
237
    public static void unRegisterKeyStroke(KeyStroke key) {
238
        GlobalKeyEventDispatcher.getInstance().removeKeyStrokeBinding(key);
239
    }
240

  
241
    /**
242
     * Gets the instance of the extension whose class is provided.
243
     * 
244
     * @param extensionClass
245
     *            Class of the extension whose instance is to be returned
246
     * 
247
     * @return The instance of the extension, or null if the instance does
248
     *         not exist.Instancia de la extensi�n o null en caso de que no haya
249
     *         una
250
     */
251
    public static IExtension getExtension(Class extensionClass) {
252
        ExtensionDecorator extAux =
253
            (ExtensionDecorator) Launcher.getClassesExtensions()
254
            .get(extensionClass);
255
        try {
256
            return extAux.getExtension();
257
        } catch (NullPointerException ex) {
258
            return null;
259
        }
260
    }
261

  
262
    /**
263
     * Gets a reference to the Extension Decorator which adds some extra options
264
     * to the basic extension interface.
265
     * 
266
     * @param extensionClass
267
     *            The class of the extension whose decorator is to be returned
268
     * @return The ExtensionDecorator associated with the provided extension,
269
     *         or null if the extension does not exist.
270
     */
271
    public static ExtensionDecorator getDecoratedExtension(Class extensionClass) {
272
        return (ExtensionDecorator) Launcher.getClassesExtensions()
273
        .get(extensionClass);
274
    }
275

  
276
    /**
277
     * Returns an array containing references to all the loaded extensions.
278
     * 
279
     * @return ExtensionDecorator[] An array of ExtensionDecorators (each
280
     *         Decorator contains one extension).
281
     */
282
    public static ExtensionDecorator[] getDecoratedExtensions() {
283
        HashMap map = Launcher.getClassesExtensions();
284
        ExtensionDecorator[] extensions =
285
            (ExtensionDecorator[]) map.values()
286
            .toArray(new ExtensionDecorator[0]);
287
        return extensions;
288
    }
289

  
290
    /**
291
     * Gets an iterator with all the loaded Extensions.
292
     * 
293
     * @return Iterator over the decorated extensions (each member of
294
     *         the iterator is an ExtensionDecorator, which in turn contains
295
     *         one IExtension object).
296
     */
297
    public static Iterator getExtensions() {
298
        return Launcher.getClassesExtensions().values().iterator();
299
    }
300

  
301
    /**
302
     * Returns the message in the current's locale language
303
     * corresponding to the provided translation key.
304
     * The key-message pairs are obtained from the plugin's
305
     * translation files (text_xx.properties files).
306
     * 
307
     * @param pluginObject
308
     *            Any object which was loaded from a plugin
309
     * 
310
     * @param key
311
     *            Translation key whose associated message is to be obtained
312
     * 
313
     * @return The message associated with the provided key, in one of the
314
     *         current locale languages, or the key if the translation is not
315
     *         found.
316
     */
317
    public static String getText(Object pluginObject, String key) {
318
        if (key == null)
319
            return null;
320
        String translation = org.gvsig.i18n.Messages.getText(key, false);
321
        if (translation != null)
322
            return translation;
323
        else {
324
            logger.debug("Can't find translation for ''{}''.", key);
325
            return key;
326
        }
327
    }
328

  
329
    /**
330
     * Sets the XML data which should be saved on disk for this plugin. This
331
     * data can be retrieved on following sessions.
332
     * 
333
     * @param The
334
     *            XMLEntity object containing the data to be persisted.
335
     * 
336
     * @see PluginServices.getPersistentXML()
337
     * @see XMLEntity
338
     */
339
    public void setPersistentXML(XMLEntity entity) {
340
        persistentXML = entity;
341
    }
342

  
343
    /**
344
     * Gets the XML data which was saved on previous sessions for this
345
     * plugins.
346
     * 
347
     * @return An XMLEntity object containing the persisted data
348
     */
349
    public XMLEntity getPersistentXML() {
350
        if (persistentXML == null) {
351
            persistentXML = new XMLEntity();
352
        }
353
        return persistentXML;
354
    }
355

  
356
    /**
357
     * A�ade un listener a un popup menu registrado en el config.xml de alg�n
358
     * plugin
359
     * 
360
     * @param name
361
     *            Nombre del men� contextual
362
     * @param c
363
     *            Componente que desplegar� el men� cuando se haga click con el
364
     *            bot�n derecho
365
     * @param listener
366
     *            Listener que se ejecutar� cuando se seleccione cualquier
367
     *            entrada del men�
368
     * 
369
     * @throws RuntimeException
370
     *             Si la interfaz no est� preparada todav�a. S�lo puede darse
371
     *             durante el arranque
372
     */
373
    public void addPopupMenuListener(String name,
374
        Component c,
375
        ActionListener listener) {
376
        MDIFrame frame = Launcher.getFrame();
377

  
378
        if (frame == null) {
379
            throw new RuntimeException("MDIFrame not loaded yet");
380
        }
381

  
382
        frame.addPopupMenuListener(name, c, listener, loader);
383
    }
384

  
385
    /**
386
     * Gets the plugin's root directory.
387
     * 
388
     * @return A File pointing to the plugin's root directory.
389
     */
390
    public File getPluginDirectory() {
391
        return Launcher.getPluginFolder(this.getPluginName());
392
    }
393

  
394
    /**
395
     * Runs a background task. The events produced on the main frame will
396
     * be inhibited.
397
     * 
398
     * @param r
399
     *            The task to run.
400
     * 
401
     * @return The Thread on which the task is executed.
402
     */
403
    public static Thread backgroundExecution(Runnable r) {
404
        Thread t = new Thread(new RunnableDecorator(r));
405
        t.start();
406

  
407
        return t;
408
    }
409

  
410
    /**
411
     * Runs a backbround task. This task may be monitored and canceled, and
412
     * does not inhibit any event.
413
     * 
414
     * @param task
415
     *            The task to run.
416
     */
417
    public static void cancelableBackgroundExecution(final IMonitorableTask task) {
418
        final org.gvsig.utils.swing.threads.SwingWorker worker =
419
            new org.gvsig.utils.swing.threads.SwingWorker() {
420

  
421
            public Object construct() {
422
                try {
423
                    task.run();
424
                    return task;
425
                } catch (Exception e) {
426
                    NotificationManager.addError(null, e);
427
                }
428
                return null;
429
            }
430

  
431
            /**
432
             * Called on the event dispatching thread (not on the worker
433
             * thread)
434
             * after the <code>construct</code> method has returned.
435
             */
436
            public void finished() {
437
                task.finished();
438
            }
439
        };
440

  
441
        Component mainFrame = (Component) PluginServices.getMainFrame();
442

  
443
        IProgressMonitorIF progressMonitor = null;
444
        String title = getText(null, "PluginServices.Procesando");
445
        progressMonitor =
446
            new UndefinedProgressMonitor((Frame) mainFrame, title);
447
        progressMonitor.setIndeterminated(!task.isDefined());
448
        progressMonitor.setInitialStep(task.getInitialStep());
449
        progressMonitor.setLastStep(task.getFinishStep());
450
        progressMonitor.setCurrentStep(task.getCurrentStep());
451
        progressMonitor.setMainTitleLabel(task.getStatusMessage());
452
        progressMonitor.setNote(task.getNote());
453
        progressMonitor.open();
454
        int delay = 500;
455
        TaskMonitorTimerListener timerListener =
456
            new TaskMonitorTimerListener(progressMonitor, task);
457
        Timer timer = new Timer(delay, timerListener);
458
        timerListener.setTimer(timer);
459
        timer.start();
460

  
461
        worker.start();
462

  
463
    }
464

  
465
    /**
466
     * Closes the application. Cleanly exits from the application:
467
     * terminates all the extensions, then exits.
468
     * 
469
     */
470
    public static void closeApplication() {
471
        Launcher.closeApplication();
472
    }
473

  
474
    /**
475
     * DOCUMENT ME!
476
     * 
477
     * @author Fernando Gonz�lez Cort�s
478
     */
479
    private static class RunnableDecorator implements Runnable {
480

  
481
        private Runnable r;
482

  
483
        /**
484
         * Crea un nuevo RunnableDecorator.
485
         * 
486
         * @param r
487
         *            DOCUMENT ME!
488
         */
489
        public RunnableDecorator(Runnable r) {
490
            this.r = r;
491
        }
492

  
493
        /**
494
         * @see java.lang.Runnable#run()
495
         */
496
        public void run() {
497
            try {
498
                SwingUtilities.invokeAndWait(new Runnable() {
499

  
500
                    public void run() {
501
                        try {
502
                            r.run();
503
                        } catch (RuntimeException e) {
504
                            NotificationManager.addError(Messages.getText("PluginServices.Bug_en_el_codigo"),
505
                                e);
506
                        } catch (Error e) {
507
                            NotificationManager.addError(Messages.getText("PluginServices.Error_grave_de_la_aplicaci�n"),
508
                                e);
509
                        }
510
                    }
511
                });
512
            } catch (InterruptedException e) {
513
                NotificationManager.addWarning(Messages.getText("PluginServices.No_se_pudo_poner_el_reloj_de_arena"),
514
                    e);
515
            } catch (InvocationTargetException e) {
516
                NotificationManager.addWarning(Messages.getText("PluginServices.No_se_pudo_poner_el_reloj_de_arena"),
517
                    e);
518
            }
519
        }
520
    }
521

  
522
    /**
523
     * Gets an array containing the application's startup arguments. <br>
524
     * <br>
525
     * Usually: <code>appName plugins-directory [locale] [other args]</code>
526
     * 
527
     * @return the original arguments that Andami received. (app-name
528
     *         plugins-directory, locale, etc)
529
     */
530
    public static String[] getArguments() {
531
        return arguments;
532
    }
533

  
534
    /**
535
     * Replaces the original Andami arguments with the provided arguments.
536
     * 
537
     * @param arguments
538
     *            An array of String, each element of the array
539
     *            represents one
540
     *            argument.
541
     */
542
    public static void setArguments(String[] arguments) {
543
        PluginServices.arguments = arguments;
544
    }
545

  
546
    /**
547
     * Returns the value of a command line named argument. <br>
548
     * <br>
549
     * The argument format is: <br>
550
     * -{argumentName}={argumentValue} <br>
551
     * <br>
552
     * example: <br>
553
     * ' -language=en '
554
     * 
555
     * @return String The value of the argument
556
     */
557
    public static String getArgumentByName(String name) {
558
        for (int i = 2; i < PluginServices.arguments.length; i++) {
559
        	String arg = PluginServices.arguments[i];
560
        	if( arg != null ) {
561
	            int index = arg.indexOf(name + "=");
562
	            if (index != -1)
563
	                return arg.substring(index
564
	                    + name.length() + 1);
565
        	}
566
        }
567
        return null;
568
    }
569

  
570
    /**
571
     * Gets the logger. The logger is used to register important
572
     * events (errors, etc), which are stored on a file which
573
     * can be checked later.
574
     * 
575
     * @return A Logger object.
576
     * @see Logger object from the Log4j library.
577
     * 
578
     */
579
    public static Logger getLogger() {
580
        return logger;
581
    }
582

  
583
    public static DlgPreferences getDlgPreferences() {
584
        return DlgPreferences.getInstance();
585
    }
586

  
587
    /**
588
     * Stores the provided text data on the clipboard.
589
     * 
590
     * @param data
591
     *            An String containing the data to be stored
592
     *            on the clipboard.
593
     */
594
    public static void putInClipboard(String data) {
595
        StringSelection ss = new StringSelection(data);
596

  
597
        Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, ss);
598
    }
599

  
600
    /**
601
     * Gets text data from the Clipboard, if available.
602
     * 
603
     * @return An String containing the clipboard's data, or <code>null</code>
604
     *         if the data was not available.
605
     */
606
    public static String getFromClipboard() {
607

  
608
        try {
609
            return (String) Toolkit.getDefaultToolkit()
610
            .getSystemClipboard()
611
            .getContents(null)
612
            .getTransferData(DataFlavor.stringFlavor);
613
        } catch (UnsupportedFlavorException e) {
614
            return null;
615
        } catch (IOException e) {
616
            // TODO Auto-generated catch block
617
            return null;
618
        }
619
    }
620

  
621
    /**
622
     * Gets the ExclusiveUIExtension, an special extension which
623
     * will take
624
     * control over the UI and will decide which extensions may be
625
     * enable/disabled or visible/hidden.
626
     * 
627
     * @return If an ExclusiveUIExtension was set, return this extension.
628
     *         Otherwise, return <code>null</code>.
629
     * 
630
     * @see org.gvsig.andami.Launcher#initializeExclusiveUIExtension()
631
     * @see org.gvsig.andami.plugins.IExtension#isEnabled(IExtension extension)
632
     * @see org.gvsig.andami.plugins.IExtension#isVisible(IExtension extension)
633
     */
634
    public static ExclusiveUIExtension getExclusiveUIExtension() {
635
        return PluginServices.exclusiveUIExtension;
636
    }
637

  
638
    /**
639
     * Sets the ExclusiveUIExtension, an special extension which
640
     * will take
641
     * control over the UI and will decide which extensions may be
642
     * enable/disabled or visible/hidden. <br>
643
     * <br>
644
     * The ExclusiveUIExtension is normally set by the following
645
     * Andami startup argument: <br>
646
     * <br>
647
     * <code>ExclusiveUIExtension=ExtensionName</code>
648
     * 
649
     * @see org.gvsig.andami.Launcher#initializeExclusiveUIExtension()
650
     * @see org.gvsig.andami.plugins.IExtension#isEnabled(IExtension extension)
651
     * @see org.gvsig.andami.plugins.IExtension#isVisible(IExtension extension)
652
     */
653
    public static void setExclusiveUIExtension(ExclusiveUIExtension extension) {
654
        PluginServices.exclusiveUIExtension = extension;
655
    }
656

  
657
    public static void addLoaders(ArrayList classLoaders) {
658
        PluginClassLoader.addLoaders(classLoaders);
659
    }
660

  
661
    /**
662
     * @deprecated use ToolsSwingLocator.getIconThemeManager()
663
     */
664
    public static IconThemeManager getIconThemeManager() {
665
    	return ToolsSwingLocator.getIconThemeManager();
666
    }
667

  
668
    /**
669
     * @deprecated use  ToolsSwingLocator.getIconThemeManager().getCurrent()
670
     */
671
    public static IconTheme getIconTheme() {
672
    	return getIconThemeManager().getCurrent(); 
673
    }
674

  
675
    /**
676
     * Try to detect if the application is running in a development
677
     * environment. <br>
678
     * This look for <b>.project</b> and <b>.classpath</b> files in the starts
679
     * path of the application.
680
     * 
681
     * @return true if <b>.project</b> and <b>.classpath</b> are in the
682
     *         development path
683
     */
684
    public static boolean runningInDevelopment() {
685
        String andamiPath;
686
        Properties props = System.getProperties();
687

  
688
        try {
689
            try {
690
                andamiPath =
691
                    (new File(Launcher.class.getResource(".").getFile()
692
                        + File.separator + ".." + File.separator + ".."
693
                        + File.separator + ".." + File.separator + "..")).getCanonicalPath();
694
            } catch (IOException e) {
695
                andamiPath =
696
                    (new File(Launcher.class.getResource(".").getFile()
697
                        + File.separator + ".." + File.separator + ".."
698
                        + File.separator + ".." + File.separator + "..")).getAbsolutePath();
699
            }
700
        } catch (Exception e1) {
701
            andamiPath = (String) props.get("user.dir");
702
        }
703

  
704
        File andamiJar = new File(andamiPath + File.separator + "andami.jar");
705
        if (!andamiJar.exists())
706
            return false;
707
        File projectFile = new File(andamiPath + File.separator + ".project");
708
        File classpathFile =
709
            new File(andamiPath + File.separator + ".classpath");
710
        return projectFile.exists() && classpathFile.exists();
711

  
712
    }
713

  
714
    public PluginsManager getManager() {
715
        return PluginsLocator.getManager();
716
    }
717

  
718
    private String[] getAllPluginNames() {
719
    	String[] names = new String[this.alternativeNames.length+1];
720
    	names[0] = this.getPluginName();
721
    	for( int n=0; n<this.alternativeNames.length; n++ ) {
722
        	names[n+1] = this.alternativeNames[n];
723
    	}
724
    	return names;
725
    }
726
    
727
    public DynObject getPluginProperties() {
728
        if (this.pluginPersistence == null) {
729
            PersistenceManager manager = ToolsLocator.getPersistenceManager();
730
            DynStruct dynStruct = manager.getDynObjectDefinition(getPluginName());
731
            if ( dynStruct == null) {
732
                File persistenceDefinitionFile =
733
                    new File(this.getPluginDirectory(), "plugin-persistence.def");
734
                String[] names = getAllPluginNames(); 
735
                for( int i=0; i<names.length ; i++ ) {
736
	                try {
737
	                    dynStruct = manager.addDefinition(DynObject.class,
738
	                        names[i],
739
	                        new FileInputStream(persistenceDefinitionFile),
740
	                        this.getClassLoader(),
741
	                        null,
742
	                        null);
743
	                    break;
744
	                } catch (FileNotFoundException e) {
745
	                    throw new PluginPersistenceNeedDefinitionException(this.getPluginName(), e);
746
	                } catch (AddDefinitionException e) {
747
	                	if( i+1 >= names.length ) { // Si ya no hay mas nombres peta
748
	                		throw new PluginPersistenceAddDefinitionException(this.getPluginName(), e);
749
	                	}
750
	                }
751
                }
752
            }
753

  
754
            File persistenceFile = getPluginPersistenceFile();
755
            if (persistenceFile.exists()) {
756
                PersistentState state;
757

  
758
                try {
759
                    state = manager.loadState(new FileInputStream(persistenceFile));
760
                    pluginPersistence = (DynObject) manager.create(state);
761
                } catch (Exception e) {
762
                	
763
                    logger.info("Can't retrieve persistent values from plugin "+
764
                    getPluginName(), e);
765
                	JOptionPane.showMessageDialog(
766
                			(Component) PluginServices.getMainFrame(),
767
                			Messages.getText("_Unable_to_read_persistence_for_plugin")
768
                			+ ": " + getPluginName() + "\n" +
769
                			Messages.getText("_Perhaps_saved_data_refers_to_missing_plugin"),
770
                			Messages.getText("_Persistence"),
771
                			JOptionPane.WARNING_MESSAGE);
772
                }
773
            }
774
            if (this.pluginPersistence == null) {
775
                logger.info("Creating default values for plugin persistence ("+this.getPluginName()+").");
776
                this.pluginPersistence =
777
                    ToolsLocator.getDynObjectManager()
778
                    .createDynObject(dynStruct); 
779
            }
780
        }
781
        return pluginPersistence;
782
    }
783

  
784
    public void savePluginProperties() {
785
        if (this.pluginPersistence == null) {
786
            return;
787
        }
788
        PersistenceManager manager = ToolsLocator.getPersistenceManager();
789
		File persistenceFile = getPluginPersistenceFile();
790
        PersistentState state;
791
        FileOutputStream fos;
792
        try {
793
            state = manager.getState(pluginPersistence);
794
            manager.saveState(state, new FileOutputStream(persistenceFile));
795
        } catch (Exception e) {
796
            throw new PluginSaveDataException(this.getPluginName(), e);
797
        }
798

  
799

  
800
    }
801

  
802
	/**
803
	 * Returns the plugin persistence file.
804
	 * 
805
	 * @return the plugin persistence file
806
	 */
807
	private File getPluginPersistenceFile() {
808
		return new File(getPluginHomeFolder(), "plugin-persistence.dat");
809
	}
810

  
811
	/**
812
	 * Returns the folder where the plugin stores its resources. That folder
813
	 * will be usually a subfolder into the application folder in the user home
814
	 * folder.
815
	 * 
816
	 * @return the folder where the plugin stores its resources
817
	 */
818
	public File getPluginHomeFolder() {
819
		File persistenceFolder = new File(Launcher.getAppHomeDir()
820
				+ File.separator + "plugins" + File.separator
821
				+ this.getPluginName());
822

  
823
		if (!persistenceFolder.exists()) {
824
			persistenceFolder.mkdirs();
825
		}
826

  
827
		return persistenceFolder;
828
	}
829

  
830
    public class PluginPersistenceNeedDefinitionException extends
831
    BaseRuntimeException {
832

  
833
        /**
834
         * 
835
         */
836
        private static final long serialVersionUID = -2036279527440882712L;
837

  
838
        PluginPersistenceNeedDefinitionException(String name, Throwable cause) {
839
            super("Can't load persistence definition of plugin %(name).",
840
                "_cant_load_persistence_definition_of_plugin_XnameX",
841
                serialVersionUID);
842
            initCause(cause);
843
            setValue("name", name);
844
        }
845
    }
846

  
847
    public class PluginPersistenceAddDefinitionException extends
848
    BaseRuntimeException {
849

  
850
        /**
851
         * 
852
         */
853
        private static final long serialVersionUID = 2227722796640780361L;
854

  
855
        PluginPersistenceAddDefinitionException(String name, Throwable cause) {
856
            super("Can't add persistence definition of plugin %(name).",
857
                "_cant_add_persistence_definition_of_plugin_XnameX",
858
                serialVersionUID);
859
            this.initCause(cause);
860
            setValue("name", name);
861
        }
862
    }
863

  
864
    public class PluginLoadDataException extends
865
    BaseRuntimeException {
866

  
867
        /**
868
         * 
869
         */
870
        private static final long serialVersionUID = 1168749231143949111L;
871

  
872
        PluginLoadDataException(String name) {
873
            super("Can't load data of plugin %(name).",
874
                "_cant_load_data_of_plugin_XnameX",
875
                serialVersionUID);
876
            setValue("name", name);
877
        }
878
    }
879

  
880
    public class PluginSaveDataException extends
881
    BaseRuntimeException {
882

  
883
        /**
884
         * 
885
         */
886
        private static final long serialVersionUID = 4893241183911774542L;
887
        private final static String MESSAGE_FORMAT = "Can't save data of plugin %(name).";
888
        private final static String MESSAGE_KEY = "_cant_save_data_of_plugin_XnameX";
889

  
890
        PluginSaveDataException(String name) {
891
            super(MESSAGE_FORMAT,
892
                MESSAGE_KEY,
893
                serialVersionUID);
894
            setValue("name", name);
895
        }
896

  
897
        public PluginSaveDataException(String name, Throwable cause) {
898
            super(MESSAGE_FORMAT, cause, MESSAGE_KEY, serialVersionUID);
899
            setValue("name", name);
900

  
901
        }
902
    }
903
    
904
    @Override
905
    public String toString() {
906
        return super.toString()+" "+this.getPluginName();
907
    }
908
    
909
    public void addDependencyWithPlugin(PluginServices otherPlugin) {
910
        this.getClassLoader().addPluginClassLoader(otherPlugin.getClassLoader());
911
    }
912
}
0 913

  
tags/org.gvsig.desktop-2.0.81/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/persistence/generate/PropertyDescriptor.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
/*
25
 * This class was automatically generated with 
26
 * <a href="http://www.castor.org">Castor 0.9.5.3</a>, using an XML
27
 * Schema.
28
 * $Id: PropertyDescriptor.java 29593 2009-06-29 15:54:31Z jpiera $
29
 */
30

  
31
package org.gvsig.andami.persistence.generate;
32

  
33
  //---------------------------------/
34
 //- Imported classes and packages -/
35
//---------------------------------/
36

  
37
import org.exolab.castor.xml.validators.NameValidator;
38
import org.exolab.castor.xml.validators.StringValidator;
39

  
40
/**
41
 * Class PropertyDescriptor.
42
 * 
43
 * @version $Revision: 29593 $ $Date: 2009-06-29 17:54:31 +0200 (lun, 29 jun 2009) $
44
 */
45
public class PropertyDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl {
46

  
47

  
48
      //--------------------------/
49
     //- Class/Member Variables -/
50
    //--------------------------/
51

  
52
    /**
53
     * Field nsPrefix
54
     */
55
    private java.lang.String nsPrefix;
56

  
57
    /**
58
     * Field nsURI
59
     */
60
    private java.lang.String nsURI;
61

  
62
    /**
63
     * Field xmlName
64
     */
65
    private java.lang.String xmlName;
66

  
67
    /**
68
     * Field identity
69
     */
70
    private org.exolab.castor.xml.XMLFieldDescriptor identity;
71

  
72

  
73
      //----------------/
74
     //- Constructors -/
75
    //----------------/
76

  
77
    public PropertyDescriptor() {
78
        super();
79
        xmlName = "property";
80
        org.exolab.castor.xml.util.XMLFieldDescriptorImpl  desc           = null;
81
        org.exolab.castor.xml.XMLFieldHandler              handler        = null;
82
        org.exolab.castor.xml.FieldValidator               fieldValidator = null;
83
        //-- initialize attribute descriptors
84
        
85
        //-- _name
86
        desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_name", "name", org.exolab.castor.xml.NodeType.Attribute);
87
        handler = (new org.exolab.castor.xml.XMLFieldHandler() {
88
            public java.lang.Object getValue( java.lang.Object object ) 
89
                throws IllegalStateException
90
            {
91
                Property target = (Property) object;
92
                return target.getName();
93
            }
94
            public void setValue( java.lang.Object object, java.lang.Object value) 
95
                throws IllegalStateException, IllegalArgumentException
96
            {
97
                try {
98
                    Property target = (Property) object;
99
                    target.setName( (java.lang.String) value);
100
                }
101
                catch (java.lang.Exception ex) {
102
                    throw new IllegalStateException(ex.toString());
103
                }
104
            }
105
            public java.lang.Object newInstance( java.lang.Object parent ) {
106
                return new java.lang.String();
107
            }
108
        } );
109
        desc.setHandler(handler);
110
        desc.setRequired(true);
111
        addFieldDescriptor(desc);
112
        
113
        //-- validation code for: _name
114
        fieldValidator = new org.exolab.castor.xml.FieldValidator();
115
        fieldValidator.setMinOccurs(1);
116
        { //-- local scope
117
            NameValidator typeValidator = new NameValidator(NameValidator.NMTOKEN);
118
            fieldValidator.setValidator(typeValidator);
119
        }
120
        desc.setValidator(fieldValidator);
121
        //-- _value
122
        desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_value", "value", org.exolab.castor.xml.NodeType.Attribute);
123
        desc.setImmutable(true);
124
        handler = (new org.exolab.castor.xml.XMLFieldHandler() {
125
            public java.lang.Object getValue( java.lang.Object object ) 
126
                throws IllegalStateException
127
            {
128
                Property target = (Property) object;
129
                return target.getValue();
130
            }
131
            public void setValue( java.lang.Object object, java.lang.Object value) 
132
                throws IllegalStateException, IllegalArgumentException
133
            {
134
                try {
135
                    Property target = (Property) object;
136
                    target.setValue( (java.lang.String) value);
137
                }
138
                catch (java.lang.Exception ex) {
139
                    throw new IllegalStateException(ex.toString());
140
                }
141
            }
142
            public java.lang.Object newInstance( java.lang.Object parent ) {
143
                return null;
144
            }
145
        } );
146
        desc.setHandler(handler);
147
        desc.setRequired(true);
148
        addFieldDescriptor(desc);
149
        
150
        //-- validation code for: _value
151
        fieldValidator = new org.exolab.castor.xml.FieldValidator();
152
        fieldValidator.setMinOccurs(1);
153
        { //-- local scope
154
            StringValidator typeValidator = new StringValidator();
155
            typeValidator.setWhiteSpace("preserve");
156
            fieldValidator.setValidator(typeValidator);
157
        }
158
        desc.setValidator(fieldValidator);
159
        //-- initialize element descriptors
160
        
161
    } //-- com.iver.andami.persistence.generate.PropertyDescriptor()
162

  
163

  
164
      //-----------/
165
     //- Methods -/
166
    //-----------/
167

  
168
    /**
169
     * Method getAccessMode
170
     */
171
    public org.exolab.castor.mapping.AccessMode getAccessMode()
172
    {
173
        return null;
174
    } //-- org.exolab.castor.mapping.AccessMode getAccessMode() 
175

  
176
    /**
177
     * Method getExtends
178
     */
179
    public org.exolab.castor.mapping.ClassDescriptor getExtends()
180
    {
181
        return null;
182
    } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() 
183

  
184
    /**
185
     * Method getIdentity
186
     */
187
    public org.exolab.castor.mapping.FieldDescriptor getIdentity()
188
    {
189
        return identity;
190
    } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() 
191

  
192
    /**
193
     * Method getJavaClass
194
     */
195
    public java.lang.Class getJavaClass()
196
    {
197
        return org.gvsig.andami.persistence.generate.Property.class;
198
    } //-- java.lang.Class getJavaClass() 
199

  
200
    /**
201
     * Method getNameSpacePrefix
202
     */
203
    public java.lang.String getNameSpacePrefix()
204
    {
205
        return nsPrefix;
206
    } //-- java.lang.String getNameSpacePrefix() 
207

  
208
    /**
209
     * Method getNameSpaceURI
210
     */
211
    public java.lang.String getNameSpaceURI()
212
    {
213
        return nsURI;
214
    } //-- java.lang.String getNameSpaceURI() 
215

  
216
    /**
217
     * Method getValidator
218
     */
219
    public org.exolab.castor.xml.TypeValidator getValidator()
220
    {
221
        return this;
222
    } //-- org.exolab.castor.xml.TypeValidator getValidator() 
223

  
224
    /**
225
     * Method getXMLName
226
     */
227
    public java.lang.String getXMLName()
228
    {
229
        return xmlName;
230
    } //-- java.lang.String getXMLName() 
231

  
232
}
0 233

  
tags/org.gvsig.desktop-2.0.81/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/persistence/generate/PluginsStatusDescriptor.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
/*
25
 * This class was automatically generated with 
26
 * <a href="http://www.castor.org">Castor 0.9.5.3</a>, using an XML
27
 * Schema.
28
 * $Id: PluginsStatusDescriptor.java 29593 2009-06-29 15:54:31Z jpiera $
29
 */
30

  
31
package org.gvsig.andami.persistence.generate;
32

  
33
  //---------------------------------/
34
 //- Imported classes and packages -/
35
//---------------------------------/
36

  
37

  
38
/**
39
 * Class PluginsStatusDescriptor.
40
 * 
41
 * @version $Revision: 29593 $ $Date: 2009-06-29 17:54:31 +0200 (lun, 29 jun 2009) $
42
 */
43
public class PluginsStatusDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl {
44

  
45

  
46
      //--------------------------/
47
     //- Class/Member Variables -/
48
    //--------------------------/
49

  
50
    /**
51
     * Field nsPrefix
52
     */
53
    private java.lang.String nsPrefix;
54

  
55
    /**
56
     * Field nsURI
57
     */
58
    private java.lang.String nsURI;
59

  
60
    /**
61
     * Field xmlName
62
     */
63
    private java.lang.String xmlName;
64

  
65
    /**
66
     * Field identity
67
     */
68
    private org.exolab.castor.xml.XMLFieldDescriptor identity;
69

  
70

  
71
      //----------------/
72
     //- Constructors -/
73
    //----------------/
74

  
75
    public PluginsStatusDescriptor() {
76
        super();
77
        xmlName = "plugins-status";
78
        
79
        //-- set grouping compositor
80
        setCompositorAsSequence();
81
        org.exolab.castor.xml.util.XMLFieldDescriptorImpl  desc           = null;
82
        org.exolab.castor.xml.XMLFieldHandler              handler        = null;
83
        org.exolab.castor.xml.FieldValidator               fieldValidator = null;
84
        //-- initialize attribute descriptors
85
        
86
        //-- initialize element descriptors
87
        
88
        //-- _plugin
89
        desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.gvsig.andami.persistence.generate.Plugin.class, "_plugin", "plugin", org.exolab.castor.xml.NodeType.Element);
90
        handler = (new org.exolab.castor.xml.XMLFieldHandler() {
91
            public java.lang.Object getValue( java.lang.Object object ) 
92
                throws IllegalStateException
93
            {
94
                PluginsStatus target = (PluginsStatus) object;
95
                return target.getPlugin();
96
            }
97
            public void setValue( java.lang.Object object, java.lang.Object value) 
98
                throws IllegalStateException, IllegalArgumentException
99
            {
100
                try {
101
                    PluginsStatus target = (PluginsStatus) object;
102
                    target.setPlugin( (org.gvsig.andami.persistence.generate.Plugin) value);
103
                }
104
                catch (java.lang.Exception ex) {
105
                    throw new IllegalStateException(ex.toString());
106
                }
107
            }
108
            public java.lang.Object newInstance( java.lang.Object parent ) {
109
                return new org.gvsig.andami.persistence.generate.Plugin();
110
            }
111
        } );
112
        desc.setHandler(handler);
113
        desc.setRequired(true);
114
        desc.setMultivalued(false);
115
        addFieldDescriptor(desc);
116
        
117
        //-- validation code for: _plugin
118
        fieldValidator = new org.exolab.castor.xml.FieldValidator();
119
        fieldValidator.setMinOccurs(1);
120
        { //-- local scope
121
        }
122
        desc.setValidator(fieldValidator);
123
        //-- _toolBars
124
        desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.gvsig.andami.persistence.generate.ToolBars.class, "_toolBars", "tool-bars", org.exolab.castor.xml.NodeType.Element);
125
        handler = (new org.exolab.castor.xml.XMLFieldHandler() {
126
            public java.lang.Object getValue( java.lang.Object object ) 
127
                throws IllegalStateException
128
            {
129
                PluginsStatus target = (PluginsStatus) object;
130
                return target.getToolBars();
131
            }
132
            public void setValue( java.lang.Object object, java.lang.Object value) 
133
                throws IllegalStateException, IllegalArgumentException
134
            {
135
                try {
136
                    PluginsStatus target = (PluginsStatus) object;
137
                    target.setToolBars( (org.gvsig.andami.persistence.generate.ToolBars) value);
138
                }
139
                catch (java.lang.Exception ex) {
140
                    throw new IllegalStateException(ex.toString());
141
                }
142
            }
143
            public java.lang.Object newInstance( java.lang.Object parent ) {
144
                return new org.gvsig.andami.persistence.generate.ToolBars();
145
            }
146
        } );
147
        desc.setHandler(handler);
148
        desc.setRequired(true);
149
        desc.setMultivalued(false);
150
        addFieldDescriptor(desc);
151
        
152
        //-- validation code for: _toolBars
153
        fieldValidator = new org.exolab.castor.xml.FieldValidator();
154
        fieldValidator.setMinOccurs(1);
155
        { //-- local scope
156
        }
157
        desc.setValidator(fieldValidator);
158
    } //-- com.iver.andami.persistence.generate.PluginsStatusDescriptor()
159

  
160

  
161
      //-----------/
162
     //- Methods -/
163
    //-----------/
164

  
165
    /**
166
     * Method getAccessMode
167
     */
168
    public org.exolab.castor.mapping.AccessMode getAccessMode()
169
    {
170
        return null;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff