|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Control
org.eclipse.swt.widgets.Scrollable
org.eclipse.swt.widgets.Composite
semorg.gui.util.AssociationTabControl
public class AssociationTabControl
This class provides a SWT composite which allows the user to manage several associations.
Field Summary | |
---|---|
private org.eclipse.swt.widgets.ToolItem |
chooseItem
The item "choose" in the toolbar. |
private Vector<DBColumn> |
columns
The columns of the GUI table. |
private org.eclipse.swt.widgets.ToolItem |
configureItem
The item "configure" in the toolbar. |
private org.eclipse.swt.widgets.ToolItem |
deleteItem
The item "delete" in the toolbar. |
private org.eclipse.swt.widgets.ToolItem |
disconnectItem
The item "disconnect" in the toolbar. |
private org.eclipse.swt.widgets.ToolItem |
editItem
The item "edit" in the toolbar. |
private boolean |
enabled
Indicates whether the control is enabled or not. |
private DistinctVector<SimpleIDKey> |
idsToDelete
Contains the ids of the items which should be deleted. |
private Set<ItemListener> |
itemListeners
A set containing the listeners of the control. |
private org.eclipse.jface.viewers.TableViewer |
mainTableViewer
Used to display the several DelayedPaymentItem objects as items
of a GUI table. |
private org.eclipse.swt.widgets.ToolItem |
newItem
The item "new" in the toolbar. |
private DistinctVector<SimpleIDKey> |
previouslySelectedIds
Contains the ids of the previously selected items. |
private int |
referencedFK
The id of the actual data record for which the associations get managed. |
private int |
style
Indicates which type of association is managed by the instance of this class. |
static int |
TYPE_CLIENTBOOKING_CLIENT
Instances from this type allow to manage the association between the classes Client and ClientBooking in the
ClientWindow . |
static int |
TYPE_CLIENTBOOKING_PRESENTATION
Instances from this type allow to manage the association between the classes ClientBooking and PublicPresentation in the
PublicPresentationWindow . |
static int |
TYPE_COMPANYBOOKING_COMPANY
Instances from this type allow to manage the association between classes Company and CompanyBooking in the CompanyWindow . |
static int |
TYPE_COMPANYBOOKING_PRESENTATION
Instances from this type allow to manage association between the classes CompanyBooking and CompanyInternalPresentation in the
CompanyInternalPresentationWindow . |
static int |
TYPE_EMPLOYEE
Instances from this type allow to manage the association between the classes Client and Company in the CompanyWindow . |
static int |
TYPE_LECTURER_CONDUCT
Instances from this type allow to manage the association Conduct in the SeminarTypeWindow . |
static int |
TYPE_LECTURER_INSTRUCTOR
Instances from this type allow to manage the association Instructor in the PublicPresentationWindow and
CompanyInternalPresentationWindow . |
static int |
TYPE_LECTURER_SUPERVISOR
Instances from this type allow to manage the association Supervisor in the PublicPresentationWindow and
CompanyInternalPresentationWindow . |
static int |
TYPE_PRESENTATION_INSTRUCTOR
Instances from this type allow to manage the association Instructor in the LecturerWindow . |
static int |
TYPE_PRESENTATION_SEMTYPE
Instances from this type allow to manage the association between classes Presentation and SeminarType in SeminarTypeWindow . |
static int |
TYPE_PRESENTATION_SUPERVISOR
Instances from this type allow to manage the association Supervisor in the LecturerWindow . |
static int |
TYPE_SEMINARTYPE_CONDUCT
Instances from this type allow to manage the association Conduct in the LecturerWindow . |
private DistinctVector<DBTableChangedListener> |
updateListeners
These listeners react on changes in the database tables by updating the GUI table. |
Fields inherited from class org.eclipse.swt.widgets.Control |
---|
handle |
Constructor Summary | |
---|---|
AssociationTabControl(org.eclipse.swt.widgets.Composite parent,
int style,
org.eclipse.swt.widgets.Shell parentShell)
Creates an instance of this class by initializing the gui elements and adding some listeners to the elements. |
Method Summary | |
---|---|
void |
addItemListener(ItemListener listener)
Adds a listener to itemListeners . |
void |
addSelectedIds(SimpleIDKey[] selectedElements,
boolean checkAlreadyAssigned)
This method is called by the editing windows whose are created by this control to update the data of this GUI table. |
private void |
addUpdateListener()
Adds listener to the updateListeners vector. |
void |
commitIntoDB(int generatedId)
Commits all changes made to the item corresponding to the given id into the database using the methods listed beneath. |
private void |
configureClassSpecificViewerParts()
Sets the columns of the GUI table corresponding to type of the association which actually managed by this control. |
private void |
connectInDB()
Connects all items whose ids are contained in the previouslySelectedIds Vector, but not in the input of the
mainTableViewer . |
private void |
deleteFromDB()
Deletes all item whose ids are contained in the idsToDelete
Vector. |
private String |
determineDeleteMessage(DistinctVector<SimpleIDKey> selectedElements)
This method determines the right deletion dialog hint text against the type of the association managed by this control. |
private void |
disconnectInDB()
Disconnects all items whose ids are contained in the previouslySelectedIds Vector, but not in the input of the
mainTableViewer . |
private void |
fireItemChanged()
Fires all listners in itemListeners . |
DistinctVector<SimpleIDKey> |
getObjects()
Returns the items of the GUI table. |
private boolean |
hasLockedId(SimpleIDKey element)
Checks if the id of the given element is locked. |
protected void |
onDelete()
This method implements the functionality of the deletion button, i.e. it deletes the selected elements if they're not locked. |
protected void |
onDisconnect()
This methode implements the functionality of the disconnect button, i.e. |
protected void |
openEditItemWindow()
This methode implements the functionality of the edit button, i.e. it opens a window for editing the chosen data record. |
protected void |
openListWindow()
Opens a ListWindow corresponding to the style of the current
AssociationTabControl instance. |
protected void |
openNewItemWindow()
This methode implements the functionality of the new button, i.e. it opens a window for editing the chosen data record. |
void |
removeItemListener(ItemListener listener)
Removes a listener from itemListeners . |
void |
setData(String key,
String value)
Sets a pair of key and value to this control needed for testing with ATOSj. |
void |
setEnabled(boolean enabled)
Enables / disables the chooseItem , the disconnectItem ,
the editItem and the deleteItem . |
void |
setInput(int referencedFK)
Fills the GUI table with data records corresponding to type of managed association and the actual data record of the editing window this control is included in. |
void |
update()
Updates the GUI table with the actual records from a database query. |
Methods inherited from class org.eclipse.swt.widgets.Composite |
---|
changed, checkSubclass, computeSize, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList |
Methods inherited from class org.eclipse.swt.widgets.Scrollable |
---|
computeTrim, getClientArea, getHorizontalBar, getVerticalBar |
Methods inherited from class org.eclipse.swt.widgets.Control |
---|
addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, computeSize, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse |
Methods inherited from class org.eclipse.swt.widgets.Widget |
---|
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int TYPE_EMPLOYEE
Client
and Company
in the CompanyWindow
.
public static final int TYPE_CLIENTBOOKING_CLIENT
Client
and ClientBooking
in the
ClientWindow
.
public static final int TYPE_COMPANYBOOKING_COMPANY
Company
and CompanyBooking
in the CompanyWindow
.
public static final int TYPE_PRESENTATION_SUPERVISOR
LecturerWindow
.
public static final int TYPE_PRESENTATION_INSTRUCTOR
LecturerWindow
.
public static final int TYPE_SEMINARTYPE_CONDUCT
LecturerWindow
.
public static final int TYPE_COMPANYBOOKING_PRESENTATION
CompanyBooking
and CompanyInternalPresentation
in the
CompanyInternalPresentationWindow
.
public static final int TYPE_LECTURER_INSTRUCTOR
PublicPresentationWindow
and
CompanyInternalPresentationWindow
.
public static final int TYPE_LECTURER_SUPERVISOR
PublicPresentationWindow
and
CompanyInternalPresentationWindow
.
public static final int TYPE_PRESENTATION_SEMTYPE
Presentation
and SeminarType
in SeminarTypeWindow
.
public static final int TYPE_LECTURER_CONDUCT
SeminarTypeWindow
.
public static final int TYPE_CLIENTBOOKING_PRESENTATION
ClientBooking
and PublicPresentation
in the
PublicPresentationWindow
.
private org.eclipse.jface.viewers.TableViewer mainTableViewer
DelayedPaymentItem
objects as items
of a GUI table.
private int style
private int referencedFK
private boolean enabled
private Vector<DBColumn> columns
private Set<ItemListener> itemListeners
private DistinctVector<DBTableChangedListener> updateListeners
private org.eclipse.swt.widgets.ToolItem disconnectItem
private org.eclipse.swt.widgets.ToolItem deleteItem
private org.eclipse.swt.widgets.ToolItem configureItem
private org.eclipse.swt.widgets.ToolItem chooseItem
private org.eclipse.swt.widgets.ToolItem editItem
private org.eclipse.swt.widgets.ToolItem newItem
private DistinctVector<SimpleIDKey> previouslySelectedIds
mainTableViewer
input. If the user
disconnects an associated item from the current item, it disappears from
the GUI table, but in the db it is still connected to the current object.
Thus we've got to hold the ids of the formerly connected items such that
we can disconnect them in the db when the user confirm his/her changes.
private DistinctVector<SimpleIDKey> idsToDelete
Constructor Detail |
---|
public AssociationTabControl(org.eclipse.swt.widgets.Composite parent, int style, org.eclipse.swt.widgets.Shell parentShell)
parent
- the parent composite of this AssociationTabControlstyle
- the style of the AssociationTabControl (see style
)Method Detail |
---|
private boolean hasLockedId(SimpleIDKey element)
element
- the element to be checked for a locked id
protected void onDelete()
idsToDelete
vector and calls
the function deleteFromDB()
.
private String determineDeleteMessage(DistinctVector<SimpleIDKey> selectedElements)
protected void openEditItemWindow()
protected void openNewItemWindow()
protected void openListWindow()
style
of the current
AssociationTabControl
instance.
protected void onDisconnect()
private void configureClassSpecificViewerParts()
public void setInput(int referencedFK) throws SQLException
SQLException
public DistinctVector<SimpleIDKey> getObjects()
DistinctVector
instance containing the the items of the
GUI table.public void setEnabled(boolean enabled)
chooseItem
, the disconnectItem
,
the editItem
and the deleteItem
.
setEnabled
in class org.eclipse.swt.widgets.Control
enabled
- if true the buttons above will be enabled, if
false they disabled.public void addSelectedIds(SimpleIDKey[] selectedElements, boolean checkAlreadyAssigned)
selectedElements
- the elements selected or created the editing windows
spawned by this control.checkAlreadyAssigned
- if true this method creates a message dialog
which informs the user that the selected item is already
assigned and will not be inserted again. Otherwise (false)
the dialog will not appear.public void commitIntoDB(int generatedId) throws SQLException
generatedId
- the id of item which was changed.
SQLException
- If the creation, manipulation, execution or closing of a
PreparedStatement instance used for querying the database
fails.deleteFromDB()
,
disconnectInDB()
,
connectInDB()
private void disconnectInDB() throws SQLException
previouslySelectedIds
Vector, but not in the input of the
mainTableViewer
.
SQLException
- If the creation, manipulation, execution or closing of a
PreparedStatement instance used for querying the database
fails.private void connectInDB() throws SQLException
previouslySelectedIds
Vector, but not in the input of the
mainTableViewer
.
SQLException
- If the creation, manipulation, execution or closing of a
PreparedStatement instance used for querying the database
fails.private void deleteFromDB() throws SQLException
idsToDelete
Vector.
SQLException
- If the creation, manipulation, execution or closing of a
PreparedStatement instance used for querying the database
fails.public void setData(String key, String value)
key
- the key (type) of the value setvalue
- the value set to the controlpublic void addItemListener(ItemListener listener)
itemListeners
.
public void removeItemListener(ItemListener listener)
itemListeners
.
private void fireItemChanged()
itemListeners
.
private void addUpdateListener()
updateListeners
vector. The type of the
listener is determined by the type of the association managed by this
control.
public void update()
update
in class org.eclipse.swt.widgets.Control
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |