use of org.eclipse.jface.viewers.ISelectionChangedListener in project archi by archimatetool.
the class ExportJasperReportsWizardPage2 method createControl.
@Override
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
container.setLayout(new GridLayout());
setControl(container);
PlatformUI.getWorkbench().getHelpSystem().setHelp(container, HELP_ID);
Composite fieldContainer = new Composite(container, SWT.NULL);
fieldContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fieldContainer.setLayout(new GridLayout(2, false));
// Template Combo
Label label = new Label(fieldContainer, SWT.NONE);
label.setText(Messages.ExportJasperReportsWizardPage2_4);
fComboTemplateViewer = new ComboViewer(new Combo(fieldContainer, SWT.READ_ONLY | SWT.BORDER));
fComboTemplateViewer.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fComboTemplateViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
Template template = (Template) ((IStructuredSelection) event.getSelection()).getFirstElement();
if (template.location == null) {
// Custom...
handleCustomDialog();
} else {
fLastSelectedTemplate = template;
}
}
});
fComboTemplateViewer.setContentProvider(new IStructuredContentProvider() {
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
@Override
public void dispose() {
}
@Override
public Object[] getElements(Object inputElement) {
return fTemplates.toArray();
}
});
fComboTemplateViewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return ((Template) element).name;
}
});
// $NON-NLS-1$
fComboTemplateViewer.setInput("");
fComboTemplateViewer.setSelection(new StructuredSelection(fTemplates.get(0)));
// Locale Combo
label = new Label(fieldContainer, SWT.NONE);
label.setText(Messages.ExportJasperReportsWizardPage2_6);
fComboLocale = new ComboViewer(new Combo(fieldContainer, SWT.READ_ONLY | SWT.BORDER));
fComboLocale.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fComboLocale.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
Locale locale = (Locale) ((IStructuredSelection) event.getSelection()).getFirstElement();
fSelectedLocale = locale;
}
});
fComboLocale.setContentProvider(new IStructuredContentProvider() {
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
@Override
public void dispose() {
}
@Override
public Object[] getElements(Object inputElement) {
Locale[] locales = Locale.getAvailableLocales();
Comparator<Locale> localeComparator = new Comparator<Locale>() {
public int compare(Locale locale1, Locale locale2) {
return locale1.toString().compareTo(locale2.toString());
}
};
Arrays.sort(locales, localeComparator);
return locales;
}
});
fComboLocale.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return ((Locale) element).toLanguageTag();
}
});
// $NON-NLS-1$
fComboLocale.setInput("");
fComboLocale.setSelection(new StructuredSelection(fSelectedLocale));
}
use of org.eclipse.jface.viewers.ISelectionChangedListener in project xtext-eclipse by eclipse.
the class ProjectSelectionDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
Font font = parent.getFont();
composite.setFont(font);
createMessageArea(composite);
tableViewer = new TableViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
doSelectionChanged(((IStructuredSelection) event.getSelection()).toArray());
}
});
tableViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
okPressed();
}
});
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT;
data.widthHint = SIZING_SELECTION_WIDGET_WIDTH;
tableViewer.getTable().setLayoutData(data);
tableViewer.setContentProvider(new WorkbenchContentProvider());
tableViewer.setLabelProvider(new WorkbenchLabelProvider());
tableViewer.setComparator(new ResourceComparator(ResourceComparator.NAME));
tableViewer.getControl().setFont(font);
Button checkbox = new Button(composite, SWT.CHECK);
checkbox.setText(Messages.ProjectSelectionDialog_filter);
checkbox.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));
checkbox.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
updateFilter(((Button) e.widget).getSelection());
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
updateFilter(((Button) e.widget).getSelection());
}
});
boolean doFilter = !dialogSettings.getBoolean(DIALOG_SETTINGS_SHOW_ALL) && !projectsWithSpecifics.isEmpty();
checkbox.setSelection(doFilter);
updateFilter(doFilter);
tableViewer.setInput(ResourcesPlugin.getWorkspace());
doSelectionChanged(new Object[0]);
Dialog.applyDialogFont(composite);
return composite;
}
use of org.eclipse.jface.viewers.ISelectionChangedListener in project archi by archimatetool.
the class TemplateManagerDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
// Help
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, getHelpID());
setTitle(Messages.TemplateManagerDialog_2);
setMessage(Messages.TemplateManagerDialog_3);
Composite composite = (Composite) super.createDialogArea(parent);
Composite client = new Composite(composite, SWT.NULL);
GridLayout layout = new GridLayout(2, false);
client.setLayout(layout);
client.setLayoutData(new GridData(GridData.FILL_BOTH));
SashForm sash = new SashForm(client, SWT.HORIZONTAL);
sash.setLayoutData(new GridData(GridData.FILL_BOTH));
GridData gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 580;
gd.heightHint = 300;
sash.setLayoutData(gd);
// Templates Table
Composite tableComp = new Composite(sash, SWT.BORDER);
layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
tableComp.setLayout(layout);
CLabel label = new CLabel(tableComp, SWT.NULL);
label.setText(Messages.TemplateManagerDialog_4);
Composite tableComp2 = new Composite(tableComp, SWT.NULL);
tableComp2.setLayout(new TableColumnLayout());
tableComp2.setLayoutData(new GridData(GridData.FILL_BOTH));
fTableViewer = new TemplatesTableViewer(tableComp2, SWT.MULTI);
fTableViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
fTableViewer.setInput(fTemplateManager.getUserTemplates());
fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
Object o = ((IStructuredSelection) event.getSelection()).getFirstElement();
fSelectedControl = fTableViewer;
updateControls(o);
}
});
// Groups Tree
Composite treeComp = new Composite(sash, SWT.BORDER);
layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
treeComp.setLayout(layout);
label = new CLabel(treeComp, SWT.NULL);
label.setText(Messages.TemplateManagerDialog_5);
// label.setImage(IArchiImages.ImageFactory.getImage(ImageFactory.ECLIPSE_IMAGE_FOLDER));
fTreeViewer = new TemplatesTreeViewer(treeComp, SWT.MULTI);
fTreeViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
fTreeViewer.setInput(fTemplateManager.getUserTemplateGroups());
fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
Object o = ((IStructuredSelection) event.getSelection()).getFirstElement();
fSelectedControl = fTreeViewer;
updateControls(o);
}
});
new TemplateManagerDialogDragDropHandler(fTableViewer, fTreeViewer);
// Buttons
Composite buttonBar = new Composite(client, SWT.NULL);
layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
buttonBar.setLayout(layout);
buttonBar.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
fButtonAddTemplate = new Button(buttonBar, SWT.NULL);
fButtonAddTemplate.setText(Messages.TemplateManagerDialog_6);
gd = new GridData(GridData.FILL_HORIZONTAL);
fButtonAddTemplate.setLayoutData(gd);
fButtonAddTemplate.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
openTemplate();
}
});
fButtonNewGroup = new Button(buttonBar, SWT.NULL);
fButtonNewGroup.setText(Messages.TemplateManagerDialog_7);
gd = new GridData(GridData.FILL_HORIZONTAL);
fButtonNewGroup.setLayoutData(gd);
fButtonNewGroup.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
newGroup();
}
});
fButtonRemove = new Button(buttonBar, SWT.NULL);
fButtonRemove.setText(Messages.TemplateManagerDialog_8);
gd = new GridData(GridData.FILL_HORIZONTAL);
fButtonRemove.setLayoutData(gd);
fButtonRemove.setEnabled(false);
fButtonRemove.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
deleteSelectedObjects();
}
});
sash.setWeights(new int[] { 30, 70 });
Composite fieldContainer = new Composite(composite, SWT.NULL);
layout = new GridLayout(2, false);
fieldContainer.setLayout(layout);
fieldContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fNameLabel = new Label(fieldContainer, SWT.NULL);
fNameLabel.setText(Messages.TemplateManagerDialog_9);
fNameLabel.setEnabled(false);
fNameTextField = new Text(fieldContainer, SWT.BORDER | SWT.SINGLE);
fNameTextField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fNameTextField.setEnabled(false);
// Single text control so strip CRLFs
UIUtils.conformSingleTextControl(fNameTextField);
fNameTextField.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
String text = fNameTextField.getText();
if (fIsSettingFields || !StringUtils.isSet(text)) {
return;
}
// Edit Template name
if (fSelectedTemplate != null) {
fSelectedTemplate.setName(text);
if (!fModifiedTemplates.contains(fSelectedTemplate)) {
fModifiedTemplates.add(fSelectedTemplate);
}
fTableViewer.refresh();
fTreeViewer.refresh();
} else // Edit Group name
if (fSelectedTemplateGroup != null) {
fSelectedTemplateGroup.setName(text);
fTreeViewer.refresh();
}
}
});
fDescriptionLabel = new Label(fieldContainer, SWT.NULL);
fDescriptionLabel.setText(Messages.TemplateManagerDialog_10);
fDescriptionLabel.setEnabled(false);
fDescriptionTextField = new Text(fieldContainer, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
fDescriptionTextField.setEnabled(false);
gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 100;
fDescriptionTextField.setLayoutData(gd);
fDescriptionTextField.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
String text = fDescriptionTextField.getText();
if (fIsSettingFields || !StringUtils.isSet(text)) {
return;
}
if (fSelectedTemplate != null) {
fSelectedTemplate.setDescription(fDescriptionTextField.getText());
if (!fModifiedTemplates.contains(fSelectedTemplate)) {
fModifiedTemplates.add(fSelectedTemplate);
}
}
}
});
fFileLabel = new Label(fieldContainer, SWT.NULL);
fFileLabel.setText(Messages.TemplateManagerDialog_11);
fFileLabel.setEnabled(false);
fFileTextField = new Text(fieldContainer, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);
fFileTextField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fFileTextField.setEnabled(false);
return composite;
}
use of org.eclipse.jface.viewers.ISelectionChangedListener in project xtext-eclipse by eclipse.
the class XtextEditor method installSelectionChangedListener.
private void installSelectionChangedListener() {
selectionChangedListener = new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
updateStatusLine();
}
};
final ISelectionProvider selectionProvider = getSelectionProvider();
if (selectionProvider instanceof IPostSelectionProvider) {
final IPostSelectionProvider postSelectionProvider = (IPostSelectionProvider) selectionProvider;
postSelectionProvider.addPostSelectionChangedListener(selectionChangedListener);
} else {
getSelectionProvider().addSelectionChangedListener(selectionChangedListener);
}
}
use of org.eclipse.jface.viewers.ISelectionChangedListener in project archi by archimatetool.
the class UserPropertiesManagerDialog method createTableControl.
private void createTableControl(Composite parent) {
Composite tableComp = new Composite(parent, SWT.BORDER);
TableColumnLayout tableLayout = new TableColumnLayout();
tableComp.setLayout(tableLayout);
tableComp.setLayoutData(new GridData(GridData.FILL_BOTH));
fTableViewer = new TableViewer(tableComp, SWT.MULTI | SWT.FULL_SELECTION);
fTableViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
fTableViewer.getTable().setHeaderVisible(true);
fTableViewer.getTable().setLinesVisible(true);
fTableViewer.setComparator(new ViewerComparator());
// Columns
TableViewerColumn columnOldKey = new TableViewerColumn(fTableViewer, SWT.NONE, 0);
columnOldKey.getColumn().setText(Messages.UserPropertiesManagerDialog_6);
tableLayout.setColumnData(columnOldKey.getColumn(), new ColumnWeightData(40, true));
TableViewerColumn columnNewKey = new TableViewerColumn(fTableViewer, SWT.NONE, 1);
columnNewKey.getColumn().setText(Messages.UserPropertiesManagerDialog_7);
tableLayout.setColumnData(columnNewKey.getColumn(), new ColumnWeightData(40, true));
columnNewKey.setEditingSupport(new KeyEditingSupport(fTableViewer));
TableViewerColumn columnUsedNumber = new TableViewerColumn(fTableViewer, SWT.NONE, 2);
// $NON-NLS-1$
columnUsedNumber.getColumn().setText("# " + Messages.UserPropertiesManagerDialog_8);
tableLayout.setColumnData(columnUsedNumber.getColumn(), new ColumnWeightData(20, true));
// Content Provider
fTableViewer.setContentProvider(new IStructuredContentProvider() {
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
public void dispose() {
}
public Object[] getElements(Object inputElement) {
return fKeysTable.entrySet().toArray();
}
});
// Label Provider
fTableViewer.setLabelProvider(new LabelCellProvider());
fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
fActionDelete.setEnabled(!event.getSelection().isEmpty());
fButtonDelete.setEnabled(!event.getSelection().isEmpty());
fActionRename.setEnabled(!event.getSelection().isEmpty());
fButtonRename.setEnabled(!event.getSelection().isEmpty());
}
});
// anything will do //$NON-NLS-1$
fTableViewer.setInput("");
}
Aggregations