List of usage examples for org.eclipse.jface.layout GridDataFactory copyData
public static GridData copyData(GridData data)
From source file:ch.elexis.core.ui.preferences.Stickers.java
License:Open Source License
@Override protected Control createContents(Composite parent) { Composite ret = new Composite(parent, SWT.NONE); ret.setLayout(new GridLayout()); ret.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); combo = new Combo(ret, SWT.SIMPLE); combo.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); combo.addSelectionListener(new SelectionAdapter() { @Override// w w w .ja v a 2 s.c o m public void widgetSelected(SelectionEvent e) { int i = combo.getSelectionIndex(); if (i > -1) { setSticker(lEtiketten.get(i)); bRemove.setEnabled(true); } } }); combo.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (combo.getText().length() == 0) { bNew.setEnabled(false); } else { bNew.setEnabled(true); } } }); for (Sticker et : lEtiketten) { if (et.isVisible()) combo.add(et.getLabel()); } // new Label(ret,SWT.NONE).setText("Anzeige"); Composite bottom = new Composite(ret, SWT.NONE); bottom.setLayout(new GridLayout(3, false)); bNew = new Button(bottom, SWT.PUSH); bNew.setText(Messages.Stickers_NewSticker); bNew.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String name = combo.getText(); Sticker n = new Sticker(name, null, null); lEtiketten.add(n); combo.add(n.getLabel()); } }); bRemove = new Button(bottom, SWT.PUSH); bRemove.setText(Messages.Stickers_DeleteSticker); bRemove.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { int idx = combo.getSelectionIndex(); if (idx > -1) { // String n=combo.getItem(idx); combo.remove(idx); Sticker eti = lEtiketten.get(idx); lEtiketten.remove(idx); eti.delete(); } } }); Group bottomRight = new Group(bottom, SWT.NONE); bottomRight.setLayoutData(SWTHelper.getFillGridData(1, true, 5, true)); bottomRight.setLayout(new RowLayout(SWT.VERTICAL)); bottomRight.setText(Messages.Stickers_useFor); addAssociateButton(Messages.Stickers_patient, Patient.class, bottomRight); addAssociateButton(Messages.Stickers_consultation, Konsultation.class, bottomRight); addAssociateButton(Messages.Stickers_case, Fall.class, bottomRight); addAssociateButton(Messages.Stickers_document, Brief.class, bottomRight); /* * new Label(ret, SWT.SEPARATOR | SWT.HORIZONTAL).setLayoutData(SWTHelper.getFillGridData(2, * false, 1, false)); */ bottom.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); cImage = new Canvas(bottom, SWT.BORDER); cImage.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { GC gc = e.gc; if (act != null) { Image img = new UiSticker(act).getImage(); if (img != null) { gc.drawImage(img, 0, 0); return; } } gc.setForeground(UiDesk.getColor(UiDesk.COL_GREY20)); gc.fillRectangle(0, 0, 32, 32); } }); GridData gdImage = new GridData(32, 32); cImage.setLayoutData(gdImage); Button bNewImage = new Button(bottom, SWT.PUSH); bNewImage.setText(Messages.Stickers_Image); bNewImage.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (act != null) { ImageChooser imc = new ImageChooser(getShell()); if (imc.open() == Dialog.OK) { new UiSticker(act).setImage(imc.getSelection()); setSticker(act); } } } }); cFore = new Canvas(bottom, SWT.BORDER); GridData gdFore = new GridData(32, 16); cFore.setLayoutData(gdFore); Button bFore = new Button(bottom, SWT.PUSH); bFore.setText(Messages.Stickers_TextColor); bFore.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (act != null) { ColorDialog cd = new ColorDialog(getShell(), SWT.NONE); RGB rgb = cd.open(); if (rgb != null) { act.setForeground(UiDesk.createColor(rgb)); } setSticker(act); } } }); cBack = new Canvas(bottom, SWT.BORDER); GridData gdBack = GridDataFactory.copyData(gdFore); cBack.setLayoutData(gdBack); Button bBack = new Button(bottom, SWT.PUSH); bBack.setText(Messages.Stickers_BackgroundColor); bBack.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (act != null) { ColorDialog cd = new ColorDialog(getShell(), SWT.NONE); RGB rgb = cd.open(); if (rgb != null) { act.setBackground(UiDesk.createColor(rgb)); } setSticker(act); } } }); spWert = new Spinner(bottom, SWT.NONE); spWert.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (act != null) { act.setWert(spWert.getSelection()); } } }); new Label(bottom, SWT.NONE).setText(Messages.Stickers_ValueOfSticker); bNew.setEnabled(false); bRemove.setEnabled(false); return ret; }
From source file:ch.elexis.icpc.views.EncounterDisplay.java
License:Open Source License
public EncounterDisplay(Composite parent) { super(parent, SWT.NONE); form = UiDesk.getToolkit().createForm(this); setLayout(new GridLayout()); form.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); Composite body = form.getBody(); body.setLayout(new GridLayout()); gRfe = new Group(body, SWT.NONE); gRfe.setText("RFE / Problem"); GridData gd = SWTHelper.getFillGridData(1, true, 1, true); gd.heightHint = 30;/*from w ww .j a va 2s . c o m*/ gRfe.setLayoutData(gd); podRfe = new PersistentObjectDropTarget(gRfe, new PersistentObjectDropTarget.IReceiver() { public boolean accept(PersistentObject o) { if (o instanceof IcpcCode) { return true; } return false; } public void dropped(PersistentObject o, DropTargetEvent ev) { if ((actEncounter) != null && (o instanceof IcpcCode)) { actEncounter.setRFE((IcpcCode) o); setEncounter(actEncounter); } CodeSelectorHandler.getInstance().removeCodeSelectorTarget(); } }); gRfe.setLayout(new FillLayout()); gRfe.addMouseListener(new ClickReact(podRfe, "RFE")); lRfe = new Label(gRfe, SWT.WRAP); gDiag = new Group(body, SWT.NONE); gDiag.setText("Diagnose"); gDiag.setLayoutData(GridDataFactory.copyData(gd)); podDiag = new PersistentObjectDropTarget(gDiag, new PersistentObjectDropTarget.IReceiver() { public boolean accept(PersistentObject o) { if (o instanceof IcpcCode) { return true; } return false; } public void dropped(PersistentObject o, DropTargetEvent ev) { if ((actEncounter) != null && (o instanceof IcpcCode)) { actEncounter.setDiag((IcpcCode) o); setEncounter(actEncounter); } CodeSelectorHandler.getInstance().removeCodeSelectorTarget(); } }); gDiag.setLayout(new FillLayout()); gDiag.addMouseListener(new ClickReact(podDiag, "DG")); lDiag = new Label(gDiag, SWT.WRAP); gProc = new Group(body, SWT.NONE); gProc.setText("Procedere"); podProc = new PersistentObjectDropTarget(gProc, new PersistentObjectDropTarget.IReceiver() { public boolean accept(PersistentObject o) { if (o instanceof IcpcCode) { return true; } return false; } public void dropped(PersistentObject o, DropTargetEvent ev) { if ((actEncounter) != null && (o instanceof IcpcCode)) { actEncounter.setProc((IcpcCode) o); setEncounter(actEncounter); } CodeSelectorHandler.getInstance().removeCodeSelectorTarget(); } }); gProc.setLayoutData(GridDataFactory.copyData(gd)); gProc.setLayout(new FillLayout()); gProc.addMouseListener(new ClickReact(podProc, "PROC")); lProc = new Label(gProc, SWT.WRAP); }
From source file:ch.elexis.preferences.Stickers.java
License:Open Source License
@Override protected Control createContents(Composite parent) { Composite ret = new Composite(parent, SWT.NONE); ret.setLayout(new GridLayout()); ret.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); combo = new Combo(ret, SWT.SIMPLE); combo.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); combo.addSelectionListener(new SelectionAdapter() { @Override/*from w w w . ja v a 2 s. co m*/ public void widgetSelected(SelectionEvent e) { int i = combo.getSelectionIndex(); if (i > -1) { setSticker(lEtiketten.get(i)); bRemove.setEnabled(true); } } }); combo.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (combo.getText().length() == 0) { bNew.setEnabled(false); } else { bNew.setEnabled(true); } } }); for (Sticker et : lEtiketten) { if (et.getVisibility()) combo.add(et.getLabel()); } // new Label(ret,SWT.NONE).setText("Anzeige"); Composite bottom = new Composite(ret, SWT.NONE); bottom.setLayout(new GridLayout(3, false)); bNew = new Button(bottom, SWT.PUSH); bNew.setText(Messages.Stickers_NewSticker); bNew.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String name = combo.getText(); Sticker n = new Sticker(name, null, null); lEtiketten.add(n); combo.add(n.getLabel()); } }); bRemove = new Button(bottom, SWT.PUSH); bRemove.setText(Messages.Stickers_DeleteSticker); bRemove.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { int idx = combo.getSelectionIndex(); if (idx > -1) { // String n=combo.getItem(idx); combo.remove(idx); Sticker eti = lEtiketten.get(idx); lEtiketten.remove(idx); eti.delete(); } } }); Group bottomRight = new Group(bottom, SWT.NONE); bottomRight.setLayoutData(SWTHelper.getFillGridData(1, true, 5, true)); bottomRight.setLayout(new RowLayout(SWT.VERTICAL)); bottomRight.setText(Messages.Stickers_useFor); addAssociateButton(Messages.Stickers_patient, Patient.class, bottomRight); addAssociateButton(Messages.Stickers_consultation, Konsultation.class, bottomRight); addAssociateButton(Messages.Stickers_case, Fall.class, bottomRight); addAssociateButton(Messages.Stickers_document, Brief.class, bottomRight); /* * new Label(ret, SWT.SEPARATOR | SWT.HORIZONTAL).setLayoutData(SWTHelper.getFillGridData(2, * false, 1, false)); */ bottom.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); cImage = new Canvas(bottom, SWT.BORDER); cImage.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { GC gc = e.gc; if (act != null) { Image img = act.getImage(); if (img != null) { gc.drawImage(img, 0, 0); return; } } gc.setForeground(Desk.getColor(Desk.COL_GREY20)); gc.fillRectangle(0, 0, 32, 32); } }); GridData gdImage = new GridData(32, 32); cImage.setLayoutData(gdImage); Button bNewImage = new Button(bottom, SWT.PUSH); bNewImage.setText(Messages.Stickers_Image); bNewImage.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (act != null) { ImageChooser imc = new ImageChooser(getShell()); if (imc.open() == Dialog.OK) { act.setImage(imc.getSelection()); setSticker(act); } } } }); cFore = new Canvas(bottom, SWT.BORDER); GridData gdFore = new GridData(32, 16); cFore.setLayoutData(gdFore); Button bFore = new Button(bottom, SWT.PUSH); bFore.setText(Messages.Stickers_TextColor); bFore.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (act != null) { ColorDialog cd = new ColorDialog(getShell(), SWT.NONE); RGB rgb = cd.open(); if (rgb != null) { act.setForeground(Desk.createColor(rgb)); } setSticker(act); } } }); cBack = new Canvas(bottom, SWT.BORDER); GridData gdBack = GridDataFactory.copyData(gdFore); cBack.setLayoutData(gdBack); Button bBack = new Button(bottom, SWT.PUSH); bBack.setText(Messages.Stickers_BackgroundColor); bBack.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (act != null) { ColorDialog cd = new ColorDialog(getShell(), SWT.NONE); RGB rgb = cd.open(); if (rgb != null) { act.setBackground(Desk.createColor(rgb)); } setSticker(act); } } }); spWert = new Spinner(bottom, SWT.NONE); spWert.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (act != null) { act.setWert(spWert.getSelection()); } } }); new Label(bottom, SWT.NONE).setText(Messages.Stickers_ValueOfSticker); bNew.setEnabled(false); bRemove.setEnabled(false); return ret; }
From source file:com.astra.ses.spell.dev.wizards.pages.PackageWizardPage.java
License:Open Source License
@Override public void createControl(Composite parent) { /*//from ww w . jav a 2 s . co m * Main container */ Composite container = new Composite(parent, SWT.NONE); GridLayout gridLayout = new GridLayout(1, true); container.setLayout(gridLayout); ModifyListener modify = new ModifyListener() { @Override public void modifyText(ModifyEvent e) { validatePage(); } }; /* * Package location group */ Group packageGroup = new Group(container, SWT.BORDER); packageGroup.setText("Package information"); GridLayout groupLayout = new GridLayout(3, false); GridData groupData = new GridData(GridData.FILL_HORIZONTAL); groupData.grabExcessHorizontalSpace = true; packageGroup.setLayout(groupLayout); packageGroup.setLayoutData(groupData); // SOURCE FOLDER LABEL Label sourceFolderLabel = new Label(packageGroup, SWT.NONE); sourceFolderLabel.setText("Source folder"); m_sourceFolder = new Text(packageGroup, SWT.BORDER | SWT.READ_ONLY); m_sourceFolder.setLayoutData(GridDataFactory.copyData(groupData)); Button browseSourceFolder = new Button(packageGroup, SWT.PUSH); browseSourceFolder.setText("Browse"); browseSourceFolder.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { PythonPackageSelectionDialog dialog = new PythonPackageSelectionDialog(getShell(), false); dialog.open(); Object firstResult = dialog.getFirstResult(); if (firstResult instanceof SourceFolder) { //it is the default package SourceFolder f = (SourceFolder) firstResult; m_sourceFolder.setText(f.folder.getFullPath().toString()); m_package.setText(""); } if (firstResult instanceof org.python.pydev.ui.dialogs.Package) { org.python.pydev.ui.dialogs.Package f = (org.python.pydev.ui.dialogs.Package) firstResult; m_sourceFolder.setText(f.sourceFolder.folder.getFullPath().toString()); m_package.setText(f.getPackageName()); } } }); // PACKAGE NAME Label packageNameLabel = new Label(packageGroup, SWT.NONE); packageNameLabel.setText("Package name"); m_package = new Text(packageGroup, SWT.BORDER); m_package.setLayoutData(GridDataFactory.copyData(groupData)); m_package.addModifyListener(modify); /* * Validate the whole page */ validatePage(); /* * Set page's control */ setControl(container); }
From source file:com.astra.ses.spell.dev.wizards.pages.ProcedureInfoWizardPage.java
License:Open Source License
@Override public void createControl(Composite parent) { /*/* ww w . java2 s.co m*/ * Main composite */ Composite container = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(1, true); layout.verticalSpacing = 25; GridData layoutData = new GridData(GridData.FILL_HORIZONTAL); container.setLayout(layout); container.setLayoutData(layoutData); ModifyListener modifyListener = new ModifyListener() { @Override public void modifyText(ModifyEvent e) { validatePage(); } }; /* * Procedure name group */ Group procInfo = new Group(container, SWT.BORDER); procInfo.setText("Procedure information"); GridLayout infoLayout = new GridLayout(2, false); procInfo.setLayout(infoLayout); procInfo.setLayoutData(GridDataFactory.copyData(layoutData)); Label procInfoDesc = new Label(procInfo, SWT.NONE); GridData infoData = new GridData(GridData.FILL_HORIZONTAL); infoData.horizontalSpan = infoLayout.numColumns; infoData.heightHint = 25; infoData.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER; procInfoDesc.setLayoutData(infoData); procInfoDesc.setText("Procedure information fields will be used to create " + "the procedure source code header automatically."); Label procFilenameLabel = new Label(procInfo, SWT.NONE); procFilenameLabel.setText("File name"); m_procedureFilename = new Text(procInfo, SWT.BORDER); m_procedureFilename.setLayoutData(GridDataFactory.copyData(layoutData)); m_procedureFilename.addModifyListener(modifyListener); Label procNameLabel = new Label(procInfo, SWT.NONE); procNameLabel.setText("Name"); m_procedureName = new Text(procInfo, SWT.BORDER); m_procedureName.setLayoutData(GridDataFactory.copyData(layoutData)); m_procedureName.addModifyListener(modifyListener); Label procDescLabel = new Label(procInfo, SWT.NONE); procDescLabel.setText("Description"); m_procedureDescription = new Text(procInfo, SWT.BORDER); m_procedureDescription.setLayoutData(GridDataFactory.copyData(layoutData)); Label procSpacecraftsLabel = new Label(procInfo, SWT.NONE); procSpacecraftsLabel.setText("Spacecrafts"); m_procedureSpacecrafts = new Text(procInfo, SWT.BORDER); m_procedureSpacecrafts.setLayoutData(GridDataFactory.copyData(layoutData)); m_procedureSpacecrafts.addModifyListener(modifyListener); new Label(procInfo, SWT.NONE); Label scInfoLabel = new Label(procInfo, SWT.NONE); scInfoLabel.setText("Applicable spacecrafts list must be a comma sepparated list of " + "spacecraft names"); Label procSpecificationLabel = new Label(procInfo, SWT.NONE); procSpecificationLabel.setText("Specification"); m_procedureSpecification = new Text(procInfo, SWT.BORDER); m_procedureSpecification.setLayoutData(GridDataFactory.copyData(layoutData)); Label procDatabaseLabel = new Label(procInfo, SWT.NONE); procDatabaseLabel.setText("Database"); m_procedureDatabase = new Text(procInfo, SWT.BORDER); m_procedureDatabase.setLayoutData(GridDataFactory.copyData(layoutData)); Label procCategoryLabel = new Label(procInfo, SWT.NONE); procCategoryLabel.setText("Category"); m_procedureCategory = new Text(procInfo, SWT.BORDER); m_procedureCategory.setLayoutData(GridDataFactory.copyData(layoutData)); Label procAuthorLabel = new Label(procInfo, SWT.NONE); procAuthorLabel.setText("Developed by"); m_procedureAuthor = new Text(procInfo, SWT.BORDER); m_procedureAuthor.setLayoutData(GridDataFactory.copyData(layoutData)); Label procReviewerLabel = new Label(procInfo, SWT.NONE); procReviewerLabel.setText("Verified by"); m_procedureReviewer = new Text(procInfo, SWT.BORDER); m_procedureReviewer.setLayoutData(GridDataFactory.copyData(layoutData)); Label procValidatorLabel = new Label(procInfo, SWT.NONE); procValidatorLabel.setText("Validated by"); m_procedureValidator = new Text(procInfo, SWT.BORDER); m_procedureValidator.setLayoutData(GridDataFactory.copyData(layoutData)); /* * Procedure location group */ Group procLocation = new Group(container, SWT.BORDER); procLocation.setText("Procedure location"); GridLayout locationLayout = new GridLayout(3, false); GridData locationData = GridDataFactory.copyData(layoutData); procLocation.setLayout(locationLayout); procLocation.setLayoutData(locationData); Label projectLabel = new Label(procLocation, SWT.NONE); projectLabel.setText("Project"); m_projectText = new Text(procLocation, SWT.BORDER | SWT.READ_ONLY); GridData projectData = new GridData(GridData.FILL_HORIZONTAL); projectData.horizontalSpan = 2; m_projectText.setLayoutData(projectData); m_projectText.addModifyListener(modifyListener); Label packageLabel = new Label(procLocation, SWT.NONE); packageLabel.setText("Source folder"); m_packageText = new Text(procLocation, SWT.BORDER | SWT.READ_ONLY); m_packageText.setLayoutData(GridDataFactory.copyData(layoutData)); m_packageText.addModifyListener(modifyListener); Button browsePackage = new Button(procLocation, SWT.PUSH); browsePackage.setText("Browse"); browsePackage.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { try { PythonPackageSelectionDialog dialog = new PythonPackageSelectionDialog(getShell(), false); if (dialog.open() == Dialog.OK) { Object firstResult = dialog.getFirstResult(); IResource res = null; if (firstResult instanceof SourceFolder) { //it is the default package res = ((SourceFolder) firstResult).folder; } if (firstResult instanceof org.python.pydev.ui.dialogs.Package) { org.python.pydev.ui.dialogs.Package f = (org.python.pydev.ui.dialogs.Package) firstResult; res = f.folder; } m_projectText.setText(res.getProject().getName()); m_packageText.setText(res.getProjectRelativePath().toOSString()); } } catch (Exception e1) { PydevPlugin.log(e1); } } }); new Label(procLocation, SWT.NONE); Label explaining = new Label(procLocation, SWT.WRAP); GridData explData = new GridData(GridData.FILL_HORIZONTAL); explData.horizontalSpan = locationLayout.numColumns - 1; explaining.setLayoutData(explData); String explanation = "Procedures can only be created inside source folders"; explaining.setText(explanation); /* * Initialize some controls depending on the initial selection */ if (m_selection != null) { Object selected = m_selection.getFirstElement(); // Selected element may be a packge if (selected instanceof IFolder) { // retrieve project IProject project = ((IFolder) selected).getProject(); // retrieve source folder IFolder folder = (IFolder) selected; String sourceFolder = folder.getProjectRelativePath().toOSString(); // update widgets m_projectText.setText(project.getName()); m_packageText.setText(sourceFolder); } } validatePage(); container.layout(); container.pack(); // set Control setControl(container); }
From source file:com.astra.ses.spell.dev.wizards.pages.SourceFolderWizardPage.java
License:Open Source License
@Override public void createControl(Composite parent) { /*/*from ww w . j ava2 s . c o m*/ * Main container */ Composite container = new Composite(parent, SWT.NONE); GridLayout gridLayout = new GridLayout(1, true); container.setLayout(gridLayout); container.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL)); container.setFont(parent.getFont()); ModifyListener modify = new ModifyListener() { @Override public void modifyText(ModifyEvent e) { validatePage(); } }; /* * Input widgets */ Group main = new Group(container, SWT.BORDER); main.setText("Source folder information"); // Group layout GridLayout groupLayout = new GridLayout(3, false); main.setLayout(groupLayout); GridData groupData = new GridData(GridData.FILL_HORIZONTAL); groupData.grabExcessHorizontalSpace = true; main.setLayoutData(groupData); // Project name widgets Label nameLabel = new Label(main, SWT.NONE); nameLabel.setText("Project"); m_projectName = new Text(main, SWT.BORDER); m_projectName.setEditable(false); m_projectName.setLayoutData(GridDataFactory.copyData(groupData)); m_projectName.addModifyListener(modify); Button browseProject = new Button(main, SWT.PUSH); browseProject.setText("Browse"); browseProject.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { /* Open the project selection dialog */ ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), new WorkbenchLabelProvider()); dialog.setTitle("Project selection"); dialog.setTitle("Select a project."); dialog.setElements(ResourcesPlugin.getWorkspace().getRoot().getProjects()); dialog.open(); Object[] result = dialog.getResult(); if (result != null && result.length > 0) { m_projectName.setText(((IProject) result[0]).getName()); } } }); // Source folder widgets Label folderLabel = new Label(main, SWT.NONE); folderLabel.setText("Folder name"); m_folderName = new Text(main, SWT.BORDER); m_folderName.setLayoutData(GridDataFactory.copyData(groupData)); m_folderName.addModifyListener(modify); /* * Initialize the widgets */ if (m_selection != null) { Object first = m_selection.getFirstElement(); if (first instanceof IResource) { IResource resource = (IResource) first; IProject project = resource.getProject(); m_projectName.setText(project.getName()); browseProject.setEnabled(false); } System.out.println("SourceFolderWizardPage.createControl()"); } validatePage(); /* Set control */ setControl(container); }
From source file:com.astra.ses.spell.dev.wizards.procs.pages.ProcedureControlVersionWizardPage.java
License:Open Source License
@Override public void createControl(Composite parent) { // Main composite Composite container = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(1, true); GridData layoutData = new GridData(GridData.FILL_HORIZONTAL); container.setLayout(layout);//from w w w .ja v a 2 s .c om container.setLayoutData(layoutData); // Control version group Group cvGroup = new Group(container, SWT.BORDER); cvGroup.setText("Control version options"); GridLayout groupLayout = GridLayoutFactory.copyLayout(layout); cvGroup.setLayout(groupLayout); GridData groupData = GridDataFactory.copyData(layoutData); cvGroup.setLayoutData(groupData); // Add to control version button m_addButton = new Button(cvGroup, SWT.CHECK); m_addButton.setText("Add this file to version control after it has been created"); m_addButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Button add = (Button) e.widget; boolean selected = add.getSelection(); m_commitButton.setEnabled(selected); m_needsLockButton.setEnabled(selected); } }); // Commit button m_commitButton = new Button(cvGroup, SWT.CHECK); m_commitButton.setText("Commit this file after its creation"); Group propertiesGroup = new Group(container, SWT.BORDER); propertiesGroup.setText("Control version options"); GridLayout propLayout = GridLayoutFactory.copyLayout(groupLayout); propertiesGroup.setLayout(propLayout); GridData propData = new GridData(GridData.FILL_HORIZONTAL); propData.grabExcessHorizontalSpace = true; propertiesGroup.setLayoutData(propData); // Needs lock property button m_needsLockButton = new Button(propertiesGroup, SWT.CHECK); m_needsLockButton.setText("This file requires to be locked for its edition"); Label descLabel = new Label(propertiesGroup, SWT.NONE); descLabel.setText("Version control properties can only be set if the procedure is added.\n" + "Properties setting will only be effective after the procedure has been committed."); //Initialize the values m_addButton.setSelection(false); m_needsLockButton.setSelection(false); m_commitButton.setSelection(true); m_commitButton.setEnabled(false); m_needsLockButton.setEnabled(false); // validate page validatePage(); // set Control setControl(container); }
From source file:com.astra.ses.spell.gui.preferences.ui.pages.GeneralPreferencePage.java
License:Open Source License
@Override protected Control createContents(Composite parent) { // CONTAINER// w w w .j ava2 s . c o m Composite container = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(1, true); GridData layoutData = new GridData(GridData.FILL_BOTH); container.setLayout(layout); container.setLayoutData(layoutData); /* Page layout */ GridData expand = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING); expand.grabExcessVerticalSpace = true; expand.grabExcessHorizontalSpace = true; /* * Startup connection button */ Composite startupConnection = new Composite(container, SWT.NONE); startupConnection.setLayout(new GridLayout(2, false)); startupConnection.setLayoutData(GridDataFactory.copyData(expand)); // Button m_startupConnect = new Button(startupConnection, SWT.CHECK); // Label Label startupDesc = new Label(startupConnection, SWT.NONE); startupDesc.setText("Connect to server at startup"); // Label Label scpUser = new Label(startupConnection, SWT.NONE); scpUser.setText("User for SCP connections"); // Text m_scpUser = new Text(startupConnection, SWT.BORDER); m_scpUser.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // Label Label scpPwd = new Label(startupConnection, SWT.NONE); scpPwd.setText("Password for SCP connections"); // Text m_scpPassword = new Text(startupConnection, SWT.BORDER | SWT.PASSWORD); m_scpPassword.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); /* * Communication group */ GridLayout communicationLayout = new GridLayout(3, false); Group communicationGroup = new Group(container, SWT.BORDER); communicationGroup.setText("Communication"); communicationGroup.setLayout(communicationLayout); communicationGroup.setLayoutData(GridDataFactory.copyData(expand)); /* * Response timeout */ // Label Label responseTimeout = new Label(communicationGroup, SWT.NONE); responseTimeout.setText("Response timeout"); // Text m_responseTimeout = new Text(communicationGroup, SWT.BORDER | SWT.RIGHT); m_responseTimeout.setLayoutData(GridDataFactory.copyData(expand)); // Units label Label units = new Label(communicationGroup, SWT.NONE); units.setText("milliseconds"); /* * Procedure opening timeout */ // Label Label procedureOpenLabel = new Label(communicationGroup, SWT.NONE); procedureOpenLabel.setText("Procedure opening timeout"); // Text m_openTimeout = new Text(communicationGroup, SWT.BORDER | SWT.RIGHT); m_openTimeout.setLayoutData(GridDataFactory.copyData(expand)); // Label Label openUnits = new Label(communicationGroup, SWT.NONE); openUnits.setText("milliseconds"); /* * User group */ GridLayout userLayout = new GridLayout(3, true); Group userGroup = new Group(container, SWT.BORDER); userGroup.setText("User settings"); userGroup.setLayout(userLayout); userGroup.setLayoutData(GridDataFactory.copyData(expand)); /* * Prompt delay */ // Label Label promptDelayLabel = new Label(userGroup, SWT.NONE); promptDelayLabel.setText("Prompt blinking delay"); m_promptDelay = new Text(userGroup, SWT.BORDER | SWT.RIGHT); m_promptDelay.setLayoutData(GridDataFactory.copyData(expand)); // Label Label promptDelayUnitsLabel = new Label(userGroup, SWT.NONE); promptDelayUnitsLabel.setText("seconds"); /* * Prompt sound file */ // Label Label promptSoundLabel = new Label(userGroup, SWT.NONE); promptSoundLabel.setText("Prompt sound file"); m_soundFile = new Text(userGroup, SWT.BORDER); m_soundFile.setLayoutData(GridDataFactory.copyData(expand)); // Browse button final Button browse = new Button(userGroup, SWT.PUSH); browse.setText("Browse..."); browse.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { FileDialog dialog = new FileDialog(browse.getShell()); dialog.setFilterExtensions(new String[] { "*.wav" }); dialog.setText("Select prompt sound file"); dialog.setFilterNames(new String[] { "Waveform files (*.wav)" }); String selected = dialog.open(); if (selected != null) { m_soundFile.setText(selected); } } }); /* * Save group */ GridLayout saveLayout = new GridLayout(3, true); Group saveGroup = new Group(container, SWT.BORDER); saveGroup.setText("Save preferences"); saveGroup.setLayout(saveLayout); saveGroup.setLayoutData(GridDataFactory.copyData(expand)); /* * Save to current XML file */ final Button saveBtn = new Button(saveGroup, SWT.PUSH); saveBtn.setText("Save to current file"); saveBtn.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { IConfigurationManager conf = getConfigurationManager(); String cfgFile = conf.getConfigurationFile(); try { if (!MessageDialog.openConfirm(saveBtn.getShell(), "Overwrite preferences?", "This action will overwrite the current preferences stored in " + "the default configuration file '" + cfgFile + "'. Do you want to continue?")) return; GUIPreferencesSaver saver = new GUIPreferencesSaver(cfgFile); saver.savePreferences(); MessageDialog.openInformation(saveBtn.getShell(), "Preferences saved", "Preferences saved to file '" + cfgFile + "'"); } catch (Exception ex) { MessageDialog.openError(saveBtn.getShell(), "Cannot save preferences", "Unable to save preferences to '" + cfgFile + "'\n" + ex.getLocalizedMessage()); } } }); /* * Save to alternate XML file */ final Button saveOtherBtn = new Button(saveGroup, SWT.PUSH); saveOtherBtn.setText("Save to another file..."); saveOtherBtn.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { FileDialog dialog = new FileDialog(saveOtherBtn.getShell(), SWT.SAVE); dialog.setFilterExtensions(new String[] { "*.xml" }); dialog.setText("Select file to save preferences"); dialog.setFilterNames(new String[] { "XML files (*.xml)" }); String selected = dialog.open(); if (selected != null) { /* * If user has not set the file extension, then add it */ if (!selected.endsWith(".xml")) { selected += ".xml"; } try { File file = new File(selected); if (file.exists()) { if (!MessageDialog.openConfirm(saveOtherBtn.getShell(), "Overwrite file?", "File '" + selected + "' already exists. Overwrite?")) return; } GUIPreferencesSaver saver = new GUIPreferencesSaver(selected); saver.savePreferences(); MessageDialog.openInformation(saveOtherBtn.getShell(), "Preferences saved", "Preferences saved to file '" + selected + "'"); } catch (Exception ex) { MessageDialog.openError(saveOtherBtn.getShell(), "Cannot save preferences", "Unable to save preferences to '" + selected + "'\n" + ex.getLocalizedMessage()); } } } }); /* * Load preferences from an external file */ final Button loadPrefsBtn = new Button(saveGroup, SWT.PUSH); loadPrefsBtn.setText("Load from external file..."); loadPrefsBtn.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { FileDialog dialog = new FileDialog(loadPrefsBtn.getShell(), SWT.OPEN); dialog.setFilterExtensions(new String[] { "*.xml", "*.XML" }); String selected = dialog.open(); if (selected != null) { File file = new File(selected); if (file.exists()) { if (!MessageDialog.openConfirm(loadPrefsBtn.getShell(), "Overwrite preferences?", "All the current values will be replaced with the ones defined in the selected file.\n" + "Do you wish to continue?")) return; } /* * Overwrite preferences dialog */ IPreferenceStore store = Activator.getDefault().getPreferenceStore(); GUIPreferencesLoader loader = new GUIPreferencesLoader(selected, store); boolean loaded = loader.overwrite(); if (!loaded) { MessageDialog.openError(loadPrefsBtn.getShell(), "Error while loading configuration file", "An unexpected error ocurred while loading the configuration file.\n" + "Check the application log for details"); } } } }); refreshPage(); return container; }
From source file:com.astra.ses.spell.gui.preferences.ui.pages.GUIColorsPreferencePage.java
License:Open Source License
@Override protected Control createContents(Composite parent) { // CONTAINER/*w ww. j av a2 s .com*/ Composite container = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(2, true); GridData layoutData = new GridData(GridData.FILL_HORIZONTAL); layoutData.grabExcessHorizontalSpace = true; container.setLayout(layout); container.setLayoutData(layoutData); /* * Fill the widget with the color chooser controls */ IConfigurationManager conf = getConfigurationManager(); m_colorSelectors = new ColorSelector[GuiColorKey.values().length]; for (GuiColorKey key : GuiColorKey.values()) { Label label = new Label(container, SWT.NONE); label.setText(key.description); label.setLayoutData(GridDataFactory.copyData(layoutData)); ColorSelector selector = new ColorSelector(container); selector.setColorValue(conf.getGuiColor(key).getRGB()); m_colorSelectors[key.ordinal()] = selector; } return container; }
From source file:com.astra.ses.spell.gui.preferences.ui.pages.PresentationsPreferencePage.java
License:Open Source License
@Override protected Control createContents(Composite parent) { GridLayout parentLayout = new GridLayout(3, true); GridData parentData = new GridData(GridData.FILL_BOTH); Composite container = new Composite(parent, SWT.NONE); container.setLayout(parentLayout);// w w w . j av a 2s . com container.setLayoutData(parentData); Label enabled = new Label(container, SWT.NONE); enabled.setText("Enabled presentations"); Label empty = new Label(container, SWT.NONE); empty.setText(""); Label disabled = new Label(container, SWT.NONE); disabled.setText("Disabled presentations"); /* * Enabled presentations list widget */ m_enabledList = new List(container, SWT.SINGLE | SWT.BORDER); GridData enabledData = new GridData(GridData.FILL_BOTH); enabledData.verticalSpan = 4; m_enabledList.setLayoutData(enabledData); /* * List control button */ GridData expandButton = new GridData(GridData.FILL_HORIZONTAL); expandButton.verticalAlignment = SWT.TOP; ImageDescriptor imgDes = Activator.imageDescriptorFromPlugin(Fragment.FRAGMENT_UI, "icons/arrow_up.png"); final Button up = new Button(container, SWT.PUSH); up.setText("UP"); up.setImage(imgDes.createImage()); up.setEnabled(false); up.setLayoutData(GridDataFactory.copyData(expandButton)); /* * Disable presentations list */ m_disabledList = new List(container, SWT.SINGLE | SWT.BORDER); m_disabledList.setLayoutData(GridDataFactory.copyData(enabledData)); /* * Rest of the list control buttons */ imgDes = Activator.imageDescriptorFromPlugin(Fragment.FRAGMENT_UI, "icons/arrow_down.png"); final Button down = new Button(container, SWT.PUSH); down.setText("DOWN"); down.setImage(imgDes.createImage()); down.setEnabled(false); down.setLayoutData(GridDataFactory.copyData(expandButton)); imgDes = Activator.imageDescriptorFromPlugin(Fragment.FRAGMENT_UI, "icons/arrow_right.png"); final Button disable = new Button(container, SWT.PUSH); disable.setText("Disable"); disable.setImage(imgDes.createImage()); disable.setEnabled(false); disable.setLayoutData(GridDataFactory.copyData(expandButton)); imgDes = Activator.imageDescriptorFromPlugin(Fragment.FRAGMENT_UI, "icons/arrow_left.png"); final Button enable = new Button(container, SWT.PUSH); enable.setText("Enable"); enable.setImage(imgDes.createImage()); enable.setEnabled(false); enable.setLayoutData(GridDataFactory.copyData(expandButton)); /* * Enabled list listeners */ m_enabledList.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { } @Override public void focusGained(FocusEvent e) { enable.setEnabled(false); m_disabledList.deselectAll(); } }); m_enabledList.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { List list = (List) e.widget; boolean presentationSelected = list.getSelectionIndex() != -1; up.setEnabled(presentationSelected); down.setEnabled(presentationSelected); disable.setEnabled(presentationSelected); if (m_enabledList.getItemCount() == 1) { disable.setEnabled(false); } } }); /* * Disabled list listener */ m_disabledList.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { } @Override public void focusGained(FocusEvent e) { disable.setEnabled(false); up.setEnabled(false); down.setEnabled(false); m_enabledList.deselectAll(); } }); m_disabledList.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { List list = (List) e.widget; boolean presentationSelected = list.getSelectionIndex() != -1; enable.setEnabled(presentationSelected); } }); /* * Up button selection listener */ up.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int selected = m_enabledList.getSelectionIndex(); // If selected presentation is on top, then return if (selected <= 0) { return; } switchListElements(m_enabledList, selected, selected - 1); } }); /* * Down selection listener */ down.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int selected = m_enabledList.getSelectionIndex(); // If selected presentation is on top, then return if (selected == m_enabledList.getItems().length - 1) { return; } switchListElements(m_enabledList, selected, selected + 1); } }); /* * Enable selection listener */ enable.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int selected = m_disabledList.getSelectionIndex(); if (selected == -1) { return; } String presentation = m_disabledList.getItem(selected); m_enabledList.add(presentation); m_disabledList.remove(selected); m_disabledList.deselectAll(); } }); /* * Disable selection listener */ disable.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int selected = m_enabledList.getSelectionIndex(); if (selected == -1) { return; } String presentation = m_enabledList.getItem(selected); m_disabledList.add(presentation); m_enabledList.remove(selected); m_enabledList.deselectAll(); } }); Label explanation = new Label(container, SWT.WRAP); explanation.setText("First presentation in enabled list will be shown by default when opening a procedure"); GridData explData = new GridData(GridData.FILL_HORIZONTAL); explData.horizontalSpan = 3; explanation.setLayoutData(explData); /* * Fill the list with the preferences contents */ refreshPage(); return parent; }