Search in sources :

Example 6 with ObjectUrl

use of org.netxms.client.ObjectUrl in project netxms by netxms.

the class ExternalResources method editUrl.

/**
 * Edit selected URL
 */
private void editUrl() {
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    if (selection.size() != 1)
        return;
    ObjectUrl url = (ObjectUrl) selection.getFirstElement();
    ObjectUrlEditDialog dlg = new ObjectUrlEditDialog(getShell(), url.getUrl(), url.getDescription());
    if (dlg.open() != Window.OK)
        return;
    int index = urls.indexOf(url);
    urls.set(index, new ObjectUrl(url.getId(), dlg.getUrl(), dlg.getDescription()));
    viewer.refresh();
    viewer.setSelection(new StructuredSelection(urls.get(index)));
    modified = true;
}
Also used : ObjectUrlEditDialog(org.netxms.ui.eclipse.objectmanager.dialogs.ObjectUrlEditDialog) ObjectUrl(org.netxms.client.ObjectUrl) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 7 with ObjectUrl

use of org.netxms.client.ObjectUrl in project netxms by netxms.

the class ExternalResources method deleteUrl.

/**
 * Delete selected URLs
 */
private void deleteUrl() {
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    if (selection.isEmpty())
        return;
    for (Object o : selection.toList()) urls.remove(o);
    for (int i = 0; i < urls.size(); i++) {
        ObjectUrl u = urls.get(i);
        urls.set(i, new ObjectUrl(i, u.getUrl(), u.getDescription()));
    }
    viewer.refresh();
    modified = true;
}
Also used : ObjectUrl(org.netxms.client.ObjectUrl) AbstractObject(org.netxms.client.objects.AbstractObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 8 with ObjectUrl

use of org.netxms.client.ObjectUrl in project netxms by netxms.

the class ExternalResources method applyChanges.

/**
 * Apply changes
 *
 * @param isApply true if update operation caused by "Apply" button
 */
protected void applyChanges(final boolean isApply) {
    if (!modified)
        // Nothing to apply
        return;
    if (isApply)
        setValid(false);
    final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
    md.setUrls(new ArrayList<ObjectUrl>(urls));
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().CustomAttributes_JobName, null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            session.modifyObject(md);
            modified = false;
        }

        @Override
        protected String getErrorMessage() {
            return "Cannot update object's URL list";
        }

        @Override
        protected void jobFinalize() {
            if (isApply) {
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        ExternalResources.this.setValid(true);
                    }
                });
            }
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) NXCObjectModificationData(org.netxms.client.NXCObjectModificationData) ObjectUrl(org.netxms.client.ObjectUrl) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

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