Search in sources :

Example 86 with Project

use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.

the class ExportProjectsAsAction method clearExternalLibraries.

/**
     * DOC zwang Comment method "clearExternalLibraries".
     */
private void clearExternalLibraries() {
    List<IResource> resourcesToDelete = new ArrayList<IResource>();
    IResource[] resourceArray = null;
    try {
        IProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
        // fix for bug 15454
        Project[] projects = repositoryFactory.readProject(true);
        for (Project project : projects) {
            IProject fsProject = ResourceUtils.getProject(project);
            IFolder libJavaFolder = fsProject.getFolder(ExportProjectsAsAction.LIB);
            if (!libJavaFolder.exists()) {
                continue;
            }
            // final DeleteResourcesOperation operation = new DeleteResourcesOperation(new IResource[] {
            // libJavaFolder },
            // IDEWorkbenchMessages.DeleteResourceAction_operationLabel, true);
            final DeleteResourcesOperation operation = new DeleteResourcesOperation(new IResource[] { libJavaFolder }, Messages.getString("IDEWorkbenchMessages.DeleteResourceAction_operationLabel"), //$NON-NLS-1$
            true);
            PlatformUI.getWorkbench().getOperationSupport().getOperationHistory().execute(operation, null, WorkspaceUndoUtil.getUIInfoAdapter(window.getShell()));
        }
    } catch (Exception e) {
        // e.printStackTrace();
        ExceptionHandler.process(e);
    }
}
Also used : IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) ArrayList(java.util.ArrayList) IResource(org.eclipse.core.resources.IResource) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) IProject(org.eclipse.core.resources.IProject) DeleteResourcesOperation(org.eclipse.ui.ide.undo.DeleteResourcesOperation) CoreException(org.eclipse.core.runtime.CoreException) ExecutionException(org.eclipse.core.commands.ExecutionException) PersistenceException(org.talend.commons.exception.PersistenceException) IFolder(org.eclipse.core.resources.IFolder)

Example 87 with Project

use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.

the class ExportProjectsAsAction method initializeExternalLibraries.

/**
     * DOC bqian Comment method "test".
     */
private void initializeExternalLibraries() {
    initializeLibPath();
    // final InputStream initialContents = null;
    final Map<Project, List<LinkTargetStore>> map = getProjectAndRelatedLinks();
    IRunnableWithProgress op = new IRunnableWithProgress() {

        @Override
        public void run(IProgressMonitor monitor) {
            Set<Project> projects = map.keySet();
            //$NON-NLS-1$
            monitor.beginTask(Messages.getString("ExportProjectsAsAction.createLiberariesLink"), projects.size());
            for (Project project : projects) {
                //$NON-NLS-1$
                monitor.setTaskName(Messages.getString("ExportProjectsAsAction.processProject") + project.getLabel());
                List<LinkTargetStore> links = map.get(project);
                for (LinkTargetStore store : links) {
                    // CreateFileOperation op = new CreateFileOperation(store.file, store.uri, null,
                    // IDEWorkbenchMessages.WizardNewFileCreationPage_title);
                    CreateFileOperation op = new CreateFileOperation(store.file, store.uri, null, //$NON-NLS-1$
                    Messages.getString("IDEWorkbenchMessages.WizardNewFileCreationPage_title"));
                    try {
                        PlatformUI.getWorkbench().getOperationSupport().getOperationHistory().execute(op, monitor, WorkspaceUndoUtil.getUIInfoAdapter(window.getShell()));
                    } catch (final ExecutionException e) {
                        ExceptionHandler.process(e);
                    }
                }
                monitor.worked(1);
            }
            monitor.done();
        }
    };
    try {
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().run(true, true, op);
    } catch (Exception e) {
        // e.printStackTrace();
        ExceptionHandler.process(e);
    }
}
Also used : IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CreateFileOperation(org.eclipse.ui.ide.undo.CreateFileOperation) ArrayList(java.util.ArrayList) List(java.util.List) ExecutionException(org.eclipse.core.commands.ExecutionException) CoreException(org.eclipse.core.runtime.CoreException) ExecutionException(org.eclipse.core.commands.ExecutionException) PersistenceException(org.talend.commons.exception.PersistenceException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 88 with Project

use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.

the class SelectDeleteProjectDialog method getProjectItem.

private List<Project> getProjectItem() {
    if (login) {
        List<Project> projectList = new ArrayList<Project>();
        if (projectItemList != null && !projectItemList.isEmpty()) {
            Iterator<Object> iter = projectItemList.iterator();
            while (iter.hasNext()) {
                Object project = iter.next();
                if (project instanceof Project) {
                    projectList.add((Project) project);
                }
            }
        }
        return projectList;
    }
    if (!projects.isEmpty()) {
        return projects;
    }
    ProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
    Project[] projects = null;
    try {
        projects = repositoryFactory.readProject();
    } catch (PersistenceException e) {
        CommonExceptionHandler.process(e);
    } catch (BusinessException e) {
        CommonExceptionHandler.process(e);
    }
    for (Project p : projects) {
        this.projects.add(p);
    }
    if (projects != null) {
        return this.projects;
    }
    return Collections.emptyList();
}
Also used : IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) BusinessException(org.talend.commons.exception.BusinessException) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) ArrayList(java.util.ArrayList) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 89 with Project

