Search in sources :

Example 1 with IRepositoryView

use of org.talend.repository.ui.views.IRepositoryView in project tdi-studio-se by Talend.

the class JobSettingsView method getSelection.

/*
     * (non-Javadoc)
     *
     * @see org.talend.designer.core.ui.views.properties.IJobSettingsView#getSelection()
     */
@Override
public ISelection getSelection() {
    ISVNUiProviderService service = null;
    if (PluginChecker.isSVNProviderPluginLoaded()) {
        service = (ISVNUiProviderService) GlobalServiceRegister.getDefault().getService(ISVNUiProviderService.class);
    }
    if (currentSelectedTab == null) {
        return null;
    }
    IDynamicProperty dc = currentSelectedTab.getPropertyComposite();
    if (dc instanceof ProcessVersionComposite) {
        return ((ProcessVersionComposite) dc).getSelection();
    } else if (service != null && service.isSVNHistoryComposite(dc)) {
        return service.getSVNHistorySelection(dc);
    } else if (CorePlugin.getDefault().getDiagramModelService().isInstanceOfBusinessAssignmentComposite(dc)) {
        IRepositoryView repositoryView = RepositoryManagerHelper.findRepositoryView();
        if (repositoryView != null) {
            return repositoryView.getViewer().getSelection();
        }
    }
    return null;
}
Also used : ProcessVersionComposite(org.talend.designer.core.ui.views.jobsettings.tabs.ProcessVersionComposite) IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) ISVNUiProviderService(org.talend.core.ui.services.ISVNUiProviderService) IRepositoryView(org.talend.repository.ui.views.IRepositoryView)

Example 2 with IRepositoryView

use of org.talend.repository.ui.views.IRepositoryView in project tdi-studio-se by Talend.

the class TalendImportUtil method openJob.

// private static void doSelection(List<String> itemIds) {
// List<IRepositoryNode> nodes = new ArrayList<IRepositoryNode>();
// RepositorySeekerManager repSeekerManager = RepositorySeekerManager.getInstance();
// for (String itemId : itemIds) {
// IRepositoryNode repoViewNode = repSeekerManager.searchRepoViewNode(itemId);
// if (repoViewNode != null) {
// nodes.add(repoViewNode);
// }
// }
//
// IRepositoryView repositoryView = RepositoryManagerHelper.findRepositoryView();
// repositoryView.getViewer().setSelection(new StructuredSelection(nodes));
// }
public static void openJob(String jobName) {
    if (jobName == null) {
        return;
    }
    if (isJobAlreadyOpened(jobName)) {
        return;
    }
    try {
        // can't open deleted jobs
        List<IRepositoryViewObject> repViewObjectList = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.PROCESS, false, false);
        Iterator<IRepositoryViewObject> repoViewObjectIter = repViewObjectList.iterator();
        while (repoViewObjectIter.hasNext()) {
            final IRepositoryViewObject current = repoViewObjectIter.next();
            if (jobName.equals(current.getLabel())) {
                Display.getDefault().syncExec(new Runnable() {

                    @Override
                    public void run() {
                        final List<IRepositoryNode> jobs = new ArrayList<IRepositoryNode>(1);
                        IRepositoryNode repositoryNode = RepositorySeekerManager.getInstance().searchRepoViewNode(current.getId());
                        jobs.add(repositoryNode);
                        IRepositoryView repositoryView = RepositoryManagerHelper.findRepositoryView();
                        repositoryView.getViewer().setSelection(new StructuredSelection(jobs));
                        openJobs(jobs);
                    }
                });
                break;
            }
        }
    } catch (Throwable e) {
        CommonExceptionHandler.process(e);
    }
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ArrayList(java.util.ArrayList) List(java.util.List) IRepositoryView(org.talend.repository.ui.views.IRepositoryView)

Example 3 with IRepositoryView

use of org.talend.repository.ui.views.IRepositoryView in project tdi-studio-se by Talend.

the class CreateFTPConnectionAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.ui.actions.AContextualAction#doRun()
     */
