Package jsynoptic.base

Examples of jsynoptic.base.Linkable


                AbstractShape abs = (AbstractShape) it.next();
                abs.addListener( (ShapeListener)sc.getComponent());
                if (!(abs instanceof Linkable)) {
                    continue;
                }
                Linkable l = (Linkable) abs;
                // Now trying to restore absolute file
                File parent = f.getParentFile();
                if (parent == null) {
                    parent = new File("./");
                }
                String link = l.getLink();
                if ((link != null) && (!link.equals(""))) {
                    File nl = new File(parent, link);
                    l.setLink(nl.getCanonicalPath());
                }
            } catch (ClassCastException cce) {
            }
        }
    }
View Full Code Here


        for (Iterator it = sc.iterator(); it.hasNext();) {
            Object o = it.next();
            if (!(o instanceof Linkable)) {
                continue;
            }
            Linkable l = (Linkable) o;
            String link = l.getLink();
            if (link != null) {
                File flink = new File(link);
                String sf = f.getCanonicalPath();
                String sl = flink.getCanonicalPath();
                int i = -1, lastOK = -1;
                while ((i < sl.length()) && (i < sf.length())
                        && ((i == -1) || sf.substring(0, i).equals(sl.substring(0, i)))) {
                    lastOK = i;
                    i = sl.indexOf(File.separator, i + 1);
                    if (i == -1) {
                        break;
                    }
                }
                String subf = sf.substring(lastOK + 1, sf.length());
                String subl = sl.substring(lastOK + 1, sl.length());
                String prefix = "";
                i = -1;
                while (true) {
                    i = subf.indexOf(File.separator, i + 1);
                    if (i == -1) {
                        break;
                    }
                    prefix += "../";
                }
                link = prefix + subl;
                link = link.replaceAll("\\\\", "/"); // regexp black magic
                // incantation
                // Set the relative link
                l.setLink(link);
            }
        }

    }
View Full Code Here

                        AbstractShape abs = (AbstractShape) it.next();
                        abs.addListener( (ShapeListener)sc.getComponent());
                        if (!(abs instanceof Linkable)) {
                            continue;
                        }
                        Linkable l = (Linkable) abs;
                        // Now trying to restore absolute file
                        File parent = f.getParentFile();
                        if (parent == null) {
                            parent = new File("./");
                        }
                        String link = l.getLink();
                        if ((link != null) && (!link.equals(""))) {
                            File nl = new File(parent, link);
                            l.setLink(nl.getCanonicalPath());
                        }
                    } catch (ClassCastException cce) {
                    }
                }
                if (JSynoptic.gui != null) {
View Full Code Here

        for (Iterator it = sc.iterator(); it.hasNext();) {
            Object o = it.next();
            if (!(o instanceof Linkable)) {
                continue;
            }
            Linkable l = (Linkable) o;
            String link = l.getLink();
            if (link != null) {
                File flink = new File(link);
                String sf = f.getCanonicalPath();
                String sl = flink.getCanonicalPath();
                int i = -1, lastOK = -1;
                while ((i < sl.length()) && (i < sf.length())
                        && ((i == -1) || sf.substring(0, i).equals(sl.substring(0, i)))) {
                    lastOK = i;
                    i = sl.indexOf(File.separator, i + 1);
                    if (i == -1) {
                        break;
                    }
                }
                String subf = sf.substring(lastOK + 1, sf.length());
                String subl = sl.substring(lastOK + 1, sl.length());
                String prefix = "";
                i = -1;
                while (true) {
                    i = subf.indexOf(File.separator, i + 1);
                    if (i == -1) {
                        break;
                    }
                    prefix += "../";
                }
                link = prefix + subl;
                link = link.replaceAll("\\\\", "/"); // regexp black magic
                // incantation
                // Set the relative link
                l.setLink(link);
            }
        }
        FileOutputStream fos = new FileOutputStream(f);
        // ZipOutputStream zos = new ZipOutputStream(fos);
        // zos.setComment(resources.getStringValue("zipComment"));
        ObjectOutputStream os = new ObjectOutputStream(fos);
        // os.writeObject(resources.getStringValue("fileComment"));
        os.writeObject(sc);
        os.writeObject(null); // for ascending compatibility
        os.writeObject(null); // for ascending compatibility
        os.writeObject(null); // for ascending compatibility
        os.flush();
        os.close();
        fos.close(); // also closes the file
        String name = f.getName();
        String myExt = resources.getStringValue("jsynopticFilterExtension");
        if (name.endsWith(myExt)) {
            name = name.substring(0, name.length() - myExt.length() - 1);
        }
        sc.getComponent().setName(name);
        // Restoring absolute links
        for (Iterator it = sc.iterator(); it.hasNext();) {
            try {
                AbstractShape abs = (AbstractShape) it.next();
                abs.addListener( (ShapeListener)sc.getComponent());
                if (!(abs instanceof Linkable)) {
                    continue;
                }
                Linkable l = (Linkable) abs;
                // Now trying to restore absolute file
                File parent = f.getParentFile();
                if (parent == null) {
                    parent = new File("./");
                }
                String link = l.getLink();
                if ((link != null) && (!link.equals(""))) {
                    File nl = new File(parent, link);
                    l.setLink(nl.getCanonicalPath());
                }
            } catch (ClassCastException cce) {
            }
        }
        if (JSynoptic.gui != null) {
View Full Code Here

TOP

Related Classes of jsynoptic.base.Linkable

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.