Search in sources :

Example 1 with ObjectUrl

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;
}
Also used : ObjectUrl(org.netxms.client.ObjectUrl) HashSet(java.util.HashSet)

Example 2 with ObjectUrl

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;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) UrlListLabelProvider(org.netxms.ui.eclipse.objectmanager.propertypages.helpers.UrlListLabelProvider) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) RowData(org.eclipse.swt.layout.RowData) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ObjectUrl(org.netxms.client.ObjectUrl) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 3 with ObjectUrl

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;
}
Also used : ObjectUrl(org.netxms.client.ObjectUrl) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 4 with ObjectUrl

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;
}
Also used : ObjectUrlEditDialog(org.netxms.ui.eclipse.objectmanager.dialogs.ObjectUrlEditDialog) ObjectUrl(org.netxms.client.ObjectUrl)

Example 5 with ObjectUrl

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();
}
Also used : ObjectUrl(org.netxms.client.ObjectUrl)

Aggregations

ObjectUrl (org.netxms.client.ObjectUrl)8 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 ObjectUrlEditDialog (org.netxms.ui.eclipse.objectmanager.dialogs.ObjectUrlEditDialog)2 HashSet (java.util.HashSet)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 SelectionListener (org.eclipse.swt.events.SelectionListener)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 RowData (org.eclipse.swt.layout.RowData)1 RowLayout (org.eclipse.swt.layout.RowLayout)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 Event (org.eclipse.swt.widgets.Event)1