use of org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfilePackage in project linuxtools by eclipse.
the class SpecStructureCreator method parseSpecfile.
private void parseSpecfile(DocumentRangeNode root, IDocument doc, IFile file) {
SpecfileParser parser = new SpecfileParser();
// FIXME: error markers do not show
if (file != null) {
FileEditorInput fei = new FileEditorInput(file);
// without it, the compare editor is blank
try {
SpecfileEditor.getSpecfileDocumentProvider().disconnect(fei);
SpecfileEditor.getSpecfileDocumentProvider().connect(fei);
} catch (CoreException e) {
SpecfileLog.logError(e);
}
parser.setErrorHandler(new SpecfileErrorHandler(fei, doc));
parser.setTaskHandler(new SpecfileTaskHandler(fei, doc));
Specfile specfile = parser.parse(doc);
String id = specfile.getName();
// Be a child under parent node of specfileSectionRoot (would be
// rootNode)
SpecNode fileNode = new SpecNode((DocumentRangeNode) root.getParentNode(), 1, id, doc, 0, doc.getLength());
for (SpecfileSection sec : specfile.getSections()) {
try {
addNode(root, doc, sec.getName(), doc.getLineOffset(sec.getLineNumber()), doc.getLineOffset(sec.getSectionEndLine()) - doc.getLineOffset(sec.getLineNumber()), 2);
} catch (BadLocationException e) {
SpecfileLog.logError(e);
}
}
// Be a child under the parent file node
for (SpecfilePackage sPackage : specfile.getPackages().getPackages()) {
try {
SpecNode pNode = addNode(fileNode, doc, sPackage.getPackageName(), doc.getLineOffset(sPackage.getLineNumber()), doc.getLineOffset(sPackage.getSectionEndLine()) - doc.getLineOffset(sPackage.getLineNumber()), 3);
for (SpecfileSection section : sPackage.getSections()) {
addNode(pNode, doc, section.getName(), doc.getLineOffset(section.getLineNumber()), doc.getLineOffset(section.getSectionEndLine()) - doc.getLineOffset(section.getLineNumber()), 4);
}
} catch (BadLocationException e) {
SpecfileLog.logError(e);
}
}
}
}
use of org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfilePackage in project linuxtools by eclipse.
the class MainPackagePage method createFormContent.
@Override
protected void createFormContent(IManagedForm managedForm) {
super.createFormContent(managedForm);
FormToolkit toolkit = managedForm.getToolkit();
ScrolledForm form = managedForm.getForm();
form.setText(Messages.MainPackagePage_2);
GridLayout layout = new GridLayout();
layout.marginWidth = layout.marginHeight = 5;
layout.numColumns = 2;
RowLayout rowLayout = new RowLayout();
rowLayout.type = SWT.VERTICAL;
rowLayout.justify = true;
rowLayout.fill = true;
form.getBody().setLayout(rowLayout);
form.getBody().setLayoutData(rowLayout);
layout.numColumns = 2;
GridData gd = new GridData();
gd.horizontalSpan = 2;
gd.horizontalAlignment = SWT.FILL;
final Section mainPackageSection = toolkit.createSection(form.getBody(), ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
mainPackageSection.setText(Messages.MainPackagePage_3);
mainPackageSection.setLayout(new GridLayout());
Composite mainPackageClient = toolkit.createComposite(mainPackageSection);
GridLayout gridLayout = new GridLayout();
gridLayout.marginWidth = gridLayout.marginHeight = 5;
gridLayout.numColumns = 2;
mainPackageClient.setLayout(gridLayout);
new RpmTagText(mainPackageClient, RpmTags.NAME, specfile);
new RpmTagText(mainPackageClient, RpmTags.VERSION, specfile);
new RpmTagText(mainPackageClient, RpmTags.RELEASE, specfile);
new RpmTagText(mainPackageClient, RpmTags.URL, specfile);
new RpmTagText(mainPackageClient, RpmTags.LICENSE, specfile);
new RpmTagText(mainPackageClient, RpmTags.GROUP, specfile);
new RpmTagText(mainPackageClient, RpmTags.EPOCH, specfile);
new RpmTagText(mainPackageClient, RpmTags.BUILD_ROOT, specfile);
new RpmTagText(mainPackageClient, RpmTags.BUILD_ARCH, specfile);
new RpmTagText(mainPackageClient, RpmTags.SUMMARY, specfile, SWT.MULTI);
// BuildRequires
final Section buildRequiresSection = toolkit.createSection(mainPackageClient, ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
buildRequiresSection.setText(Messages.MainPackagePage_4);
buildRequiresSection.setLayout(rowLayout);
buildRequiresSection.setExpanded(false);
Composite buildRequiresClient = toolkit.createComposite(buildRequiresSection);
buildRequiresClient.setLayout(gridLayout);
for (SpecfileTag buildRequire : specfile.getBuildRequires()) {
new RpmTagText(buildRequiresClient, buildRequire, specfile);
}
buildRequiresSection.setClient(buildRequiresClient);
toolkit.paintBordersFor(buildRequiresClient);
toolkit.paintBordersFor(buildRequiresSection);
// Requires
final Section requiresSection = toolkit.createSection(mainPackageClient, ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
requiresSection.setText(Messages.MainPackagePage_5);
requiresSection.setLayout(rowLayout);
requiresSection.setExpanded(false);
Composite requiresClient = toolkit.createComposite(requiresSection);
requiresClient.setLayout(gridLayout);
requiresClient.setLayoutData(gd);
for (SpecfileTag require : specfile.getRequires()) {
new RpmTagText(requiresClient, require, specfile);
}
requiresSection.setClient(requiresClient);
toolkit.paintBordersFor(requiresClient);
toolkit.paintBordersFor(requiresSection);
mainPackageSection.setClient(mainPackageClient);
toolkit.paintBordersFor(mainPackageClient);
toolkit.paintBordersFor(mainPackageSection);
// subpackages
final Section packagesSection = toolkit.createSection(form.getBody(), ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
packagesSection.setText(Messages.MainPackagePage_6);
packagesSection.setLayout(gridLayout);
Composite packagesClient = toolkit.createComposite(packagesSection);
packagesClient.setLayout(gridLayout);
packagesClient.setLayoutData(gd);
for (SpecfilePackage specfilePackage : specfile.getPackages().getPackages()) {
if (specfilePackage.isMainPackage()) {
continue;
}
final Section packageSection = toolkit.createSection(packagesClient, ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
packageSection.setText(specfilePackage.getFullPackageName());
packageSection.setExpanded(false);
packageSection.setLayout(rowLayout);
Composite packageClient = toolkit.createComposite(packageSection);
packageClient.setLayout(gridLayout);
packageClient.setLayoutData(gd);
new RpmTagText(packageClient, RpmTags.SUMMARY, specfile, specfilePackage, SWT.MULTI);
new RpmTagText(packageClient, RpmTags.GROUP, specfile, specfilePackage, SWT.MULTI);
final Section packageRequiresSection = toolkit.createSection(packageClient, ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
packageRequiresSection.setText(Messages.MainPackagePage_7);
packageRequiresSection.setLayout(rowLayout);
packageRequiresSection.setLayoutData(gd);
Composite packageRequiresClient = toolkit.createComposite(packageRequiresSection);
packageRequiresClient.setLayout(gridLayout);
packageRequiresClient.setLayoutData(gd);
for (SpecfileTag require : specfilePackage.getRequires()) {
new RpmTagText(packageRequiresClient, require, specfile);
}
packageRequiresSection.setClient(packageRequiresClient);
toolkit.paintBordersFor(packageRequiresClient);
toolkit.paintBordersFor(packageRequiresSection);
packageSection.setClient(packageClient);
toolkit.paintBordersFor(packageClient);
toolkit.paintBordersFor(packageSection);
}
packagesSection.setClient(packagesClient);
toolkit.paintBordersFor(packagesClient);
toolkit.paintBordersFor(packagesSection);
managedForm.refresh();
}
use of org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfilePackage in project linuxtools by eclipse.
the class SpecfileLabelProvider method getText.
@Override
public String getText(Object element) {
// $NON-NLS-1$
String str = "";
if (element instanceof SpecfileSection) {
SpecfileSection specfileSection = (SpecfileSection) element;
str = specfileSection.toString();
} else if (element instanceof Specfile) {
str = ((Specfile) element).getName();
} else if (element instanceof SpecfilePackageContainer) {
str = Messages.SpecfileLabelProvider_0;
} else if (element instanceof SpecfilePreamble) {
str = Messages.SpecfileLabelProvider_1;
} else if (element instanceof SpecfileElement) {
SpecfileElement specfileElement = (SpecfileElement) element;
str = specfileElement.getName();
} else if (element instanceof String) {
str = (String) element;
} else if (element instanceof SpecfilePackage) {
str = ((SpecfilePackage) element).getName();
}
return filterMacros(str.trim());
}
Aggregations