List of usage examples for org.eclipse.jface.viewers LabelProvider LabelProvider
public LabelProvider()
From source file:com.google.gdt.eclipse.designer.mobile.preferences.device.DevicesPreferencePage.java
License:Open Source License
/** * Creates {@link CheckboxTreeViewer} for categories/devices. *//*from w w w . jav a 2s . c o m*/ private void createViewer(Composite parent) { m_viewer = new CheckboxTreeViewer(parent, SWT.BORDER | SWT.MULTI); GridDataFactory.create(m_viewer.getTree()).grab().fill().hintC(50, 20); // content provider m_viewer.setContentProvider(new ITreeContentProvider() { public Object[] getElements(Object inputElement) { return DeviceManager.getCategories().toArray(); } public Object[] getChildren(Object parentElement) { if (parentElement instanceof CategoryInfo) { return ((CategoryInfo) parentElement).getDevices().toArray(); } return ArrayUtils.EMPTY_OBJECT_ARRAY; } public boolean hasChildren(Object element) { return getChildren(element).length != 0; } public Object getParent(Object element) { if (element instanceof DeviceInfo) { return ((DeviceInfo) element).getCategory(); } return null; } public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } }); // label provider m_viewer.setLabelProvider(new LabelProvider() { @Override public Image getImage(Object element) { if (element instanceof CategoryInfo) { return IMAGE_CATEGORY; } return IMAGE_DEVICE; } @Override public String getText(Object element) { if (element instanceof CategoryInfo) { CategoryInfo category = (CategoryInfo) element; return category.getName(); } else if (element instanceof DeviceInfo) { DeviceInfo device = (DeviceInfo) element; return device.getName() + " - " + device.getDisplayBounds().width + "x" + device.getDisplayBounds().height; } return null; } }); // set input m_viewer.setInput(this); refreshViewer(); refreshViewChecks(); // listeners m_viewer.addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { AbstractDeviceInfo element = (AbstractDeviceInfo) event.getElement(); commands_add(new ElementVisibilityCommand(element, event.getChecked())); } }); m_viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { updateButtons(); updatePreview(); } }); m_viewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { if (m_editButton.isEnabled()) { onEdit(); } } }); // DND configureDND(); }
From source file:com.google.gdt.eclipse.designer.model.property.css.StylesEditComposite.java
License:Open Source License
/** * Create CSS-file viewer.//w w w . j a v a2 s. c om */ protected void createFileGroup(Composite parent) { final int columns = 3; Group filesGroup = new Group(parent, SWT.NONE); filesGroup.setText("CSS files referenced from HTML"); GridLayoutFactory.create(filesGroup).columns(columns); GridDataFactory.create(filesGroup).grabH().fill(); // search { m_searchField = new StringItemDialogField(new IStringItemAdapter() { public void itemPressed(DialogField field) { searchRule(); } }); m_searchField.setLabelText("&Search CSS rule in files:"); m_searchField.setItemImage(DesignerPlugin.getImage("find.png")); m_searchField.setItemToolTip("Search"); m_searchField.doFillIntoGrid(filesGroup, 3); } { m_filesViewer = new ListViewer(filesGroup, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); GridDataFactory.create(m_filesViewer.getControl()).spanH(columns).grab().fill().hintC(80, 6); // set providers and input { m_filesViewer.setContentProvider(new DefaultStructuredContextProvider() { @SuppressWarnings("unchecked") public Object[] getElements(Object inputElement) { List<IFile> files = (List<IFile>) inputElement; return files.toArray(); } }); m_filesViewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { IFile file = (IFile) element; return file.getFullPath().toPortableString(); } }); } // add selection listener m_filesViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IFile file = (IFile) ((IStructuredSelection) event.getSelection()).getFirstElement(); setContext(getContext(file)); { Object firstElement = m_rulesViewer.getElementAt(0); if (firstElement != null) { m_rulesViewer.setSelection(new StructuredSelection(firstElement)); } } } }); } }
From source file:com.google.gdt.eclipse.designer.model.property.ImagePrototypePropertyEditor.java
License:Open Source License
@Override protected void openDialog(Property property) throws Exception { ElementTreeSelectionDialog selectionDialog; {//from ww w . ja v a2 s . c o m selectionDialog = new ElementTreeSelectionDialog(m_parentShell, new LabelProvider() { @Override public Image getImage(Object element) { if (element instanceof ImageBundleInfo) { return ObjectsLabelProvider.INSTANCE.getImage(element); } if (element instanceof ImageBundlePrototypeDescription) { ImageBundlePrototypeDescription prototype = (ImageBundlePrototypeDescription) element; return prototype.getIcon(); } return null; } @Override public String getText(Object element) { if (element instanceof ImageBundleInfo) { return ObjectsLabelProvider.INSTANCE.getText(element); } if (element instanceof ImageBundlePrototypeDescription) { ImageBundlePrototypeDescription prototype = (ImageBundlePrototypeDescription) element; return prototype.getMethod().getName() + "()"; } return null; } }, new ITreeContentProvider() { public Object[] getElements(Object inputElement) { return ImageBundleContainerInfo.getBundles((JavaInfo) inputElement).toArray(); } public Object[] getChildren(Object parentElement) { if (parentElement instanceof ImageBundleInfo) { return ((ImageBundleInfo) parentElement).getPrototypes().toArray(); } return ArrayUtils.EMPTY_OBJECT_ARRAY; } public Object getParent(Object element) { if (element instanceof ImageBundlePrototypeDescription) { return ((ImageBundlePrototypeDescription) element).getBundle(); } return null; } public boolean hasChildren(Object element) { return getChildren(element).length != 0; } public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } }) { @Override public void create() { super.create(); getTreeViewer().expandAll(); } @Override protected Control createDialogArea(Composite parent) { return super.createDialogArea(parent); } }; // validator selectionDialog.setValidator(new ISelectionStatusValidator() { public IStatus validate(Object[] selection) { if (selection.length == 1 && selection[0] instanceof ImageBundlePrototypeDescription) { return StatusUtils.OK_STATUS; } else { return StatusUtils.ERROR_STATUS; } } }); // configure selectionDialog.setAllowMultiple(false); selectionDialog.setTitle(property.getTitle()); selectionDialog.setMessage("Select prototype:"); // set input selectionDialog.setInput(m_rootJavaInfo); // set initial selection selectionDialog.setInitialSelection(property.getValue()); } // open dialog if (selectionDialog.open() == Window.OK) { ImageBundlePrototypeDescription prototype = (ImageBundlePrototypeDescription) selectionDialog .getFirstResult(); property.setValue(prototype); } }
From source file:com.google.gwt.eclipse.wtp.wizards.GwtFacetWizardPage.java
License:Open Source License
/** * Predefined path | [x] | Sdks Combo | | * * Custom path | [ ] | [ path to sdk ] | [browse] | *//*from w ww. j av a 2 s .c o m*/ @Override protected Composite createTopLevelComposite(Composite parent) { initializeDialogUnits(parent); Composite container = new Composite(parent, SWT.NONE); container.setLayout(new GridLayout()); Group sdkSelectionGroup = new Group(container, SWT.NONE); sdkSelectionGroup.setText("Select GWT SDK"); sdkSelectionGroup.setLayout(new GridLayout(3, false)); sdkSelectionGroup.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false)); Label lblSdks = new Label(sdkSelectionGroup, SWT.NONE); lblSdks.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); lblSdks.setText("Select from the defined SDKs"); new Label(sdkSelectionGroup, SWT.NONE); Button radioDefined = new Button(sdkSelectionGroup, SWT.RADIO); radioDefined.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { enablePaths(false); } }); radioDefined.setSelection(true); comboViewer = new ComboViewer(sdkSelectionGroup, SWT.NONE); comboViewer.setLabelProvider(new LabelProvider() { @Override @SuppressWarnings("unchecked") public String getText(Object element) { GWTRuntime sdk = (GWTRuntime) element; return sdk.getName(); } }); comboViewer.setContentProvider(new ArrayContentProvider()); comboViewerCombo = comboViewer.getCombo(); comboViewerCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); comboViewerCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { setSdkSelection(); } }); btnAddSdk = new Button(sdkSelectionGroup, SWT.NONE); btnAddSdk.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { openGwtPreferencesDialog(); } }); btnAddSdk.setText("Add SDK"); Label lblBlank = new Label(sdkSelectionGroup, SWT.NONE); new Label(sdkSelectionGroup, SWT.NONE); new Label(sdkSelectionGroup, SWT.NONE); Label lblCustomPath = new Label(sdkSelectionGroup, SWT.NONE); lblCustomPath.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); lblCustomPath.setText("Select a custom SDK location"); new Label(sdkSelectionGroup, SWT.NONE); Button radioPath = new Button(sdkSelectionGroup, SWT.RADIO); radioPath.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { enablePaths(true); } }); textPath = new Text(sdkSelectionGroup, SWT.BORDER); textPath.setEditable(false); textPath.setEnabled(false); textPath.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); btnDirBrowser = new Button(sdkSelectionGroup, SWT.NONE); btnDirBrowser.setEnabled(false); btnDirBrowser.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { showDirectoryDialog(); } }); btnDirBrowser.setText("Select SDK Directory"); addSdkOptionsToCombo(); Dialog.applyDialogFont(container); synchHelper.synchAllUIWithModel(); return container; }
From source file:com.googlecode.goclipse.ui.launch.GoLaunchConfigurationTab.java
License:Open Source License
@Override protected void openProgramPathDialog(IProject project) { // TODO: this should be refactored to show only main packages try {//from w w w. j av a 2s . c o m ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), new LabelProvider() { @Override public String getText(Object element) { GoPackageName goPackageName = (GoPackageName) element; return goPackageName.getFullNameAsString(); } }); dialog.setTitle("Select Go main package"); dialog.setMessage("Select Go main package"); GoEnvironment goEnv = GoProjectEnvironment.getGoEnvironment(project); Collection<GoPackageName> sourcePackages = GoProjectEnvironment.getSourcePackages(project, goEnv); dialog.setElements(ArrayUtil.createFrom(sourcePackages)); if (dialog.open() == IDialogConstants.OK_ID) { GoPackageName goPackageName = (GoPackageName) dialog.getFirstResult(); String packageResourcePath = goPackageName.getFullNameAsString(); if (!GoProjectEnvironment.isProjectInsideGoPath(project, goEnv.getGoPath())) { packageResourcePath = "src/" + packageResourcePath; } else { Path projectLocation = project.getLocation().toFile().toPath(); GoPackageName projectGoPackage = goEnv.getGoPath() .findGoPackageForSourceFile(projectLocation.resolve("dummy.go")); // snip project base name. packageResourcePath = StringUtil.segmentAfterMatch(packageResourcePath, projectGoPackage.getFullNameAsString() + "/"); } // check extension programPathField.setFieldValue(packageResourcePath); } } catch (CoreException ce) { UIOperationExceptionHandler.handleOperationStatus("Error selecting package from dialog: ", ce); } }
From source file:com.googlecode.goclipse.ui.launch.GoMainLaunchConfigurationTab.java
License:Open Source License
protected String openProgramPathDialog(IProject project) throws OperationCancellation { // TODO: this should be refactored to show only main packages try {//from w ww .j ava2 s .c om ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), new LabelProvider() { @Override public String getText(Object element) { GoPackageName goPackageName = (GoPackageName) element; return goPackageName.getFullNameAsString(); } }); dialog.setTitle("Select Go main package"); dialog.setMessage("Select Go main package"); GoEnvironment goEnv = GoProjectEnvironment.getGoEnvironment(project); Collection2<GoPackageName> sourcePackages = GoProjectEnvironment.findSourcePackages(project, goEnv); dialog.setElements(sourcePackages.toArray()); if (dialog.open() == IDialogConstants.OK_ID) { GoPackageName goPackageName = (GoPackageName) dialog.getFirstResult(); return goPackageName.getFullNameAsString(); } } catch (CommonException ce) { UIOperationsStatusHandler.handleStatus(false, "Error selecting package from dialog: ", ce); } throw new OperationCancellation(); }
From source file:com.hangum.tadpole.rdb.core.dialog.driver.JDBCDriverManageDialog.java
License:Open Source License
/** * Create contents of the dialog.//from ww w. j av a2 s.c o m * @param parent */ @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); GridLayout gridLayout = (GridLayout) container.getLayout(); gridLayout.verticalSpacing = 5; gridLayout.horizontalSpacing = 5; gridLayout.marginHeight = 5; gridLayout.marginWidth = 5; SashForm sashForm = new SashForm(container, SWT.NONE); sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); Composite compositeLeft = new Composite(sashForm, SWT.NONE); compositeLeft.setLayout(new GridLayout(1, false)); Label lblDriverList = new Label(compositeLeft, SWT.NONE); lblDriverList.setText(Messages.get().JDBCDriverSetting_DriverList); lvDB = new ListViewer(compositeLeft, SWT.BORDER | SWT.V_SCROLL); lvDB.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { StructuredSelection ss = (StructuredSelection) lvDB.getSelection(); if (ss.isEmpty()) return; DBDefine dbDefine = (DBDefine) ss.getFirstElement(); jdbc_dir = ApplicationArgumentUtils.JDBC_RESOURCE_DIR + dbDefine.getExt() + PublicTadpoleDefine.DIR_SEPARATOR; lblRealFullPath.setText(jdbc_dir); initDBFileList(); } }); List list = lvDB.getList(); list.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); lvDB.setContentProvider(new ArrayContentProvider()); lvDB.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { DBDefine dbDefine = (DBDefine) element; return dbDefine.getDBToString(); } }); lvDB.setInput(DBDefine.getDriver()); Composite compositeBody = new Composite(sashForm, SWT.NONE); compositeBody.setLayout(new GridLayout(3, false)); Label lblDumy = new Label(compositeBody, SWT.NONE); lblDumy.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1)); Label lblPath = new Label(compositeBody, SWT.NONE); lblPath.setText(Messages.get().JDBCDriverSetting_Path); lblRealFullPath = new Text(compositeBody, SWT.NONE | SWT.READ_ONLY); lblRealFullPath.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); Label txtFileList = new Label(compositeBody, SWT.NONE); txtFileList.setText(Messages.get().JDBCDriverSetting_FileList); new Label(compositeBody, SWT.NONE); new Label(compositeBody, SWT.NONE); lvDriverFile = new ListViewer(compositeBody, SWT.BORDER | SWT.V_SCROLL); lvDriverFile.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { btnDelete.setEnabled(true); } }); lvDriverFile.setContentProvider(new ArrayContentProvider()); lvDriverFile.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { String str = element.toString(); return str; } }); List listDriver = lvDriverFile.getList(); listDriver.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); Composite compositeBodyBtn = new Composite(compositeBody, SWT.NONE); compositeBodyBtn.setLayout(new GridLayout(1, false)); compositeBodyBtn.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true, 1, 1)); btnDelete = new Button(compositeBodyBtn, SWT.NONE); btnDelete.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { StructuredSelection ss = (StructuredSelection) lvDriverFile.getSelection(); if (ss.isEmpty()) return; String strFile = (String) ss.getFirstElement(); if (!MessageDialog.openConfirm(getShell(), Messages.get().Confirm, Messages.get().Delete)) return; if (logger.isDebugEnabled()) logger.debug("File delete : " + jdbc_dir + strFile); try { FileUtils.forceDelete(new File(jdbc_dir + strFile)); initDBFileList(); } catch (IOException e1) { logger.error("File delete", e1); MessageDialog.openError(getShell(), Messages.get().Error, "File deleteing: " + e1.getMessage()); } } }); btnDelete.setText(Messages.get().Delete); final String url = startUploadReceiver(); pushSession = new ServerPushSession(); fileUpload = new FileUpload(compositeBodyBtn, SWT.NONE); fileUpload.setText(Messages.get().JDBCDriverSetting_JARUpload); fileUpload.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); fileUpload.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String fileName = fileUpload.getFileName(); if ("".equals(fileName) || null == fileName) //$NON-NLS-1$ return; if (!MessageDialog.openConfirm(null, Messages.get().Confirm, Messages.get().SQLiteLoginComposite_17)) return; if (logger.isDebugEnabled()) logger.debug("=[file name]==> " + fileName); pushSession.start(); fileUpload.submit(url); } }); Button btnRefresh = new Button(compositeBodyBtn, SWT.NONE); btnRefresh.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { initDBFileList(); } }); btnRefresh.setText(Messages.get().Refresh); sashForm.setWeights(new int[] { 3, 7 }); initManager(); return container; }
From source file:com.hibouhome.rcp.spikes.databinding.parts.StockistsPart.java
License:Open Source License
private void createCountriesListViewer(final Composite parent) { countriesListViewer = new ListViewer(parent); countriesListViewer.getList().setLayoutData(new GridData(60, 300)); countriesListViewer.setLabelProvider(new LabelProvider() { @Override//w w w. java 2 s.com public String getText(final Object element) { return ((Country) element).getName(); } }); countriesListViewer.setContentProvider(new ObservableListContentProvider()); final IEMFListProperty countriesProperty = EMFProperties .list(StockistsPackage.Literals.STOCKISTS__COUNTRIES); countriesListViewer.setInput(countriesProperty.observe(stockists)); }
From source file:com.hibouhome.rcp.spikes.databinding.parts.StockistsPart.java
License:Open Source License
private void createRegionsListViewer(final Composite parent) { regionsListViewer = new ListViewer(parent); regionsListViewer.getList().setLayoutData(new GridData(120, 300)); regionsListViewer.setLabelProvider(new LabelProvider() { @Override// w ww . j a va2 s . c o m public String getText(final Object element) { return ((Region) element).getName(); } }); regionsListViewer.setContentProvider(new ObservableListContentProvider()); }
From source file:com.hibouhome.rcp.spikes.databinding.parts.StockistsPart.java
License:Open Source License
private void createStockistsListViewer(final Composite parent) { stockistsListViewer = new ListViewer(parent); stockistsListViewer.getList().setLayoutData(new GridData(180, 300)); stockistsListViewer.setLabelProvider(new LabelProvider() { @Override/*from w w w .j a v a2s. co m*/ public String getText(final Object element) { return ((Stockist) element).getName(); } }); stockistsListViewer.setContentProvider(new ObservableListContentProvider()); }