use of org.eclipse.jface.util.IPropertyChangeListener in project tdq-studio-se by Talend.
the class SQLPreferencePage method createPreviewer.
/**
* Creates the synatx highlighting previewer
*
* @param parent
* @return
*/
private Control createPreviewer(Composite parent) {
final String separator = System.getProperty("line.separator");
final String content = Messages.getString("select_*_from_MyTable_--_single_line_comment_12") + separator + Messages.getString("/*_multi_line_comment_13") + // $NON-NLS-2$
separator + Messages.getString("select_*_14") + separator + Messages.getString("end_multi_line_comment*/_15") + separator + // $NON-NLS-2$
Messages.getString("where_A___1___16");
// Get a text viewer and load our sample into it
final SQLTextViewer fPreviewViewer = new SQLTextViewer(parent, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, getPreferenceStore(), null);
fPreviewViewer.setEditable(false);
IDocument document = new Document(content);
fPreviewViewer.setDocument(document);
getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
fPreviewViewer.invalidateTextPresentation();
// MOD by zshen for bug 12046,save the font size.
FontData fd = PreferenceConverter.getFontData(fontFieldEditor.getPreferenceStore(), IConstants.FONT);
getPreferenceStore().setValue(IConstants.FONT, fd.toString());
// ~12046
}
});
return fPreviewViewer.getControl();
}
use of org.eclipse.jface.util.IPropertyChangeListener in project whole by wholeplatform.
the class EditorPreferencePage method createContents.
protected Control createContents(Composite parent) {
Label label;
GridData gd;
Composite topComposite = new Composite(parent, SWT.NONE);
topComposite.setLayout(new GridLayout(1, false));
topComposite.setFont(parent.getFont());
gd = new GridData(GridData.FILL_BOTH);
gd.horizontalSpan = 1;
topComposite.setLayoutData(gd);
Label fontsLabel = new Label(topComposite, SWT.LEFT);
fontsLabel.setText("Font category:");
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
fontsLabel.setLayoutData(gd);
Composite fontComposite = new Composite(topComposite, SWT.BORDER);
GridLayout fontLayout = new GridLayout(3, false);
fontComposite.setLayout(fontLayout);
fontComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
monospaceFont = new FontFieldEditor(PreferenceConstants.MONOSPACE_FONT, "Monospace", fontComposite);
sanserifFont = new FontFieldEditor(PreferenceConstants.SANSERIF_FONT, "Sans Serif", fontComposite);
serifFont = new FontFieldEditor(PreferenceConstants.SERIF_FONT, "Serif", fontComposite);
GridLayout bgLayout = new GridLayout(2, false);
bgLayout.marginHeight = 5;
bgLayout.marginWidth = 10;
topComposite.setLayout(bgLayout);
Label bgLabel = new Label(topComposite, SWT.LEFT);
bgLabel.setText("Hilight category:");
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
bgLabel.setLayoutData(gd);
bgCategoryTable = new TableViewer(topComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
bgCategoryTable.setContentProvider(new ArrayContentProvider());
bgCategoryTable.setLabelProvider(new PresentationLabelProvider(bgCategoryTable));
bgCategoryTable.setComparator(new ViewerComparator());
gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_BOTH);
gd.widthHint = convertWidthInCharsToPixels(25);
// convertHeightInCharsToPixels(5);
gd.heightHint = 90;
bgCategoryTable.getControl().setLayoutData(gd);
bgColumn = new TableColumn(bgCategoryTable.getTable(), SWT.LEFT);
Composite bgStylesComposite = new Composite(topComposite, SWT.NONE);
GridLayout bgStylesLayout = new GridLayout(2, false);
bgStylesLayout.marginHeight = 0;
bgStylesLayout.marginWidth = 0;
bgStylesComposite.setLayout(bgStylesLayout);
bgStylesComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
label = new Label(bgStylesComposite, SWT.LEFT);
label.setText("Color:");
label.setLayoutData(new GridData());
bgColorSelector = new ColorSelector(bgStylesComposite);
Label fgLabel = new Label(topComposite, SWT.NONE);
fgLabel.setText("Syntax category:");
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
fgLabel.setLayoutData(gd);
fgCategoryTable = new TableViewer(topComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
fgCategoryTable.setContentProvider(new ArrayContentProvider());
fgCategoryTable.setLabelProvider(new PresentationLabelProvider(fgCategoryTable));
fgCategoryTable.setComparator(new ViewerComparator());
gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_BOTH);
gd.widthHint = convertWidthInCharsToPixels(25);
// convertHeightInCharsToPixels(4);
gd.heightHint = 52;
fgCategoryTable.getControl().setLayoutData(gd);
fgColumn = new TableColumn(fgCategoryTable.getTable(), SWT.LEFT);
Composite fgStylesComposite = new Composite(topComposite, SWT.NONE);
GridLayout fgStylesLayout = new GridLayout(2, false);
fgStylesLayout.marginHeight = 0;
fgStylesLayout.marginWidth = 0;
fgStylesComposite.setLayout(fgStylesLayout);
fgStylesComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
label = new Label(fgStylesComposite, SWT.LEFT);
label.setText("Color:");
label.setLayoutData(new GridData());
fgColorSelector = new ColorSelector(fgStylesComposite);
label = new Label(fgStylesComposite, SWT.LEFT);
label.setText("Font:");
label.setLayoutData(new GridData());
classCombo = new Combo(fgStylesComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
classCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
label = new Label(fgStylesComposite, SWT.LEFT);
label.setText("Style:");
label.setLayoutData(new GridData());
styleCombo = new Combo(fgStylesComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
styleCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
label = new Label(fgStylesComposite, SWT.LEFT);
label.setText("Size:");
label.setLayoutData(new GridData());
sizeCombo = new Combo(fgStylesComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
sizeCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
bgCategoryTable.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
if (!event.getSelection().isEmpty()) {
handleBgCategoryListSelection();
}
}
});
bgCategoryTable.getControl().addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
bgColumn.setWidth(bgCategoryTable.getControl().getSize().x - 4);
}
});
bgColorSelector.addListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
RGB newRGB = (RGB) event.getNewValue();
String key = getSelectedKey(bgCategoryTable);
if (key != null && newRGB != null && !newRGB.equals(event.getOldValue())) {
store.putValue(key, StringConverter.asString(newRGB));
}
}
});
fgCategoryTable.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
if (!event.getSelection().isEmpty()) {
handleFgCategoryListSelection();
}
}
});
fgCategoryTable.getControl().addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
fgColumn.setWidth(fgCategoryTable.getControl().getSize().x - 24);
}
});
fgColorSelector.addListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
RGB newRGB = (RGB) event.getNewValue();
String key = getSelectedKey(fgCategoryTable);
if (key != null && newRGB != null && !newRGB.equals(event.getOldValue())) {
store.putValue(key, StringConverter.asString(newRGB));
}
}
});
classCombo.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
String key = getSelectedKey(fgCategoryTable);
store.putValue(key + PreferenceConstants.CLASS, FontClass.nameOf(classCombo.getSelectionIndex()));
}
});
styleCombo.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
String key = getSelectedKey(fgCategoryTable);
store.putValue(key + PreferenceConstants.STYLE, FontStyle.nameOf(styleCombo.getSelectionIndex()));
}
});
sizeCombo.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
String key = getSelectedKey(fgCategoryTable);
store.putValue(key + PreferenceConstants.SIZE, FontSize.nameOf(sizeCombo.getSelectionIndex()));
}
});
initialize();
return topComposite;
}
use of org.eclipse.jface.util.IPropertyChangeListener in project ecf by eclipse.
the class MessagesView method createPartControl.
public void createPartControl(Composite parent) {
boolean useTraditionalTabFolder = PlatformUI.getPreferenceStore().getBoolean(IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS);
tabFolder = new CTabFolder(parent, SWT.CLOSE);
tabFolder.setTabPosition(SWT.BOTTOM);
tabFolder.setSimple(useTraditionalTabFolder);
PlatformUI.getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS) && !tabFolder.isDisposed()) {
tabFolder.setSimple(((Boolean) event.getNewValue()).booleanValue());
tabFolder.redraw();
}
}
});
tabFolder.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
Iterator it = tabs.values().iterator();
while (it.hasNext()) {
ChatTab tab = (ChatTab) it.next();
if (tab.item == e.item) {
tab.inputText.setFocus();
break;
}
}
}
});
tabFolder.addCTabFolder2Listener(new CTabFolder2Adapter() {
public void close(CTabFolderEvent e) {
Iterator it = tabs.keySet().iterator();
while (it.hasNext()) {
Object key = it.next();
ChatTab tab = (ChatTab) tabs.get(key);
if (tab.item == e.item) {
tabs.remove(key);
break;
}
}
}
});
IMenuManager manager = getViewSite().getActionBars().getMenuManager();
IAction timestampAction = new Action(Messages.MessagesView_ShowTimestamps, IAction.AS_CHECK_BOX) {
public void run() {
showTimestamps = !showTimestamps;
}
};
timestampAction.setChecked(true);
IAction clearChatLogAction = new Action(Messages.MessagesView_ClearChatLog) {
public void run() {
CTabItem item = tabFolder.getSelection();
if (item != null) {
Iterator iterator = tabs.values().iterator();
while (iterator.hasNext()) {
ChatTab tab = (ChatTab) iterator.next();
if (tab.item == item) {
if (MessageDialog.openConfirm(tabFolder.getShell(), Messages.MessagesView_ClearChatLogDialogTitle, Messages.MessagesView_ClearChatLogDialogMessage)) {
synchronized (tab) {
// $NON-NLS-1$
tab.chatText.setText("");
}
}
return;
}
}
}
}
};
manager.add(clearChatLogAction);
manager.add(timestampAction);
redColor = new Color(parent.getDisplay(), 255, 0, 0);
blueColor = new Color(parent.getDisplay(), 0, 0, 255);
}
use of org.eclipse.jface.util.IPropertyChangeListener in project InformationSystem by ObeoNetwork.
the class ExportAsSQLScriptsAction method setActiveEditor.
@Override
public void setActiveEditor(final IAction action, final IEditorPart activeEditor) {
this.activeEditor = activeEditor;
editorPluginAction = action;
action.setEnabled(false);
if (activeEditor != null && activeEditor.getEditorSite() != null && COMPARE_EDITOR_ID.equals(activeEditor.getEditorSite().getId())) {
final IEditorInput editorInput = activeEditor.getEditorInput();
if (editorInput instanceof CompareEditorInput) {
final CompareConfiguration config = ((CompareEditorInput) editorInput).getCompareConfiguration();
if (propertyChangeListener == null) {
propertyChangeListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
// FIX for EMFCompare 2.2
if (isInitEventBus(event) && eventBusChangeRecorder == null) {
eventBusChangeRecorder = new EventBusChangeRecorder();
((EventBus) event.getNewValue()).register(eventBusChangeRecorder);
}
}
};
config.addPropertyChangeListener(propertyChangeListener);
}
if (comparison != null) {
editorPluginAction.setEnabled(areDatabaseDifferences(comparison));
}
}
}
}
use of org.eclipse.jface.util.IPropertyChangeListener in project titan.EclipsePlug-ins by eclipse.
the class ProjectNamingConventionPropertyPage method createFieldEditors.
@Override
protected void createFieldEditors() {
final Composite tempParent = getFieldEditorParent();
configurationManager = new ConfigurationManagerControl(tempParent, (IProject) getElement());
configurationManager.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
if (configurationManager.hasConfigurationChanged()) {
changeConfiguration(configurationManager.getActualSelection());
}
}
});
firstConfiguration = configurationManager.getActualSelection();
BooleanFieldEditor booleanedit = new BooleanFieldEditor(PreferenceConstants.ENABLEPROJECTSPECIFICNAMINGCONVENTIONS, ENABLEPROJECTSPECIFIC, tempParent);
booleanedit.setPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent event) {
setChanged(true);
}
});
addField(booleanedit);
createNamingConventionBody(tempParent);
}
Aggregations