use of org.apache.xerces.util.URI.MalformedURIException 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 org.apache.xerces.util.URI.MalformedURIException in project ACS by ACS-Community.
the class AlarmManager method checkCDB.
public String checkCDB() {
List<FaultFamily> ffs = _ffList;
String error = "";
for (FaultFamily ff : ffs) {
if (ff.getName() == null || ff.getName().length() == 0)
error += "Fault Family " + ff.getName() + " doesn't have a name.\n";
try {
new URI(ff.getHelpUrl());
} catch (MalformedURIException e1) {
error += "Fault Family " + ff.getName() + " has malformed URL.\n";
}
if (ff.getContact() == null)
error += "Fault Family " + ff.getName() + " doesn't define Contact entity.\n";
if (ff.getContact().getName() == null || ff.getContact().getName().length() == 0)
error += "Fault Family " + ff.getName() + " doesn't define Contact name.\n";
if (ff.getAlarmSource().compareTo("ALARM_SYSTEM_SOURCES") != 0)
error += "Fault Family " + ff.getName() + " has wrong Source defined.\n";
if (ff.getFaultMemberCount() == 0 && ff.getFaultMemberDefault() == null)
error += "Fault Family " + ff.getName() + " doesn't define any Fault Member and doesn't have a Default Fault Member.\n";
FaultMember[] fms = ff.getFaultMember();
for (FaultMember fm : fms) {
if (fm.getName() == null || fm.getName().length() == 0)
error += "Fault Member " + fm.getName() + " defined in Fault Family " + ff.getName() + " doesn't have a name.\n";
}
FaultCode[] fcs = ff.getFaultCode();
for (FaultCode fc : fcs) {
if (fc.getValue() <= 0)
error += "Fault Code " + fc.getValue() + " defined in Fault Family " + ff.getName() + " has an invalid value (Must be > 0).\n";
if (!fc.hasPriority())
error += "Fault Code " + fc.getValue() + " defined in Fault Family " + ff.getName() + " doesn't define a priority.\n";
if (fc.getPriority() < 0 || fc.getPriority() > 3)
error += "Fault Code " + fc.getValue() + " defined in Fault Family " + ff.getName() + " has an invalid a priority (Must be in [0;3]).\n";
if (fc.getProblemDescription() == null || fc.getProblemDescription().length() == 0)
error += "Fault Code " + fc.getValue() + " defined in Fault Family " + ff.getName() + " doesn't define a problem description.\n";
}
}
return error;
}
Aggregations