Search in sources :

Example 46 with Status

use of org.eclipse.core.runtime.Status in project tdi-studio-se by Talend.

the class NewImportProjectWizardPage method checkFieldsValue.

/**
     * DOC ocarbone Comment method "checkField".
     */
protected void checkFieldsValue() {
    // Field Name
    if (nameText.getText().length() == 0) {
        nameStatus = new Status(IStatus.ERROR, RepositoryPlugin.PLUGIN_ID, IStatus.OK, Messages.getString("NewProjectWizardPage.nameEmpty"), //$NON-NLS-1$
        null);
    } else {
        // for bug 11214
        if (!nameText.getText().endsWith(" ")) {
            //$NON-NLS-1$
            technicalNameText.setText(Project.createTechnicalName(nameText.getText()));
        }
        if (ProjectUtils.isNotValidProjectName(nameText.getText())) {
            nameStatus = new Status(IStatus.ERROR, RepositoryPlugin.PLUGIN_ID, IStatus.OK, Messages.getString("NewProjectWizardPage.illegalCharacter"), //$NON-NLS-1$
            null);
        } else {
            if (isProjectNameAlreadyUsed(nameText.getText())) {
                nameStatus = new Status(IStatus.ERROR, RepositoryPlugin.PLUGIN_ID, IStatus.OK, Messages.getString("NewProjectWizardPage.projectNameAlredyExists"), //$NON-NLS-1$
                null);
            } else {
                nameStatus = createOkStatus();
                // Field description
                descriptionStatus = createOkStatus();
                // Combo language
                if (!languageJavaRadio.getSelection() && !languagePerlRadio.getSelection()) {
                    languageStatus = new Status(IStatus.ERROR, RepositoryPlugin.PLUGIN_ID, IStatus.OK, //$NON-NLS-1$
                    Messages.getString("NewProjectWizardPage.languageEmpty"), null);
                } else if (!languageEnable(getLanguage())) {
                    languageStatus = new Status(IStatus.ERROR, RepositoryPlugin.PLUGIN_ID, IStatus.WARNING, //$NON-NLS-1$
                    Messages.getString("NewProjectWizard.error.languageNotSupported", getLanguage()), null);
                } else {
                    languageStatus = createOkStatus();
                }
            }
        }
    }
    updatePageStatus();
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status)

Example 47 with Status

use of org.eclipse.core.runtime.Status in project tdi-studio-se by Talend.

the class ImportProjectAsWizardPage method evaluateSpecifiedPath.

private void evaluateSpecifiedPath(String path) {
    if (path.equals(lastPath)) {
        return;
    }
    // on an empty path empty selectedProjects
    if (path == null || path.length() == 0) {
        checkFieldsValue();
        return;
    }
    final boolean dirSelected = this.projectFromDirectoryRadio.getSelection();
    File directory = new File(path);
    Collection projectFiles = new ArrayList();
    Collection talendProjectFiles = new ArrayList();
    if (!dirSelected && ArchiveFileManipulations.isTarFile(path)) {
        TarFile sourceTarFile = getSpecifiedTarSourceFile(path);
        if (sourceTarFile == null) {
            return;
        }
        TarLeveledStructureProvider provider = new TarLeveledStructureProvider(sourceTarFile);
        Object child = provider.getRoot();
        if (!ImportProjectsUtilities.collectProjectFilesFromProvider(projectFiles, provider, child, 0, null, IProjectDescription.DESCRIPTION_FILE_NAME)) {
            return;
        }
        if (!ImportProjectsUtilities.collectProjectFilesFromProvider(talendProjectFiles, provider, child, 0, null, FileConstants.LOCAL_PROJECT_FILENAME)) {
            return;
        }
        if (!ImportProjectsUtilities.collectProjectFilesFromProvider(talendProjectFiles, provider, child, 0, null, FileConstants.OLD_TALEND_PROJECT_FILENAME)) {
            return;
        }
    } else if (!dirSelected && ArchiveFileManipulations.isZipFile(path)) {
        ZipFile sourceFile = getSpecifiedZipSourceFile(path);
        if (sourceFile == null) {
            return;
        }
        ZipLeveledStructureProvider provider = new ZipLeveledStructureProvider(sourceFile);
        Object child = provider.getRoot();
        if (!ImportProjectsUtilities.collectProjectFilesFromProvider(projectFiles, provider, child, 0, null, IProjectDescription.DESCRIPTION_FILE_NAME)) {
            return;
        }
        if (!ImportProjectsUtilities.collectProjectFilesFromProvider(talendProjectFiles, provider, child, 0, null, FileConstants.LOCAL_PROJECT_FILENAME)) {
            return;
        }
        if (!ImportProjectsUtilities.collectProjectFilesFromProvider(talendProjectFiles, provider, child, 0, null, FileConstants.OLD_TALEND_PROJECT_FILENAME)) {
            return;
        }
    } else if (dirSelected && directory.isDirectory()) {
        if (!ImportProjectsUtilities.collectProjectFilesFromDirectory(projectFiles, directory, null, IProjectDescription.DESCRIPTION_FILE_NAME)) {
            return;
        }
        if (!ImportProjectsUtilities.collectProjectFilesFromDirectory(talendProjectFiles, directory, null, FileConstants.LOCAL_PROJECT_FILENAME)) {
            return;
        }
        if (!ImportProjectsUtilities.collectProjectFilesFromDirectory(talendProjectFiles, directory, null, FileConstants.OLD_TALEND_PROJECT_FILENAME)) {
            return;
        }
    }
    lastPath = path;
    if (projectFiles.size() != 1 || talendProjectFiles.size() != 1) {
        IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
        String string = //$NON-NLS-1$
        Messages.getString(//$NON-NLS-1$
        "ImportProjectAsWizardPage.error.notATalendProject", brandingService.getShortProductName());
        fileContentStatus = new Status(IStatus.ERROR, RepositoryPlugin.PLUGIN_ID, IStatus.OK, string, null);
    } else {
        fileContentStatus = createOkStatus();
    }
    checkFieldsValue();
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) TarLeveledStructureProvider(org.eclipse.ui.internal.wizards.datatransfer.TarLeveledStructureProvider) ZipFile(java.util.zip.ZipFile) ZipLeveledStructureProvider(org.eclipse.ui.internal.wizards.datatransfer.ZipLeveledStructureProvider) ArrayList(java.util.ArrayList) TarFile(org.eclipse.ui.internal.wizards.datatransfer.TarFile) Collection(java.util.Collection) IBrandingService(org.talend.core.ui.branding.IBrandingService) ZipFile(java.util.zip.ZipFile) File(java.io.File) TarFile(org.eclipse.ui.internal.wizards.datatransfer.TarFile)

