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 + "*")));
}
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;
}
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;
}
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;
}
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();
}
});
}
}
Aggregations