### Eclipse Workspace Patch 1.0 #P org.eclipse.jst.ejb.ui Index: ejb_ui/org/eclipse/jst/ejb/ui/internal/wizard/AddSessionBeanWizardPage.java =================================================================== RCS file: /cvsroot/webtools/ejbtools/plugins/org.eclipse.jst.ejb.ui/ejb_ui/org/eclipse/jst/ejb/ui/internal/wizard/AddSessionBeanWizardPage.java,v retrieving revision 1.10 diff -u -r1.10 AddSessionBeanWizardPage.java --- ejb_ui/org/eclipse/jst/ejb/ui/internal/wizard/AddSessionBeanWizardPage.java 28 May 2008 16:21:14 -0000 1.10 +++ ejb_ui/org/eclipse/jst/ejb/ui/internal/wizard/AddSessionBeanWizardPage.java 30 Jun 2008 08:22:54 -0000 @@ -51,9 +51,7 @@ import org.eclipse.wst.common.frameworks.datamodel.IDataModel; public class AddSessionBeanWizardPage extends AddEnterpriseBeanWizardPage { - - //private Text remoteInterfaceName; - //private Text localInterfaceName; + private Text ejbNameText; private Text mappedNameText; private Combo transactionTypeCombo; @@ -137,8 +135,14 @@ synchHelper.synchCheckbox(local2xCheck, LOCAL_HOME, null); - Session2xInterfacesTableRow localRow = new Session2xInterfacesTableRow("L", model.getStringProperty(LOCAL_COMPONENT_INTERFACE), LOCAL_COMPONENT_INTERFACE); - Session2xInterfacesTableRow localRowHome = new Session2xInterfacesTableRow("LH", model.getStringProperty(LOCAL_HOME_INTERFACE), LOCAL_HOME_INTERFACE); + Session2xInterfacesTableRow localRow = new Session2xInterfacesTableRow( + EJBUIMessages.LOCAL_COMPONENT_INTERFACE_CODE, + model.getStringProperty(LOCAL_COMPONENT_INTERFACE), + LOCAL_COMPONENT_INTERFACE); + Session2xInterfacesTableRow localRowHome = new Session2xInterfacesTableRow( + EJBUIMessages.LOCAL_HOME_INTERFACE_CODE, + model.getStringProperty(LOCAL_HOME_INTERFACE), + LOCAL_HOME_INTERFACE); Session2xInterfacesTableRow[] localTableRows = {localRow, localRowHome}; localIntfTable = new Session2xInterfacesTable(othersComposite, new String[0], model, localTableRows); localIntfTable.getTable().setEnabled(model.getBooleanProperty(LOCAL_HOME)); @@ -166,8 +170,14 @@ synchHelper.synchCheckbox(remote2xCheck, REMOTE_HOME, null); - Session2xInterfacesTableRow remoteRow = new Session2xInterfacesTableRow("R", model.getStringProperty(REMOTE_COMPONENT_INTERFACE), REMOTE_COMPONENT_INTERFACE); - Session2xInterfacesTableRow remoteRowHome = new Session2xInterfacesTableRow("RH", model.getStringProperty(REMOTE_HOME_INTERFACE), REMOTE_HOME_INTERFACE); + Session2xInterfacesTableRow remoteRow = new Session2xInterfacesTableRow( + EJBUIMessages.REMOTE_COMPONENT_INTERFACE_CODE, + model.getStringProperty(REMOTE_COMPONENT_INTERFACE), + REMOTE_COMPONENT_INTERFACE); + Session2xInterfacesTableRow remoteRowHome = new Session2xInterfacesTableRow( + EJBUIMessages.REMOTE_HOME_INTERFACE_CODE, + model.getStringProperty(REMOTE_HOME_INTERFACE), + REMOTE_HOME_INTERFACE); Session2xInterfacesTableRow[] remoteTableRows = {remoteRow, remoteRowHome}; remoteIntfTable = new Session2xInterfacesTable(othersComposite, new String[0], model, remoteTableRows); remoteIntfTable.getTable().setEnabled(model.getBooleanProperty(REMOTE_HOME)); @@ -318,5 +328,4 @@ return true; } - } Index: ejb_ui/org/eclipse/jst/ejb/ui/internal/wizard/Session2xInterfacesTableRow.java =================================================================== RCS file: /cvsroot/webtools/ejbtools/plugins/org.eclipse.jst.ejb.ui/ejb_ui/org/eclipse/jst/ejb/ui/internal/wizard/Session2xInterfacesTableRow.java,v retrieving revision 1.1 diff -u -r1.1 Session2xInterfacesTableRow.java --- ejb_ui/org/eclipse/jst/ejb/ui/internal/wizard/Session2xInterfacesTableRow.java 23 Apr 2008 14:51:59 -0000 1.1 +++ ejb_ui/org/eclipse/jst/ejb/ui/internal/wizard/Session2xInterfacesTableRow.java 30 Jun 2008 08:22:54 -0000 @@ -10,26 +10,30 @@ *******************************************************************************/ package org.eclipse.jst.ejb.ui.internal.wizard; -public class Session2xInterfacesTableRow{ - private String abriviation; +public class Session2xInterfacesTableRow { + + private String abbreviation; private String className; private String propertyName; - Session2xInterfacesTableRow(String abriviation, String className, String propertyName){ - setAbriviation(abriviation); + Session2xInterfacesTableRow(String abbreviation, String className, String propertyName){ + setAbbreviation(abbreviation); setClassName(className); setPropertyName(propertyName); } - public void setAbriviation(String abriviation) { - this.abriviation = abriviation; + public void setAbbreviation(String abbreviation) { + this.abbreviation = abbreviation; } - public String getAbriviation() { - return abriviation; + + public String getAbbreviation() { + return abbreviation; } + public void setClassName(String className) { this.className = className; } + public String getClassName() { return className; } @@ -41,4 +45,5 @@ public String getPropertyName() { return propertyName; } + } Index: ejb_ui/org/eclipse/jst/ejb/ui/internal/wizard/Session2xInterfacesTable.java =================================================================== RCS file: /cvsroot/webtools/ejbtools/plugins/org.eclipse.jst.ejb.ui/ejb_ui/org/eclipse/jst/ejb/ui/internal/wizard/Session2xInterfacesTable.java,v retrieving revision 1.1 diff -u -r1.1 Session2xInterfacesTable.java --- ejb_ui/org/eclipse/jst/ejb/ui/internal/wizard/Session2xInterfacesTable.java 23 Apr 2008 14:51:59 -0000 1.1 +++ ejb_ui/org/eclipse/jst/ejb/ui/internal/wizard/Session2xInterfacesTable.java 30 Jun 2008 08:22:54 -0000 @@ -26,6 +26,7 @@ import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.TextCellEditor; import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jst.ejb.ui.internal.util.EJBUIMessages; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.TableEditor; import org.eclipse.swt.events.ControlAdapter; @@ -35,10 +36,16 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableItem; @@ -47,18 +54,18 @@ public class Session2xInterfacesTable extends Composite { + private static final String _TABLEITEM = "_TABLEITEM"; + private Table table; private TableViewer viewer; private IDataModel model; - private final String ABRIVIATION_COLUMN = "abriviation"; - private final String CLASS_NAME_COLUMN = "className"; + private final static String ABBREVIATION_COLUMN = "abbreviation"; + private final static String CLASS_NAME_COLUMN = "className"; private ArrayList tableValues = new ArrayList(); // Set column names - private String[] columnNames = { ABRIVIATION_COLUMN, - CLASS_NAME_COLUMN - }; + private String[] columnNames = { ABBREVIATION_COLUMN, CLASS_NAME_COLUMN }; protected class IntfTableContentProvider implements IStructuredContentProvider { @@ -86,11 +93,11 @@ } public String getColumnText(Object element, int columnIndex) { - if(element instanceof Session2xInterfacesTableRow){ + if (element instanceof Session2xInterfacesTableRow) { Session2xInterfacesTableRow row = (Session2xInterfacesTableRow) element; - if(columnIndex == 0){ - return row.getAbriviation(); - }else if(columnIndex == 1){ + if (columnIndex == 0) { + return row.getAbbreviation(); + } else if(columnIndex == 1){ return row.getClassName(); } } @@ -103,18 +110,15 @@ public Session2xInterfacesTable(Composite parent, String[] columnTitles, IDataModel model, Session2xInterfacesTableRow[] tableRows) { super(parent, SWT.NONE); this.model = model; - for(int k=0;kThis method has been derived from example + * Snippet 125

