Search in sources :

Example 1 with VerticalRuler

use of org.eclipse.jface.text.source.VerticalRuler in project tmdm-studio-se by Talend.

the class ProcessResultsDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    try {
        parent.getShell().setText(title);
        Composite composite = (Composite) super.createDialogArea(parent);
        GridLayout layout = (GridLayout) composite.getLayout();
        layout.numColumns = 2;
        ((GridData) composite.getLayoutData()).widthHint = 800;
        Label variableLabel = new Label(composite, SWT.NONE);
        variableLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true, 1, 1));
        variableLabel.setText(Messages.ProcessResultsDialog_PipelineVariables);
        variablesCombo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
        variablesCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1));
        /*
             * variablesCombo.addKeyListener( new KeyListener() { public void keyPressed(KeyEvent e) {} public void
             * keyReleased(KeyEvent e) { if ((e.stateMask==0) && (e.character == SWT.CR)) {
             * ProcessResultsPage.this.variablesViewer.setDocument(new Document(getText(variablesCombo.getText()))); }
             * }//keyReleased }//keyListener );
             */
        variablesViewer = new SourceViewer(composite, new VerticalRuler(10), SWT.V_SCROLL | SWT.H_SCROLL);
        variablesViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 2, 1));
        variablesViewer.configure(new TextSourceViewerConfiguration());
        ((GridData) variablesViewer.getControl().getLayoutData()).minimumHeight = 500;
        final Button seeInBrowser = new Button(composite, SWT.PUSH);
        seeInBrowser.setText(Messages.ProcessResultsDialog_display);
        seeInBrowser.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                String htmlContent = variablesViewer.getTextWidget().getText();
                IFile file = FileProvider.createdTempFile(htmlContent, Messages.ProcessResultsDialog_temphtml, null);
                File htmlFile = file.getLocation().toFile();
                // $NON-NLS-1$
                String SHARED_ID = "org.eclipse.ui.browser";
                try {
                    IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
                    if (WebBrowserPreference.getBrowserChoice() == WebBrowserPreference.INTERNAL) {
                        support.createBrowser(IWorkbenchBrowserSupport.AS_EDITOR, file.getLocation().toPortableString(), null, null).openURL(htmlFile.toURL());
                    } else {
                        support.createBrowser(IWorkbenchBrowserSupport.AS_EXTERNAL, SHARED_ID, null, null).openURL(htmlFile.toURL());
                    }
                } catch (Exception e1) {
                    log.error(e1.getMessage(), e1);
                }
            }
        });
        variablesCombo.addModifyListener(new ModifyListener() {

            public void modifyText(ModifyEvent e) {
                String output = variablesCombo.getText();
                if (output.startsWith(TransformerMainPage.DEFAULT_DISPLAY)) {
                    // TransformerMainPage.DEFAULT_VAR+output.substring(TransformerMainPage.DEFAULT_DISPLAY.length());
                    output = DEFAULT_DISPLAY_TEXT;
                }
                String text = variablesCombo.getText();
                if (text.equals(DEFAULT_DISPLAY_TEXT)) {
                    text = TransformerMainPage.DEFAULT_DISPLAY;
                }
                variablesViewer.setDocument(new Document(getText(text)));
                // $NON-NLS-1$
                seeInBrowser.setEnabled("html".equals(text));
            }
        });
        variablesCombo.setFocus();
        refreshData();
        return composite;
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(this.getShell(), Messages._Error, Messages.bind(Messages.ProcessResultsDialog_ErrorMsg, e.getLocalizedMessage()));
        return null;
    }
}
Also used : VerticalRuler(org.eclipse.jface.text.source.VerticalRuler) SourceViewer(org.eclipse.jface.text.source.SourceViewer) IFile(org.eclipse.core.resources.IFile) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) Document(org.eclipse.jface.text.Document) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) IFile(org.eclipse.core.resources.IFile) File(java.io.File) TextSourceViewerConfiguration(org.eclipse.ui.editors.text.TextSourceViewerConfiguration)

Example 2 with VerticalRuler

use of org.eclipse.jface.text.source.VerticalRuler in project tmdm-studio-se by Talend.

