public void widgetSelected(SelectionEvent e) { Object oSource = e.getSource(); if (oSource.equals(btnDown)) { fireHandleEvent(MOUSE_CLICKED_EVENT); toggleDropDown(); } else if (oSource.equals(this.btnImage)) { FileDialog fDlg = new FileDialog(this.getShell(), SWT.OPEN); cmpDropDown.getParent().dispose(); fDlg.setFilterExtensions(saImageTypes); String sStartFolder = System.getProperty("user.dir"); String sImageFile = ""; if (fCurrent instanceof Image) { String sFullPath = ((Image) fCurrent).getURL().toString(); sImageFile = sFullPath .substring(sFullPath.lastIndexOf("/") + 1); sStartFolder = sFullPath.substring(0, sFullPath .lastIndexOf("/")); } fDlg.setFilterPath(sStartFolder); fDlg.setFileName(sImageFile); fDlg.open();
public void widgetSelected(SelectionEvent e) { Object oSource = e.getSource(); if (oSource.equals(btnDown)) { fireHandleEvent(MOUSE_CLICKED_EVENT); toggleDropDown(); } else if (oSource.equals(this.btnImage)) { FileDialog fDlg = new FileDialog(this.getShell(), SWT.OPEN); cmpDropDown.getParent().dispose(); fDlg.setFilterExtensions(saImageTypes); String sStartFolder = System.getProperty("user.dir"); String sImageFile = ""; if (fCurrent instanceof Image) { String sFullPath = ((Image) fCurrent).getURL().toString(); sImageFile = sFullPath.substring(sFullPath.lastIndexOf("/") + 1); sStartFolder = sFullPath.substring(0, sFullPath.lastIndexOf("/")); } fDlg.setFilterPath(sStartFolder); fDlg.setFileName(sImageFile); String sImgPath = fDlg.open();
	public void widgetSelected(SelectionEvent e) {		Object oSource = e.getSource();		if (oSource.equals(btnDown)) {			fireHandleEvent(MOUSE_CLICKED_EVENT);			toggleDropDown();		} else if (oSource.equals(this.btnImage)) {			FileDialog fDlg = new FileDialog(this.getShell(), SWT.OPEN);			cmpDropDown.getParent().dispose();			fDlg.setFilterExtensions(saImageTypes);			String sStartFolder = System.getProperty("user.dir");			String sImageFile = "";			if (fCurrent instanceof Image) {				String sFullPath = ((Image) fCurrent).getURL().toString();				sImageFile = sFullPath						.substring(sFullPath.lastIndexOf("/") + 1);				sStartFolder = sFullPath.substring(0, sFullPath						.lastIndexOf("/"));			}			fDlg.setFilterPath(sStartFolder);			fDlg.setFileName(sImageFile);			fDlg.open();			String sImgPath = fDlg.getFileName();			// Do nothing if dialog was cancelled			if (sImgPath.trim().length() == 0) {				return;			}			try {				new URL(sImgPath);			} catch (MalformedURLException e1) {				sImgPath = "file:///" + fDlg.getFilterPath() + File.separator						+ fDlg.getFileName();			}			if (sImgPath != null && sImgPath.trim().length() > 0) {				Image imgFill = AttributeFactory.eINSTANCE.createImage();				imgFill.setURL(sImgPath);				this.setFill(imgFill);				fireHandleEvent(FillChooserComposite.FILL_CHANGED_EVENT);			}		} else if (oSource.equals(this.btnCustom)) {			ColorDialog cDlg = new ColorDialog(this.getShell(), SWT.NONE);			cmpDropDown.getParent().dispose();			if (fCurrent instanceof ColorDefinition) {				cDlg.setRGB(new RGB(((ColorDefinition) this.fCurrent).getRed(),						((ColorDefinition) this.fCurrent).getGreen(),						((ColorDefinition) this.fCurrent).getBlue()));			}			cDlg.open();			RGB rgb = cDlg.getRGB();			if (rgb != null) {				ColorDefinition cdNew = AttributeFactory.eINSTANCE						.createColorDefinition();				cdNew.set(rgb.red, rgb.green, rgb.blue);				this.setFill(cdNew);				fireHandleEvent(FillChooserComposite.FILL_CHANGED_EVENT);			}		} else if (oSource.equals(this.btnGradient)) {			GradientEditorDialog ged = null;			cmpDropDown.getParent().dispose();			if (fCurrent instanceof Gradient) {				ged = new GradientEditorDialog((Gradient) fCurrent);			} else {				ged = new GradientEditorDialog(null);			}			if (ged.getGradient() != null) {				Fill fTmp = ged.getGradient();				if (fCurrent == null || !(fCurrent.equals(fTmp))) {					this.setFill(fTmp);					fireHandleEvent(FillChooserComposite.FILL_CHANGED_EVENT);				}			}		} else if (oSource.equals(btnTransparent)) {			if (btnTransparent.getSelection()) {				fCurrent = null;			} else {				fCurrent = ColorDefinitionImpl.WHITE();			}			this.setFill(fCurrent);			fireHandleEvent(FillChooserComposite.FILL_CHANGED_EVENT);			cmpDropDown.getParent().dispose();		}	}