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;
}
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);
}
}
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);
}
}
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);
}
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);
}
}
Aggregations