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