Search in sources :

Example 36 with StyledText

use of org.eclipse.swt.custom.StyledText in project tdi-studio-se by Talend.

the class StandAloneTalendJavaEditor method init.

@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
    super.init(site, input);
    Bundle bundle = FrameworkUtil.getBundle(StandAloneTalendJavaEditor.class);
    lockService = bundle.getBundleContext().registerService(EventHandler.class.getName(), new EventHandler() {

        @Override
        public void handleEvent(Event event) {
            String lockTopic = Constant.REPOSITORY_ITEM_EVENT_PREFIX + Constant.ITEM_LOCK_EVENT_SUFFIX;
            if (lockTopic.equals(event.getTopic())) {
                if (!isEditable) {
                    Object o = event.getProperty(Constant.ITEM_EVENT_PROPERTY_KEY);
                    if (o instanceof FileItem) {
                        boolean isTheCorrectEditor = false;
                        Property property = ((FileItem) o).getProperty();
                        if (property != null) {
                            String eventItemId = property.getId();
                            //$NON-NLS-1$
                            String currentOpenedItemId = "";
                            if (rEditorInput != null) {
                                currentOpenedItemId = rEditorInput.getId();
                            }
                            isTheCorrectEditor = currentOpenedItemId.equals(eventItemId);
                        }
                        if (!isTheCorrectEditor) {
                            return;
                        }
                        item.getProperty().eAdapters().remove(dirtyListener);
                        item = (FileItem) o;
                        item.getProperty().eAdapters().add(dirtyListener);
                        if (isEditable()) {
                            isEditable = true;
                            rEditorInput.getFile().setReadOnly(false);
                            getSite().getShell().getDisplay().asyncExec(new Runnable() {

                                @Override
                                public void run() {
                                    setFocus();
                                    ISourceViewer viewer = getViewer();
                                    if (viewer != null) {
                                        StyledText styledText = viewer.getTextWidget();
                                        if (styledText != null) {
                                            styledText.setBackground(bgColorForEditabeItem);
                                            styledText.setDragDetect(true);
                                        }
                                    }
                                }
                            });
                            try {
                                ICodeGeneratorService service = (ICodeGeneratorService) GlobalServiceRegister.getDefault().getService(ICodeGeneratorService.class);
                                if (o instanceof RoutineItem) {
                                    ITalendSynchronizer routineSynchronizer = service.createJavaRoutineSynchronizer();
                                    routineSynchronizer.syncRoutine((RoutineItem) o, true);
                                } else if (o instanceof SQLPatternItem) {
                                    ISQLPatternSynchronizer sqlPatternSynchronizer = service.getSQLPatternSynchronizer();
                                    sqlPatternSynchronizer.syncSQLPattern((SQLPatternItem) o, true);
                                } else {
                                    //$NON-NLS-1$
                                    org.talend.commons.exception.ExceptionHandler.process(new Exception("Uncatched case"));
                                }
                                setName();
                            } catch (Exception e) {
                                org.talend.commons.exception.ExceptionHandler.process(e);
                            }
                        }
                    }
                }
            }
        }
    }, new Hashtable<String, String>(//$NON-NLS-1$
    Collections.singletonMap(EventConstants.EVENT_TOPIC, Constant.REPOSITORY_ITEM_EVENT_PREFIX + "*")));
}
Also used : ITalendSynchronizer(org.talend.designer.codegen.ITalendSynchronizer) StyledText(org.eclipse.swt.custom.StyledText) Bundle(org.osgi.framework.Bundle) Hashtable(java.util.Hashtable) ISQLPatternSynchronizer(org.talend.designer.codegen.ISQLPatternSynchronizer) EventHandler(org.osgi.service.event.EventHandler) RoutineItem(org.talend.core.model.properties.RoutineItem) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) LoginException(org.talend.commons.exception.LoginException) InvocationTargetException(java.lang.reflect.InvocationTargetException) PersistenceException(org.talend.commons.exception.PersistenceException) ICodeGeneratorService(org.talend.designer.codegen.ICodeGeneratorService) FileItem(org.talend.core.model.properties.FileItem) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) IResourceChangeEvent(org.eclipse.core.resources.IResourceChangeEvent) ResourceChangeEvent(org.eclipse.core.internal.events.ResourceChangeEvent) Event(org.osgi.service.event.Event) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) Property(org.talend.core.model.properties.Property)

Example 37 with StyledText

use of org.eclipse.swt.custom.StyledText in project cubrid-manager by CUBRID.

the class EditFunctionDialog method createSqlScriptComposite.