Example 48 with Status

use of org.eclipse.core.runtime.Status in project tdi-studio-se by Talend.

the class NewProjectWizardPage method checkFieldsValue.

/**
     * DOC ocarbone Comment method "checkField".
     */
protected void checkFieldsValue() {
    // Field Name
    if (nameText.getText().length() == 0) {
        // for bug TDI-6993
        technicalNameText.setText("");
        nameStatus = new Status(IStatus.ERROR, RepositoryPlugin.PLUGIN_ID, IStatus.OK, Messages.getString("NewProjectWizardPage.nameEmpty"), //$NON-NLS-1$
        null);
    } else {
        // for bug 11214
        if (!nameText.getText().endsWith(" ")) {
            //$NON-NLS-1$
            technicalNameText.setText(Project.createTechnicalName(nameText.getText()));
        }
        if (ProjectUtils.isNotValidProjectName(nameText.getText())) {
            //$NON-NLS-1$
            nameStatus = new Status(IStatus.ERROR, RepositoryPlugin.PLUGIN_ID, IStatus.OK, Messages.getString("NewProjectWizardPage.illegalCharacter"), //$NON-NLS-1$
            null);
        } else {
            if (isProjectNameAlreadyUsed(nameText.getText())) {
                nameStatus = new Status(IStatus.ERROR, RepositoryPlugin.PLUGIN_ID, IStatus.OK, Messages.getString("NewProjectWizardPage.projectNameAlredyExists"), //$NON-NLS-1$
                null);
            } else {
                nameStatus = createOkStatus();
                // Field description
                descriptionStatus = createOkStatus();
                // Combo language
                if (!languageJavaRadio.getSelection() && !languagePerlRadio.getSelection()) {
                    languageStatus = new Status(IStatus.ERROR, RepositoryPlugin.PLUGIN_ID, IStatus.OK, //$NON-NLS-1$
                    Messages.getString("NewProjectWizardPage.languageEmpty"), null);
                } else if (!languageEnable(getLanguage())) {
                    languageStatus = new Status(IStatus.ERROR, RepositoryPlugin.PLUGIN_ID, IStatus.WARNING, //$NON-NLS-1$
                    Messages.getString("NewProjectWizard.error.languageNotSupported", getLanguage()), null);
                } else {
                    languageStatus = createOkStatus();
                }
            }
        }
    }
    updatePageStatus();
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status)

Example 49 with Status

use of org.eclipse.core.runtime.Status in project tesb-studio-se by Talend.

the class Activator method copyConfigs.

