use of org.eclipse.jface.viewers.IStructuredContentProvider in project webtools.sourceediting by eclipse.
the class PropertyPreferencePage method openProjectSettings.
void openProjectSettings() {
ListDialog dialog = new ListDialog(getShell()) {
protected Control createDialogArea(Composite container) {
Control area = super.createDialogArea(container);
getTableViewer().setSorter(new ResourceSorter(ResourceSorter.NAME));
return area;
}
};
dialog.setMessage(SSEUIMessages.PropertyPreferencePage_02);
dialog.setContentProvider(new IStructuredContentProvider() {
public void dispose() {
}
public Object[] getElements(Object inputElement) {
return ((IWorkspace) inputElement).getRoot().getProjects();
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
dialog.setLabelProvider(new DecoratingLabelProvider(new WorkbenchLabelProvider(), SSEUIPlugin.getDefault().getWorkbench().getDecoratorManager().getLabelDecorator()));
dialog.setInput(ResourcesPlugin.getWorkspace());
dialog.setTitle(SSEUIMessages.PropertyPreferencePage_01);
if (dialog.open() == Window.OK) {
Object[] result = dialog.getResult();
if (result.length > 0) {
IProject project = (IProject) dialog.getResult()[0];
Map data = new HashMap();
data.put(DISABLE_LINK, Boolean.TRUE);
PreferencesUtil.createPropertyDialogOn(getShell(), project, getPropertyPageID(), new String[] { getPropertyPageID() }, data).open();
}
}
}
use of org.eclipse.jface.viewers.IStructuredContentProvider in project webtools.sourceediting by eclipse.
the class AbstractPropertyPreferencePage method openProjectSettings.
void openProjectSettings() {
ListDialog dialog = new ListDialog(getShell()) {
protected Control createDialogArea(Composite container) {
Control area = super.createDialogArea(container);
getTableViewer().setSorter(new ResourceSorter(ResourceSorter.NAME));
return area;
}
};
dialog.setMessage(SSEUIMessages.PropertyPreferencePage_02);
dialog.setContentProvider(new IStructuredContentProvider() {
public void dispose() {
}
public Object[] getElements(Object inputElement) {
return ((IWorkspace) inputElement).getRoot().getProjects();
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
dialog.setLabelProvider(new DecoratingLabelProvider(new WorkbenchLabelProvider(), SSEUIPlugin.getDefault().getWorkbench().getDecoratorManager().getLabelDecorator()));
dialog.setInput(ResourcesPlugin.getWorkspace());
dialog.setTitle(SSEUIMessages.PropertyPreferencePage_01);
if (dialog.open() == Window.OK) {
Object[] result = dialog.getResult();
if (result.length > 0) {
IProject project = (IProject) dialog.getResult()[0];
Map data = new HashMap();
data.put(DISABLE_LINK, Boolean.TRUE);
PreferencesUtil.createPropertyDialogOn(getShell(), project, getPropertyPageID(), new String[] { getPropertyPageID() }, data).open();
}
}
}
use of org.eclipse.jface.viewers.IStructuredContentProvider in project webtools.sourceediting by eclipse.
the class OutputPropertyDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.widthHint = 400;
comp.setLayoutData(gd);
comp.setLayout(new GridLayout());
Label label = new Label(comp, SWT.NONE);
// $NON-NLS-1$
label.setText(Messages.getString("OutputPropertyDialog_1"));
table = new Table(comp, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.MULTI);
table.setHeaderVisible(false);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.verticalIndent = 10;
gd.heightHint = 200;
table.setLayoutData(gd);
tViewer = new TableViewer(table);
tViewer.setContentProvider(new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
return properties.toArray(new IOutputProperty[0]);
}
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
tViewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
IOutputProperty property = (IOutputProperty) element;
return property.getURI();
}
});
tViewer.setSorter(new ViewerSorter() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
IOutputProperty a1 = (IOutputProperty) e1;
IOutputProperty a2 = (IOutputProperty) e2;
return a1.getURI().compareTo(a2.getURI());
}
});
tViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
selectedProperties = sel.toList();
if (sel.isEmpty())
// $NON-NLS-1$
text.setText("");
else {
IOutputProperty property = (IOutputProperty) sel.getFirstElement();
text.setText(property.getDescription());
}
}
});
tViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
buttonPressed(IDialogConstants.OK_ID);
}
});
tViewer.setInput(properties);
text = new Text(comp, SWT.BORDER | SWT.WRAP | SWT.READ_ONLY | SWT.V_SCROLL);
text.setEditable(false);
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
gd.heightHint = 80;
text.setLayoutData(gd);
if (properties.size() > 0) {
tViewer.setSelection(new StructuredSelection(tViewer.getElementAt(0)), true);
}
return comp;
}
use of org.eclipse.jface.viewers.IStructuredContentProvider in project webtools.sourceediting by eclipse.
the class AttributeDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.widthHint = 400;
comp.setLayoutData(gd);
comp.setLayout(new GridLayout());
Label label = new Label(comp, SWT.NONE);
// $NON-NLS-1$
label.setText(Messages.getString("AttributeDialog_1"));
table = new Table(comp, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.MULTI);
table.setHeaderVisible(false);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.verticalIndent = 10;
gd.heightHint = 200;
table.setLayoutData(gd);
tViewer = new TableViewer(table);
tViewer.setContentProvider(new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
return attributes.toArray(new IAttribute[0]);
}
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
tViewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
IAttribute attribute = (IAttribute) element;
return attribute.getURI();
}
});
tViewer.setSorter(new ViewerSorter() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
IAttribute a1 = (IAttribute) e1;
IAttribute a2 = (IAttribute) e2;
return a1.getURI().compareTo(a2.getURI());
}
});
tViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
selectedAttributes = sel.toList();
if (sel.isEmpty())
// $NON-NLS-1$
text.setText(Messages.getString("AttributeDialog_2"));
else {
IAttribute attribute = (IAttribute) sel.getFirstElement();
text.setText(attribute.getDescription());
}
}
});
tViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
buttonPressed(IDialogConstants.OK_ID);
}
});
tViewer.setInput(attributes);
text = new Text(comp, SWT.BORDER | SWT.WRAP | SWT.READ_ONLY | SWT.V_SCROLL);
text.setEditable(false);
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
gd.heightHint = 80;
text.setLayoutData(gd);
if (attributes.size() > 0) {
tViewer.setSelection(new StructuredSelection(tViewer.getElementAt(0)), true);
}
return comp;
}
use of org.eclipse.jface.viewers.IStructuredContentProvider in project webtools.sourceediting by eclipse.
the class OutputPropertiesBlock method createControl.
public void createControl(Composite parent) {
TabItem item = new TabItem((TabFolder) parent, SWT.NONE);
// $NON-NLS-1$
item.setText(Messages.getString("OutputPropertiesBlock_0"));
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
layout.marginBottom = 0;
layout.marginWidth = 0;
composite.setLayout(layout);
item.setControl(composite);
table = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.MULTI);
table.setHeaderVisible(true);
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
table.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent event) {
if (event.character == SWT.DEL && event.stateMask == 0) {
performRemove();
}
}
});
TableColumn tc1 = new TableColumn(table, SWT.NONE);
// $NON-NLS-1$
tc1.setText(Messages.getString("OutputPropertiesBlock_1"));
tc1.setWidth(350);
tc1.setResizable(true);
TableColumn tc2 = new TableColumn(table, SWT.NONE);
// $NON-NLS-1$
tc2.setText(Messages.getString("OutputPropertiesBlock_2"));
tc2.setWidth(50);
tc2.setResizable(true);
Composite buttonComp = new Composite(composite, SWT.FILL);
buttonComp.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
GridLayout gl = new GridLayout();
gl.marginWidth = 0;
buttonComp.setLayout(gl);
Button addButton = new Button(buttonComp, SWT.PUSH);
// $NON-NLS-1$
addButton.setText(Messages.getString("OutputPropertiesBlock_3"));
addButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
addButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
OutputPropertyDialog dialog = new OutputPropertyDialog(getShell(), properties);
if (dialog.open() == Window.OK) {
List<IOutputProperty> newProperties = dialog.getOutpuProperties();
String first = null;
for (IOutputProperty property : newProperties) {
String att = property.getURI();
if (first == null)
first = att;
properties.setProperty(property.getURI(), null);
}
if (newProperties.size() > 0) {
tViewer.refresh();
tViewer.setSelection(new StructuredSelection(first), true);
tViewer.editElement(first, 1);
updateLaunchConfigurationDialog();
}
}
}
});
removeButton = new Button(buttonComp, SWT.PUSH);
// $NON-NLS-1$
removeButton.setText(Messages.getString("OutputPropertiesBlock_4"));
removeButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
removeButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
performRemove();
}
});
setControl(table);
tViewer = new TableViewer(table);
tViewer.setContentProvider(new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
return properties.getProperties().keySet().toArray(new String[0]);
}
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
tViewer.setSorter(new ViewerSorter());
tViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
updateRemoveButton();
}
});
TableViewerColumn tvc1 = new TableViewerColumn(tViewer, tc1);
tvc1.setLabelProvider(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
String tv = (String) cell.getElement();
cell.setText(tv);
}
@Override
public int getToolTipTimeDisplayed(Object object) {
return 5000;
}
@Override
public String getToolTipText(Object element) {
String tv = (String) element;
return propertyUris.get(tv).getDescription();
}
});
// ColumnViewerToolTipSupport.enableFor(tViewer);
TableViewerColumn tvc2 = new TableViewerColumn(tViewer, tc2);
tvc2.setLabelProvider(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
String tv = (String) cell.getElement();
String val = properties.getProperty(tv);
// $NON-NLS-1$
cell.setText(val == null ? "" : val);
}
});
tvc2.setEditingSupport(new EditingSupport(tViewer) {
@Override
protected boolean canEdit(Object element) {
return true;
}
@Override
protected CellEditor getCellEditor(Object element) {
return new TextCellEditor(table);
}
@Override
protected Object getValue(Object element) {
String tv = (String) element;
String val = properties.getProperty(tv);
// $NON-NLS-1$
return val == null ? "" : val;
}
@Override
protected void setValue(Object element, Object value) {
String tv = (String) element;
properties.setProperty(tv, (String) value);
updateLaunchConfigurationDialog();
tViewer.update(tv, null);
}
});
restoreColumnSettings();
}
Aggregations