private Composite createSqlScriptComposite() {
    final Composite composite = new Composite(tabFolder, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout();
    layout.marginWidth = 10;
    layout.marginHeight = 10;
    sqlScriptText = new StyledText(composite, SWT.BORDER | SWT.WRAP | SWT.MULTI | SWT.READ_ONLY);
    CommonUITool.registerContextMenu(sqlScriptText, false);
    sqlScriptText.setLayoutData(new GridData(GridData.FILL_BOTH));
    composite.setLayout(layout);
    return composite;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData)

Example 38 with StyledText

use of org.eclipse.swt.custom.StyledText in project cubrid-manager by CUBRID.

the class CreateOrEditSerialDialog method createSqlScriptComposite.

/**
	 * Create SQL script composite
	 *
	 * @return the composite
	 */
private Composite createSqlScriptComposite() {
    final Composite composite = new Composite(tabFolder, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout();
    layout.marginWidth = 10;
    layout.marginHeight = 10;
    sqlScriptText = new StyledText(composite, SWT.BORDER | SWT.WRAP | SWT.MULTI | SWT.READ_ONLY);
    CommonUITool.registerContextMenu(sqlScriptText, false);
    sqlScriptText.setLayoutData(new GridData(GridData.FILL_BOTH));
    composite.setLayout(layout);
    return composite;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData)

Example 39 with StyledText

use of org.eclipse.swt.custom.StyledText in project cubrid-manager by CUBRID.

the class InsertTableDataDialog method createDialogArea.

protected Control createDialogArea(Composite parent) {
    Composite parentComp = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(parentComp, SWT.NONE);
    {
        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
        GridLayout layout = new GridLayout();
        layout.numColumns = 1;
        layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
        layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
        layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
        layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
        composite.setLayout(layout);
    }
    sashForm = new SashForm(composite, SWT.NONE);
    {
        sashForm.setOrientation(SWT.VERTICAL);
        GridData gridData = new GridData(GridData.FILL_BOTH);
        gridData.widthHint = 620;
        gridData.heightHint = 500;
        sashForm.setLayoutData(gridData);
        createAttrTable();
        sqlHistoryTxt = new StyledText(sashForm, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY);
        sqlHistoryTxt.setLayoutData(new GridData(GridData.FILL_BOTH));
        CommonUITool.registerContextMenu(sqlHistoryTxt, false);
        sashForm.setWeights(new int[] { 60, 40 });
    }
    lblTotalInsertedCount = new Label(composite, SWT.NONE);
    {
        lblTotalInsertedCount.setText("");
        GridData gridData = new GridData();
        gridData.grabExcessHorizontalSpace = true;
        gridData.horizontalAlignment = GridData.FILL;
        lblTotalInsertedCount.setLayoutData(gridData);
    }
    setTitle(Messages.insertInstanceMsgTitle);
    setMessage(Messages.insertInstanceMsg);
    return parentComp;
}
Also used : SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label)

Example 40 with StyledText

use of org.eclipse.swt.custom.StyledText in project cubrid-manager by CUBRID.

the class PstmtDataDialog method createSqlTextComposite.

private void createSqlTextComposite(Composite parent) {
    Group sqlGroup = new Group(parent, SWT.NONE);
    {
        sqlGroup.setText(Messages.grpSql);
        GridData gridData = new GridData(GridData.FILL_BOTH);
        gridData.heightHint = 160;
        sqlGroup.setLayoutData(gridData);
        GridLayout layout = new GridLayout();
        layout.numColumns = 2;
        sqlGroup.setLayout(layout);
    }
    sqlTxt = new StyledText(sqlGroup, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
    {
        GridData gridData = new GridData(GridData.FILL_BOTH);
        sqlTxt.setLayoutData(gridData);
        sqlTxt.addModifyListener(new ModifyListener() {

            public void modifyText(ModifyEvent event) {
                if (validSql()) {
                    analyzeButton.setEnabled(true);
                } else {
                    analyzeButton.setEnabled(false);
                }
            }
        });
        CommonUITool.registerContextMenu(sqlTxt, true);
    }
    Composite composite = new Composite(sqlGroup, SWT.NONE);
    {
        GridLayout gridLayout = new GridLayout();
        gridLayout.marginWidth = 0;
        gridLayout.marginHeight = 0;
        composite.setLayout(gridLayout);
        GridData gridData = new GridData();
        gridData.verticalAlignment = SWT.TOP;
        composite.setLayoutData(gridData);
    }
    Button clearButton = new Button(composite, SWT.NONE);
    {
        GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
        clearButton.setLayoutData(gridData);
        clearButton.setText(Messages.btnClear);
        clearButton.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                sqlTxt.setText("");
                validate();
            }
        });
    }
    analyzeButton = new Button(composite, SWT.NONE);
    {
        GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
        analyzeButton.setLayoutData(gridData);
        analyzeButton.setText(Messages.btnAnalyze);
        analyzeButton.setEnabled(false);
        analyzeButton.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                analyzeSql();
                validate();
            }
        });
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) StyledText(org.eclipse.swt.custom.StyledText) ModifyListener(org.eclipse.swt.events.ModifyListener) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

StyledText (org.eclipse.swt.custom.StyledText)329 Point (org.eclipse.swt.graphics.Point)102 GridData (org.eclipse.swt.layout.GridData)68 Composite (org.eclipse.swt.widgets.Composite)63 GridLayout (org.eclipse.swt.layout.GridLayout)62 Control (org.eclipse.swt.widgets.Control)46 SelectionEvent (org.eclipse.swt.events.SelectionEvent)32 Label (org.eclipse.swt.widgets.Label)32 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)30 Display (org.eclipse.swt.widgets.Display)30 Shell (org.eclipse.swt.widgets.Shell)30 Rectangle (org.eclipse.swt.graphics.Rectangle)27 Color (org.eclipse.swt.graphics.Color)25 FillLayout (org.eclipse.swt.layout.FillLayout)25 Button (org.eclipse.swt.widgets.Button)23 Text (org.eclipse.swt.widgets.Text)21 StyleRange (org.eclipse.swt.custom.StyleRange)20 Font (org.eclipse.swt.graphics.Font)20 Event (org.eclipse.swt.widgets.Event)20 Test (org.junit.Test)20