KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jawe > JaWE


1 /* JaWE.java
2  *
3  * Authors:
4  * Stefanovic Nenad chupo@iis.ns.ac.yu
5  * Bojanic Sasa sasaboy@neobee.net
6  * Puskas Vladimir vpuskas@eunet.yu
7  * Pilipovic Goran zboniek@uns.ac.yu
8  *
9  */

10
11 package org.enhydra.jawe;
12
13 import java.util.*;
14 import java.io.*;
15 import java.net.*;
16 import java.awt.*;
17 import java.awt.event.*;
18 import javax.swing.*;
19
20 import org.enhydra.jawe.misc.*;
21 import org.enhydra.jawe.ldap.*;
22 import org.enhydra.jawe.misc.*;
23 import org.enhydra.jawe.xml.*;
24 import org.enhydra.jawe.xml.elements.*;
25
26 /**
27  * This is the main class of application. It is made singleton, and
28  * it's main funcionality is to provide some methods to access the
29  * process editor class.
30  */

31 public final class JaWE implements XMLElementChangeListener {
32    /** The one and only instance of JaWE.*/
33    private static JaWE jawe;
34
35    // Application Icon. From resource file.
36
public static ImageIcon appIcon;
37    // Application Icon. From resource file.
38
private static ImageIcon logoIcon;
39    // Application Title and other stuff. From resource file.
40
private static String JavaDoc appTitle;
41
42    // first we have to create XMLInterface - it is used in the next static
43
// field initialization (mandatoryConfirmanceClass initialization)
44
private static XMLInterface xmlInterface=new XML();
45
46    public static XMLInterface getXMLInterface () {
47       return xmlInterface;
48    }
49
50    // some start parameters
51
private static String JavaDoc mandatoryConformanceClass=
52       JaWEConfig.getInstance().getMandatoryConformanceClass();
53
54    private static final int recentFileListSize=
55       JaWEConfig.getInstance().getRecentFileListSize();
56
57
58    /**
59     * Checks if java version is >= 1.4, sets application title and icon, as
60     * well as logo icon.
61     */

62    static {
63       try {
64          String JavaDoc vers = System.getProperty("java.version");
65          if (vers.compareTo("1.4") < 0) {
66             System.out.println("!!!WARNING: JaWE must be run with a " +
67                                   "1.4 or higher version VM!!!");
68             System.exit(1);
69          }
70
71
72          // application title
73
appTitle = ResourceManager.getLanguageDependentString("Title");
74
75          // Logo
76
URL url = ResourceManager.getResource("Logo");
77          if (url != null) logoIcon = new ImageIcon(url);
78
79          // Icon
80
url = ResourceManager.getResource("Icon");
81          if (url != null) appIcon = new ImageIcon(url);
82
83          // setting the port view sizes similar to activities
84
JaWEPortView.setPortSize(java.lang.Math.min(JaWEConfig.getInstance().getActivityWidth(),
85                                                      JaWEConfig.getInstance().getActivityHeight())-10);
86
87          // creating USER_HOME/.JaWE directory if it doesn't exist
88
File ujdir=new File(JaWEConstants.JAWE_USER_HOME);
89          if (!ujdir.exists()) {
90             try {
91                ujdir.mkdir();
92             } catch (Exception JavaDoc exc) {};
93          }
94
95          ((XML)xmlInterface).setFileLockingStatus(JaWEConfig.getInstance().getFileLockingStatus());
96
97       } catch (Throwable JavaDoc t) {
98          System.err.println("uncaught exception: " + t);
99          t.printStackTrace();
100       }
101    }
102
103    /**
104     * Returns one and only instance of JaWE.
105     * @return The instance of JaWE class.
106     */

107    public static JaWE getInstance () {
108       if (JaWE.jawe==null) {
109          JaWE.jawe=new JaWE();
110          JaWE.jawe.init(null);
111       }
112       return jawe;
113    }
114
115    /**
116     * Returns the application title.
117     */

118    public static String JavaDoc getAppTitle () {
119       return appTitle;
120    }
121
122    /**
123     * Returns the logo icon.
124     */

125    public static ImageIcon getLogoIcon () {
126       return logoIcon;
127    }
128
129    /**
130     * Returns the application icon.
131     */

132    public static ImageIcon getAppIcon () {
133       return appIcon;
134    }
135
136    /** The main frame of application. */
137    private JFrame mainFrame;
138
139    /**
140     * The instance of process editor. It is the only instance, because this
141     * is a single-document application.
142     */

143    private PackageEditor packageEditor;
144
145    /* Filename for the current document. Null if never saved or opened. */
146    private String JavaDoc filename;
147
148    /* True if document was modified since last save. */
149    private boolean modified=false;
150
151    private Action save;
152    private Action exit;
153
154    private JMenu recentFilesMenu;
155
156    /**
157     * Construct JaWE.
158     */

159    private JaWE () {
160       mainFrame = new JFrame();
161       mainFrame.setBackground(Color.lightGray);
162       mainFrame.getContentPane().setLayout(new BorderLayout());
163       mainFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
164       if (appIcon != null) mainFrame.setIconImage(appIcon.getImage());
165       XMLUtil.setApplicationWindow(mainFrame);
166       // adding to xml element change listener collection
167
XMLElementDialog.addXMLElementChangedListener(this);
168       // Everything else is done within init method
169
}
170
171    private void init (String JavaDoc filename) {
172       org.enhydra.jawe.xml.elements.Package pkg=
173          openDocument(filename,true,false);
174       packageEditor = new PackageEditor(pkg);
175       mainFrame.getContentPane().add(packageEditor,BorderLayout.CENTER);
176
177       if (filename!=null && new File(filename).exists()) {
178          boolean validationStatus=JaWEConfig.getInstance().getValidationStatus();
179          PackageValidator pv=new PackageValidator(pkg,false,true,true,true,
180                                                   JaWEConfig.getInstance().getAllowUndefinedStartActivity(),
181                                                   JaWEConfig.getInstance().getAllowUndefinedEndActivity(),
182                                                   JaWEConfig.getInstance().getEncoding());
183          ValidationErrorDisplay ved=null;
184          if (validationStatus && !pv.validateAll(true)) {
185             try {
186                JaWESplash.getSplash().hideSplash();
187             } catch (Exception JavaDoc ex) {}
188             Map xpdlSchemaValidationErrors=pv.getXPDLSchemaValidationErrors();
189             Map connectionErrors=pv.getGraphsConnectionErrors(pkg);
190             java.util.List JavaDoc basicGraphConformanceErrors=pv.getBasicGraphConformanceErrors(pkg);
191             Map graphConformanceErrors=pv.getGraphConformanceErrors(pkg);
192             Map logicErrors=pv.getLogicErrors(pkg);
193             // Prints connection error messages contained in a given Hashtable.
194
// Hashtable has activity elements as a keys and it's error
195
// connection messages as a values.
196
String JavaDoc title=ResourceManager.getLanguageDependentString("DialogValidationReport");
197             ved=new ValidationErrorDisplay(xpdlSchemaValidationErrors,connectionErrors,
198                                            basicGraphConformanceErrors,graphConformanceErrors,logicErrors,
199                                            mainFrame,title,true);
200          }
201
202          if (ved==null || !ved.hasBeenStoped()) {
203             packageEditor.setNewPackage(pkg,true);
204             if (!packageEditor.isInitialized() || pkg.get("Id").toString().trim().length()==0) {
205                if (ved!=null && !ved.hasBeenStoped()) {
206                   message(ResourceManager.getLanguageDependentString("InformationErrorWhileOpeningFile"),
207                           JOptionPane.INFORMATION_MESSAGE);
208                }
209                this.filename=null;
210                packageEditor.update();
211                packageEditor.enterPackageID();
212             } else {
213                try {
214                   JaWESplash.getSplash().hideSplash();
215                } catch (Exception JavaDoc ex) {}
216                // check if there is mandatory conformance class
217
processConformanceClassAttribute(pkg);
218             }
219          } else {
220             org.enhydra.jawe.actions.New.openNewPackage();
221          }
222          packageEditor.update();
223       } else {
224          this.filename=null;
225          packageEditor.setNewPackage(pkg,true);
226       }
227
228       save = packageEditor.getAction("Save");
229       exit = packageEditor.getAction("Exit");
230       // recentFiles menu receives a special treatment, since
231
// we need the reference to that menu available to the
232
// addToRecentFiles method
233
recentFilesMenu=(JMenu)packageEditor.getMenuItem("RecentFiles");
234       // now fill in recent files menu from storage file
235
initRecentFileMenu();
236       if (this.filename!=null && new File(this.filename).exists()) {
237          addToRecentFiles(this.filename);
238       }
239
240       mainFrame.addWindowListener(createAppCloser());
241       mainFrame.pack();
242       // set default location to be centered and size to be almost maximized
243
//Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
244
Dimension screenSize =
245          GraphicsEnvironment
246          .getLocalGraphicsEnvironment()
247          .getDefaultScreenDevice()
248          .getDefaultConfiguration()
249          .getBounds()
250          .getSize();
251
252
253       int xMinus=50, yMinus=100;
254       mainFrame.setBounds(xMinus/2, yMinus/2, screenSize.width - xMinus,
255                           screenSize.height - yMinus);
256       ToolTipManager.sharedInstance().setEnabled(JaWEConfig.getInstance().getTooltipStatus());
257    }
258
259    /** Gets the filename of current document. */
260    public String JavaDoc getFilename () {
261       return filename;
262    }
263
264    /** Sets the filename of current document. */
265    public void setFilename (String JavaDoc filename) {
266       this.filename=filename;
267    }
268
269    /**
270     * Creates AppCloser object.
271     */

272    protected WindowAdapter createAppCloser() {
273       return new JaWE.AppCloser();
274    }
275
276    //************** APPCLOSER CLASS FOR CLOSING APPLICATION WINDOW ***************
277
/**
278     * To shutdown when run as an application.
279     */

280    private final class AppCloser extends WindowAdapter {
281       public void windowClosing(WindowEvent e) {
282          exit.actionPerformed(null);
283       }
284    }
285    //**** END OF CREATING APPLICATION CLOSER COMPONENT FOR APPLICATION WINDOW ****
286

287
288
289    public JMenu getRecentFilesMenu() {
290       return recentFilesMenu;
291    }
292
293    private void initRecentFileMenu () {
294       String JavaDoc rfl = XMLUtil.fileToString(
295          JaWEConstants.JAWE_USER_HOME + JaWEConstants.RFL_FILENAME);
296       if (rfl != null) {
297          for (StringTokenizer st = new StringTokenizer(rfl,"\n");
298               st.hasMoreTokens();) {
299             addToRecentFiles(st.nextToken());
300          }
301       }
302    }
303
304    /**
305     *
306     */

307    public void addToRecentFiles(String JavaDoc filename) {
308       JMenuItem mItem;
309       for (int i = 0; i < recentFilesMenu.getItemCount(); ++i) {
310          mItem=(JMenuItem)recentFilesMenu.getMenuComponent(i);
311          if (filename.equals(mItem.getText().substring(2))) {
312             recentFilesMenu.remove(i);
313          }
314       }
315       if (recentFilesMenu.getItemCount()==recentFileListSize) {
316          recentFilesMenu.remove(recentFileListSize-1);
317       }
318       mItem = new JMenuItem("1 "+filename);
319       mItem.addActionListener(new ActionListener() {
320                public void actionPerformed(ActionEvent e) {
321                   String JavaDoc filename = e.getActionCommand().substring(2);
322                   if (JaWE.getInstance().close()) {
323                      checkNameAndOpenDocumentIfPossible(filename);
324                   }
325                }
326             });
327       recentFilesMenu.insert(mItem,0);
328       // changing mnemonics to correspond to the ordinal number of items
329
for (int i = 0; i < recentFilesMenu.getItemCount(); ++i) {
330          mItem=(JMenuItem)recentFilesMenu.getMenuComponent(i);
331          String JavaDoc oldText=mItem.getText();
332          String JavaDoc ordNo=String.valueOf(i+1);
333          String JavaDoc mnemonic=ordNo.substring(ordNo.length()-1,ordNo.length());
334          mItem.setText(mnemonic+" " +oldText.substring(2));
335          BarFactory.setMnemonic(mItem,mnemonic);
336       }
337
338    }
339
340    /*
341     * Method for closing document. Returns true if the user really
342     * wants to close. Gives chance to save work.
343     */

344    public boolean close() {
345       int r = JOptionPane.NO_OPTION;
346       if (isModified()) {
347          r=JOptionPane.showConfirmDialog(mainFrame,
348                                          ResourceManager.getLanguageDependentString("SaveChangesDialog"),
349                                          appTitle, JOptionPane.YES_NO_CANCEL_OPTION);
350       }
351       if (r == JOptionPane.YES_OPTION) {
352          save.actionPerformed(null);
353          if (isModified()) {
354             r = JOptionPane.CANCEL_OPTION;
355          }
356       }
357       if (r == JOptionPane.CANCEL_OPTION) {
358          //getWindow().dispose();
359
return false;
360       }
361       return true;
362    }
363
364
365    /**
366     * Returns the instance of package editor that maintains current package.
367     */

368    public PackageEditor getPackageEditor () {
369       return packageEditor;
370    }
371
372    /**
373     * Gets the main package representing opened XML file.
374     */

375    public org.enhydra.jawe.xml.elements.Package
376       getRealXMLPackage () {
377       return packageEditor.getRealXMLPackage();
378    }
379
380    /**
381     * Shows the specified process. If nothing is specified, creates
382     * the new process.
383     */

384    public WorkflowProcess showProcess (Window parentWindow,
385                                        WorkflowProcess wp,String JavaDoc processID) {
386       return packageEditor.showProcess(parentWindow,wp,processID);
387    }
388
389    /**
390     * Sets the indication if document is modified.
391     */

392    public void setModified (boolean modified) {
393       if (this.modified!=modified) {
394          this.modified=modified;
395          getPackageEditor().update();
396       }
397    }
398
399    /**
400     * Returns if the document is modified.
401     */

402    public boolean isModified () {
403       return modified;
404    }
405
406    public void checkNameAndOpenDocumentIfPossible (String JavaDoc name) {
407       if (name!=null && new File(name).exists()) {
408          packageEditor.displayPackage(packageEditor.getRealXMLPackage());
409          org.enhydra.jawe.xml.elements.Package pkg=
410             openDocument(name,true,false);
411
412          boolean validationStatus=JaWEConfig.getInstance().getValidationStatus();
413
414          PackageValidator pv=new PackageValidator(pkg,false,true,true,true,
415                                                   JaWEConfig.getInstance().getAllowUndefinedStartActivity(),
416                                                   JaWEConfig.getInstance().getAllowUndefinedEndActivity(),
417                                                   JaWEConfig.getInstance().getEncoding());
418          ValidationErrorDisplay ved=null;
419          if (validationStatus && !pv.validateAll(true)) {
420             Map xpdlSchemaValidationErrors=pv.getXPDLSchemaValidationErrors();
421             Map connectionErrors=pv.getGraphsConnectionErrors(pkg);
422             java.util.List JavaDoc basicGraphConformanceErrors=pv.getBasicGraphConformanceErrors(pkg);
423             Map graphConformanceErrors=pv.getGraphConformanceErrors(pkg);
424             Map logicErrors=pv.getLogicErrors(pkg);
425
426             // Prints connection error messages contained in a given Hashtable.
427
// Hashtable has activity elements as a keys and it's error
428
// connection messages as a values.
429
String JavaDoc title=ResourceManager.getLanguageDependentString("DialogValidationReport");
430             ved=new ValidationErrorDisplay(xpdlSchemaValidationErrors,connectionErrors,
431                                            basicGraphConformanceErrors,graphConformanceErrors,logicErrors,
432                                            mainFrame,title,true);
433          }
434
435          if (ved==null || !ved.hasBeenStoped()) {
436             packageEditor.setNewPackage(pkg,true);
437             if (!packageEditor.isInitialized() || pkg.get("Id").toString().trim().length()==0) {
438                if (ved!=null && !ved.hasBeenStoped()) {
439                   message(ResourceManager.getLanguageDependentString("InformationErrorWhileOpeningFile"),
440                           JOptionPane.INFORMATION_MESSAGE);
441                }
442                this.filename=null;
443                packageEditor.update();
444                packageEditor.enterPackageID();
445             } else {
446                addToRecentFiles(this.filename);
447                // check if there is mandatory conformance class
448
processConformanceClassAttribute(pkg);
449             }
450          } else {
451             org.enhydra.jawe.actions.New.openNewPackage();
452          }
453          packageEditor.update();
454       } else {
455          message(ResourceManager.getLanguageDependentString("InformationErrorWhileOpeningFile"),
456                  JOptionPane.INFORMATION_MESSAGE);
457       }
458    }
459
460    public void openPackageFromStream (String JavaDoc name,String JavaDoc pkgCnt) {
461       if (name!=null && pkgCnt!=null) {
462          this.filename = name;
463
464          packageEditor.displayPackage(packageEditor.getRealXMLPackage());
465          xmlInterface.closeAllPackages();
466
467          xmlInterface.putPkgIdToFileContentMapping(name,pkgCnt);
468
469          org.enhydra.jawe.xml.elements.Package pkg=null;
470
471
472          pkg=xmlInterface.openPackage(name,true);
473          System.out.println("pkg="+pkg);
474          if (pkg==null) {
475             pkg=new org.enhydra.jawe.xml.elements.Package(xmlInterface);
476          }
477
478          boolean validationStatus=JaWEConfig.getInstance().getValidationStatus();
479
480          PackageValidator pv=new PackageValidator(pkg,false,true,true,false,
481                                                   JaWEConfig.getInstance().getAllowUndefinedStartActivity(),
482                                                   JaWEConfig.getInstance().getAllowUndefinedEndActivity(),
483                                                   JaWEConfig.getInstance().getEncoding());
484          ValidationErrorDisplay ved=null;
485          if (validationStatus && !pv.validateAll(true)) {
486             Map xpdlSchemaValidationErrors=pv.getXPDLSchemaValidationErrors();
487             Map connectionErrors=pv.getGraphsConnectionErrors(pkg);
488             java.util.List JavaDoc basicGraphConformanceErrors=pv.getBasicGraphConformanceErrors(pkg);
489             Map graphConformanceErrors=pv.getGraphConformanceErrors(pkg);
490             Map logicErrors=pv.getLogicErrors(pkg);
491
492             // Prints connection error messages contained in a given Hashtable.
493
// Hashtable has activity elements as a keys and it's error
494
// connection messages as a values.
495
String JavaDoc title=ResourceManager.getLanguageDependentString("DialogValidationReport");
496             ved=new ValidationErrorDisplay(xpdlSchemaValidationErrors,connectionErrors,
497                                            basicGraphConformanceErrors,graphConformanceErrors,logicErrors,
498                                            mainFrame,title,true);
499          }
500
501          if (ved==null || !ved.hasBeenStoped()) {
502             packageEditor.setNewPackage(pkg,false);
503             if (!packageEditor.isInitialized() || pkg.get("Id").toString().trim().length()==0) {
504                if (ved!=null && !ved.hasBeenStoped()) {
505                   message(ResourceManager.getLanguageDependentString("InformationErrorWhileOpeningFile"),
506                           JOptionPane.INFORMATION_MESSAGE);
507                }
508                this.filename=null;
509                packageEditor.update();
510                packageEditor.enterPackageID();
511             } else {
512                filename=null;
513                // check if there is mandatory conformance class
514
processConformanceClassAttribute(pkg);
515             }
516          } else {
517             org.enhydra.jawe.actions.New.openNewPackage();
518          }
519          packageEditor.update();
520       } else {
521          message(ResourceManager.getLanguageDependentString("InformationErrorWhileOpeningFile"),
522                  JOptionPane.INFORMATION_MESSAGE);
523       }
524    }
525
526    /**
527     * Used to open new document when some other document is beeing edited (called
528     * from New and Open actions).
529     */

530    public org.enhydra.jawe.xml.elements.Package openDocument (
531       String JavaDoc filename,boolean clearOtherPackages,boolean openFromStream) {
532       this.filename = filename;
533       org.enhydra.jawe.xml.elements.Package pkg=null;
534       if (clearOtherPackages) {
535          xmlInterface.closeAllPackages();
536       }
537       if (filename!=null) {
538          pkg=xmlInterface.openPackage(filename,openFromStream);
539       }
540       if (pkg==null) {
541          pkg=new org.enhydra.jawe.xml.elements.Package(xmlInterface);
542       }
543
544       return pkg;
545    }
546
547    // ********************************** DIALOGS *********************************
548
/* Show a file open dialog and return the filename. */
549    public String JavaDoc openDialog(String JavaDoc message) {
550       return XMLUtil.dialog(mainFrame,message,0,0,null);
551    }
552
553    /* Show a file save dialog and return the filename. */
554    public String JavaDoc saveDialog(String JavaDoc message,int filteringMode,String JavaDoc initialName) {
555       return XMLUtil.dialog(mainFrame,message,1,filteringMode,initialName);
556    }
557
558    /* Show a dialog with the given error message. */
559    public void message(String JavaDoc message,int type) {
560       JOptionPane.showMessageDialog(mainFrame,message,JaWE.getAppTitle(),type);
561    }
562
563    public void setRecentFilesMenu (JMenu rfm) {
564       recentFilesMenu=rfm;
565    }
566
567    /* Return JaWE's main frame. */
568    public JFrame getMainFrame() {
569       return mainFrame;
570    }
571    /**
572     * Reacts upon the XML element change by setting isModified flag
573     * of PackageEditor if needed.
574     */

575    public void xmlElementChanged (XMLElement el) {
576       if (!(((el instanceof XMLCollection) &&
577                 !(el instanceof ExternalPackages) && !el.getClass().getName().startsWith(
578                    "org.enhydra.jawe.xml.elements.Activity$")) || (el instanceof Responsible) ||
579                (el instanceof ExtendedAttribute) || (el instanceof DataTypes) ||
580                (el instanceof EnumerationValue) || (el instanceof Tool) ||
581                (el instanceof ActualParameter) || (el instanceof ExternalProcesses) ||
582                (el instanceof ExternalParticipants) || (el instanceof Deadline) ||
583                el.getClass().getName().startsWith(
584                   "org.enhydra.jawe.xml.panels.XMLListChoiceControlPanel$"))) {
585          setModified(true);
586       }
587
588       if (!JaWEConfig.getInstance().getStatusBarStatus()) return;
589       // status bar update
590
if (el instanceof org.enhydra.jawe.xml.elements.Activity ||
591           el instanceof org.enhydra.jawe.xml.elements.Transition) {
592          packageEditor.getStatusBar().updateMessage();
593          XMLCollectionElement actOrTrans=(XMLCollectionElement)el;
594          org.enhydra.jawe.graph.Process pr=null;
595          if (actOrTrans.getCollection().getOwner() instanceof WorkflowProcess) {
596             pr=packageEditor.
597                getProcessObject((WorkflowProcess)actOrTrans.getCollection().getOwner());
598             pr.getImplementationEditor().getStatusBar().updateMessage();
599          } else {
600             ActivitySet actSet=(ActivitySet)actOrTrans.getCollection().getOwner();
601             pr=packageEditor.
602                getProcessObject((WorkflowProcess)actSet.getCollection().getOwner());
603
604             Set baObjects=pr.getImplementationEditor().getGraph().getWorkflowManager().getBlockActivities(true);
605             // iterate through all block activity objects, get their editors and
606
// call change language on them
607
Iterator baObjs =baObjects.iterator();
608             while(baObjs.hasNext()) {
609                org.enhydra.jawe.graph.BlockActivity ba=
610                   (org.enhydra.jawe.graph.BlockActivity)baObjs.next();
611                AbstractEditor bae=ba.getImplementationEditor();
612                if (bae!=null) {
613                   Object JavaDoc xpdlObj=bae.getGraph().getXPDLObject();
614                   if (xpdlObj.equals(actSet)) {
615                      bae.getStatusBar().updateMessage();
616                   }
617                }
618             }
619
620          }
621       }
622       if (el instanceof org.enhydra.jawe.xml.elements.Package) {
623          packageEditor.getStatusBar().updateMessage();
624       }
625    }
626
627    /**
628     * Processes conformance class attribute, compares it with mandatory default,
629     * and performs appropriate actions.
630     */

631    private void processConformanceClassAttribute (
632       org.enhydra.jawe.xml.elements.Package pkg) {
633       ConformanceClass cc=(ConformanceClass)pkg.get("ConformanceClass");
634       String JavaDoc gct=cc.get("GraphConformance").toValue().toString();
635       int mct=XMLUtil.getConformanceClassNo(mandatoryConformanceClass);
636       int ct=XMLUtil.getConformanceClassNo(gct);
637       if (mct>0) {
638          if (mct!=ct) {
639             message(ResourceManager.getLanguageDependentString(
640                        "WarningYouHaveOpenedPackageWithConformanceClassDiferentThenMandatoryOne"),
641                     JOptionPane.WARNING_MESSAGE);
642          } else {
643             cc.setReadOnly(true);
644          }
645       }
646    }
647
648    public String JavaDoc getMandatoryConformanceClass () {
649       return mandatoryConformanceClass;
650    }
651
652    /** Main method. */
653    public static void main(String JavaDoc[] args) {
654       JaWE.jawe=new JaWE();
655
656       JaWESplash splash = new JaWESplash("SplashImage", null, 9000);
657       // Starting file name
658
String JavaDoc fn=null;
659       // Starting locale
660
String JavaDoc sl=null;
661       // Mandatory conformance class
662
String JavaDoc mcc=null;
663
664       // Startup parameters:
665
// -sl STARTING_LOCALE
666
// -mcc MANDATORY_CONFORMANCE_CLASS
667
if (args!=null && args.length>0) {
668          for (int i = 0; i < args.length; ++i) {
669             if(args[i].compareTo("-mcc")==0) {
670                if (++i == args.length) {
671                   System.err.println("error: Missing argument to -mcc option.");
672                   continue;
673                }
674                mcc = args[i];
675                String JavaDoc oldMCC=JaWEConfig.getInstance().getMandatoryConformanceClass();
676                JaWEConfig.getInstance().setMandatoryConformanceClass(mcc);
677                jawe.mandatoryConformanceClass=JaWEConfig.getInstance().getMandatoryConformanceClass();
678                JaWEConfig.getInstance().setMandatoryConformanceClass(oldMCC);
679             }
680             if(args[i].compareTo("-sl")==0) {
681                if (++i == args.length) {
682                   System.err.println("error: Missing argument to -sl option.");
683                   continue;
684                }
685                sl = args[i];
686                try {
687                   PFLocale pfl=PFLocale.createPFLocale(sl);
688                   if (pfl==null) {
689                      pfl=new PFLocale(Locale.getDefault());
690                   }
691                   ResourceManager.setChoosen(pfl.getLocale());
692                } catch (Exception JavaDoc ex) {
693                   System.err.println("warning: Can't start with locale "+sl);
694                }
695             }
696          }
697          // check if there is a file that should be open at the startup
698
if (args.length/2!=(args.length/2.0)) {
699             fn=args[args.length-1];
700          }
701       }
702       // first the singleton object must be created, and after that
703
// it is initialized because within init method, some JaWE
704
// methods are called, which would cause reinitialization
705
JaWE.jawe.init(fn);
706       splash.dispose();
707       splash=null;
708       jawe.getPackageEditor().showWindow(null,jawe.getPackageEditor().getTitle());
709    }
710
711
712 }
713
714
Popular Tags