Examples of XFile


Examples of com.nexirius.util.XFile

        return true;
    }
    //Method that defines that actual command and should return true if the transition
    //it could be mapped into should take place.
    public boolean execute(HTMLSessionVariable sessionVariable) throws Exception {
        XFile file = JnexExampleHtmlApplication.getTextFile();

        file.writeText(sessionVariable.getApplicationModel().dragData());
        return true;
    }
View Full Code Here

Examples of com.nexirius.util.XFile

    public static void init() {
        String dbFileName = "theteam.mdb";
        String dbDirName = System.getProperty("user.dir") + File.separator + "data" + File.separator;
        String dbPathName = dbDirName + dbFileName;
        XFile dbFile = new XFile(dbPathName);

        if (!dbFile.exists()) {
            InputStream stream = new BufferedInputStream(dbFile.getClass().getClassLoader().getResourceAsStream(dbFileName));

            try {
                new XFile(dbDirName).mkdirs();
                dbFile.createFrom(stream);
            } catch (IOException e) {
                throw new ErrorMessageException("Cannot initialize database", e, null);
            }
        }
View Full Code Here

Examples of com.nexirius.util.XFile

        while (e.hasMore()) {
            AttachmentModel att = (AttachmentModel) e.next();

            try {
                XFile file = new XFile(att.getFilename());
                InputStream in = new BufferedInputStream(new FileInputStream(file));

                MimeBodyPart attPart;
                try {
                    attPart = new MimeBodyPart();
                    attPart.setDataHandler(new DataHandler(new ByteArrayDataSource(in, "application/foo")));
                    attPart.setFileName(file.getName());
                    attPart.setHeader("Content-ID", file.getName());
                    attPart.setDisposition(Part.ATTACHMENT);
                    multipart.addBodyPart(attPart);
                } catch (MessagingException e3) {
                    e3.printStackTrace();
                }
View Full Code Here

Examples of com.nexirius.util.XFile

        if (retval == JFileChooser.APPROVE_OPTION) {
            File theFile = chooser.getSelectedFile();

            if (theFile != null) {
                XFile xfile = new XFile(chooser.getSelectedFile().getAbsolutePath());
                StringVector sv;

                try {
                    sv = xfile.getTextLines();
                } catch (Exception e) {
                    DialogManager.error(e.getMessage());

                    return;
                }
View Full Code Here

Examples of com.nexirius.util.XFile

        if (retval == JFileChooser.APPROVE_OPTION) {
            File theFile = chooser.getSelectedFile();

            if (theFile != null) {
                XFile xfile = new XFile(chooser.getSelectedFile().getAbsolutePath());

                StringVector sv = new StringVector();

                DataModelEnumeration e = mailList.getMailModelEnumeration();

                while (e.hasMore()) {
                    MailModel m = (MailModel) e.next();
                    StringBuffer line = new StringBuffer();

                    for (int i = 0; i < MailModel.MAIL_FIELDS.length; ++i) {
                        line.append(m.getChildText(MailModel.MAIL_FIELDS[i]) + SEPARATOR_CHAR[separator.getInt()]);
                    }

                    sv.append(line.toString());
                }

                DialogManager.setWaitCursor(DialogManager.getToplevelFrame());
                try {
                    xfile.writeTextLines(sv);
                } catch (Exception ex) {
                    DialogManager.setDefaultCursor(DialogManager.getToplevelFrame());
                    DialogManager.error(ex.getMessage());

                    return;
View Full Code Here

Examples of com.nexirius.util.XFile

     * init the persistant data store (all data will be stored under this directory)
     *
     * @param persistenceRootDirectory
     */
    public static void init(String persistenceRootDirectory) {
        XFile dir = new XFile(persistenceRootDirectory);

        dir.mkdirs();
        instance = new FilePersistence(persistenceRootDirectory);
    }
View Full Code Here

Examples of com.nexirius.util.XFile

        return instance;
    }

    public String getNewID() {
        try {
            XFile f = new XFile(rootDirectory, "ID.TXT");
            int id = 1;
            if (f.exists()) {
                String sID = new String(f.getBytes()); // reads the content of the file into a string
                id = Integer.parseInt(sID);
                ++id;
            }
            // write the latest id into file
            f.writeText(Integer.toString(id));

            return Integer.toString(id);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
View Full Code Here

Examples of com.nexirius.util.XFile

        }
        return "";
    }

    private XFile getDirectory(Class cl) {
        XFile dir = new XFile(rootDirectory + cl.getName());
        if (!dir.isDirectory()) {
            dir.mkdirs();
        }
        return dir;
    }
View Full Code Here

Examples of com.nexirius.util.XFile

     * @param model
     */
    public void create(DataModel model) {
        try {
            String id = getNewID();
            XFile dir = getDirectory(model.getClass());
            XFile file = new XFile(dir.getPath(), id);
            file.writeText(model.dragData());
            model.setInstanceName(id);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
View Full Code Here

Examples of com.nexirius.util.XFile

     * @param cl the class of the instance
     * @param id the is of the instance
     */
    public void delete(Class cl, String id) {
        try {
            XFile dir = getDirectory(cl);
            XFile file = new XFile(dir.getPath(), id);

            if (file.exists()) {
                file.delete();
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.