Package org.enhydra.jawe

Examples of org.enhydra.jawe.WaitScreen


        return openPackage(null, xpdlStream);
    }

    protected Package openPackage(String filename, byte[] xpdlStream) {
        //CUSTOM: added exception handling for HeadlessException
        WaitScreen ws = null;
        try {
            ws = new WaitScreen(frame);
        } catch (HeadlessException e) {
            // ignore
        }
        XPDLHandler xpdlh = null;
        try {
            Package pkg = null;
            clearAll();
            XPDLHandler xpdlhandler = JaWEManager.getInstance().getXPDLHandler();
            if (jaweFrameShown && filename != null && xpdlStream == null) {
                if (ws != null) {
                    ws.show(null, "", settings.getLanguageDependentString("OpeningFile"));
                }
            }
            xpdlh = JaWEManager.getInstance().createXPDLHandler(xpdlhandler.getXPDLRepositoryHandler());

            try {
                if (filename != null) {
                    pkg = xpdlh.openPackage(filename, true);
                } else {
                    pkg = xpdlh.openPackageFromStream(xpdlStream, true);
                }
            } catch (Exception ex) {
                ex.printStackTrace();
                clearAll();
                xpdlh.closeAllPackages();
                if (ws != null) {
                    ws.setVisible(false);
                }
                getJaWEFrame().message(settings.getLanguageDependentString("ErrorCannotOpenXPDL" + "\n" + ex.getMessage()),
                        JOptionPane.INFORMATION_MESSAGE);
            }

            if (pkg != null) {
                // do not allow insertion if package has the same Id as the one already
                // inserted
                Set allpkgids = new HashSet(xpdlhandler.getAllPackageIds());
                boolean canInsert = true;
                if (allpkgids.contains(pkg.getId())) {
                    canInsert = false;
                }
                if (canInsert) {
                    xpdlhandler.synchronizePackages(xpdlh);

                    boolean mainChanged = false;
                    Iterator it = xpdlhandler.getAllPackages().iterator();
                    while (it.hasNext()) {
                        Package p = (Package) it.next();
                        boolean changed = false;
                        try {
                            changed = adjustXPDL(p);
                        } catch (Exception e) {
                            // ignore
                        }

                        XPDLListenerAndObservable xpdl;
                        if (p == pkg) {
                            xpdl = createNewXPDLListenerObservable(pkg, true, false);
                            if (changed) {
                                mainChanged = true;
                            }
                        } else {
                            xpdl = createNewXPDLListenerObservable(p, false, false);
                            p.setReadOnly(true);
                        }
                        xpdl.setModified(changed);
                    }

                    List inserted = new ArrayList();
                    inserted.add(pkg);

                    it = xpdlhandler.getAllPackages().iterator();
                    while (it.hasNext()) {
                        Package pkgext = (Package) it.next();
                        if (pkgext == pkg) {
                            continue;
                        }
                        inserted.add(pkgext);
                    }

                    setChanged();
                    notifyObservers(createInfo(pkg, inserted, XMLElementChangeInfo.INSERTED));

                    if (pkg.getWorkflowProcesses().size() > 0) {
                        selectionMng.setSelection(pkg.getWorkflowProcesses().get(0), true);
                    } else {
                        selectionMng.setSelection(pkg, true);
                    }

                    JaWEManager.getInstance().getLoggingManager().info("JaWEController -> opened package " + pkg.getId());
                    if (settings.isInitialXPDLValidationEnabled()) {
                        try {
                            checkValidity(pkg, true, true, true);
                        } catch (Exception e) {
                            // ignore
                        }

                    }

                    if ((mainChanged) && jaweFrameShown) {
                        if (mainChanged) {
                            if (ws != null) {
                                ws.setVisible(false);
                            }
                            // CUSTOM: hide warning message
//                            frame.message(settings.getLanguageDependentString("InformationTogWEHasAutomaticallyAdjustedSomeXPDLParts"),
//                                    JOptionPane.INFORMATION_MESSAGE);
                            // END CUSTOM
                        }
                    }

                } else {
                    if (getJaWEFrame() != null) {
                        getJaWEFrame().message(settings.getLanguageDependentString("InformationPackageCannotBeOpened"),
                                JOptionPane.INFORMATION_MESSAGE);

                    }
                }
            } else {
                clearAll();
                Map pems = xpdlhandler.getParsingErrorMessages();
                String msg = null;
                if (pems != null && pems.size() > 0) {
                    Set s = (Set) pems.values().toArray()[0];
                    if (s != null && s.size() > 0) {
                        msg = (String) s.toArray()[0];
                    }
                }
                Iterator it = xpdlhandler.getAllPackages().iterator();
                while (it.hasNext()) {
                    Package p = (Package) it.next();
                    if (!p.isTransient()) {
                        xpdlhandler.closePackageVersion(p.getId(), p.getInternalVersion());
                    }
                }
                if (ws != null) {
                    ws.setVisible(false);
                }
                getJaWEFrame().message(settings.getLanguageDependentString("ErrorCannotOpenXPDL") + ((msg != null) ? "\n" + msg : ""),
                        JOptionPane.INFORMATION_MESSAGE);
            }
            updateTitle();
            adjustActions();

            return pkg;
        } finally {
            if (ws != null) {
                ws.setVisible(false);
            }
        }
        //END CUSTOM
    }
View Full Code Here

TOP

Related Classes of org.enhydra.jawe.WaitScreen

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.