d1b7afc67ccb581e6e2a25a28550b16e21803803
[public/netxms.git] / src / java / netxms-eclipse / DataCollection / src / org / netxms / ui / eclipse / datacollection / propertypages / General.java
1 /**
2 * NetXMS - open source network management system
3 * Copyright (C) 2003-2011 Victor Kirhenshtein
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 package org.netxms.ui.eclipse.datacollection.propertypages;
20
21 import java.util.HashMap;
22 import java.util.Map;
23
24 import org.eclipse.core.runtime.IProgressMonitor;
25 import org.eclipse.jface.dialogs.Dialog;
26 import org.eclipse.jface.window.Window;
27 import org.eclipse.swt.SWT;
28 import org.eclipse.swt.events.SelectionEvent;
29 import org.eclipse.swt.events.SelectionListener;
30 import org.eclipse.swt.layout.FillLayout;
31 import org.eclipse.swt.layout.FormAttachment;
32 import org.eclipse.swt.layout.FormData;
33 import org.eclipse.swt.layout.FormLayout;
34 import org.eclipse.swt.layout.GridData;
35 import org.eclipse.swt.layout.GridLayout;
36 import org.eclipse.swt.layout.RowLayout;
37 import org.eclipse.swt.widgets.Button;
38 import org.eclipse.swt.widgets.Combo;
39 import org.eclipse.swt.widgets.Composite;
40 import org.eclipse.swt.widgets.Control;
41 import org.eclipse.swt.widgets.Group;
42 import org.eclipse.swt.widgets.Text;
43 import org.eclipse.ui.dialogs.PropertyPage;
44 import org.netxms.client.NXCSession;
45 import org.netxms.client.datacollection.DataCollectionItem;
46 import org.netxms.client.objects.Cluster;
47 import org.netxms.client.objects.ClusterResource;
48 import org.netxms.client.objects.GenericObject;
49 import org.netxms.client.objects.Node;
50 import org.netxms.client.snmp.SnmpObjectId;
51 import org.netxms.client.snmp.SnmpObjectIdFormatException;
52 import org.netxms.ui.eclipse.datacollection.Activator;
53 import org.netxms.ui.eclipse.datacollection.Messages;
54 import org.netxms.ui.eclipse.datacollection.dialogs.IParameterSelectionDialog;
55 import org.netxms.ui.eclipse.datacollection.dialogs.SelectAgentParamDlg;
56 import org.netxms.ui.eclipse.datacollection.dialogs.SelectInternalParamDlg;
57 import org.netxms.ui.eclipse.datacollection.dialogs.SelectSnmpParamDlg;
58 import org.netxms.ui.eclipse.datacollection.dialogs.WinPerfCounterSelectionDialog;
59 import org.netxms.ui.eclipse.jobs.ConsoleJob;
60 import org.netxms.ui.eclipse.objectbrowser.widgets.ObjectSelector;
61 import org.netxms.ui.eclipse.shared.ConsoleSharedData;
62 import org.netxms.ui.eclipse.tools.NumericTextFieldValidator;
63 import org.netxms.ui.eclipse.tools.WidgetHelper;
64 import org.netxms.ui.eclipse.widgets.LabeledText;
65
66 /**
67 * "General" property page for DCI
68 */
69 public class General extends PropertyPage
70 {
71 private static final String[] snmpRawTypes =
72 {
73 Messages.General_SNMP_DT_None,
74 Messages.General_SNMP_DT_int32,
75 Messages.General_SNMP_DT_uint32,
76 Messages.General_SNMP_DT_int64,
77 Messages.General_SNMP_DT_uint64,
78 Messages.General_SNMP_DT_float,
79 Messages.General_SNMP_DT_ipAddr,
80 Messages.General_SNMP_DT_macAddr
81 };
82
83 private DataCollectionItem dci;
84 private GenericObject owner;
85 private Cluster cluster = null;
86 private Map<Integer, Long> clusterResourceMap;
87 private Text description;
88 private LabeledText parameter;
89 private Button selectButton;
90 private Combo origin;
91 private Combo dataType;
92 private Button checkInterpretRawSnmpValue;
93 private Combo snmpRawType;
94 private Button checkUseCustomSnmpPort;
95 private Text customSnmpPort;
96 private ObjectSelector proxyNode;
97 private Combo schedulingMode;
98 private LabeledText pollingInterval;
99 private LabeledText retentionTime;
100 private Combo clusterResource;
101 private Button statusActive;
102 private Button statusDisabled;
103 private Button statusUnsupported;
104
105 /* (non-Javadoc)
106 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
107 */
108 @Override
109 protected Control createContents(Composite parent)
110 {
111 dci = (DataCollectionItem)getElement().getAdapter(DataCollectionItem.class);
112 final NXCSession session = (NXCSession)ConsoleSharedData.getSession();
113 owner = session.findObjectById(dci.getNodeId());
114
115 if (owner instanceof Cluster)
116 {
117 cluster = (Cluster)owner;
118 }
119 else if (owner instanceof Node)
120 {
121 for(GenericObject o : owner.getParentsAsArray())
122 {
123 if (o instanceof Cluster)
124 {
125 cluster = (Cluster)o;
126 break;
127 }
128 }
129 }
130
131 Composite dialogArea = new Composite(parent, SWT.NONE);
132
133 GridLayout layout = new GridLayout();
134 layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
135 layout.marginWidth = 0;
136 layout.marginHeight = 0;
137 layout.numColumns = 2;
138 dialogArea.setLayout(layout);
139
140 /** description area **/
141 Group groupDescription = new Group(dialogArea, SWT.NONE);
142 groupDescription.setText(Messages.General_Description);
143 FillLayout descriptionLayout = new FillLayout();
144 descriptionLayout.marginWidth = WidgetHelper.OUTER_SPACING;
145 descriptionLayout.marginHeight = WidgetHelper.OUTER_SPACING;
146 groupDescription.setLayout(descriptionLayout);
147 description = new Text(groupDescription, SWT.BORDER);
148 description.setTextLimit(255);
149 description.setText(dci.getDescription());
150 GridData gd = new GridData();
151 gd.grabExcessHorizontalSpace = true;
152 gd.horizontalAlignment = SWT.FILL;
153 gd.horizontalSpan = 2;
154 groupDescription.setLayoutData(gd);
155
156 /** data area **/
157 Group groupData = new Group(dialogArea, SWT.NONE);
158 groupData.setText(Messages.General_Data);
159 FormLayout dataLayout = new FormLayout();
160 dataLayout.marginHeight = WidgetHelper.OUTER_SPACING;
161 dataLayout.marginWidth = WidgetHelper.OUTER_SPACING;
162 groupData.setLayout(dataLayout);
163 gd = new GridData();
164 gd.grabExcessHorizontalSpace = true;
165 gd.horizontalAlignment = SWT.FILL;
166 gd.horizontalSpan = 2;
167 groupData.setLayoutData(gd);
168
169 parameter = new LabeledText(groupData, SWT.NONE);
170 parameter.setLabel(Messages.General_Parameter);
171 parameter.getTextControl().setTextLimit(255);
172 parameter.setText(dci.getName());
173
174 selectButton = new Button(groupData, SWT.PUSH);
175 selectButton.setText(Messages.General_Select);
176 selectButton.addSelectionListener(new SelectionListener() {
177 @Override
178 public void widgetDefaultSelected(SelectionEvent e)
179 {
180 widgetSelected(e);
181 }
182
183 @Override
184 public void widgetSelected(SelectionEvent e)
185 {
186 selectParameter();
187 }
188 });
189
190 FormData fd = new FormData();
191 fd.left = new FormAttachment(0, 0);
192 fd.top = new FormAttachment(0, 0);
193 fd.right = new FormAttachment(selectButton, -WidgetHelper.INNER_SPACING, SWT.LEFT);
194 parameter.setLayoutData(fd);
195
196 fd = new FormData();
197 fd.right = new FormAttachment(100, 0);
198 fd.bottom = new FormAttachment(parameter, 0, SWT.BOTTOM);
199 fd.width = WidgetHelper.BUTTON_WIDTH_HINT;
200 selectButton.setLayoutData(fd);
201
202 fd = new FormData();
203 fd.left = new FormAttachment(0, 0);
204 fd.top = new FormAttachment(parameter, WidgetHelper.OUTER_SPACING, SWT.BOTTOM);
205 fd.right = new FormAttachment(50, -WidgetHelper.OUTER_SPACING / 2);
206 origin = WidgetHelper.createLabeledCombo(groupData, SWT.READ_ONLY, Messages.General_Origin, fd);
207 origin.add(Messages.General_SourceInternal);
208 origin.add(Messages.General_SourceAgent);
209 origin.add(Messages.General_SourceSNMP);
210 origin.add(Messages.General_SourceCPSNMP);
211 origin.add(Messages.General_SourcePush);
212 origin.add("Windows Performance Counters");
213 origin.select(dci.getOrigin());
214 origin.addSelectionListener(new SelectionListener() {
215 @Override
216 public void widgetDefaultSelected(SelectionEvent e)
217 {
218 widgetSelected(e);
219 }
220
221 @Override
222 public void widgetSelected(SelectionEvent e)
223 {
224 onOriginChange();
225 }
226 });
227
228 fd = new FormData();
229 fd.left = new FormAttachment(50, WidgetHelper.OUTER_SPACING / 2);
230 fd.top = new FormAttachment(parameter, WidgetHelper.OUTER_SPACING, SWT.BOTTOM);
231 fd.right = new FormAttachment(100, 0);
232 dataType = WidgetHelper.createLabeledCombo(groupData, SWT.READ_ONLY, Messages.General_DataType, fd);
233 dataType.add(Messages.General_DT_int32);
234 dataType.add(Messages.General_DT_uint32);
235 dataType.add(Messages.General_DT_int64);
236 dataType.add(Messages.General_DT_uint64);
237 dataType.add(Messages.General_DT_string);
238 dataType.add(Messages.General_DT_float);
239 dataType.select(dci.getDataType());
240
241 checkInterpretRawSnmpValue = new Button(groupData, SWT.CHECK);
242 checkInterpretRawSnmpValue.setText(Messages.General_InterpretRawValue);
243 checkInterpretRawSnmpValue.setSelection(dci.isSnmpRawValueInOctetString());
244 checkInterpretRawSnmpValue.addSelectionListener(new SelectionListener() {
245 @Override
246 public void widgetSelected(SelectionEvent e)
247 {
248 snmpRawType.setEnabled(checkInterpretRawSnmpValue.getSelection());
249 }
250
251 @Override
252 public void widgetDefaultSelected(SelectionEvent e)
253 {
254 widgetSelected(e);
255 }
256 });
257 fd = new FormData();
258 fd.left = new FormAttachment(0, 0);
259 fd.top = new FormAttachment(origin.getParent(), WidgetHelper.OUTER_SPACING, SWT.BOTTOM);
260 checkInterpretRawSnmpValue.setLayoutData(fd);
261 checkInterpretRawSnmpValue.setEnabled(dci.getOrigin() == DataCollectionItem.SNMP);
262
263 snmpRawType = new Combo(groupData, SWT.BORDER | SWT.READ_ONLY);
264 for(int i = 0; i < snmpRawTypes.length; i++)
265 snmpRawType.add(snmpRawTypes[i]);
266 snmpRawType.select(dci.getSnmpRawValueType());
267 snmpRawType.setEnabled((dci.getOrigin() == DataCollectionItem.SNMP) && dci.isSnmpRawValueInOctetString());
268 fd = new FormData();
269 fd.left = new FormAttachment(0, 0);
270 fd.top = new FormAttachment(checkInterpretRawSnmpValue, WidgetHelper.OUTER_SPACING, SWT.BOTTOM);
271 fd.right = new FormAttachment(checkInterpretRawSnmpValue, 0, SWT.RIGHT);
272 snmpRawType.setLayoutData(fd);
273
274 checkUseCustomSnmpPort = new Button(groupData, SWT.CHECK);
275 checkUseCustomSnmpPort.setText(Messages.General_UseCustomPort);
276 checkUseCustomSnmpPort.setSelection(dci.getSnmpPort() != 0);
277 checkUseCustomSnmpPort.addSelectionListener(new SelectionListener() {
278 @Override
279 public void widgetSelected(SelectionEvent e)
280 {
281 customSnmpPort.setEnabled(checkUseCustomSnmpPort.getSelection());
282 }
283
284 @Override
285 public void widgetDefaultSelected(SelectionEvent e)
286 {
287 widgetSelected(e);
288 }
289 });
290 fd = new FormData();
291 fd.left = new FormAttachment(checkInterpretRawSnmpValue, WidgetHelper.OUTER_SPACING, SWT.RIGHT);
292 fd.right = new FormAttachment(100, 0);
293 fd.top = new FormAttachment(dataType.getParent(), WidgetHelper.OUTER_SPACING, SWT.BOTTOM);
294 checkUseCustomSnmpPort.setLayoutData(fd);
295 checkUseCustomSnmpPort.setEnabled(dci.getOrigin() == DataCollectionItem.SNMP);
296
297 customSnmpPort = new Text(groupData, SWT.BORDER);
298 if ((dci.getOrigin() == DataCollectionItem.SNMP) && (dci.getSnmpPort() != 0))
299 {
300 customSnmpPort.setEnabled(true);
301 customSnmpPort.setText(Integer.toString(dci.getSnmpPort()));
302 }
303 else
304 {
305 customSnmpPort.setEnabled(false);
306 }
307 fd = new FormData();
308 fd.left = new FormAttachment(checkInterpretRawSnmpValue, WidgetHelper.OUTER_SPACING, SWT.RIGHT);
309 fd.right = new FormAttachment(100, 0);
310 fd.top = new FormAttachment(checkUseCustomSnmpPort, WidgetHelper.OUTER_SPACING, SWT.BOTTOM);
311 customSnmpPort.setLayoutData(fd);
312
313 proxyNode = new ObjectSelector(groupData, SWT.NONE, true);
314 proxyNode.setLabel(Messages.General_ProxyNode);
315 fd = new FormData();
316 fd.left = new FormAttachment(0, 0);
317 fd.top = new FormAttachment(snmpRawType, WidgetHelper.OUTER_SPACING, SWT.BOTTOM);
318 fd.right = new FormAttachment(100, 0);
319 proxyNode.setLayoutData(fd);
320 proxyNode.setObjectClass(Node.class);
321 proxyNode.setObjectId(dci.getProxyNode());
322 proxyNode.setEnabled(dci.getOrigin() != DataCollectionItem.PUSH);
323
324 /** polling area **/
325 Group groupPolling = new Group(dialogArea, SWT.NONE);
326 groupPolling.setText(Messages.General_Polling);
327 FormLayout pollingLayout = new FormLayout();
328 pollingLayout.marginHeight = WidgetHelper.OUTER_SPACING;
329 pollingLayout.marginWidth = WidgetHelper.OUTER_SPACING;
330 groupPolling.setLayout(pollingLayout);
331 gd = new GridData();
332 gd.grabExcessHorizontalSpace = true;
333 gd.horizontalAlignment = SWT.FILL;
334 gd.verticalAlignment = SWT.FILL;
335 groupPolling.setLayoutData(gd);
336
337 fd = new FormData();
338 fd.left = new FormAttachment(0, 0);
339 fd.right = new FormAttachment(50, -WidgetHelper.OUTER_SPACING / 2);
340 fd.top = new FormAttachment(0, 0);
341 schedulingMode = WidgetHelper.createLabeledCombo(groupPolling, SWT.READ_ONLY, Messages.General_PollingMode, fd);
342 schedulingMode.add(Messages.General_FixedIntervals);
343 schedulingMode.add(Messages.General_CustomSchedule);
344 schedulingMode.select(dci.isUseAdvancedSchedule() ? 1 : 0);
345 schedulingMode.setEnabled(dci.getOrigin() != DataCollectionItem.PUSH);
346 schedulingMode.addSelectionListener(new SelectionListener() {
347 @Override
348 public void widgetDefaultSelected(SelectionEvent e)
349 {
350 widgetSelected(e);
351 }
352
353 @Override
354 public void widgetSelected(SelectionEvent e)
355 {
356 pollingInterval.getTextControl().setEnabled(schedulingMode.getSelectionIndex() == 0);
357 }
358 });
359
360 pollingInterval = new LabeledText(groupPolling, SWT.NONE);
361 pollingInterval.getTextControl().setTextLimit(5);
362 pollingInterval.setLabel(Messages.General_PollingInterval);
363 pollingInterval.setText(Integer.toString(dci.getPollingInterval()));
364 pollingInterval.setEnabled(!dci.isUseAdvancedSchedule() && (dci.getOrigin() != DataCollectionItem.PUSH));
365 fd = new FormData();
366 fd.left = new FormAttachment(50, WidgetHelper.OUTER_SPACING / 2);
367 fd.right = new FormAttachment(100, 0);
368 fd.top = new FormAttachment(0, 0);
369 pollingInterval.setLayoutData(fd);
370
371 fd = new FormData();
372 fd.left = new FormAttachment(0, 0);
373 fd.right = new FormAttachment(100, 0);
374 fd.top = new FormAttachment(schedulingMode.getParent(), WidgetHelper.OUTER_SPACING, SWT.BOTTOM);
375 clusterResource = WidgetHelper.createLabeledCombo(groupPolling, SWT.READ_ONLY, Messages.General_ClRes, fd);
376 if (cluster != null)
377 {
378 clusterResourceMap = new HashMap<Integer, Long>();
379 clusterResourceMap.put(0, 0L);
380
381 clusterResource.add(Messages.General_None);
382 if (dci.getResourceId() == 0)
383 clusterResource.select(0);
384
385 int index = 1;
386 for (ClusterResource r : cluster.getResources())
387 {
388 clusterResource.add(r.getName());
389 clusterResourceMap.put(index, r.getId());
390 if (dci.getResourceId() == r.getId())
391 clusterResource.select(index);
392 index++;
393 }
394 }
395 else
396 {
397 clusterResource.add(Messages.General_None);
398 clusterResource.select(0);
399 clusterResource.setEnabled(false);
400 }
401
402 /** status **/
403 Group groupStatus = new Group(dialogArea, SWT.NONE);
404 groupStatus.setText(Messages.General_Status);
405 gd = new GridData();
406 gd.horizontalAlignment = SWT.FILL;
407 gd.verticalAlignment = SWT.FILL;
408 groupStatus.setLayoutData(gd);
409 RowLayout statusLayout = new RowLayout();
410 statusLayout.type = SWT.VERTICAL;
411 groupStatus.setLayout(statusLayout);
412
413 statusActive = new Button(groupStatus, SWT.RADIO);
414 statusActive.setText(Messages.General_Active);
415 statusActive.setSelection(dci.getStatus() == DataCollectionItem.ACTIVE);
416
417 statusDisabled = new Button(groupStatus, SWT.RADIO);
418 statusDisabled.setText(Messages.General_Disabled);
419 statusDisabled.setSelection(dci.getStatus() == DataCollectionItem.DISABLED);
420
421 statusUnsupported = new Button(groupStatus, SWT.RADIO);
422 statusUnsupported.setText(Messages.General_NotSupported);
423 statusUnsupported.setSelection(dci.getStatus() == DataCollectionItem.NOT_SUPPORTED);
424
425 /** storage **/
426 Group groupStorage = new Group(dialogArea, SWT.NONE);
427 groupStorage.setText(Messages.General_Storage);
428 gd = new GridData();
429 gd.horizontalAlignment = SWT.FILL;
430 gd.verticalAlignment = SWT.FILL;
431 gd.horizontalSpan = 2;
432 groupStorage.setLayoutData(gd);
433 FillLayout storageLayout = new FillLayout();
434 storageLayout.marginWidth = WidgetHelper.OUTER_SPACING;
435 storageLayout.marginHeight = WidgetHelper.OUTER_SPACING;
436 groupStorage.setLayout(storageLayout);
437
438 retentionTime = new LabeledText(groupStorage, SWT.NONE);
439 retentionTime.setLabel(Messages.General_RetentionTime);
440 retentionTime.getTextControl().setTextLimit(5);
441 retentionTime.setText(Integer.toString(dci.getRetentionTime()));
442
443 return dialogArea;
444 }
445
446 /**
447 * Handler for changing item origin
448 */
449 private void onOriginChange()
450 {
451 int index = origin.getSelectionIndex();
452 proxyNode.setEnabled(index != DataCollectionItem.PUSH);
453 schedulingMode.setEnabled(index != DataCollectionItem.PUSH);
454 pollingInterval.getTextControl().setEnabled((index != DataCollectionItem.PUSH) && (schedulingMode.getSelectionIndex() == 0));
455 checkInterpretRawSnmpValue.setEnabled(index == DataCollectionItem.SNMP);
456 snmpRawType.setEnabled((index == DataCollectionItem.SNMP) && checkInterpretRawSnmpValue.getSelection());
457 checkUseCustomSnmpPort.setEnabled(index == DataCollectionItem.SNMP);
458 customSnmpPort.setEnabled((index == DataCollectionItem.SNMP) && checkUseCustomSnmpPort.getSelection());
459 }
460
461 /**
462 * Select parameter
463 */
464 private void selectParameter()
465 {
466 Dialog dlg;
467 switch(origin.getSelectionIndex())
468 {
469 case DataCollectionItem.INTERNAL:
470 dlg = new SelectInternalParamDlg(getShell(), dci.getNodeId());
471 break;
472 case DataCollectionItem.AGENT:
473 dlg = new SelectAgentParamDlg(getShell(), dci.getNodeId(), false);
474 break;
475 case DataCollectionItem.SNMP:
476 case DataCollectionItem.CHECKPOINT_SNMP:
477 SnmpObjectId oid;
478 try
479 {
480 oid = SnmpObjectId.parseSnmpObjectId(parameter.getText());
481 }
482 catch(SnmpObjectIdFormatException e)
483 {
484 oid = null;
485 }
486 dlg = new SelectSnmpParamDlg(getShell(), oid);
487 break;
488 case DataCollectionItem.WINPERF:
489 dlg = new WinPerfCounterSelectionDialog(getShell(), dci.getNodeId());
490 break;
491 default:
492 dlg = null;
493 break;
494 }
495
496 if ((dlg != null) && (dlg.open() == Window.OK))
497 {
498 IParameterSelectionDialog pd = (IParameterSelectionDialog)dlg;
499 description.setText(pd.getParameterDescription());
500 parameter.setText(pd.getParameterName());
501 dataType.select(pd.getParameterDataType());
502 }
503 }
504
505 /**
506 * Apply changes
507 *
508 * @param isApply true if update operation caused by "Apply" button
509 */
510 protected boolean applyChanges(final boolean isApply)
511 {
512 if (!WidgetHelper.validateTextInput(customSnmpPort, Messages.General_CustomPort, new NumericTextFieldValidator(1, 65535), this) ||
513 !WidgetHelper.validateTextInput(pollingInterval, new NumericTextFieldValidator(1, 1000000), this) ||
514 !WidgetHelper.validateTextInput(retentionTime, new NumericTextFieldValidator(1, 65535), this))
515 return false;
516
517 if (isApply)
518 setValid(false);
519
520 dci.setDescription(description.getText().trim());
521 dci.setName(parameter.getText().trim());
522 dci.setOrigin(origin.getSelectionIndex());
523 dci.setDataType(dataType.getSelectionIndex());
524 dci.setProxyNode(proxyNode.getObjectId());
525 dci.setUseAdvancedSchedule(schedulingMode.getSelectionIndex() == 1);
526 dci.setPollingInterval(Integer.parseInt(pollingInterval.getText()));
527 dci.setRetentionTime(Integer.parseInt(retentionTime.getText()));
528 dci.setSnmpRawValueInOctetString(checkInterpretRawSnmpValue.getSelection());
529 dci.setSnmpRawValueType(snmpRawType.getSelectionIndex());
530 if (checkUseCustomSnmpPort.getSelection())
531 {
532 dci.setSnmpPort(Integer.parseInt(customSnmpPort.getText()));
533 }
534 else
535 {
536 dci.setSnmpPort(0);
537 }
538
539 if (statusActive.getSelection())
540 dci.setStatus(DataCollectionItem.ACTIVE);
541 else if (statusDisabled.getSelection())
542 dci.setStatus(DataCollectionItem.DISABLED);
543 else if (statusUnsupported.getSelection())
544 dci.setStatus(DataCollectionItem.NOT_SUPPORTED);
545
546 if (cluster != null)
547 {
548 dci.setResourceId(clusterResourceMap.get(clusterResource.getSelectionIndex()));
549 }
550
551 new ConsoleJob(Messages.General_JobTitle + dci.getId(), null, Activator.PLUGIN_ID, null) {
552 @Override
553 protected void runInternal(IProgressMonitor monitor) throws Exception
554 {
555 dci.getOwner().modifyObject(dci);
556 runInUIThread(new Runnable() {
557 @Override
558 public void run()
559 {
560 General.this.setValid(true);
561 }
562 });
563 }
564
565 @Override
566 protected String getErrorMessage()
567 {
568 return Messages.General_JobError;
569 }
570 }.start();
571 return true;
572 }
573
574 /* (non-Javadoc)
575 * @see org.eclipse.jface.preference.PreferencePage#performOk()
576 */
577 @Override
578 public boolean performOk()
579 {
580 return applyChanges(false);
581 }
582
583 /* (non-Javadoc)
584 * @see org.eclipse.jface.preference.PreferencePage#performApply()
585 */
586 @Override
587 protected void performApply()
588 {
589 applyChanges(true);
590 }
591
592 /* (non-Javadoc)
593 * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
594 */
595 @Override
596 protected void performDefaults()
597 {
598 super.performDefaults();
599 schedulingMode.select(0);
600 pollingInterval.setText("60"); //$NON-NLS-1$
601 statusActive.setSelection(true);
602 statusDisabled.setSelection(false);
603 statusUnsupported.setSelection(false);
604 retentionTime.setText("30"); //$NON-NLS-1$
605 checkInterpretRawSnmpValue.setSelection(false);
606 checkUseCustomSnmpPort.setSelection(false);
607 }
608 }