use of alma.acs.alarmsystem.generated.FaultFamily in project ACS by ACS-Community.
the class AlarmsView method createFFWidgets.
private void createFFWidgets() {
_updateFaultFamily = new Listener() {
public void handleEvent(Event event) {
TreeItem tmp = _tree.getSelection()[0];
String ff = tmp.getText();
FaultFamily fft = new FaultFamily();
//TODO: Error icon or something similar
if (_ffNameText.getText().isEmpty()) {
_ffErrorMessageLabel.setText("FaultFamily Name Missing!");
return;
}
if (_ffNameText.getText().contains(" ")) {
_ffErrorMessageLabel.setText("Invalid FaultFamily Name. No spaces allowed.");
return;
}
fft.setName(_ffNameText.getText());
if (!_ffHelpURLText.getText().isEmpty()) {
URI hurl;
try {
hurl = new URI(_ffHelpURLText.getText());
} catch (MalformedURIException e1) {
_ffErrorMessageLabel.setText("Malformed URL!");
return;
}
fft.setHelpUrl(hurl.toString());
}
fft.setAlarmSource(_ffSourceCombo.getText());
Contact ct = new Contact();
if (_ffContactNameText.getText().isEmpty()) {
_ffErrorMessageLabel.setText("Contact Name Missing!");
return;
}
ct.setName(_ffContactNameText.getText());
if (!_ffContactMailText.getText().isEmpty())
ct.setEmail(_ffContactMailText.getText());
if (!_ffContactGSMText.getText().isEmpty())
ct.setGsm(_ffContactGSMText.getText());
fft.setContact(ct);
_ffErrorMessageLabel.setText("");
try {
_alarmManager.updateFaultFamily(_alarmManager.getFaultFamily(ff), fft);
tmp.setText(_ffNameText.getText());
IWorkbenchWindow _window = getViewSite().getWorkbenchWindow();
IViewReference[] views = _window.getActivePage().getViewReferences();
IMyViewPart view = ((IMyViewPart) views[2].getView(false));
view.fillWidgets();
if (ff.compareTo(fft.getName()) != 0) {
sortFaultFamilyList();
selectElementFromTree(fft.getName(), null, null);
}
} catch (IllegalOperationException e) {
_ffErrorMessageLabel.setText(e.getMessage());
} catch (NullPointerException e) {
e.printStackTrace();
_ffErrorMessageLabel.setText(e.getMessage());
}
}
};
_addCategory = new Listener() {
public void handleEvent(Event event) {
if (event.type == SWT.KeyUp)
if (!(event.keyCode == SWT.CR || event.keyCode == ' '))
return;
if (event.type == SWT.MouseDoubleClick) {
Point pt = new Point(event.x, event.y);
if (_ffCategoryList.getItem(pt) == null)
return;
}
TreeItem[] tmp1 = _tree.getSelection();
if (tmp1 == null || tmp1.length == 0)
return;
String ff = tmp1[0].getText();
TableItem[] tmp2 = _ffCategoryList.getSelection();
if (tmp2 == null || tmp2.length == 0)
return;
TableItem item = tmp2[0];
Category c = _categoryManager.getCategoryByPath(item.getText());
try {
String[] ffs = c.getAlarms().getFaultFamily();
for (int i = 0; i < ffs.length; i++) {
if (ff.compareTo(ffs[i]) == 0) {
c.getAlarms().removeFaultFamily(ff);
item.setImage((org.eclipse.swt.graphics.Image) null);
IWorkbenchWindow _window = getViewSite().getWorkbenchWindow();
IViewReference[] views = _window.getActivePage().getViewReferences();
IMyViewPart view = ((IMyViewPart) views[2].getView(false));
view.fillWidgets();
return;
}
}
c.getAlarms().addFaultFamily(ff);
item.setImage(Activator.getDefault().getImageRegistry().get(Activator.IMG_TICKET));
} catch (NullPointerException e) {
item.setImage((org.eclipse.swt.graphics.Image) null);
Alarms alarms = new Alarms();
alarms.addFaultFamily(ff.toString());
alarms.setFaultFamily(0, ff.toString());
c.setAlarms(alarms);
item.setImage(Activator.getDefault().getImageRegistry().get(Activator.IMG_TICKET));
}
IWorkbenchWindow _window = getViewSite().getWorkbenchWindow();
IViewReference[] views = _window.getActivePage().getViewReferences();
IMyViewPart view = ((IMyViewPart) views[2].getView(false));
view.fillWidgets();
}
};
_FFgroup = new Group(_compInitial, SWT.SHADOW_ETCHED_IN);
_FFgroup.setText("Fault Family details");
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
_FFgroup.setLayoutData(gd);
GridLayout gl = new GridLayout();
gl.numColumns = 2;
_FFgroup.setLayout(gl);
_ffNameLabel = new Label(_FFgroup, SWT.NONE);
_ffNameLabel.setText("Fault Family name");
_ffNameText = new Text(_FFgroup, SWT.SINGLE | SWT.BORDER);
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
_ffNameText.setLayoutData(gd);
_ffNameText.addListener(SWT.Modify, _updateFaultFamily);
_ffHelpURLLabel = new Label(_FFgroup, SWT.NONE);
_ffHelpURLLabel.setText("Help URL");
_ffHelpURLText = new Text(_FFgroup, SWT.SINGLE | SWT.BORDER);
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
_ffHelpURLText.setLayoutData(gd);
_ffHelpURLText.addListener(SWT.Modify, _updateFaultFamily);
_ffContactNameLabel = new Label(_FFgroup, SWT.NONE);
_ffContactNameLabel.setText("Contact name");
_ffContactNameText = new Text(_FFgroup, SWT.SINGLE | SWT.BORDER);
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
_ffContactNameText.setLayoutData(gd);
_ffContactNameText.addListener(SWT.Modify, _updateFaultFamily);
_ffContactMailLabel = new Label(_FFgroup, SWT.NONE);
_ffContactMailLabel.setText("Contact e-mail");
_ffContactMailText = new Text(_FFgroup, SWT.SINGLE | SWT.BORDER);
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
_ffContactMailText.setLayoutData(gd);
_ffContactMailText.addListener(SWT.Modify, _updateFaultFamily);
_ffContactGSMLabel = new Label(_FFgroup, SWT.NONE);
_ffContactGSMLabel.setText("Contact GSM");
_ffContactGSMText = new Text(_FFgroup, SWT.SINGLE | SWT.BORDER);
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
_ffContactGSMText.setLayoutData(gd);
_ffContactGSMText.addListener(SWT.Modify, _updateFaultFamily);
_ffSourceLabel = new Label(_FFgroup, SWT.NONE);
_ffSourceLabel.setText("Source");
_ffSourceCombo = new Combo(_FFgroup, SWT.DROP_DOWN | SWT.READ_ONLY);
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
_ffSourceCombo.setLayoutData(gd);
_ffSourceCombo.setEnabled(false);
_ffSourceCombo.addListener(SWT.Modify, _updateFaultFamily);
_ffCategoryLabel = new Label(_FFgroup, SWT.NONE);
_ffCategoryLabel.setText("Categories:");
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.horizontalSpan = 2;
_ffCategoryLabel.setLayoutData(gd);
_ffCategoryList = new Table(_FFgroup, SWT.BORDER);
gd = new GridData();
gd.verticalAlignment = SWT.FILL;
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 2;
_ffCategoryList.setLayoutData(gd);
_ffCategoryList.addListener(SWT.KeyUp, _addCategory);
_ffCategoryList.addListener(SWT.MouseDoubleClick, _addCategory);
Menu categoryPopUp = new Menu(_ffCategoryList);
_ffCategoryList.setMenu(categoryPopUp);
categoryPopUp.addListener(SWT.Show, new Listener() {
public void handleEvent(Event e) {
TableItem[] sel = _ffCategoryList.getSelection();
Menu categoryPopUp = _ffCategoryList.getMenu();
MenuItem[] items = categoryPopUp.getItems();
for (int i = 0; i < items.length; i++) items[i].dispose();
if (sel == null || sel.length == 0)
return;
MenuItem mitem;
mitem = new MenuItem(categoryPopUp, SWT.PUSH);
if (sel[0].getImage() == null) {
mitem.setText("Add to Category");
mitem.addListener(SWT.Selection, _addCategory);
} else {
mitem.setText("Remove from Category");
mitem.addListener(SWT.Selection, _addCategory);
}
}
});
_ffErrorMessageLabel = new Label(_FFgroup, SWT.NONE);
_ffErrorMessageLabel.setText("");
_ffErrorMessageLabel.setForeground(getViewSite().getShell().getDisplay().getSystemColor(SWT.COLOR_RED));
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.horizontalSpan = 2;
_ffErrorMessageLabel.setLayoutData(gd);
}
use of alma.acs.alarmsystem.generated.FaultFamily in project ACS by ACS-Community.
the class ReductionsView method fillMRParentWidgets.
private void fillMRParentWidgets(String ff, String fm, int fc) {
ReductionRule mrr = _reductionManager.getMRParentByTriplet(ff, fm, fc);
Alarm parent = null;
// This should happen only when creating a new rule...
if (mrr == null) {
parent = _alarmManager.getAlarm(ff + ":" + fm + ":" + fc);
_MRParentErrorMessageLabel.setText("No Reduction Rule for this triplet.");
} else {
parent = mrr.getParent();
if (mrr.getChildrenCount() < mrr.getThreshold())
_MRParentErrorMessageLabel.setText("You need to have at least threshold (" + mrr.getThreshold() + ") childs for this triplet.");
}
_MRParentFFCombo.removeAll();
_MRParentChFFCombo.removeAll();
_MRParentChFFCombo.add("Any");
_MRParentChFFCombo.select(0);
List<FaultFamily> ffList = _alarmManager.getAllAlarms();
List<String> tmp = new ArrayList<String>();
List<FaultFamily> sortedFFList = new ArrayList<FaultFamily>();
for (FaultFamily tff : ffList) tmp.add(tff.getName());
Collections.sort(tmp, IGNORE_CASE_ORDER);
for (String sff : tmp) sortedFFList.add(_alarmManager.getFaultFamily(sff));
ffList = sortedFFList;
FaultFamily ffs = null;
int i = -1;
for (Iterator<FaultFamily> iterator = ffList.iterator(); iterator.hasNext(); ) {
FaultFamily fft = iterator.next();
if (fft.getFaultCodeCount() > 0 && fft.getFaultMemberCount() > 0)
_MRParentFFCombo.add(fft.getName());
_MRParentChFFCombo.add(fft.getName());
if (parent != null && fft.getName().compareTo(parent.getTriplet().getFaultFamily()) == 0) {
i = _MRParentFFCombo.getItemCount() - 1;
ffs = fft;
}
}
_MRParentFFCombo.select(i);
_MRParentFMCombo.removeAll();
if (ffs != null) {
i = -1;
FaultMember[] fml = ffs.getFaultMember();
List<FaultMember> fmList = Arrays.asList(fml);
tmp = new ArrayList<String>();
List<FaultMember> sortedFMList = new ArrayList<FaultMember>();
for (FaultMember tfm : fmList) tmp.add(tfm.getName());
Collections.sort(tmp, IGNORE_CASE_ORDER);
for (String sfm : tmp) for (FaultMember tfm : fmList) if (sfm.compareTo(tfm.getName()) == 0)
sortedFMList.add(tfm);
fmList = sortedFMList;
for (FaultMember fmt : fmList) {
_MRParentFMCombo.add(fmt.getName());
if (fmt.getName().compareTo(parent.getTriplet().getFaultMember()) == 0)
i = _MRParentFMCombo.getItemCount() - 1;
}
_MRParentFMCombo.select(i);
}
_MRParentFCCombo.removeAll();
if (ffs != null) {
i = -1;
FaultCode[] fcl = ffs.getFaultCode();
List<FaultCode> fcList = Arrays.asList(fcl);
tmp = new ArrayList<String>();
List<FaultCode> sortedFCList = new ArrayList<FaultCode>();
for (FaultCode tfc : fcList) tmp.add(Integer.toString(tfc.getValue()));
Collections.sort(tmp);
for (String sfc : tmp) for (FaultCode tfc : fcList) if (sfc.compareTo(Integer.toString(tfc.getValue())) == 0)
sortedFCList.add(tfc);
fcList = sortedFCList;
for (FaultCode fct : fcList) {
_MRParentFCCombo.add(Integer.toString(fct.getValue()));
if (fct.getValue() == parent.getTriplet().getFaultCode())
i = _MRParentFCCombo.getItemCount() - 1;
}
_MRParentFCCombo.select(i);
}
_MRParentThresholdText.setText("");
if (mrr != null)
_MRParentThresholdText.setText(Integer.toString(mrr.getThreshold()));
_MRParentChFMCombo.removeAll();
_MRParentChFMCombo.add("Any");
_MRParentChFMCombo.select(0);
_MRParentChFCCombo.removeAll();
_MRParentChFCCombo.add("Any");
_MRParentChFCCombo.select(0);
if (ff.isEmpty() && fm.isEmpty() && fc == 0) {
if (!_MRParentFFCombo.getText().isEmpty() && !_MRParentFMCombo.getText().isEmpty() && !_MRParentFCCombo.getText().isEmpty())
fillMRParentChAlarmList(_MRParentFFCombo.getText(), _MRParentFMCombo.getText(), Integer.parseInt(_MRParentFCCombo.getText()));
} else
fillMRParentChAlarmList(ff, fm, fc);
//_updateNRParentFF.setEnabled(true);
}
use of alma.acs.alarmsystem.generated.FaultFamily in project ACS by ACS-Community.
the class AlarmsView method createViewWidgets.
private void createViewWidgets(Composite parent) {
Listener hoverTree = new Listener() {
public void handleEvent(Event event) {
Point coords = new Point(event.x, event.y);
TreeItem it = _tree.getItem(coords);
String tooltip = "";
if (it == null) {
_tree.setToolTipText(tooltip);
return;
}
NodeType type = (NodeType) it.getData();
switch(type) {
case FAULT_FAMILY:
{
tooltip = _alarmManager.getFaultFamily(it.getText()).getName();
break;
}
case FAULT_CODE_DATA:
{
tooltip = _alarmManager.getFaultCode(it.getParentItem().getParentItem().getText(), new Integer(it.getText())).getProblemDescription();
break;
}
case FAULT_MEMBER_DATA:
{
tooltip = _alarmManager.getFaultMember(it.getParentItem().getParentItem().getText(), it.getText()).getName();
break;
}
}
_tree.setToolTipText(tooltip);
}
};
_deleteElement = new Listener() {
public void handleEvent(Event event) {
boolean choice = MessageDialog.openQuestion(AlarmsView.this.getViewSite().getShell(), "Confirmation", "Are you sure you want to delete this element");
if (choice == true) {
TreeItem sel = null;
if (_tree.getSelection() == null || _tree.getSelection().length == 0)
return;
NodeType type = (NodeType) _tree.getSelection()[0].getData();
if (type == NodeType.FAULT_CODE_LIST || type == NodeType.FAULT_MEMBER_LIST)
return;
String alarm = _tree.getSelection()[0].getText();
try {
if (type == NodeType.FAULT_FAMILY)
_alarmManager.deleteFaultFamily(_alarmManager.getFaultFamily(alarm));
else if (type == NodeType.FAULT_CODE_DATA) {
String ff = _tree.getSelection()[0].getParentItem().getParentItem().getText();
_alarmManager.deleteFaultCode(_alarmManager.getFaultFamily(ff), _alarmManager.getFaultCode(ff, new Integer(alarm).intValue()));
} else if (type == NodeType.FAULT_MEMBER_DATA) {
String ff = _tree.getSelection()[0].getParentItem().getParentItem().getText();
_alarmManager.deleteFaultMember(_alarmManager.getFaultFamily(ff), _alarmManager.getFaultMember(ff, alarm));
} else if (type == NodeType.FAULT_MEMBER_DEFAULT) {
String ff = _tree.getSelection()[0].getParentItem().getParentItem().getText();
_alarmManager.setFaultMemberDefault(_alarmManager.getFaultFamily(ff), null);
}
} catch (IllegalOperationException e) {
ErrorDialog error = new ErrorDialog(AlarmsView.this.getViewSite().getShell(), "Cannot delete the item", e.getMessage(), new Status(IStatus.ERROR, "cl.utfsm.acs.acg", e.getMessage()), IStatus.ERROR);
error.setBlockOnOpen(true);
error.open();
return;
} catch (NullPointerException e) {
ErrorDialog error = new ErrorDialog(AlarmsView.this.getViewSite().getShell(), "Cannot delete the item", e.getMessage(), new Status(IStatus.ERROR, "cl.utfsm.acs.acg", e.getMessage()), IStatus.ERROR);
error.setBlockOnOpen(true);
error.open();
return;
}
if (type != NodeType.FAULT_FAMILY) {
sel = _tree.getSelection()[0].getParentItem();
TreeItem tff = sel.getParentItem();
FaultFamily fft = _alarmManager.getFaultFamily(tff.getText());
if (fft.getFaultCodeCount() == 0 || (fft.getFaultMemberCount() == 0 && fft.getFaultMemberDefault() == null)) {
sel.setForeground(new Color(sel.getDisplay(), 255, 0, 0));
tff.setForeground(new Color(tff.getDisplay(), 255, 0, 0));
} else {
sel.setForeground(new Color(sel.getDisplay(), 0, 0, 0));
tff.setForeground(new Color(tff.getDisplay(), 0, 0, 0));
}
_tree.getSelection()[0].dispose();
_tree.setSelection(sel);
Event e = new Event();
_tree.notifyListeners(SWT.Selection, e);
} else {
_tree.getSelection()[0].dispose();
if (_tree.getItemCount() > 0)
_tree.setSelection(_tree.getItems()[0]);
Event e = new Event();
_tree.notifyListeners(SWT.Selection, e);
}
}
}
};
_addFaultMember = new Listener() {
public void handleEvent(Event event) {
TreeItem tmp = _tree.getSelection()[0];
TreeItem tmp2 = null;
while (tmp != null) {
tmp2 = tmp;
tmp = tmp.getParentItem();
}
String ff = tmp2.getText();
InputDialog dialog = new InputDialog(AlarmsView.this.getViewSite().getShell(), "New Fault Member", "Enter the Fault Member name", null, new IInputValidator() {
public String isValid(String newText) {
if (newText.trim().compareTo("") == 0)
return "The name is empty";
return null;
}
});
dialog.setBlockOnOpen(true);
dialog.open();
int returnCode = dialog.getReturnCode();
if (returnCode == InputDialog.OK) {
FaultMember newFaultMember = new FaultMember();
newFaultMember.setName(dialog.getValue());
try {
_alarmManager.addFaultMember(_alarmManager.getFaultFamily(ff), newFaultMember);
} catch (IllegalOperationException e) {
ErrorDialog error = new ErrorDialog(AlarmsView.this.getViewSite().getShell(), "Cannot add the new Fault Member", e.getMessage(), new Status(IStatus.ERROR, "cl.utfsm.acs.acg", e.getMessage()), IStatus.ERROR);
error.setBlockOnOpen(true);
error.open();
return;
} catch (NullPointerException e) {
ErrorDialog error = new ErrorDialog(AlarmsView.this.getViewSite().getShell(), "Cannot add the new Fault Member", e.getMessage(), new Status(IStatus.ERROR, "cl.utfsm.acs.acg", e.getMessage()), IStatus.ERROR);
error.setBlockOnOpen(true);
error.open();
return;
}
sortFaultFamilyList();
selectElementFromTree(ff, dialog.getValue(), null);
}
}
};
_addFaultMemberDefault = new Listener() {
public void handleEvent(Event event) {
TreeItem tmp = _tree.getSelection()[0];
TreeItem tmp2 = null;
while (tmp != null) {
tmp2 = tmp;
tmp = tmp.getParentItem();
}
String ff = tmp2.getText();
FaultMemberDefault newFaultMemberDefault = new FaultMemberDefault();
try {
_alarmManager.setFaultMemberDefault(_alarmManager.getFaultFamily(ff), newFaultMemberDefault);
} catch (IllegalOperationException e) {
ErrorDialog error = new ErrorDialog(AlarmsView.this.getViewSite().getShell(), "Cannot add the new Default Fault Member", e.getMessage(), new Status(IStatus.ERROR, "cl.utfsm.acs.acg", e.getMessage()), IStatus.ERROR);
error.setBlockOnOpen(true);
error.open();
return;
} catch (NullPointerException e) {
ErrorDialog error = new ErrorDialog(AlarmsView.this.getViewSite().getShell(), "Cannot add the new Default Fault Member", e.getMessage(), new Status(IStatus.ERROR, "cl.utfsm.acs.acg", e.getMessage()), IStatus.ERROR);
error.setBlockOnOpen(true);
error.open();
return;
}
sortFaultFamilyList();
selectElementFromTree(ff, "Default Member", null);
}
};
_addFaultCode = new Listener() {
public void handleEvent(Event event) {
TreeItem tmp = _tree.getSelection()[0];
TreeItem tmp2 = null;
while (tmp != null) {
tmp2 = tmp;
tmp = tmp.getParentItem();
}
String ff = tmp2.getText();
InputDialog dialog = new InputDialog(AlarmsView.this.getViewSite().getShell(), "New Fault Code", "Enter the Fault Code Value", null, new IInputValidator() {
public String isValid(String newText) {
if (newText.trim().compareTo("") == 0)
return "The value is empty";
try {
new Integer(newText);
} catch (NumberFormatException e) {
return "The value is not a number";
}
return null;
}
});
dialog.setBlockOnOpen(true);
dialog.open();
int returnCode = dialog.getReturnCode();
if (returnCode == InputDialog.OK) {
FaultCode newFaultCode = new FaultCode();
newFaultCode.setValue(new Integer(dialog.getValue()).intValue());
try {
_alarmManager.addFaultCode(_alarmManager.getFaultFamily(ff), newFaultCode);
} catch (IllegalOperationException e) {
ErrorDialog error = new ErrorDialog(AlarmsView.this.getViewSite().getShell(), "Cannot add the new Fault Code", e.getMessage(), new Status(IStatus.ERROR, "cl.utfsm.acs.acg", e.getMessage()), IStatus.ERROR);
error.setBlockOnOpen(true);
error.open();
return;
} catch (NullPointerException e) {
ErrorDialog error = new ErrorDialog(AlarmsView.this.getViewSite().getShell(), "Cannot add the new Fault Code", e.getMessage(), new Status(IStatus.ERROR, "cl.utfsm.acs.acg", e.getMessage()), IStatus.ERROR);
error.setBlockOnOpen(true);
error.open();
return;
}
sortFaultFamilyList();
selectElementFromTree(ff, null, dialog.getValue());
}
}
};
_addFaultFamily = new Listener() {
public void handleEvent(Event event) {
InputDialog dialog = new InputDialog(AlarmsView.this.getViewSite().getShell(), "New Alarm", "Enter the Fault Family name", null, new IInputValidator() {
public String isValid(String newText) {
if (newText.trim().compareTo("") == 0)
return "The name is empty";
return null;
}
});
dialog.setBlockOnOpen(true);
dialog.open();
int returnCode = dialog.getReturnCode();
if (returnCode == InputDialog.OK) {
FaultFamily newAlarm = new FaultFamily();
newAlarm.setName(dialog.getValue());
try {
_alarmManager.addFaultFamily(newAlarm);
} catch (IllegalOperationException e) {
ErrorDialog error = new ErrorDialog(AlarmsView.this.getViewSite().getShell(), "Cannot add the new Alarm", e.getMessage(), new Status(IStatus.ERROR, "cl.utfsm.acs.acg", e.getMessage()), IStatus.ERROR);
error.setBlockOnOpen(true);
error.open();
} catch (NullPointerException e) {
ErrorDialog error = new ErrorDialog(AlarmsView.this.getViewSite().getShell(), "Cannot add the new Alarm", e.getMessage(), new Status(IStatus.ERROR, "cl.utfsm.acs.acg", e.getMessage()), IStatus.ERROR);
error.setBlockOnOpen(true);
error.open();
return;
}
sortFaultFamilyList();
selectElementFromTree(dialog.getValue(), null, null);
}
}
};
_sash = new SashForm(parent, SWT.NONE);
_sash.setLayout(new FillLayout());
_alarmsComp = new Composite(_sash, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
_alarmsComp.setLayout(layout);
_treeGroup = new Group(_alarmsComp, SWT.SHADOW_ETCHED_IN);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
_treeGroup.setLayoutData(gd);
GridLayout gl = new GridLayout();
gl.numColumns = 1;
_treeGroup.setLayout(gl);
_treeGroup.setText("Fault Family List");
/* The tree used to list the FF, FM and FCs */
_tree = new Tree(_treeGroup, SWT.VIRTUAL | SWT.BORDER);
gd = new GridData();
gd.verticalAlignment = SWT.FILL;
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
gd.grabExcessHorizontalSpace = true;
_tree.setLayoutData(gd);
//Menu treePopUp = new Menu(parent, SWT.POP_UP);
Menu treePopUp = new Menu(parent);
_tree.setMenu(treePopUp);
treePopUp.addListener(SWT.Show, new Listener() {
public void handleEvent(Event e) {
//Point point = new Point(e.x, e.y);
//TreeItem sel = _tree.getItem(point);
TreeItem[] sel = _tree.getSelection();
Menu treePopUp = _tree.getMenu();
MenuItem[] items = treePopUp.getItems();
for (int i = 0; i < items.length; i++) items[i].dispose();
MenuItem mitem;
if (sel == null || sel.length == 0) {
mitem = new MenuItem(treePopUp, SWT.PUSH);
mitem.setText("Add Fault Family");
mitem.addListener(SWT.Selection, _addFaultFamily);
return;
}
NodeType type = (NodeType) sel[0].getData();
switch(type) {
case FAULT_FAMILY:
mitem = new MenuItem(treePopUp, SWT.PUSH);
mitem.setText("Add Fault Family");
mitem.addListener(SWT.Selection, _addFaultFamily);
mitem = new MenuItem(treePopUp, SWT.PUSH);
mitem.setText("Delete Fault Family");
mitem.addListener(SWT.Selection, _deleteElement);
break;
case FAULT_CODE_LIST:
mitem = new MenuItem(treePopUp, SWT.PUSH);
mitem.setText("Add Fault Code");
mitem.addListener(SWT.Selection, _addFaultCode);
break;
case FAULT_CODE_DATA:
mitem = new MenuItem(treePopUp, SWT.PUSH);
mitem.setText("Add Fault Code");
mitem.addListener(SWT.Selection, _addFaultCode);
mitem = new MenuItem(treePopUp, SWT.PUSH);
mitem.setText("Delete Fault Code");
mitem.addListener(SWT.Selection, _deleteElement);
break;
case FAULT_MEMBER_LIST:
mitem = new MenuItem(treePopUp, SWT.PUSH);
mitem.setText("Add Fault Member");
mitem.addListener(SWT.Selection, _addFaultMember);
if (_alarmManager.getFaultFamily(sel[0].getParentItem().getText()).getFaultMemberDefault() == null) {
mitem = new MenuItem(treePopUp, SWT.PUSH);
mitem.setText("Add Default Fault Member");
mitem.addListener(SWT.Selection, _addFaultMemberDefault);
}
break;
case FAULT_MEMBER_DATA:
mitem = new MenuItem(treePopUp, SWT.PUSH);
mitem.setText("Add Fault Member");
mitem.addListener(SWT.Selection, _addFaultMember);
mitem = new MenuItem(treePopUp, SWT.PUSH);
mitem.setText("Delete Fault Member");
mitem.addListener(SWT.Selection, _deleteElement);
break;
case FAULT_MEMBER_DEFAULT:
mitem = new MenuItem(treePopUp, SWT.PUSH);
mitem.setText("Delete Default Fault Member");
mitem.addListener(SWT.Selection, _deleteElement);
break;
default:
for (int i = 0; i < items.length; i++) items[i].dispose();
break;
}
}
});
_tree.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
TreeItem[] tmp = ((Tree) e.widget).getSelection();
if (tmp == null || tmp.length == 0) {
_FFgroup.setVisible(false);
((GridData) _FFgroup.getLayoutData()).exclude = true;
_FMgroup.setVisible(false);
((GridData) _FMgroup.getLayoutData()).exclude = true;
_FCgroup.setVisible(false);
((GridData) _FCgroup.getLayoutData()).exclude = true;
_FMDgroup.setVisible(false);
((GridData) _FMDgroup.getLayoutData()).exclude = true;
_FCFMgroup.setVisible(false);
((GridData) _FCFMgroup.getLayoutData()).exclude = true;
return;
}
TreeItem item = tmp[0];
NodeType type = (NodeType) item.getData();
/* Delete the label the first time we select something */
Control c = _compInitial.getChildren()[0];
if (c instanceof Label) {
c.dispose();
_compInitial.layout();
c = _compInitial.getChildren()[0];
}
if (type == NodeType.FAULT_FAMILY) {
_FFgroup.setVisible(true);
((GridData) _FFgroup.getLayoutData()).exclude = false;
_FMgroup.setVisible(false);
((GridData) _FMgroup.getLayoutData()).exclude = true;
_FCgroup.setVisible(false);
((GridData) _FCgroup.getLayoutData()).exclude = true;
_FMDgroup.setVisible(false);
((GridData) _FMDgroup.getLayoutData()).exclude = true;
_FCFMgroup.setVisible(false);
((GridData) _FCFMgroup.getLayoutData()).exclude = true;
//_FFgroup.moveAbove(c);
fillFFWidgets(item.getText());
} else if (type == NodeType.FAULT_CODE_LIST) {
_FFgroup.setVisible(false);
((GridData) _FFgroup.getLayoutData()).exclude = true;
_FMgroup.setVisible(false);
((GridData) _FMgroup.getLayoutData()).exclude = true;
_FCgroup.setVisible(false);
((GridData) _FCgroup.getLayoutData()).exclude = true;
_FMDgroup.setVisible(false);
((GridData) _FMDgroup.getLayoutData()).exclude = true;
_FCFMgroup.setVisible(true);
((GridData) _FCFMgroup.getLayoutData()).exclude = false;
fillFCFMWidgets();
} else if (type == NodeType.FAULT_CODE_DATA) {
_FFgroup.setVisible(false);
((GridData) _FFgroup.getLayoutData()).exclude = true;
_FMgroup.setVisible(false);
((GridData) _FMgroup.getLayoutData()).exclude = true;
_FCgroup.setVisible(true);
((GridData) _FCgroup.getLayoutData()).exclude = false;
_FMDgroup.setVisible(false);
((GridData) _FMDgroup.getLayoutData()).exclude = true;
_FCFMgroup.setVisible(false);
((GridData) _FCFMgroup.getLayoutData()).exclude = true;
//_FCgroup.moveAbove(c);
fillFCWidgets(Integer.parseInt(item.getText()), item.getParentItem().getParentItem().getText());
} else if (type == NodeType.FAULT_MEMBER_LIST) {
_FFgroup.setVisible(false);
((GridData) _FFgroup.getLayoutData()).exclude = true;
_FMgroup.setVisible(false);
((GridData) _FMgroup.getLayoutData()).exclude = true;
_FCgroup.setVisible(false);
((GridData) _FCgroup.getLayoutData()).exclude = true;
_FMDgroup.setVisible(false);
((GridData) _FMDgroup.getLayoutData()).exclude = true;
_FCFMgroup.setVisible(true);
((GridData) _FCFMgroup.getLayoutData()).exclude = false;
fillFCFMWidgets();
} else if (type == NodeType.FAULT_MEMBER_DATA) {
_FFgroup.setVisible(false);
((GridData) _FFgroup.getLayoutData()).exclude = true;
_FMgroup.setVisible(true);
((GridData) _FMgroup.getLayoutData()).exclude = false;
_FCgroup.setVisible(false);
((GridData) _FCgroup.getLayoutData()).exclude = true;
_FMDgroup.setVisible(false);
((GridData) _FMDgroup.getLayoutData()).exclude = true;
_FCFMgroup.setVisible(false);
((GridData) _FCFMgroup.getLayoutData()).exclude = true;
//_FMgroup.moveAbove(c);
fillFMWidgets(item.getText(), item.getParentItem().getParentItem().getText());
} else if (type == NodeType.FAULT_MEMBER_DEFAULT) {
_FFgroup.setVisible(false);
((GridData) _FFgroup.getLayoutData()).exclude = true;
_FMgroup.setVisible(false);
((GridData) _FMgroup.getLayoutData()).exclude = true;
_FCgroup.setVisible(false);
((GridData) _FCgroup.getLayoutData()).exclude = true;
_FMDgroup.setVisible(true);
((GridData) _FMDgroup.getLayoutData()).exclude = false;
_FCFMgroup.setVisible(false);
((GridData) _FCFMgroup.getLayoutData()).exclude = true;
fillFMDWidgets(item.getParentItem().getParentItem().getText());
}
_compInitial.layout();
}
});
_tree.addListener(SWT.MouseHover, hoverTree);
_alarmsButtonsComp = new Composite(_alarmsComp, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 2;
_alarmsButtonsComp.setLayout(layout);
_addAlarmButton = new Button(_alarmsButtonsComp, SWT.None);
_addAlarmButton.setText("Add");
_addAlarmButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ADD));
_deleteAlarmButton = new Button(_alarmsButtonsComp, SWT.None);
_deleteAlarmButton.setText("Delete");
_deleteAlarmButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ETOOL_DELETE));
_addAlarmButton.addListener(SWT.Selection, _addFaultFamily);
_deleteAlarmButton.addListener(SWT.Selection, _deleteElement);
/* Top widget of the right side */
_compInitial = new Composite(_sash, SWT.SHADOW_ETCHED_IN);
_compInitial.setLayout(new GridLayout());
new Label(_compInitial, SWT.NONE).setText("Select an element");
/* FF/FM/FC Details */
createFFWidgets();
createFCWidgets();
createFMWidgets();
createFMDWidgets();
createFCFMWidgets();
/* At the beginning we only show a label */
_FFgroup.setVisible(false);
_FCgroup.setVisible(false);
_FMgroup.setVisible(false);
_FMDgroup.setVisible(false);
_FCFMgroup.setVisible(false);
_sash.setWeights(new int[] { 3, 5 });
}
use of alma.acs.alarmsystem.generated.FaultFamily in project ACS by ACS-Community.
the class CategoriesView method sortFullFaultFamilyList.
public java.util.List<String> sortFullFaultFamilyList() {
java.util.List<FaultFamily> ffs = _alarmManager.getAllAlarms();
java.util.List<String> sortedFFs = new ArrayList<String>();
java.util.List<String> returnFFs = new ArrayList<String>();
for (FaultFamily ff : ffs) sortedFFs.add(ff.getName().toLowerCase());
Collections.sort(sortedFFs);
for (String sff : sortedFFs) for (FaultFamily ff : ffs) if (sff.compareTo(ff.getName().toLowerCase()) == 0)
returnFFs.add(ff.getName());
return returnFFs;
}
use of alma.acs.alarmsystem.generated.FaultFamily in project ACS by ACS-Community.
the class AlarmManagerTest method testGetFaultFamily.
public void testGetFaultFamily() {
_am = AlarmManager.getInstance(_daoManager.getAlarmDAO());
_am.loadFromCDB();
List<FaultFamily> ffList = _am.getAllAlarms();
assertNotNull(ffList);
for (FaultFamily faultFamily : ffList) {
FaultFamily ff = _am.getFaultFamily(faultFamily.getName());
assertNotNull(ff);
assertEquals(ff.getName(), faultFamily.getName());
assertEquals(ff.getFaultCodeCount(), faultFamily.getFaultCodeCount());
assertEquals(ff.getFaultMemberCount(), faultFamily.getFaultMemberCount());
assertEquals(ff.getHelpUrl(), faultFamily.getHelpUrl());
assertEquals(ff.getContact().getName(), faultFamily.getContact().getName());
assertEquals(ff.getContact().getEmail(), faultFamily.getContact().getEmail());
assertEquals(ff.getContact().getGsm(), faultFamily.getContact().getGsm());
}
}
Aggregations