use of org.eclipse.swt.events.ControlEvent in project netxms by netxms.
the class EventProcessingPolicyEditor 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();
IDialogSettings settings = Activator.getDefault().getDialogSettings();
// $NON-NLS-1$
filterEnabled = settings.getBoolean("EventProcessingPolicyEditor.filterEnabled");
// Initiate loading of required plugins if they was not loaded yet
try {
// $NON-NLS-1$
Platform.getAdapterManager().loadAdapter(new EventTemplate(0), "org.eclipse.ui.model.IWorkbenchAdapter");
// $NON-NLS-1$
Platform.getAdapterManager().loadAdapter(new ServerAction(0), "org.eclipse.ui.model.IWorkbenchAdapter");
// $NON-NLS-1$
Platform.getAdapterManager().loadAdapter(session.getTopLevelObjects()[0], "org.eclipse.ui.model.IWorkbenchAdapter");
} catch (Exception e) {
}
// $NON-NLS-1$
imageStop = Activator.getImageDescriptor("icons/stop.png").createImage();
// $NON-NLS-1$
imageAlarm = Activator.getImageDescriptor("icons/alarm.png").createImage();
// $NON-NLS-1$
imageSituation = Activator.getImageDescriptor("icons/situation.gif").createImage();
// $NON-NLS-1$
imageExecute = Activator.getImageDescriptor("icons/execute.png").createImage();
// $NON-NLS-1$
imageTerminate = Activator.getImageDescriptor("icons/terminate.png").createImage();
imageCollapse = SharedIcons.COLLAPSE.createImage();
imageExpand = SharedIcons.EXPAND.createImage();
imageEdit = SharedIcons.EDIT.createImage();
parent.setLayout(new FormLayout());
// Create filter area
filterControl = new FilterText(parent, SWT.NONE);
filterControl.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
onFilterModify();
}
});
filterControl.setCloseAction(new Action() {
@Override
public void run() {
enableFilter(false);
}
});
scroller = new ScrolledComposite(parent, SWT.V_SCROLL);
dataArea = new Composite(scroller, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.verticalSpacing = 0;
dataArea.setLayout(layout);
dataArea.setBackground(BACKGROUND_COLOR);
scroller.setContent(dataArea);
scroller.setExpandVertical(true);
scroller.setExpandHorizontal(true);
scroller.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
Rectangle r = scroller.getClientArea();
scroller.setMinSize(dataArea.computeSize(r.width, SWT.DEFAULT));
}
});
// Setup layout
FormData fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(filterControl);
fd.right = new FormAttachment(100, 0);
fd.bottom = new FormAttachment(100, 0);
scroller.setLayoutData(fd);
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
filterControl.setLayoutData(fd);
normalFont = JFaceResources.getDefaultFont();
boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT);
sessionListener = new SessionListener() {
@Override
public void notificationHandler(SessionNotification n) {
processSessionNotification(n);
}
};
session.addListener(sessionListener);
selection = new TreeSet<RuleEditor>(new Comparator<RuleEditor>() {
@Override
public int compare(RuleEditor arg0, RuleEditor arg1) {
return arg0.getRuleNumber() - arg1.getRuleNumber();
}
});
createActions();
contributeToActionBars();
openEventProcessingPolicy();
activateContext();
// Set initial focus to filter input line
if (filterEnabled)
filterControl.setFocus();
else
// Will hide filter area correctly
enableFilter(false);
}
use of org.eclipse.swt.events.ControlEvent in project netxms by netxms.
the class ChildObjectListDialog 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);
AbstractObject object = ((NXCSession) ConsoleSharedData.getSession()).findObjectById(parentObject);
AbstractObject[] sourceObjects = (object != null) ? object.getChildsAsArray() : new AbstractObject[0];
GridLayout layout = new GridLayout();
layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
dialogArea.setLayout(layout);
// Create filter area
Composite filterArea = new Composite(dialogArea, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 2;
layout.horizontalSpacing = WidgetHelper.INNER_SPACING;
layout.marginHeight = 0;
layout.marginWidth = 0;
filterArea.setLayout(layout);
filterArea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label filterLabel = new Label(filterArea, SWT.NONE);
filterLabel.setText(Messages.get().ChildObjectListDialog_Filter);
filterText = new Text(filterArea, SWT.BORDER);
filterText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
filterText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
filter.setFilterString(filterText.getText());
objectList.refresh(false);
AbstractObject obj = filter.getLastMatch();
if (obj != null) {
objectList.setSelection(new StructuredSelection(obj), true);
objectList.reveal(obj);
}
}
});
// Create object list
objectList = new TableViewer(dialogArea, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
TableColumn tc = new TableColumn(objectList.getTable(), SWT.LEFT);
tc.setText(Messages.get().ChildObjectListDialog_Name);
tc.setWidth(280);
objectList.getTable().setHeaderVisible(false);
objectList.setContentProvider(new ArrayContentProvider());
objectList.setLabelProvider(new WorkbenchLabelProvider());
objectList.setComparator(new ViewerComparator());
filter = new ObjectFilter(null, sourceObjects, classFilter);
objectList.addFilter(filter);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
objectList.getControl().setLayoutData(gd);
objectList.getTable().addControlListener(new ControlListener() {
@Override
public void controlMoved(ControlEvent e) {
}
@Override
public void controlResized(ControlEvent e) {
Table table = objectList.getTable();
int w = table.getSize().x - table.getBorderWidth() * 2;
ScrollBar sc = table.getVerticalBar();
if ((sc != null) && sc.isVisible())
w -= sc.getSize().x;
table.getColumn(0).setWidth(w);
}
});
if (object != null)
objectList.setInput(sourceObjects);
filterText.setFocus();
return dialogArea;
}
use of org.eclipse.swt.events.ControlEvent in project netxms by netxms.
the class RackTab method createTabContent.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.objectview.objecttabs.ObjectTab#createTabContent(org.eclipse.swt.widgets.Composite)
*/
@Override
protected void createTabContent(Composite parent) {
scroller = new ScrolledComposite(parent, SWT.H_SCROLL);
content = new Composite(scroller, SWT.NONE) {
@Override
public Point computeSize(int wHint, int hHint, boolean changed) {
if ((rackFrontWidget == null) || (rackRearWidget == null) || (hHint == SWT.DEFAULT))
return super.computeSize(wHint, hHint, changed);
Point s = rackFrontWidget.computeSize(wHint, hHint, changed);
return new Point(s.x * 2, s.y);
}
};
content.setBackground(SharedColors.getColor(SharedColors.RACK_BACKGROUND, parent.getDisplay()));
content.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
if ((rackFrontWidget == null) || (rackRearWidget == null))
return;
updateRackWidgetsSize();
}
});
scroller.setContent(content);
scroller.setExpandHorizontal(true);
scroller.setExpandVertical(true);
scroller.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
scroller.setMinSize(content.computeSize(SWT.DEFAULT, scroller.getSize().y));
}
});
}
use of org.eclipse.swt.events.ControlEvent in project netxms by netxms.
the class ObjectOverview method createTabContent.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.objectview.objecttabs.ObjectTab#createTabContent(org.eclipse.swt.widgets.Composite)
*/
@Override
protected void createTabContent(Composite parent) {
scroller = new ScrolledComposite(parent, SWT.V_SCROLL);
scroller.setExpandVertical(true);
scroller.setExpandHorizontal(true);
// FIXME: scroller.getVerticalBar().setIncrement(20);
scroller.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
Rectangle r = scroller.getClientArea();
scroller.setMinSize(viewArea.computeSize(r.width, SWT.DEFAULT));
objectChanged(getObject());
}
});
viewArea = new Composite(scroller, SWT.NONE);
viewArea.setBackground(SharedColors.getColor(SharedColors.OBJECT_TAB_BACKGROUND, parent.getDisplay()));
GridLayout layout = new GridLayout();
layout.numColumns = 2;
viewArea.setLayout(layout);
scroller.setContent(viewArea);
leftColumn = new Composite(viewArea, SWT.NONE);
leftColumn.setLayout(createColumnLayout());
leftColumn.setBackground(SharedColors.getColor(SharedColors.OBJECT_TAB_BACKGROUND, parent.getDisplay()));
GridData gd = new GridData();
gd.verticalAlignment = SWT.TOP;
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
leftColumn.setLayoutData(gd);
rightColumn = new Composite(viewArea, SWT.NONE);
rightColumn.setLayout(createColumnLayout());
rightColumn.setBackground(SharedColors.getColor(SharedColors.OBJECT_TAB_BACKGROUND, parent.getDisplay()));
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
gd.horizontalAlignment = SWT.LEFT;
gd.grabExcessHorizontalSpace = true;
gd.minimumWidth = SWT.DEFAULT;
rightColumn.setLayoutData(gd);
OverviewPageElement e = new GeneralInfo(leftColumn, null, this);
elements.add(e);
e = new LastValues(leftColumn, e, this);
elements.add(e);
e = new Commands(leftColumn, e, this);
elements.add(e);
e = new AvailabilityChart(leftColumn, e, this);
elements.add(e);
e = new ExternalResources(leftColumn, e, this);
elements.add(e);
e = new Comments(leftColumn, e, this);
elements.add(e);
e = new Capabilities(rightColumn, null, this);
elements.add(e);
e = new Connection(rightColumn, e, this);
elements.add(e);
}
use of org.eclipse.swt.events.ControlEvent in project netxms by netxms.
the class AddressMap method createTabContent.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.objectview.objecttabs.ObjectTab#createTabContent(org.eclipse.swt.widgets.Composite)
*/
@Override
protected void createTabContent(Composite parent) {
scroller = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
addressMap = new SubnetAddressMap(scroller, SWT.NONE, getViewPart(), new VisibilityValidator() {
@Override
public boolean isVisible() {
return isActive();
}
});
scroller.setContent(addressMap);
scroller.setExpandVertical(true);
scroller.setExpandHorizontal(true);
scroller.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
scroller.setMinSize(addressMap.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
});
}
Aggregations