Skip to content
Snippets Groups Projects
Commit 15140af1 authored by Niklas Kielblock's avatar Niklas Kielblock
Browse files

fix #4

parent 9b4043ae
Branches master
No related tags found
No related merge requests found
......@@ -358,7 +358,7 @@ public class DetailsTable extends JScrollPane
if(NameValue.getText().isEmpty())
JOptionPane.showMessageDialog(controller.gui,"Ein Kompetenzbereichsname muss muss mind. ein Zeichen lang sein.",
"Ungültiger Name",JOptionPane.ERROR_MESSAGE);
else if(((ObserverScopesList)controller.gui.getComponent("ScopesList")).containsScope(NameValue.getText()))
else if(((ObserverScopesList)controller.gui.getComponent("ScopesList")).containsScopeExcept(NameValue.getText(), scope))
JOptionPane.showMessageDialog(controller.gui,"Mehrere gleichnamige Kompetenzbereiche sind nicht erlaubt.",
"Gleiche Kompetenzbereichsnamen",JOptionPane.ERROR_MESSAGE);
else
......@@ -475,7 +475,7 @@ public class DetailsTable extends JScrollPane
if(NameValue.getText().isEmpty())
JOptionPane.showMessageDialog(controller.gui,"Ein Modulname muss muss mind. ein Zeichen lang sein.",
"Ungültiger Name",JOptionPane.ERROR_MESSAGE);
else if(((ObserverModulesList)controller.gui.getComponent("ModulesList")).containsModule(NameValue.getText()))
else if(((ObserverModulesList)controller.gui.getComponent("ModulesList")).containsModuleExcept(NameValue.getText(), module))
JOptionPane.showMessageDialog(controller.gui,"Mehrere gleichnamige Module sind nicht erlaubt.",
"Gleiche Modulnamen",JOptionPane.ERROR_MESSAGE);
else
......
......@@ -102,6 +102,19 @@ public class ObserverModulesList extends JList implements Observer
return false;
}
/** Whether list contains module named <i>name</i> that is not the same object as <i>except</i>
*
* @param name Name of module
* @param except Module object that should not be looked for
*/
public boolean containsModuleExcept(String name, Module except)
{
for(Module m : currentModules)
if(m != except && m.getName().equals(name))
return true;
return false;
}
public int length()
{
return currentModules.length;
......
......@@ -103,6 +103,19 @@ public class ObserverScopesList extends JList implements Observer
return false;
}
/** Whether list contains scope named <i>name</i> that is not the same object as <i>except</i>
*
* @param name Name of scope
* @param except Scope object that should not be looked for
*/
public boolean containsScopeExcept(String name, Scope except)
{
for(Scope s : currentScopes)
if(s != except && s.getName().equals(name))
return true;
return false;
}
public int length()
{
return currentScopes.length;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment