use of org.antlr.v4.runtime.tree.ParseTree in project titan.EclipsePlug-ins by eclipse.
the class ModuleParameterSectionPage method createNewModuleParameterSection.
private void createNewModuleParameterSection() {
if (moduleParametersHandler == null) {
return;
}
ParserRuleContext sectionRoot = new ParserRuleContext();
moduleParametersHandler.setLastSectionRoot(sectionRoot);
ParseTree header = new AddedParseTree("\n[MODULE_PARAMETERS]");
ConfigTreeNodeUtilities.addChild(sectionRoot, header);
ParserRuleContext root = editor.getParseTreeRoot();
if (root != null) {
root.addChild(sectionRoot);
}
}
use of org.antlr.v4.runtime.tree.ParseTree in project titan.EclipsePlug-ins by eclipse.
the class IncludeSectionDropTargetListener method drop.
@Override
public void drop(final DropTargetEvent event) {
if (IncludeItemTransfer.getInstance().isSupportedType(event.currentDataType)) {
if (event.item != null && viewer.getInput() != null) {
IncludeSectionHandler includeSectionHandler = (IncludeSectionHandler) viewer.getInput();
ParseTree element = (ParseTree) event.item.getData();
ParseTree[] items = (ParseTree[]) event.data;
int baseindex = includeSectionHandler.getFiles().indexOf(element);
final ParseTree parent = includeSectionHandler.getLastSectionRoot();
ConfigTreeNodeUtilities.removeChild(parent, element);
ConfigTreeNodeUtilities.addChild(parent, element, baseindex);
if (items.length > 0) {
for (int i = 0; i < items.length - 1; i++) {
includeSectionHandler.getFiles().add(++baseindex, items[i]);
}
includeSectionHandler.getFiles().add(++baseindex, items[items.length - 1]);
}
viewer.refresh(true);
editor.setDirty();
}
}
}
use of org.antlr.v4.runtime.tree.ParseTree in project titan.EclipsePlug-ins by eclipse.
the class IncludeSubPage method createIncludeSection.
void createIncludeSection(final Composite parent, final ScrolledForm form, final FormToolkit toolkit) {
Section section = toolkit.createSection(parent, ExpandableComposite.TWISTIE | Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
section.setActiveToggleColor(toolkit.getHyperlinkGroup().getActiveForeground());
section.setToggleColor(toolkit.getColors().getColor(IFormColors.SEPARATOR));
Composite client = toolkit.createComposite(section, SWT.WRAP);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
client.setLayout(layout);
toolkit.paintBordersFor(client);
includeElementsTable = toolkit.createTable(client, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
includeElementsTable.setEnabled(includeSectionHandler != null);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 100;
gd.heightHint = 200;
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
gd.verticalAlignment = SWT.FILL;
includeElementsTable.setLayoutData(gd);
TableColumn column = new TableColumn(includeElementsTable, SWT.LEFT, 0);
column.setText("File name");
column.setMoveable(false);
column.setWidth(100);
includeElementsTable.setLinesVisible(true);
includeElementsTable.setHeaderVisible(true);
Composite buttons = toolkit.createComposite(client);
buttons.setLayout(new GridLayout());
buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.GRAB_VERTICAL));
add = toolkit.createButton(buttons, "Add...", SWT.PUSH);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
add.setEnabled(includeSectionHandler != null);
add.setLayoutData(gd);
add.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
if (includeSectionHandler == null) {
return;
}
if (includeSectionHandler.getLastSectionRoot() == null) {
createNewIncludeSection();
}
ParseTree newItem = createNewIncludeItem();
if (newItem == null) {
return;
}
ParseTree root = includeSectionHandler.getLastSectionRoot();
// a new line before every item
ConfigTreeNodeUtilities.addChild(root, ConfigTreeNodeUtilities.createHiddenTokenNode("\n"));
ConfigTreeNodeUtilities.addChild(root, newItem);
includeSectionHandler.getFiles().add(newItem);
internalRefresh();
includeElementsTable.select(includeSectionHandler.getFiles().size() - 1);
includeElementsTable.showSelection();
editor.setDirty();
}
});
remove = toolkit.createButton(buttons, "Remove", SWT.PUSH);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
remove.setLayoutData(gd);
remove.setEnabled(includeSectionHandler != null);
remove.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
if (includeElementsTableViewer == null || includeSectionHandler == null) {
return;
}
removeSelectedIncludeItems();
if (includeSectionHandler.getFiles().isEmpty()) {
removeIncludeSection();
}
internalRefresh();
editor.setDirty();
}
});
totalIncludeElementsLabel = toolkit.createLabel(buttons, "Total: 0");
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
totalIncludeElementsLabel.setLayoutData(gd);
section.setText("Included configurations");
section.setDescription("Specify the list of included configuration files for this configuration.");
section.setClient(client);
section.setExpanded(true);
section.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(final ExpansionEvent e) {
form.reflow(false);
}
});
gd = new GridData(GridData.FILL_HORIZONTAL);
section.setLayoutData(gd);
includeElementsTableViewer = new TableViewer(includeElementsTable);
includeElementsTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
// not needed this time
}
});
includeElementsTableViewer.setContentProvider(new IncludeDataContentProvider());
includeElementsTableViewer.setLabelProvider(new IncludeDataLabelProvider());
includeElementsTableViewer.setInput(includeSectionHandler);
includeElementsTableViewer.setColumnProperties(new String[] { "file_name" });
includeElementsTableViewer.setCellEditors(new TextCellEditor[] { new TextCellEditor(includeElementsTable) });
includeElementsTableViewer.setCellModifier(new ICellModifier() {
@Override
public boolean canModify(final Object element, final String property) {
return true;
}
@Override
public String getValue(final Object element, final String property) {
IncludeDataLabelProvider labelProvider = (IncludeDataLabelProvider) includeElementsTableViewer.getLabelProvider();
return labelProvider.getColumnText(element, 0);
}
@Override
public void modify(final Object element, final String property, final Object value) {
if (element != null && element instanceof TableItem && value instanceof String) {
ParseTree item = (ParseTree) ((TableItem) element).getData();
ConfigTreeNodeUtilities.setText(item, (String) value);
includeElementsTableViewer.refresh(item);
editor.setDirty();
}
}
});
includeElementsTableViewer.addDragSupport(DND.DROP_COPY | DND.DROP_MOVE, new Transfer[] { IncludeItemTransfer.getInstance() }, new IncludeSectionDragSourceListener(this, includeElementsTableViewer));
includeElementsTableViewer.addDropSupport(DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_DEFAULT, new Transfer[] { IncludeItemTransfer.getInstance() }, new IncludeSectionDropTargetListener(includeElementsTableViewer, editor));
internalRefresh();
}
use of org.antlr.v4.runtime.tree.ParseTree in project titan.EclipsePlug-ins by eclipse.
the class LoggingBitsSubPage method createConsoleMaskRootNode.
private void createConsoleMaskRootNode(final LoggingSectionHandler.LoggerTreeElement lte, final LogParamEntry logentry) {
ParseTree consoleMaskRoot = new ParserRuleContext();
logentry.setConsoleMaskRoot(consoleMaskRoot);
ConfigTreeNodeUtilities.addChild(consoleMaskRoot, new AddedParseTree("\n"));
StringBuilder name = new StringBuilder();
lte.writeNamePrefix(name);
name.append("ConsoleMask := ");
ParseTree node = new AddedParseTree(name.toString());
ConfigTreeNodeUtilities.addChild(consoleMaskRoot, node);
ParseTree consoleMask = new ParserRuleContext();
logentry.setConsoleMask(consoleMask);
ConfigTreeNodeUtilities.addChild(consoleMaskRoot, consoleMask);
ConfigTreeNodeUtilities.addChild(loggingSectionHandler.getLastSectionRoot(), consoleMaskRoot);
}
use of org.antlr.v4.runtime.tree.ParseTree in project titan.EclipsePlug-ins by eclipse.
the class LoggingBitsSubPage method removeLoggingBit.
private void removeLoggingBit(final Map<LoggingBit, ParseTree> aBitMask, final ParseTree aBitmaskRoot, final LoggingBit aBit) {
final ParseTree removedBit = aBitMask.remove(aBit);
ConfigTreeNodeUtilities.removeChildWithSeparator(aBitmaskRoot, removedBit);
}
Aggregations