/** * Creates a combo that controls whether a cursor is set on the registered controls. * * @return the created combo */ protected Combo createCursorCombo() { Composite group = new Composite(styleComp, SWT.NONE); group.setLayout(new GridLayout(2, false)); new Label(group, SWT.NONE).setText("Cursor"); final Combo combo = new Combo(group, SWT.READ_ONLY); combo.setItems(SWT_CURSORS); combo.select(0); combo.addSelectionListener( new SelectionAdapter() { public void widgetSelected(final SelectionEvent e) { String selection = null; int index = combo.getSelectionIndex(); if (index > 0) { selection = combo.getItem(index); } updateCursor(selection); } }); return combo; }
void createControlTransfer(Composite parent) { Label l = new Label(parent, SWT.NONE); l.setText("Text:"); Button b = new Button(parent, SWT.PUSH); b.setText("Cut"); b.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { text.cut(); } }); b = new Button(parent, SWT.PUSH); b.setText("Copy"); b.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { text.copy(); } }); b = new Button(parent, SWT.PUSH); b.setText("Paste"); b.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { text.paste(); } }); text = new Text(parent, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.heightHint = data.widthHint = SIZE; text.setLayoutData(data); l = new Label(parent, SWT.NONE); l.setText("Combo:"); b = new Button(parent, SWT.PUSH); b.setText("Cut"); b.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { combo.cut(); } }); b = new Button(parent, SWT.PUSH); b.setText("Copy"); b.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { combo.copy(); } }); b = new Button(parent, SWT.PUSH); b.setText("Paste"); b.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { combo.paste(); } }); combo = new Combo(parent, SWT.NONE); combo.setItems(new String[] {"Item 1", "Item 2", "Item 3", "A longer Item"}); l = new Label(parent, SWT.NONE); l.setText("StyledText:"); l = new Label(parent, SWT.NONE); l.setVisible(false); b = new Button(parent, SWT.PUSH); b.setText("Copy"); b.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { styledText.copy(); } }); b = new Button(parent, SWT.PUSH); b.setText("Paste"); b.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { styledText.paste(); } }); styledText = new StyledText(parent, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); data = new GridData(GridData.FILL_HORIZONTAL); data.heightHint = data.widthHint = SIZE; styledText.setLayoutData(data); }
@Override protected void createClient(Section section, FormToolkit toolkit) { section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1)); GridData data = new GridData(GridData.FILL_BOTH); section.setLayoutData(data); section.setText(PDEUIMessages.ArgumentsSection_title); section.setDescription(PDEUIMessages.ArgumentsSection_desc); Composite client = toolkit.createComposite(section); client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1)); client.setLayoutData(new GridData(GridData.FILL_BOTH)); fTabFolder = new CTabFolder(client, SWT.FLAT | SWT.TOP); toolkit.adapt(fTabFolder, true, true); GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); fTabFolder.setLayoutData(gd); gd.heightHint = 2; toolkit.getColors().initializeSectionToolBarColors(); Color selectedColor = toolkit.getColors().getColor(IFormColors.TB_BG); fTabFolder.setSelectionBackground( new Color[] {selectedColor, toolkit.getColors().getBackground()}, new int[] {100}, true); fTabFolder.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (fProgramArgs.isDirty()) fProgramArgs.commit(); if (fVMArgs.isDirty()) fVMArgs.commit(); refresh(); fArchCombo.select(fLastArch[fLastTab]); } }); createTabs(); Composite archParent = toolkit.createComposite(client); archParent.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2)); archParent.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); toolkit.createLabel(archParent, PDEUIMessages.ArgumentsSection_architecture); fArchCombo = new ComboViewerPart(); fArchCombo.createControl(archParent, toolkit, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY); fArchCombo.getControl().setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); fArchCombo.setItems(TAB_ARCHLABELS); Control archComboControl = fArchCombo.getControl(); if (archComboControl instanceof Combo) ((Combo) archComboControl).select(fLastArch[fLastTab]); else ((CCombo) archComboControl).select(fLastArch[fLastTab]); fArchCombo.addSelectionChangedListener( new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { if (fProgramArgs.isDirty()) fProgramArgs.commit(); if (fVMArgs.isDirty()) fVMArgs.commit(); // remember the change in combo for currently selected platform Control fArchComboControl = fArchCombo.getControl(); if (fArchComboControl instanceof Combo) fLastArch[fLastTab] = ((Combo) fArchComboControl).getSelectionIndex(); else fLastArch[fLastTab] = ((CCombo) fArchComboControl).getSelectionIndex(); refresh(); } }); IActionBars actionBars = getPage().getPDEEditor().getEditorSite().getActionBars(); fProgramArgs = new FormEntry( client, toolkit, PDEUIMessages.ArgumentsSection_program, SWT.MULTI | SWT.WRAP); fProgramArgs.getText().setLayoutData(new GridData(GridData.FILL_BOTH)); fProgramArgs.setFormEntryListener( new FormEntryAdapter(this, actionBars) { @Override public void textValueChanged(FormEntry entry) { IArgumentsInfo info = getLauncherArguments(); info.setProgramArguments(entry.getValue().trim(), fLastTab, fLastArch[fLastTab]); updateArgumentPreview(info); } }); fProgramArgs.setEditable(isEditable()); fVMArgs = new FormEntry(client, toolkit, PDEUIMessages.ArgumentsSection_vm, SWT.MULTI | SWT.WRAP); fVMArgs.getText().setLayoutData(new GridData(GridData.FILL_BOTH)); fVMArgs.setFormEntryListener( new FormEntryAdapter(this, actionBars) { @Override public void textValueChanged(FormEntry entry) { IArgumentsInfo info = getLauncherArguments(); info.setVMArguments(entry.getValue().trim(), fLastTab, fLastArch[fLastTab]); updateArgumentPreview(info); } }); fVMArgs.setEditable(isEditable()); fPreviewArgs = new FormEntry( client, toolkit, PDEUIMessages.ArgumentsSection_preview, SWT.MULTI | SWT.WRAP); fPreviewArgs.getText().setLayoutData(new GridData(GridData.FILL_BOTH)); fPreviewArgs.setEditable(false); toolkit.paintBordersFor(client); section.setClient(client); // Register to be notified when the model changes getModel().addModelChangedListener(this); }