use of org.eclipse.jface.viewers.ViewerComparator in project netxms by netxms.
the class ActionSelectionDialog method createDialogArea.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
final Composite dialogArea = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout();
layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
dialogArea.setLayout(layout);
viewer = new TableViewer(dialogArea, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new ActionSelectionDialogLabelProvider());
viewer.setComparator(new ViewerComparator() {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
return ((ServerAction) e1).getName().compareToIgnoreCase(((ServerAction) e2).getName());
}
});
final NXCSession session = ConsoleSharedData.getSession();
new ConsoleJob("Get server actions", null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final List<ServerAction> list = session.getActions();
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.setInput(list.toArray());
}
});
}
@Override
protected String getErrorMessage() {
return "Cannot get server actions";
}
}.start();
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.heightHint = 400;
viewer.getControl().setLayoutData(gd);
return dialogArea;
}
use of org.eclipse.jface.viewers.ViewerComparator in project netxms by netxms.
the class WinPerfCounterSelectionDialog method createDialogArea.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite dialogArea = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
layout.horizontalSpacing = WidgetHelper.DIALOG_SPACING;
layout.verticalSpacing = WidgetHelper.INNER_SPACING;
dialogArea.setLayout(layout);
new Label(dialogArea, SWT.NONE).setText(Messages.get().WinPerfCounterSelectionDialog_ObjectsAndCounters);
new Label(dialogArea, SWT.NONE).setText(Messages.get().WinPerfCounterSelectionDialog_Instances);
objectTree = new TreeViewer(dialogArea, SWT.BORDER | SWT.FULL_SELECTION);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.heightHint = 400;
gd.widthHint = 350;
objectTree.getControl().setLayoutData(gd);
objectTree.setContentProvider(new WinPerfObjectTreeContentProvider());
objectTree.setLabelProvider(new WinPerfObjectTreeLabelProvider());
objectTree.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
String s1 = (e1 instanceof WinPerfCounter) ? ((WinPerfCounter) e1).getName() : ((WinPerfObject) e1).getName();
String s2 = (e2 instanceof WinPerfCounter) ? ((WinPerfCounter) e2).getName() : ((WinPerfObject) e2).getName();
return s1.compareToIgnoreCase(s2);
}
});
objectTree.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
onObjectSelection();
}
});
instanceList = new TableViewer(dialogArea, SWT.BORDER | SWT.FULL_SELECTION);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.widthHint = 350;
instanceList.getControl().setLayoutData(gd);
instanceList.setContentProvider(new ArrayContentProvider());
instanceList.setLabelProvider(new LabelProvider());
instanceList.setComparator(new StringComparator());
fillData();
return dialogArea;
}
use of org.eclipse.jface.viewers.ViewerComparator in project netxms by netxms.
the class StartServerToAgentFileUploadDialog method createDialogArea.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite dialogArea = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout();
layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
layout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
dialogArea.setLayout(layout);
Label label = new Label(dialogArea, SWT.NONE);
label.setText(Messages.get().StartServerToAgentFileUploadDialog_ServerFile);
fileList = new TableViewer(dialogArea, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.widthHint = 400;
gd.heightHint = 150;
fileList.getControl().setLayoutData(gd);
fileList.setContentProvider(new ArrayContentProvider());
fileList.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return ((ServerFile) element).getName();
}
});
fileList.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
return ((ServerFile) e1).getName().compareToIgnoreCase(((ServerFile) e2).getName());
}
});
fileList.setInput(serverFiles);
Composite buttonArea = new Composite(dialogArea, SWT.NONE);
layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.numColumns = 2;
buttonArea.setLayout(layout);
gd = new GridData();
gd.horizontalAlignment = SWT.RIGHT;
buttonArea.setLayoutData(gd);
buttonAddFile = new Button(buttonArea, SWT.PUSH);
buttonAddFile.setText("&Add...");
gd = new GridData();
gd.widthHint = WidgetHelper.BUTTON_WIDTH_HINT;
buttonAddFile.setLayoutData(gd);
buttonAddFile.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
SelectServerFileDialog dlg = new SelectServerFileDialog(getShell(), true);
if (dlg.open() == Window.OK) {
for (ServerFile f : dlg.getSelectedFiles()) {
boolean found = false;
for (ServerFile sf : serverFiles) if (sf.getName().equals(f.getName())) {
found = true;
break;
}
if (!found)
serverFiles.add(f);
}
fileList.refresh();
}
}
});
buttonRemoveFile = new Button(buttonArea, SWT.PUSH);
buttonRemoveFile.setText("&Remove");
gd = new GridData();
gd.widthHint = WidgetHelper.BUTTON_WIDTH_HINT;
buttonRemoveFile.setLayoutData(gd);
buttonRemoveFile.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
IStructuredSelection selection = (IStructuredSelection) fileList.getSelection();
for (Object o : selection.toList()) serverFiles.remove(o);
fileList.refresh();
}
});
textRemoteFile = new LabeledText(dialogArea, SWT.NONE);
textRemoteFile.setLabel(Messages.get().StartServerToAgentFileUploadDialog_RemoteFileName);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
textRemoteFile.setLayoutData(gd);
checkJobOnHold = new Button(dialogArea, SWT.CHECK);
checkJobOnHold.setText(Messages.get().StartServerToAgentFileUploadDialog_CreateJobOnHold);
checkJobOnHold.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
checkIsSchedule.setEnabled(!checkJobOnHold.getSelection());
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
if (canScheduleFileUpload) {
checkIsSchedule = new Button(dialogArea, SWT.CHECK);
checkIsSchedule.setText(Messages.get().StartServerToAgentFileUploadDialog_ScheduleTask);
checkIsSchedule.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
checkJobOnHold.setEnabled(!checkIsSchedule.getSelection());
scheduleSelector.setEnabled(checkIsSchedule.getSelection());
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
scheduleSelector = new ScheduleSelector(dialogArea, SWT.NONE);
scheduleSelector.setEnabled(false);
}
return dialogArea;
}
use of org.eclipse.jface.viewers.ViewerComparator in project netxms by netxms.
the class SelectScriptDialog method createDialogArea.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite dialogArea = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout();
layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
dialogArea.setLayout(layout);
new Label(dialogArea, SWT.NONE).setText(Messages.get().SelectScriptDialog_AvailableScripts);
viewer = new TableViewer(dialogArea, SWT.BORDER | SWT.FULL_SELECTION | (multiSelection ? SWT.MULTI : 0));
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return ((Script) element).getName();
}
});
viewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
Script s1 = (Script) e1;
Script s2 = (Script) e2;
return s1.getName().compareToIgnoreCase(s2.getName());
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
SelectScriptDialog.this.okPressed();
}
});
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.heightHint = 300;
gd.widthHint = 400;
viewer.getControl().setLayoutData(gd);
final NXCSession session = ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().SelectScriptDialog_JobTitle, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final List<Script> scripts = session.getScriptLibrary();
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.setInput(scripts.toArray());
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().SelectScriptDialog_JobError;
}
}.start();
return dialogArea;
}
use of org.eclipse.jface.viewers.ViewerComparator in project netxms by netxms.
the class NetworkMapWidget method setLayoutAlgorithm.
/**
* Set layout algorithm for map
* @param alg
*/
public void setLayoutAlgorithm(MapLayoutAlgorithm alg) {
LayoutAlgorithm algorithm;
switch(alg) {
case SPRING:
algorithm = new SpringLayoutAlgorithm();
break;
case RADIAL:
algorithm = new RadialLayoutAlgorithm();
break;
case HTREE:
algorithm = new TreeLayoutAlgorithm(TreeLayoutAlgorithm.LEFT_RIGHT);
break;
case VTREE:
algorithm = new TreeLayoutAlgorithm(TreeLayoutAlgorithm.TOP_DOWN);
break;
case SPARSE_VTREE:
TreeLayoutAlgorithm mainLayoutAlgorithm = new TreeLayoutAlgorithm(TreeLayoutAlgorithm.TOP_DOWN);
viewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
return e1.toString().compareToIgnoreCase(e2.toString());
}
});
algorithm = new CompositeLayoutAlgorithm(new LayoutAlgorithm[] { mainLayoutAlgorithm, new SparseTree() });
break;
default:
algorithm = new GridLayoutAlgorithm();
break;
}
viewer.setLayoutAlgorithm(algorithm);
}
Aggregations