ENOVIA Lifecycle Applications |
User Interface |
How to use the Identity Card InterfaceCreating and displaying tabs in ENOVIA |
Use Case |
AbstractThis article shows how to use the ENOVIIdentityCardInterface interface of the VPMDesktop framework to create and display tabs in the Identity Card View. |
This use case is intended to show you how to create and display a new tab for the Identity Card view in the Change Management domain. Identity Cards are used to control and display the data of an object. The VPMDesktop framework contains the ENOVIIdentityCardInterface interface which allows you to directly create and display the tab which may then be manipulated as desired.
[Top]
CAADkiIdentityCard is a use case of the CAAVPMDesktop.edu framework that illustrates the creation and display of tabs for the Identity Card view of ENOVIA objects.
[Top]
CAADkiIdentityCard is illustrating an example for a customer having a request from their user community to provide an informal way for each user to store personal notes connected to an ENOVIA object. For purposes of illustration we will assume that the requirement is to only display these notes for Change Management objects (Actions/COs/CRs). The information will be displayed by creating a new tab attached to the Identity Card view. All data displayed on the tab will be stored locally on the user's workstation.
The ENOVIIdentityCardInterface interface/methods shown are as follows:
isEnabled
setObject
setServerParameters
The CAADkiNotesTab methods shown are as follows:
canEnabled
showMyView
CAADkiNotesTab
getFile
The ActionListener interface/methods shown are as follows:
actionPerformed
[Top]
To launch CAADkiIdentityCard, you will need to execute the following steps:
[Top]
The CAADkiIdentityCard use case is made of a single file located in the CAADkiIdentityCard.mj module of the CAAVPMDesktop.edu framework:
Windows | InstallRootDirectory\CAAVPMDesktop.edu\CAADkiIdentityCard.mj\ |
Unix | InstallRootDirectory/CAAVPMDesktop.edu/CAADkiIdentityCard.mj/ |
where InstallRootDirectory
is the directory where the CAA
CD-ROM is installed.
[Top]
For demonstration purposes, the code from the CAADkiIdentityCard use case is shown here. There are three logical steps in the CAADkiIdentityCard use case:
ShowMyView
Method
[Top]
import com.dassault_systemes.vpmdesktop.vdk0interfaces.interfaces.ENOVIIdentityCardInterface; import com.dassault_systemes.vpmdesktop.vdk0interfaces.interfaces.ENOVIObject; import javax.swing.JPanel; |
These import statements are required for the following operations.
//--- Create a class extending a JPanel implementing the ENOVIIdentityCardInterface public class CAADkiNotesTab extends JPanel implements ENOVIIdentityCardInterface { public CAADkiNotesTab() {} public void setServerParameters(String marker, String host) {} public boolean isEnabled(ENOVIObject obj) {} public void setObject(ENOVIObject obj) {} public static boolean canEnabled(ENOVIObject obj) {} } |
CAADkiNotesTab
and the methods copied from
ENOVIIdentityCardInterface setServerParameters
, isEnabled
,
and setObject
. The method canEnabled
is
not a true method in the interface since static methods can not be part of an
interface but this method is also needed for our new class. canEnabled
. This
method is used to determine whether this tab should be added to the
IdentityCard being constructed. For our example we wish to add this new
tab only to Actions, Change Orders and Change Requests. To limit when
this tab will be created we will need to get the Type from the ENOVIObject.setObject
method will be used to create the data and fields to be
displayed on our new tab.[Top]
No additional import statements are required for the following operations.
//--- implement ENOVIIdentityCardInterface::setServerParameters public void setServerParameters(String marker, String host) {} //--- implement CAADkiNotesTab::canEnabled public static boolean canEnabled(ENOVIObject obj) { return ("ENOVIA_ECO"==obj.getBaseType() || "ENOVIA_ECR"==obj.getBaseType() || "ENOVIA_AFLAction"==obj.getBaseType()); } //--- implement ENOVIIdentityCardInterface::isEnabled public boolean isEnabled(ENOVIObject obj) { return canEnabled(obj); } //--- implement ENOVIIdentityCardInterface::setObject public void setObject(ENOVIObject obj) { myObject = obj; String notes = myNotes.getProperty(obj.getInternalStringValue("V_name")); showMyView(notes); } |
setServerParameters
is not needed for our example so we just
use an empty method body. getBaseType
method to return a
string that can be used to determine what type of object is represented.
We can use this information in our implementation of the canEnabled
method
to limit when our new tab will be created.
isEnabled
method determines when the user is allowed to select the
tab for display and editing. We will return TRUE whenever our new tab
is created.setObject
method will do the main work of creating the layout of
our new tab and populating the data to be displayed.[Top]
ShowMyView
Method
import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.border.Border; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JScrollPane; import javax.swing.JTextArea; |
These import statements are required for the following operations.
private void showMyView(String notes) { Border raisedbevel, loweredbevel; raisedbevel = BorderFactory.createRaisedBevelBorder(); loweredbevel = BorderFactory.createLoweredBevelBorder(); myTextArea = new JTextArea(5, 30); myTextArea.setLineWrap(true); myTextArea.setBackground(Color.white); myTextArea.append(notes); JScrollPane scrollPane = new JScrollPane(myTextArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); setPreferredSize(new Dimension(450, 110)); scrollPane.setPreferredSize(new Dimension(500,250)); scrollPane.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createCompoundBorder( loweredbevel, raisedbevel), scrollPane.getBorder())); scrollPane.getHorizontalScrollBar().setEnabled(true); scrollPane.getVerticalScrollBar().setEnabled(true); add(scrollPane, BorderLayout.CENTER); JButton b1 = new JButton("Save"); b1.setActionCommand("savenotes"); b1.addActionListener(this); b1.setToolTipText("Click this button to save these notes."); add(b1, BorderLayout.SOUTH); } |
public class CAADkiNotesTab extends JPanel implements ENOVIIdentityCardInterface, ActionListener public void actionPerformed(ActionEvent e) { if ("savenotes".equals(e.getActionCommand())) { setNotes(myObject.getInternalStringValue("V_name"), myTextArea.getText()); } } |
showMyView
actionPerformed
method. We will use this method the store the notes text in a file
saved in the user's home directory.[Top]
import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Properties; import javax.swing.border.EtchedBorder; import javax.swing.border.TitledBorder; |
These import statements are required for the following operations.
public CAADkiNotesTab() { TitledBorder myBorder = new TitledBorder(new EtchedBorder(), myFullFilename); setBorder(myBorder); myFile = getFile(); try { myNotes.load(new FileInputStream(myFile)); } catch(IOException e) { //e.printStackTrace(); //No need to take any action since a file will be created when the notes are saved. } } private String getNotes(String key) { return myNotes.getProperty(key); } private void setNotes(String key, String value) { myNotes.setProperty(key, value); try { myNotes.store(new FileOutputStream(myFile), myFileHeader); } catch(IOException e) { e.printStackTrace(); } } public File getFile() { if((myFilename==null) || (myFilename.length() == 0)) myFile = null; else { myFile = new File(myDirectory, myFilename); } return myFile; } |
getNotes
method to return the notes text based on the key.
This simple example is using the value stored in the V_name attribute as the
key.setNotes
method is used to store the new or edited notes text into a
Properties object and also saves the updated Properties information to a text
file stored in the user's home directory on the client.[Top]
Use the ENOVIIdentityCardInterface interface to create and display
additional tabs in the Identity Card view for ENOVIA objects. You can hide the
tab using canEnabled
and disable the tab using
isEnabled
.
[Top]
[1] | Building and Launching a CAA V5 Use Case |
[Top] |
Version: 1 [Nov 2004] | Document created |
[Top] |
Copyright © 1994-2004, Dassault Systèmes. All rights reserved.