PDA

View Full Version : How to set default Drawing 2D Class


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 ???

alexniccoli
10-12-2006, 03:24 AM
Hi Wilfried
1.I think that if you don't use DRAWING_2D,you can rename it in DRAWING_2D_COCREATE(for example) and so Model manager don't use this
Datamanagement schema class.
2.You must configure your custum classes of 2D drwings using XML.Example:IF
you use me_drawing and sd_drawing (classes of Workmanager Schama)
you must configure this classes like follows:

<Class extends="xxx">
<Name catalog="awmdemoa" msg_num="172">sd_drawing</Name>
...
<AnnotationClass>true</AnnotationClass>
...
</Class>

<Class extends="xxx">
<Name catalog="awmdemoa" msg_num="13">me_drawing</Name>
...
<DraftingClass>true</DraftingClass>
...
</Class>

<AnnotationClass> specify that this class is Annotation default doc class.
<DraftingClass> specify that this class is (OSDD-ME10) default class.

Tell me something if you don't undserstand or if I have not understood something

Alessandro

fortner
10-13-2006, 05:00 AM
I think a good start point would be com.osm.datamgmt.biz.MMClassNameManager, where
getModelClassName() , getDrawingClassName(), or any other get*ClassName() are able to provide the default values used in the save UI.
You may overwrite these functions through custom business to fit your requirements.

wilfried_loewe
10-13-2006, 06:56 AM
Hi to all,

thank you for your tips. I covered this problem yesterday implementing/extending my own "Class Name Manager". I become this tip from MM development team while testing 14.5 beta.
There is a good topic in the Manager Customization Guide called "The Java Class Name Manager" which covers this in depth. I think this is the best way, if you had e. g. 3 teams working on one Database Instance all with their own classes and logic.

Usng multiple classes of the same kind/category (e. g. 2D-Drawing). If you start a query in query panel Drawings, all drawingnumbers of the different classes in the same category are listen. You had no change to get only the drawings of one specified class e. g. DRAWING_2D.
Querying of pseudo attributes not possible and use of DB_CLASS_NAME is filtered by the query panel.
So we should get/have a combo box with all class items of the same category, if there is more then one class. The combo box is already in use by "Advanced" queries (First row of panel) - see source code in com.osm.datamgmt.ui.search.QueryAttributesPanel.java. In the method createAllAttributeEditors() the variable usingComboBox is set to false, if a class specified query is called. Only small changes in this classes are required, to solve this problem - but I think, it is not a good idea, to replace the class with this required changes ...

Or does anyone know another way to query only one class of multiple in same category ???