use of org.netxms.ui.eclipse.epp.widgets.RuleEditor in project netxms by netxms.
the class EventProcessingPolicyEditor method savePolicy.
/**
* Save policy to server
*/
private void savePolicy() {
actionSave.setEnabled(false);
new ConsoleJob(Messages.get().EventProcessingPolicyEditor_SaveJob_Title, this, Activator.PLUGIN_ID, JOB_FAMILY) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
EventProcessingPolicy newPolicy = new EventProcessingPolicy(ruleEditors.size());
for (RuleEditor editor : ruleEditors) newPolicy.addRule(editor.getRule());
session.saveEventProcessingPolicy(policy);
runInUIThread(new Runnable() {
@Override
public void run() {
modified = false;
firePropertyChange(PROP_DIRTY);
}
});
}
@Override
protected void jobFinalize() {
runInUIThread(new Runnable() {
@Override
public void run() {
actionSave.setEnabled(modified);
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().EventProcessingPolicyEditor_SaveJob_Error;
}
}.start();
}
use of org.netxms.ui.eclipse.epp.widgets.RuleEditor in project netxms by netxms.
the class EventProcessingPolicyEditor method initPolicyEditor.
/**
* Init policy editor
*/
private void initPolicyEditor() {
for (EventProcessingPolicyRule rule : policy.getRules()) {
if (isRuleVisible(rule)) {
RuleEditor editor = new RuleEditor(dataArea, rule, this);
ruleEditors.add(editor);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
editor.setLayoutData(gd);
}
}
dataArea.layout();
Rectangle r = scroller.getClientArea();
scroller.setMinSize(dataArea.computeSize(r.width, SWT.DEFAULT));
}
use of org.netxms.ui.eclipse.epp.widgets.RuleEditor in project netxms by netxms.
the class EventProcessingPolicyEditor method insertRule.
/**
* Insert new rule at given position
*
* @param position
*/
private void insertRule(int position) {
EventProcessingPolicyRule rule = new EventProcessingPolicyRule();
rule.setRuleNumber(position + 1);
policy.insertRule(rule, position);
RuleEditor editor = new RuleEditor(dataArea, rule, this);
ruleEditors.add(position, editor);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
editor.setLayoutData(gd);
for (int i = position + 1; i < ruleEditors.size(); i++) ruleEditors.get(i).setRuleNumber(i + 1);
if (position < ruleEditors.size() - 1) {
RuleEditor anchor = null;
for (int i = position + 1; i < ruleEditors.size(); i++) if (!ruleEditors.get(i).isDisposed()) {
anchor = ruleEditors.get(i);
break;
}
if (anchor != null)
editor.moveAbove(anchor);
}
updateEditorAreaLayout();
setModified(true);
}
use of org.netxms.ui.eclipse.epp.widgets.RuleEditor 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.netxms.ui.eclipse.epp.widgets.RuleEditor in project netxms by netxms.
the class EventProcessingPolicyEditor method addToSelection.
/**
* Add rule to selection
*
* @param e rule editor
*/
public void addToSelection(RuleEditor e, boolean allFromPrevSelection) {
if (allFromPrevSelection && (lastSelectedRule != -1)) {
int direction = Integer.signum(e.getRuleNumber() - lastSelectedRule);
for (int i = lastSelectedRule + direction; i != e.getRuleNumber(); i += direction) {
RuleEditor r = ruleEditors.get(i - 1);
selection.add(r);
r.setSelected(true);
}
}
selection.add(e);
e.setSelected(true);
lastSelectedRule = e.getRuleNumber();
onSelectionChange();
}
Aggregations