List of usage examples for org.eclipse.jface.viewers LabelProvider LabelProvider
public LabelProvider()
From source file:com.mindquarry.desktop.minutes.editor.widget.PeopleWidget.java
License:Open Source License
/** * {@inheritDoc}/* w ww .j av a2 s.co m*/ * * @see com.mindquarry.desktop.minutes.editor.widget.EditorWidget#createContents(org.eclipse.swt.widgets.Composite) */ protected void createContents(Composite parent) { Table table = new Table(parent, SWT.MULTI); TableColumn titleColumn = new TableColumn(table, SWT.NONE); titleColumn.setResizable(false); TableViewer viewer = new TableViewer(table); viewer.setColumnProperties(new String[] { PARTICIPANT_COL }); viewer.setLabelProvider(new LabelProvider() { }); viewer.setContentProvider(new IStructuredContentProvider() { /** * @see org.eclipse.jface.viewers.IContentProvider#dispose() */ public void dispose() { // nothing to do so far } /** * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, * java.lang.Object, java.lang.Object) */ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { // nothing to do so far } /** * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) */ public Object[] getElements(Object inputElement) { if (inputElement instanceof List) { List list = (List) inputElement; return list.toArray(); } return null; } }); }
From source file:com.mmkarton.mx7.reportgenerator.wizards.BIRTSQLWizardPage.java
License:Open Source License
private void setFilterComboContents(ComboViewer filterComboViewer, boolean supportsProcedure) { if (filterComboViewer == null) { return;//w w w . j a va 2s .co m } List<FilterConfig.Type> types = new ArrayList<FilterConfig.Type>(); // Populate the Types of Data bases objects which can be retrieved types.add(Type.ALL); types.add(Type.TABLE); types.add(Type.VIEW); if (supportsProcedure) { types.add(Type.PROCEDURE); } filterComboViewer.setContentProvider(new IStructuredContentProvider() { @SuppressWarnings("unchecked") public Object[] getElements(Object inputElement) { return ((List) inputElement).toArray(); } public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } }); filterComboViewer.setLabelProvider(new LabelProvider() { public String getText(Object inputElement) { FilterConfig.Type type = (FilterConfig.Type) inputElement; return FilterConfig.getTypeDisplayText(type); } }); filterComboViewer.setInput(types); // Set the Default selection to the First Item , which is "All" filterComboViewer.getCombo().select(0); filterComboViewer.getCombo().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Type type = getSelectedFilterType(); /*if ( type == Type.ALL || type == Type.TABLE ) { showSystemTableCheckBox.setEnabled( true ); } else { showSystemTableCheckBox.setEnabled( false ); }*/ } }); }
From source file:com.mobilesorcery.sdk.profiles.ui.DeviceFilterComposite.java
License:Open Source License
public DeviceFilterComposite(Composite parent, int style) { super(parent, style); GridLayout layout = new GridLayout(1, false); layout.marginWidth = 0;/*from www .j ava 2s.c o m*/ setLayout(layout); Composite buttonRow = new Composite(this, SWT.NONE); buttonRow.setLayout(new GridLayout(3, true)); add = new Button(buttonRow, SWT.PUSH); add.setText(Messages.DeviceFilterComposite_Add); constrainSize(add, 85, SWT.DEFAULT); remove = new Button(buttonRow, SWT.PUSH); remove.setText(Messages.DeviceFilterComposite_Remove); constrainSize(remove, 85, SWT.DEFAULT); edit = new Button(buttonRow, SWT.PUSH); edit.setText(Messages.DeviceFilterComposite_Edit); constrainSize(edit, 85, SWT.DEFAULT); add.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { SelectFilterTypeDialog dialog = new SelectFilterTypeDialog(getShell()); int result = dialog.open(); if (result == IDialogConstants.OK_ID && dialog.getFilter() != null) { filter.addFilter(dialog.getFilter()); updateUI(true); } } }); edit.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { editSelectedFilter(); } }); filterTable = new TableViewer(this); filterTable.setContentProvider(new ArrayContentProvider()); filterTable.setLabelProvider(new LabelProvider()); filterTable.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { updateUI(false); } }); GridData filterTableData = new GridData(SWT.FILL, SWT.FILL, true, true); filterTable.getControl().setLayoutData(filterTableData); filterTable.getControl().addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.DEL) { removeSelectedFilters(); } } @Override public void keyReleased(KeyEvent e) { } }); remove.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { removeSelectedFilters(); } }); deviceCountLabel = new Label(this, SWT.TRAIL); deviceCountLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); updateUI(true); }
From source file:com.mobilesorcery.sdk.ui.internal.launch.MoSyncLaunchParamsTab.java
License:Open Source License
private void createLaunchDelegateEditor(Composite control) { Set<String> ids = sortLaunchers(CoreMoSyncPlugin.getDefault().getEmulatorLauncherIds()); launchDelegateHolderParent = control; Group launchDelegateGroup = new Group(control, SWT.NONE); launchDelegateGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); launchDelegateGroup.setText("&Emulator"); launchDelegateGroup.setLayout(new GridLayout(1, false)); launchDelegateList = new ComboViewer(launchDelegateGroup); launchDelegateList.setContentProvider(new ArrayContentProvider()); launchDelegateList.setInput(filterLaunchDelegateIds(ids).toArray()); launchDelegateList.setLabelProvider(new LabelProvider() { @Override// w ww . j ava 2s .c om public String getText(Object element) { return CoreMoSyncPlugin.getDefault().getEmulatorLauncher((String) element).getName(); } }); launchDelegateList.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); String id = (String) selection.getFirstElement(); switchDelegate(id, false); } }); launchDelegateList.getCombo().addModifyListener(listener); launchDelegateHolderParent = launchDelegateGroup; launchDelegateHolder = new Composite(launchDelegateHolderParent, SWT.NONE); launchDelegateHolder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); launchDelegateHolderLayout = new StackLayout(); launchDelegateHolder.setLayout(launchDelegateHolderLayout); switchDelegate(MoReLauncher.ID, true); }
From source file:com.mobilesorcery.sdk.ui.targetphone.android.AndroidTargetPhoneTransport.java
License:Open Source License
@Override public ITargetPhone scan(IShellProvider shellProvider, IProgressMonitor monitor) throws CoreException { final List<String> devices = ADB.getDefault().listDeviceSerialNumbers(true); if (devices.size() == 0) { throw new CoreException( new Status(IStatus.ERROR, TargetPhonePlugin.PLUGIN_ID, "No android devices connected")); }//from w w w .ja va 2 s. c o m final AndroidTargetPhone[] phone = new AndroidTargetPhone[1]; final Shell shell = shellProvider.getShell(); shell.getDisplay().syncExec(new Runnable() { @Override public void run() { ListDialog dialog = new ListDialog(shell); dialog.setTitle("Android Device"); dialog.setMessage("Select Android device to use"); dialog.setContentProvider(new ArrayContentProvider()); dialog.setLabelProvider(new LabelProvider()); dialog.setInput(devices.toArray()); if (dialog.open() == ListDialog.OK) { Object[] dialogResult = dialog.getResult(); if (dialogResult.length > 0) { String serialNumber = (String) dialogResult[0]; phone[0] = new AndroidTargetPhone(serialNumber, serialNumber, AndroidTargetPhoneTransport.ID); } } } }); return phone[0]; }
From source file:com.motorola.studio.android.launch.ui.DeviceSelectionDialog.java
License:Apache License
/** * Default constructor /*ww w . jav a 2 s . c o m*/ * * @param parent Parent shell * @param description Dialog description */ public DeviceSelectionDialog(Shell parent, String description, final IProject project) { super(parent, new LabelProvider() { @Override public String getText(Object element) { String result = ""; if (element instanceof ISerialNumbered) { ISerialNumbered serialNumbered = (ISerialNumbered) element; result = serialNumbered.getDeviceName(); if (serialNumbered instanceof IAndroidEmulatorInstance) { IAndroidEmulatorInstance emulatorInstance = (IAndroidEmulatorInstance) serialNumbered; int emulatorApi = emulatorInstance.getAPILevel(); String emulatorTarget = emulatorInstance.getTarget(); result += " (" + emulatorTarget + ", Api version " + emulatorApi + ")"; } else if (serialNumbered instanceof IInstance) { IInstance instance = (IInstance) serialNumbered; Properties properties = instance.getProperties(); if (properties != null) { String target = properties.getProperty("ro.build.version.release"); //$NON-NLS-1$ if (target != null) { result += " (Android " + target + ")"; } } } } return result; } @Override public Image getImage(Object element) { Image img = null; ISerialNumbered serialNumbered = (ISerialNumbered) element; IStatus compatible = LaunchUtils.isCompatible(project, serialNumbered); // notify the warning state if (compatible.getSeverity() == IStatus.WARNING) { img = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK); } return img; } }); this.setTitle(LaunchNLS.UI_LaunchComposite_SelectDeviceScreenTitle); this.setMessage(description); Collection<ISerialNumbered> instances = DevicesManager.getInstance().getAllDevicesSorted(); if ((project != null) && (instances != null) && (instances.size() > 0)) { Collection<ISerialNumbered> filteredInstances = LaunchUtils.filterInstancesByProject(instances, project); Object[] filteredInstancesArray = filteredInstances.toArray(); this.setElements(filteredInstancesArray); } this.setHelpAvailable(true); PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, DEV_SELECTION_CONTEXT_HELP_ID); }
From source file:com.motorola.studio.android.launch.ui.LaunchConfigurationTab.java
License:Apache License
/** * Create the main information selection group * @param mainComposite: the parent composite */// w ww . j a va 2s. c om private void createMainInfoGroup(Composite mainComposite) { this.mainComposite = mainComposite; // create destination group Group destinationGroup = new Group(mainComposite, SWT.NONE); GridLayout layout = new GridLayout(3, false); destinationGroup.setLayout(layout); GridData defaultDestGridData = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1); destinationGroup.setLayoutData(defaultDestGridData); destinationGroup.setText(LaunchNLS.LaunchComposite_UI_LaunchComposite_DestinationGroupText); // Project Name Label Label projectNameLabel = new Label(destinationGroup, SWT.NONE); projectNameLabel.setText(LaunchNLS.UI_LaunchComposite_ProjectNameLabel); GridData folderGridData = new GridData(SWT.LEFT, SWT.CENTER, false, false); projectNameLabel.setLayoutData(folderGridData); // Project Name Text final Text projectNameText = new Text(destinationGroup, SWT.SINGLE | SWT.BORDER); projectNameText.setText(projectName); folderGridData = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); projectNameText.setLayoutData(folderGridData); projectNameText.addModifyListener(new ModifyListener() { /* * (non-Javadoc) * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent) */ public void modifyText(ModifyEvent e) { if (e.data == UPDATE_WIDGETS_EVENT) { projectNameText.setText(projectName); } else { projectName = projectNameText.getText(); updateLaunchConfigurationDialog(); } } }); // Project Name Browse Button Button projectNameBrowseButton = new Button(destinationGroup, SWT.PUSH); folderGridData = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); projectNameBrowseButton.setLayoutData(folderGridData); projectNameBrowseButton.setText(LaunchNLS.UI_LaunchComposite_BrowseButton); projectNameBrowseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { AndroidProjectsSelectionDialog dialog = new AndroidProjectsSelectionDialog(getShell()); int result = dialog.open(); if (result == Dialog.OK) { Object resultProject = dialog.getFirstResult(); if (resultProject instanceof IProject) { IProject project = (IProject) resultProject; projectNameText.setText(project.getName()); } } } }); Group activityGroup = new Group(mainComposite, SWT.NONE); GridLayout activityLayout = new GridLayout(3, false); activityGroup.setLayout(activityLayout); GridData activityGrid = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1); activityGroup.setLayoutData(activityGrid); activityGroup.setText(LaunchNLS.UI_LaunchComposite_ActivityGroupLabel); final Button defaultActivityButton = new Button(activityGroup, SWT.RADIO); defaultActivityButton.setText(LaunchNLS.UI_LaunchComposite_ActivityDefaultButton); GridData gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.horizontalSpan = 3; defaultActivityButton.setLayoutData(gridData); // Activity Name Button final Button specificActivityButton = new Button(activityGroup, SWT.RADIO); specificActivityButton.setText(LaunchNLS.LaunchConfigurationTab_LaunchButton); GridData activityData = new GridData(SWT.LEFT, SWT.CENTER, false, false); specificActivityButton.setLayoutData(activityData); // Activity Name Text final Text activityNameText = new Text(activityGroup, SWT.SINGLE | SWT.BORDER); activityNameText.setText(activityName); activityData = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); activityNameText.setLayoutData(activityData); activityNameText.addModifyListener(new ModifyListener() { /* * (non-Javadoc) * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent) */ public void modifyText(ModifyEvent e) { if (e.data == UPDATE_WIDGETS_EVENT) { activityNameText.setText(activityName); } else { activityName = activityNameText.getText(); updateLaunchConfigurationDialog(); } } }); // Activity Name Browse Button final Button activityNameBrowseButton = new Button(activityGroup, SWT.PUSH); activityData = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); activityNameBrowseButton.setLayoutData(activityData); activityNameBrowseButton.setText(LaunchNLS.UI_LaunchComposite_BrowseButton); activityNameBrowseButton.addSelectionListener(new SelectionAdapter() { /** * Retrieve all activities of a given project * @return All the activities of a given project */ private Set<String> getAllActivities(String projectName) { String[] tempActivities = null; Set<String> activities = new HashSet<String>(); if (projectName.length() != 0) { IProject selectedProject = LaunchUtils.getProject(projectName); tempActivities = LaunchUtils.getProjectActivities(selectedProject); for (String s : tempActivities) { activities.add(s); } } return activities; } /* * (non-Javadoc) * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) */ @Override public void widgetSelected(SelectionEvent e) { if (projectName.length() == 0) { IWorkbenchWindow ww = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); MessageDialog.openInformation(ww.getShell(), LaunchNLS.UI_LaunchComposite_ProjectRequiredTitle, LaunchNLS.UI_LaunchComposite_ProjectRequiredMessage); } else { ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), new LabelProvider() { @Override public String getText(Object element) { String activity = (String) element; return activity; } }) { /* * (non-Javadoc) * @see org.eclipse.ui.dialogs.ElementListSelectionDialog#createDialogArea(org.eclipse.swt.widgets.Composite) */ @Override protected Control createDialogArea(Composite parent) { PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ACTIVITY_SELECTION_DIALOG_HELPID); return super.createDialogArea(parent); } }; dialog.setTitle(LaunchNLS.UI_LaunchComposite_SelectActivityScreenTitle); dialog.setMessage(LaunchNLS.UI_LaunchComposite_SelectActivityScreenMessage); Object[] allActivities = getAllActivities(projectNameText.getText()).toArray(); if (allActivities.length == 0) { activityNameText.setText(""); //$NON-NLS-1$ } else { dialog.setElements(getAllActivities(projectNameText.getText()).toArray()); int buttonId = dialog.open(); if (buttonId == IDialogConstants.OK_ID) { String activity = (String) dialog.getFirstResult(); activityNameText.setText(activity); } } } } protected static final String ACTIVITY_SELECTION_DIALOG_HELPID = "com.motorola.studio.android.launch.activitySelectionDialog"; //$NON-NLS-1$ }); final Button noActivityButton = new Button(activityGroup, SWT.RADIO); noActivityButton.setText(LaunchNLS.LaunchConfigurationTab_DoNothingButton); gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.horizontalSpan = 3; noActivityButton.setLayoutData(gridData); defaultActivityButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (e.data == UPDATE_WIDGETS_EVENT) { defaultActivityButton.setSelection(!activitySpecified && runDefaultActivity); activityNameText.setEnabled(activitySpecified); activityNameBrowseButton.setEnabled(activitySpecified); } else { // handle variables handleActivityLauncherTypeVariables(defaultActivityButton, specificActivityButton, activityNameText, activityNameBrowseButton); } } }); specificActivityButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (e.data == UPDATE_WIDGETS_EVENT) { specificActivityButton.setSelection(activitySpecified && !runDefaultActivity); activityNameText.setEnabled(activitySpecified); activityNameBrowseButton.setEnabled(activitySpecified); } else { // handle variables handleActivityLauncherTypeVariables(defaultActivityButton, specificActivityButton, activityNameText, activityNameBrowseButton); } } }); noActivityButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (e.data == UPDATE_WIDGETS_EVENT) { noActivityButton.setSelection(!activitySpecified && !runDefaultActivity); activityNameText.setEnabled(activitySpecified); activityNameBrowseButton.setEnabled(activitySpecified); } else { // handle variables handleActivityLauncherTypeVariables(defaultActivityButton, specificActivityButton, activityNameText, activityNameBrowseButton); } } }); // Device Name Label Label deviceNameLabel = new Label(destinationGroup, SWT.NONE); deviceNameLabel.setText(LaunchNLS.UI_LaunchComposite_DeviceNameLabel); GridData deviceGridData = new GridData(SWT.LEFT, SWT.CENTER, false, false); deviceNameLabel.setLayoutData(deviceGridData); // Device Name Text final Text deviceNameText = new Text(destinationGroup, SWT.SINGLE | SWT.BORDER); deviceNameText.setText(deviceName); deviceGridData = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); deviceNameText.setLayoutData(deviceGridData); deviceNameText.addModifyListener(new ModifyListener() { /* * (non-Javadoc) * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent) */ public void modifyText(ModifyEvent e) { if (e.data == UPDATE_WIDGETS_EVENT) { deviceNameText.setText(deviceName); } else { deviceName = deviceNameText.getText(); updateLaunchConfigurationDialog(); } } }); // Device Name Browse Button deviceNameBrowseButton = new Button(destinationGroup, SWT.PUSH); deviceGridData = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); deviceNameBrowseButton.setLayoutData(deviceGridData); deviceNameBrowseButton.setText(LaunchNLS.UI_LaunchComposite_BrowseButton); deviceNameBrowseButton.addSelectionListener(new SelectionAdapter() { /* * (non-Javadoc) * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) */ @Override public void widgetSelected(SelectionEvent e) { IProject selectedProject = LaunchUtils.getProject(projectNameText.getText()); DeviceSelectionDialog dialog = new DeviceSelectionDialog(getShell(), LaunchNLS.UI_LaunchComposite_SelectDeviceScreenMessage, selectedProject); dialog.setTitle(LaunchNLS.UI_LaunchComposite_SelectDeviceScreenTitle); dialog.setMultipleSelection(false); dialog.setValidator(new ISelectionStatusValidator() { public IStatus validate(Object[] selection) { IStatus status = new Status(IStatus.OK, LaunchPlugin.PLUGIN_ID, ""); //$NON-NLS-1$ if (selection.length == 0) { status = new Status(IStatus.ERROR, LaunchPlugin.PLUGIN_ID, "No selected instance"); //$NON-NLS-1$ } return status; } }); int res = dialog.open(); if (res == IDialogConstants.OK_ID) { ISerialNumbered serialNumbered = (ISerialNumbered) dialog.getFirstResult(); String selectedDevice = ((IInstance) serialNumbered).getName(); deviceNameText.setText(selectedDevice); } } }); InstanceEventManager.getInstance().addInstanceListener(instanceListener); Link createNewAvdLink = new Link(destinationGroup, SWT.NONE); deviceGridData = new GridData(SWT.RIGHT, SWT.CENTER, true, false, 3, 1); createNewAvdLink.setLayoutData(deviceGridData); createNewAvdLink.setText(LaunchNLS.LaunchConfigurationTab_CreateNewAVDLink); createNewAvdLink.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { OpenNewDeviceWizardHandler handler = new OpenNewDeviceWizardHandler(); try { handler.execute(new ExecutionEvent()); } catch (ExecutionException exception) { //do nothing } } }); mainComposite.addListener(SWT.Modify, new Listener() { /* * (non-Javadoc) * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event) */ public void handleEvent(Event e) { projectNameText.notifyListeners(SWT.Modify, e); activityNameText.notifyListeners(SWT.Modify, e); deviceNameText.notifyListeners(SWT.Modify, e); defaultActivityButton.notifyListeners(SWT.Selection, e); specificActivityButton.notifyListeners(SWT.Selection, e); noActivityButton.notifyListeners(SWT.Selection, e); if (defaultLauncherButton != null) { defaultLauncherButton.notifyListeners(SWT.Selection, e); } if (vdlLauncherButton != null) { vdlLauncherButton.notifyListeners(SWT.Selection, e); } } }); PlatformUI.getWorkbench().getHelpSystem().setHelp(mainComposite, LAUNCH_DIALOG_HELP); //$NON-NLS-1$ }
From source file:com.motorola.studio.android.obfuscate.ui.ObfuscateDialog.java
License:Apache License
@Override protected Control createDialogArea(Composite parent) { super.createDialogArea(parent).setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Composite mainComposite = new Composite(parent, SWT.NONE); mainComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); GridLayout layout = new GridLayout(1, false); mainComposite.setLayout(layout);/* w w w . j a v a 2 s.co m*/ treeViewer = new CheckboxTreeViewer(mainComposite, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL); treeViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); // Set content and label provider treeViewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { String label = null; if (element instanceof IProject) { label = ((IProject) element).getName(); } return label; } }); treeViewer.setContentProvider(new TreeViewerContentProvider()); ArrayList<IProject> projectsList = generateInputForTree(); treeViewer.setInput(projectsList); for (IProject p : projectsList) { treeViewer.setChecked(p, ObfuscatorManager.isProguardSet(p)); } treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { selectedProjects = treeViewer.getCheckedElements(); } }); treeViewer.expandAll(); mainComposite.layout(true); setTitle(AndroidNLS.ObfuscateProjectsHandler_2); setMessage(AndroidNLS.ObfuscateProjectsHandler_3, IMessageProvider.NONE); PlatformUI.getWorkbench().getHelpSystem().setHelp(mainComposite, OBFUSCATION_DIALOG_HELP); return mainComposite; }
From source file:com.motorola.studio.android.wizards.buildingblocks.ActivitySampleSelectionPage.java
License:Apache License
@Override protected void createExtendedControls(Composite parent) { Composite mainComposite = new Composite(parent, SWT.FILL); mainComposite.setLayout(new GridLayout(1, false)); mainComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); // Samples Tree Label Label itemsTableLabel = new Label(mainComposite, SWT.NONE); itemsTableLabel.setText(CodeUtilsNLS.UI_SampleSelectionPage_SamplesTreeLabel); // Samples Tree Viewer treeViewer = new TreeViewer(mainComposite, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL); treeViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); treeViewer.setLabelProvider(new LabelProvider() { @Override// w w w. j ava 2 s . c o m public Image getImage(Object obj) { return androidImg; } @Override public String getText(Object element) { return element.toString(); } }); content = new String[getBuildBlock().getAvailableSamples().size()]; int i = 0; for (String currentSample : getBuildBlock().getAvailableSamples().keySet()) { content[i] = currentSample; i++; } treeViewer.setContentProvider(new SampleTreeContentProvider(content)); treeViewer.setInput(content); final Group intentFilterGroup = new Group(mainComposite, SWT.NONE); treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent e) { String selection = e.getSelection().toString(); getBuildBlock().setSample(selection.substring(1, selection.length() - 1)); getBuildBlock() .setSampleCategoty(ActivityBasedOnTemplate.SAMPLE_CATEGORY.SAMPLE_ACTIVITIES_CATEGORY); if (selection.substring(1, selection.length() - 1) .equals(ActivityBasedOnTemplate.DATABASE_LIST_SAMPLE_LOCALIZED)) { getBuildBlock().setDatabaseTemplateSelected(true); } else { getBuildBlock().setDatabaseTemplateSelected(false); } canFlip = true; updateDescriptionPane(); getWizard().getContainer().updateButtons(); } }); treeViewer.setComparator(new ViewerComparator()); treeViewer.expandAll(); intentFilterGroup.setText(CodeUtilsNLS.UI_SampleSelectionPage_SamplesDescriptionPane); intentFilterGroup.setLayout(new GridLayout(1, false)); intentFilterGroup.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false)); ScrolledComposite scrolledArea = new ScrolledComposite(intentFilterGroup, SWT.V_SCROLL); GridData descriptionLabelData = new GridData(GridData.FILL, GridData.FILL, true, true); descriptionLabelData.heightHint = 140; scrolledArea.setLayoutData(descriptionLabelData); descriptionLabel = new Label(scrolledArea, SWT.FILL | SWT.WRAP); descriptionLabel.setText(""); scrolledArea.setContent(descriptionLabel); descriptionLabel.setSize(descriptionLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT)); // Add a listener to the wizard to listen for page changes if (getContainer() instanceof IPageChangeProvider) { ((IPageChangeProvider) getContainer()).addPageChangedListener(new PageChangeListener()); } setControl(mainComposite); }
From source file:com.motorola.studio.android.wizards.buildingblocks.NewActivityWizardListTemplatesPage.java
License:Apache License
@Override protected void createExtendedControls(Composite parent) { Composite mainComposite = new Composite(parent, SWT.FILL); mainComposite.setLayout(new GridLayout(2, false)); mainComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); // Samples Tree Label Label itemsTableLabel = new Label(mainComposite, SWT.NONE); itemsTableLabel.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1)); itemsTableLabel.setText(CodeUtilsNLS.UI_SampleSelectionPage_SamplesTreeLabel); // Samples Tree Viewer treeViewer = new TreeViewer(mainComposite, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL); treeViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); treeViewer.setLabelProvider(new LabelProvider() { @Override/* ww w . j ava 2 s . co m*/ public Image getImage(Object obj) { return androidImg; } @Override public String getText(Object element) { return element.toString(); } }); content = new String[getBuildBlock().getListActivitiesSamples().size()]; int i = 0; for (String currentSample : getBuildBlock().getListActivitiesSamples().keySet()) { content[i] = currentSample; i++; } //sets tree content and icon treeViewer.setContentProvider(new SampleTreeContentProvider(content)); treeViewer.setInput(content); final Group previewGroup = new Group(mainComposite, SWT.NONE); previewGroup.setText(CodeUtilsNLS.UI_ListActivityPage_Preview); previewGroup.setLayout(new GridLayout(1, false)); previewGroup.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, true, 1, 1)); imgLabel = new Label(previewGroup, SWT.NONE); imgLabel.setImage(null); GridData imageLabelData = new GridData(GridData.FILL, GridData.FILL, true, true); imageLabelData.widthHint = 200; imgLabel.setLayoutData(imageLabelData); final Group descriptionGroup = new Group(mainComposite, SWT.NONE); treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent e) { updateTreeViewAfterSelection(e.getSelection()); updateDescriptionPane(); getWizard().getContainer().updateButtons(); } }); //sort tree treeViewer.setComparator(new ViewerComparator()); treeViewer.expandAll(); //description pane descriptionGroup.setText(CodeUtilsNLS.UI_SampleSelectionPage_SamplesDescriptionPane); descriptionGroup.setLayout(new GridLayout(1, false)); descriptionGroup.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1)); ScrolledComposite scroll = new ScrolledComposite(descriptionGroup, SWT.V_SCROLL); GridData scrollData = new GridData(GridData.FILL, GridData.FILL, true, true); scroll.setLayoutData(scrollData); scroll.setMinSize(100, 140); descriptionLabel = new Label(scroll, SWT.FILL | SWT.WRAP); descriptionLabel.setText(""); scroll.setContent(descriptionLabel); // Add a listener to the wizard to listen for page changes if (getContainer() instanceof IPageChangeProvider) { ((IPageChangeProvider) getContainer()).addPageChangedListener(new PageChangeListener()); } setControl(mainComposite); }