use of alma.acs.alarmsystem.generated.FaultMember in project ACS by ACS-Community.
the class AlarmsView method fillFMWidgets.
private void fillFMWidgets(String fmName, String ffName) {
FaultMember fm = _alarmManager.getFaultMember(ffName, fmName);
// This should never happen anyways...
if (fm == null)
return;
String name = "";
String building = "";
String floor = "";
String room = "";
String mnemonic = "";
String position = "";
name = fm.getName();
if (fm.getLocation() != null) {
if (fm.getLocation().getBuilding() != null)
building = fm.getLocation().getBuilding().trim();
if (fm.getLocation().getFloor() != null)
floor = fm.getLocation().getFloor().trim();
if (fm.getLocation().getRoom() != null)
room = fm.getLocation().getRoom().trim();
if (fm.getLocation().getMnemonic() != null)
mnemonic = fm.getLocation().getMnemonic().trim();
if (fm.getLocation().getPosition() != null)
position = fm.getLocation().getPosition().trim();
}
_fmNameText.setText(name);
_fmLocBuildingText.setText(building);
_fmLocFloorText.setText(floor);
_fmLocRoomText.setText(room);
_fmLocMnemonicText.setText(mnemonic);
_fmLocPositionText.setText(position);
}
use of alma.acs.alarmsystem.generated.FaultMember 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.FaultMember 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.FaultMember in project ACS by ACS-Community.
the class ACSAlarmDAOImpl method generateAlarmsMap.
/**
* Generate the alarms from the definition of the fault families.
* The alarms will be added into the HashMap with their triplet as key.
* The default item has FM="*".
*
* The sources read from the families are also added to the HashMap of the sources
*
* @param families The FF read from the CDB
*/
private void generateAlarmsMap(Vector<FaultFamily> families) {
if (families == null) {
throw new IllegalArgumentException("Invalid null vector of FFs");
}
for (FaultFamily family : families) {
String FF = family.getName();
String helpUrl = family.getHelpUrl();
String source = family.getAlarmSource();
Contact contactPerson = family.getContact();
FaultMember[] FMs = family.getFaultMember();
FaultMemberDefault defaultFM = family.getFaultMemberDefault();
FaultCode[] FCs = family.getFaultCode();
// There should be at least one FC in the CDB
if (FCs == null || FCs.length == 0) {
logger.log(AcsLogLevel.WARNING, "No FC defined for family " + family.getName());
continue;
}
// There should be at least one FM or a default FM defined in the CDB
if (defaultFM == null && (FMs == null || FMs.length == 0)) {
logger.log(AcsLogLevel.WARNING, "No FM defined for family " + family.getName());
continue;
}
// Iterate over the FCs
for (FaultCode code : FCs) {
int FC = code.getValue();
int priority = code.getPriority();
String action = code.getAction();
String cause = code.getCause();
String consequence = code.getConsequence();
String problemDesc = code.getProblemDescription();
boolean instant = code.getInstant();
// Iterate over all the FMs
for (FaultMember member : FMs) {
alma.acs.alarmsystem.generated.Location loc = member.getLocation();
if (loc == null) {
loc = new alma.acs.alarmsystem.generated.Location();
}
if (loc.getBuilding() == null) {
loc.setBuilding("");
}
if (loc.getFloor() == null) {
loc.setFloor("");
}
if (loc.getMnemonic() == null) {
loc.setMnemonic("");
}
if (loc.getPosition() == null) {
loc.setPosition("");
}
if (loc.getRoom() == null) {
loc.setRoom("");
}
String FM = member.getName();
if (FM.equals(DEFAULT_FM)) {
logger.log(AcsLogLevel.ERROR, "In the CDB, FM=" + DEFAULT_FM + " in family " + FF + " is not allowed");
}
AlarmImpl alarm = new AlarmImpl();
alarm.setMultiplicityChildrenIds(new HashSet());
alarm.setMultiplicityParentIds(new HashSet());
alarm.setNodeChildrenIds(new HashSet());
alarm.setNodeParentIds(new HashSet());
alarm.setAction(action);
alarm.setTriplet(new Triplet(FF, FM, FC));
alarm.setCategories(new HashSet<Category>());
alarm.setCause(cause);
alarm.setConsequence(consequence);
alarm.setProblemDescription(problemDesc);
try {
alarm.setHelpURL(new URL(helpUrl));
} catch (MalformedURLException e) {
alarm.setHelpURL(null);
}
alarm.setInstant(instant);
Location location = new Location("0", loc.getFloor(), loc.getMnemonic(), loc.getPosition(), loc.getRoom());
alarm.setLocation(location);
if (contactPerson.getEmail() != null) {
alarm.setPiquetEmail(contactPerson.getEmail());
} else {
alarm.setPiquetEmail("");
}
if (contactPerson.getGsm() != null) {
alarm.setPiquetGSM(contactPerson.getGsm());
} else {
alarm.setPiquetGSM("");
}
alarm.setPriority(priority);
ResponsiblePerson responsible = new ResponsiblePerson(0, contactPerson.getName(), "", contactPerson.getEmail(), contactPerson.getGsm(), "");
alarm.setResponsiblePerson(responsible);
SourceDefinition srcDef = new SourceDefinition(source, "SOURCE", "", 15, 1);
Source src = new Source(srcDef, responsible);
alarm.setSource(src);
alarm.setIdentifier(alarm.getTriplet().toIdentifier());
addAlarmToCache(alarm);
if (!srcDefs.containsKey(source)) {
srcDefs.put(src.getSourceId(), src);
logger.log(AcsLogLevel.DEBUG, "Source " + src.getName() + " (id=" + src.getSourceId() + ") added");
}
logger.log(AcsLogLevel.DEBUG, "Alarm added " + alarm.getAlarmId());
}
// Add the default
if (defaultFM != null) {
alma.acs.alarmsystem.generated.Location loc = defaultFM.getLocation();
if (loc == null) {
loc = new alma.acs.alarmsystem.generated.Location();
}
if (loc.getBuilding() == null) {
loc.setBuilding("");
}
if (loc.getFloor() == null) {
loc.setFloor("");
}
if (loc.getMnemonic() == null) {
loc.setMnemonic("");
}
if (loc.getPosition() == null) {
loc.setPosition("");
}
if (loc.getRoom() == null) {
loc.setRoom("");
}
AlarmImpl defaultAlarm = new AlarmImpl();
defaultAlarm.setMultiplicityChildrenIds(new HashSet());
defaultAlarm.setMultiplicityParentIds(new HashSet());
defaultAlarm.setNodeChildrenIds(new HashSet());
defaultAlarm.setNodeParentIds(new HashSet());
defaultAlarm.setAction(action);
defaultAlarm.setCategories(new HashSet<Category>());
defaultAlarm.setCause(cause);
defaultAlarm.setConsequence(consequence);
defaultAlarm.setProblemDescription(problemDesc);
try {
defaultAlarm.setHelpURL(new URL(helpUrl));
} catch (MalformedURLException e) {
defaultAlarm.setHelpURL(null);
}
defaultAlarm.setInstant(instant);
Location location = new Location("0", loc.getFloor(), loc.getMnemonic(), loc.getPosition(), loc.getRoom());
defaultAlarm.setLocation(location);
defaultAlarm.setPiquetEmail(contactPerson.getEmail());
defaultAlarm.setPiquetGSM(contactPerson.getGsm());
defaultAlarm.setPriority(priority);
ResponsiblePerson responsible = new ResponsiblePerson(0, contactPerson.getName(), "", contactPerson.getEmail(), contactPerson.getGsm(), "");
defaultAlarm.setResponsiblePerson(responsible);
SourceDefinition srcDef = new SourceDefinition(source, "SOURCE", "", 15, 1);
Source src = new Source(srcDef, responsible);
defaultAlarm.setSource(src);
defaultAlarm.setIdentifier(defaultAlarm.getTriplet().toIdentifier());
Triplet triplet = new Triplet(FF, DEFAULT_FM, FC);
defaultAlarm.setTriplet(triplet);
defaultAlarm.setIdentifier(triplet.toIdentifier());
addAlarmToCache(defaultAlarm);
if (!srcDefs.containsKey(source)) {
srcDefs.put(src.getSourceId(), src);
logger.log(AcsLogLevel.DEBUG, "Source " + src.getName() + " (id=" + src.getSourceId() + ") added");
}
logger.log(AcsLogLevel.DEBUG, "Default alarm added " + defaultAlarm.getAlarmId());
}
}
}
}
use of alma.acs.alarmsystem.generated.FaultMember in project ACS by ACS-Community.
the class ACSAlarmDAOImpl method generateAlarmsMap.
/**
* Generate the alarms from the definition of the fault families.
* The alarms will be added into the HashMap with their triplet as key.
* The default item has FM="*".
*
* The sources read from the families are also added to the HashMap of the sources
*
* @param families The FF read from the CDB
*/
public void generateAlarmsMap(Vector<FaultFamily> families) {
if (families == null) {
throw new IllegalArgumentException("Invalid null vector of FFs");
}
for (FaultFamily family : families) {
String FF = family.getName();
String helpUrl = family.getHelpUrl();
String source = family.getAlarmSource();
Contact contactPerson = family.getContact();
FaultMember[] FMs = family.getFaultMember();
FaultMemberDefault defaultFM = family.getFaultMemberDefault();
FaultCode[] FCs = family.getFaultCode();
// There should be at least one FC in the CDB
if (FCs == null || FCs.length == 0) {
logger.log(AcsLogLevel.WARNING, "No FC defined for family " + family.getName());
continue;
}
// There should be at least one FM or a default FM defined in the CDB
if (defaultFM == null && (FMs == null || FMs.length == 0)) {
logger.log(AcsLogLevel.WARNING, "No FM defined for family " + family.getName());
continue;
}
// Iterate over the FCs
for (FaultCode code : FCs) {
int FC = code.getValue();
int priority = code.getPriority();
String action = code.getAction();
String cause = code.getCause();
String consequence = code.getConsequence();
String problemDesc = code.getProblemDescription();
boolean instant = code.getInstant();
// Iterate over all the FMs
for (FaultMember member : FMs) {
alma.acs.alarmsystem.generated.Location loc = member.getLocation();
if (loc == null) {
loc = new alma.acs.alarmsystem.generated.Location();
}
if (loc.getBuilding() == null) {
loc.setBuilding("");
}
if (loc.getFloor() == null) {
loc.setFloor("");
}
if (loc.getMnemonic() == null) {
loc.setMnemonic("");
}
if (loc.getPosition() == null) {
loc.setPosition("");
}
if (loc.getRoom() == null) {
loc.setRoom("");
}
String FM = member.getName();
if (FM.equals(DEFAULT_FM)) {
logger.log(AcsLogLevel.ERROR, "In the CDB, FM=" + DEFAULT_FM + " in family " + FF + " is not allowed");
}
AlarmImpl alarm = new AlarmImpl();
alarm.setMultiplicityChildrenIds(new HashSet());
alarm.setMultiplicityParentIds(new HashSet());
alarm.setNodeChildrenIds(new HashSet());
alarm.setNodeParentIds(new HashSet());
alarm.setAction(action);
alarm.setTriplet(new Triplet(FF, FM, FC));
alarm.setCategories(new HashSet<Category>());
alarm.setCause(cause);
alarm.setConsequence(consequence);
alarm.setProblemDescription(problemDesc);
try {
alarm.setHelpURL(new URL(helpUrl));
} catch (MalformedURLException e) {
alarm.setHelpURL(null);
}
alarm.setInstant(instant);
Location location = new Location("0", loc.getFloor(), loc.getMnemonic(), loc.getPosition(), loc.getRoom());
alarm.setLocation(location);
if (contactPerson.getEmail() != null) {
alarm.setPiquetEmail(contactPerson.getEmail());
} else {
alarm.setPiquetEmail("");
}
if (contactPerson.getGsm() != null) {
alarm.setPiquetGSM(contactPerson.getGsm());
} else {
alarm.setPiquetGSM("");
}
alarm.setPriority(priority);
ResponsiblePerson responsible = new ResponsiblePerson(0, contactPerson.getName(), "", contactPerson.getEmail(), contactPerson.getGsm(), "");
alarm.setResponsiblePerson(responsible);
SourceDefinition srcDef = new SourceDefinition(source, "SOURCE", "", 15, 1);
Source src = new Source(srcDef, responsible);
alarm.setSource(src);
alarm.setIdentifier(alarm.getTriplet().toIdentifier());
alarmDefs.put(alarm.getAlarmId(), alarm);
if (!srcDefs.containsKey(source)) {
srcDefs.put(src.getSourceId(), src);
logger.log(AcsLogLevel.DEBUG, "Source " + src.getName() + " (id=" + src.getSourceId() + ") added");
}
logger.log(AcsLogLevel.DEBUG, "Alarm added " + alarm.getAlarmId());
}
// Add the default
if (defaultFM != null) {
alma.acs.alarmsystem.generated.Location loc = defaultFM.getLocation();
if (loc == null) {
loc = new alma.acs.alarmsystem.generated.Location();
}
if (loc.getBuilding() == null) {
loc.setBuilding("");
}
if (loc.getFloor() == null) {
loc.setFloor("");
}
if (loc.getMnemonic() == null) {
loc.setMnemonic("");
}
if (loc.getPosition() == null) {
loc.setPosition("");
}
if (loc.getRoom() == null) {
loc.setRoom("");
}
AlarmImpl defaultAlarm = new AlarmImpl();
defaultAlarm.setMultiplicityChildrenIds(new HashSet());
defaultAlarm.setMultiplicityParentIds(new HashSet());
defaultAlarm.setNodeChildrenIds(new HashSet());
defaultAlarm.setNodeParentIds(new HashSet());
defaultAlarm.setAction(action);
defaultAlarm.setCategories(new HashSet<Category>());
defaultAlarm.setCause(cause);
defaultAlarm.setConsequence(consequence);
defaultAlarm.setProblemDescription(problemDesc);
try {
defaultAlarm.setHelpURL(new URL(helpUrl));
} catch (MalformedURLException e) {
defaultAlarm.setHelpURL(null);
}
defaultAlarm.setInstant(instant);
Location location = new Location("0", loc.getFloor(), loc.getMnemonic(), loc.getPosition(), loc.getRoom());
defaultAlarm.setLocation(location);
defaultAlarm.setPiquetEmail(contactPerson.getEmail());
defaultAlarm.setPiquetGSM(contactPerson.getGsm());
defaultAlarm.setPriority(priority);
ResponsiblePerson responsible = new ResponsiblePerson(0, contactPerson.getName(), "", contactPerson.getEmail(), contactPerson.getGsm(), "");
defaultAlarm.setResponsiblePerson(responsible);
SourceDefinition srcDef = new SourceDefinition(source, "SOURCE", "", 15, 1);
Source src = new Source(srcDef, responsible);
defaultAlarm.setSource(src);
defaultAlarm.setIdentifier(defaultAlarm.getTriplet().toIdentifier());
Triplet triplet = new Triplet(FF, DEFAULT_FM, FC);
defaultAlarm.setTriplet(triplet);
defaultAlarm.setIdentifier(triplet.toIdentifier());
alarmDefs.put(defaultAlarm.getAlarmId(), defaultAlarm);
if (!srcDefs.containsKey(source)) {
srcDefs.put(src.getSourceId(), src);
logger.log(AcsLogLevel.DEBUG, "Source " + src.getName() + " (id=" + src.getSourceId() + ") added");
}
logger.log(AcsLogLevel.DEBUG, "Default alarm added " + defaultAlarm.getAlarmId());
}
}
}
}
Aggregations