use of org.eclipse.jface.viewers.ISelection 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);
}
}
}
});
}
use of org.eclipse.jface.viewers.ISelection in project tdi-studio-se by Talend.
the class OutputDataMapTableView method createFiltersTable.
protected void createFiltersTable() {
this.extendedTableViewerForFilters = new AbstractExtendedTableViewer<FilterTableEntry>(((OutputTable) abstractDataMapTable).getTableFiltersEntriesModel(), centerComposite) {
@Override
protected void createColumns(TableViewerCreator<FilterTableEntry> tableViewerCreator, Table table) {
createFiltersColumns(tableViewerCreator);
}
/*
* (non-Javadoc)
*
* @see
* org.talend.commons.ui.swt.extended.macrotable.AbstractExtendedTableViewer#setTableViewerCreatorOptions
* (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)
*/
@Override
protected void setTableViewerCreatorOptions(TableViewerCreator<FilterTableEntry> newTableViewerCreator) {
super.setTableViewerCreatorOptions(newTableViewerCreator);
newTableViewerCreator.setColumnsResizableByDefault(false);
newTableViewerCreator.setBorderVisible(false);
newTableViewerCreator.setLayoutMode(LAYOUT_MODE.FILL_HORIZONTAL);
newTableViewerCreator.setKeyboardManagementForCellEdition(true);
// tableViewerCreatorForColumns.setUseCustomItemColoring(this.getDataMapTable()
// instanceof
// AbstractInOutTable);
newTableViewerCreator.setFirstColumnMasked(true);
}
};
tableViewerCreatorForFilters = this.extendedTableViewerForFilters.getTableViewerCreator();
this.extendedTableViewerForFilters.setCommandStack(mapperManager.getCommandStack());
tableForConstraints = tableViewerCreatorForFilters.getTable();
tableForConstraintsGridData = new GridData(GridData.FILL_HORIZONTAL);
tableForConstraints.setLayoutData(tableForConstraintsGridData);
boolean tableConstraintsVisible = false;
if (abstractDataMapTable instanceof OutputTable) {
tableConstraintsVisible = ((OutputTable) abstractDataMapTable).getFilterEntries().size() > 0;
}
tableForConstraintsGridData.exclude = !tableConstraintsVisible;
tableForConstraints.setVisible(tableConstraintsVisible);
if (!mapperManager.componentIsReadOnly()) {
new DragNDrop(mapperManager, tableForConstraints, false, true);
}
tableViewerCreatorForFilters.addCellValueModifiedListener(new ITableCellValueModifiedListener() {
public void cellValueModified(TableCellValueModifiedEvent e) {
unselectAllEntriesIfErrorDetected(e);
}
});
final TableViewer tableViewer = tableViewerCreatorForFilters.getTableViewer();
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
selectThisDataMapTableView();
UIManager uiManager = mapperManager.getUiManager();
uiManager.selectLinks(OutputDataMapTableView.this, uiManager.extractSelectedTableEntries(selection), false, false);
}
});
tableForConstraints.addListener(SWT.KeyDown, new Listener() {
public void handleEvent(Event event) {
processEnterKeyDown(tableViewerCreatorForFilters, event);
}
});
tableViewerCreatorForFilters.setLabelProvider(new DefaultTableLabelProvider(tableViewerCreatorForFilters) {
@Override
public Color getBackground(Object element, int columnIndex) {
return getBackgroundCellColor(tableViewerCreator, element, columnIndex);
}
@Override
public Color getForeground(Object element, int columnIndex) {
return getForegroundCellColor(tableViewerCreator, element, columnIndex);
}
});
initShowMessageErrorListener(tableForConstraints);
}
use of org.eclipse.jface.viewers.ISelection in project tdi-studio-se by Talend.
the class MemoryRuntimeComposite method initRuntimeGraphs.
private void initRuntimeGraphs(final Composite parent) {
ISelection processContextSelection = viewPart.getSite().getSelectionProvider() == null ? null : viewPart.getSelection();
setExpandHorizontal(true);
setExpandVertical(true);
FormData layouData = new FormData();
layouData.left = new FormAttachment(0, 0);
layouData.right = new FormAttachment(100, 0);
layouData.top = new FormAttachment(0, 0);
layouData.bottom = new FormAttachment(100, 0);
this.setBackground(parent.getBackground());
this.setLayout(new FormLayout());
setLayoutData(layouData);
monitorComposite = new Composite(this, SWT.NULL);
FormData baseData = new FormData();
baseData.left = new FormAttachment(0, 0);
baseData.right = new FormAttachment(100, 0);
baseData.top = new FormAttachment(0, 0);
baseData.bottom = new FormAttachment(100, 0);
monitorComposite.setLayout(new FormLayout());
monitorComposite.setLayoutData(layouData);
setContent(monitorComposite);
Group topGroup = createTopGroup(monitorComposite);
runtimeButton = new Button(topGroup, SWT.PUSH);
if (processContext != null) {
setRuntimeButtonByStatus(!processContext.isMonitoring());
} else {
setRuntimeButtonByStatus(true);
}
runtimeButton.setEnabled(true);
GridData runButtonData = new GridData();
Point execSize = null;
execSize = computeSize(runtimeButton.getText());
runButtonData.widthHint = execSize.x + 70;
runtimeButton.setLayoutData(runButtonData);
gcCheckButton = new Button(topGroup, SWT.CHECK);
GridData gcCheckButtonData = new GridData();
gcCheckButtonData.grabExcessHorizontalSpace = false;
gcCheckButton.setLayoutData(gcCheckButtonData);
gcCheckButton.setEnabled(true);
gcCheckButton.setSelection(isGCSelected);
Label periodLabel = new Label(topGroup, SWT.NULL);
//$NON-NLS-1$
periodLabel.setText(Messages.getString("ProcessView.moniorPeriod"));
periodLabel.setBackground(getBackground());
GridData periodLabelData = new GridData();
execSize = computeSize(periodLabel.getText());
periodLabelData.widthHint = execSize.x;
periodLabelData.grabExcessHorizontalSpace = false;
periodLabelData.horizontalAlignment = GridData.BEGINNING;
periodLabel.setLayoutData(periodLabelData);
periodCombo = new Combo(topGroup, SWT.READ_ONLY);
GridData periodData = new GridData();
execSize = computeSize("Select");
periodData.widthHint = execSize.x;
periodData.grabExcessHorizontalSpace = false;
periodData.horizontalAlignment = GridData.BEGINNING;
periodData.minimumWidth = execSize.x;
periodCombo.setLayoutData(periodData);
periodCombo.setItems(new String[] { "Select", "30 sec", "60 sec", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"120 sec" });
periodCombo.setEnabled(isGCSelected);
if (isGCSelected) {
periodCombo.select(periodComboSelectionIndex);
} else {
periodCombo.select(0);
periodComboSelectionIndex = 0;
}
contextCombo = new ComboViewer(topGroup, SWT.BORDER | SWT.READ_ONLY);
contextCombo.getCombo().setLayout(new FormLayout());
GridData contextComboData = new GridData();
contextComboData.grabExcessHorizontalSpace = true;
contextComboData.horizontalAlignment = GridData.END;
//$NON-NLS-N$
execSize = computeSize("Default");
contextComboData.minimumWidth = execSize.x;
contextCombo.getCombo().setLayoutData(contextComboData);
contextCombo.setContentProvider(ArrayContentProvider.getInstance());
contextCombo.setLabelProvider(new ContextNameLabelProvider());
initContextInput();
chartComposite = new RuntimeGraphcsComposite(monitorComposite, processContextSelection, SWT.NULL);
FormLayout rgcLayout = new FormLayout();
FormData charLayData = new FormData();
charLayData.left = new FormAttachment(0, 10);
charLayData.right = new FormAttachment(100, 0);
charLayData.top = new FormAttachment(topGroup, 60, SWT.BOTTOM);
charLayData.bottom = new FormAttachment(100, 0);
chartComposite.setLayout(rgcLayout);
chartComposite.setLayoutData(charLayData);
}
use of org.eclipse.jface.viewers.ISelection 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.ISelection in project tdi-studio-se by Talend.
the class LoadChartSetDialog method createChartSetViewer.
/**
* Creates the chart set viewer.
*
* @param parent The parent composite
* @return The chart set viewer
*/
private TableViewer createChartSetViewer(Composite parent) {
final TableViewer viewer = new TableViewer(parent, SWT.BORDER | SWT.FULL_SELECTION);
GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.heightHint = 300;
viewer.getTable().setLayoutData(gridData);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element.equals(defaultChartSet)) {
return NLS.bind(Messages.defaultChartSet, defaultChartSet);
}
return super.getText(element);
}
});
viewer.setInput(chartSets.toArray(new String[chartSets.size()]));
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
Object element = ((StructuredSelection) selection).getFirstElement();
if (deleteButton != null) {
deleteButton.setEnabled(!selection.isEmpty() && !predefinedChartSets.contains(element));
}
if (element != null) {
chartSet = element.toString();
} else {
viewer.setSelection(new StructuredSelection(chartSet));
}
}
});
viewer.setSelection(new StructuredSelection(defaultChartSet));
return viewer;
}
Aggregations