Search in sources :

Example 26 with Project

use of org.talend.core.model.properties.Project in project tdq-studio-se by Talend.

the class ExportWizardPage method canFinish.

/**
 * check if the output path is correct.
 *
 * @return
 */
public boolean canFinish() {
    String lastPath = writer.getBasePath().toString();
    if (lastPath == null || PluginConstant.EMPTY_STRING.equals(lastPath)) {
        // $NON-NLS-1$//$NON-NLS-2$
        MessageDialog.openError(getShell(), "Error", Messages.getString("ExportWizardPage.emptyPath"));
        return false;
    }
    ProjectManager pManager = ProjectManager.getInstance();
    Project project = pManager.getCurrentProject().getEmfProject();
    // $NON-NLS-1$
    File outputDir = new File(lastPath + File.separator + project.getTechnicalLabel());
    // if the file exists,pop an dialog to ask that it will override the old file.
    if ((dirBTN.getSelection() && outputDir.exists()) || (archBTN.getSelection() && new File(archTxt.getText().trim()).exists())) {
        File oldFile = outputDir.exists() ? outputDir : new File(archTxt.getText().trim());
        if (MessageDialogWithToggle.openConfirm(null, Messages.getString("ExportWizard.waring"), Messages.getString("ExportWizard.fileAlreadyExist"))) {
            // $NON-NLS-1$ //$NON-NLS-2$
            FileUtils.deleteQuietly(oldFile);
        } else {
            return false;
        }
    }
    return true;
}
Also used : Project(org.talend.core.model.properties.Project) IFile(org.eclipse.core.resources.IFile) File(java.io.File) ProjectManager(org.talend.repository.ProjectManager)

Aggregations

Project (org.talend.core.model.properties.Project)26 IProject (org.eclipse.core.resources.IProject)11 IPath (org.eclipse.core.runtime.IPath)10 Path (org.eclipse.core.runtime.Path)8 PersistenceException (org.talend.commons.exception.PersistenceException)7 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)6 File (java.io.File)5 Item (org.talend.core.model.properties.Item)5 ProcessItem (org.talend.core.model.properties.ProcessItem)5 ArrayList (java.util.ArrayList)4 CoreException (org.eclipse.core.runtime.CoreException)4 URI (org.eclipse.emf.common.util.URI)4 InternalEObject (org.eclipse.emf.ecore.InternalEObject)4 Property (org.talend.core.model.properties.Property)4 RoutineItem (org.talend.core.model.properties.RoutineItem)4 IOException (java.io.IOException)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 EObject (org.eclipse.emf.ecore.EObject)3 Resource (org.eclipse.emf.ecore.resource.Resource)3 URL (java.net.URL)2