use of org.netxms.client.ObjectUrl in project netxms by netxms.
the class AbstractObject method getStrings.
/**
* Get all strings in object
*
* @return set of all strings in object
*/
public Set<String> getStrings() {
Set<String> strings = new HashSet<String>();
addString(strings, comments);
addString(strings, objectName);
if ((postalAddress != null) && !postalAddress.isEmpty())
strings.add(postalAddress.getAddressLine());
for (String s : customAttributes.values()) addString(strings, s);
for (ObjectUrl u : urls) {
addString(strings, u.getUrl().toString());
addString(strings, u.getDescription());
}
return strings;
}
use of org.netxms.client.ObjectUrl 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;
}
use of org.netxms.client.ObjectUrl in project netxms by netxms.
the class ExternalResources method moveSelection.
/**
* Move selection
*
* @param up
*/
private void moveSelection(boolean up) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() != 1)
return;
ObjectUrl url = (ObjectUrl) selection.getFirstElement();
int index = urls.indexOf(url);
if (((index == 0) && up) || ((index == urls.size() - 1) && !up))
return;
int swapIndex = up ? index - 1 : index + 1;
ObjectUrl swapUrl = urls.get(swapIndex);
urls.set(index, new ObjectUrl(index, swapUrl.getUrl(), swapUrl.getDescription()));
urls.set(swapIndex, new ObjectUrl(index, url.getUrl(), url.getDescription()));
viewer.refresh();
viewer.setSelection(new StructuredSelection(urls.get(swapIndex)));
modified = true;
}
use of org.netxms.client.ObjectUrl in project netxms by netxms.
the class ExternalResources method addUrl.
/**
* Add new URL
*/
private void addUrl() {
ObjectUrlEditDialog dlg = new ObjectUrlEditDialog(getShell(), null, null);
if (dlg.open() != Window.OK)
return;
urls.add(new ObjectUrl(urls.size(), dlg.getUrl(), dlg.getDescription()));
viewer.refresh();
modified = true;
}
use of org.netxms.client.ObjectUrl in project netxms by netxms.
the class ExternalResources method onObjectChange.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.objectview.objecttabs.elements.OverviewPageElement#onObjectChange()
*/
@Override
protected void onObjectChange() {
for (Element e : elements) e.dispose();
elements.clear();
for (ObjectUrl u : getObject().getUrls()) elements.add(new Element(content, u));
content.layout();
}
Aggregations