Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Overholt2010-05-27 19:25:57 +0000
committerAndrew Overholt2010-05-27 19:25:57 +0000
commitc2b663300212785c0cc065fdb262b594d2da45fb (patch)
treee4d8d069c37ff1124505b2670d81aed30d6e68ff /rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/rpm/ui/editor/parser/SpecfileSection.java
parentbf2f337fa5eb403d3a0b377bcc91ab2c6ad3b096 (diff)
downloadorg.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.java84
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
+
+ }
+
+}

Back to the top