Search in sources :

Example 1 with DemoProjectBean

use of org.talend.repository.ui.actions.importproject.DemoProjectBean in project tdi-studio-se by Talend.

the class ImportDemoItemAction method doRun.

@Override
protected void doRun() {
    if (ProxyRepositoryFactory.getInstance().isUserReadOnlyOnCurrentProject()) {
        return;
    }
    // qli modified to fix the bug "6999".
    IRepositoryView repositoryView = RepositoryManagerHelper.findRepositoryView();
    if (repositoryView != null && repositoryView.getViewer() instanceof TreeViewer) {
        ((TreeViewer) repositoryView.getViewer()).getTree().setFocus();
    }
    ISelection selection = this.getSelection();
    RepositoryNode rNode = null;
    if (toolbarAction) {
        if (repositoryView != null) {
            selection = repositoryView.getViewer().getSelection();
        }
    } else if ((selection instanceof IStructuredSelection) && (((IStructuredSelection) selection).getFirstElement() instanceof RepositoryNode)) {
        Object o = ((IStructuredSelection) selection).getFirstElement();
        if (o instanceof RepositoryNode) {
            rNode = (RepositoryNode) o;
        }
    }
    final List<DemoProjectBean> demoProjectList = ImportProjectsUtilities.getAllDemoProjects();
    ImportDemoProjectItemsWizard wizard = new ImportDemoProjectItemsWizard(demoProjectList);
    wizard.setWindowTitle(IMPORT_DEMO);
    wizard.init(PlatformUI.getWorkbench(), (IStructuredSelection) selection);
    Shell activeShell = Display.getCurrent().getActiveShell();
    WizardDialog dialog = new WizardDialog(activeShell, wizard);
    dialog.open();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) DemoProjectBean(org.talend.repository.ui.actions.importproject.DemoProjectBean) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IRepositoryView(org.talend.repository.ui.views.IRepositoryView) RepositoryNode(org.talend.repository.model.RepositoryNode) ImportDemoProjectItemsWizard(org.talend.repository.ui.actions.importproject.ImportDemoProjectItemsWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 2 with DemoProjectBean

use of org.talend.repository.ui.actions.importproject.DemoProjectBean in project tdi-studio-se by Talend.

the class DemoImportTestUtil method getResourceManagers.

public static List<ResourcesManager> getResourceManagers(List<DemoProjectBean> checkedProjectBean) {
    List<ResourcesManager> resManagers = new ArrayList<ResourcesManager>();
    try {
        for (DemoProjectBean pro : checkedProjectBean) {
            ResourcesManager resManager = null;
            Bundle bundle = Platform.getBundle(pro.getPluginId());
            URL demoURL = FileLocator.find(bundle, new Path(pro.getDemoProjectFilePath()), null);
            demoURL = FileLocator.toFileURL(demoURL);
            String filePath = new Path(demoURL.getFile()).toOSString();
            File srcFile = new File(filePath);
            FileResourcesUnityManager fileUnityManager = ResourcesManagerFactory.getInstance().createFileUnityManager(srcFile);
            resManager = fileUnityManager.doUnify();
            if (resManager != null) {
                resManagers.add(resManager);
            }
        }
    } catch (ZipException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (TarException e) {
        e.printStackTrace();
    }
    return resManagers;
}
Also used : Path(org.eclipse.core.runtime.Path) TarException(org.eclipse.ui.internal.wizards.datatransfer.TarException) Bundle(org.osgi.framework.Bundle) ArrayList(java.util.ArrayList) FileNotFoundException(java.io.FileNotFoundException) FileResourcesUnityManager(org.talend.repository.items.importexport.ui.managers.FileResourcesUnityManager) ZipException(java.util.zip.ZipException) IOException(java.io.IOException) URL(java.net.URL) DemoProjectBean(org.talend.repository.ui.actions.importproject.DemoProjectBean) ResourcesManager(org.talend.repository.items.importexport.manager.ResourcesManager) File(java.io.File)

Aggregations

DemoProjectBean (org.talend.repository.ui.actions.importproject.DemoProjectBean)2 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 ZipException (java.util.zip.ZipException)1 Path (org.eclipse.core.runtime.Path)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 Shell (org.eclipse.swt.widgets.Shell)1 TarException (org.eclipse.ui.internal.wizards.datatransfer.TarException)1 Bundle (org.osgi.framework.Bundle)1 ResourcesManager (org.talend.repository.items.importexport.manager.ResourcesManager)1 FileResourcesUnityManager (org.talend.repository.items.importexport.ui.managers.FileResourcesUnityManager)1 RepositoryNode (org.talend.repository.model.RepositoryNode)1 ImportDemoProjectItemsWizard (org.talend.repository.ui.actions.importproject.ImportDemoProjectItemsWizard)1 IRepositoryView (org.talend.repository.ui.views.IRepositoryView)1