Class AbstractTemplatePreferencePage

  • All Implemented Interfaces:
    org.eclipse.jface.dialogs.IDialogPage, org.eclipse.jface.dialogs.IMessageProvider, org.eclipse.jface.preference.IPreferencePage, org.eclipse.ui.IWorkbenchPreferencePage
    Direct Known Subclasses:
    BslTemplatePreferencePage

    public abstract class AbstractTemplatePreferencePage
    extends org.eclipse.jface.preference.PreferencePage
    implements org.eclipse.ui.IWorkbenchPreferencePage
    Abstract implementation of Preference page for templates to have the same main page
    • Field Detail

      • templateStorageSnapshot

        protected String templateStorageSnapshot
      • templatesTableViewer

        protected TableViewer templatesTableViewer
      • currentSearchText

        protected String currentSearchText
    • Constructor Detail

      • AbstractTemplatePreferencePage

        public AbstractTemplatePreferencePage()
    • Method Detail

      • init

        public void init​(org.eclipse.ui.IWorkbench workbench)
        Specified by:
        init in interface org.eclipse.ui.IWorkbenchPreferencePage
      • performOk

        public boolean performOk()
        Specified by:
        performOk in interface org.eclipse.jface.preference.IPreferencePage
        Overrides:
        performOk in class org.eclipse.jface.preference.PreferencePage
      • performCancel

        public boolean performCancel()
        Specified by:
        performCancel in interface org.eclipse.jface.preference.IPreferencePage
        Overrides:
        performCancel in class org.eclipse.jface.preference.PreferencePage
      • createContents

        protected org.eclipse.swt.widgets.Control createContents​(org.eclipse.swt.widgets.Composite parent)
        Specified by:
        createContents in class org.eclipse.jface.preference.PreferencePage
      • handleImport

        protected void handleImport()
        Handles import button selection
      • handleAdd

        protected void handleAdd()
        Handles add button selection. Delegates creating new template to doAdd()
      • handleRemove

        protected void handleRemove()
        Handles remove button selection
      • handleEdit

        protected void handleEdit()
        Handles edit button selection. Delegates editing template to doEdit(ITemplate)
      • handleExport

        protected void handleExport()
        Handle export button selection. Exports templates from file.
      • handleSelection

        protected void handleSelection()
        Handles table selection changed
      • doEdit

        protected abstract boolean doEdit​(ITemplate template)
        Edits the given template
        Parameters:
        template - The template to edit, cannot be null
        Returns:
        Whether editing was completed
      • doAdd

        protected abstract ITemplate doAdd()
        Creates new template and returns it
        Returns:
        The newly created template, can be null when adding is canceled
      • adjustPreviewField

        protected void adjustPreviewField()
        Adjusts pattern's text to the selected template's
      • adjustPatternPreview

        protected void adjustPatternPreview​(org.eclipse.swt.custom.StyledText patternPreview,
                                            ITemplate template)
        Adjusts the preview of the pattern text field with given template
        Parameters:
        patternPreview - The pattern preview text field to adjust, cannot be null
        template - The template to adjust to, can be null
      • adjustDescriptionPreview

        protected void adjustDescriptionPreview​(org.eclipse.swt.custom.StyledText descriptionPreview,
                                                ITemplate template)
        Adjusts the preview of the description text field with given template
        Parameters:
        descriptionPreview - The description preview text field to adjust, cannot be null
        template - The template to adjust to, can be null
      • getTemplateColumnSelectionAdapter

        protected org.eclipse.swt.events.SelectionAdapter getTemplateColumnSelectionAdapter​(org.eclipse.swt.widgets.TableColumn tableColumn,
                                                                                            int columnIndex,
                                                                                            AbstractTemplatePreferencePage.TemplateViewerComparator viewerComparator,
                                                                                            TableViewer tableViewer)
        Returns new SelectionAdapter for tableColumn with given parameters
        Parameters:
        tableColumn - The tableColumn for this adapter, cannot be null
        columnIndex - The index of the column
        viewerComparator - The viewerComparator for this SelectiionAdapter, cannot be null
        tableViewer - The tableViewer of table, cannot be null
        Returns:
        The newly created SelectionAdapter, cannot be null
      • createTable

        protected final TableViewer createTable​(org.eclipse.swt.widgets.Composite parent,
                                                AbstractTemplatePreferencePage.TemplateViewerComparator viewerComparator)
        Creates table on the given composite with given viwerComparator
        Parameters:
        parent - The composite parent, cannot be null
        viewerComparator - The viewer comparator for this table, cannot be null
        Returns:
        The TableViewer of created table, cannot be null
      • getTemplateContextPresentation

        protected abstract String getTemplateContextPresentation​(ITemplateContext templateContext)
        Returns presentation of context of given templateContext. It shall be human-readable description on which context this template supports
        Parameters:
        templateContext - The templateContext to get presentation, cannot be null
        Returns:
        The presentation of the templateContext, cannot be null
      • setNewTemplateStorageManager

        protected void setNewTemplateStorageManager​(TemplateStorageManager manager)
        Changes TemplateStorageManager to given one
        Parameters:
        manager - The manager to set, cannot be null
      • isAccebtableTemplate

        protected boolean isAccebtableTemplate​(ITemplate template,
                                               String entry)
        Checks if given template shall be shown with given search entry
        Parameters:
        template - The template to check, cannot be null
        entry - The search entry, cannot be null
        Returns:
        Whether given template shall be shown with given entry