use of org.eclipse.jface.viewers.StructuredSelection in project tdi-studio-se by Talend.
the class TalendConnectionCreationTool method selectAddedObject.
protected void selectAddedObject(EditPartViewer viewer, Collection objects) {
final List editparts = new ArrayList();
final EditPart[] primaryEP = new EditPart[1];
for (Iterator i = objects.iterator(); i.hasNext(); ) {
Object object = i.next();
if (object instanceof IAdaptable) {
Object editPart = viewer.getEditPartRegistry().get(((IAdaptable) object).getAdapter(View.class));
if (editPart instanceof GraphicalEditPart) {
editparts.add(editPart);
}
}
}
if (!editparts.isEmpty()) {
viewer.setSelection(new StructuredSelection(editparts));
// automatically put the first shape into edit-mode
Display.getCurrent().asyncExec(new Runnable() {
@Override
public void run() {
if (primaryEP[0] == null) {
primaryEP[0] = (EditPart) editparts.get(0);
}
// code is being executed. (see RATLC00527114)
if (primaryEP[0].isActive()) {
primaryEP[0].performRequest(new Request("direct edit"));
}
}
});
}
}
use of org.eclipse.jface.viewers.StructuredSelection in project tdi-studio-se by Talend.
the class ShowInTimelineAction method selectionChanged.
/*
* @see ISelectionChangedListener#selectionChanged(SelectionChangedEvent)
*/
@Override
public void selectionChanged(SelectionChangedEvent event) {
IActiveJvm jvm = section.getJvm();
if (!(event.getSelection() instanceof StructuredSelection) || jvm == null || !jvm.isConnected()) {
setEnabled(false);
return;
}
Object[] elements = ((StructuredSelection) event.getSelection()).toArray();
if (elements.length == 0) {
setEnabled(false);
return;
}
boolean enabled = true;
selections.clear();
for (Object element : elements) {
MBeanAttribute attribute = getMBeanAttribute(element);
if (attribute != null) {
selections.add(attribute);
}
if (!getEnabled(element)) {
enabled = false;
}
}
setEnabled(enabled);
}
use of org.eclipse.jface.viewers.StructuredSelection in project tdi-studio-se by Talend.
the class NewJvmConnectionWizard method performFinish.
/*
* @see Wizard#performFinish()
*/
@Override
public boolean performFinish() {
// add active JVM
IActiveJvm jvm = addActiveJvm();
if (jvm == null) {
return false;
}
// select item on JVM explorer
viewer.refresh();
viewer.setSelection(new StructuredSelection(jvm));
// connect to JVM
try {
int period = Activator.getDefault().getPreferenceStore().getInt(IConstants.UPDATE_PERIOD);
jvm.connect(period);
} catch (JvmCoreException e) {
Activator.log(NLS.bind(Messages.connectJvmFailedMsg, jvm.getPid()), e);
}
page.storeDialogSettings();
return true;
}
use of org.eclipse.jface.viewers.StructuredSelection in project tdi-studio-se by Talend.
the class UseDynamicJobSelectionDialog method setCheckingNodes.
private void setCheckingNodes() {
final IContentProvider contentProvider = getItemsTreeViewer().getContentProvider();
final Object input = getItemsTreeViewer().getInput();
if (contentProvider instanceof ITreeContentProvider && input instanceof ProjectRepositoryNode && getNeedCheckedjobs() != null && getNeedCheckedjobs().length > 0) {
ITreeContentProvider cnfContentProvider = (ITreeContentProvider) contentProvider;
List<IRepositoryNode> checkingNodes = new ArrayList<IRepositoryNode>();
List<String> needCheckedJobIds = new ArrayList(Arrays.asList(getNeedCheckedjobs()));
final ProjectRepositoryNode root = (ProjectRepositoryNode) input;
final RepositoryNode rootRepositoryNode = root.getRootRepositoryNode(getSupportType());
if (rootRepositoryNode == null) {
return;
}
withReferenceProjects(cnfContentProvider, rootRepositoryNode, needCheckedJobIds, checkingNodes);
// set check for node
getItemsTreeViewer().setCheckedElements(checkingNodes.toArray());
// select and will expand the selected node auto
getItemsTreeViewer().setSelection(new StructuredSelection(checkingNodes), true);
// let scroll bar on top
getItemsTreeViewer().setSelection(new StructuredSelection(rootRepositoryNode));
getItemsTreeViewer().setSelection(StructuredSelection.EMPTY);
}
}
use of org.eclipse.jface.viewers.StructuredSelection in project tdi-studio-se by Talend.
the class ProjectSettingsPreferenceDialog method openPage.
@Override
public boolean openPage(String nodeId, Object data) {
if (this instanceof IWorkbenchPreferenceContainer) {
((IWorkbenchPreferenceContainer) this).openPage(nodeId, data);
} else {
// impl by self
final IPreferenceNode node = findNodeMatching(nodeId);
if (node != null) {
getTreeViewer().setSelection(new StructuredSelection(node));
showPage(node);
}
IPreferencePage page = getCurrentPage();
if (page instanceof PreferencePage) {
((PreferencePage) page).applyData(data);
}
return true;
}
return false;
}
Aggregations