use of org.netxms.ui.eclipse.objectmanager.propertypages.helpers.UrlListLabelProvider in project netxms by netxms.
the class ExternalResources method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
Composite dialogArea = new Composite(parent, SWT.NONE);
object = (AbstractObject) getElement().getAdapter(AbstractObject.class);
if (// Paranoid check
object == null)
return dialogArea;
GridLayout layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
layout.marginWidth = 0;
layout.marginHeight = 0;
layout.numColumns = 2;
dialogArea.setLayout(layout);
final String[] columnNames = { "URL", "Description" };
final int[] columnWidths = { 300, 300 };
viewer = new SortableTableViewer(dialogArea, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new UrlListLabelProvider());
urls = new ArrayList<ObjectUrl>(object.getUrls());
viewer.setInput(urls);
GridData gridData = new GridData();
gridData.verticalAlignment = GridData.FILL;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.horizontalSpan = 2;
gridData.heightHint = 0;
viewer.getControl().setLayoutData(gridData);
Composite buttonsLeft = new Composite(dialogArea, SWT.NONE);
RowLayout buttonLayout = new RowLayout();
buttonLayout.type = SWT.HORIZONTAL;
buttonLayout.pack = false;
buttonLayout.marginWidth = 0;
buttonLayout.marginRight = 0;
buttonsLeft.setLayout(buttonLayout);
gridData = new GridData();
gridData.horizontalAlignment = SWT.LEFT;
buttonsLeft.setLayoutData(gridData);
moveUpButton = new Button(buttonsLeft, SWT.PUSH);
moveUpButton.setText("&Up");
RowData rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
moveUpButton.setLayoutData(rd);
moveUpButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
moveSelection(true);
}
});
moveDownButton = new Button(buttonsLeft, SWT.PUSH);
moveDownButton.setText("&Down");
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
moveDownButton.setLayoutData(rd);
moveDownButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
moveSelection(false);
}
});
Composite buttonsRight = new Composite(dialogArea, SWT.NONE);
buttonLayout = new RowLayout();
buttonLayout.type = SWT.HORIZONTAL;
buttonLayout.pack = false;
buttonLayout.marginWidth = 0;
buttonLayout.marginRight = 0;
buttonsRight.setLayout(buttonLayout);
gridData = new GridData();
gridData.horizontalAlignment = SWT.RIGHT;
buttonsRight.setLayoutData(gridData);
addButton = new Button(buttonsRight, SWT.PUSH);
addButton.setText(Messages.get().CustomAttributes_Add);
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
addButton.setLayoutData(rd);
addButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
addUrl();
}
});
editButton = new Button(buttonsRight, SWT.PUSH);
editButton.setText(Messages.get().CustomAttributes_Modify);
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
editButton.setLayoutData(rd);
editButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
editUrl();
}
});
deleteButton = new Button(buttonsRight, SWT.PUSH);
deleteButton.setText(Messages.get().CustomAttributes_Delete);
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
deleteButton.setLayoutData(rd);
deleteButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
deleteUrl();
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
editButton.notifyListeners(SWT.Selection, new Event());
}
});
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
moveUpButton.setEnabled(selection.size() == 1);
moveDownButton.setEnabled(selection.size() == 1);
editButton.setEnabled(selection.size() == 1);
deleteButton.setEnabled(selection.size() > 0);
}
});
return dialogArea;
}
Aggregations