bogdanrechi.lansator.properties.ProgramItem.java Source code

Java tutorial

Introduction

Here is the source code for bogdanrechi.lansator.properties.ProgramItem.java

Source

/*
 * The MIT License (MIT)
 * 
 * Copyright (c) 2016 Bogdan Rechi
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

package bogdanrechi.lansator.properties;

import java.util.UUID;

import org.apache.commons.io.FilenameUtils;

import bogdanrechi.commons.exceptions.StringException;
import bogdanrechi.commons.file.Files;
import bogdanrechi.lansator.MainWindow;

/**
 * Program properties
 * 
 * @author Bogdan Rechi
 */
public class ProgramItem extends Item {
    public String path = "";
    public String runInFolder = "";
    public String parameters = "";
    public boolean asSuperuser;
    public boolean isSeparator;

    // region methods

    public ProgramItem() {
    }

    public ProgramItem(ProgramItem object) throws StringException {
        this.guid = UUID.randomUUID().toString();
        this.name = object.name;
        this.path = object.path;
        this.runInFolder = object.runInFolder;
        this.asSuperuser = object.asSuperuser;
        this.parameters = object.parameters;
        this.isImageAndText = object.isImageAndText;
        this.isSeparator = object.isSeparator;

        if (object.imageFile.length() > 0 && Files.exists(MainWindow.getImagesPath() + object.imageFile)) {
            String imageCopy = UUID.randomUUID().toString() + "." + FilenameUtils.getExtension(object.imageFile);

            Files.copyFileToFolder(MainWindow.getImagesPath() + object.imageFile, MainWindow.getImagesPath(),
                    imageCopy);

            this.imageFile = imageCopy;
        } else {
            this.imageFile = object.imageFile;
        }
    }
}