use of org.eclipse.jface.text.templates.persistence.TemplatePersistenceData in project eclipse.platform.text by eclipse.
the class TemplatePreferencePage method add.
private void add() {
Iterator<TemplateContextType> it = fContextTypeRegistry.contextTypes();
if (it.hasNext()) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Template template = new Template("", "", it.next().getId(), "", true);
Template newTemplate = editTemplate(template, false, true);
if (newTemplate != null) {
TemplatePersistenceData data = new TemplatePersistenceData(newTemplate, true);
fTemplateStore.add(data);
fTableViewer.refresh();
fTableViewer.setChecked(data, true);
fTableViewer.setSelection(new StructuredSelection(data));
}
}
}
use of org.eclipse.jface.text.templates.persistence.TemplatePersistenceData in project eclipse.platform.text by eclipse.
the class TemplatePreferencePage method export.
private void export() {
IStructuredSelection selection = (IStructuredSelection) fTableViewer.getSelection();
Object[] templates = selection.toArray();
TemplatePersistenceData[] datas = new TemplatePersistenceData[templates.length];
for (int i = 0; i != templates.length; i++) datas[i] = (TemplatePersistenceData) templates[i];
export(datas);
}
use of org.eclipse.jface.text.templates.persistence.TemplatePersistenceData in project eclipse.platform.text by eclipse.
the class TemplatePreferencePage method revert.
private void revert() {
IStructuredSelection selection = (IStructuredSelection) fTableViewer.getSelection();
Iterator<?> elements = selection.iterator();
while (elements.hasNext()) {
TemplatePersistenceData data = (TemplatePersistenceData) elements.next();
data.revert();
fTableViewer.setChecked(data, data.isEnabled());
}
selectionChanged1();
fTableViewer.refresh();
}
use of org.eclipse.jface.text.templates.persistence.TemplatePersistenceData in project eclipse.platform.text by eclipse.
the class TemplatePreferencePage method remove.
private void remove() {
IStructuredSelection selection = (IStructuredSelection) fTableViewer.getSelection();
Iterator<?> elements = selection.iterator();
while (elements.hasNext()) {
TemplatePersistenceData data = (TemplatePersistenceData) elements.next();
fTemplateStore.delete(data);
}
fTableViewer.refresh();
}
use of org.eclipse.jface.text.templates.persistence.TemplatePersistenceData in project erlide_eclipse by erlang.
the class ErlideContributionTemplateStore method readIncludedTemplates.
private void readIncludedTemplates(final Collection<TemplatePersistenceData> templates, final String[] files) {
for (final String file : files) {
if (file != null) {
try (final InputStream input = new FileInputStream(new File(file));
InputStream stream = new BufferedInputStream(input)) {
final TemplateReaderWriter reader = new TemplateReaderWriter();
final TemplatePersistenceData[] datas = reader.read(stream, null);
for (final TemplatePersistenceData data : datas) {
if (validateTemplate(data.getTemplate())) {
templates.add(data);
}
}
} catch (final IOException x) {
}
}
}
}
Aggregations