the class StoredProcedureMainPage method createCharacteristicsContent.

@Override
protected void createCharacteristicsContent(FormToolkit toolkit, Composite charComposite) {
    try {
        WSStoredProcedure wsStoredProcedure = (WSStoredProcedure) (getXObject().getWsObject());
        // description
        Label descriptionLabel = toolkit.createLabel(charComposite, Messages.StoredProcedureMainPage_4, SWT.NULL);
        descriptionLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 1, 1));
        // $NON-NLS-1$
        descriptionText = toolkit.createText(charComposite, "", SWT.BORDER);
        descriptionText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        // $NON-NLS-1$
        descriptionText.setText(wsStoredProcedure.getDescription() == null ? "" : wsStoredProcedure.getDescription());
        descriptionText.addModifyListener(this);
        // Procedure
        Group storedProcedureGroup = new Group(charComposite, SWT.SHADOW_NONE);
        storedProcedureGroup.setText(Messages.StoredProcedureMainPage_5);
        storedProcedureGroup.setLayout(new GridLayout(1, true));
        storedProcedureGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
        ((GridData) storedProcedureGroup.getLayoutData()).minimumHeight = 100;
        procedureViewer = new SourceViewer(storedProcedureGroup, new VerticalRuler(10), SWT.V_SCROLL);
        procedureViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        procedureViewer.addTextListener(this);
        WidgetUtils.initRedoUndo(procedureViewer);
        refreshCacheBtn = toolkit.createButton(charComposite, Messages.StoredProcedureMainPage_6, SWT.CHECK);
        refreshCacheBtn.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
        refreshCacheBtn.addSelectionListener(new SelectionListener() {

            public void widgetSelected(SelectionEvent e) {
                markDirty();
            }

            public void widgetDefaultSelected(SelectionEvent e) {
                markDirty();
            }
        });
        /**
         **********************************************************
         * Execute Stored Procedure
         ***********************************************************
         */
        createCompDropTarget();
        Composite resultsGroup = this.getNewSectionComposite(Messages.StoredProcedureMainPage_7);
        resultsGroup.setLayout(new GridLayout(4, false));
        // data cluster
        Hyperlink dataClusterLink = toolkit.createHyperlink(resultsGroup, Messages.StoredProcedureMainPage_8, SWT.NULL);
        dataClusterLink.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
        dataClusterLink.addHyperlinkListener(new IHyperlinkListener() {

            public void linkEntered(org.eclipse.ui.forms.events.HyperlinkEvent e) {
            }

            public void linkExited(org.eclipse.ui.forms.events.HyperlinkEvent e) {
            }

            public void linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent e) {
                if (!isLocalInput()) {
                    TreeParent serverRoot = StoredProcedureMainPage.this.getXObject().getServerRoot();
                    TreeObject iaObject = new TreeObject(StoredProcedureMainPage.this.dataClusterCombo.getText(), serverRoot, TreeObject.DATA_CLUSTER, new WSDataClusterPK(StoredProcedureMainPage.this.dataClusterCombo.getText()), null);
                    (new EditXObjectAction(iaObject, StoredProcedureMainPage.this.getSite().getPage())).run();
                }
            }
        });
        dataClusterCombo = new Combo(resultsGroup, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.SINGLE);
        dataClusterCombo.setLayoutData(new GridData(SWT.BEGINNING, SWT.NONE, false, false, 1, 1));
        Button executeButton = new Button(resultsGroup, SWT.PUSH);
        executeButton.setText(Messages.StoredProcedureMainPage_9);
        executeButton.addMouseListener(new MouseListener() {

            public void mouseUp(MouseEvent e) {
                executeProcedure();
            }

            public void mouseDoubleClick(MouseEvent e) {
            }

            public void mouseDown(MouseEvent e) {
            }
        });
        resultsLabel = toolkit.createLabel(resultsGroup, // $NON-NLS-1$
        "                                                                                                           ", SWT.NULL);
        resultsLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false, 1, 1));
        resultsViewer = new TableViewer(resultsGroup);
        resultsViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));
        ((GridData) resultsViewer.getControl().getLayoutData()).heightHint = 300;
        resultsViewer.setContentProvider(new ArrayContentProvider());
        resultsViewer.setLabelProvider(new XMLTableLabelProvider());
        resultsViewer.addDoubleClickListener(new IDoubleClickListener() {

            public void doubleClick(DoubleClickEvent event) {
                resultsViewer.setSelection(event.getSelection());
                new ResultsViewAction(StoredProcedureMainPage.this.getSite().getShell(), resultsViewer).run();
            }
        });
        hookContextMenu();
        refreshData();
        dataClusterCombo.select(0);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) SourceViewer(org.eclipse.jface.text.source.SourceViewer) TreeParent(com.amalto.workbench.models.TreeParent) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) WSDataClusterPK(com.amalto.workbench.webservices.WSDataClusterPK) MouseListener(org.eclipse.swt.events.MouseListener) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IHyperlinkListener(org.eclipse.ui.forms.events.IHyperlinkListener) WSStoredProcedure(com.amalto.workbench.webservices.WSStoredProcedure) VerticalRuler(org.eclipse.jface.text.source.VerticalRuler) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) EditXObjectAction(com.amalto.workbench.actions.EditXObjectAction) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) TreeObject(com.amalto.workbench.models.TreeObject) TableViewer(org.eclipse.jface.viewers.TableViewer) SelectionListener(org.eclipse.swt.events.SelectionListener) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink)

