use of org.eclipse.jface.viewers.ISelection in project tdi-studio-se by Talend.
the class SWTResourcesPage method createSashFormControls.
/*
* @see AbstractSashForm#createSashFormControls(SashForm, IActionBars)
*/
@Override
protected void createSashFormControls(SashForm sashForm, IActionBars actionBars) {
resourceFilteredTree = new SWTResourceFilteredTree(sashForm, actionBars);
TreeViewer resourceViewer = resourceFilteredTree.getViewer();
resourceViewer.setContentProvider(new SWTResourceContentProvider(resourceViewer));
resourceViewer.setLabelProvider(new SWTResourceLabelProvider());
resourceViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
if (selection.isEmpty()) {
selection = null;
}
stackTraceViewer.setInput(selection);
}
});
stackTraceViewer = new StackTraceViewer(sashForm, actionBars);
}
use of org.eclipse.jface.viewers.ISelection 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.eclipse.jface.viewers.ISelection in project tdi-studio-se by Talend.
the class TestComposite method installListener.
private void installListener() {
buttonAddVar.addMouseListener(new MouseAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
*/
@Override
public void mouseUp(MouseEvent e) {
List<Variable> input = (List<Variable>) variableTableViewer.getInput();
input.add(new Variable(input.size()));
variableTableViewer.refresh();
}
});
buttonRemoveVar.addMouseListener(new MouseAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
*/
@Override
public void mouseUp(MouseEvent e) {
ISelection selection = variableTableViewer.getSelection();
List<Variable> list = ((List<Variable>) variableTableViewer.getInput());
if (!selection.isEmpty() && selection instanceof StructuredSelection) {
Object[] vars = ((StructuredSelection) selection).toArray();
for (Object var : vars) {
list.remove(var);
variableTableViewer.refresh();
}
} else if (!list.isEmpty()) {
list.remove(list.size() - 1);
variableTableViewer.refresh();
}
}
});
testButton.addMouseListener(new MouseAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
*/
@Override
public void mouseUp(MouseEvent e) {
new ExpressionTestMain(CategoryComposite.getSelectedFunction(), testResultText);
}
});
clearButton.addMouseListener(new MouseAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
*/
@Override
public void mouseUp(MouseEvent e) {
//$NON-NLS-1$
testResultText.setText("");
}
});
}
use of org.eclipse.jface.viewers.ISelection in project tesb-studio-se by Talend.
the class CreateNewJobAction method getSelectedRepositoryNode.
private RepositoryNode getSelectedRepositoryNode() {
ISelection selection = getSelection();
if (selection == null) {
return null;
}
Object obj = ((IStructuredSelection) selection).getFirstElement();
return (RepositoryNode) obj;
}
use of org.eclipse.jface.viewers.ISelection in project tesb-studio-se by Talend.
the class OpenJobAction method init.
@Override
public void init(TreeViewer viewer, IStructuredSelection selection) {
if (selection.size() != 1) {
setEnabled(false);
return;
}
IRepositoryNode node = (IRepositoryNode) selection.getFirstElement();
if (!ERepositoryObjectType.SERVICESOPERATION.equals((ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE)) || !WSDLUtils.isOperationInBinding(node)) {
// not enabled if the operation doesn't define in binding
setEnabled(false);
return;
}
String jobId = getReferenceJobId(node);
if (jobId == null) {
setEnabled(false);
return;
}
IRepositoryNode repoNode = RepositorySeekerManager.getInstance().searchRepoViewNode(jobId, false);
jobNode = repoNode == null ? null : (RepositoryNode) repoNode;
if (jobNode == null) {
removeReferenecJobId(node);
setEnabled(false);
return;
}
final IStructuredSelection jobSelection = new StructuredSelection(jobNode);
setSpecialSelection(new ISelectionProvider() {
public void setSelection(ISelection arg0) {
}
public void removeSelectionChangedListener(ISelectionChangedListener arg0) {
}
public ISelection getSelection() {
return jobSelection;
}
public void addSelectionChangedListener(ISelectionChangedListener arg0) {
}
});
super.init(viewer, jobSelection);
}
Aggregations