Search in sources :

Example 41 with Project

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

the class OpenRepositoryJobHierarchyAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
protected void doRun() {
    ISelection selection = getSelection();
    Object obj = ((IStructuredSelection) selection).getFirstElement();
    RepositoryNode node = (RepositoryNode) obj;
    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
    if (node.getObject() instanceof IRepositoryObject) {
        IRepositoryObject iobject = (IRepositoryObject) node.getObject();
        iobject.setProperty(updatedProperty);
    }
    Assert.isTrue(property.getItem() instanceof ProcessItem);
    // TODO should use a fake Process here to replace the real Process.
    // Process loadedProcess = new Process(property);
    // loadedProcess.loadXmlFile();
    IDesignerCoreService designerCoreService = CorePlugin.getDefault().getDesignerCoreService();
    Process loadedProcess = (Process) designerCoreService.getProcessFromProcessItem((ProcessItem) updatedProperty.getItem());
    OpenJobHierarchyAction openAction = new OpenJobHierarchyAction(this.getViewPart());
    openAction.run(loadedProcess);
}
Also used : Project(org.talend.core.model.general.Project) ProcessItem(org.talend.core.model.properties.ProcessItem) ISelection(org.eclipse.jface.viewers.ISelection) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryObject(org.talend.core.model.repository.IRepositoryObject) Process(org.talend.designer.core.ui.editor.process.Process) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) RepositoryNode(org.talend.repository.model.RepositoryNode) Property(org.talend.core.model.properties.Property) IRepositoryObject(org.talend.core.model.repository.IRepositoryObject)

Example 42 with Project

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

the class JSONShadowProcess method getTmpFolderPath.

private IPath getTmpFolderPath() {
    Project project = ProjectManager.getInstance().getCurrentProject();
    IProject physProject;
    //$NON-NLS-1$
    String tmpFolder = System.getProperty("user.dir");
    try {
        physProject = ResourceModelUtils.getProject(project);
        //$NON-NLS-1$
        tmpFolder = physProject.getFolder("temp").getLocation().toPortableString();
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
    //$NON-NLS-1$
    tmpFolder = tmpFolder + "/preview";
    return new Path(tmpFolder);
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) IProject(org.eclipse.core.resources.IProject) ProcessorException(org.talend.designer.runprocess.ProcessorException) IOException(java.io.IOException)

Example 43 with Project

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

the class JSONFileStep1Form method initFileContent.

private void initFileContent() {
    byte[] bytes = getConnection().getFileContent();
    Project project = ProjectManager.getInstance().getCurrentProject();
    IProject fsProject = null;
    try {
        fsProject = ResourceUtils.getProject(project);
    } catch (PersistenceException e2) {
        ExceptionHandler.process(e2);
    }
    if (fsProject == null) {
        return;
    }
    //$NON-NLS-1$
    String temPath = fsProject.getLocationURI().getPath() + File.separator + "temp";
    //$NON-NLS-1$
    String fileName = "";
    if (getConnection().getJSONFilePath() != null) {
        fileName = "tempJSONFile" + '.' + "json";
    }
    File temfile = new File(temPath + File.separator + fileName);
    if (!temfile.exists()) {
        try {
            temfile.createNewFile();
        } catch (IOException e) {
            ExceptionHandler.process(e);
        }
    }
    FileOutputStream outStream;
    try {
        outStream = new FileOutputStream(temfile);
        outStream.write(bytes);
        outStream.close();
    } catch (FileNotFoundException e1) {
        ExceptionHandler.process(e1);
    } catch (IOException e) {
        ExceptionHandler.process(e);
    }
    tempJSONXsdPath = temfile.getPath();
    if (isContextMode()) {
        ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(connectionItem.getConnection());
        tempJSONXsdPath = TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType, tempJSONXsdPath));
    }
// valid = this.treePopulator.populateTree(tempJSONXsdPath, treeNode);
// temfile.delete();
}
Also used : Project(org.talend.core.model.general.Project) IProject(org.eclipse.core.resources.IProject) ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) FileOutputStream(java.io.FileOutputStream) PersistenceException(org.talend.commons.exception.PersistenceException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) File(java.io.File) IProject(org.eclipse.core.resources.IProject)

Example 44 with Project

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

the class AbstractJSONFileStepForm method getXSDJSONFilePath.

