use of org.eclipse.jface.viewers.SelectionChangedEvent in project tdi-studio-se by Talend.
the class CpuDumpEditor method createHotSpotsPage.
/**
* Creates the hot spots page.
*/
private void createHotSpotsPage() {
Composite panel = new Composite(getContainer(), SWT.NONE);
panel.setLayout(new FillLayout());
final HotSpotsFilteredTree hotSpotsFilteredTree = new HotSpotsFilteredTree(panel, getEditorSite().getActionBars());
TreeViewer hotSpotsViewer = hotSpotsFilteredTree.getViewer();
hotSpotsViewer.setContentProvider(new AbstractContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
if (inputElement instanceof ICpuModel) {
return ((ICpuModel) inputElement).getHotSpotRoots();
}
return new Object[0];
}
});
hotSpotsViewer.setLabelProvider(new HotSpotsLabelProvider(hotSpotsFilteredTree));
hotSpotsViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
hotSpotsFilteredTree.updateStatusLine((IStructuredSelection) event.getSelection());
}
});
hotSpotsViewer.setUseHashlookup(true);
hotSpotsViewer.setInput(cpuModel);
hotSpotsFilteredTree.sortColumn(hotSpotsViewer.getTree().getColumn(1));
int page = addPage(panel);
trees.put(hotSpotsFilteredTree, page);
setPageText(page, Messages.hotSpotsPageLabel);
setPageImage(page, getHotSpotsImage());
}
use of org.eclipse.jface.viewers.SelectionChangedEvent in project tdi-studio-se by Talend.
the class PaletteSettingPage method addTreeViewer.
/**
* qwei Comment method "addViewer".
*
* @param parent
*/
private void addTreeViewer(ThreeCompositesSashForm parent) {
ViewerSorter sorter = new ViewerSorter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer,
* java.lang.Object, java.lang.Object)
*/
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
if (e1 instanceof ComponentPaletteItem && e2 instanceof ComponentPaletteItem) {
return super.compare(viewer, ((IPaletteItem) e1).getLabel(), ((IPaletteItem) e2).getLabel());
} else if (e1 instanceof FolderPaletteItem && e2 instanceof FolderPaletteItem) {
return super.compare(viewer, ((IPaletteItem) e1).getLabel(), ((IPaletteItem) e2).getLabel());
} else if (e1 instanceof ComponentPaletteItem && e2 instanceof FolderPaletteItem) {
return 1;
} else if (e1 instanceof FolderPaletteItem && e2 instanceof ComponentPaletteItem) {
return -1;
} else if (e1 instanceof RootPaletteItem && e2 instanceof RootPaletteItem) {
if (((IPaletteItem) e1).getPaletteType() == ComponentCategory.CATEGORY_4_DI) {
// up
return -1;
} else if (((IPaletteItem) e2).getPaletteType() == ComponentCategory.CATEGORY_4_DI) {
// down
return 1;
} else if (((IPaletteItem) e1).getPaletteType() == ComponentCategory.CATEGORY_4_CAMEL && ((IPaletteItem) e2).getPaletteType() == ComponentCategory.CATEGORY_4_MAPREDUCE) {
// up
return -1;
} else if (((IPaletteItem) e1).getPaletteType() == ComponentCategory.CATEGORY_4_MAPREDUCE && ((IPaletteItem) e2).getPaletteType() == ComponentCategory.CATEGORY_4_CAMEL) {
// down
return 1;
} else if (((IPaletteItem) e1).getPaletteType() == ComponentCategory.CATEGORY_4_MAPREDUCE && ((IPaletteItem) e2).getPaletteType() == ComponentCategory.CATEGORY_4_STORM) {
// up
return -1;
} else if (((IPaletteItem) e1).getPaletteType() == ComponentCategory.CATEGORY_4_STORM && ((IPaletteItem) e2).getPaletteType() == ComponentCategory.CATEGORY_4_MAPREDUCE) {
// down
return 1;
} else if (((IPaletteItem) e1).getPaletteType() == ComponentCategory.CATEGORY_4_CAMEL && ((IPaletteItem) e2).getPaletteType() == ComponentCategory.CATEGORY_4_STORM) {
// up
return -1;
} else if (((IPaletteItem) e1).getPaletteType() == ComponentCategory.CATEGORY_4_STORM && ((IPaletteItem) e2).getPaletteType() == ComponentCategory.CATEGORY_4_CAMEL) {
// down
return 1;
}
}
return super.compare(viewer, e1, e2);
}
};
List<IPaletteItem> input = getViewerInput();
Composite leftComposite = parent.getLeftComposite();
Label label = new Label(leftComposite, SWT.NONE);
label.setText("Hide");
hiddenViewer = new TreeViewer(leftComposite);
hiddenViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
hiddenViewer.setContentProvider(new TalendPaletteTreeProvider());
hiddenViewer.setLabelProvider(new TalendPaletteLabelProvider());
hiddenViewer.addFilter(getFilterForComponent(false));
hiddenViewer.setSorter(sorter);
hiddenViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
displayComponentsButton.setEnabled(!event.getSelection().isEmpty());
}
});
createButtons(parent.getMidComposite());
Composite rightComposite = parent.getRightComposite();
label = new Label(rightComposite, SWT.NONE);
label.setText("Show");
displayViewer = new TreeViewer(rightComposite);
displayViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
displayViewer.setContentProvider(new TalendPaletteTreeProvider());
displayViewer.setLabelProvider(new TalendPaletteLabelProvider());
displayViewer.addFilter(getFilterForComponent(true));
displayViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
hideCompnentsButton.setEnabled(!event.getSelection().isEmpty());
}
});
displayViewer.setSorter(sorter);
getComponentsFromProject(project);
hiddenViewer.setInput(input);
displayViewer.setInput(input);
if (!input.isEmpty()) {
displayViewer.expandToLevel(input.get(0), 1);
}
if (!input.isEmpty()) {
hiddenViewer.expandToLevel(input.get(0), 1);
}
}
use of org.eclipse.jface.viewers.SelectionChangedEvent in project tdi-studio-se by Talend.
the class ProcessVersionComposite method addSortListener.
/**
* DOC Administrator Comment method "addSortListener".
*
* @param table
* @param column1
* @param column2
* @param column3
*/
private void addSortListener(final Table table, final TableColumn column1, final TableColumn column2, final TableColumn column3, final TableColumn column4) {
Listener sortListener = new Listener() {
private int direction = 1;
@Override
public void handleEvent(Event e) {
final TableColumn column = (TableColumn) e.widget;
if (column == table.getSortColumn()) {
direction = -direction;
}
if (direction == 1) {
table.setSortDirection(SWT.DOWN);
} else {
table.setSortDirection(SWT.UP);
}
table.setSortColumn(column);
tableViewer.setSorter(new ViewerSorter() {
int index = 0;
@Override
public void sort(Viewer viewer, Object[] elements) {
while (index < table.getColumns().length && table.getColumn(index) != column) {
index++;
}
super.sort(viewer, elements);
}
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
ITableLabelProvider labelProvider = (ITableLabelProvider) tableViewer.getLabelProvider();
String columnText = labelProvider.getColumnText(e1, index) != null ? labelProvider.getColumnText(e1, index) : //$NON-NLS-1$
"";
String columnText2 = labelProvider.getColumnText(e2, index) != null ? labelProvider.getColumnText(e2, index) : //$NON-NLS-1$
"";
return getComparator().compare(columnText, columnText2) * direction;
}
});
}
};
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
/*
* (non-Javadoc)
*
* @seeorg.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.
* SelectionChangedEvent)
*/
@Override
public void selectionChanged(SelectionChangedEvent event) {
ProcessVersionComposite.this.selection = event.getSelection();
if (getParentWizard() != null) {
((WizardPage) getParentWizard()).setPageComplete(true);
}
}
});
column1.addListener(SWT.Selection, sortListener);
column2.addListener(SWT.Selection, sortListener);
column3.addListener(SWT.Selection, sortListener);
column4.addListener(SWT.Selection, sortListener);
table.setSortColumn(column1);
table.setSortDirection(SWT.DOWN);
tableViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
if (getParentWizard() == null) {
ITreeContextualAction editPropertiesAction = getEditPropertiesAction(EditPropertiesAction.class);
if (editPropertiesAction != null) {
editPropertiesAction.run();
}
}
}
});
}
use of org.eclipse.jface.viewers.SelectionChangedEvent in project tdi-studio-se by Talend.
the class JobSettingsView method createPartControl.
@Override
public void createPartControl(Composite parent) {
// tabFactory = new HorizontalTabFactory();
this.parent = parent;
tabFactory.initComposite(parent, false);
tabFactory.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
TalendPropertyTabDescriptor descriptor = (TalendPropertyTabDescriptor) selection.getFirstElement();
if (descriptor == null) {
return;
}
if (currentSelectedTab != null) {
if ((!currentSelectedTab.getData().equals(descriptor.getData()) || currentSelectedTab.getData() != descriptor.getData() || currentSelectedTab.getCategory() != descriptor.getCategory())) {
for (Control curControl : tabFactory.getTabComposite().getChildren()) {
curControl.dispose();
}
}
}
if (element == null || !element.equals(descriptor.getData()) || currentSelectedTab == null || currentSelectedTab.getCategory() != descriptor.getCategory() || selectedPrimary) {
Object data = descriptor.getData();
if (data instanceof Element) {
element = (Element) data;
currentSelectedTab = descriptor;
IDynamicProperty propertyComposite = createTabComposite(tabFactory.getTabComposite(), element, descriptor.getCategory());
} else if (data instanceof IRepositoryViewObject) {
IRepositoryViewObject viewObject = (IRepositoryViewObject) data;
IProcess process = getProcess(viewObject);
if (process != null && process instanceof Element && process.getId().equals(viewObject.getId()) && process.getVersion().equals(viewObject.getVersion())) {
data = process;
}
currentSelectedTab = descriptor;
IDynamicProperty propertyComposite = createTabComposite(tabFactory.getTabComposite(), data, descriptor.getCategory());
} else if (data instanceof IEditorPart) {
currentSelectedTab = descriptor;
IRepositoryViewObject repObj = retrieveBusiness((IEditorPart) data);
if (repObj != null) {
IDynamicProperty propertyComposite = createTabComposite(tabFactory.getTabComposite(), repObj, descriptor.getCategory());
}
} else {
currentSelectedTab = descriptor;
IDynamicProperty propertyComposite = createTabComposite(tabFactory.getTabComposite(), null, descriptor.getCategory());
}
selectedPrimary = false;
}
}
});
}
use of org.eclipse.jface.viewers.SelectionChangedEvent in project tdi-studio-se by Talend.
the class DeploymentComposite method addListeners.
private void addListeners() {
groupIdCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (groupIdCheckbox.getSelection()) {
groupIdText.setEnabled(true);
groupIdText.setText(groupId);
} else {
groupIdText.setEnabled(false);
groupIdText.setText(defaultGroupId);
// remove key, so will be default groupId
Command cmd = new MavenDeploymentValueChangeCommand(process, MavenConstants.NAME_GROUP_ID, null);
getCommandStack().execute(cmd);
}
}
});
groupIdText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
String currentGroupId = groupIdText.getText();
if (currentGroupId != null && !currentGroupId.trim().equals("")) {
//$NON-NLS-1$
groupIdText.setBackground(getBackground());
//$NON-NLS-1$
groupIdText.setToolTipText("");
if (!defaultGroupId.equals(currentGroupId)) {
groupId = currentGroupId;
} else {
currentGroupId = null;
}
Command cmd = new MavenDeploymentValueChangeCommand(process, MavenConstants.NAME_GROUP_ID, currentGroupId);
getCommandStack().execute(cmd);
} else {
groupIdText.setBackground(COLOR_RED);
//$NON-NLS-1$
groupIdText.setToolTipText(Messages.getString("DeploymentComposite.valueWarning"));
}
}
});
versionCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (versionCheckbox.getSelection()) {
versionText.setEnabled(true);
versionText.setText(version);
} else {
versionText.setEnabled(false);
versionText.setText(defaultVersion);
// remove key, so will be default version
Command cmd = new MavenDeploymentValueChangeCommand(process, MavenConstants.NAME_USER_VERSION, null);
getCommandStack().execute(cmd);
}
}
});
versionText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
String currentVersion = versionText.getText();
if (//$NON-NLS-1$
currentVersion != null && !currentVersion.trim().equals("") && !MavenVersionUtils.isValidMavenVersion(currentVersion)) {
//$NON-NLS-1$
versionText.setToolTipText(Messages.getString("DeploymentComposite.valueWarning"));
versionText.setBackground(COLOR_RED);
} else {
//$NON-NLS-1$
versionText.setToolTipText("");
versionText.setBackground(getBackground());
if (!defaultVersion.equals(currentVersion)) {
version = currentVersion;
} else {
currentVersion = null;
}
// if empty, remove it from job, else will set the new value
Command cmd = new MavenDeploymentValueChangeCommand(process, MavenConstants.NAME_USER_VERSION, currentVersion);
getCommandStack().execute(cmd);
}
}
});
buildTypeCombo.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
final ISelection selection = event.getSelection();
if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
final Object elem = ((IStructuredSelection) selection).getFirstElement();
if (elem instanceof BuildType) {
Command cmd = new MavenDeploymentValueChangeCommand(process, TalendProcessArgumentConstant.ARG_BUILD_TYPE, ((BuildType) elem).getName());
getCommandStack().execute(cmd);
}
}
}
});
}
Aggregations