diff options
author | Andrew Overholt | 2010-05-27 19:25:57 +0000 |
---|---|---|
committer | Andrew Overholt | 2010-05-27 19:25:57 +0000 |
commit | c2b663300212785c0cc065fdb262b594d2da45fb (patch) | |
tree | e4d8d069c37ff1124505b2670d81aed30d6e68ff /rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/rpm/ui/editor/parser/SpecfileSection.java | |
parent | bf2f337fa5eb403d3a0b377bcc91ab2c6ad3b096 (diff) | |
download | org.eclipse.linuxtools-c2b663300212785c0cc065fdb262b594d2da45fb.tar.gz org.eclipse.linuxtools-c2b663300212785c0cc065fdb262b594d2da45fb.tar.xz org.eclipse.linuxtools-c2b663300212785c0cc065fdb262b594d2da45fb.zip |
Branch for RCP app. modifications.
Diffstat (limited to 'rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/rpm/ui/editor/parser/SpecfileSection.java')
-rw-r--r-- | rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/rpm/ui/editor/parser/SpecfileSection.java | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/rpm/ui/editor/parser/SpecfileSection.java b/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/rpm/ui/editor/parser/SpecfileSection.java new file mode 100644 index 0000000000..49de0e91bd --- /dev/null +++ b/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/rpm/ui/editor/parser/SpecfileSection.java @@ -0,0 +1,84 @@ +/******************************************************************************* + * Copyright (c) 2007, 2009 Red Hat, Inc. + * 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: + * Red Hat - initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.rpm.ui.editor.parser; + +import java.text.MessageFormat; + +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; + +public class SpecfileSection extends SpecfileElement { + + private SpecfilePackage parentPackage; + private int sectionEndLine; + + public SpecfileSection(String name, Specfile specfile) { + super(name); + parentPackage = null; + super.setSpecfile(specfile); + } + + public SpecfilePackage getPackage() { + return parentPackage; + } + + public void setPackage(SpecfilePackage thePackage) { + this.parentPackage = thePackage; + } + + @Override + public String toString() { + if (parentPackage == null) { + return getName(); + } else { + return MessageFormat.format("{0} {1}", getName(), parentPackage); //$NON-NLS-1$ + } + } + + public String getPackageName() { + return parentPackage.getPackageName(); + } + + /** + * @param sectionEnd + * the sectionEnd to set + */ + public void setSectionEndLine(int sectionEnd) { + this.sectionEndLine = sectionEnd; + } + + /** + * @return the sectionEnd + */ + public int getSectionEndLine() { + return sectionEndLine; + } + + public String getContents() { + IDocument document = getSpecfile().getDocument(); + int beginning = getLineStartPosition(); + try { + int end = document.getLineOffset(getSectionEndLine()); + return document.get(beginning, end-beginning); + } catch (BadLocationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return ""; //$NON-NLS-1$ + } + + public void setContents(String newContent) { + // TODO Modify document to change the contents + + } + +} |