Search in sources :

Example 1 with ImportDemoProjectItemsWizard

use of org.talend.repository.ui.actions.importproject.ImportDemoProjectItemsWizard 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)

Aggregations

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 RepositoryNode (org.talend.repository.model.RepositoryNode)1 DemoProjectBean (org.talend.repository.ui.actions.importproject.DemoProjectBean)1 ImportDemoProjectItemsWizard (org.talend.repository.ui.actions.importproject.ImportDemoProjectItemsWizard)1 IRepositoryView (org.talend.repository.ui.views.IRepositoryView)1