use of org.eclipse.swt.events.ControlListener in project tdi-studio-se by Talend.
the class MapperUI method addParentListeners.
private void addParentListeners(final UIManager uiManager, final ExternalMapperUiProperties uiProperties) {
mapperUIParent.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
release();
}
});
mapperUIParent.addListener(SWT.Close, new Listener() {
public void handleEvent(Event event) {
if (uiManager.getMapperResponse() == SWT.NONE) {
uiManager.setMapperResponse(SWT.CANCEL);
}
}
});
mapperUIParent.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
updateBackground(false, true);
}
public void focusLost(FocusEvent e) {
}
});
// store size if not maximized
if (mapperUIParent instanceof Shell) {
((Shell) mapperUIParent).addControlListener(new ControlListener() {
public void controlMoved(ControlEvent e) {
}
public void controlResized(ControlEvent e) {
if (!((Shell) e.getSource()).getMaximized()) {
uiProperties.setBoundsMapper(((Shell) e.getSource()).getBounds());
}
}
});
}
}
use of org.eclipse.swt.events.ControlListener in project eclipse.platform.text by eclipse.
the class AbstractTemplatesPage method createPatternForm.
/**
* Setup the pattern viewer.
*
* @param parent the parent composite
*/
private void createPatternForm(Composite parent) {
ViewForm viewForm = new ViewForm(parent, SWT.NONE);
viewForm.setBorderVisible(false);
CLabel previewLabel = new CLabel(viewForm, SWT.NONE);
previewLabel.setText(TemplatesMessages.TemplatesPage_preview);
previewLabel.setImage(TemplatesPageImages.get(TemplatesPageImages.IMG_OBJ_PREVIEW));
viewForm.setTopLeft(previewLabel);
fPatternViewer = createPatternViewer(viewForm);
viewForm.setContent(fPatternViewer.getControl());
viewForm.addControlListener(new ControlListener() {
@Override
public void controlMoved(ControlEvent e) {
}
@Override
public void controlResized(ControlEvent e) {
int[] weights = fControl.getWeights();
int sashSize = (int) (weights[0] * 100.0 / (weights[0] + weights[1]));
fPreferenceStore.setValue(SASH_SIZE_PREF_ID, sashSize);
}
});
}
use of org.eclipse.swt.events.ControlListener in project eclipse.platform.text by eclipse.
the class CompletionProposalPopup2 method createProposalSelector.
/**
* Creates the proposal selector.
*/
private void createProposalSelector() {
if (Helper2.okToUse(fProposalShell))
return;
Control control = fViewer.getTextWidget();
fProposalShell = new Shell(control.getShell(), SWT.ON_TOP);
// fProposalShell= new Shell(control.getShell(), SWT.ON_TOP | SWT.RESIZE );
fProposalTable = new Table(fProposalShell, SWT.H_SCROLL | SWT.V_SCROLL);
// fProposalTable= new Table(fProposalShell, SWT.H_SCROLL | SWT.V_SCROLL);
fIsColoredLabelsSupportEnabled = fContentAssistant.isColoredLabelsSupportEnabled();
if (fIsColoredLabelsSupportEnabled)
TableOwnerDrawSupport.install(fProposalTable);
fProposalTable.setLocation(0, 0);
if (fAdditionalInfoController != null)
fAdditionalInfoController.setSizeConstraints(50, 10, true, false);
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
fProposalShell.setLayout(layout);
GridData data = new GridData(GridData.FILL_BOTH);
fProposalTable.setLayoutData(data);
fProposalShell.pack();
// set location
Point currentLocation = fProposalShell.getLocation();
Point newLocation = getLocation();
if ((newLocation.x < currentLocation.x && newLocation.y == currentLocation.y) || newLocation.y < currentLocation.y)
fProposalShell.setLocation(newLocation);
if (fAdditionalInfoController != null) {
fProposalShell.addControlListener(new ControlListener() {
@Override
public void controlMoved(ControlEvent e) {
}
@Override
public void controlResized(ControlEvent e) {
// resets the cached resize constraints
fAdditionalInfoController.setSizeConstraints(50, 10, true, false);
}
});
}
ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
Color background = colorRegistry.get(JFacePreferences.CONTENT_ASSIST_BACKGROUND_COLOR);
if (background == null) {
background = JFaceColors.getInformationViewerBackgroundColor(Display.getDefault());
}
Color foreground = colorRegistry.get(JFacePreferences.CONTENT_ASSIST_FOREGROUND_COLOR);
if (foreground == null) {
foreground = JFaceColors.getInformationViewerBackgroundColor(Display.getDefault());
}
fProposalShell.setBackground(background);
fProposalTable.setBackground(background);
fProposalTable.setForeground(foreground);
fProposalTable.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
selectProposalWithMask(e.stateMask);
}
});
fPopupCloser.install(fContentAssistant, fProposalTable);
fProposalShell.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
// but don't dispose the shell, since we're being called from its disposal event!
unregister();
}
});
fProposalTable.setHeaderVisible(false);
fContentAssistant.addToLayout(this, fProposalShell, ContentAssistant2.LayoutManager.LAYOUT_PROPOSAL_SELECTOR, fContentAssistant.getSelectionOffset());
}
use of org.eclipse.swt.events.ControlListener in project eclipse.platform.text by eclipse.
the class CompletionProposalPopup method createProposalSelector.
/**
* Creates the proposal selector.
*/
void createProposalSelector() {
if (Helper.okToUse(fProposalShell))
return;
Control control = fContentAssistSubjectControlAdapter.getControl();
fProposalShell = new Shell(control.getShell(), SWT.ON_TOP | SWT.RESIZE);
fProposalShell.setFont(JFaceResources.getDefaultFont());
fProposalTable = new Table(fProposalShell, SWT.H_SCROLL | SWT.V_SCROLL | SWT.VIRTUAL);
Listener listener = new Listener() {
@Override
public void handleEvent(Event event) {
handleSetData(event);
}
};
fProposalTable.addListener(SWT.SetData, listener);
fIsColoredLabelsSupportEnabled = fContentAssistant.isColoredLabelsSupportEnabled();
if (fIsColoredLabelsSupportEnabled)
TableOwnerDrawSupport.install(fProposalTable);
fProposalTable.setLocation(0, 0);
if (fAdditionalInfoController != null)
fAdditionalInfoController.setSizeConstraints(50, 10, true, true);
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
layout.verticalSpacing = 1;
fProposalShell.setLayout(layout);
if (fContentAssistant.isStatusLineVisible()) {
createMessageText();
}
GridData data = new GridData(GridData.FILL_BOTH);
Point size = fContentAssistant.restoreCompletionProposalPopupSize();
if (size != null) {
fProposalTable.setLayoutData(data);
fProposalShell.setSize(size);
} else {
int height = fProposalTable.getItemHeight() * 10;
// use golden ratio as default aspect ratio
final double aspectRatio = (1 + Math.sqrt(5)) / 2;
int width = (int) (height * aspectRatio);
Rectangle trim = fProposalTable.computeTrim(0, 0, width, height);
data.heightHint = trim.height;
data.widthHint = trim.width;
fProposalTable.setLayoutData(data);
fProposalShell.pack();
}
fContentAssistant.addToLayout(this, fProposalShell, ContentAssistant.LayoutManager.LAYOUT_PROPOSAL_SELECTOR, fContentAssistant.getSelectionOffset());
fProposalShell.addControlListener(new ControlListener() {
@Override
public void controlMoved(ControlEvent e) {
}
@Override
public void controlResized(ControlEvent e) {
if (fAdditionalInfoController != null) {
// reset the cached resize constraints
fAdditionalInfoController.setSizeConstraints(50, 10, true, false);
fAdditionalInfoController.hideInformationControl();
fAdditionalInfoController.handleTableSelectionChanged();
}
fSize = fProposalShell.getSize();
}
});
Color background = getBackgroundColor(control);
if (background == null) {
background = JFaceColors.getInformationViewerBackgroundColor(Display.getDefault());
}
Color foreground = getForegroundColor(control);
if (foreground == null) {
foreground = JFaceColors.getInformationViewerBackgroundColor(Display.getDefault());
}
fProposalShell.setBackground(background);
fProposalTable.setBackground(background);
fProposalTable.setForeground(foreground);
fProposalTable.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
insertSelectedProposalWithMask(e.stateMask);
}
});
fPopupCloser.install(fContentAssistant, fProposalTable, fAdditionalInfoController);
fProposalShell.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
// but don't dispose the shell, since we're being called from its disposal event!
unregister();
}
});
fProposalTable.setHeaderVisible(false);
addCommandSupport(fProposalTable);
}
use of org.eclipse.swt.events.ControlListener in project eclipse.platform.text by eclipse.
the class ContextInformationPopup method createContextSelector.
/**
* Creates the context selector in case the user has the choice between multiple valid contexts
* at a given offset.
*/
private void createContextSelector() {
if (Helper.okToUse(fContextSelectorShell))
return;
Control control = fContentAssistSubjectControlAdapter.getControl();
fContextSelectorShell = new Shell(control.getShell(), SWT.ON_TOP | SWT.RESIZE);
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
fContextSelectorShell.setLayout(layout);
fContextSelectorShell.setBackground(control.getDisplay().getSystemColor(SWT.COLOR_BLACK));
fContextSelectorShell.addControlListener(new ControlListener() {
@Override
public void controlMoved(ControlEvent e) {
}
@Override
public void controlResized(ControlEvent e) {
fContextSelectorPopupSize = fContextSelectorShell.getSize();
}
});
if (fViewer instanceof ITextViewerExtension) {
final ITextViewerExtension textViewerExtension = (ITextViewerExtension) fViewer;
final StyledText textWidget = fViewer.getTextWidget();
final VerifyKeyListener verifyListener = new VerifyKeyListener() {
@Override
public void verifyKey(VerifyEvent event) {
if (isActive() && event.keyCode == 13 && event.character == '\r' && event.widget == textWidget) {
event.doit = false;
insertSelectedContext();
hideContextSelector();
}
}
};
textViewerExtension.prependVerifyKeyListener(verifyListener);
fContextSelectorShell.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
textViewerExtension.removeVerifyKeyListener(verifyListener);
}
});
}
fContextSelectorTable = new Table(fContextSelectorShell, SWT.H_SCROLL | SWT.V_SCROLL);
fContextSelectorTable.setLocation(1, 1);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = fContextSelectorTable.getItemHeight() * 10;
gd.widthHint = 300;
fContextSelectorTable.setLayoutData(gd);
Point size = fContentAssistant.restoreContextSelectorPopupSize();
if (size != null)
fContextSelectorShell.setSize(size);
else
fContextSelectorShell.pack(true);
Color c = fContentAssistant.getContextSelectorBackground();
if (c == null)
c = control.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
fContextSelectorTable.setBackground(c);
c = fContentAssistant.getContextSelectorForeground();
if (c == null)
c = control.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND);
fContextSelectorTable.setForeground(c);
fContextSelectorTable.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
insertSelectedContext();
hideContextSelector();
}
});
fPopupCloser.install(fContentAssistant, fContextSelectorTable);
fContextSelectorTable.setHeaderVisible(false);
fContentAssistant.addToLayout(this, fContextSelectorShell, ContentAssistant.LayoutManager.LAYOUT_CONTEXT_SELECTOR, fContentAssistant.getSelectionOffset());
}
Aggregations