private void copyConfigs() throws CoreException, IOException, URISyntaxException {
    // find ESB configuration files folder in plug-in
    URL esbConfigsFolderUrl = FileLocator.find(getBundle(), new Path("esb"), null);
    if (null == esbConfigsFolderUrl) {
        getLog().log(new Status(IStatus.WARNING, getBundle().getSymbolicName(), "cannot find ESB configuration files"));
        return;
    }
    // resolve plug-in ESB config folder URL into file protocol URL
    esbConfigsFolderUrl = FileLocator.toFileURL(esbConfigsFolderUrl);
    // create ESB configuration folder under Studio instalation
    IFileSystem fileSystem = EFS.getLocalFileSystem();
    IFileStore esbConfigsTargetFolder = fileSystem.getStore(EsbConfigUtils.getEclipseEsbFolder().toURI());
    esbConfigsTargetFolder = esbConfigsTargetFolder.mkdir(EFS.SHALLOW, null);
    // retrieve all ESB configuration files packed inside plug-in
    File fileEsbConfigFolder = new File(esbConfigsFolderUrl.getPath());
    IFileStore esbConfigsFolderStore = fileSystem.getStore(fileEsbConfigFolder.toURI());
    IFileStore[] esbConfigsFolderStoreChildren = esbConfigsFolderStore.childStores(EFS.NONE, null);
    if (0 == esbConfigsFolderStoreChildren.length) {
        getLog().log(new Status(IStatus.WARNING, getBundle().getSymbolicName(), "cannot find any ESB configuration files"));
        return;
    }
    // try to copy ESB configuration files (without overwriting)
    for (IFileStore esbConfigFileStore : esbConfigsFolderStoreChildren) {
        if (!esbConfigFileStore.fetchInfo().isDirectory()) {
            String esbConfigFileName = esbConfigFileStore.fetchInfo().getName();
            try {
                esbConfigFileStore.copy(esbConfigsTargetFolder.getChild(esbConfigFileName), EFS.NONE, null);
            } catch (CoreException e) {
                // ignore to do not overwrite possible user changes in configuration files
                return;
            }
        } else {
            String esbConfigFileName = esbConfigFileStore.fetchInfo().getName();
            if ("microservice".equals(esbConfigFileName) && PluginChecker.isTIS()) {
                try {
                    esbConfigFileStore.copy(esbConfigsTargetFolder.getChild(esbConfigFileName), EFS.NONE, null);
                } catch (CoreException e) {
                    // ignore to do not overwrite possible user changes in configuration files
                    return;
                }
            }
        }
    }
}
Also used : Path(org.eclipse.core.runtime.Path) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) IFileSystem(org.eclipse.core.filesystem.IFileSystem) IFileStore(org.eclipse.core.filesystem.IFileStore) File(java.io.File) URL(java.net.URL)

Example 50 with Status

use of org.eclipse.core.runtime.Status in project tdi-studio-se by Talend.

the class ShadowFilePreview method preview.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.preview.filedelimited.IFileDelimitedPreview#
     * preview(org.talend.repository.preview.filedelimited.ProcessDescription)
     */
public CsvArray preview(IProcessDescription description, String type) throws CoreException {
    CsvArray res = null;
    EShadowProcessType typeShadow = EShadowProcessType.valueOf(type);
    shadowProcess = new ShadowProcess<IProcessDescription>(description, typeShadow);
    try {
        res = shadowProcess.run();
    } catch (ProcessorException e) {
        Status status = new Status(Status.ERROR, RunProcessPlugin.PLUGIN_ID, Status.OK, e.getMessage(), e);
        RunProcessPlugin.getDefault().getLog().log(status);
        throw new CoreException(status);
    }
    return res;
}
Also used : Status(org.eclipse.core.runtime.Status) CsvArray(org.talend.core.utils.CsvArray) ProcessorException(org.talend.designer.runprocess.ProcessorException) CoreException(org.eclipse.core.runtime.CoreException) IProcessDescription(org.talend.core.repository.model.preview.IProcessDescription) EShadowProcessType(org.talend.designer.runprocess.shadow.ShadowProcess.EShadowProcessType)

Aggregations

Status (org.eclipse.core.runtime.Status)538 IStatus (org.eclipse.core.runtime.IStatus)513 CoreException (org.eclipse.core.runtime.CoreException)248 IOException (java.io.IOException)110 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)84 ArrayList (java.util.ArrayList)62 InvocationTargetException (java.lang.reflect.InvocationTargetException)60 IFile (org.eclipse.core.resources.IFile)54 File (java.io.File)53 MultiStatus (org.eclipse.core.runtime.MultiStatus)43 IResource (org.eclipse.core.resources.IResource)41 IPath (org.eclipse.core.runtime.IPath)41 InputStream (java.io.InputStream)36 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)34 PartInitException (org.eclipse.ui.PartInitException)32 IProject (org.eclipse.core.resources.IProject)31 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)25 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)24 SubMonitor (org.eclipse.core.runtime.SubMonitor)24 ITask (com.cubrid.common.core.task.ITask)23