/** * Provide layout and listeners for the controls. * * @param parent */ private void addLayout(Composite parent) { FormData data; // http://www.eclipse.org/forums/index.php/t/202738/ final FormLayout layout = new FormLayout(); layout.marginWidth = 4; layout.marginHeight = 0; layout.spacing = 10; // 100; parent.setLayout(layout); data = new FormData(); data.left = new FormAttachment(0, 0); data.top = new FormAttachment(nameTextVal, 0, SWT.CENTER); valueLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(valueLabel, 0); // data.right = new FormAttachment(100, 0); // data.right = new FormAttachment(50, 0); data.width = 200; data.top = new FormAttachment(0, VSPACE); // data.width = SWT.BORDER; nameTextVal.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0, 0); data.width = 200; // data.right = new FormAttachment(100, 0); // data.right = new FormAttachment(50, 0); data.top = new FormAttachment(nameTextVal, VSPACE); // data.width = SWT.BORDER; allowedModes.setLayoutData(data); }
/** Creates content Composite. */ Composite eswtConstructContent(int style) { Composite comp = super.eswtConstructContent(SWT.VERTICAL); FormLayout layout = new FormLayout(); layout.marginBottom = Style.pixelMetric(Style.QSTYLE_PM_LAYOUTBOTTOMMARGIN); layout.marginTop = Style.pixelMetric(Style.QSTYLE_PM_LAYOUTTOPMARGIN); layout.marginLeft = Style.pixelMetric(Style.QSTYLE_PM_LAYOUTLEFTMARGIN); layout.marginRight = Style.pixelMetric(Style.QSTYLE_PM_LAYOUTRIGHTMARGIN); layout.spacing = Style.pixelMetric(Style.QSTYLE_PM_LAYOUTVERTICALSPACING); comp.setLayout(layout); eswtScrolledText = new ScrolledTextComposite(comp, comp.getVerticalBar()); eswtImgLabel = new LabelExtension(comp, SWT.NONE); FormData imageLD = new FormData(); imageLD.right = new FormAttachment(100); imageLD.top = new FormAttachment(0); eswtImgLabel.setLayoutData(imageLD); FormData scrolledTextLD = new FormData(); scrolledTextLD.left = new FormAttachment(0); scrolledTextLD.top = new FormAttachment(0); scrolledTextLD.right = new FormAttachment(eswtImgLabel); eswtScrolledText.setLayoutData(scrolledTextLD); eswtProgbarLD = new FormData(); eswtProgbarLD.left = new FormAttachment(0); eswtProgbarLD.right = new FormAttachment(100); eswtProgbarLD.bottom = new FormAttachment(100); eswtUpdateProgressbar(comp, false, false); return comp; }
public void createControl(Composite parent) { Composite container = new Composite(parent, SWT.NULL); GridLayout layout = new GridLayout(); container.setLayout(layout); layout.numColumns = 1; layout.verticalSpacing = 4; Composite userInteratcion = component.createControl(container); GridData gd = new GridData(GridData.FILL_BOTH); userInteratcion.setLayoutData(gd); Composite nameContainer = new Composite(container, SWT.NULL); gd = new GridData(GridData.FILL_HORIZONTAL); nameContainer.setLayoutData(gd); FormLayout formLayout = new FormLayout(); formLayout.spacing = 9; formLayout.marginLeft = 5; nameContainer.setLayout(formLayout); Label nameLabel = new Label(nameContainer, SWT.NULL); nameLabel.setText("User interaction name (optional):"); FormData data = new FormData(); data.left = new FormAttachment(0, 0); data.width = 170; nameLabel.setLayoutData(data); nameText = new Text(nameContainer, SWT.BORDER | SWT.SINGLE); data = new FormData(); data.left = new FormAttachment(nameLabel); data.width = 170; nameText.setLayoutData(data); nameText.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { actions.setName(nameText.getText()); } }); setControl(container); }
private void showInputBox() { Display display = Display.getDefault(); final Shell dialog = new Shell(display, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); dialog.setText("Add a row"); dialog.setLocation( shlTypeDocument.getBounds().x / 2 + shlTypeDocument.getBounds().width / 2, shlTypeDocument.getBounds().y / 2 + shlTypeDocument.getBounds().height / 2); FormLayout formLayout = new FormLayout(); formLayout.marginWidth = 10; formLayout.marginHeight = 10; formLayout.spacing = 10; dialog.setLayout(formLayout); Label label = new Label(dialog, SWT.NONE); label.setText("Type an identifier:"); FormData data = new FormData(); label.setLayoutData(data); Button cancel = new Button(dialog, SWT.PUSH); cancel.setText("Cancel"); data = new FormData(); data.width = 60; data.right = new FormAttachment(100, 0); data.bottom = new FormAttachment(100, 0); cancel.setLayoutData(data); cancel.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { dialog.close(); } }); final Text text = new Text(dialog, SWT.BORDER); data = new FormData(); data.width = 200; data.left = new FormAttachment(label, 0, SWT.DEFAULT); data.right = new FormAttachment(100, 0); data.top = new FormAttachment(label, 0, SWT.CENTER); data.bottom = new FormAttachment(cancel, 0, SWT.DEFAULT); text.setLayoutData(data); Button ok = new Button(dialog, SWT.PUSH); ok.setText("OK"); data = new FormData(); data.width = 60; data.right = new FormAttachment(cancel, 0, SWT.DEFAULT); data.bottom = new FormAttachment(100, 0); ok.setLayoutData(data); ok.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { identifier = text.getText(); dialog.close(); } }); dialog.setDefaultButton(ok); dialog.pack(); dialog.open(); while (!dialog.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }
private void drawWindow() { shell = new Shell(SWT.ON_TOP | SWT.APPLICATION_MODAL | SWT.TITLE | SWT.MIN | SWT.MAX | SWT.RESIZE); // Setup Title shell.setText("Artifact Information"); // Setup Icon Image image = ArtifactImageManager.getImage(CoreArtifactTypes.Artifact); shell.setImage(image); // Setup Form Layout FormLayout layout = new FormLayout(); layout.marginHeight = 5; layout.marginWidth = 5; shell.setLayout(layout); SashForm sashForm = new SashForm(shell, SWT.VERTICAL); // Create valid artifact fields FormLayout validLayout = new FormLayout(); validLayout.spacing = 5; Composite validComposite = new Composite(sashForm, SWT.NONE); validComposite.setLayout(validLayout); Label validLabel = new Label(validComposite, SWT.LEFT); validLabel.setText("Valid artifacts - will be added"); Table validTable = new Table( validComposite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION); validTable.setLinesVisible(true); validTable.setHeaderVisible(true); // Create invalid artifacts fields FormLayout invalidLayout = new FormLayout(); invalidLayout.spacing = 5; Composite invalidComposite = new Composite(sashForm, SWT.NONE); invalidComposite.setLayout(invalidLayout); Label invalidLabel = new Label(invalidComposite, SWT.LEFT); invalidLabel.setText("Invalid artifacts - will not be added"); Table invalidTable = new Table( invalidComposite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION); invalidTable.setLinesVisible(true); invalidTable.setHeaderVisible(true); // Create the Buttons Button okButton = new Button(invalidComposite, SWT.PUSH); okButton.setText("OK"); Button cancelButton = new Button(invalidComposite, SWT.PUSH); cancelButton.setText("Cancel"); // Attach validLabel to top-left corner FormData data = new FormData(); data.top = new FormAttachment(0); data.left = new FormAttachment(0); validLabel.setLayoutData(data); // Attach validTable to bottom of validLabel data = new FormData(); data.top = new FormAttachment(validLabel); data.bottom = new FormAttachment(100); data.left = new FormAttachment(0); data.right = new FormAttachment(100); data.height = validTable.getItemHeight() * 10; validTable.setLayoutData(data); // Attach invalidLabel to top-left corner data = new FormData(); data.top = new FormAttachment(0); data.left = new FormAttachment(0); invalidLabel.setLayoutData(data); // Attach invalidTable to bottom of invalidLabel data = new FormData(); data.top = new FormAttachment(invalidLabel); data.bottom = new FormAttachment(okButton); data.left = new FormAttachment(0); data.right = new FormAttachment(100); data.height = validTable.getItemHeight() * 10; invalidTable.setLayoutData(data); // Attach sashForm to top-left corner of shell data = new FormData(); data.top = new FormAttachment(0); data.bottom = new FormAttachment(100); data.left = new FormAttachment(0); data.right = new FormAttachment(100); sashForm.setLayoutData(data); // Attach buttons to bottom of sashForm data = new FormData(); data.bottom = new FormAttachment(100); data.right = new FormAttachment(100); cancelButton.setLayoutData(data); data = new FormData(); data.bottom = new FormAttachment(100); data.right = new FormAttachment(cancelButton); okButton.setLayoutData(data); // Populate Tables relationTableViewer = new RelationTableViewer(validTable, invalidTable, branch); for (int i = 0; i < validArtifacts.size(); i++) { relationTableViewer.addValidItem(validArtifacts.get(i)); } for (int i = 0; i < invalidName.size(); i++) { relationTableViewer.addInvalidItem(invalidName.get(i), invalidReason.get(i)); } // Add Listeners to buttons okButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { okSelected(); } }); cancelButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { cancelSelected(); } }); // Add shell resize listener shell.addControlListener( new ControlListener() { @Override public void controlMoved(ControlEvent e) { // do nothing } @Override public void controlResized(ControlEvent e) { relationTableViewer.resizeTable(((Shell) e.widget).getClientArea().width); shell.layout(); } }); if (needWindow) { shell.pack(); shell.open(); } else { okSelected(); } }
public RenameDialog(Shell parent, SourcesHandler handler, CopySource copy) { dialog = new Shell(parent, SWT.DIALOG_TRIM | SWT.CLOSE | SWT.APPLICATION_MODAL); FormLayout formLayout = new FormLayout(); formLayout.marginWidth = 10; formLayout.marginHeight = 10; formLayout.spacing = 10; dialog.setLayout(formLayout); this.copySource = copy; this.handler = handler; ApplicationFactory factory = new ApplicationFactory(dialog, "Creator", getClass().getName()); Label label = factory.createLabel("name"); // new Label (dialog, SWT.NONE); FormData data = new FormData(); label.setLayoutData(data); Button cancel = factory.createButton("cancel"); data = new FormData(); data.width = 60; data.right = new FormAttachment(100, 0); data.bottom = new FormAttachment(100, 0); cancel.setLayoutData(data); cancel.addSelectionListener( new SelectionAdapter() { @SuppressWarnings("unused") public void widgetSelected(SelectionEvent e) { dialog.close(); } }); final Text text = new Text(dialog, SWT.BORDER); text.setText(copySource.getSrcNames()[0]); data = new FormData(); data.width = 200; data.left = new FormAttachment(label, 0, SWT.DEFAULT); data.right = new FormAttachment(100, 0); data.top = new FormAttachment(label, 0, SWT.CENTER); data.bottom = new FormAttachment(cancel, 0, SWT.DEFAULT); text.setLayoutData(data); Button ok = new Button(factory.getComposite(), SWT.PUSH); ; ok.setText("Ok"); data = new FormData(); data.width = 60; data.right = new FormAttachment(cancel, 0, SWT.DEFAULT); data.bottom = new FormAttachment(100, 0); ok.setLayoutData(data); ok.addSelectionListener( new SelectionAdapter() { @SuppressWarnings("unused") public void widgetSelected(SelectionEvent e) { rename(text.getText()); } }); Rectangle displayRect = UIDATA.DISPLAY.getBounds(); int x = (displayRect.width - 350) / 2; int y = (displayRect.height - 300) / 2; dialog.setImage(parent.getImage()); dialog.setLocation(x, y); dialog.setDefaultButton(ok); dialog.pack(); // XPWindowTheme.setWin32Theme(dialog); dialog.open(); }
public Control createControl( final Composite parent, IMemoryBlock memBlock, IDialogSettings properties, ExportMemoryDialog parentDialog) { fMemoryBlock = memBlock; fParentDialog = parentDialog; fProperties = properties; Composite composite = new Composite(parent, SWT.NONE) { public void dispose() { fProperties.put(TRANSFER_FILE, fFileText.getText().trim()); fProperties.put(TRANSFER_START, fStartText.getText().trim()); fProperties.put(TRANSFER_END, fEndText.getText().trim()); try { fStartAddress = getStartAddress(); fEndAddress = getEndAddress(); fOutputFile = getFile(); } catch (Exception e) { } super.dispose(); } }; FormLayout formLayout = new FormLayout(); formLayout.spacing = 5; formLayout.marginWidth = formLayout.marginHeight = 9; composite.setLayout(formLayout); // start address Label startLabel = new Label(composite, SWT.NONE); startLabel.setText(Messages.getString("SRecordExporter.StartAddress")); // $NON-NLS-1$ FormData data = new FormData(); startLabel.setLayoutData(data); fStartText = new Text(composite, SWT.BORDER); data = new FormData(); data.left = new FormAttachment(startLabel); data.width = 120; fStartText.setLayoutData(data); // end address Label endLabel = new Label(composite, SWT.NONE); endLabel.setText(Messages.getString("SRecordExporter.EndAddress")); // $NON-NLS-1$ data = new FormData(); data.top = new FormAttachment(fStartText, 0, SWT.CENTER); data.left = new FormAttachment(fStartText); endLabel.setLayoutData(data); fEndText = new Text(composite, SWT.BORDER); data = new FormData(); data.top = new FormAttachment(fStartText, 0, SWT.CENTER); data.left = new FormAttachment(endLabel); data.width = 120; fEndText.setLayoutData(data); // length Label lengthLabel = new Label(composite, SWT.NONE); lengthLabel.setText(Messages.getString("SRecordExporter.Length")); // $NON-NLS-1$ data = new FormData(); data.top = new FormAttachment(fStartText, 0, SWT.CENTER); data.left = new FormAttachment(fEndText); lengthLabel.setLayoutData(data); fLengthText = new Text(composite, SWT.BORDER); data = new FormData(); data.top = new FormAttachment(fStartText, 0, SWT.CENTER); data.left = new FormAttachment(lengthLabel); data.width = 120; fLengthText.setLayoutData(data); // file Label fileLabel = new Label(composite, SWT.NONE); fFileText = new Text(composite, SWT.BORDER); Button fileButton = new Button(composite, SWT.PUSH); fileLabel.setText(Messages.getString("Exporter.FileName")); // $NON-NLS-1$ data = new FormData(); data.top = new FormAttachment(fileButton, 0, SWT.CENTER); fileLabel.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(fileButton, 0, SWT.CENTER); data.left = new FormAttachment(fileLabel); data.width = 360; fFileText.setLayoutData(data); fileButton.setText(Messages.getString("Exporter.Browse")); // $NON-NLS-1$ data = new FormData(); data.top = new FormAttachment(fLengthText); data.left = new FormAttachment(fFileText); fileButton.setLayoutData(data); // Restriction notice about 32-bit support Label spacingLabel = new Label(composite, SWT.NONE); spacingLabel.setText(""); // $NON-NLS-1$ data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(fileLabel); spacingLabel.setLayoutData(data); Label restrictionLabel = new Label(composite, SWT.NONE); restrictionLabel.setText( Messages.getString("SRecordExporter.32BitLimitationMessage")); // $NON-NLS-1$ data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(spacingLabel); restrictionLabel.setLayoutData(data); String textValue = fProperties.get(TRANSFER_FILE); fFileText.setText(textValue != null ? textValue : ""); // $NON-NLS-1$ textValue = fProperties.get(TRANSFER_START); fStartText.setText(textValue != null ? textValue : "0x0"); // $NON-NLS-1$ try { getStartAddress(); } catch (Exception e) { fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } textValue = fProperties.get(TRANSFER_END); fEndText.setText(textValue != null ? textValue : "0x0"); // $NON-NLS-1$ try { getEndAddress(); } catch (Exception e) { fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } try { BigInteger length = getEndAddress().subtract(getStartAddress()); fLengthText.setText(length.toString()); if (length.compareTo(BigInteger.ZERO) <= 0) { fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } } catch (Exception e) { fLengthText.setText("0"); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } fileButton.addSelectionListener( new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // TODO Auto-generated method stub } public void widgetSelected(SelectionEvent e) { FileDialog dialog = new FileDialog(parent.getShell(), SWT.SAVE); dialog.setText(Messages.getString("SRecordExporter.ChooseFile")); // $NON-NLS-1$ dialog.setFilterExtensions(new String[] {"*.*;*"}); // $NON-NLS-1$ dialog.setFilterNames( new String[] {Messages.getString("Exporter.AllFiles")}); // $NON-NLS-1$ dialog.setFileName(fFileText.getText().trim()); dialog.open(); String filename = dialog.getFileName(); if (filename != null && filename.length() != 0) { fFileText.setText(dialog.getFilterPath() + File.separator + filename); } validate(); } }); fStartText.addKeyListener( new KeyListener() { public void keyReleased(KeyEvent e) { try { fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); BigInteger startAddress = getStartAddress(); BigInteger actualLength = getEndAddress().subtract(startAddress); fLengthText.setText(actualLength.toString()); if (actualLength.compareTo(BigInteger.ZERO) <= 0) { fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } if (startAddress.compareTo(BigInteger.ZERO) < 0) { fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } BigInteger endAddress = getEndAddress(); if (endAddress.compareTo(BigInteger.ZERO) < 0) { fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } } catch (Exception ex) { fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } validate(); } public void keyPressed(KeyEvent e) {} }); fEndText.addKeyListener( new KeyListener() { public void keyReleased(KeyEvent e) { try { fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); BigInteger actualLength = getEndAddress().subtract(getStartAddress()); fLengthText.setText(actualLength.toString()); if (actualLength.compareTo(BigInteger.ZERO) <= 0) { fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } BigInteger startAddress = getStartAddress(); if (startAddress.compareTo(BigInteger.ZERO) < 0) { fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } BigInteger endAddress = getEndAddress(); if (endAddress.compareTo(BigInteger.ZERO) < 0) { fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } } catch (Exception ex) { fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } validate(); } public void keyPressed(KeyEvent e) {} }); fLengthText.addKeyListener( new KeyListener() { public void keyReleased(KeyEvent e) { try { fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fStartText.setText(fStartText.getText().trim()); BigInteger length = getLength(); String endString; BigInteger startAddress = getStartAddress(); BigInteger endAddress = startAddress.add(length); if (length.compareTo(BigInteger.ZERO) <= 0) { if (endAddress.compareTo(BigInteger.ZERO) < 0) { endString = endAddress.toString(16); // $NON-NLS-1$ } else { endString = "0x" + endAddress.toString(16); // $NON-NLS-1$ } } else { endString = "0x" + endAddress.toString(16); // $NON-NLS-1$ } fEndText.setText(endString); if (length.compareTo(BigInteger.ZERO) <= 0) { fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } if (startAddress.compareTo(BigInteger.ZERO) < 0) { fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } if (endAddress.compareTo(BigInteger.ZERO) < 0) { fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } } catch (Exception ex) { if (fLengthText.getText().trim().length() != 0) { fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } validate(); } public void keyPressed(KeyEvent e) {} }); fFileText.addKeyListener( new KeyListener() { public void keyReleased(KeyEvent e) { validate(); } public void keyPressed(KeyEvent e) {} }); composite.pack(); parent.pack(); /* * We need to perform a validation. If we do it immediately we will get an exception * because things are not totally setup. So we schedule an immediate running of the * validation. For a very brief time the view logically may show a state which does * not reflect the true state of affairs. But the validate immediately corrects the * info. In practice the user never sees the invalid state displayed, because of the * speed of the draw of the dialog. */ Display.getDefault() .asyncExec( new Runnable() { public void run() { validate(); } }); return composite; }
@Override public void createPartControl(Composite aParent) { label = new Label(aParent, SWT.NONE); label.setText(Messages.LocationView_prompt); text = new Text(aParent, SWT.BORDER); text.setText(Messages.LocationView_default); text.setEditable(true); text.addSelectionListener( new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { search(createQuery()); // search according to filter } public void widgetSelected(SelectionEvent e) { quick(text.getText()); } }); // Create bbox button bbox = new Button(aParent, SWT.CHECK); bbox.setText(Messages.LocationView_bbox); bbox.setToolTipText(Messages.LocationView_bboxTooltip); super.createPartControl(aParent); // Layout using Form Layout (+ indicates FormAttachment) // + // +label+text+bbox+ // + // contents // + FormLayout layout = new FormLayout(); layout.marginHeight = 0; layout.marginWidth = 0; layout.spacing = 0; aParent.setLayout(layout); FormData dLabel = new FormData(); // bind to left & text dLabel.left = new FormAttachment(0); dLabel.top = new FormAttachment(text, 5, SWT.CENTER); label.setLayoutData(dLabel); FormData dText = new FormData(); // bind to top, label, bbox dText.top = new FormAttachment(1); dText.left = new FormAttachment(label, 5); dText.right = new FormAttachment(bbox, -5); text.setLayoutData(dText); FormData dBbox = new FormData(); // text & right dBbox.right = new FormAttachment(100); dBbox.top = new FormAttachment(text, 0, SWT.CENTER); bbox.setLayoutData(dBbox); FormData dsashForm = new FormData(100, 100); // text & bottom dsashForm.right = new FormAttachment(100); // bind to right of form dsashForm.left = new FormAttachment(0); // bind to left of form dsashForm.top = new FormAttachment(text, 2); // attach with 5 pixel offset dsashForm.bottom = new FormAttachment(100); // bind to bottom of form splitter.setWeights(new int[] {60, 40}); splitter.setLayoutData(dsashForm); createContextMenu(); }
private void create(Shell parent, final SymitarFile file) { FormLayout layout = new FormLayout(); layout.marginTop = 5; layout.marginBottom = 5; layout.marginLeft = 5; layout.marginRight = 5; layout.spacing = 5; shell = new Shell(parent, SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM); shell.setText("Line Printer Options"); shell.setLayout(layout); Label queueLabel = new Label(shell, SWT.NONE); queueLabel.setText("LPT Queue"); Label overrideLabel = new Label(shell, SWT.NONE); overrideLabel.setText("Forms Override"); Label lengthLabel = new Label(shell, SWT.NONE); lengthLabel.setText("Form Length"); Label startLabel = new Label(shell, SWT.NONE); startLabel.setText("Start Page"); Label endLabel = new Label(shell, SWT.NONE); endLabel.setText("End Page"); Label copiesLabel = new Label(shell, SWT.NONE); copiesLabel.setText("Copies"); Label landscapeLabel = new Label(shell, SWT.NONE); landscapeLabel.setText("Landscape"); Label duplexLabel = new Label(shell, SWT.NONE); duplexLabel.setText("Duplex"); Label priorityLabel = new Label(shell, SWT.NONE); priorityLabel.setText("Queue Priority"); // Select All when tabbing through FocusListener selectAllFocuser = new FocusListener() { public void focusGained(FocusEvent e) { if (e.widget instanceof Text) ((Text) e.widget).selectAll(); } public void focusLost(FocusEvent e) {} }; MouseListener mouseFocuser = new MouseAdapter() { public void mouseDown(MouseEvent e) { if (e.widget instanceof Text) ((Text) e.widget).selectAll(); } }; final Text queueText = new Text(shell, SWT.BORDER); queueText.setText("0"); queueText.selectAll(); queueText.addFocusListener(selectAllFocuser); queueText.addMouseListener(mouseFocuser); final Combo overrideCombo = new Combo(shell, SWT.READ_ONLY); overrideCombo.add("No"); overrideCombo.add("Yes"); overrideCombo.select(0); final Text lengthText = new Text(shell, SWT.BORDER); lengthText.setText("0"); lengthText.addFocusListener(selectAllFocuser); lengthText.addMouseListener(mouseFocuser); final Text startText = new Text(shell, SWT.BORDER); startText.setText("0"); startText.addFocusListener(selectAllFocuser); startText.addMouseListener(mouseFocuser); final Text endText = new Text(shell, SWT.BORDER); endText.setText("0"); endText.addFocusListener(selectAllFocuser); endText.addMouseListener(mouseFocuser); final Text copiesText = new Text(shell, SWT.BORDER); copiesText.setText("1"); copiesText.addFocusListener(selectAllFocuser); copiesText.addMouseListener(mouseFocuser); final Combo landscapeCombo = new Combo(shell, SWT.READ_ONLY); landscapeCombo.add("No"); landscapeCombo.add("Yes"); landscapeCombo.select(0); final Combo duplexCombo = new Combo(shell, SWT.READ_ONLY); duplexCombo.add("No"); duplexCombo.add("Yes"); duplexCombo.select(0); final Text priorityText = new Text(shell, SWT.BORDER); priorityText.setText("4"); priorityText.addFocusListener(selectAllFocuser); priorityText.addMouseListener(mouseFocuser); Button okButton = new Button(shell, SWT.PUSH); okButton.setText("Print"); Button cancelButton = new Button(shell, SWT.PUSH); cancelButton.setText("Cancel"); shell.setDefaultButton(okButton); queueText.setFocus(); FormData data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(0); data.width = 120; queueLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(overrideLabel); data.top = new FormAttachment(0); data.right = new FormAttachment(100); data.width = 80; queueText.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(queueText); data.width = 120; overrideLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(overrideLabel); data.top = new FormAttachment(queueText); data.right = new FormAttachment(100); data.width = 80; overrideCombo.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(overrideCombo); data.width = 120; lengthLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(lengthLabel); data.top = new FormAttachment(overrideCombo); data.right = new FormAttachment(100); data.width = 80; lengthText.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(lengthText); data.width = 120; startLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(startLabel); data.top = new FormAttachment(lengthText); data.right = new FormAttachment(100); data.width = 80; startText.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(startText); data.width = 120; endLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(endLabel); data.top = new FormAttachment(startText); data.right = new FormAttachment(100); data.width = 80; endText.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(endText); data.width = 120; copiesLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(copiesLabel); data.top = new FormAttachment(endText); data.right = new FormAttachment(100); data.width = 80; copiesText.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(copiesText); data.width = 120; landscapeLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(landscapeLabel); data.top = new FormAttachment(copiesText); data.right = new FormAttachment(100); data.width = 80; landscapeCombo.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(landscapeCombo); data.width = 120; duplexLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(duplexLabel); data.top = new FormAttachment(landscapeCombo); data.right = new FormAttachment(100); data.width = 80; duplexCombo.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(duplexCombo); data.width = 120; priorityLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(priorityLabel); data.top = new FormAttachment(duplexCombo); data.right = new FormAttachment(100); data.width = 80; priorityText.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(priorityText); data.right = new FormAttachment(100); cancelButton.setLayoutData(data); cancelButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { result = false; shell.dispose(); } }); data = new FormData(); data.right = new FormAttachment(cancelButton); data.top = new FormAttachment(priorityText); okButton.setLayoutData(data); okButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { result = true; SessionError result = SessionError.INPUT_ERROR; try { result = RepDevMain.SYMITAR_SESSIONS .get(file.getSym()) .printFileLPT( file, Integer.parseInt(queueText.getText()), false, 0, Integer.parseInt(startText.getText()), Integer.parseInt(endText.getText()), Integer.parseInt(copiesText.getText()), landscapeCombo.getSelectionIndex() == 1, duplexCombo.getSelectionIndex() == 1, Integer.parseInt(priorityText.getText())); } catch (NumberFormatException e1) { } if (result != SessionError.NONE) { MessageBox dialog = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR); dialog.setText("Print Error"); dialog.setMessage(result.toString()); dialog.open(); } shell.dispose(); } }); shell.pack(); shell.open(); }
private Composite getFightPane(Composite parent) { // creates the composite to eventually return Composite composite = new Composite(parent, SWT.NONE); // sets its layout FormLayout layout = new FormLayout(); FormData data; layout.spacing = 5; composite.setLayout(layout); // Let's create some controls! // search button final Button fightButton = new Button(composite, SWT.PUSH); fightButton.setText("Fight!"); try { fightButton.setImage(new Image(null, new FileInputStream("images/search.png"))); } catch (Exception e) { } fightButton.setToolTipText("Click here to see how many articles contain each search term"); data = new FormData(); data.top = new FormAttachment(0, 0); data.left = new FormAttachment(50, -50); data.width = 100; data.height = 30; fightButton.setLayoutData(data); // search text searchText = new Text(composite, SWT.SINGLE | SWT.BORDER); data = new FormData(); data.top = new FormAttachment(0, 0); data.right = new FormAttachment(fightButton, 0); data.width = 150; data.height = 24; searchText.setLayoutData(data); // second search text searchText2 = new Text(composite, SWT.SINGLE | SWT.BORDER); data = new FormData(); data.top = new FormAttachment(0, 0); data.left = new FormAttachment(fightButton, 0); data.width = 150; data.height = 24; searchText2.setLayoutData(data); // label label = new Label(composite, SWT.CENTER); label.setText("Enter two terms and click 'Fight!'"); label.setFont(new Font(Display.getCurrent(), "", 16, SWT.BOLD)); data = new FormData(); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); data.top = new FormAttachment(fightButton, 5); label.setLayoutData(data); // browser browser = new Browser(composite, SWT.BORDER); data = new FormData(); data.left = new FormAttachment(50, -275); data.right = new FormAttachment(50, 275); data.top = new FormAttachment(label, 5); // data.bottom = new FormAttachment(100,0); data.height = 520; data.width = 550; browser.setLayoutData(data); // sets browser home page browser.setUrl("http://www.rssoap.com"); // adds click listener to start animation fightButton.addMouseListener( new MouseListener() { public void mouseUp(MouseEvent e) {} public void mouseDown(MouseEvent e) { fight(); } public void mouseDoubleClick(MouseEvent e) {} }); return composite; }
/** Opens the Dialog Shell. Auto-generated code - any changes you make will disappear. */ public void open() { try { preInitGUI(); Shell parent = getParent(); dialogShell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); dialogShell.setText(getText()); composite2 = new Composite(dialogShell, SWT.NULL); isLocalBtn = new Button(composite2, SWT.CHECK | SWT.LEFT); isAbstractBtn = new Button(composite2, SWT.CHECK | SWT.LEFT); repositoryIdTxt = new Text(composite2, SWT.BORDER); versionTxt = new Text(composite2, SWT.BORDER); identifierTxt = new Text(composite2, SWT.BORDER); versionLb = new Label(composite2, SWT.NULL); repositoryIdLb = new Label(composite2, SWT.NULL); idLb = new Label(composite2, SWT.NULL); composite3 = new Composite(dialogShell, SWT.NULL); cancel = new Button(composite3, SWT.PUSH | SWT.CENTER); enter = new Button(composite3, SWT.PUSH | SWT.CENTER); dialogShell.setText("Add Module"); dialogShell.setSize(new org.eclipse.swt.graphics.Point(476, 145)); GridData composite2LData = new GridData(); composite2LData.verticalAlignment = GridData.CENTER; composite2LData.horizontalAlignment = GridData.BEGINNING; composite2LData.widthHint = 464; composite2LData.heightHint = 102; composite2LData.horizontalIndent = 0; composite2LData.horizontalSpan = 1; composite2LData.verticalSpan = 1; composite2LData.grabExcessHorizontalSpace = false; composite2LData.grabExcessVerticalSpace = false; composite2.setLayoutData(composite2LData); composite2.setSize(new org.eclipse.swt.graphics.Point(464, 102)); FormData isLocalBtnLData = new FormData(); isLocalBtnLData.height = 20; isLocalBtnLData.width = 70; isLocalBtnLData.left = new FormAttachment(519, 1000, 0); isLocalBtnLData.right = new FormAttachment(750, 1000, 0); isLocalBtnLData.top = new FormAttachment(700, 1000, 0); isLocalBtnLData.bottom = new FormAttachment(897, 1000, 0); isLocalBtn.setLayoutData(isLocalBtnLData); isLocalBtn.setText("is local"); isLocalBtn.setSize(new org.eclipse.swt.graphics.Point(70, 20)); final Font isLocalBtnfont = new Font(Display.getDefault(), "Tahoma", 8, 1); isLocalBtn.setFont(isLocalBtnfont); FormData isAbstractBtnLData = new FormData(); isAbstractBtnLData.height = 20; isAbstractBtnLData.width = 100; isAbstractBtnLData.left = new FormAttachment(239, 1000, 0); isAbstractBtnLData.right = new FormAttachment(475, 1000, 0); isAbstractBtnLData.top = new FormAttachment(700, 1000, 0); isAbstractBtnLData.bottom = new FormAttachment(897, 1000, 0); isAbstractBtn.setLayoutData(isAbstractBtnLData); isAbstractBtn.setText("is abstract"); isAbstractBtn.setSize(new org.eclipse.swt.graphics.Point(100, 20)); isAbstractBtn.setFont(isLocalBtnfont); FormData repositoryIdTxtLData = new FormData(); repositoryIdTxtLData.height = 13; repositoryIdTxtLData.width = 352; repositoryIdTxtLData.left = new FormAttachment(239, 1000, 0); repositoryIdTxtLData.right = new FormAttachment(996, 1000, 0); repositoryIdTxtLData.top = new FormAttachment(269, 1000, 0); repositoryIdTxtLData.bottom = new FormAttachment(465, 1000, 0); repositoryIdTxt.setLayoutData(repositoryIdTxtLData); repositoryIdTxt.setDoubleClickEnabled(false); final Font repositoryIdTxtfont = new Font(Display.getDefault(), "Tahoma", 7, 0); repositoryIdTxt.setFont(repositoryIdTxtfont); repositoryIdTxt.setEditable(false); repositoryIdTxt.setSize(new org.eclipse.swt.graphics.Point(352, 13)); repositoryIdTxt.setEnabled(false); FormData versionTxtLData = new FormData(); versionTxtLData.height = 13; versionTxtLData.width = 352; versionTxtLData.left = new FormAttachment(239, 1000, 0); versionTxtLData.right = new FormAttachment(996, 1000, 0); versionTxtLData.top = new FormAttachment(485, 1000, 0); versionTxtLData.bottom = new FormAttachment(691, 1000, 0); versionTxt.setLayoutData(versionTxtLData); versionTxt.setFont(repositoryIdTxtfont); versionTxt.setSize(new org.eclipse.swt.graphics.Point(352, 13)); versionTxt.addKeyListener( new KeyAdapter() { public void keyReleased(KeyEvent evt) { versionTxtKeyReleased(evt); } }); FormData identifierTxtLData = new FormData(); identifierTxtLData.height = 13; identifierTxtLData.width = 352; identifierTxtLData.left = new FormAttachment(239, 1000, 0); identifierTxtLData.right = new FormAttachment(996, 1000, 0); identifierTxtLData.top = new FormAttachment(48, 1000, 0); identifierTxtLData.bottom = new FormAttachment(250, 1000, 0); identifierTxt.setLayoutData(identifierTxtLData); identifierTxt.setFont(repositoryIdTxtfont); identifierTxt.setSize(new org.eclipse.swt.graphics.Point(352, 13)); identifierTxt.setFocus(); identifierTxt.addKeyListener( new KeyAdapter() { public void keyReleased(KeyEvent evt) { identifierTxtKeyReleased(evt); } }); FormData versionLbLData = new FormData(); versionLbLData.height = 20; versionLbLData.width = 90; versionLbLData.left = new FormAttachment(11, 1000, 0); versionLbLData.right = new FormAttachment(245, 1000, 0); versionLbLData.top = new FormAttachment(485, 1000, 0); versionLbLData.bottom = new FormAttachment(681, 1000, 0); versionLb.setLayoutData(versionLbLData); versionLb.setText("Version:"); versionLb.setSize(new org.eclipse.swt.graphics.Point(90, 20)); versionLb.setFont(isLocalBtnfont); FormData repositoryIdLbLData = new FormData(); repositoryIdLbLData.height = 20; repositoryIdLbLData.width = 90; repositoryIdLbLData.left = new FormAttachment(11, 1000, 0); repositoryIdLbLData.right = new FormAttachment(245, 1000, 0); repositoryIdLbLData.top = new FormAttachment(269, 1000, 0); repositoryIdLbLData.bottom = new FormAttachment(465, 1000, 0); repositoryIdLb.setLayoutData(repositoryIdLbLData); repositoryIdLb.setText("Repository ID:"); repositoryIdLb.setSize(new org.eclipse.swt.graphics.Point(90, 20)); repositoryIdLb.setFont(isLocalBtnfont); FormData idLbLData = new FormData(); idLbLData.height = 20; idLbLData.width = 90; idLbLData.left = new FormAttachment(11, 1000, 0); idLbLData.right = new FormAttachment(245, 1000, 0); idLbLData.top = new FormAttachment(53, 1000, 0); idLbLData.bottom = new FormAttachment(250, 1000, 0); idLb.setLayoutData(idLbLData); idLb.setText("Identifier:"); idLb.setSize(new org.eclipse.swt.graphics.Point(90, 20)); idLb.setFont(isLocalBtnfont); FormLayout composite2Layout = new FormLayout(); composite2.setLayout(composite2Layout); composite2Layout.marginWidth = 0; composite2Layout.marginHeight = 0; composite2Layout.spacing = 0; composite2.layout(); GridData composite3LData = new GridData(); composite3LData.verticalAlignment = GridData.CENTER; composite3LData.horizontalAlignment = GridData.BEGINNING; composite3LData.widthHint = 466; composite3LData.heightHint = 46; composite3LData.horizontalIndent = 0; composite3LData.horizontalSpan = 1; composite3LData.verticalSpan = 1; composite3LData.grabExcessHorizontalSpace = false; composite3LData.grabExcessVerticalSpace = false; composite3.setLayoutData(composite3LData); composite3.setSize(new org.eclipse.swt.graphics.Point(466, 46)); FormData cancelLData = new FormData(); cancelLData.height = 21; cancelLData.width = 80; cancelLData.left = new FormAttachment(816, 1000, 0); cancelLData.right = new FormAttachment(988, 1000, 0); cancelLData.top = new FormAttachment(6, 1000, 0); cancelLData.bottom = new FormAttachment(580, 1000, 0); cancel.setLayoutData(cancelLData); cancel.setText("CANCEL"); cancel.setSize(new org.eclipse.swt.graphics.Point(80, 21)); cancel.setFont(isLocalBtnfont); cancel.addMouseListener( new MouseAdapter() { public void mouseDown(MouseEvent evt) { cancelMouseDown(evt); } }); FormData enterLData = new FormData(); enterLData.height = 21; enterLData.width = 80; enterLData.left = new FormAttachment(623, 1000, 0); enterLData.right = new FormAttachment(795, 1000, 0); enterLData.top = new FormAttachment(6, 1000, 0); enterLData.bottom = new FormAttachment(580, 1000, 0); enter.setLayoutData(enterLData); enter.setText("ENTER"); enter.setSize(new org.eclipse.swt.graphics.Point(80, 21)); enter.setFont(isLocalBtnfont); enter.addMouseListener( new MouseAdapter() { public void mouseDown(MouseEvent evt) { enterMouseDown(evt); } }); FormLayout composite3Layout = new FormLayout(); composite3.setLayout(composite3Layout); composite3Layout.marginWidth = 0; composite3Layout.marginHeight = 0; composite3Layout.spacing = 0; composite3.layout(); GridLayout dialogShellLayout = new GridLayout(1, true); dialogShell.setLayout(dialogShellLayout); dialogShellLayout.marginWidth = 5; dialogShellLayout.marginHeight = 5; dialogShellLayout.numColumns = 1; dialogShellLayout.makeColumnsEqualWidth = true; dialogShellLayout.horizontalSpacing = 5; dialogShellLayout.verticalSpacing = 5; dialogShell.layout(); dialogShell.addDisposeListener( new DisposeListener() { public void widgetDisposed(DisposeEvent e) { isLocalBtnfont.dispose(); repositoryIdTxtfont.dispose(); } }); Rectangle bounds = dialogShell.computeTrim(0, 0, 476, 145); dialogShell.setSize(bounds.width, bounds.height); postInitGUI(); dialogShell.open(); Display display = dialogShell.getDisplay(); while (!dialogShell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } catch (Exception e) { e.printStackTrace(); } }
void createContents(Composite parent) { prefs = frame.getPreferences(); prefs.setDefault(PREFS_TARGET_FILES_KEY, ""); // $NON-NLS-1$ prefs.setDefault(PREFS_SOURCE_FILES_KEY, ""); // $NON-NLS-1$ prefs.setDefault(PREFS_SAME_TARGET_KEY, true); prefs.setDefault(PREFS_USE_EXTENSION_FILTER_KEY, false); prefs.setDefault(PREFS_EXTENSION_FILTER_KEY, DEFAULT_EXTENSION_FILTER); prefs.setDefault(PREFS_TARGET_FILES_KEY + ".save", true); // $NON-NLS-1$ prefs.setDefault(PREFS_SOURCE_FILES_KEY + ".save", true); // $NON-NLS-1$ rootComp = new SashForm(parent, SWT.HORIZONTAL); rootComp.setSashWidth(8); rootComp.setLayout(new FillLayout()); Group targetComp = new Group(rootComp, SWT.NONE); targetComp.setText(messages.getString("FileEntrySelectPage.TARGET_TABLE_CAPTION")); { FillLayout l = new FillLayout(); l.marginWidth = l.marginHeight = 8; targetComp.setLayout(l); } targetFileListViewer = new FileDropListViewer(frame, targetComp); Composite rightComp = new Composite(rootComp, SWT.NONE); { FormLayout l = new FormLayout(); l.spacing = 8; rightComp.setLayout(l); } Group storageComp = new Group(rightComp, SWT.NONE); storageComp.setText(messages.getString("FileEntrySelectPage.SOURCE_TABLE_CAPTION")); { FormLayout l = new FormLayout(); l.marginWidth = l.marginHeight = 8; l.spacing = 8; storageComp.setLayout(l); } storageFileListViewer = new FileDropListViewer(frame, storageComp); sameTargetCheck = new Button(storageComp, SWT.CHECK); sameTargetCheck.setText(messages.getString("FileEntrySelectPage.TARGET_AS_SOURCE_BUTTON_TEXT")); sameTargetCheck.addSelectionListener(UPDATE_CONTENTS_ENABLED); storageFileListViewer .getControl() .setLayoutData( new FormDataBuilder().left(0).right(100).top(0).bottom(sameTargetCheck).build()); sameTargetCheck.setLayoutData(new FormDataBuilder().left(0).right(100).bottom(100).build()); Composite extFilterComp = new Composite(rightComp, SWT.NONE); { FormLayout l = new FormLayout(); l.marginWidth = l.marginHeight = 8; l.spacing = 8; extFilterComp.setLayout(l); } extFilterCheck = new Button(extFilterComp, SWT.CHECK); extFilterCheck.setText(messages.getString("FileEntrySelectPage.TARGET_EXTENSION_LABEL_TEXT")); extFilterCheck.addSelectionListener(UPDATE_CONTENTS_ENABLED); extFilterText = new Text(extFilterComp, SWT.BORDER); extFilterCheck.setLayoutData(new FormDataBuilder().left(0).top(0).build()); extFilterText.setLayoutData( new FormDataBuilder().left(extFilterCheck).right(100).top(0).build()); storageComp.setLayoutData( new FormDataBuilder().left(0).right(100).top(0).bottom(extFilterComp).build()); extFilterComp.setLayoutData(new FormDataBuilder().left(0).right(100).bottom(100).build()); sameTargetCheck.setSelection(prefs.getBoolean(PREFS_SAME_TARGET_KEY)); extFilterCheck.setSelection(prefs.getBoolean(PREFS_USE_EXTENSION_FILTER_KEY)); extFilterText.setText(prefs.getString(PREFS_EXTENSION_FILTER_KEY)); if (!prefs.getString(PREFS_TARGET_FILES_KEY).isEmpty()) { for (String path : prefs.getString(PREFS_TARGET_FILES_KEY).split(File.pathSeparator)) { // $NON-NLS-1$ targetFileListViewer.addFile(path); } } if (!prefs.getString(PREFS_SOURCE_FILES_KEY).isEmpty()) { for (String path : prefs.getString(PREFS_SOURCE_FILES_KEY).split(File.pathSeparator)) { // $NON-NLS-1$ storageFileListViewer.addFile(path); } } updateContentsEnabled(); }
private void createContents(Composite parent) { titleBar = new Composite(parent, SWT.NONE); titleBar.setBackground(new Color(Display.getDefault(), 255, 255, 255)); { RowLayout l = new RowLayout(SWT.VERTICAL); l.marginWidth = l.marginHeight = 8; titleBar.setLayout(l); } pageTitleLabel = new Label(titleBar, SWT.NONE); pageTitleLabel.setBackground(new Color(Display.getDefault(), 255, 255, 255)); pageTitleLabel.setFont( new Font( Display.getDefault(), Display.getDefault().getSystemFont().getFontData()[0].getName(), Display.getDefault().getSystemFont().getFontData()[0].getHeight(), SWT.BOLD)); pageDescLabel = new Label(titleBar, SWT.NONE); pageDescLabel.setBackground(new Color(Display.getDefault(), 255, 255, 255)); Group contentGroup = new Group(parent, SWT.NONE); { FillLayout l = new FillLayout(); l.marginWidth = l.marginHeight = 8; contentGroup.setLayout(l); } contentComp = new Composite(contentGroup, SWT.NONE); contentComp.setLayout(contentStack = new StackLayout()); Composite buttonBar = new Composite(parent, SWT.NONE); { FormLayout l = new FormLayout(); l.marginWidth = l.marginHeight = 8; l.spacing = 8; buttonBar.setLayout(l); } prefsButton = new Button(buttonBar, SWT.PUSH); prefsButton.setText(messages.getString("DREFrame.CONFIG_BUTTON_TEXT")); prefsButton.addSelectionListener(PREFS_BUTTON_SELECTED); prevButton = new Button(buttonBar, SWT.PUSH); prevButton.setText(messages.getString("DREFrame.BACK_BUTTON_TEXT")); prevButton.addSelectionListener(PREV_BUTTON_SELECTED); nextButton = new Button(buttonBar, SWT.PUSH); nextButton.setText(messages.getString("DREFrame.NEXT_BUTTON_TEXT")); nextButton.addSelectionListener(NEXT_BUTTON_SELECTED); closeButton = new Button(buttonBar, SWT.PUSH); closeButton.setText(messages.getString("DREFrame.CLOSE_BUTTON_TEXT")); closeButton.addSelectionListener(CLOSE_BUTTON_SELECTED); prefsButton.setLayoutData(new FormDataBuilder().left(0).width(120).height(30).build()); prevButton.setLayoutData(new FormDataBuilder().width(120).right(nextButton).height(30).build()); nextButton.setLayoutData( new FormDataBuilder().width(120).right(closeButton).height(30).build()); closeButton.setLayoutData(new FormDataBuilder().width(80).right(100).height(30).build()); { FormData fd = new FormData(); fd.top = new FormAttachment(0, 0); fd.left = new FormAttachment(0, 0); fd.right = new FormAttachment(100, 0); titleBar.setLayoutData(fd); } { FormData fd = new FormData(); fd.top = new FormAttachment(titleBar); fd.bottom = new FormAttachment(buttonBar); fd.left = new FormAttachment(0, 0); fd.right = new FormAttachment(100, 0); contentGroup.setLayoutData(fd); } { FormData fd = new FormData(); fd.bottom = new FormAttachment(100, 0); fd.left = new FormAttachment(0, 0); fd.right = new FormAttachment(100, 0); buttonBar.setLayoutData(fd); } for (DREPage page : pageMap.values()) { page.createContents(contentComp); } }