| /******************************************************************************* |
| * Copyright (c) 2001, 2004 IBM Corporation 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: |
| * IBM Corporation - initial API and implementation |
| * Jens Lukowski/Innoopract - initial renaming/restructuring |
| * |
| *******************************************************************************/ |
| package org.eclipse.wst.xml.ui.actions; |
| |
| import java.util.ResourceBundle; |
| |
| import org.eclipse.jface.text.BadLocationException; |
| import org.eclipse.ui.texteditor.ITextEditor; |
| import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException; |
| import org.eclipse.wst.sse.ui.edit.util.StructuredTextEditorActionConstants; |
| import org.eclipse.wst.sse.ui.internal.SSEUIPlugin; |
| import org.eclipse.wst.xml.core.internal.document.CommentImpl; |
| |
| public class RemoveBlockCommentActionXML extends AddBlockCommentActionXML { |
| public RemoveBlockCommentActionXML(ResourceBundle bundle, String prefix, ITextEditor editor) { |
| super(bundle, prefix, editor); |
| } |
| |
| protected void init() { |
| super.init(); |
| |
| fCloseCommentOffset = fSelectionEndIndexedRegion.getEndOffset() - OPEN_COMMENT.length() - CLOSE_COMMENT.length(); |
| } |
| |
| protected void processAction() { |
| fModel.beginRecording(this, SSEUIPlugin.getResourceString(StructuredTextEditorActionConstants.ACTION_NAME_REMOVE_BLOCK_COMMENT + ".tooltip")); //$NON-NLS-1$ |
| fModel.aboutToChangeModel(); |
| |
| if (fSelection.getLength() == 0) { |
| if (fSelectionStartIndexedRegion instanceof CommentImpl) { |
| try { |
| fDocument.replace(fOpenCommentOffset, OPEN_COMMENT.length(), ""); //$NON-NLS-1$ |
| fDocument.replace(fCloseCommentOffset, CLOSE_COMMENT.length(), ""); //$NON-NLS-1$ |
| } catch (BadLocationException e) { |
| throw new SourceEditingRuntimeException(); |
| } |
| } |
| } else { |
| if (fSelectionStartIndexedRegion instanceof CommentImpl) { |
| try { |
| fDocument.replace(fOpenCommentOffset, OPEN_COMMENT.length(), ""); //$NON-NLS-1$ |
| } catch (BadLocationException e) { |
| throw new SourceEditingRuntimeException(); |
| } |
| } |
| |
| if (fSelectionEndIndexedRegion instanceof CommentImpl) { |
| try { |
| fDocument.replace(fCloseCommentOffset, CLOSE_COMMENT.length(), ""); //$NON-NLS-1$ |
| } catch (BadLocationException e) { |
| throw new SourceEditingRuntimeException(); |
| } |
| } |
| } |
| removeOpenCloseComments(fOpenCommentOffset + OPEN_COMMENT.length(), fCloseCommentOffset - fOpenCommentOffset - CLOSE_COMMENT.length()); |
| |
| fModel.changedModel(); |
| fModel.endRecording(this); |
| } |
| } |