+ * @param table + */ + protected void setTableTooltips(final Table table) { + // Disable native tooltip + table.setToolTipText(""); + + // Implement a "fake" tooltip + final Listener labelListener = new Listener() { + public void handleEvent(Event event) { + Label label = (Label) event.widget; + Shell shell = label.getShell(); + switch (event.type) { + case SWT.MouseDown: + Event e = new Event(); + e.item = (TableItem) label.getData(_TABLEITEM); + // Assuming table is single select, set the selection as if + // the mouse down event went through to the table + table.setSelection(new TableItem[] { (TableItem) e.item }); + table.notifyListeners(SWT.Selection, e); + shell.dispose(); + table.setFocus(); + break; + case SWT.MouseExit: + shell.dispose(); + break; + } + } + }; + + Listener tableListener = new Listener() { + Shell tip = null; + Label label = null; + public void handleEvent(Event event) { + switch (event.type) { + case SWT.Dispose: + case SWT.KeyDown: + case SWT.MouseMove: { + if (tip == null) break; + tip.dispose(); + tip = null; + label = null; + break; + } + case SWT.MouseHover: { + TableItem item = table.getItem(new Point(event.x, event.y)); + if (item != null) { + if (tip != null && !tip.isDisposed()) tip.dispose(); + Display display = event.widget.getDisplay(); + Shell shell = ((Table) event.widget).getShell(); + tip = new Shell(shell, SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL); + tip.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + FillLayout layout = new FillLayout(); + layout.marginWidth = 2; + tip.setLayout(layout); + label = new Label(tip, SWT.NONE); + label.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); + label.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + label.setData(_TABLEITEM, item); + label.setText(getTooltipForTableItem(item.getText())); + label.addListener(SWT.MouseExit, labelListener); + label.addListener(SWT.MouseDown, labelListener); + Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT); + Rectangle rect = item.getBounds(0); + Point pt = table.toDisplay(rect.x, rect.y); + tip.setBounds(pt.x, pt.y, size.x, size.y); + tip.setVisible(true); + } + } + } + } + }; + + table.addListener(SWT.Dispose, tableListener); + table.addListener(SWT.KeyDown, tableListener); + table.addListener(SWT.MouseMove, tableListener); + table.addListener(SWT.MouseHover, tableListener); + } + + protected String getTooltipForTableItem(String tableItemText) { + if (EJBUIMessages.LOCAL_COMPONENT_INTERFACE_CODE.equals(tableItemText)) { + return EJBUIMessages.LOCAL_COMPONENT_INTERFACE_TOOLTIP; + } else if (EJBUIMessages.LOCAL_HOME_INTERFACE_CODE.equals(tableItemText)) { + return EJBUIMessages.LOCAL_HOME_INTERFACE_TOOLTIP; + } else if (EJBUIMessages.REMOTE_COMPONENT_INTERFACE_CODE.equals(tableItemText)) { + return EJBUIMessages.REMOTE_COMPONENT_INTERFACE_TOOLTIP; + } else if (EJBUIMessages.REMOTE_HOME_INTERFACE_CODE.equals(tableItemText)) { + return EJBUIMessages.REMOTE_HOME_INTERFACE_TOOLTIP; + } + + return ""; + } + } Index: property_files/ejb_ui.properties =================================================================== RCS file: /cvsroot/webtools/ejbtools/plugins/org.eclipse.jst.ejb.ui/property_files/ejb_ui.properties,v retrieving revision 1.17 diff -u -r1.17 ejb_ui.properties --- property_files/ejb_ui.properties 22 May 2008 15:06:50 -0000 1.17 +++ property_files/ejb_ui.properties 30 Jun 2008 08:22:54 -0000 @@ -58,6 +58,14 @@ LOCAL_BUSINESS_INTERFACE=Local LOCAL_BUSINESS_INTERFACE_LABEL=Local Business Interface: LOCAL_HOME_INTERFACE_LABEL=Local Home Interface: +LOCAL_COMPONENT_INTERFACE_CODE=L +LOCAL_HOME_INTERFACE_CODE=LH +REMOTE_COMPONENT_INTERFACE_CODE=R +REMOTE_HOME_INTERFACE_CODE=RH +LOCAL_COMPONENT_INTERFACE_TOOLTIP=Local Component interface +LOCAL_HOME_INTERFACE_TOOLTIP=Local Home interface +REMOTE_COMPONENT_INTERFACE_TOOLTIP=Remote Component interface +REMOTE_HOME_INTERFACE_TOOLTIP=Remote Home interface EJB_NAME=Bean name: TRANSACTION_TYPE_CONTAINER=Container TRANSACTION_TYPE_BEAN=Bean Index: ejb_ui/org/eclipse/jst/ejb/ui/internal/util/EJBUIMessages.java =================================================================== RCS file: /cvsroot/webtools/ejbtools/plugins/org.eclipse.jst.ejb.ui/ejb_ui/org/eclipse/jst/ejb/ui/internal/util/EJBUIMessages.java,v retrieving revision 1.13 diff -u -r1.13 EJBUIMessages.java --- ejb_ui/org/eclipse/jst/ejb/ui/internal/util/EJBUIMessages.java 22 May 2008 15:06:45 -0000 1.13 +++ ejb_ui/org/eclipse/jst/ejb/ui/internal/util/EJBUIMessages.java 30 Jun 2008 08:22:54 -0000 @@ -96,6 +96,14 @@ public static String MESSAGE_LISTENER_INTERFACE_HYPERLINK; public static String MESSAGE_LISTENER_INTERFACE_HYPERLINK_TOOLTIP; public static String CLICK_TO_SELECT; + public static String LOCAL_COMPONENT_INTERFACE_CODE; + public static String LOCAL_HOME_INTERFACE_CODE; + public static String REMOTE_COMPONENT_INTERFACE_CODE; + public static String REMOTE_HOME_INTERFACE_CODE; + public static String LOCAL_COMPONENT_INTERFACE_TOOLTIP; + public static String LOCAL_HOME_INTERFACE_TOOLTIP; + public static String REMOTE_COMPONENT_INTERFACE_TOOLTIP; + public static String REMOTE_HOME_INTERFACE_TOOLTIP; static {