wilfried_loewe
10-10-2006, 06:51 AM
Does anyone know, how to set a default Class for saving 2D-Drawings if you had more then one 2D Drawing Classes ??? The default is the last extended Class (LIFO-Lists Concept) e. g. if you had the Standard Class DRAWING_2D and a User definded Class BOM_2D, BOM_2D is the default Class saving a new 2D Drawing. I had tested a following Extension:
XML extend on DBR_ELEMENT:
<Attribute>
DB_CLASS_NAME
<Visible>true</Visible>
<Protect>false</Protect>
<Searchable>true</Searchable>
<DisplayName>DocumentClass</DisplayName>
<AttributeEditorClass>com.kl_wl_custom.datamgmt.editor.Doc2DDBClassNameAttributeEditor</AttributeEditorClass>
</Attribute>
with the following Java Extension (see Tag AttributeEditorClass above):
// Beginn of Java Code ....
package com.kl_wl_custom.datamgmt.editor;
import java.util.*;
import javax.swing.table.*;
import com.osm.biz.*;
import com.osm.datamgmt.biz.*;
import com.osm.exception.*;
import com.osm.datamgmt.editor.*;
public class Doc2DDBClassNameAttributeEditor extends com.osm.editor.WMAttEditorComboBox {
TableCellEditor cellEditor;
/** Creates new StoreTypeAttributeEditor 2D Classes. */
public Doc2DDBClassNameAttributeEditor(WMAttribute wmAttribute)
throws WMException {
super(wmAttribute);
}
public void setDBObject(WMDBObject object) {
super.setDBObject(object);
try {
if (object instanceof Drawing) {
populatePickList(ClassNameRegistrar.getInstance().getClassNameManager().getDrawingClasses());
setEnabled(true);
}
} catch (WMException e) {
}
}
public javax.swing.table.TableCellEditor getTableCellEditor() {
try {
// populatePickList(WMSession.getWMSession().getClassInstances(Drawing.class));
populatePickList(ClassNameRegistrar.getInstance().getClassNameManager().getDrawingClasses());
} catch (WMException e) {
}
return super.getTableCellEditor();
}
private String getDefaultDoc2DClass() {
try {
if (ClassNameRegistrar.getInstance().getClassNameManager().getDrawingClasses().contains(pdm.catgets("awm_stda", 254, "DRAWING_2D")))
return pdm.catgets("awm_stda", 254, "DRAWING_2D");
else
return null;
} catch (Throwable t) {
return null;
}
}
private void populatePickList(List list) {
if (list != null) {
removeAllItems();
for (int i = 0; i < list.size(); ++i) {
addItem(list.get(i));
}
if (list.size() > 0) {
if (getDefaultDoc2DClass() != null) {
setSelectedItem(getDefaultDoc2DClass());
} else {
setSelectedIndex(0);
}
}
}
}
}
// End of Java Code ....
Why it does not work ???
XML extend on DBR_ELEMENT:
<Attribute>
DB_CLASS_NAME
<Visible>true</Visible>
<Protect>false</Protect>
<Searchable>true</Searchable>
<DisplayName>DocumentClass</DisplayName>
<AttributeEditorClass>com.kl_wl_custom.datamgmt.editor.Doc2DDBClassNameAttributeEditor</AttributeEditorClass>
</Attribute>
with the following Java Extension (see Tag AttributeEditorClass above):
// Beginn of Java Code ....
package com.kl_wl_custom.datamgmt.editor;
import java.util.*;
import javax.swing.table.*;
import com.osm.biz.*;
import com.osm.datamgmt.biz.*;
import com.osm.exception.*;
import com.osm.datamgmt.editor.*;
public class Doc2DDBClassNameAttributeEditor extends com.osm.editor.WMAttEditorComboBox {
TableCellEditor cellEditor;
/** Creates new StoreTypeAttributeEditor 2D Classes. */
public Doc2DDBClassNameAttributeEditor(WMAttribute wmAttribute)
throws WMException {
super(wmAttribute);
}
public void setDBObject(WMDBObject object) {
super.setDBObject(object);
try {
if (object instanceof Drawing) {
populatePickList(ClassNameRegistrar.getInstance().getClassNameManager().getDrawingClasses());
setEnabled(true);
}
} catch (WMException e) {
}
}
public javax.swing.table.TableCellEditor getTableCellEditor() {
try {
// populatePickList(WMSession.getWMSession().getClassInstances(Drawing.class));
populatePickList(ClassNameRegistrar.getInstance().getClassNameManager().getDrawingClasses());
} catch (WMException e) {
}
return super.getTableCellEditor();
}
private String getDefaultDoc2DClass() {
try {
if (ClassNameRegistrar.getInstance().getClassNameManager().getDrawingClasses().contains(pdm.catgets("awm_stda", 254, "DRAWING_2D")))
return pdm.catgets("awm_stda", 254, "DRAWING_2D");
else
return null;
} catch (Throwable t) {
return null;
}
}
private void populatePickList(List list) {
if (list != null) {
removeAllItems();
for (int i = 0; i < list.size(); ++i) {
addItem(list.get(i));
}
if (list.size() > 0) {
if (getDefaultDoc2DClass() != null) {
setSelectedItem(getDefaultDoc2DClass());
} else {
setSelectedIndex(0);
}
}
}
}
}
// End of Java Code ....
Why it does not work ???