Search in sources :

Example 1 with FastPartitioner

use of org.eclipse.jface.text.rules.FastPartitioner in project KaiZen-OpenAPI-Editor by RepreZen.

the class JsonDocumentProvider method createDocument.

@Override
protected IDocument createDocument(Object element) throws CoreException {
    IDocument document = super.createDocument(element);
    if (document != null) {
        JsonScanner scanner = new JsonScanner(new ColorManager(), store);
        Set<String> tokens = YAMLToken.VALID_TOKENS.keySet();
        FastPartitioner partitioner = new FastPartitioner(scanner, tokens.toArray(new String[tokens.size()]));
        document.setDocumentPartitioner(partitioner);
        partitioner.connect(document);
    }
    return document;
}
Also used : FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner) ColorManager(org.dadacoalition.yedit.editor.ColorManager) IDocument(org.eclipse.jface.text.IDocument)

Example 2 with FastPartitioner

use of org.eclipse.jface.text.rules.FastPartitioner in project cubrid-manager by CUBRID.

the class SQLEditorComposite method createSQLEditor.

/**
	 * Create the SQL editor
	 */
private void createSQLEditor() {
    final Composite composite = new Composite(this, SWT.NONE);
    composite.setLayout(new FillLayout());
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    CompositeRuler ruler = new CompositeRuler();
    LineNumberRulerColumn lineCol = new LineNumberRulerColumn();
    lineCol.setBackground(ResourceManager.getColor(new RGB(236, 233, 216)));
    ruler.addDecorator(0, lineCol);
    sqlTextViewer = new SQLTextViewer(composite, ruler, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, queryEditor);
    viewerConfig = new SQLViewerConfiguration(queryEditor);
    sqlTextViewer.configure(viewerConfig);
    document = new SQLDocument();
    IDocumentPartitioner partitioner = new FastPartitioner(new SQLPartitionScanner(), SQLPartitionScanner.getAllTypes());
    document.setDocumentPartitioner(ISQLPartitions.SQL_PARTITIONING, partitioner);
    partitioner.connect(document);
    sqlTextViewer.setDocument(document);
    findReplaceDocAdapter = new FindReplaceDocumentAdapter(document);
    undoManager = new TextViewerUndoManager(50);
    undoManager.connect(sqlTextViewer);
    contentAssistant = viewerConfig.getContentAssistant(sqlTextViewer);
    contentAssistant.install(sqlTextViewer);
    recentlyUsedSQLcontentAssistant = viewerConfig.getRecentlyUsedContentAssistant(sqlTextViewer);
    recentlyUsedSQLcontentAssistant.install(sqlTextViewer);
    formatHandler = new TextViewerOperationHandler(sqlTextViewer, ISourceViewer.FORMAT);
    contentAssistHandler = new TextViewerOperationHandler(sqlTextViewer, ISourceViewer.CONTENTASSIST_PROPOSALS);
    text = (StyledText) sqlTextViewer.getTextWidget();
    text.setIndent(1);
    text.setData(SQL_EDITOR_FLAG, sqlTextViewer);
    createContextMenu();
    addListener();
}
Also used : LineNumberRulerColumn(org.eclipse.jface.text.source.LineNumberRulerColumn) SQLDocument(com.cubrid.common.ui.query.editor.SQLDocument) Composite(org.eclipse.swt.widgets.Composite) CompositeRuler(org.eclipse.jface.text.source.CompositeRuler) FillLayout(org.eclipse.swt.layout.FillLayout) SQLTextViewer(com.cubrid.common.ui.query.editor.SQLTextViewer) RGB(org.eclipse.swt.graphics.RGB) SQLViewerConfiguration(com.cubrid.common.ui.query.editor.SQLViewerConfiguration) TextViewerUndoManager(org.eclipse.jface.text.TextViewerUndoManager) IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner) GridData(org.eclipse.swt.layout.GridData) SQLPartitionScanner(com.cubrid.common.ui.query.editor.SQLPartitionScanner) FindReplaceDocumentAdapter(org.eclipse.jface.text.FindReplaceDocumentAdapter)

Example 3 with FastPartitioner

use of org.eclipse.jface.text.rules.FastPartitioner in project cubrid-manager by CUBRID.

the class QueryRecordListComparator method createQueryTunerTab.

