1 package org.simantics.spreadsheet.ui;
\r
2 /*******************************************************************************
\r
3 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
4 * in Industry THTH ry.
\r
5 * All rights reserved. This program and the accompanying materials
\r
6 * are made available under the terms of the Eclipse Public License v1.0
\r
7 * which accompanies this distribution, and is available at
\r
8 * http://www.eclipse.org/legal/epl-v10.html
\r
11 * VTT Technical Research Centre of Finland - initial API and implementation
\r
12 *******************************************************************************/
\r
13 import org.eclipse.core.commands.AbstractHandler;
\r
14 import org.eclipse.core.commands.ExecutionEvent;
\r
15 import org.eclipse.core.commands.ExecutionException;
\r
16 import org.eclipse.core.runtime.IAdaptable;
\r
17 import org.eclipse.ui.handlers.HandlerUtil;
\r
18 import org.simantics.spreadsheet.CellEditor;
\r
19 import org.simantics.spreadsheet.graph.GraphUI;
\r
20 import org.simantics.spreadsheet.util.SpreadsheetUtils;
\r
23 public class DeleteHandler extends AbstractHandler {
\r
26 public Object execute(ExecutionEvent event) throws ExecutionException {
\r
28 IAdaptable editor = (IAdaptable)HandlerUtil.getActiveEditor(event);
\r
29 if(editor == null) return null;
\r
31 Spreadsheet sheet = (Spreadsheet)editor.getAdapter(Spreadsheet.class);
\r
32 if(sheet == null) return null;
\r
34 int[] cols = sheet.getModel().getTable().getSelectedColumns();
\r
35 int[] rows = sheet.getModel().getTable().getSelectedRows();
\r
37 GraphUI ui = (GraphUI)editor.getAdapter(GraphUI.class);
\r
38 CellEditor ce = (CellEditor)ui.getAdapter(CellEditor.class);
\r
40 for(int row : rows) {
\r
41 for(int col : cols) {
\r
42 ce.edit(null, SpreadsheetUtils.cellName(row, col), null, null);
\r