use of org.eclipse.jface.viewers.IStructuredSelection in project tdi-studio-se by Talend.
the class AttributeSelectionDialog method okPressed.
/*
* @see Dialog#okPressed()
*/
@Override
protected void okPressed() {
ISelection selection = viewer.getSelection();
if (!(selection instanceof IStructuredSelection)) {
return;
}
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
for (Object item : structuredSelection.toArray()) {
if (!(item instanceof AttributeNode)) {
continue;
}
AttributeNode node = (AttributeNode) item;
MBeanAttribute mBeanAttribute = new MBeanAttribute(node.getObjectName(), node.getQualifiedName(), node.getRgb());
selectedAttributes.add(mBeanAttribute);
}
super.okPressed();
}
use of org.eclipse.jface.viewers.IStructuredSelection in project tdi-studio-se by Talend.
the class AttributeSelectionDialog method createMBeanViewer.
/**
* Creates the MBean viewer.
*
* @param parent The parent composite
*/
private void createMBeanViewer(Composite parent) {
Composite composite = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout(3, false);
layout.marginWidth = 0;
layout.marginHeight = 0;
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
viewer = new MyFilteredTree(composite).getViewer();
AttributeContentProvider mBeanContentProvider = new AttributeContentProvider();
viewer.setContentProvider(mBeanContentProvider);
viewer.setLabelProvider(new MyDecoratingStyledCellLabelProvider());
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
viewerSlectionChanged((IStructuredSelection) event.getSelection());
}
});
viewer.setInput(jvm);
mBeanContentProvider.refresh(jvm);
viewer.refresh();
viewer.expandToLevel(2);
new Label(composite, SWT.NONE).setText(Messages.colorLabel);
colorSelector = createColorSelector(composite);
}
use of org.eclipse.jface.viewers.IStructuredSelection in project tdi-studio-se by Talend.
the class ConfigureChartDialog method createAttributesViewer.
/**
* Creates the attributes viewer.
*
* @param parent The parent composite
* @return The attribute viewer
*/
private TreeViewer createAttributesViewer(Composite parent) {
TreeViewer viewer = new TreeViewer(parent, SWT.BORDER | SWT.FULL_SELECTION);
viewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
viewer.setContentProvider(new MBeanAttributeContentProvider());
viewer.setLabelProvider(new MBeanAttributeLabelProvider(viewer));
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
viewerSlectionChanged((IStructuredSelection) event.getSelection());
}
});
configureTree(viewer.getTree());
viewer.setInput(attributes.toArray(new MBeanAttribute[attributes.size()]));
return viewer;
}
use of org.eclipse.jface.viewers.IStructuredSelection in project tdi-studio-se by Talend.
the class AddListDialog method createAllTypeDialog.
private void createAllTypeDialog() {
IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
if (selection.size() == 1) {
Object obj = selection.getFirstElement();
if (obj instanceof ParameterInfo) {
ParameterInfo info = (ParameterInfo) obj;
if (info.getName().contains("anyType")) {
AllTypeDialog alltype;
try {
alltype = new AllTypeDialog(parentShell, info, URLValue, serverConfig);
if (alltype.open() == Window.OK) {
String selectedName = alltype.getSelectedName();
Map<String, String> labelAndNameSpaceMap = alltype.getLabelAndNameSpaceMap();
if (selectedName.contains("simpletype")) {
String namespace = labelAndNameSpaceMap.get(selectedName);
String[] ret = getNameSpaceAndType(namespace);
ParameterInfo newChild = new ParameterInfo();
newChild.setName(selectedName);
newChild.setType(selectedName.split(":")[1]);
newChild.setParent(info);
info.getParameterInfos().clear();
if (info.getName().indexOf("{") > 0) {
info.setName(info.getName().substring(0, info.getName().indexOf("{")));
}
info.setName(info.getName() + "{" + ret[0] + "," + ret[1] + "}");
info.getParameterInfos().add(newChild);
treeViewer.refresh();
} else if (selectedName.contains("complextype")) {
String namespace = labelAndNameSpaceMap.get(selectedName);
String[] ret = getNameSpaceAndType(namespace);
ParameterInfo selectParameterInfo = alltype.getSelectedParaInfo();
info.getParameterInfos().clear();
if (info.getName().indexOf("{") > 0) {
info.setName(info.getName().substring(0, info.getName().indexOf("{")));
}
info.setName(info.getName() + "{" + ret[0] + "," + ret[1] + "}");
List<ParameterInfo> childAttributes = selectParameterInfo.getParameterInfos();
for (ParameterInfo child : childAttributes) {
info.getParameterInfos().add(child);
child.setParent(info);
}
treeViewer.refresh();
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
}
}
}
use of org.eclipse.jface.viewers.IStructuredSelection 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);
}
}
Aggregations