private void createQueryTunerTab(CTabFolder tabFolder) {
    CTabItem item = new CTabItem(tabFolder, SWT.None | SWT.MULTI | SWT.V_SCROLL);
    item.setText(Messages.tabItemQueryTuner);
    tabFolder.setSelection(item);
    SashForm form = new SashForm(tabFolder, SWT.HORIZONTAL);
    item.setControl(form);
    form.setLayout(new FillLayout());
    /*Left composite*/
    Composite leftComposite = new Composite(form, SWT.BORDER);
    leftComposite.setLayout(new GridLayout());
    /*Right composite*/
    queryPlanContainer = new Composite(form, SWT.BORDER);
    queryPlanContainer.setLayout(new FillLayout());
    form.setWeights(new int[] { 40, 60 });
    ToolBar toolBar = new ToolBar(leftComposite, SWT.None);
    runItem = new ToolItem(toolBar, SWT.None);
    runItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_run.png"));
    runItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/query_run_disabled.png"));
    runItem.setToolTipText(Messages.run);
    runItem.setEnabled(false);
    runItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            runQuery();
        }
    });
    runPlanItem = new ToolItem(toolBar, SWT.None);
    runPlanItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_execution_plan.png"));
    runPlanItem.setToolTipText(Messages.queryPlanTip);
    runPlanItem.setEnabled(false);
    runPlanItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            runQueryPlan();
        }
    });
    saveQueryItem = new ToolItem(toolBar, SWT.None);
    saveQueryItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/file_save.png"));
    saveQueryItem.setToolTipText(Messages.ttSaveQueryTuning);
    saveQueryItem.setEnabled(false);
    saveQueryItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            saveQueryRecord();
        }
    });
    SashForm sashForm = new SashForm(leftComposite, SWT.VERTICAL);
    sashForm.setBackground(SASH_COLOR);
    sashForm.setLayout(new FillLayout());
    sashForm.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    CompositeRuler ruler = new CompositeRuler();
    LineNumberRulerColumn lineCol = new LineNumberRulerColumn();
    lineCol.setBackground(ResourceManager.getColor(new RGB(236, 233, 216)));
    ruler.addDecorator(0, lineCol);
    sqlTextViewer = new SQLTextViewer(sashForm, ruler, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, this);
    viewerConfig = new SQLViewerConfiguration(this);
    sqlTextViewer.configure(viewerConfig);
    SQLDocument document = new SQLDocument();
    IDocumentPartitioner partitioner = new FastPartitioner(new SQLPartitionScanner(), SQLPartitionScanner.getAllTypes());
    document.setDocumentPartitioner(ISQLPartitions.SQL_PARTITIONING, partitioner);
    partitioner.connect(document);
    sqlTextViewer.setDocument(document);
    undoManager = new TextViewerUndoManager(50);
    undoManager.connect(sqlTextViewer);
    contentAssistant = viewerConfig.getContentAssistant(sqlTextViewer);
    contentAssistant.install(sqlTextViewer);
    recentlyUsedSQLcontentAssistant = viewerConfig.getRecentlyUsedContentAssistant(sqlTextViewer);
    recentlyUsedSQLcontentAssistant.install(sqlTextViewer);
    formatHandler = new TextViewerOperationHandler(sqlTextViewer, ISourceViewer.FORMAT);
    contentAssistHandler = new TextViewerOperationHandler(sqlTextViewer, ISourceViewer.CONTENTASSIST_PROPOSALS);
    StyledText text = (StyledText) sqlTextViewer.getTextWidget();
    text.setIndent(1);
    text.setData(SQL_EDITOR_FLAG, sqlTextViewer);
    addTextViewerListener(text);
    queryResultContainer = new Composite(sashForm, SWT.None);
    queryResultContainer.setLayout(new FillLayout());
    displayQuery(null);
    displayQueryPlan(null);
}
Also used : LineNumberRulerColumn(org.eclipse.jface.text.source.LineNumberRulerColumn) SQLDocument(com.cubrid.common.ui.query.editor.SQLDocument) StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) QueryPlanComposite(com.cubrid.common.ui.query.control.queryplan.QueryPlanComposite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) CompositeRuler(org.eclipse.jface.text.source.CompositeRuler) FillLayout(org.eclipse.swt.layout.FillLayout) SQLTextViewer(com.cubrid.common.ui.query.editor.SQLTextViewer) RGB(org.eclipse.swt.graphics.RGB) CTabItem(org.eclipse.swt.custom.CTabItem) SQLViewerConfiguration(com.cubrid.common.ui.query.editor.SQLViewerConfiguration) SashForm(org.eclipse.swt.custom.SashForm) TextViewerUndoManager(org.eclipse.jface.text.TextViewerUndoManager) GridLayout(org.eclipse.swt.layout.GridLayout) IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TextViewerOperationHandler(com.cubrid.common.ui.query.control.TextViewerOperationHandler) SQLPartitionScanner(com.cubrid.common.ui.query.editor.SQLPartitionScanner) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 4 with FastPartitioner