@Override
protected void doRun() {
    RepositoryNode dbConnectionNode = getCurrentRepositoryNode();
    if (isToolbar()) {
        if (dbConnectionNode != null && dbConnectionNode.getContentType() != ERepositoryObjectType.METADATA_FILE_FTP) {
            dbConnectionNode = null;
        }
        if (dbConnectionNode == null) {
            dbConnectionNode = getRepositoryNodeForDefault(ERepositoryObjectType.METADATA_FILE_FTP);
        }
    }
    RepositoryNode metadataNode = dbConnectionNode.getParent();
    if (metadataNode != null) {
        // Force focus to the repositoryView and open Metadata and DbConnection nodes
        IRepositoryView viewPart = getViewPart();
        if (viewPart != null) {
            viewPart.setFocus();
            viewPart.expand(metadataNode, true);
            viewPart.expand(dbConnectionNode, true);
        }
    }
    FTPConnection connection = null;
    IPath pathToSave = null;
    // Define the RepositoryNode, by default Metadata/DbConnection
    RepositoryNode node = dbConnectionNode;
    ISelection selection = null;
    // When the userSelection is an element of metadataNode, use it !
    if (!isToolbar()) {
        Object userSelection = ((IStructuredSelection) getSelection()).getFirstElement();
        if (userSelection instanceof RepositoryNode) {
            switch(((RepositoryNode) userSelection).getType()) {
                case REPOSITORY_ELEMENT:
                case SIMPLE_FOLDER:
                case SYSTEM_FOLDER:
                    node = (RepositoryNode) userSelection;
                    break;
            }
        }
        selection = getSelection();
    }
    boolean creation = false;
    // Define the repositoryObject DatabaseConnection and his pathToSave
    switch(node.getType()) {
        case REPOSITORY_ELEMENT:
            // pathToSave = null;
            connection = (FTPConnection) ((ConnectionItem) node.getObject().getProperty().getItem()).getConnection();
            creation = false;
            break;
        case SIMPLE_FOLDER:
            pathToSave = RepositoryNodeUtilities.getPath(node);
            connection = ConnectionFactory.eINSTANCE.createFTPConnection();
            creation = true;
            break;
        case SYSTEM_FOLDER:
            //$NON-NLS-1$
            pathToSave = new Path("");
            connection = ConnectionFactory.eINSTANCE.createFTPConnection();
            creation = true;
            break;
    }
    // Init the content of the Wizard
    init(node);
    FTPWizard ftpWizard;
    if (isToolbar()) {
        ftpWizard = new FTPWizard(PlatformUI.getWorkbench(), creation, node, getExistingNames());
        ftpWizard.setToolBar(true);
    } else {
        ftpWizard = new FTPWizard(PlatformUI.getWorkbench(), creation, selection, getExistingNames());
    }
    // Open the Wizard
    WizardDialog wizardDialog = new WizardDialog(Display.getCurrent().getActiveShell(), ftpWizard);
    wizardDialog.setPageSize(700, 550);
    wizardDialog.create();
    wizardDialog.open();
    IRepositoryView view = getViewPart();
    if (view != null) {
        view.expand(dbConnectionNode, true);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) FTPConnectionItem(org.talend.core.model.properties.FTPConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryView(org.talend.repository.ui.views.IRepositoryView) FTPConnection(org.talend.core.model.metadata.builder.connection.FTPConnection) FTPWizard(org.talend.repository.ftp.ui.wizards.FTPWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 4 with IRepositoryView

use of org.talend.repository.ui.views.IRepositoryView in project tdi-studio-se by Talend.

the class AbstractContentProviderTest method setup.

@BeforeClass
public static void setup() {
    IRepositoryView repoView = RepositoryManagerHelper.findRepositoryView();
    if (repoView == null) {
        return;
    }
    assertNotNull("Must open the DI repository view to test", repoView);
    assertEquals("Must test in DI repository view", IRepositoryView.VIEW_ID, repoView.getViewSite().getId());
    navContentService = NavigatorContentServiceFactory.INSTANCE.createContentService(IRepositoryView.VIEW_ID, repoView.getViewer());
    assertNotNull(navContentService);
    contentProvider = navContentService.createCommonContentProvider();
    assertNotNull(contentProvider);
}
Also used : IRepositoryView(org.talend.repository.ui.views.IRepositoryView) BeforeClass(org.junit.BeforeClass)

Example 5 with IRepositoryView

use of org.talend.repository.ui.views.IRepositoryView in project tdi-studio-se by Talend.

the class EditPropertiesAction method processRename.

protected void processRename(IRepositoryNode node, String originalName) {
    try {
        IRunProcessService runProcessService = CorePlugin.getDefault().getRunProcessService();
        ITalendProcessJavaProject talendProcessJavaProject = runProcessService.getTalendProcessJavaProject();
        if (talendProcessJavaProject == null) {
            return;
        }
        IFolder srcFolder = talendProcessJavaProject.getSrcFolder();
        IPackageFragmentRoot root = talendProcessJavaProject.getJavaProject().getPackageFragmentRoot(srcFolder);
        // add for bug TDI-24379 on August 23, 2013.
        IFolder srcInterFolder = srcFolder.getFolder(JavaUtils.JAVA_INTERNAL_DIRECTORY);
        if (srcInterFolder.exists()) {
            File file = new File(srcInterFolder.getLocationURI());
            for (File f : file.listFiles()) {
                if (f.isFile()) {
                    f.delete();
                }
            }
        }
        // qli modified to fix the bug 5400 and 6185.
        // update for fix [TESB-6784]
        IPackageFragment routinesPkg = getPackageFragment(root, node);
        // ICompilationUnit unit = routinesPkg.getCompilationUnit(originalName +
        // SuffixConstants.SUFFIX_STRING_java);
        //$NON-NLS-1$
        ICompilationUnit unit = routinesPkg.getCompilationUnit(originalName + ".java");
        if (unit == null) {
            return;
        }
        String newName = node.getObject().getProperty().getLabel();
        JavaRenameProcessor processor = new RenameCompilationUnitProcessor(unit);
        // processor.setNewElementName(newName + SuffixConstants.SUFFIX_STRING_java);
        //$NON-NLS-1$
        processor.setNewElementName(newName + ".java");
        RenameRefactoring ref = new RenameRefactoring(processor);
        final PerformRefactoringOperation operation = new PerformRefactoringOperation(ref, CheckConditionsOperation.ALL_CONDITIONS);
        IRunnableWithProgress r = new IRunnableWithProgress() {

            @Override
            public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                Display.getDefault().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        try {
                            operation.run(monitor);
                        } catch (CoreException e) {
                            ExceptionHandler.process(e);
                        }
                    }
                });
            }
        };
        PlatformUI.getWorkbench().getProgressService().run(true, true, r);
        RefactoringStatus conditionStatus = operation.getConditionStatus();
        if (conditionStatus.hasError()) {
            //$NON-NLS-1$
            String errorMessage = Messages.getString("EditPropertiesAction.renameError", unit.getElementName(), newName);
            RefactoringStatusEntry[] entries = conditionStatus.getEntries();
            for (RefactoringStatusEntry entry : entries) {
                //$NON-NLS-1$
                errorMessage += "\n>>>" + entry.getMessage();
            }
            Shell shell = null;
            IRepositoryView viewPart = getViewPart();
            if (viewPart != null) {
                shell = viewPart.getViewSite().getShell();
            } else {
                shell = Display.getCurrent().getActiveShell();
            }
            //$NON-NLS-1$
            MessageDialog.openError(shell, Messages.getString("EditPropertiesAction.warning"), errorMessage);
            return;
        }
        // ICompilationUnit newUnit = routinesPkg.getCompilationUnit(newName + SuffixConstants.SUFFIX_STRING_java);
        //$NON-NLS-1$
        ICompilationUnit newUnit = routinesPkg.getCompilationUnit(newName + ".java");
        if (newUnit == null) {
            return;
        }
        RoutineItem item = (RoutineItem) node.getObject().getProperty().getItem();
        IFile javaFile = (IFile) newUnit.getAdapter(IResource.class);
        try {
            ByteArray byteArray = item.getContent();
            byteArray.setInnerContentFromFile(javaFile);
            IRepositoryService service = CorePlugin.getDefault().getRepositoryService();
            IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
            repFactory.save(item);
        } catch (Exception e) {
            // e.printStackTrace();
            ExceptionHandler.process(e);
        }
    } catch (Exception e) {
        // e.printStackTrace();
        ExceptionHandler.process(e);
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) PerformRefactoringOperation(org.eclipse.ltk.core.refactoring.PerformRefactoringOperation) IRepositoryView(org.talend.repository.ui.views.IRepositoryView) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IRepositoryService(org.talend.repository.model.IRepositoryService) Shell(org.eclipse.swt.widgets.Shell) ByteArray(org.talend.core.model.properties.ByteArray) JavaRenameProcessor(org.eclipse.jdt.internal.corext.refactoring.rename.JavaRenameProcessor) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) IPackageFragment(org.eclipse.jdt.core.IPackageFragment) RenameRefactoring(org.eclipse.ltk.core.refactoring.participants.RenameRefactoring) RefactoringStatusEntry(org.eclipse.ltk.core.refactoring.RefactoringStatusEntry) RoutineItem(org.talend.core.model.properties.RoutineItem) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) RenameCompilationUnitProcessor(org.eclipse.jdt.internal.corext.refactoring.rename.RenameCompilationUnitProcessor) CoreException(org.eclipse.core.runtime.CoreException) IFile(org.eclipse.core.resources.IFile) File(java.io.File) IResource(org.eclipse.core.resources.IResource) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

IRepositoryView (org.talend.repository.ui.views.IRepositoryView)20 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)11 RepositoryNode (org.talend.repository.model.RepositoryNode)9 TreeViewer (org.eclipse.jface.viewers.TreeViewer)7 IRepositoryNode (org.talend.repository.model.IRepositoryNode)7 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)6 IPerspectiveDescriptor (org.eclipse.ui.IPerspectiveDescriptor)5 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)5 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)5 ISelection (org.eclipse.jface.viewers.ISelection)4 StructuredViewer (org.eclipse.jface.viewers.StructuredViewer)4 Shell (org.eclipse.swt.widgets.Shell)4 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)4 WorkbenchException (org.eclipse.ui.WorkbenchException)4 WizardDialog (org.eclipse.jface.wizard.WizardDialog)3 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)3 ArrayList (java.util.ArrayList)2 ConnectionItem (org.talend.core.model.properties.ConnectionItem)2 RoutineItem (org.talend.core.model.properties.RoutineItem)2 File (java.io.File)1