Skip to main content
summaryrefslogtreecommitdiffstats
blob: 4363916ba6704bbf3188b9a00fecd452861cd74d (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
/*******************************************************************************
 * Copyright (c) 2006 Sybase, Inc. 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:
 *     Sybase, Inc. - initial API and implementation
 *******************************************************************************/
package org.eclipse.jst.pagedesigner.dnd.internal;

import org.eclipse.jst.pagedesigner.commands.SourceViewerCommand;
import org.eclipse.jst.pagedesigner.editors.pagedesigner.PageDesignerResources;
import org.eclipse.wst.sse.ui.StructuredTextEditor;

/**
 * @author mengbo
 */
public class SourceViewLocalDropCommand extends SourceViewerCommand {
	/**
	 * the map from feedback to ILocalDropHandler
	 */
	private int _location;

	private StructuredTextEditor _textEditor;

	private Object _data;

	/**
	 * 
	 */
	public SourceViewLocalDropCommand(StructuredTextEditor textEditor,
			Object data, int location) {
		super(PageDesignerResources.getInstance().getString(
				"SourceViewLocalDropCommand.Label.InsertSyntax"), textEditor); //$NON-NLS-1$
		_textEditor = textEditor;
		_data = data;
		_location = location;
	}

	public void doExecute() {
		_textEditor.getTextViewer().getTextWidget().insert((String) _data);
	}

	public void setSelection() {
		_textEditor.getTextViewer().setSelectedRange(_location,
				((String) _data).length());
	}
}

Back to the top