use of org.eclipse.jface.text.rules.FastPartitioner in project eclipse.platform.text by eclipse.

the class JavaDocumentSetupParticipant method setup.

@Override
public void setup(IDocument document) {
    if (document instanceof IDocumentExtension3) {
        IDocumentExtension3 extension3 = (IDocumentExtension3) document;
        IDocumentPartitioner partitioner = new FastPartitioner(JavaEditorExamplePlugin.getDefault().getJavaPartitionScanner(), JavaPartitionScanner.JAVA_PARTITION_TYPES);
        extension3.setDocumentPartitioner(JavaEditorExamplePlugin.JAVA_PARTITIONING, partitioner);
        partitioner.connect(document);
    }
}
Also used : IDocumentExtension3(org.eclipse.jface.text.IDocumentExtension3) IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner)

Example 5 with FastPartitioner

use of org.eclipse.jface.text.rules.FastPartitioner in project eclipse.platform.text by eclipse.

the class DefaultPartitionerZeroLengthTest method setUp.

@Before
public void setUp() {
    fDoc = new Document();
    IPartitionTokenScanner scanner = new RuleBasedPartitionScanner() {

        {
            IToken comment = new Token(COMMENT);
            IPredicateRule[] rules = new IPredicateRule[] { new MultiLineRule("/*", "*/", comment) };
            setPredicateRules(rules);
        }
    };
    fPartitioner = new FastPartitioner(scanner, new String[] { DEFAULT, COMMENT });
    fDoc.setDocumentPartitioner(fPartitioner);
    fPartitioner.connect(fDoc);
}
Also used : RuleBasedPartitionScanner(org.eclipse.jface.text.rules.RuleBasedPartitionScanner) IToken(org.eclipse.jface.text.rules.IToken) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner) MultiLineRule(org.eclipse.jface.text.rules.MultiLineRule) IPartitionTokenScanner(org.eclipse.jface.text.rules.IPartitionTokenScanner) IToken(org.eclipse.jface.text.rules.IToken) Token(org.eclipse.jface.text.rules.Token) IPredicateRule(org.eclipse.jface.text.rules.IPredicateRule) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) Before(org.junit.Before)

Aggregations

FastPartitioner (org.eclipse.jface.text.rules.FastPartitioner)37 IDocumentPartitioner (org.eclipse.jface.text.IDocumentPartitioner)25 IDocument (org.eclipse.jface.text.IDocument)17 IDocumentExtension3 (org.eclipse.jface.text.IDocumentExtension3)14 RuleBasedPartitionScanner (org.eclipse.jface.text.rules.RuleBasedPartitionScanner)5 Document (org.eclipse.jface.text.Document)4 DocumentEvent (org.eclipse.jface.text.DocumentEvent)4 IDocumentListener (org.eclipse.jface.text.IDocumentListener)4 IPredicateRule (org.eclipse.jface.text.rules.IPredicateRule)4 Token (org.eclipse.jface.text.rules.Token)4 IPartitionTokenScanner (org.eclipse.jface.text.rules.IPartitionTokenScanner)3 SQLDocument (com.cubrid.common.ui.query.editor.SQLDocument)2 SQLPartitionScanner (com.cubrid.common.ui.query.editor.SQLPartitionScanner)2 SQLTextViewer (com.cubrid.common.ui.query.editor.SQLTextViewer)2 SQLViewerConfiguration (com.cubrid.common.ui.query.editor.SQLViewerConfiguration)2 DocumentProvider (com.cubrid.tool.editor.DocumentProvider)2 ArrayList (java.util.ArrayList)2 TextViewerUndoManager (org.eclipse.jface.text.TextViewerUndoManager)2 IToken (org.eclipse.jface.text.rules.IToken)2 MultiLineRule (org.eclipse.jface.text.rules.MultiLineRule)2