Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 321701 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.xml (+15 lines)
Lines 224-227 Link Here
224
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
224
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
225
      	</key>
225
      	</key>
226
	</extension>
226
	</extension>
227
 <extension
228
       point="org.eclipse.ui.handlers">
229
    <handler
230
          class="org.eclipse.mylyn.internal.wikitext.tasks.ui.commands.DeleteLineHandler"
231
          commandId="org.eclipse.ui.edit.text.delete.line">
232
         <activeWhen>
233
         	<with variable="activeContexts">
234
	            <iterate operator="or" ifEmpty="false">
235
	               <equals
236
	                     value="org.eclipse.mylyn.wikitext.tasks.ui.markupSourceContext"/>
237
	            </iterate>
238
         	</with>
239
		</activeWhen>
240
    </handler>
241
 </extension>
227
</plugin>
242
</plugin>
(-)src/org/eclipse/mylyn/internal/wikitext/tasks/ui/commands/AbstractDeleteLineHandler.java (+53 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007, 2010 David Green and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     David Green - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.internal.wikitext.tasks.ui.commands;
13
14
import org.eclipse.core.commands.ExecutionEvent;
15
import org.eclipse.core.commands.ExecutionException;
16
import org.eclipse.core.commands.IHandler;
17
import org.eclipse.jface.text.BadLocationException;
18
import org.eclipse.jface.text.ITextSelection;
19
import org.eclipse.jface.text.source.ISourceViewer;
20
import org.eclipse.ui.texteditor.TextViewerDeleteLineTarget;
21
22
/**
23
 * Abstract command handler that uses {@link TextViewerDeleteLineTarget}. Subclasses can specify the type of delete line
24
 * and copyToClipboard.
25
 * 
26
 * @author David Green
27
 */
28
public class AbstractDeleteLineHandler extends AbstractMarkupSourceViewerHandler implements IHandler {
29
	protected final int type;
30
31
	protected final boolean copyToClipboard;
32
33
	protected AbstractDeleteLineHandler(int type, boolean copyToClipboard) {
34
		this.type = type;
35
		this.copyToClipboard = copyToClipboard;
36
	}
37
38
	public Object execute(ExecutionEvent event) throws ExecutionException {
39
		ISourceViewer viewer = getSourceViewer(event);
40
		if (viewer != null) {
41
			TextViewerDeleteLineTarget target = new TextViewerDeleteLineTarget(viewer);
42
43
			try {
44
				target.deleteLine(viewer.getDocument(), (ITextSelection) viewer.getSelectionProvider().getSelection(),
45
						type, copyToClipboard);
46
			} catch (BadLocationException e) {
47
				throw new ExecutionException(e.getMessage(), e);
48
			}
49
		}
50
		return null;
51
	}
52
53
}
(-)src/org/eclipse/mylyn/internal/wikitext/tasks/ui/commands/AbstractMarkupSourceViewerHandler.java (+37 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007, 2010 David Green and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     David Green - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.internal.wikitext.tasks.ui.commands;
13
14
import org.eclipse.core.commands.AbstractHandler;
15
import org.eclipse.core.commands.ExecutionEvent;
16
import org.eclipse.core.commands.ExecutionException;
17
import org.eclipse.jface.text.source.ISourceViewer;
18
import org.eclipse.swt.custom.StyledText;
19
import org.eclipse.ui.handlers.HandlerUtil;
20
21
/**
22
 * Abstract command handler that can get the current source viewer
23
 * 
24
 * @author David Green
25
 */
26
public abstract class AbstractMarkupSourceViewerHandler extends AbstractHandler {
27
28
	protected ISourceViewer getSourceViewer(ExecutionEvent event) throws ExecutionException {
29
		Object activeFocusControl = HandlerUtil.getVariable(event, "activeFocusControl"); //$NON-NLS-1$
30
		if (activeFocusControl instanceof StyledText) {
31
			StyledText textWidget = (StyledText) activeFocusControl;
32
			ISourceViewer viewer = (ISourceViewer) textWidget.getData(ISourceViewer.class.getName());
33
			return viewer;
34
		}
35
		return null;
36
	}
37
}
(-)src/org/eclipse/mylyn/internal/wikitext/tasks/ui/commands/DeleteLineHandler.java (+25 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007, 2010 David Green and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     David Green - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.internal.wikitext.tasks.ui.commands;
13
14
import org.eclipse.ui.texteditor.DeleteLineAction;
15
16
/**
17
 * Command handler for delete line command (whole)
18
 * 
19
 * @author David Green
20
 */
21
public class DeleteLineHandler extends AbstractDeleteLineHandler {
22
	public DeleteLineHandler() {
23
		super(DeleteLineAction.WHOLE, false);
24
	}
25
}

Return to bug 321701