Example 3 with VerticalRuler

use of org.eclipse.jface.text.source.VerticalRuler in project tmdm-studio-se by Talend.

the class SchematronExpressBuilder method create.

private void create() {
    com = new Composite(parent, SWT.NONE);
    com.setLayout(getLayout(3));
    // expression
    Group expressG = new Group(com, SWT.NONE);
    expressG.setText(Messages.SchematronExpressBuilder_Expression);
    expressG.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 2));
    expressG.setLayout(getLayout(1));
    // top button group
    Composite topCom = new Composite(expressG, 0);
    Button clearBtn = new Button(topCom, SWT.PUSH);
    topCom.setLayout(getLayout(4));
    clearBtn.setText(Messages.SchematronExpressBuilder_Clear);
    clearBtn.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false, 1, 1));
    clearBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // $NON-NLS-1$
            sourceViewer.setDocument(new Document(""));
        }
    });
    org.eclipse.jface.text.Document doc = new org.eclipse.jface.text.Document(value);
    sourceViewer = new SourceViewer(expressG, new VerticalRuler(5), SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 6);
    gd.heightHint = 150;
    sourceViewer.getControl().setLayoutData(gd);
    WidgetUtils.initRedoUndo(sourceViewer);
    sourceViewer.setDocument(doc);
    // bottom button group
    Composite bottomCom = new Composite(expressG, 0);
    GridLayout ly = getLayout(4);
    bottomCom.setLayout(ly);
    Composite com1 = new Composite(bottomCom, 0);
    com1.setLayout(getLayout(4));
    // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    String[] strs1 = { "+", "-", "*", "div" };
    for (String str : strs1) {
        final Button btn = new Button(com1, SWT.PUSH);
        btn.setText(str);
        btn.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                // getTextWidget().setText(getText() + btn.getText());
                insertText(btn.getText());
            }
        });
    }
    Composite com2 = new Composite(bottomCom, 0);
    com2.setLayout(getLayout(4));
    // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    String[] strs2 = { "=", "!=", ">", "<" };
    for (String str : strs2) {
        final Button btn = new Button(com2, SWT.PUSH);
        btn.setText(str);
        btn.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                // getTextWidget().setText(getText() + btn.getText());
                insertText(btn.getText());
            }
        });
    }
    Composite com3 = new Composite(bottomCom, 0);
    com3.setLayout(getLayout(4));
    // $NON-NLS-1$//$NON-NLS-2$
    String[] strs3 = { "and", "or" };
    for (int i = 0; i < strs3.length; i++) {
        final Button btn = new Button(com3, SWT.PUSH);
        btn.setText(strs3[i]);
        btn.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                // getTextWidget().setText(getText() + btn.getText());
                insertText(btn.getText());
            }
        });
    }
    Composite com4 = new Composite(bottomCom, 0);
    com4.setLayout(getLayout(3));
    // $NON-NLS-1$//$NON-NLS-2$
    String[] strs4 = { ")", "(" };
    for (int i = 0; i < strs4.length; i++) {
        final Button btn = new Button(com4, SWT.PUSH);
        btn.setText(strs4[i]);
        btn.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                // getTextWidget().setText(getText() + btn.getText());
                insertText(btn.getText());
            }
        });
    }
    Button xpathButton = new Button(com4, SWT.PUSH);
    // $NON-NLS-1$
    xpathButton.setText("xpath");
    xpathButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            XpathSelectDialog dlg = getXPathSelectDialog();
            dlg.setConceptName(conceptName);
            // dlg.setContext(context);
            dlg.setBlockOnOpen(true);
            dlg.open();
            if (dlg.getReturnCode() == Window.OK) {
                if (getTextWidget().getSelectionText().length() > 0) {
                    // getTextWidget().setText(getText().replace(getTextWidget().getSelectionText(),
                    // dlg.getXpath()));
                    getTextWidget().replaceTextRange(getTextWidget().getSelectionRanges()[0], getTextWidget().getSelectionRanges()[1], dlg.getXpath());
                } else {
                    // getTextWidget().setText(getText()+dlg.getXpath());
                    insertText(dlg.getXpath());
                }
            }
        }
    });
    // //test
    // Group testG=new Group(com,SWT.NONE);
    // testG.setText("Test");
    // GridData gd2=new GridData(SWT.FILL,SWT.FILL,true,true,1,2);
    // gd2.widthHint=190;
    // testG.setLayoutData(gd2);
    // testG.setLayout(getLayout(2));
    // Button btnStartTest=new Button(testG,SWT.PUSH);
    // btnStartTest.setText("Start Test");
    // btnStartTest.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,false,1,1));
    // 
    // Button btnCleartTest=new Button(testG,SWT.PUSH);
    // btnCleartTest.setText("Clear");
    // btnCleartTest.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,false,1,1));
    // 
    // testResult=new StyledText(testG,SWT.V_SCROLL|SWT.BORDER);
    // testResult.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true,2,3));
    // btnCleartTest.addSelectionListener(new SelectionAdapter(){
    // @Override
    // public void widgetSelected(SelectionEvent e) {
    // testResult.setText("");
    // }
    // });
    // categories
    Group categoryG = new Group(com, SWT.NONE);
    categoryG.setText(Messages.SchematronExpressBuilder_Categories);
    GridData gd1 = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gd1.heightHint = 200;
    gd1.widthHint = 140;
    categoryG.setLayoutData(gd1);
    categoryG.setLayout(getLayout(1));
    categoryList = new List(categoryG, SWT.BORDER | SWT.V_SCROLL);
    categoryList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    for (XPathFunc c : categories) {
        categoryList.add(c.getCategory());
    }
    categoryList.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            funcList.removeAll();
            String c = categoryList.getSelection()[0];
            for (XPathFunc func : categories) {
                if (func.getCategory().equals(c)) {
                    curfc = func;
                    for (KeyValue kv : func.getFuncs()) {
                        funcList.add(kv.key);
                    }
                    break;
                }
            }
            if (funcList.getItems().length > 0) {
                funcList.select(0);
                helpTxt.setText(curfc.getFuncs().get(0).value);
            }
        }
    });
    // funcations
    Group functionG = new Group(com, SWT.NONE);
    functionG.setText(Messages.SchematronExpressBuilder_Functions);
    functionG.setLayout(getLayout(1));
    GridData gd3 = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gd3.widthHint = 220;
    functionG.setLayoutData(gd3);
    funcList = new List(functionG, SWT.BORDER | SWT.V_SCROLL);
    funcList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    funcList.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
            getTextWidget().setText(getText() + funcList.getItem(funcList.getSelectionIndex()));
        }

        public void widgetSelected(SelectionEvent e) {
            String c = funcList.getSelection()[0];
            for (KeyValue kv : curfc.getFuncs()) {
                if (kv.key.equals(c)) {
                    helpTxt.setText(kv.value);
                    break;
                }
            }
        }
    });
    // help
    Group helpG = new Group(com, SWT.NONE);
    helpG.setText(Messages.SchematronExpressBuilder_Help);
    helpG.setLayout(getLayout(1));
    helpG.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    helpTxt = new StyledText(helpG, SWT.BORDER | SWT.WRAP);
    GridData gd4 = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gd4.widthHint = 210;
    helpTxt.setLayoutData(gd4);
}
Also used : Group(org.eclipse.swt.widgets.Group) SourceViewer(org.eclipse.jface.text.source.SourceViewer) KeyValue(com.amalto.workbench.models.KeyValue) XpathSelectDialog(com.amalto.workbench.dialogs.XpathSelectDialog) Document(org.eclipse.jface.text.Document) Document(org.eclipse.jface.text.Document) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) List(org.eclipse.swt.widgets.List) VerticalRuler(org.eclipse.jface.text.source.VerticalRuler) StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) XPathFunc(com.amalto.workbench.models.XPathFunc) Point(org.eclipse.swt.graphics.Point) GridData(org.eclipse.swt.layout.GridData) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 4 with VerticalRuler

