protected void makeStartCommandControlsVisible(StartCommandType typeToMakeVisible) { StartCommandPart part = startCommandAreas.get(typeToMakeVisible); Control areaToMakeVisible = part != null ? part.getComposite() : null; if (areaToMakeVisible != null && !areaToMakeVisible.isDisposed()) { GridData data = (GridData) areaToMakeVisible.getLayoutData(); GridDataFactory.createFrom(data).exclude(false).applyTo(areaToMakeVisible); areaToMakeVisible.setVisible(true); // Hide the other sections // If hiding, exclude from layout as to not take up space when it is // made invisible for (StartCommandType otherTypes : startCommandAreas.keySet()) { if (!otherTypes.equals(typeToMakeVisible)) { StartCommandPart otherArea = startCommandAreas.get(otherTypes); if (otherArea != null) { Control otherAreaComposite = otherArea.getComposite(); if (!otherAreaComposite.isDisposed()) { data = (GridData) otherAreaComposite.getLayoutData(); GridDataFactory.createFrom(data).exclude(true).applyTo(otherAreaComposite); otherAreaComposite.setVisible(false); } } } } // Recalculate layout areaToMakeVisible.getParent().layout(true, true); } }
public Composite createComposite(Composite parent) { Composite tableArea = new Composite(parent, SWT.NONE); GridLayoutFactory.fillDefaults().numColumns(1).equalWidth(true).applyTo(tableArea); GridDataFactory.fillDefaults().grab(true, true).applyTo(tableArea); Composite orgTableComposite = new Composite(tableArea, SWT.NONE); GridLayoutFactory.fillDefaults().numColumns(1).applyTo(orgTableComposite); GridDataFactory.fillDefaults().grab(true, true).applyTo(orgTableComposite); Label orgLabel = new Label(orgTableComposite, SWT.NONE); GridDataFactory.fillDefaults().grab(false, false).applyTo(orgLabel); orgLabel.setText("Organizations and Spaces:"); Tree orgTable = new Tree(orgTableComposite, SWT.BORDER | SWT.SINGLE); GridDataFactory.fillDefaults().grab(true, true).applyTo(orgTable); orgsSpacesViewer = new TreeViewer(orgTable); orgsSpacesViewer.setContentProvider(new TableContentProvider()); orgsSpacesViewer.setLabelProvider(new SpacesLabelProvider()); orgsSpacesViewer.setSorter(new SpacesSorter()); orgsSpacesViewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { refresh(); } }); setInput(); return tableArea; }
private void addComponents() { getWidgetLayout().numColumns = 2; getWidgetLayout().makeColumnsEqualWidth = false; getContainer().setLayout(getWidgetLayout()); CIDescriptor desc = new CIDescriptor(); desc.setClazz(Valuta.class); desc.setInput(BorgCache.getValute()); desc.setTextMethodName(Valuta.EXTERNAL_REFLECT_GET_ACRONIM); desc.setImageMethodName(Valuta.EXTERNAL_REFLECT_GET_IMAGE); desc.setToolItemStyle(ComboImage.ADD_ADD); desc.setAddContentProposal(isViewEnabled()); new Label(getContainer(), SWT.NONE).setText("Valuta"); this.comboValuta = new ComboImage(getContainer(), desc); GridDataFactory.fillDefaults() .grab(true, false) .align(SWT.FILL, SWT.CENTER) .applyTo(this.comboValuta); this.comboValuta.getItemAdd().addListener(SWT.Selection, this); this.comboValuta.getItemAdd().setToolTipText("Adaugare valuta"); desc = new CIDescriptor(); desc.setClazz(Banca.class); desc.setInput(this.mapBanci); desc.setTextMethodName(Banca.EXTERNAL_REFLECT_GET_COD); desc.setImageMethodName(Banca.EXTERNAL_REFLECT_GET_SIGLA); desc.setToolItemStyle(ComboImage.ADD_ADD); desc.setAddContentProposal(isViewEnabled()); new Label(getContainer(), SWT.NONE).setText("Banca"); this.comboBanca = new ComboImage(getContainer(), desc); GridDataFactory.fillDefaults() .grab(true, false) .align(SWT.FILL, SWT.CENTER) .applyTo(this.comboBanca); this.comboBanca.getItemAdd().addListener(SWT.Selection, this); this.comboBanca.getItemAdd().setToolTipText("Adaugare banca"); new Label(getContainer(), SWT.NONE).setText("Data"); this.textData = new Text(getContainer(), SWT.BORDER); GridDataFactory.fillDefaults() .grab(true, false) .align(SWT.FILL, SWT.CENTER) .applyTo(this.textData); this.textData.setEnabled(false); this.textData.setText(EncodeLive.getSQLDateLogin().toString()); new Label(getContainer(), SWT.NONE).setText("Curs"); this.textCurs = new FormattedText(getContainer(), SWT.BORDER); GridDataFactory.fillDefaults() .grab(true, false) .align(SWT.FILL, SWT.CENTER) .span(getWidgetLayout().numColumns - 1, 1) .applyTo(this.textCurs.getControl()); this.textCurs.setFormatter(NumberUtil.getFormatter(4, false)); ((NumberFormatter) this.textCurs.getFormatter()).setFixedLengths(false, true); WidgetCompositeUtil.addColoredFocusListener2Childrens(getContainer()); }
private void createSymbolicExecutionPart(Composite parent) { Label label = new Label(parent, SWT.NONE); label.setText("Symbolic Execution: "); this.symbolicExecutionLabel = new Label(parent, SWT.NONE); this.symbolicExecutionLabel.setText("No"); this.symbolicExecutionLabel.setLayoutData( GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create()); label = new Label(parent, SWT.NONE); label.setText("Interpretation: "); this.symbolicExecutionInterpretationLabel = new Label(parent, SWT.NONE); this.symbolicExecutionInterpretationLabel.setText("-"); this.symbolicExecutionInterpretationLabel.setLayoutData( GridDataFactory.fillDefaults().grab(true, false).create()); this.symbolicExecutionInterpretationImage = new Label(parent, SWT.NONE); this.symbolicExecutionInterpretationImage.setImage( BehavioralInferenceImages.getImage(BehavioralInferenceImages.IMG_NOT_ACCEPTED)); this.symbolicExecutionInterpretationImage.setLayoutData( GridDataFactory.fillDefaults().grab(true, false).create()); Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL); separator.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(3, 1).create()); }
private void createComposite( int style, Project project, ESModelElementIdToEObjectMapping<ESModelElementId> idToEObjectMapping, boolean showRootNodes) { setLayout(new GridLayout()); folder = new TabFolder(this, style); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(folder); tabComposite = new Composite(folder, SWT.NONE); GridLayoutFactory.fillDefaults().applyTo(tabComposite); tabTreeViewer = new TreeViewer(tabComposite, SWT.H_SCROLL | SWT.V_SCROLL); GridDataFactory.fillDefaults().grab(true, true).applyTo(tabTreeViewer.getControl()); contentProvider = new SCMContentProvider(idToEObjectMapping); contentProvider.setShowRootNodes(showRootNodes); SCMLabelProvider detailedLabelProvider = new SCMLabelProvider(project); detailedLabelProvider.setChangePackageVisualizationHelper( new ChangePackageVisualizationHelper(idToEObjectMapping)); tabTreeViewer.setContentProvider(contentProvider); tabTreeViewer.setLabelProvider(detailedLabelProvider); tabTreeViewer.expandToLevel(1); TabItem opTab = new TabItem(folder, style); opTab.setText("Operations"); opTab.setControl(tabComposite); }
private void createUI20RecentEntries(final Composite parent) { final Composite container = new Composite(parent, SWT.NONE); GridDataFactory.fillDefaults().grab(true, false).applyTo(container); GridLayoutFactory.fillDefaults().numColumns(2).applyTo(container); { /* * number of recent tour types */ final Label label = new Label(container, NONE); label.setText(Messages.Pref_Appearance_NumberOfRecent_TourTypes); label.setToolTipText(Messages.Pref_Appearance_NumberOfRecent_TourTypes_Tooltip); // spinner _spinnerRecentTourTypes = new Spinner(container, SWT.BORDER); GridDataFactory.fillDefaults() // .hint(_hintDefaultSpinnerWidth, SWT.DEFAULT) .align(SWT.BEGINNING, SWT.CENTER) .applyTo(_spinnerRecentTourTypes); _spinnerRecentTourTypes.setToolTipText( Messages.Pref_Appearance_NumberOfRecent_TourTypes_Tooltip); _spinnerRecentTourTypes.setMinimum(0); _spinnerRecentTourTypes.setMaximum(9); _spinnerRecentTourTypes.addSelectionListener(_defaultSelectionAdapter); _spinnerRecentTourTypes.addMouseWheelListener(_defaultMouseWheelListener); } }
public Shell createShell() { // Build a UI Display display = Display.getDefault(); Shell shell = new Shell(display); duckFamily = new Table(shell, SWT.BORDER | SWT.FULL_SELECTION); duckFamily.setHeaderVisible(true); GridDataFactory.defaultsFor(duckFamily).span(2, 1).applyTo(duckFamily); createColumn("Name"); createColumn("Mother"); createColumn("Father"); createColumn("Grandmother"); duckFamily.setLinesVisible(true); new Label(shell, SWT.NONE).setText("Name:"); nameText = new Text(shell, SWT.BORDER); GridDataFactory.defaultsFor(nameText).grab(true, false).applyTo(nameText); new Label(shell, SWT.NONE).setText("Mother:"); motherCombo = new Combo(shell, SWT.READ_ONLY); new Label(shell, SWT.NONE).setText("Father:"); fatherCombo = new Combo(shell, SWT.READ_ONLY); DataBindingContext bindingContext = new DataBindingContext(); bindGUI(bindingContext); GridLayoutFactory.swtDefaults().numColumns(2).applyTo(shell); // Open and return the Shell shell.setSize(500, 300); shell.open(); return shell; }
public Control createPart(Composite parent) { Composite tableArea = new Composite(parent, SWT.NONE); GridLayoutFactory.fillDefaults().numColumns(1).equalWidth(true).applyTo(tableArea); GridDataFactory.fillDefaults().grab(true, true).applyTo(tableArea); Composite orgTableComposite = new Composite(tableArea, SWT.NONE); GridLayoutFactory.fillDefaults().numColumns(1).applyTo(orgTableComposite); GridDataFactory.fillDefaults().grab(true, true).applyTo(orgTableComposite); Label orgLabel = new Label(orgTableComposite, SWT.NONE); GridDataFactory.fillDefaults().grab(false, false).applyTo(orgLabel); orgLabel.setText(Messages.CloudSpacesSelectionPart_TEXT_ORG_AND_SPACE_WITH_COLUMN); Tree orgTable = new Tree(orgTableComposite, SWT.BORDER | SWT.SINGLE); GridDataFactory.fillDefaults().grab(true, true).applyTo(orgTable); orgsSpacesViewer = new TreeViewer(orgTable); orgsSpacesViewer.setContentProvider(new TableContentProvider()); orgsSpacesViewer.setLabelProvider(new SpacesLabelProvider()); orgsSpacesViewer.setSorter(new SpacesSorter()); orgsSpacesViewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { refresh(); } }); return tableArea; }
@Override public void createPartControl(final Composite parent) { resizeAction = new Action("Resize", SWT.TOGGLE) { @Override public void run() { updatePreview(true); } }; resizeAction.setImageDescriptor( Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "/icons/resize.png")); GridLayoutFactory.fillDefaults().numColumns(2).spacing(0, 0).applyTo(parent); ToolBar toolbar = new ToolBar(parent, SWT.VERTICAL | SWT.FLAT); toolbar.setBackground(toolbar.getDisplay().getSystemColor(SWT.COLOR_GRAY)); ToolBarManager toolbarManager = new ToolBarManager(toolbar); toolbarManager.add(resizeAction); GridDataFactory.fillDefaults() .grab(false, true) .align(SWT.BEGINNING, SWT.FILL) .applyTo(toolbar); toolbarManager.update(true); container = new Composite(parent, SWT.NONE); container.setLayout(new FillLayout()); GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(container); getSite().getPage().addPartListener(trackRelevantEditorsPartListener); tryConnectTo(getSite().getPage().getActiveEditor()); }
/** * Creates the left score composite. * * @param nbCol the nb col * @param scoreData the score data * @return the composite */ private Composite createLeftScoreComposite(int nbCol, GridDataFactory scoreData) { ExpandableComposite leftScoreMain = this.toolkit.createExpandableComposite( this.body, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED | ExpandableComposite.NO_TITLE); GridLayoutFactory.fillDefaults().applyTo(leftScoreMain); Composite leftScoreBody = this.toolkit.createComposite(leftScoreMain); GridLayoutFactory.fillDefaults() .extendedMargins(0, 0, 6, 0) .numColumns(nbCol) .equalWidth(true) .applyTo(leftScoreBody); GridDataFactory.fillDefaults().grab(true, true).applyTo(leftScoreBody); Composite cmpPlayerLeftScore; for (IPlayer player : this.game.getPlayers()) { cmpPlayerLeftScore = this.createPlayerScoreLeftComposite(leftScoreBody, player); scoreData.copy().applyTo(cmpPlayerLeftScore); } this.toolkit.paintBordersFor(leftScoreBody); leftScoreMain.setClient(leftScoreBody); leftScoreMain.addExpansionListener(this); return leftScoreMain; }
private void createTableViewer(final Composite parent) { mainComposite = new Composite(parent, SWT.NONE); mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); gridLayout = new GridLayout(1, false); mainComposite.setLayout(gridLayout); viewer = new TableViewer(mainComposite, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL); final TableLayout layout = new TableLayout(); layout.addColumnData(new ColumnWeightData(100, false)); viewer.getTable().setLayout(layout); viewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); final TableViewerColumn columnViewer = new TableViewerColumn(viewer, SWT.NONE); final TableColumn column = columnViewer.getColumn(); column.setText(Messages.name); final TableColumnSorter sorter = new TableColumnSorter(viewer); sorter.setColumn(column); viewer.getTable().setHeaderVisible(true); viewer.setContentProvider(new ArrayContentProvider()); viewer.setLabelProvider(new ParameterNameLabelProvider()); viewer.addPostSelectionChangedListener( new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { if (!event.getSelection().isEmpty()) { ParameterEditor.this.fireSelectionChanged(); } } }); }
protected Control createInputExpressionComposite( Section section, TabbedPropertySheetWidgetFactory widgetFactory) { final Composite client = widgetFactory.createComposite(section); client.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); client.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).create()); inputExpressionViewer = new ExpressionViewer( client, SWT.BORDER, widgetFactory, editingDomain, FormPackage.Literals.WIDGET__INPUT_EXPRESSION); inputExpressionViewer.addFilter( new AvailableExpressionTypeFilter( new String[] { ExpressionConstants.VARIABLE_TYPE, ExpressionConstants.SCRIPT_TYPE, ExpressionConstants.CONSTANT_TYPE, ExpressionConstants.DOCUMENT_REF_TYPE, ExpressionConstants.PARAMETER_TYPE })); inputExpressionViewer.setMessage(getInputExpressionHint(), IStatus.INFO); inputExpressionViewer .getControl() .setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); return client; }
protected Control createResourceComposite( Section section, TabbedPropertySheetWidgetFactory widgetFactory) { final Composite client = widgetFactory.createComposite(section); client.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); client.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0).create()); resourceText = widgetFactory.createText(client, ""); resourceText.setLayoutData( GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).create()); final ControlDecoration cd = new ControlDecoration(resourceText, SWT.LEFT); cd.setImage(Pics.getImage(PicsConstants.hint)); cd.setDescriptionText(Messages.filewidget_resource_hint); final Button browseResourceButton = widgetFactory.createButton(client, Messages.Browse, SWT.PUSH); browseResourceButton.setLayoutData(GridDataFactory.fillDefaults().create()); browseResourceButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { final SelectDocumentInBonitaStudioRepository selectDocumentInBonitaStudioRepository = new SelectDocumentInBonitaStudioRepository(Display.getDefault().getActiveShell()); if (IDialogConstants.OK_ID == selectDocumentInBonitaStudioRepository.open()) { resourceText.setText( selectDocumentInBonitaStudioRepository.getSelectedDocument().getName()); } } }); return client; }
@SuppressWarnings("unchecked") private IObservableValue<String> createImageSelectionControls(final Composite container) { final Label nameLabel = new Label(container, SWT.NULL); nameLabel.setText(WizardMessages.getString("ImagePullPushPage.name.label")); // $NON-NLS-1$ GridDataFactory.fillDefaults() .align(SWT.FILL, SWT.CENTER) .grab(false, false) .applyTo(nameLabel); final Combo imageNameCombo = new Combo(container, SWT.DROP_DOWN); imageNameCombo.setToolTipText(WizardMessages.getString("ImagePushName.toolTip")); // $NON-NLS-1$ GridDataFactory.fillDefaults() .align(SWT.FILL, SWT.CENTER) .grab(true, false) .applyTo(imageNameCombo); final ComboViewer imageNameComboViewer = new ComboViewer(imageNameCombo); imageNameComboViewer.setContentProvider(new ArrayContentProvider()); imageNameComboViewer.setInput(getModel().getImage().repoTags()); // binding must take place after the input is set, so that default // repo/name can be selected. final IObservableValue<String> imageNameObservable = BeanProperties.value(ImagePushPageModel.class, ImagePullPushPageModel.SELECTED_IMAGE_NAME) .observe(getModel()); dbc.bindValue(WidgetProperties.selection().observe(imageNameCombo), imageNameObservable); // filler for the last column GridDataFactory.fillDefaults() .align(SWT.FILL, SWT.CENTER) .grab(false, false) .applyTo(new Label(container, SWT.NONE)); return imageNameObservable; }
private void createUI22SmoothGradient(final Composite parent) { /* * image: gradient */ _iconGradient = new CLabel(parent, SWT.NONE); GridDataFactory.fillDefaults().indent(16, 0).applyTo(_iconGradient); _iconGradient.setBackground(_tk.getColors().getBackground()); _iconGradient.setImage(_imageGradient); /* * label: smooth gradient */ final Label label = _tk.createLabel(parent, Messages.TourChart_Smoothing_Label_GradientSmoothing, SWT.CHECK); GridDataFactory.fillDefaults() // .align(SWT.FILL, SWT.CENTER) .applyTo(label); label.setToolTipText(Messages.TourChart_Smoothing_Label_GradientSmoothing_Tooltip); /* * spinner: gradient tau */ _spinnerGradientTau = new Spinner(parent, SWT.BORDER); GridDataFactory.fillDefaults() // .align(SWT.BEGINNING, SWT.FILL) .applyTo(_spinnerGradientTau); _spinnerGradientTau.setDigits(1); _spinnerGradientTau.setMinimum(1); _spinnerGradientTau.setMaximum(MAX_TAU); _spinnerGradientTau.addSelectionListener(_selectionListener); _spinnerGradientTau.addMouseWheelListener(_spinnerMouseWheelListener); }
@Override protected void createControl(Composite parent) { if (mOptional) { GridLayoutFactory.swtDefaults().applyTo(parent); mEnableButton = new Button(parent, SWT.CHECK); mEnableButton.setText(Messages.TIME_OF_DAY_FIELD_EDITOR_ENABLE_BUTTON_LABEL.getText()); GridDataFactory.defaultsFor(mEnableButton).applyTo(mEnableButton); mComposite = new Composite(parent, SWT.NONE); GridDataFactory.fillDefaults().indent(10, 0).applyTo(mComposite); super.createControl(mComposite); mEnablement = ControlEnableState.disable(mComposite); mEnableButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (mEnableButton.getSelection()) { mEnablement.restore(); } else { mEnablement = ControlEnableState.disable(mComposite); } } }); } else { super.createControl(parent); } }
private void createUI24SmoothPulse(final Composite parent) { /* * image: pulse */ _iconPulse = new CLabel(parent, SWT.NONE); GridDataFactory.fillDefaults().indent(16, 0).applyTo(_iconPulse); _iconPulse.setBackground(_tk.getColors().getBackground()); _iconPulse.setImage(_imagePulse); /* * checkbox: smooth speed */ _chkIsPulseSmoothing = _tk.createButton(parent, Messages.TourChart_Smoothing_Checkbox_IsPulseSmoothing, SWT.CHECK); GridDataFactory.fillDefaults() // .align(SWT.FILL, SWT.CENTER) .applyTo(_chkIsPulseSmoothing); _chkIsPulseSmoothing.addSelectionListener(_selectionListener); _chkIsPulseSmoothing.setToolTipText( Messages.TourChart_Smoothing_Checkbox_IsPulseSmoothing_Tooltip); /* * spinner: speed tau */ _spinnerPulseTau = new Spinner(parent, SWT.BORDER); GridDataFactory.fillDefaults() // .align(SWT.BEGINNING, SWT.FILL) .applyTo(_spinnerPulseTau); _spinnerPulseTau.setDigits(1); _spinnerPulseTau.setMinimum(1); _spinnerPulseTau.setMaximum(MAX_TAU); _spinnerPulseTau.addSelectionListener(_selectionListener); _spinnerPulseTau.addMouseWheelListener(_spinnerMouseWheelListener); }
@Override public Control createExampleControl(Composite parent) { Composite panel = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; panel.setLayout(layout); GridDataFactory.fillDefaults().grab(true, true).applyTo(panel); Composite gridPanel = new Composite(panel, SWT.NONE); gridPanel.setLayout(layout); GridDataFactory.fillDefaults().grab(true, true).applyTo(gridPanel); Composite buttonPanel = new Composite(panel, SWT.NONE); buttonPanel.setLayout(new GridLayout()); GridDataFactory.fillDefaults().grab(true, false).applyTo(buttonPanel); // property names of the Person class String[] propertyNames = {"firstName", "lastName", "gender", "married", "birthday"}; // mapping from property to label, needed for column header labels Map<String, String> propertyToLabelMap = new HashMap<String, String>(); propertyToLabelMap.put("firstName", "Firstname"); propertyToLabelMap.put("lastName", "Lastname"); propertyToLabelMap.put("gender", "Gender"); propertyToLabelMap.put("married", "Married"); propertyToLabelMap.put("birthday", "Birthday"); IDataProvider bodyDataProvider = new DefaultBodyDataProvider<Person>(PersonService.getPersons(100), propertyNames); DataLayer bodyDataLayer = new DataLayer(bodyDataProvider); SelectionLayer selectionLayer = new SelectionLayer(bodyDataLayer); ViewportLayer viewportLayer = new ViewportLayer(selectionLayer); // add the PrintCommandHandler to the ViewportLayer in order to make // printing work viewportLayer.registerCommandHandler(new PrintCommandHandler(viewportLayer)); final NatTable natTable = new NatTable(gridPanel, viewportLayer, false); // adding this configuration adds the styles and the painters to use natTable.addConfiguration(new DefaultNatTableStyleConfiguration()); natTable.addConfiguration(new DefaultPrintBindings()); natTable.configure(); GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable); Button addColumnButton = new Button(buttonPanel, SWT.PUSH); addColumnButton.setText("Print"); addColumnButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { natTable.doCommand(new PrintCommand(natTable.getConfigRegistry(), natTable.getShell())); } }); return panel; }
@Override protected Control createContents(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); POPUP_LAYOUT_FACTORY.applyTo(composite); // LAYOUTDATA_GRAB_BOTH.applyTo(composite); GridData gd = LAYOUTDATA_GRAB_BOTH.create(); composite.setLayoutData(gd); if (hasTitleArea()) { createTitleMenuArea(composite); createHorizontalSeparator(composite); } dialogArea = createDialogArea(composite); if (dialogArea.getLayoutData() == null) LAYOUTDATA_GRAB_BOTH.applyTo(composite); gd = LAYOUTDATA_GRAB_BOTH.create(); dialogArea.pack(); gd.widthHint = dialogArea.getSize().x; gd.heightHint = dialogArea.getSize().y; dialogArea.setLayoutData(gd); if (hasInfoArea()) { createHorizontalSeparator(composite); createInfoTextArea(composite); } return composite; }
@Override public void createPartControl(Composite parent) { // Creates toolkit and form toolkit = createFormBodySection(parent, "Senate Crawler"); Section section = toolkit.createSection(form.getBody(), Section.TITLE_BAR | Section.EXPANDED); GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(section); section.setExpanded(true); // Create a composite to hold the other widgets ScrolledComposite sc = new ScrolledComposite(section, SWT.H_SCROLL | SWT.V_SCROLL); sc.setExpandHorizontal(true); sc.setExpandVertical(true); GridLayoutFactory.fillDefaults().numColumns(3).equalWidth(false).applyTo(sc); // Creates an empty to create a empty space TacitFormComposite.createEmptyRow(toolkit, sc); // Create a composite that can hold the other widgets Composite client = toolkit.createComposite(form.getBody()); GridLayoutFactory.fillDefaults() .equalWidth(true) .numColumns(1) .applyTo(client); // Align the composite section to one column GridDataFactory.fillDefaults().grab(true, false).span(1, 1).applyTo(client); GridLayout layout = new GridLayout(); // Layout creation layout.numColumns = 2; createSenateInputParameters(client); TacitFormComposite.createEmptyRow(toolkit, client); outputLayout = TacitFormComposite.createOutputSection(toolkit, client, form.getMessageManager()); // Add run and help button on the toolbar addButtonsToToolBar(); }
public Control createControl(Composite composite) { packagingGroup = new Group(composite, SWT.NONE); packagingGroup.setFont(composite.getFont()); packagingGroup.setText("Packaging Provider"); packagingGroup.setLayout(initGridLayout(new GridLayout(2, false), true)); builtinButton = new Button(packagingGroup, SWT.RADIO); builtinButton.setText("Select a built-in provider"); builtinButton.setSelection(true); builtinButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { packagingProviderCombo.setEnabled(true); packagingProviderText.setEnabled(false); } }); GridDataFactory.fillDefaults().span(2, 1).applyTo(builtinButton); Label options = new Label(packagingGroup, SWT.WRAP); options.setText("Packaging: "); GridDataFactory.swtDefaults().indent(5, 0).applyTo(options); packagingProviderCombo = new Combo(packagingGroup, SWT.DROP_DOWN | SWT.READ_ONLY); packagingProviderCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); packagingProviderCombo.setEnabled(true); List<String> provider = new ArrayList<String>(); provider.add("JAR"); provider.add("BUNDLE"); provider.add("POM"); provider.add("WAR"); packagingProviderCombo.setItems(provider.toArray(new String[provider.size()])); packagingProviderCombo.select(0); customButton = new Button(packagingGroup, SWT.RADIO); customButton.setText("Specify a custom provider"); customButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { packagingProviderCombo.setEnabled(false); packagingProviderText.setEnabled(true); } }); GridDataFactory.fillDefaults().span(2, 1).applyTo(customButton); Label flag = new Label(packagingGroup, SWT.WRAP); flag.setText("--provider "); GridDataFactory.swtDefaults().indent(5, 0).applyTo(flag); packagingProviderText = new Text(packagingGroup, SWT.BORDER); packagingProviderText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); packagingProviderText.setEnabled(false); updateEnablement(); packagingGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); return packagingGroup; }
protected void createExpressionTypePanel(Composite parentForm) { Composite parentComposite = new Composite(parentForm, SWT.NONE); parentComposite.setLayoutData( GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.FILL).grab(false, true).create()); parentComposite.setLayout(new GridLayout(1, false)); Label expressionTypeLabel = new Label(parentComposite, SWT.NONE); expressionTypeLabel.setText(Messages.expressionTypeLabel); expressionTypeLabel.setLayoutData(GridDataFactory.swtDefaults().grab(true, false).create()); expressionTypeViewer = new TableViewer(parentComposite, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE); expressionTypeViewer .getTable() .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); expressionTypeViewer.setContentProvider(new ExpressionTypeContentProvider()); expressionTypeViewer.setLabelProvider(new ExpressionTypeLabelProvider()); expressionTypeViewer.setSorter( new ViewerSorter() { @Override public int compare(Viewer viewer, Object e1, Object e2) { IExpressionProvider p1 = (IExpressionProvider) e1; IExpressionProvider p2 = (IExpressionProvider) e2; return p1.getTypeLabel().compareTo(p2.getTypeLabel()); } }); if (viewerTypeFilters != null) { expressionTypeViewer.setFilters(viewerTypeFilters); } ColumnViewerToolTipSupport.enableFor(expressionTypeViewer, ToolTip.NO_RECREATE); expressionTypeViewer.setInput(context); expressionTypeViewer.addSelectionChangedListener( new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { if (!event.getSelection().equals(oldSelection)) { oldSelection = event.getSelection(); expressionTypeChanged(event.getSelection()); Button okButton = getButton(OK); if (okButton != null && !okButton.isDisposed() && currentExpressionEditor != null) { okButton.setEnabled(currentExpressionEditor.canFinish()); } else if (currentExpressionEditor == null) { okButton.setEnabled(false); } } } }); expressionTypeViewer.addPostSelectionChangedListener( new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { getShell().layout(true, true); } }); }
@Override public void createControl(Composite parent) { mComposite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(2, false); layout.marginWidth = layout.marginHeight = 0; mComposite.setLayout(layout); GridDataFactory.fillDefaults().grab(true, true).applyTo(mComposite); Label l = new Label(mComposite, SWT.NONE); l.setText("Size: "); GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(l); mSizeLabel = new Label(mComposite, SWT.NONE); GridDataFactory.fillDefaults().grab(true, false).applyTo(mSizeLabel); l = new Label(mComposite, SWT.NONE); l.setText("Usage: "); GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(l); mUsageLabel = new Label(mComposite, SWT.NONE); GridDataFactory.fillDefaults().grab(true, false).applyTo(mUsageLabel); l = new Label(mComposite, SWT.NONE); l.setText("Type: "); GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(l); mTypeLabel = new Label(mComposite, SWT.NONE); GridDataFactory.fillDefaults().grab(true, false).applyTo(mTypeLabel); l = new Label(mComposite, SWT.NONE); l.setText("Format Data As: "); GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(l); DisplayFormat[] values = DisplayFormat.values(); List<String> formats = new ArrayList<String>(values.length); for (DisplayFormat format : values) { formats.add(format.name()); } mDisplayFormatCombo = new Combo(mComposite, SWT.DROP_DOWN | SWT.READ_ONLY); mDisplayFormatCombo.setItems(formats.toArray(new String[formats.size()])); mDisplayFormatCombo.select(0); mDisplayFormatCombo.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { updateContents(); } }); GridDataFactory.fillDefaults().grab(true, false).applyTo(mDisplayFormatCombo); mTextControl = new Text( mComposite, SWT.BORDER | SWT.READ_ONLY | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL); GridDataFactory.fillDefaults().span(2, 1).grab(true, true).applyTo(mTextControl); mTextControl.setEditable(false); }
private void createFilterControl(Composite panel) { // Filter control searchControl = new SearchControl(panel); if (isHorizontal) { GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(searchControl); } else { GridDataFactory.fillDefaults().grab(true, false).applyTo(searchControl); } searchControl.setInitialText("Tag name"); searchControl.getFilterControl().setToolTipText(TOOLTIP_FILTER); proposalAdapter = new AutocompleteContentProposalAdapter( searchControl.getFilterControl(), new TextContentAdapter(), new AutocompleteContentProposalProvider(), null, null); proposalAdapter.setPropagateKeys(true); proposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); proposalAdapter.addContentProposalListener( new IContentProposalListener() { @Override public void proposalAccepted(IContentProposal proposal) { selectAutocompleteOffer(); } }); searchControl .getFilterControl() .addListener( SWT.KeyDown, new Listener() { @Override public void handleEvent(Event event) { switch (event.keyCode) { // ContentProposalAdapter can't be activated by any character and CTRL+SPACE at // the same time, // so by default it's activated by any alphanumeric character and here it's // activated by CTRL+SPACE case SWT.SPACE: if ((event.stateMask & SWT.CTRL) == SWT.CTRL) { proposalAdapter.showProposals(); event.doit = false; } break; // Uses Enter to refresh listViewer if User typed filter query instead of using // autocompletion case SWT.CR: selectAutocompleteOffer(); break; } } }); }
public Composite createComposite(Composite parent, IWizardHandle handle) { this.handle = handle; handle.setTitle(Messages.ArchiveTitle); handle.setDescription(Messages.ArchiveDescription); handle.setImageDescriptor(JavaPluginImages.DESC_WIZBAN_ADD_LIBRARY); Composite c = new Composite(parent, SWT.NONE); PlatformUI.getWorkbench() .getHelpSystem() .setHelp(c, IJstCommonUIContextIds.DEPLOYMENT_ASSEMBLY_NEW_ARCHIVE_REFERENCE_P1); c.setLayout(new GridLayout(2, false)); viewer = new TreeViewer(c, SWT.MULTI | SWT.BORDER); viewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH)); viewer.setContentProvider(getContentProvider()); viewer.setLabelProvider(getLabelProvider()); viewer.setInput(ResourcesPlugin.getWorkspace()); Composite buttonColumn = new Composite(c, SWT.NONE); buttonColumn.setLayoutData(new GridData(GridData.FILL_VERTICAL)); final GridLayout gl = new GridLayout(); gl.marginWidth = 0; gl.marginHeight = 0; buttonColumn.setLayout(gl); add = new Button(buttonColumn, SWT.NONE); add.setText(Messages.Add); GridDataFactory.defaultsFor(add).applyTo(add); remove = new Button(buttonColumn, SWT.NONE); remove.setText(Messages.Remove); GridDataFactory.defaultsFor(remove).applyTo(remove); add.addSelectionListener( new SelectionListener() { public void widgetSelected(SelectionEvent e) { buttonPressed(); } public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } }); remove.addSelectionListener( new SelectionListener() { public void widgetSelected(SelectionEvent e) { removeButtonPressed(); } public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } }); return c; }
@Override protected Control createDialogArea(Composite parent) { Composite tparent = (Composite) super.createDialogArea(parent); GridDataFactory.fillDefaults().hint(500, 180).grab(true, true).applyTo(tparent); Composite composite = new Composite(tparent, SWT.NONE); GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).applyTo(composite); GridLayoutFactory.fillDefaults() .extendedMargins(0, 0, 0, 0) .equalWidth(false) .numColumns(2) .applyTo(composite); GridData textData = new GridData(GridData.FILL, SWT.CENTER, true, false); // 非译元素的名称 Label tipLbl = new Label(composite, SWT.NONE); tipLbl.setText(Messages.getString("qa.preference.NonTranslationQAPage.tip")); GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(tipLbl); tipTxt = new Text(composite, SWT.BORDER); tipTxt.setLayoutData(textData); // 非译元素的非译内容 Label contentLbl = new Label(composite, SWT.NONE); contentLbl.setText(Messages.getString("qa.preference.NonTranslationQAPage.content")); GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(contentLbl); contentTxt = new Text(composite, SWT.BORDER); contentTxt.setLayoutData(textData); // 非译元素的正则表达式 Label regularLbl = new Label(composite, SWT.NONE); regularLbl.setText(Messages.getString("qa.preference.NonTranslationQAPage.regular")); GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(regularLbl); regularTxt = new Text(composite, SWT.BORDER); regularTxt.setLayoutData(textData); // 正则表达式自定义选项 new Label(composite, SWT.NONE); Composite pesonalCmp = new Composite(composite, SWT.NONE); pesonalCmp.setLayoutData(textData); GridLayoutFactory.fillDefaults().equalWidth(true).numColumns(2).applyTo(pesonalCmp); wordBtn = new Button(pesonalCmp, SWT.CHECK); wordBtn.setText(Messages.getString("qa.preference.NonTranslationQAPage.addTip1")); ignoreCaseBtn = new Button(pesonalCmp, SWT.CHECK); ignoreCaseBtn.setText(Messages.getString("qa.preference.NonTranslationQAPage.addTip2")); new Label(composite, SWT.NONE); initListener(); initValue(); return tparent; }
@Override protected Control createDialogArea(Composite parent) { Composite main = new Composite(parent, SWT.NONE); GridDataFactory.fillDefaults().grab(true, true).applyTo(main); GridLayoutFactory.fillDefaults().numColumns(2).margins(5, 5).applyTo(main); new Label(main, SWT.NONE).setText(UIText.BranchRenameDialog_NewNameLabel); name = new Text(main, SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).applyTo(name); return main; }
public static void main(String[] args) throws Exception { final Shell shell = new Shell(); final Display display = shell.getDisplay(); shell.setLayout(new GridLayout(1, false)); final Switch control = new Switch(shell); control.setLayoutData(GridDataFactory.swtDefaults().create()); control.setActiveText("Shown"); control.setActiveBackground(new Color(display, 135, 209, 243)); control.setInactiveBackground(new Color(display, 198, 198, 198)); control.setInactiveText("Hidden"); control.setFont(new Font(display, "Arial", 10, SWT.BOLD)); control.setEnabled(true); control.setSelection(true); final Switch control1 = new Switch(shell); control1.setLayoutData(GridDataFactory.swtDefaults().create()); control1.setActiveText("Shown"); control1.setActiveBackground(new Color(display, 135, 209, 243)); control1.setInactiveBackground(new Color(display, 198, 198, 198)); control1.setInactiveText("Hidden"); control1.setFont(new Font(display, "Arial", 10, SWT.BOLD)); control1.setEnabled(false); control1.setSelection(true); final Switch control2 = new Switch(shell); control2.setLayoutData(GridDataFactory.swtDefaults().create()); control2.setActiveText("Shown"); control2.setActiveBackground(new Color(display, 135, 209, 243)); control2.setInactiveBackground(new Color(display, 198, 198, 198)); control2.setInactiveText("Hidden"); control2.setFont(new Font(display, "Arial", 10, SWT.BOLD)); control2.setEnabled(false); control2.setSelection(false); final RoundedComposite c3 = new RoundedComposite(shell, SWT.LEFT); c3.setBackground(new Color(display, 135, 209, 243)); c3.setLayoutData( GridDataFactory // .swtDefaults() // .hint(SWT.DEFAULT, SWT.DEFAULT) // .create()); final Label label = new Label(c3, SWT.NONE); label.setText("Hi"); label.setForeground(display.getSystemColor(SWT.COLOR_WHITE)); label.setFont(new Font(display, "Arial", 11, SWT.BOLD)); c3.setClient(label); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }
private void createControl(final Composite parent) { Composite comp = new Composite(parent, SWT.NONE); GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.BEGINNING).applyTo(comp); GridLayoutFactory.fillDefaults() .numColumns(isCentered ? 1 : 2) .margins(margin.x, margin.y) .applyTo(comp); updateStatusLabel = new Link(comp, SWT.NO_FOCUS); if (backgroundColor != null) { comp.setBackground(backgroundColor); updateStatusLabel.setBackground(backgroundColor); } updateStatusLabel.addSelectionListener( new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } @Override public void widgetSelected(SelectionEvent e) { ExternalBrowserUtil.openInExternalBrowser(UpdateCore.getChangeLogUrl()); } }); GridDataFactory.fillDefaults() .align(isCentered ? SWT.CENTER : SWT.FILL, SWT.CENTER) .grab(true, false) .applyTo(updateStatusLabel); updateStatusButton = new Button(comp, SWT.PUSH); updateStatusButton.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); GridDataFactory.fillDefaults() .align(SWT.CENTER, SWT.CENTER) .indent(0, 3) .applyTo(updateStatusButton); updateStatusButton.addSelectionListener( new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { performAction(e); } @Override public void widgetSelected(SelectionEvent e) { performAction(e); } }); }
private void createJavaApplicationControls(Composite composite) { this.createJavaApplicationButton = new Button(composite, SWT.RADIO); this.createJavaApplicationButton.setText( JaxrsApplicationCreationMessages .JaxrsApplicationCreationWizardPage_JavaApplicationCreation); this.createJavaApplicationButton.setSelection(true); GridDataFactory.fillDefaults() .align(SWT.FILL, SWT.CENTER) .grab(false, false) .applyTo(createJavaApplicationButton); this.createJavaApplicationButton.addSelectionListener(onSelectJavaApplication()); // controls for Java application creation final int nColumns = 4; javaApplicationControlsContainer = new Composite(composite, SWT.NONE); GridLayoutFactory.fillDefaults().numColumns(nColumns).applyTo(javaApplicationControlsContainer); GridDataFactory.fillDefaults() .indent(30, 0) .align(SWT.FILL, SWT.CENTER) .grab(true, false) .applyTo(javaApplicationControlsContainer); createContainerControls(javaApplicationControlsContainer, nColumns); createPackageControls(javaApplicationControlsContainer, nColumns); createTypeNameControls(javaApplicationControlsContainer, nColumns); // createSuperClassControls(javaApplicationControlsContainer, nColumns); final Label applicationPathLabel = new Label(javaApplicationControlsContainer, SWT.NONE); applicationPathLabel.setText("Application path:"); GridDataFactory.fillDefaults() .align(SWT.FILL, SWT.CENTER) .grab(false, false) .applyTo(applicationPathLabel); this.javaApplicationApplicationPathText = new Text(javaApplicationControlsContainer, SWT.BORDER); this.javaApplicationApplicationPathText.setText(getApplicationPath()); GridDataFactory.fillDefaults() .align(SWT.FILL, SWT.CENTER) .span(2, 1) .grab(true, false) .applyTo(javaApplicationApplicationPathText); GridDataFactory.fillDefaults() .align(SWT.FILL, SWT.CENTER) .grab(false, false) .applyTo(new Label(javaApplicationControlsContainer, SWT.NONE)); javaApplicationApplicationPathText.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent evt) { onJavaApplicationPathChange(); doStatusUpdate(); } }); createCommentControls(javaApplicationControlsContainer, nColumns); enableCommentControl(true); }