Java Code Examples for org.eclipse.swt.SWT
The following examples show how to use
org.eclipse.swt.SWT. These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: bonita-studio Source File: BonitaContentProposalAdapter.java License: GNU General Public License v2.0 | 6 votes |
void installListeners() { // Listeners on this popup's table and scroll bar proposalTable.addListener(SWT.FocusOut, this); final ScrollBar scrollbar = proposalTable.getVerticalBar(); if (scrollbar != null) { scrollbar.addListener(SWT.Selection, this); } // Listeners on this popup's shell getShell().addListener(SWT.Deactivate, this); getShell().addListener(SWT.Close, this); // Listeners on the target control control.addListener(SWT.MouseDoubleClick, this); control.addListener(SWT.MouseDown, this); control.addListener(SWT.Dispose, this); control.addListener(SWT.FocusOut, this); // Listeners on the target control's shell final Shell controlShell = control.getShell(); controlShell.addListener(SWT.Move, this); controlShell.addListener(SWT.Resize, this); }
Example 2
Source Project: hop Source File: PipelineRunConfigurationDialog.java License: Apache License 2.0 | 6 votes |
private void addGuiCompositeWidgets() { // Remove existing children // for ( Control child : wPluginSpecificComp.getChildren() ) { child.removeListener( SWT.DefaultSelection, okListener ); child.dispose(); } if ( workingConfiguration.getEngineRunConfiguration() != null ) { guiCompositeWidgets = new GuiCompositeWidgets( runConfiguration, 25 ); guiCompositeWidgets.createCompositeWidgets( workingConfiguration.getEngineRunConfiguration(), null, wPluginSpecificComp, PipelineRunConfiguration.GUI_PLUGIN_ELEMENT_PARENT_ID, null ); for ( Control control : guiCompositeWidgets.getWidgetsMap().values() ) { control.addListener( SWT.DefaultSelection, okListener ); } } }
Example 3
Source Project: translationstudio8 Source File: WaitDialog.java License: GNU General Public License v2.0 | 6 votes |
@Override protected Control createContents(Composite parent) { centerDialogOnScreen(getShell()); Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(2, false)); composite.setLayoutData(new GridData(CENTER, CENTER, true, true)); composite.setRedraw(true); Label imgLabel = new Label(composite, SWT.NONE); imgLabel.setImage(iconImage); textLabel = new Label(composite, SWT.NONE); textLabel.setLayoutData(new GridData(CENTER, CENTER, true, true)); textLabel.setFont(GUIHelper.getFont(new FontData("Arial", 9, SWT.BOLD))); textLabel.setRedraw(true); textLabel.setText(msg); return composite; }
Example 4
Source Project: olca-app Source File: ParameterSection.java License: Mozilla Public License 2.0 | 6 votes |
private void createComponents(Composite body, FormToolkit toolkit) { String title = forInputParameters ? M.InputParameters : M.DependentParameters; Section section = UI.section(body, toolkit, title); UI.gridData(section, true, true); Composite parent = UI.sectionClient(section, toolkit, 1); table = Tables.createViewer(parent, columns()); ParameterLabelProvider label = new ParameterLabelProvider(); table.setLabelProvider(label); addSorters(table, label); bindActions(section); Tables.bindColumnWidths(table, 0.3, 0.3, 0.2, 0.17, 0.03); int col = forInputParameters ? 1 : 2; table.getTable().getColumns()[col].setAlignment(SWT.RIGHT); Tables.onDoubleClick(table, e -> { var item = Tables.getItem(table, e); if (item == null) { onAdd(); } }); }
Example 5
Source Project: translationstudio8 Source File: MenuItemProviders.java License: GNU General Public License v2.0 | 6 votes |
public static IMenuItemProvider renameColumnMenuItemProvider(final String label) { return new IMenuItemProvider() { public void addMenuItem(final NatTable natTable, final Menu popupMenu) { MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH); menuItem.setText(label); menuItem.setEnabled(true); menuItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { natTable.doCommand(new DisplayColumnRenameDialogCommand(natTable, getNatEventData(event).getColumnPosition())); } }); } }; }
Example 6
Source Project: pentaho-kettle Source File: EditRowsDialog.java License: Apache License 2.0 | 6 votes |
public EditRowsDialog( Shell parent, int style, String title, String message, RowMetaInterface rowMeta, List<Object[]> rowBuffer ) { this.title = title; this.message = message; this.rowBuffer = rowBuffer; this.rowMeta = rowMeta; this.parentShell = parent; this.style = ( style != SWT.None ) ? style : this.style; props = PropsUI.getInstance(); bounds = null; hscroll = -1; vscroll = -1; title = null; message = null; this.log = LogChannel.GENERAL; }
Example 7
Source Project: translationstudio8 Source File: MenuItemProviders.java License: GNU General Public License v2.0 | 6 votes |
public static IMenuItemProvider hideColumnMenuItemProvider() { return new IMenuItemProvider() { public void addMenuItem(final NatTable natTable, final Menu popupMenu) { MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH); menuItem.setText("Hide column"); menuItem.setImage(GUIHelper.getImage("hide_column")); menuItem.setEnabled(true); menuItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { int columnPosition = getNatEventData(event).getColumnPosition(); natTable.doCommand(new ColumnHideCommand(natTable, columnPosition)); } }); } }; }
Example 8
Source Project: bonita-studio Source File: ContractInputTypeCellLabelProvider.java License: GNU General Public License v2.0 | 6 votes |
@Override public void update(ViewerCell cell) { super.update(cell); final ContractInput element = (ContractInput) cell.getElement(); final String text = getText(element); final StyledString styledString = new StyledString(text, new StyledString.Styler() { @Override public void applyStyles(TextStyle textStyle) { if (element.getType() == ContractInputType.DATE) { textStyle.foreground = Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY); } } }); cell.setText(styledString.getString()); cell.setStyleRanges(styledString.getStyleRanges()); }
Example 9
Source Project: nebula Source File: AbstractPictureControl.java License: Eclipse Public License 2.0 | 6 votes |
/** * Create the SWT {@link Label} to host the image picture. * * @param parent * a composite control which will be the parent of the new * instance (cannot be null) * @param style * the style of control to construct * @return */ protected Label createLabelImage(Composite parent, int style) { // Create a Label Label label = createLabel(parent, style); // Create SWT GridData. the size is managed with maxImageWidth and // maxImageHeight pictureLabelImageGridData = new GridData(); pictureLabelImageGridData.horizontalAlignment = SWT.CENTER; pictureLabelImageGridData.verticalAlignment = SWT.CENTER; pictureLabelImageGridData.horizontalSpan = 2; label.setLayoutData(pictureLabelImageGridData); setMaxImageWidth(maxImageWidth); setMaxImageHeight(maxImageHeight); // Create a menu with "Delete", "Modify" Item. Menu menu = createMenu(label); if (menu != null) { label.setMenu(menu); } return label; }
Example 10
Source Project: elexis-3-core Source File: ContactSorterSwitcher.java License: Eclipse Public License 1.0 | 6 votes |
@Override public void fill(Menu menu, int index){ for (final ContactSelectorViewerComparator.sorter sortMethod : ContactSelectorViewerComparator.sorter .values()) { MenuItem temp = new MenuItem(menu, SWT.CHECK, index); temp.setData(sortMethod); temp.setText(sortMethod.label); temp.setSelection(ContactSelectorViewerComparator.getSelectedSorter() .equals(sortMethod)); temp.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e){ ContactSelectorViewerComparator.setSelectedSorter(sortMethod); } }); } }
Example 11
Source Project: Eclipse-Postfix-Code-Completion Source File: ConvertAnonymousToNestedWizard.java License: Eclipse Public License 1.0 | 6 votes |
private Text addFieldNameField(Composite result) { Label nameLabel= new Label(result, SWT.NONE); nameLabel.setText(RefactoringMessages.ConvertAnonymousToNestedInputPage_class_name); nameLabel.setLayoutData(new GridData()); final Text classNameField= new Text(result, SWT.BORDER | SWT.SINGLE); classNameField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); classNameField.addModifyListener(new ModifyListener(){ public void modifyText(ModifyEvent e) { ConvertAnonymousToNestedInputPage.this.getConvertRefactoring().setClassName(classNameField.getText()); ConvertAnonymousToNestedInputPage.this.updateStatus(); } }); TextFieldNavigationHandler.install(classNameField); return classNameField; }
Example 12
Source Project: typescript.java Source File: FormatterConfigurationBlock.java License: MIT License | 6 votes |
@Override protected Composite createUI(Composite parent) { final ScrolledPageContent pageContent = new ScrolledPageContent(parent); Composite composite = pageContent.getBody(); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; composite.setLayout(layout); controlsComposite = new Composite(composite, SWT.NONE); controlsComposite.setFont(composite.getFont()); controlsComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false)); layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; layout.numColumns = 1; controlsComposite.setLayout(layout); // editor options createEditorOptions(controlsComposite); // format options createFormatOptions(controlsComposite); return pageContent; }
Example 13
Source Project: nebula Source File: Gallery.java License: Eclipse Public License 2.0 | 6 votes |
/** * Returns the index of a GalleryItem when it is a root Item * * @param parentItem * @param item * @return */ protected int _indexOf(GalleryItem item) { int itemCount = getItemCount(); if (item == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (1 <= lastIndexOf && lastIndexOf < itemCount - 1) { if (items[lastIndexOf] == item) return lastIndexOf; if (items[lastIndexOf + 1] == item) return ++lastIndexOf; if (items[lastIndexOf - 1] == item) return --lastIndexOf; } if (lastIndexOf < itemCount / 2) { for (int i = 0; i < itemCount; i++) { if (items[i] == item) return lastIndexOf = i; } } else { for (int i = itemCount - 1; i >= 0; --i) { if (items[i] == item) return lastIndexOf = i; } } return -1; }
Example 14
Source Project: birt Source File: ResultSetColumnPage.java License: Eclipse Public License 1.0 | 6 votes |
protected void buttonPressed( int buttonId ) { ResultSetColumnModel model = getSelectedColumn( ); int index = columnList.indexOf( model ); columnList.remove( index ); switch ( buttonId ) { case SWT.UP : columnList.add( index - 1, model ); break; case SWT.DOWN : columnList.add( index + 1, model ); break; } updateTable( ); updateButtons( ); }
Example 15
Source Project: BiglyBT Source File: SWTSkin.java License: GNU General Public License v2.0 | 6 votes |
protected static Listener getHandCursorListener(Display display) { if (handCursorListener == null) { handCursor = new Cursor(display, SWT.CURSOR_HAND); handCursorListener = new Listener() { @Override public void handleEvent(Event event) { if (event.type == SWT.MouseEnter) { ((Control) event.widget).setCursor(handCursor); } if (event.type == SWT.MouseExit) { ((Control) event.widget).setCursor(null); } } }; } return handCursorListener; }
Example 16
Source Project: nebula Source File: StringFormatterSnippet1.java License: Eclipse Public License 2.0 | 6 votes |
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout()); shell.setSize(300, 200); FormattedText text = new FormattedText(shell, SWT.BORDER); text.setFormatter(new StringFormatter()); GridData data = new GridData(); data.widthHint = 200; text.getControl().setLayoutData(data); shell.open(); while ( ! shell.isDisposed() ) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
Example 17
Source Project: APICloud-Studio Source File: UnmanageAction.java License: GNU General Public License v3.0 | 6 votes |
protected Control createCustomArea(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout()); radio1 = new Button(composite, SWT.RADIO); radio1.addSelectionListener(selectionListener); radio1.setText(Policy.bind("Unmanage.option2")); //$NON-NLS-1$ radio2 = new Button(composite, SWT.RADIO); radio2.addSelectionListener(selectionListener); radio2.setText(Policy.bind("Unmanage.option1")); //$NON-NLS-1$ // set initial state radio1.setSelection(deleteContent); radio2.setSelection(!deleteContent); PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.DISCONNECT_ACTION); return composite; }
Example 18
Source Project: Eclipse-Postfix-Code-Completion Source File: MoveInnerToTopWizard.java License: Eclipse Public License 1.0 | 6 votes |
public void createControl(Composite parent) { initializeDialogUnits(parent); Composite newControl= new Composite(parent, SWT.NONE); setControl(newControl); PlatformUI.getWorkbench().getHelpSystem().setHelp(newControl, IJavaHelpContextIds.MOVE_INNER_TO_TOP_WIZARD_PAGE); newControl.setLayout(new GridLayout()); Dialog.applyDialogFont(newControl); GridLayout layout= new GridLayout(); layout.numColumns= 2; layout.verticalSpacing= 8; newControl.setLayout(layout); addFieldNameEntry(newControl); addFinalCheckBox(newControl); if (getMoveRefactoring().isCreatingInstanceFieldPossible()) { fFinalCheckBox.setSelection(getMoveRefactoring().isInstanceFieldMarkedFinal()); fFinalCheckBox.setEnabled(true); } else { fFinalCheckBox.setSelection(false); fFinalCheckBox.setEnabled(false); } }
Example 19
Source Project: Eclipse-Postfix-Code-Completion Source File: JavaCompilerPropertyPage.java License: Eclipse Public License 1.0 | 6 votes |
@Override protected Control createContents(Composite parent) { if (!fIsValidElement) { return new Composite(parent, SWT.NONE); } Composite composite= new Composite(parent, SWT.NONE); composite.setFont(parent.getFont()); GridLayout topLayout= new GridLayout(); topLayout.marginWidth= 0; topLayout.marginHeight= 0; composite.setLayout(topLayout); fIgnoreOptionalProblemsField= new SelectionButtonDialogField(SWT.CHECK); fIgnoreOptionalProblemsField.setLabelText(PreferencesMessages.JavaCompilerPropertyPage_ignore_optional_problems_label); fIgnoreOptionalProblemsField.setSelection(isIgnoringOptionalProblems()); fIgnoreOptionalProblemsField.doFillIntoGrid(composite, 1); return composite; }
Example 20
Source Project: nebula Source File: DualList.java License: Eclipse Public License 2.0 | 6 votes |
private void deselect(final int start, final int end, final boolean shouldFireEvents) { checkWidget(); if (start > end) { SWT.error(SWT.ERROR_INVALID_RANGE); } final List<DLItem> toBeRemoved = new ArrayList<DLItem>(); for (int index = start; index <= end; index++) { if (index < 0 || index >= items.size()) { continue; } toBeRemoved.add(selection.get(index)); } for (final DLItem item : toBeRemoved) { selection.remove(item); if (shouldFireEvents) { fireSelectionEvent(item); } } if (shouldFireEvents) { fireSelectionChangeEvent(toBeRemoved); } toBeRemoved.clear(); redrawTables(); }
Example 21
Source Project: pentaho-kettle Source File: JobEntrySNMPTrapDialog.java License: Apache License 2.0 | 6 votes |
private void ok() { if ( Utils.isEmpty( wName.getText() ) ) { MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR ); mb.setText( BaseMessages.getString( PKG, "System.StepJobEntryNameMissing.Title" ) ); mb.setMessage( BaseMessages.getString( PKG, "System.JobEntryNameMissing.Msg" ) ); mb.open(); return; } jobEntry.setName( wName.getText() ); jobEntry.setPort( wPort.getText() ); jobEntry.setServerName( wServerName.getText() ); jobEntry.setOID( wOID.getText() ); jobEntry.setTimeout( wTimeout.getText() ); jobEntry.setRetry( wTimeout.getText() ); jobEntry.setComString( wComString.getText() ); jobEntry.setMessage( wMessage.getText() ); jobEntry.setTargetType( wTargetType.getText() ); jobEntry.setUser( wUser.getText() ); jobEntry.setPassPhrase( wPassphrase.getText() ); jobEntry.setEngineID( wEngineID.getText() ); dispose(); }
Example 22
Source Project: hop Source File: PrioritizeStreamsDialog.java License: Apache License 2.0 | 6 votes |
/** * Copy information from the meta-data input to the dialog fields. */ public void getData() { Table table = wFields.table; if ( input.getTransformName().length > 0 ) { table.removeAll(); } for ( int i = 0; i < input.getTransformName().length; i++ ) { TableItem ti = new TableItem( table, SWT.NONE ); ti.setText( 0, "" + ( i + 1 ) ); if ( input.getTransformName()[ i ] != null ) { ti.setText( 1, input.getTransformName()[ i ] ); } } wFields.removeEmptyRows(); wFields.setRowNums(); wFields.optWidth( true ); wTransformName.selectAll(); wTransformName.setFocus(); }
Example 23
Source Project: developer-studio Source File: WSO2UIToolkit.java License: Apache License 2.0 | 6 votes |
public static void createLine(Composite container, int columns, Integer verticalIndent, Integer horizontalIndent) { Label label = new Label(container, SWT.SEPARATOR | SWT.HORIZONTAL); if (columns != -1) { GridData gridData = new GridData(); gridData.horizontalSpan = columns; gridData.grabExcessHorizontalSpace = true; gridData.horizontalAlignment = SWT.FILL; if (verticalIndent != null) { gridData.verticalIndent = verticalIndent; } if (horizontalIndent != null) { gridData.horizontalIndent = horizontalIndent; } label.setLayoutData(gridData); } }
Example 24
Source Project: goclipse Source File: MultipleInputDialog.java License: Eclipse Public License 1.0 | 5 votes |
protected void createTextField(String labelText, String initialValue, boolean allowEmpty) { Label label = new Label(panel, SWT.NONE); label.setText(labelText); label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); final Text text = new Text(panel, SWT.SINGLE | SWT.BORDER); text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); text.setData(FIELD_NAME, labelText); // make sure rows are the same height on both panels. label.setSize(label.getSize().x, text.getSize().y); if (initialValue != null) { text.setText(initialValue); } if (!allowEmpty) { validators.add(new Validator() { @Override public boolean validate() { return !text.getText().equals(IInternalDebugCoreConstants.EMPTY_STRING); } }); text.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { validateFields(); } }); } controlList.add(text); }
Example 25
Source Project: birt Source File: AggregateEditorComposite.java License: Eclipse Public License 1.0 | 5 votes |
public AggregateEditorComposite( Composite parent, SeriesDefinition sd, ChartWizardContext context, boolean enabled, Query query ) { super( parent, SWT.NONE ); setAggregation( query, sd ); fChartContext = context; fEnabled = enabled; placeComponents( ); }
Example 26
Source Project: offspring Source File: IssueAssetWizard.java License: MIT License | 5 votes |
@Override public Control createReadonlyControl(Composite parent) { textNameReadonly = new Text(parent, SWT.BORDER); textNameReadonly.setText(""); textNameReadonly.setEditable(false); return textNameReadonly; }
Example 27
Source Project: texlipse Source File: ViewerConfigDialog.java License: Eclipse Public License 1.0 | 5 votes |
/** * Create the contents of the dialog. * @param parent parent component */ protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); GridLayout gl = (GridLayout) composite.getLayout(); gl.numColumns = 2; Label descrLabel = new Label(composite, SWT.LEFT); descrLabel.setText(TexlipsePlugin.getResourceString("preferenceViewerDescriptionLabel")); GridData dgd = new GridData(GridData.FILL_HORIZONTAL); dgd.horizontalSpan = 2; descrLabel.setLayoutData(dgd); addConfigNameField(composite); addFileBrowser(composite); addArgumentsField(composite); addDDEGroups(composite); addFormatChooser(composite); addInverseChooser(composite); addForwardChooser(composite); Group group = new Group(composite, SWT.SHADOW_IN); group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); ((GridData)group.getLayoutData()).horizontalSpan = 2; group.setLayout(new GridLayout()); statusField = new Label(group, SWT.LEFT); statusField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); statusField.setToolTipText(TexlipsePlugin.getResourceString("preferenceViewerStatusTooltip")); return composite; }
Example 28
Source Project: statecharts Source File: StatechartDefinitionSection.java License: Eclipse Public License 1.0 | 5 votes |
protected void createNameLabel(Composite labelComposite) { nameLabel = new Text(labelComposite, SWT.SINGLE | SWT.NORMAL); GridDataFactory.fillDefaults().indent(5, 1).grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(nameLabel); Optional<String> name = getStatechartName(); if (name.isPresent()) { nameLabel.setText(name.get()); } nameLabel.setEditable(isStatechart()); nameLabel.setBackground(ColorConstants.white); nameModificationListener = new ModifyListener() { @Override public void modifyText(ModifyEvent e) { Optional<Statechart> sct = getStatechart(); if (sct.isPresent()) { if (Objects.equals(sct.get().getName(), nameLabel.getText())) { return; } getSash().setRedraw(false); TransactionalEditingDomain domain = getTransactionalEditingDomain(); SetCommand command = new SetCommand(domain, sct.get(), BasePackage.Literals.NAMED_ELEMENT__NAME, nameLabel.getText()); domain.getCommandStack().execute(command); refresh(nameLabel.getParent()); getSash().setRedraw(true); } } }; nameLabel.addModifyListener(nameModificationListener); }
Example 29
Source Project: pentaho-kettle Source File: WriteToLogDialog.java License: Apache License 2.0 | 5 votes |
/** * Copy information from the meta-data input to the dialog fields. */ public void getData() { wLoglevel.select( input.getLogLevelByDesc().getLevel() ); wPrintHeader.setSelection( input.isdisplayHeader() ); wLimitRows.setSelection( input.isLimitRows() ); wLimitRowsNumber.setText( "" + input.getLimitRowsNumber() ); if ( input.getLogMessage() != null ) { wLogMessage.setText( input.getLogMessage() ); } Table table = wFields.table; if ( input.getFieldName().length > 0 ) { table.removeAll(); } for ( int i = 0; i < input.getFieldName().length; i++ ) { TableItem ti = new TableItem( table, SWT.NONE ); ti.setText( 0, "" + ( i + 1 ) ); ti.setText( 1, input.getFieldName()[i] ); } wFields.setRowNums(); wFields.optWidth( true ); wStepname.selectAll(); wStepname.setFocus(); }
Example 30
Source Project: elexis-3-core Source File: MandantSelectionContributionItem.java License: Eclipse Public License 1.0 | 5 votes |
public static Image getBoxSWTColorImage(Color color){ Display display = Display.getCurrent(); Image image = new Image(display, 16, 16); GC gc = new GC(image); gc.setBackground(color); gc.fillRoundRectangle(0, 0, 16, 16, 8, 8); gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); gc.dispose(); return image; }