use of org.eclipse.jface.text.source.VerticalRuler in project jbosstools-hibernate by jbosstools.

the class DynamicSQLPreviewView method createPartControl.

public void createPartControl(Composite parent) {
    textViewer = new HQLSourceViewer(parent, new VerticalRuler(1), null, false, SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL);
    // textViewer.setEditable(false);
    IDocument doc = new Document();
    textViewer.setDocument(doc);
    docSetupParticipant.setup(doc);
    textViewer.getDocument().set(HibernateConsoleMessages.DynamicSQLPreviewView_no_hql_query_editor_selected);
    textViewer.configure(new HQLSourceViewerConfiguration(null));
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IPartService service = window.getPartService();
    hookIntoEditor(service.getActivePartReference());
}
Also used : VerticalRuler(org.eclipse.jface.text.source.VerticalRuler) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) HQLSourceViewer(org.hibernate.eclipse.hqleditor.HQLSourceViewer) HQLSourceViewerConfiguration(org.hibernate.eclipse.hqleditor.HQLSourceViewerConfiguration) IPartService(org.eclipse.ui.IPartService) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) IDocument(org.eclipse.jface.text.IDocument)

Example 5 with VerticalRuler

use of org.eclipse.jface.text.source.VerticalRuler in project mylyn.docs by eclipse.

