use of org.eclipse.swt.widgets.Listener in project cubrid-manager by CUBRID.
the class RenameConnectionDialog method createDialogArea.
/**
* @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
* @param parent The parent composite to contain the dialog area
* @return the dialog area control
*/
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 = 3;
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);
Label label1 = new Label(composite, SWT.LEFT);
label1.setText(Messages.lblName);
GridData data = new GridData();
data.widthHint = 60;
data.horizontalSpan = 1;
data.verticalSpan = 1;
label1.setLayoutData(data);
newNameText = new Text(composite, SWT.BORDER);
data = new GridData();
data.horizontalSpan = 2;
data.verticalSpan = 1;
data.grabExcessHorizontalSpace = true;
data.verticalAlignment = GridData.FILL;
data.horizontalAlignment = GridData.FILL;
newNameText.setLayoutData(data);
newNameText.setText(database.getName());
newNameText.selectAll();
newNameText.setFocus();
newNameText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
setErrorMessage(null);
getButton(IDialogConstants.OK_ID).setEnabled(false);
if (!valid()) {
return;
}
getButton(IDialogConstants.OK_ID).setEnabled(true);
}
});
newNameText.addListener(SWT.KeyDown, new Listener() {
public void handleEvent(Event e) {
if (e.type == SWT.KeyDown && e.character == SWT.CR) {
buttonPressed(IDialogConstants.OK_ID);
}
}
});
setTitle(Messages.bind(Messages.renameMSGTitle, database.getName()));
setMessage(Messages.bind(Messages.renameDialogMSG, database.getName()));
return parent;
}
use of org.eclipse.swt.widgets.Listener in project bndtools by bndtools.
the class NewWrappingBndFileWizardPage method createAdvancedControls.
@Override
protected void createAdvancedControls(Composite parent) {
// Override the existing advanced controls
Composite composite = new Composite(parent, SWT.NONE);
new Label(composite, SWT.NONE).setText(Messages.NewWrappingBndFileWizardPage_labelBSN);
txtBSN = new Text(composite, SWT.BORDER);
new Label(composite, SWT.NONE).setText(Messages.NewWrappingBndFileWizardPage_labelVersion);
txtVersion = new Text(composite, SWT.BORDER);
txtBSN.setText(bsn);
txtVersion.setText(version.toString());
txtBSN.addListener(SWT.Modify, new Listener() {
public void handleEvent(Event event) {
bsn = txtBSN.getText();
getContainer().updateButtons();
getContainer().updateMessage();
}
});
txtVersion.addListener(SWT.Modify, new Listener() {
public void handleEvent(Event event) {
try {
version = Version.parseVersion(txtVersion.getText());
error = null;
} catch (IllegalArgumentException e) {
version = null;
error = Messages.NewWrappingBndFileWizardPage_errorInvalidVersion;
}
getContainer().updateButtons();
getContainer().updateMessage();
}
});
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
GridLayout layout = new GridLayout(2, false);
layout.marginWidth = 0;
layout.marginHeight = 0;
composite.setLayout(layout);
txtBSN.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
txtVersion.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
super.createAdvancedControls(parent);
}
use of org.eclipse.swt.widgets.Listener in project bndtools by bndtools.
the class ProjectLaunchTabPiece method createControl.
@Override
@SuppressWarnings("unused")
public Control createControl(Composite parent) {
Group projectGroup = new Group(parent, SWT.NONE);
projectGroup.setText("Launch:");
launchTargetTxt = new Text(projectGroup, SWT.BORDER);
Button projectNameBrowseBtn = new Button(projectGroup, SWT.PUSH);
projectNameBrowseBtn.setText("Browse Projects");
// Spacer
new Label(projectGroup, SWT.NONE);
Button bndrunBrowseBtn = new Button(projectGroup, SWT.PUSH);
bndrunBrowseBtn.setText("Browse Run Files");
enableTraceBtn = new Button(projectGroup, SWT.CHECK);
enableTraceBtn.setText("Enable launcher tracing.");
// LISTENERS
projectNameBrowseBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doBrowseProject();
}
});
bndrunBrowseBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doBrowseBndrun();
}
});
launchTargetTxt.addListener(SWT.Modify, new Listener() {
@Override
public void handleEvent(Event event) {
String oldName = targetName;
targetName = launchTargetTxt.getText();
setDirty(true);
firePropertyChange(PROP_LAUNCH_TARGET, oldName, targetName);
}
});
enableTraceBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean oldValue = enableTrace;
enableTrace = enableTraceBtn.getSelection();
setDirty(true);
firePropertyChange(PROP_ENABLE_TRACE, oldValue, enableTrace);
}
});
// LAYOUT
GridLayout layout = new GridLayout(2, false);
layout.verticalSpacing = 0;
layout.horizontalSpacing = 0;
projectGroup.setLayout(layout);
launchTargetTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
projectNameBrowseBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
bndrunBrowseBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
return projectGroup;
}
use of org.eclipse.swt.widgets.Listener in project azure-tools-for-java by Microsoft.
the class DropDownHandler method pullDropdown.
public void pullDropdown(Event event) {
Widget widget = event.widget;
if (widget instanceof ToolItem) {
ToolItem toolItem = (ToolItem) widget;
Listener[] listeners = toolItem.getListeners(SWT.Selection);
if (listeners.length > 0) {
Listener listener = listeners[0];
Event eve = new Event();
eve.type = SWT.Selection;
eve.widget = toolItem;
eve.detail = SWT.DROP_DOWN;
eve.x = toolItem.getBounds().x;
eve.y = toolItem.getBounds().height;
listener.handleEvent(eve);
}
}
}
use of org.eclipse.swt.widgets.Listener in project eclipse.platform.text by eclipse.
the class AbstractTextEditor method createPartControl.
/**
* The <code>AbstractTextEditor</code> implementation of this
* <code>IWorkbenchPart</code> method creates the vertical ruler and
* source viewer.
* <p>
* Subclasses may extend this method. Besides extending this method, the
* behavior of <code>createPartControl</code> may be customized by
* calling, extending or replacing the following methods: <br>
* Subclasses may supply customized implementations for some members using
* the following methods before <code>createPartControl</code> is invoked:
* <ul>
* <li>
* {@linkplain #setSourceViewerConfiguration(SourceViewerConfiguration) setSourceViewerConfiguration}
* to supply a custom source viewer configuration,</li>
* <li>{@linkplain #setRangeIndicator(Annotation) setRangeIndicator} to
* provide a range indicator,</li>
* <li>{@linkplain #setHelpContextId(String) setHelpContextId} to provide a
* help context id,</li>
* <li>{@linkplain #setEditorContextMenuId(String) setEditorContextMenuId}
* to set a custom context menu id,</li>
* <li>{@linkplain #setRulerContextMenuId(String) setRulerContextMenuId} to
* set a custom ruler context menu id.</li>
* </ul>
* <br>
* Subclasses may replace the following methods called from within
* <code>createPartControl</code>:
* <ul>
* <li>{@linkplain #createVerticalRuler() createVerticalRuler} to supply a
* custom vertical ruler,</li>
* <li>{@linkplain #createSourceViewer(Composite, IVerticalRuler, int) createSourceViewer}
* to supply a custom source viewer,</li>
* <li>{@linkplain #getSelectionProvider() getSelectionProvider} to supply
* a custom selection provider.</li>
* </ul>
* <br>
* Subclasses may extend the following methods called from within
* <code>createPartControl</code>:
* <ul>
* <li>
* {@linkplain #initializeViewerColors(ISourceViewer) initializeViewerColors}
* to customize the viewer color scheme (may also be replaced),</li>
* <li>
* {@linkplain #initializeDragAndDrop(ISourceViewer) initializeDragAndDrop}
* to customize drag and drop (may also be replaced),</li>
* <li>{@linkplain #createNavigationActions() createNavigationActions} to
* add navigation actions,</li>
* <li>{@linkplain #createActions() createActions} to add text editor
* actions.</li>
* </ul>
* </p>
*
* @param parent the parent composite
*/
@Override
public void createPartControl(Composite parent) {
fVerticalRuler = createVerticalRuler();
int styles = SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION;
fSourceViewer = createSourceViewer(parent, fVerticalRuler, styles);
if (fConfiguration == null)
fConfiguration = new SourceViewerConfiguration();
fSourceViewer.configure(fConfiguration);
if (fSourceViewer instanceof ISourceViewerExtension4)
fKeyBindingSupportForContentAssistant = new KeyBindingSupportForAssistant(((ISourceViewerExtension4) fSourceViewer));
if (fSourceViewer instanceof ISourceViewerExtension3) {
IQuickAssistAssistant assistant = ((ISourceViewerExtension3) fSourceViewer).getQuickAssistAssistant();
if (assistant != null)
fKeyBindingSupportForQuickAssistant = new KeyBindingSupportForAssistant(assistant);
}
if (fRangeIndicator != null)
fSourceViewer.setRangeIndicator(fRangeIndicator);
fSourceViewer.addTextListener(fTextListener);
fSourceViewer.addTextInputListener(fTextListener);
getSelectionProvider().addSelectionChangedListener(getSelectionChangedListener());
initializeViewerFont(fSourceViewer);
initializeViewerColors(fSourceViewer);
initializeFindScopeColor(fSourceViewer);
initializeDragAndDrop(fSourceViewer);
StyledText styledText = fSourceViewer.getTextWidget();
styledText.addMouseListener(getCursorListener());
styledText.addKeyListener(getCursorListener());
// Disable orientation switching until we fully support it.
styledText.addListener(SWT.OrientationChange, new Listener() {
@Override
public void handleEvent(Event event) {
event.doit = false;
}
});
if (getHelpContextId() != null)
PlatformUI.getWorkbench().getHelpSystem().setHelp(styledText, getHelpContextId());
String id = fEditorContextMenuId != null ? fEditorContextMenuId : DEFAULT_EDITOR_CONTEXT_MENU_ID;
MenuManager manager = new MenuManager(id, id);
manager.setRemoveAllWhenShown(true);
manager.addMenuListener(getContextMenuListener());
fTextContextMenu = manager.createContextMenu(styledText);
styledText.setMenu(fTextContextMenu);
if (fEditorContextMenuId != null)
getEditorSite().registerContextMenu(fEditorContextMenuId, manager, getSelectionProvider(), isEditorInputIncludedInContextMenu());
else if (fCompatibilityMode)
getEditorSite().registerContextMenu(DEFAULT_EDITOR_CONTEXT_MENU_ID, manager, getSelectionProvider(), isEditorInputIncludedInContextMenu());
if ((fEditorContextMenuId != null && fCompatibilityMode) || fEditorContextMenuId == null) {
String partId = getEditorSite().getId();
if (partId != null)
// $NON-NLS-1$
getEditorSite().registerContextMenu(partId + ".EditorContext", manager, getSelectionProvider(), isEditorInputIncludedInContextMenu());
}
getEditorSite().registerContextMenu(COMMON_EDITOR_CONTEXT_MENU_ID, manager, getSelectionProvider(), false);
if (fEditorContextMenuId == null)
fEditorContextMenuId = DEFAULT_EDITOR_CONTEXT_MENU_ID;
id = fRulerContextMenuId != null ? fRulerContextMenuId : DEFAULT_RULER_CONTEXT_MENU_ID;
manager = new MenuManager(id, id);
manager.setRemoveAllWhenShown(true);
manager.addMenuListener(getContextMenuListener());
Control rulerControl = fVerticalRuler.getControl();
fRulerContextMenu = manager.createContextMenu(rulerControl);
rulerControl.setMenu(fRulerContextMenu);
rulerControl.addMouseListener(getRulerMouseListener());
if (fRulerContextMenuId != null)
getEditorSite().registerContextMenu(fRulerContextMenuId, manager, getSelectionProvider(), false);
else if (fCompatibilityMode)
getEditorSite().registerContextMenu(DEFAULT_RULER_CONTEXT_MENU_ID, manager, getSelectionProvider(), false);
if ((fRulerContextMenuId != null && fCompatibilityMode) || fRulerContextMenuId == null) {
String partId = getSite().getId();
if (partId != null)
// $NON-NLS-1$
getEditorSite().registerContextMenu(partId + ".RulerContext", manager, getSelectionProvider(), false);
}
getEditorSite().registerContextMenu(COMMON_RULER_CONTEXT_MENU_ID, manager, getSelectionProvider(), false);
if (fRulerContextMenuId == null)
fRulerContextMenuId = DEFAULT_RULER_CONTEXT_MENU_ID;
initializeZoomGestures(rulerControl, fSourceViewer);
getSite().setSelectionProvider(getSelectionProvider());
fSelectionListener = new SelectionListener();
fSelectionListener.install(getSelectionProvider());
fSelectionListener.setDocument(getDocumentProvider().getDocument(getEditorInput()));
initializeActivationCodeTrigger();
createNavigationActions();
createAccessibilityActions();
createActions();
initializeSourceViewer(getEditorInput());
/* since 3.2 - undo redo actions should be created after
* the source viewer is initialized, so that the undo manager
* can obtain its undo context from its document.
*/
createUndoRedoActions();
JFaceResources.getFontRegistry().addListener(fFontPropertyChangeListener);
IVerticalRuler ruler = getVerticalRuler();
if (ruler instanceof CompositeRuler)
updateContributedRulerColumns((CompositeRuler) ruler);
if (isWordWrapSupported()) {
setWordWrap(getInitialWordWrapStatus());
}
}
Aggregations