Révision 854

tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 854)
28 28
import org.eclipse.swt.SWT;
29 29
import org.eclipse.swt.events.MouseAdapter;
30 30
import org.eclipse.swt.events.MouseEvent;
31
import org.eclipse.swt.graphics.Point;
31 32
import org.eclipse.swt.layout.GridData;
32 33
import org.eclipse.swt.layout.GridLayout;
33 34
import org.eclipse.swt.layout.RowLayout;
......
1165 1166
	}
1166 1167

  
1167 1168
	/**
1168
	 * Adds a mouse adapter to the specified table that executes a command link specified by its id on double click event.
1169
	 * Adds a mouse adapter to the specified table column  that executes a command link specified by its id on double click event.
1169 1170
	 * @param table
1171
	 * @param column column index >= 0; if == -1, the parameter is ignored
1170 1172
	 * @param commandId
1171 1173
	 */
1172
	public static void addDoubleClickCommandListener(Table table, final String commandId, final String targetCommandId)	{
1174
	public static void addDoubleClickCommandListener(final Table table, final int column, final String commandId, final String targetCommandId)	{
1175
		
1173 1176
		table.addMouseListener(new MouseAdapter() {
1174 1177
			@Override
1175 1178
			public void mouseDoubleClick(MouseEvent e) {
1179
				Point mouseposition = new Point(e.x
1180
						+ table.getHorizontalBar()
1181
						.getSelection(), e.y);
1182
				if (column >0 && column != getPointedColumn(table, mouseposition)) {
1183
					return;
1184
				}
1185
				
1176 1186
				BaseAbstractHandler.executeCommand(commandId, Collections.singletonMap("sendToTargetCommandId", targetCommandId)); //$NON-NLS-1$
1177 1187
			}
1178 1188
		});
1179 1189
	}
1190
	
1191
	/**
1192
	 * Gets the pointed column.
1193
	 *
1194
	 * @param mouseposition the mouseposition
1195
	 * @return the pointed column
1196
	 */
1197
	public static int getPointedColumn(Table table, Point mouseposition) {
1198
		int x = mouseposition.x; // + lineTableViewer.getTable().get;
1199
		int sumWidthColumn = 0;
1200
		for (int i = 0 ; i < table.getColumnCount() ; i++) {
1201
			TableColumn col = table.getColumn(i);
1202
			sumWidthColumn += col.getWidth();
1203
			if (x < sumWidthColumn)
1204
				return i;
1205
		}
1206
		
1207
		return -1;
1208
	}
1180 1209

  
1210
	
1181 1211
	/**
1212
	 * Adds a mouse adapter to the specified composite that executes a command link specified by its id on double click event.
1213
	 * @param table
1214
	 * @param commandId
1215
	 */
1216
	public static void addDoubleClickCommandListener(Composite composite, final String commandId, final String targetCommandId)	{
1217
		composite.addMouseListener(new MouseAdapter() {
1218
			@Override
1219
			public void mouseDoubleClick(MouseEvent e) {
1220
				BaseAbstractHandler.executeCommand(commandId, Collections.singletonMap("sendToTargetCommandId", targetCommandId)); //$NON-NLS-1$
1221
			}
1222
		});
1223
	}
1224

  
1225
	/**
1182 1226
	 * @return the lastComputingParameters
1183 1227
	 */
1184 1228
	public HashMap<String, Object> getLastComputingParameters() {

Formats disponibles : Unified diff