the class MarkupViewerPreferencePage method createContents.

@Override
protected Control createContents(Composite parent) {
    colorRegistry = new Colors();
    colorRegistry.put(WHITE, new RGB(255, 255, 255));
    Composite composite = new Composite(parent, SWT.NULL);
    GridLayoutFactory.fillDefaults().margins(5, 5).numColumns(1).applyTo(composite);
    Label label = new Label(composite, SWT.WRAP);
    label.setText(Messages.MarkupViewerPreferencePage_appearanceInfo);
    GridDataFactory.fillDefaults().applyTo(label);
    Preferences preferences = WikiTextUiPlugin.getDefault().getPreferences();
    Composite viewerContainer = new Composite(composite, SWT.BORDER);
    GridLayoutFactory.fillDefaults().margins(0, 0).numColumns(1).applyTo(viewerContainer);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(viewerContainer);
    {
        sourceViewer = new SourceViewer(viewerContainer, new VerticalRuler(0), SWT.WRAP | SWT.V_SCROLL);
        GridDataFactory.fillDefaults().grab(true, true).applyTo(sourceViewer.getControl());
        Document document = new Document(preferences.getMarkupViewerCss());
        CssPartitioner partitioner = new CssPartitioner();
        partitioner.connect(document);
        document.setDocumentPartitioner(partitioner);
        sourceViewer.setDocument(document);
        CssConfiguration configuration = new CssConfiguration(colorRegistry);
        sourceViewer.configure(configuration);
    }
    label = new Label(composite, SWT.WRAP);
    label.setText(Messages.MarkupViewerPreferencePage_preview);
    GridDataFactory.fillDefaults().applyTo(label);
    applyDialogFont(composite);
    Composite previewViewerContainer = new Composite(composite, SWT.BORDER);
    GridLayoutFactory.fillDefaults().margins(0, 0).numColumns(1).applyTo(previewViewerContainer);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(previewViewerContainer);
    {
        previewViewer = new HtmlViewer(previewViewerContainer, new VerticalRuler(0), SWT.WRAP | SWT.V_SCROLL);
        previewViewer.getTextWidget().setBackground(colorRegistry.get(WHITE));
        GridDataFactory.fillDefaults().grab(true, true).applyTo(previewViewer.getControl());
        htmlViewerConfiguration = new HtmlViewerConfiguration(previewViewer);
        previewViewer.configure(htmlViewerConfiguration);
        previewViewer.getTextWidget().setEditable(false);
        previewViewer.setStylesheet(preferences.getStylesheet());
        if (JFaceResources.getFontRegistry().hasValueFor(WikiTextTasksUiPlugin.FONT_REGISTRY_KEY_DEFAULT_FONT)) {
            previewViewer.getTextWidget().setFont(JFaceResources.getFontRegistry().get(WikiTextTasksUiPlugin.FONT_REGISTRY_KEY_DEFAULT_FONT));
        }
        if (JFaceResources.getFontRegistry().hasValueFor(WikiTextTasksUiPlugin.FONT_REGISTRY_KEY_MONOSPACE_FONT)) {
            previewViewer.setDefaultMonospaceFont(JFaceResources.getFontRegistry().get(WikiTextTasksUiPlugin.FONT_REGISTRY_KEY_MONOSPACE_FONT));
        }
        previewViewer.setHtml(createPreviewHtml());
        sourceViewer.getDocument().addDocumentListener(new IDocumentListener() {

            public void documentAboutToBeChanged(DocumentEvent event) {
            }

            public void documentChanged(DocumentEvent event) {
                schedulePreviewUpdate();
            }
        });
    }
    return composite;
}
Also used : VerticalRuler(org.eclipse.jface.text.source.VerticalRuler) CssConfiguration(org.eclipse.mylyn.internal.wikitext.ui.util.css.editor.CssConfiguration) SourceViewer(org.eclipse.jface.text.source.SourceViewer) Composite(org.eclipse.swt.widgets.Composite) HtmlViewerConfiguration(org.eclipse.mylyn.wikitext.ui.viewer.HtmlViewerConfiguration) IDocumentListener(org.eclipse.jface.text.IDocumentListener) Label(org.eclipse.swt.widgets.Label) CssPartitioner(org.eclipse.mylyn.internal.wikitext.ui.util.css.editor.CssPartitioner) RGB(org.eclipse.swt.graphics.RGB) Document(org.eclipse.jface.text.Document) DocumentEvent(org.eclipse.jface.text.DocumentEvent) Preferences(org.eclipse.mylyn.internal.wikitext.ui.editor.preferences.Preferences) HtmlViewer(org.eclipse.mylyn.wikitext.ui.viewer.HtmlViewer)

Aggregations

VerticalRuler (org.eclipse.jface.text.source.VerticalRuler)5 Document (org.eclipse.jface.text.Document)4 SourceViewer (org.eclipse.jface.text.source.SourceViewer)4 Composite (org.eclipse.swt.widgets.Composite)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Button (org.eclipse.swt.widgets.Button)3 Label (org.eclipse.swt.widgets.Label)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionListener (org.eclipse.swt.events.SelectionListener)2 Combo (org.eclipse.swt.widgets.Combo)2 Group (org.eclipse.swt.widgets.Group)2 EditXObjectAction (com.amalto.workbench.actions.EditXObjectAction)1 XpathSelectDialog (com.amalto.workbench.dialogs.XpathSelectDialog)1 KeyValue (com.amalto.workbench.models.KeyValue)1 TreeObject (com.amalto.workbench.models.TreeObject)1 TreeParent (com.amalto.workbench.models.TreeParent)1 XPathFunc (com.amalto.workbench.models.XPathFunc)1 WSDataClusterPK (com.amalto.workbench.webservices.WSDataClusterPK)1