protected String getXSDJSONFilePath() {
    if (getConnection().getFileContent() == null || getConnection().getFileContent().length == 0) {
        return null;
    }
    byte[] bytes = getConnection().getFileContent();
    Project project = ProjectManager.getInstance().getCurrentProject();
    IProject fsProject = null;
    try {
        fsProject = ResourceUtils.getProject(project);
    } catch (PersistenceException e2) {
        ExceptionHandler.process(e2);
    }
    if (fsProject == null) {
        return null;
    }
    //$NON-NLS-1$
    String temPath = fsProject.getLocationURI().getPath() + File.separator + "temp";
    //$NON-NLS-1$
    String fileName = "";
    if (getConnection().getJSONFilePath() != null) {
        fileName = "tempJSONFile" + '.' + "json";
    }
    File temfile = new File(temPath + File.separator + fileName);
    if (!temfile.exists()) {
        try {
            temfile.createNewFile();
        } catch (IOException e) {
            ExceptionHandler.process(e);
        }
    }
    FileOutputStream outStream;
    try {
        outStream = new FileOutputStream(temfile);
        outStream.write(bytes);
        outStream.close();
    } catch (FileNotFoundException e1) {
        ExceptionHandler.process(e1);
    } catch (IOException e) {
        ExceptionHandler.process(e);
    }
    String tempJSONXsdPath = temfile.getPath();
    if (isContextMode()) {
        ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(connectionItem.getConnection());
        tempJSONXsdPath = TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType, tempJSONXsdPath));
    }
    return tempJSONXsdPath;
}
Also used : IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) FileOutputStream(java.io.FileOutputStream) PersistenceException(org.talend.commons.exception.PersistenceException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) File(java.io.File) IProject(org.eclipse.core.resources.IProject)

Example 45 with Project

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

the class ExchangeLoginTask method run.

/* (non-Javadoc)
     * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
     */
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    if (!PluginChecker.isExchangeSystemLoaded() || TalendPropertiesUtil.isHideExchange()) {
        return;
    }
    Job job = new //$NON-NLS-1$
    Job(//$NON-NLS-1$
    "Check Exchange") {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            // check for Talendforge
            IPreferenceStore prefStore = PlatformUI.getPreferenceStore();
            boolean checkTisVersion = prefStore.getBoolean(ITalendCorePrefConstants.EXCHANGE_CHECK_TIS_VERSION);
            IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
            if (!checkTisVersion && brandingService.isPoweredbyTalend()) {
                int count = prefStore.getInt(TalendForgeDialog.LOGINCOUNT);
                if (count < 0) {
                    count = 1;
                }
                ExchangeUser exchangeUser = ProjectManager.getInstance().getCurrentProject().getExchangeUser();
                //$NON-NLS-1$
                boolean isExchangeLogon = exchangeUser.getLogin() != null && !exchangeUser.getLogin().equals("");
                boolean isUserPassRight = true;
                if (isExchangeLogon) {
                    IExchangeService service = (IExchangeService) GlobalServiceRegister.getDefault().getService(IExchangeService.class);
                    if (service.checkUserAndPass(exchangeUser.getUsername(), exchangeUser.getPassword()) != null) {
                        isUserPassRight = false;
                    }
                }
                if (!isExchangeLogon || !isUserPassRight) {
                    if ((count + 1) % 4 == 0) {
                        // if (Platform.getOS().equals(Platform.OS_LINUX)) {
                        // TalendForgeDialog tfDialog = new TalendForgeDialog(this.getShell(), project);
                        // tfDialog.open();
                        // } else {
                        Display.getDefault().asyncExec(new Runnable() {

                            @Override
                            public void run() {
                                Project project = ProjectManager.getInstance().getCurrentProject();
                                String userEmail = null;
                                if (project.getAuthor() != null) {
                                    userEmail = project.getAuthor().getLogin();
                                }
                                TalendForgeDialog tfDialog = new TalendForgeDialog(DisplayUtils.getDefaultShell(), userEmail);
                                tfDialog.setBlockOnOpen(true);
                                tfDialog.open();
                            }
                        });
                    }
                    prefStore.setValue(TalendForgeDialog.LOGINCOUNT, count + 1);
                }
            }
            return org.eclipse.core.runtime.Status.OK_STATUS;
        }
    };
    job.setSystem(true);
    job.setUser(false);
    job.setPriority(Job.INTERACTIVE);
    // start as soon as possible
    job.schedule();
}
Also used : IBrandingService(org.talend.core.ui.branding.IBrandingService) ExchangeUser(org.talend.core.model.properties.ExchangeUser) Project(org.talend.core.model.general.Project) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IExchangeService(org.talend.core.service.IExchangeService) Job(org.eclipse.core.runtime.jobs.Job) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) TalendForgeDialog(org.talend.registration.wizards.register.TalendForgeDialog)

Aggregations

Project (org.talend.core.model.general.Project)160 IProject (org.eclipse.core.resources.IProject)77 PersistenceException (org.talend.commons.exception.PersistenceException)73 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)34 ArrayList (java.util.ArrayList)24 IFolder (org.eclipse.core.resources.IFolder)23 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)23 Property (org.talend.core.model.properties.Property)21 File (java.io.File)20 Path (org.eclipse.core.runtime.Path)19 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)19 IPath (org.eclipse.core.runtime.IPath)18 IOException (java.io.IOException)17 RepositoryContext (org.talend.core.context.RepositoryContext)16 CoreException (org.eclipse.core.runtime.CoreException)14 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)14 IFile (org.eclipse.core.resources.IFile)13 Item (org.talend.core.model.properties.Item)13 User (org.talend.core.model.properties.User)13 Test (org.junit.Test)12