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 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 void doFillIntoGrid(Composite parent, int numColumns) { getLabelControl(parent); mTime = new DateTime(parent, SWT.TIME | SWT.LONG); mTime.setTime(0, 0, 0); GridDataFactory.defaultsFor(mTime).applyTo(mTime); }
@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); } }
@Override public void createPartControl(Composite parent) { final IActionBars actionBars = getViewSite().getActionBars(); IToolBarManager toolbar = actionBars.getToolBarManager(); mSymbolEntryText = new TextContributionItem(""); // $NON-NLS-1$ toolbar.add(mSymbolEntryText); toolbar.add(new AddSymbolAction(mSymbolEntryText, this)); final Table table = new Table(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.BORDER); table.setHeaderVisible(true); mViewer = new TableViewer(table); GridDataFactory.defaultsFor(table).applyTo(table); final MarketDataItemComparator comparator = new MarketDataItemComparator(); mViewer.setComparator(comparator); SelectionListener listener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // determine new sort column and direction TableColumn sortColumn = table.getSortColumn(); TableColumn currentColumn = (TableColumn) e.widget; final int index = table.indexOf(currentColumn); int dir = table.getSortDirection(); if (sortColumn == currentColumn) { dir = dir == SWT.UP ? SWT.DOWN : SWT.UP; } else { table.setSortColumn(currentColumn); dir = SWT.UP; } table.setSortDirection(dir); comparator.setSort(dir == SWT.UP ? 1 : -1); comparator.setIndex(index); mViewer.refresh(); } }; // create columns, using FIXFieldLocalizer to preserve backwards // compatibility TableViewerColumn symbolColumn = new TableViewerColumn( mViewer, createColumn( table, FIXFieldLocalizer.getLocalizedFIXFieldName(Symbol.class.getSimpleName()), SWT.LEFT, listener)); symbolColumn.setEditingSupport(new SymbolEditingSupport()); createColumn( table, FIXFieldLocalizer.getLocalizedFIXFieldName(LastPx.class.getSimpleName()), SWT.RIGHT, listener); createColumn( table, FIXFieldLocalizer.getLocalizedFIXFieldName(LastQty.class.getSimpleName()), SWT.RIGHT, listener); createColumn( table, FIXFieldLocalizer.getLocalizedFIXFieldName(BidSize.class.getSimpleName()), SWT.RIGHT, listener); createColumn( table, FIXFieldLocalizer.getLocalizedFIXFieldName(BidPx.class.getSimpleName()), SWT.RIGHT, listener); createColumn( table, FIXFieldLocalizer.getLocalizedFIXFieldName(OfferPx.class.getSimpleName()), SWT.RIGHT, listener); createColumn( table, FIXFieldLocalizer.getLocalizedFIXFieldName(OfferSize.class.getSimpleName()), SWT.RIGHT, listener); // restore table state if it exists if (mViewState != null) { ColumnState.restore(table, mViewState); for (TableColumn column : table.getColumns()) { if (column.getWidth() == 0) { column.setResizable(false); } } } registerContextMenu(); getSite().setSelectionProvider(mViewer); ObservableListContentProvider content = new ObservableListContentProvider(); mViewer.setContentProvider(content); IObservableSet domain = content.getKnownElements(); IObservableMap[] maps = new IObservableMap[] { BeansObservables.observeMap(domain, MarketDataViewItem.class, "symbol"), // $NON-NLS-1$ createCompositeMap( domain, "latestTick", MDPackage.Literals.MD_LATEST_TICK__PRICE), // $NON-NLS-1$ createCompositeMap( domain, "latestTick", MDPackage.Literals.MD_LATEST_TICK__SIZE), // $NON-NLS-1$ createCompositeMap( domain, "topOfBook", MDPackage.Literals.MD_TOP_OF_BOOK__BID_SIZE), // $NON-NLS-1$ createCompositeMap( domain, "topOfBook", MDPackage.Literals.MD_TOP_OF_BOOK__BID_PRICE), // $NON-NLS-1$ createCompositeMap( domain, "topOfBook", MDPackage.Literals.MD_TOP_OF_BOOK__ASK_PRICE), // $NON-NLS-1$ createCompositeMap( domain, "topOfBook", MDPackage.Literals.MD_TOP_OF_BOOK__ASK_SIZE) // $NON-NLS-1$ }; mViewer.setLabelProvider(new ObservableMapLabelProvider(maps)); mViewer.setUseHashlookup(true); mItems = WritableList.withElementType(MarketDataViewItem.class); mViewer.setInput(mItems); }
public void createControl(Composite parent) { Clipboard clipboard = new Clipboard(parent.getDisplay()); String clipText = (String) clipboard.getContents(TextTransfer.getInstance()); String defaultUri = null; String defaultCommand = null; String defaultChange = null; if (clipText != null) { final String pattern = "git fetch (\\w+:\\S+) (refs/changes/\\d+/\\d+/\\d+) && git (\\w+) FETCH_HEAD"; //$NON-NLS-1$ Matcher matcher = Pattern.compile(pattern).matcher(clipText); if (matcher.matches()) { defaultUri = matcher.group(1); defaultChange = matcher.group(2); defaultCommand = matcher.group(3); } } Composite main = new Composite(parent, SWT.NONE); main.setLayout(new GridLayout(2, false)); GridDataFactory.fillDefaults().grab(true, true).applyTo(main); new Label(main, SWT.NONE).setText(UIText.FetchGerritChangePage_UriLabel); uriCombo = new Combo(main, SWT.DROP_DOWN); GridDataFactory.fillDefaults().grab(true, false).applyTo(uriCombo); uriCombo.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { changeRefs = null; } }); new Label(main, SWT.NONE).setText(UIText.FetchGerritChangePage_ChangeLabel); refText = new Text(main, SWT.BORDER); if (defaultChange != null) refText.setText(defaultChange); GridDataFactory.fillDefaults().grab(true, false).applyTo(refText); addRefContentProposalToText(refText); Group checkoutGroup = new Group(main, SWT.SHADOW_ETCHED_IN); checkoutGroup.setLayout(new GridLayout(2, false)); GridDataFactory.fillDefaults().span(2, 1).grab(true, true).applyTo(checkoutGroup); checkoutGroup.setText(UIText.FetchGerritChangePage_AfterFetchGroup); // radio: create local branch createBranch = new Button(checkoutGroup, SWT.RADIO); GridDataFactory.fillDefaults().span(2, 1).applyTo(createBranch); createBranch.setText(UIText.FetchGerritChangePage_LocalBranchRadio); createBranch.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { checkPage(); } }); branchTextlabel = new Label(checkoutGroup, SWT.NONE); GridDataFactory.defaultsFor(branchTextlabel).exclude(false).applyTo(branchTextlabel); branchTextlabel.setText(UIText.FetchGerritChangePage_BranchNameText); branchText = new Text(checkoutGroup, SWT.SINGLE | SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).applyTo(branchText); branchText.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { checkPage(); } }); // radio: create tag createTag = new Button(checkoutGroup, SWT.RADIO); GridDataFactory.fillDefaults().span(2, 1).applyTo(createTag); createTag.setText(UIText.FetchGerritChangePage_TagRadio); createTag.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { checkPage(); } }); tagTextlabel = new Label(checkoutGroup, SWT.NONE); GridDataFactory.defaultsFor(tagTextlabel).exclude(true).applyTo(tagTextlabel); tagTextlabel.setText(UIText.FetchGerritChangePage_TagNameText); tagText = new Text(checkoutGroup, SWT.SINGLE | SWT.BORDER); GridDataFactory.fillDefaults().exclude(true).grab(true, false).applyTo(tagText); tagText.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { checkPage(); } }); // radio: checkout FETCH_HEAD checkout = new Button(checkoutGroup, SWT.RADIO); GridDataFactory.fillDefaults().span(2, 1).applyTo(checkout); checkout.setText(UIText.FetchGerritChangePage_CheckoutRadio); checkout.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { checkPage(); } }); // radio: don't checkout dontCheckout = new Button(checkoutGroup, SWT.RADIO); GridDataFactory.fillDefaults().span(2, 1).applyTo(checkout); dontCheckout.setText(UIText.FetchGerritChangePage_UpdateRadio); dontCheckout.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { checkPage(); } }); if ("checkout".equals(defaultCommand)) // $NON-NLS-1$ checkout.setSelection(true); else createBranch.setSelection(true); warningAdditionalRefNotActive = new Composite(main, SWT.NONE); GridDataFactory.fillDefaults() .span(2, 1) .grab(true, false) .exclude(true) .applyTo(warningAdditionalRefNotActive); warningAdditionalRefNotActive.setLayout(new GridLayout(2, false)); warningAdditionalRefNotActive.setVisible(false); activateAdditionalRefs = new Button(warningAdditionalRefNotActive, SWT.CHECK); activateAdditionalRefs.setText(UIText.FetchGerritChangePage_ActivateAdditionalRefsButton); activateAdditionalRefs.setToolTipText( UIText.FetchGerritChangePage_ActivateAdditionalRefsTooltip); refText.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { Change change = Change.fromRef(refText.getText()); if (change != null) { branchText.setText( NLS.bind( UIText.FetchGerritChangePage_SuggestedRefNamePattern, change.getChangeNumber(), change.getPatchSetNumber())); tagText.setText(branchText.getText()); } else { branchText.setText(""); // $NON-NLS-1$ tagText.setText(""); // $NON-NLS-1$ } checkPage(); } }); // get all available URIs from the repository SortedSet<String> uris = new TreeSet<String>(); try { for (RemoteConfig rc : RemoteConfig.getAllRemoteConfigs(repository.getConfig())) { if (rc.getURIs().size() > 0) uris.add(rc.getURIs().get(0).toPrivateString()); for (URIish u : rc.getPushURIs()) uris.add(u.toPrivateString()); } } catch (URISyntaxException e) { Activator.handleError(e.getMessage(), e, false); setErrorMessage(e.getMessage()); } for (String aUri : uris) uriCombo.add(aUri); if (defaultUri != null) uriCombo.setText(defaultUri); else selectLastUsedUri(); refText.setFocus(); Dialog.applyDialogFont(main); setControl(main); checkPage(); }