blob: 1dd505cedbb04215fae7d062bd16abd3ab5c675a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
//------------------------------------------------------------------------------
// Copyright (c) 2009 Anyware Technologies and others
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// which accompanies this distribution, and is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// Contributors:
// Anyware Technologies - initial API and implementation
//------------------------------------------------------------------------------
package org.eclipse.papyrus.views.documentation.view.actions;
import org.eclipse.epf.richtext.IRichText;
import org.eclipse.epf.richtext.actions.RichTextAction;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.papyrus.views.documentation.view.DocViewPlugin;
import org.eclipse.papyrus.views.documentation.view.Messages;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
/**
* Insert a row to the selected table in the rich text control.
*
* @author Jose Alfredo Serrano (Anyware Technologies)
* @author Jacques LESCOT (Anyware Technologies)
*/
public class InsertTableRowAction extends RichTextAction {
/**
* Creates a new instance.
*/
public InsertTableRowAction(IRichText richText) {
super(richText, IAction.AS_PUSH_BUTTON);
setImageDescriptor(DocViewPlugin.getDefault().getImageRegistry().getDescriptor("INSERT_ROW")); //$NON-NLS-1$
setToolTipText(Messages.InsertTableRowAction_title);
}
/**
* Executes the action.
*
* @param richText
* a rich text control
*/
public void execute(IRichText richText) {
if (richText != null) {
Shell parent = Display.getCurrent().getActiveShell();
InputDialog dialog = new InputDialog(parent, "Insert Row", Messages.InsertTableRowAction_text, "0", new NumberValidator()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
if (dialog.open() == Window.OK) {
richText.executeCommand(CommandConstants.INSERT_TABLE_ROW, dialog.getValue());
}
}
}
}
|