use of org.netxms.ui.eclipse.widgets.FilterText in project netxms by netxms.
the class PredefinedGraphTree method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
session = (NXCSession) ConsoleSharedData.getSession();
parent.setLayout(new FormLayout());
// Create filter area
filterText = new FilterText(parent, SWT.NONE);
filterText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
onFilterModify();
}
});
filterText.setCloseAction(new Action() {
@Override
public void run() {
enableFilter(false);
}
});
viewer = new TreeViewer(parent, SWT.NONE);
viewer.setUseHashlookup(true);
viewer.setContentProvider(new GraphTreeContentProvider());
viewer.setLabelProvider(new GraphTreeLabelProvider());
viewer.setComparer(new IElementComparer() {
@Override
public int hashCode(Object element) {
if ((element instanceof GraphSettings)) {
return (int) ((GraphSettings) element).getId();
}
if ((element instanceof GraphFolder)) {
return ((GraphFolder) element).getName().hashCode();
}
return element.hashCode();
}
@Override
public boolean equals(Object a, Object b) {
if ((a instanceof GraphSettings) && (b instanceof GraphSettings))
return ((GraphSettings) a).getId() == ((GraphSettings) b).getId();
if ((a instanceof GraphFolder) && (b instanceof GraphFolder))
return ((GraphFolder) a).getName().equals(((GraphFolder) b).getName());
return a.equals(b);
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
actionOpen.run();
}
});
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@SuppressWarnings("rawtypes")
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
Iterator it = selection.iterator();
boolean enabled = false;
while (it.hasNext()) {
if (it.next() instanceof GraphSettings) {
enabled = true;
break;
}
}
actionOpen.setEnabled(enabled);
actionDelete.setEnabled(enabled);
actionProperties.setEnabled(enabled);
}
});
filter = new GraphTreeFilter();
viewer.addFilter(filter);
// Setup layout
FormData fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(filterText);
fd.right = new FormAttachment(100, 0);
fd.bottom = new FormAttachment(100, 0);
viewer.getTree().setLayoutData(fd);
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
filterText.setLayoutData(fd);
activateContext();
createActions();
contributeToActionBars();
createPopupMenu();
reloadGraphList();
session.addListener(this);
// Set initial focus to filter input line
if (initShowFilter)
filterText.setFocus();
else
// Will hide filter area correctly
enableFilter(false);
}
use of org.netxms.ui.eclipse.widgets.FilterText in project netxms by netxms.
the class ObjectToolsEditor method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
session = (NXCSession) ConsoleSharedData.getSession();
// Initiate loading of required plugins if they was not loaded yet
try {
// $NON-NLS-1$
Platform.getAdapterManager().loadAdapter(new AccessListElement(0, 0), "org.eclipse.ui.model.IWorkbenchAdapter");
} catch (Exception e) {
}
// Create interface area
objectToolsArea = new Composite(parent, SWT.BORDER);
FormLayout formLayout = new FormLayout();
objectToolsArea.setLayout(formLayout);
// Create filter
filterText = new FilterText(objectToolsArea, SWT.NONE);
filterText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
onFilterModify();
}
});
filterText.setCloseAction(new Action() {
@Override
public void run() {
enableFilter(false);
actionShowFilter.setChecked(initShowFilter);
}
});
final String[] columnNames = { Messages.get().ObjectToolsEditor_ColId, Messages.get().ObjectToolsEditor_ColName, Messages.get().ObjectToolsEditor_ColType, Messages.get().ObjectToolsEditor_ColDescr };
final int[] columnWidths = { 90, 200, 100, 200 };
viewer = new SortableTableViewer(objectToolsArea, columnNames, columnWidths, COLUMN_NAME, SWT.UP, SWT.FULL_SELECTION | SWT.MULTI);
WidgetHelper.restoreTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new ObjectToolsLabelProvider());
filter = new ObjectToolsFilter();
viewer.addFilter(filter);
viewer.setComparator(new ObjectToolsComparator());
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection != null) {
actionEdit.setEnabled(selection.size() == 1);
actionClone.setEnabled(selection.size() == 1);
actionDelete.setEnabled(selection.size() > 0);
actionDisable.setEnabled(containsEnabled(selection));
actionEnable.setEnabled(containsDisabled(selection));
}
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
actionEdit.run();
}
});
viewer.getTable().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
WidgetHelper.saveTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
}
});
// Setup layout
FormData fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(filterText);
fd.right = new FormAttachment(100, 0);
fd.bottom = new FormAttachment(100, 0);
viewer.getControl().setLayoutData(fd);
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
filterText.setLayoutData(fd);
createActions();
contributeToActionBars();
createPopupMenu();
activateContext();
session.addListener(this);
// Set initial focus to filter input line
if (initShowFilter)
filterText.setFocus();
else
// Will hide filter area correctly
enableFilter(false);
refreshToolList();
}
use of org.netxms.ui.eclipse.widgets.FilterText in project netxms by netxms.
the class AgentFileManager method createPartControl.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
content = new Composite(parent, SWT.NONE);
content.setLayout(new FormLayout());
// Create filter area
filterText = new FilterText(content, SWT.NONE);
filterText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
onFilterModify();
}
});
// $NON-NLS-1$
String os = ((Node) session.findObjectById(objectId)).getSystemDescription();
if (// if OS is windows don't show group and access rights columns //$NON-NLS-1$
os.contains("Windows")) {
final String[] columnNames = { Messages.get().AgentFileManager_ColName, Messages.get().AgentFileManager_ColType, Messages.get().AgentFileManager_ColSize, Messages.get().AgentFileManager_ColDate, Messages.get().AgentFileManager_ColOwner };
final int[] columnWidths = { 300, 120, 150, 150, 150 };
viewer = new SortableTreeViewer(content, columnNames, columnWidths, 0, SWT.UP, SortableTableViewer.DEFAULT_STYLE);
} else {
final String[] columnNames = { Messages.get().AgentFileManager_ColName, Messages.get().AgentFileManager_ColType, Messages.get().AgentFileManager_ColSize, Messages.get().AgentFileManager_ColDate, Messages.get().AgentFileManager_ColOwner, Messages.get().AgentFileManager_ColGroup, Messages.get().AgentFileManager_ColAccessRights };
final int[] columnWidths = { 300, 120, 150, 150, 150, 150, 200 };
viewer = new SortableTreeViewer(content, columnNames, columnWidths, 0, SWT.UP, SortableTableViewer.DEFAULT_STYLE);
}
WidgetHelper.restoreTreeViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
viewer.setContentProvider(new ViewAgentFilesProvider());
viewer.setLabelProvider(new AgentFileLabelProvider());
viewer.setComparator(new AgentFileComparator());
filter = new AgentFileFilter();
viewer.addFilter(filter);
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection != null) {
actionDelete.setEnabled(selection.size() > 0);
actionCalculateFolderSize.setEnabled(selection.size() > 0);
}
}
});
viewer.getTree().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
WidgetHelper.saveTreeViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
}
});
enableDragSupport();
enableDropSupport();
enableInPlaceRename();
// Setup layout
FormData fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(filterText);
fd.right = new FormAttachment(100, 0);
fd.bottom = new FormAttachment(100, 0);
viewer.getTree().setLayoutData(fd);
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
filterText.setLayoutData(fd);
createActions();
contributeToActionBars();
createPopupMenu();
activateContext();
filterText.setCloseAction(actionShowFilter);
// Set initial focus to filter input line
if (initShowFilter)
filterText.setFocus();
else
// Will hide filter area correctly
enableFilter(false);
refreshFileList();
}
use of org.netxms.ui.eclipse.widgets.FilterText in project netxms by netxms.
the class RuleSelectionDialog method createDialogArea.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
IDialogSettings settings = Activator.getDefault().getDialogSettings();
Composite dialogArea = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout();
layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
layout.horizontalSpacing = WidgetHelper.OUTER_SPACING;
layout.numColumns = 2;
dialogArea.setLayout(layout);
filterText = new FilterText(dialogArea, SWT.NONE, null, false);
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
filterText.setLayoutData(gd);
// $NON-NLS-1$
final String filterString = settings.get("SelectRule.Filter");
if (filterString != null)
filterText.setText(filterString);
viewer = new TableViewer(dialogArea, SWT.BORDER | SWT.FULL_SELECTION | (multiSelection ? SWT.MULTI : SWT.SINGLE) | SWT.H_SCROLL | SWT.V_SCROLL);
viewer.getTable().setLinesVisible(true);
viewer.getTable().setHeaderVisible(true);
TableColumn column = new TableColumn(viewer.getTable(), SWT.LEFT);
column.setText("Rule #");
column.setWidth(60);
column = new TableColumn(viewer.getTable(), SWT.LEFT);
column.setText("Rule Name");
column.setWidth(250);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setComparator(new RuleComparator());
viewer.setLabelProvider(new RuleLabelProvider());
filter = new RuleListFilter();
if (filterString != null)
filter.setFilterString(filterString);
viewer.addFilter(filter);
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.horizontalSpan = 2;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
gd.heightHint = 350;
viewer.getTable().setLayoutData(gd);
filterText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
filter.setFilterString(filterText.getText());
viewer.refresh();
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
RuleSelectionDialog.this.okPressed();
}
});
if (rulesCache == null) {
viewer.getTable().setEnabled(false);
getButton(IDialogConstants.OK_ID).setEnabled(false);
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
ConsoleJob job = new ConsoleJob(Messages.get().RuleSelectionDialog_JobTitle, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final EventProcessingPolicy policy = session.getEventProcessingPolicy();
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.getTable().setEnabled(true);
getButton(IDialogConstants.OK_ID).setEnabled(true);
viewer.setInput(policy.getRules().toArray());
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().RuleSelectionDialog_JobError;
}
};
job.setUser(false);
job.start();
} else {
viewer.setInput(rulesCache.toArray());
}
return dialogArea;
}
use of org.netxms.ui.eclipse.widgets.FilterText in project netxms by netxms.
the class ZoneSelectionDialog method createDialogArea.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
IDialogSettings settings = Activator.getDefault().getDialogSettings();
Composite dialogArea = (Composite) super.createDialogArea(parent);
NXCSession session = (NXCSession) ConsoleSharedData.getSession();
GridLayout layout = new GridLayout();
layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
layout.horizontalSpacing = WidgetHelper.OUTER_SPACING;
dialogArea.setLayout(layout);
filterText = new FilterText(dialogArea, SWT.NONE, null, false);
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
filterText.setLayoutData(gd);
// $NON-NLS-1$
final String filterString = settings.get("SelectZone.Filter");
if (filterString != null)
filterText.setText(filterString);
final String[] names = { "Name" };
final int[] widths = { 200 };
zoneList = new SortableTableViewer(dialogArea, names, widths, 0, SWT.UP, SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE | SWT.V_SCROLL);
zoneList.setContentProvider(new ArrayContentProvider());
zoneList.setComparator(new ZoneSelectionDialogComparator());
zoneList.setLabelProvider(new WorkbenchLabelProvider());
filter = new ZoneSelectionDialogFilter();
if (filterString != null)
filter.setFilterString(filterString);
zoneList.addFilter(filter);
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
zoneList.getTable().setLayoutData(gd);
zoneList.setInput(session.getAllZones());
filterText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
filter.setFilterString(filterText.getText());
zoneList.refresh();
}
});
zoneList.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
ZoneSelectionDialog.this.okPressed();
}
});
filterText.setFocus();
return dialogArea;
}
Aggregations