* @param window
* @param presentationModel
*/
public void openAttributeView(WindowInterface window,
PresentationModel presentationModel) {
ConstructionTypeModel constructionTypeModel = (ConstructionTypeModel) presentationModel
.getBean();
AttributeViewHandler attributeViewHandler = new AttributeViewHandler(
login, managerRepository);
AttributeView attributeView = new AttributeView(attributeViewHandler,
true);
WindowInterface dialog = new JDialogAdapter(new JDialog(
ProTransMain.PRO_TRANS_MAIN, "Attributt", true));
dialog.setName("AttributeView");
dialog.add(attributeView.buildPanel(dialog));
dialog.pack();
Util.locateOnScreenCenter(dialog);
dialog.setVisible(true);
List<Attribute> newAttributes = attributeView.getSelectedObjects();
if (newAttributes != null && newAttributes.size() == 1) {
String useAsUniversal = "";
if (masterDialog) {
useAsUniversal = (String) JOptionPane.showInputDialog(window
.getComponent(),
"Skal attributt gjelde alle gjeldende garasjetyper",
"Skal gjelde alle gjelende grasjetype",
JOptionPane.PLAIN_MESSAGE, null, new Object[] { "Ja",
"Nei" }, null);
}
Attribute att = newAttributes.get(0);
Object[] selectionValues = null;
List<String> choices = att.getChoices();
if (choices != null && choices.size() != 0) {
selectionValues = choices.toArray();
} else if (att.getYesNo() != null && att.getYesNo() > 0) {
selectionValues = new Object[] { "Ja", "Nei" };
}
String attributeValue = (String) JOptionPane.showInputDialog(window
.getComponent(), "Gi attributt verdi", "Attributt",
JOptionPane.PLAIN_MESSAGE, null, selectionValues, null);
String orderValue = (String) JOptionPane.showInputDialog(window
.getComponent(), "Rekkef�lge", "Attributt",
JOptionPane.PLAIN_MESSAGE, null, null, null);
Integer dialogOrder = null;
if (orderValue != null && orderValue.length() != 0) {
dialogOrder = Integer.valueOf(orderValue);
}
if (attributeValue == null || attributeValue.length() == 0) {
Util.showErrorDialog(window.getComponent(), "Feil",
"Attributt m� ha verdi");
} else {
ConstructionTypeAttribute constructionTypeAttribute = constructionTypeModel
.getArticleAttribute(newAttributes.get(0),
attributeValue, dialogOrder);
if (masterDialog && useAsUniversal.equalsIgnoreCase("Ja")) {
universalAttributes.add(constructionTypeAttribute);
}