use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.

the class DBTreeProvider method getMetadataConnection.

/**
     * @return MetadataConnection
     */
@SuppressWarnings("unchecked")
private Container getMetadataConnection() {
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    ProjectManager pManager = ProjectManager.getInstance();
    Container container = null;
    try {
        container = factory.getMetadata(pManager.getCurrentProject(), ERepositoryObjectType.METADATA_CONNECTIONS);
        pManager.retrieveReferencedProjects();
        for (Project p : pManager.getAllReferencedProjects()) {
            RootContainer rContainer = factory.getMetadata(p, ERepositoryObjectType.METADATA_CONNECTIONS);
            if (container == null) {
                container = rContainer;
            } else if (rContainer != null) {
                Iterator iterator = rContainer.absoluteKeySet().iterator();
                while (iterator.hasNext()) {
                    Object id = iterator.next();
                    container.addMember(id, rContainer.getAbsoluteMember(id));
                }
            }
        }
    } catch (PersistenceException e) {
        //$NON-NLS-1$
        SqlBuilderPlugin.log(Messages.getString("DBTreeProvider.logMessage"), e);
    } catch (BusinessException e) {
        //$NON-NLS-1$
        SqlBuilderPlugin.log(Messages.getString("DBTreeProvider.logMessage"), e);
    }
    return container;
}
Also used : Project(org.talend.core.model.general.Project) Container(org.talend.commons.utils.data.container.Container) RootContainer(org.talend.commons.utils.data.container.RootContainer) BusinessException(org.talend.commons.exception.BusinessException) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) Iterator(java.util.Iterator) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) RootContainer(org.talend.commons.utils.data.container.RootContainer) ProjectManager(org.talend.repository.ProjectManager)

Example 90 with Project

use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.

the class ReadSqlpatternAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
protected void doRun() {
    RepositoryNode node = (RepositoryNode) ((IStructuredSelection) getSelection()).getFirstElement();
    Property property = (Property) node.getObject().getProperty();
    Property updatedProperty = null;
    try {
        updatedProperty = ProxyRepositoryFactory.getInstance().getLastVersion(new Project(ProjectManager.getInstance().getProject(property.getItem())), property.getId()).getProperty();
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
    // update the property of the node repository object
    // node.getObject().setProperty(updatedProperty);
    SQLPatternItem sqlpatternItem = (SQLPatternItem) node.getObject().getProperty().getItem();
    try {
        openSQLPatternEditor(sqlpatternItem, true);
    } catch (PartInitException e) {
        MessageBoxExceptionHandler.process(e);
    } catch (SystemException e) {
        MessageBoxExceptionHandler.process(e);
    }
}
Also used : Project(org.talend.core.model.general.Project) SystemException(org.talend.commons.exception.SystemException) PersistenceException(org.talend.commons.exception.PersistenceException) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) PartInitException(org.eclipse.ui.PartInitException) RepositoryNode(org.talend.repository.model.RepositoryNode) Property(org.talend.core.model.properties.Property)

Aggregations

Project (org.talend.core.model.general.Project)94 PersistenceException (org.talend.commons.exception.PersistenceException)47 IProject (org.eclipse.core.resources.IProject)38 File (java.io.File)18 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)18 ArrayList (java.util.ArrayList)17 IOException (java.io.IOException)13 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)13 RepositoryContext (org.talend.core.context.RepositoryContext)12 Property (org.talend.core.model.properties.Property)12 CoreException (org.eclipse.core.runtime.CoreException)10 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)10 List (java.util.List)9 IFolder (org.eclipse.core.resources.IFolder)8 Path (org.eclipse.core.runtime.Path)8 SystemException (org.talend.commons.exception.SystemException)8 JSONException (org.talend.utils.json.JSONException)8 InvocationTargetException (java.lang.reflect.InvocationTargetException)7 ConnectionBean (org.talend.core.model.general.ConnectionBean)7 ITalendProcessJavaProject (org.talend.core.runtime.process.ITalendProcessJavaProject)7