List of usage examples for org.eclipse.jface.viewers TreeViewer TreeViewer
public TreeViewer(Composite parent, int style)
From source file:com.nokia.carbide.cpp.internal.project.ui.mmpEditor.CompilerSectionPart.java
License:Open Source License
/** * Fill the section//w w w . java2s .co m */ private void createClient(Section section, FormToolkit toolkit) { section.setText(Messages.CompilerSectionPart_sectionLabel); Composite container = toolkit.createComposite(section); toolkit.paintBordersFor(container); final FormLayout formLayout = new FormLayout(); formLayout.marginHeight = 2; formLayout.marginWidth = 2; container.setLayout(formLayout); // section.setClient(container); compilerTreeViewer = new TreeViewer(container, SWT.NONE); compilerTreeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); compilerTreeViewer.setLabelProvider(new TreeLabelProvider()); compilerTreeViewer.setContentProvider(model); compilerTreeViewer.setInput(model.getRoot()); Tree tree = compilerTreeViewer.getTree(); final FormData formData = new FormData(); formData.top = new FormAttachment(0, 10); formData.right = new FormAttachment(0, 203); formData.left = new FormAttachment(0, 10); tree.setLayoutData(formData); toolkit.adapt(tree, true, true); compilerTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { updateButtons(); } }); compilerTreeViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { viewerDoubleClicked(); } }); tree.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.character == SWT.DEL) { doRemove(); } } }); final Composite compilerButtonComposite = toolkit.createComposite(container, SWT.NONE); final RowLayout rowLayout = new RowLayout(SWT.VERTICAL); rowLayout.fill = true; rowLayout.wrap = false; rowLayout.marginTop = 0; compilerButtonComposite.setLayout(rowLayout); final FormData formData_1 = new FormData(); formData_1.bottom = new FormAttachment(0, 150); formData_1.left = new FormAttachment(tree, 7, SWT.DEFAULT); formData_1.top = new FormAttachment(0, 10); compilerButtonComposite.setLayoutData(formData_1); toolkit.paintBordersFor(compilerButtonComposite); addButton = toolkit.createButton(compilerButtonComposite, Messages.CompilerSectionPart_addBtn, SWT.NONE); addButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { doAdd(); } }); editButton = toolkit.createButton(compilerButtonComposite, Messages.CompilerSectionPart_editBtn, SWT.NONE); editButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { doEdit(); } }); removeButton = toolkit.createButton(compilerButtonComposite, Messages.CompilerSectionPart_removeBtn, SWT.NONE); removeButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { doRemove(); } }); upButton = toolkit.createButton(compilerButtonComposite, Messages.CompilerSectionPart_upButton, SWT.NONE); upButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { doUp(); } }); downButton = toolkit.createButton(compilerButtonComposite, Messages.CompilerSectionPart_downButton, SWT.NONE); downButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { doDown(); } }); strictDependenciesButton = toolkit.createButton(container, Messages.CompilerSectionPart_perVariantIncludeDependenciesBtn, SWT.CHECK); strictDependenciesButton.setToolTipText(Messages.CompilerSectionPart_strictDependenciesTooltip); formData.bottom = new FormAttachment(strictDependenciesButton, -5, SWT.TOP); final FormData formData_2 = new FormData(); formData_2.top = new FormAttachment(0, 239); formData_2.bottom = new FormAttachment(0, 255); formData_2.left = new FormAttachment(tree, 0, SWT.LEFT); strictDependenciesButton.setLayoutData(formData_2); srcdebugButton = toolkit.createButton(container, Messages.CompilerSectionPart_disableOptsButton, SWT.CHECK); srcdebugButton.setToolTipText(Messages.CompilerSectionPart_srcdebugTooltip); final FormData formData_3 = new FormData(); formData_3.top = new FormAttachment(0, 260); formData_3.left = new FormAttachment(tree, 0, SWT.LEFT); srcdebugButton.setLayoutData(formData_3); compilerTreeViewer.expandAll(); hookControls(); refresh(); }
From source file:com.nokia.carbide.cpp.internal.project.ui.mmpEditor.ResourcesSectionPart.java
License:Open Source License
/** * Fill the section//ww w . j a v a2s.c o m */ private void createClient(Section section, FormToolkit toolkit) { section.setText(Messages.ResourcesSectionPart_resourcesSectionTitle); section.setDescription(Messages.ResourcesSectionPart_resourcesDescription); Composite container = toolkit.createComposite(section); final FormLayout formLayout = new FormLayout(); formLayout.marginHeight = 2; formLayout.marginWidth = 2; container.setLayout(formLayout); toolkit.paintBordersFor(container); // section.setClient(container); resourceTreeViewer = new TreeViewer(container, SWT.NONE); Tree tree = resourceTreeViewer.getTree(); final FormData formData = new FormData(); formData.right = new FormAttachment(0, 247); formData.bottom = new FormAttachment(100, -3); formData.top = new FormAttachment(0, 3); formData.left = new FormAttachment(0, 3); tree.setLayoutData(formData); toolkit.adapt(tree, true, true); resourceTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { updateButtons(); } }); resourceTreeViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { viewerDoubleClicked(); } }); tree.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.character == SWT.DEL) { doRemove(); } } }); final Composite composite = new Composite(container, SWT.NONE); final RowLayout buttonComposite = new RowLayout(SWT.VERTICAL); buttonComposite.marginTop = 0; buttonComposite.fill = true; buttonComposite.pack = false; composite.setLayout(buttonComposite); final FormData formData_1 = new FormData(); formData_1.bottom = new FormAttachment(0, 90); formData_1.left = new FormAttachment(tree, 7, SWT.DEFAULT); formData_1.top = new FormAttachment(0, 3); composite.setLayoutData(formData_1); toolkit.adapt(composite); addButton = toolkit.createButton(composite, Messages.ResourcesSectionPart_addBtn, SWT.NONE); addButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doAdd(); } }); editButton = toolkit.createButton(composite, Messages.ResourcesSectionPart_editBtn, SWT.NONE); editButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doEdit(); } }); removeButton = toolkit.createButton(composite, Messages.ResourcesSectionPart_removeBtn, SWT.NONE); removeButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doRemove(); } }); }
From source file:com.nokia.carbide.cpp.uiq.ui.vieweditor.CommandsPage.java
License:Open Source License
/** * Create the commands List section. The TreeViewer and the buttons. * @param toolkit/*from w ww . j a v a 2 s . c o m*/ * @param body */ private void CreateCommandListSection(FormToolkit toolkit, Composite body) { commandListSection = toolkit.createSection(body, Section.DESCRIPTION | Section.TITLE_BAR | Section.FOCUS_TITLE); final FormData formDataCommandListSection = new FormData(); formDataCommandListSection.right = new FormAttachment(0, 415); formDataCommandListSection.left = new FormAttachment(0, 0); formDataCommandListSection.bottom = new FormAttachment(0, 300); formDataCommandListSection.top = new FormAttachment(0, 0); commandListSection.setLayoutData(formDataCommandListSection); commandListSection.setText(Messages.getString("CommandsPage.commandListSection.Title")); //$NON-NLS-1$ commandListSection.setDescription(Messages.getString("CommandsPage.commandListSection.description")); //$NON-NLS-1$ final Composite comandListSectionComposite = toolkit.createComposite(commandListSection);//new Composite(commandListSection, SWT.None); comandListSectionComposite.setLayout(new FormLayout()); commandListSection.setClient(comandListSectionComposite); toolkit.adapt(comandListSectionComposite); commandsTreeViewer = new TreeViewer(comandListSectionComposite, SWT.FULL_SELECTION | SWT.BORDER); commandsTree = commandsTreeViewer.getTree(); final FormData treeFrmData = new FormData(); treeFrmData.right = new FormAttachment(0, 240); treeFrmData.bottom = new FormAttachment(100, -5); treeFrmData.top = new FormAttachment(0, 5); treeFrmData.left = new FormAttachment(0, 5); commandsTree.setLayoutData(treeFrmData); toolkit.adapt(commandsTree, true, true); commandsTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { if (event.getSelection().isEmpty()) { editingSection.setVisible(false); return; } if (event.getSelection() instanceof IStructuredSelection) { editingSection.setVisible(true); IStructuredSelection selection = (IStructuredSelection) event.getSelection(); Object element = selection.getFirstElement(); selected = element; editImageBtn.setEnabled(true); anonymousGroupBtn.setEnabled(true); duplicateBtn.setEnabled(true); if (element instanceof CommandList) {//Disable Edit Image button duplicateBtn.setEnabled(false); editImageBtn.setEnabled(false); editingSection.setText( Messages.getString("CommandsPage.commandEditingSection.title.editCommandList")); displayPropertiesCommandList((CommandList) element); } if (element instanceof CommandModel) {//Disable Edit Image button editingSection.setText( Messages.getString("CommandsPage.commandEditingSection.title.editCommand")); displayPropertiesCommandOrNamed((CommandModel) element, true); } if (element instanceof AnonymousGroup) {//Disable Edit Image button anonymousGroupBtn.setEnabled(false); editImageBtn.setEnabled(false); editingSection.setText( Messages.getString("CommandsPage.commandEditingSection.title.editAnonymousGroup")); displayPropertiesAnonymousGroup((AnonymousGroup) element); } if (element instanceof NamedGroup) {//Disable Edit Image button editingSection.setText( Messages.getString("CommandsPage.commandEditingSection.title.editNamedGroup")); displayPropertiesCommandOrNamed((NamedGroup) element, false); } } } }); treeColumnElements = new TreeColumn(commandsTree, SWT.NONE); treeColumnElements.setWidth(120); treeColumnElements.setText(Messages.getString("CommandsPage.commandListSection.tree.column1.label")); //$NON-NLS-1$ treeColumnCommandID = new TreeColumn(commandsTree, SWT.NONE); treeColumnCommandID.setWidth(100); treeColumnCommandID.setText(Messages.getString("CommandsPage.commandListSection.tree.column2.label")); //$NON-NLS-1$ commandsTree.setHeaderVisible(true); listBtn = toolkit.createButton(comandListSectionComposite, "", SWT.FLAT); final FormData listBtnFrmData = new FormData(); listBtnFrmData.left = new FormAttachment(commandsTree, 5, SWT.RIGHT); listBtn.setLayoutData(listBtnFrmData); toolkit.adapt(listBtn, true, true); listBtn.setText(Messages.getString("CommandsPage.commandListSection.buttons.list.label")); //$NON-NLS-1$ listBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { addCommandListElement(); } }); commandBtn = toolkit.createButton(comandListSectionComposite, "", SWT.FLAT); listBtnFrmData.right = new FormAttachment(commandBtn, 0, SWT.RIGHT); listBtnFrmData.top = new FormAttachment(commandBtn, -28, SWT.TOP); listBtnFrmData.bottom = new FormAttachment(commandBtn, -5, SWT.TOP); final FormData commandBtnFrmData = new FormData(); commandBtn.setLayoutData(commandBtnFrmData); toolkit.adapt(commandBtn, true, true); commandBtn.setText(Messages.getString("CommandsPage.commandListSection.buttons.command.label")); //$NON-NLS-1$ commandBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { addCommandElement(); } }); namedGroupBtn = toolkit.createButton(comandListSectionComposite, "", SWT.FLAT); commandBtnFrmData.right = new FormAttachment(namedGroupBtn, 0, SWT.RIGHT); commandBtnFrmData.left = new FormAttachment(namedGroupBtn, 0, SWT.LEFT); commandBtnFrmData.top = new FormAttachment(namedGroupBtn, -28, SWT.TOP); commandBtnFrmData.bottom = new FormAttachment(namedGroupBtn, -5, SWT.TOP); final FormData namedGroupBtnFrmData = new FormData(SWT.FILL, SWT.FILL); namedGroupBtn.setLayoutData(namedGroupBtnFrmData); toolkit.adapt(namedGroupBtn, true, true); namedGroupBtn.setText(Messages.getString("CommandsPage.commandListSection.buttons.namedGroup.label")); //$NON-NLS-1$ namedGroupBtn.setAlignment(SWT.UP | SWT.LEFT_TO_RIGHT); namedGroupBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { addNamedGroupElement(); } }); anonymousGroupBtn = toolkit.createButton(comandListSectionComposite, "", SWT.FLAT); namedGroupBtnFrmData.right = new FormAttachment(anonymousGroupBtn, 0, SWT.RIGHT); namedGroupBtnFrmData.left = new FormAttachment(anonymousGroupBtn, 0, SWT.LEFT); namedGroupBtnFrmData.top = new FormAttachment(anonymousGroupBtn, -34, SWT.TOP); namedGroupBtnFrmData.bottom = new FormAttachment(anonymousGroupBtn, -5, SWT.TOP); final FormData anonymousGroupBtnFrmData = new FormData(SWT.FILL, SWT.FILL); anonymousGroupBtnFrmData.left = new FormAttachment(commandsTree, 5, SWT.RIGHT); anonymousGroupBtnFrmData.right = new FormAttachment(0, 395); anonymousGroupBtn.setLayoutData(anonymousGroupBtnFrmData); toolkit.adapt(anonymousGroupBtn, true, true); anonymousGroupBtn .setText(Messages.getString("CommandsPage.commandListSection.buttons.anonymousGroup.label")); //$NON-NLS-1$ anonymousGroupBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { addAnonymousGroupElement(); } }); duplicateBtn = toolkit.createButton(comandListSectionComposite, "", SWT.FLAT);//SWT.TOGGLE | SWT.BORDER); anonymousGroupBtnFrmData.top = new FormAttachment(duplicateBtn, -35, SWT.TOP); anonymousGroupBtnFrmData.bottom = new FormAttachment(duplicateBtn, -5, SWT.TOP); final FormData duplicateBtnFrmData = new FormData(); duplicateBtnFrmData.right = new FormAttachment(anonymousGroupBtn, 150, SWT.LEFT); duplicateBtnFrmData.left = new FormAttachment(anonymousGroupBtn, 0, SWT.LEFT); duplicateBtn.setLayoutData(duplicateBtnFrmData); toolkit.adapt(duplicateBtn, true, true); duplicateBtn.setText(Messages.getString("CommandsPage.commandListSection.buttons.duplicate.label")); //$NON-NLS-1$ duplicateBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { copyBranch(); } }); editImageBtn = toolkit.createButton(comandListSectionComposite, "", SWT.FLAT);//new Button(comandListSectionComposite, SWT.FLAT); duplicateBtnFrmData.top = new FormAttachment(editImageBtn, -28, SWT.TOP); duplicateBtnFrmData.bottom = new FormAttachment(editImageBtn, -5, SWT.TOP); final FormData editImageBtnFrmData = new FormData(); editImageBtnFrmData.right = new FormAttachment(duplicateBtn, 0, SWT.RIGHT); editImageBtnFrmData.top = new FormAttachment(0, 162); editImageBtnFrmData.bottom = new FormAttachment(0, 185); editImageBtnFrmData.left = new FormAttachment(duplicateBtn, 0, SWT.LEFT); editImageBtn.setLayoutData(editImageBtnFrmData); toolkit.adapt(editImageBtn, true, true); editImageBtn.setText(Messages.getString("CommandsPage.commandListSection.buttons.edit.label")); //$NON-NLS-1$ editImageBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { selected = getSelectionTree(); if (selected != null) { modelCommands.editTitleIcon(selected); } } }); removeBtn = toolkit.createButton(comandListSectionComposite, "", SWT.FLAT);//new Button(comandListSectionComposite, SWT.FLAT); final FormData removeBtnFrmData = new FormData(); removeBtnFrmData.bottom = new FormAttachment(0, 210); removeBtnFrmData.right = new FormAttachment(editImageBtn, 0, SWT.RIGHT); removeBtnFrmData.top = new FormAttachment(0, 188); removeBtnFrmData.left = new FormAttachment(editImageBtn, 0, SWT.LEFT); removeBtn.setLayoutData(removeBtnFrmData); toolkit.adapt(removeBtn, true, true); removeBtn.setText(Messages.getString("CommandsPage.commandListSection.buttons.remove.label")); //$NON-NLS-1$ removeBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { removeElement(); } }); initializeCommandListSection(); }
From source file:com.nokia.carbide.internal.api.templatewizard.ui.ChooseTemplatePage.java
License:Open Source License
public void createControl(Composite parent) { initializeDialogUnits(parent);/*from w w w .j a v a 2s . c om*/ Composite container = new Composite(parent, SWT.NONE); final GridLayout gridLayout = new GridLayout(); gridLayout.makeColumnsEqualWidth = true; container.setLayout(gridLayout); container.setData(UID_KEY, "ChooseTemplatePage"); //$NON-NLS-1$ container.setData("ChooseTemplatePage", this); //$NON-NLS-1$ setControl(container); final Label chooseTemplateLabel = new Label(container, SWT.NONE); chooseTemplateLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, true, false)); chooseTemplateLabel.setText(Messages.getString("ChooseTemplatePage.ChooseTemplateLabel")); //$NON-NLS-1$ final SashForm sashForm = new SashForm(container, SWT.VERTICAL); final GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true); sashForm.setLayoutData(gridData); templateTreeViewer = new TreeViewer(sashForm, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); templateTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(final SelectionChangedEvent e) { handleTemplateSelectionChanged(); } }); templateTreeViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { handleTemplateSelectionChanged(); if (getSelectedLoadedTemplate() != null) getContainer().showPage(getNextPage()); } }); templateTreeViewer.setContentProvider(new TreeNodeContentProvider()); templateTreeViewer.setLabelProvider(new LabelProvider() { @Override public Image getImage(Object element) { Check.checkContract(element instanceof TreeNode); Object value = ((TreeNode) element).getValue(); if (value instanceof String) { if (folderImage == null) folderImage = TemplateWizardPlugin.getImageDescriptor(FOLDER_ICON).createImage(); return folderImage; } if (value instanceof ITemplate) { ITemplate template = (ITemplate) value; if (templateImages == null) templateImages = new HashMap<ITemplate, Image>(); if (!templateImages.containsKey(template)) { Image templateImage = null; ImageDescriptor imageDescriptor = template.getImageDescriptor(); if (imageDescriptor != null) templateImage = imageDescriptor.createImage(); templateImages.put(template, templateImage); } return templateImages.get(template); } return super.getImage(element); } @Override public String getText(Object element) { Check.checkContract(element instanceof TreeNode); Object value = ((TreeNode) element).getValue(); if (value instanceof String) { return value.toString(); } if (value instanceof ITemplate) { return ((ITemplate) value).getDisplayName(); } return ((TreeNode) element).getValue().toString(); } }); templateTreeViewer.getTree().setData(UID_KEY, "templateTree"); //$NON-NLS-1$ templateDescriptionText = new Text(sashForm, SWT.V_SCROLL | SWT.BORDER | SWT.WRAP); templateDescriptionText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); templateDescriptionText.setEditable(false); templateDescriptionText.setData(UID_KEY, "templateDescription"); //$NON-NLS-1$ sashForm.setWeights(new int[] { 250, 100 }); filterCheckbox = new Button(container, SWT.CHECK); filterCheckbox.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, true, false)); filterCheckbox.setText(filterCheckboxLabel); filterCheckbox.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { initTreeViewer(false); } }); if (hideFilterCheckbox) { filterCheckbox.setVisible(false); } filterCheckbox.setSelection(!hideFilterCheckbox); filterCheckbox.setData(UID_KEY, "filterCheckbox"); //$NON-NLS-1$ String helpContextId = TemplateWizardPlugin.ID + ".choose_template_page"; //$NON-NLS-1$ PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), helpContextId); }
From source file:com.nokia.carbide.remoteconnections.settings.ui.ConnectionSettingsPage.java
License:Open Source License
private void createInstallTabComposite(TabFolder tabFolder) { TabItem tabItem = new TabItem(tabFolder, SWT.NONE); tabItem.setText(Messages.getString("ConnectionSettingsPage.InstallTabLabel")); //$NON-NLS-1$ tabItem.setData(UID, "installTab"); //$NON-NLS-1$ Composite composite = new Composite(tabFolder, SWT.NONE); GridLayout gridLayout = new GridLayout(); composite.setLayout(gridLayout);/*from www .j av a 2 s . co m*/ tabItem.setControl(composite); Composite installDebugAgentComposite = new Composite(tabFolder, SWT.NONE); installDebugAgentComposite.setLayout(new GridLayout(1, false)); tabItem.setControl(installDebugAgentComposite); installerSashForm = new SashForm(installDebugAgentComposite, SWT.HORIZONTAL); GridData gd_sash = new GridData(SWT.FILL, SWT.FILL, true, true); gd_sash.widthHint = 420; gd_sash.heightHint = 280; installerSashForm.setLayoutData(gd_sash); installerTreeViewer = new TreeViewer(installerSashForm, SWT.BORDER); GridData gd_tree = new GridData(SWT.CENTER, SWT.CENTER, false, false); installerTreeViewer.getTree().setLayoutData(gd_tree); installerTreeViewer.getControl().setData(UID, "installerTreeViewer"); //$NON-NLS-1$ installerTreeViewer.setContentProvider(new TreeNodeContentProvider()); installerTreeViewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { TreeNode node = (TreeNode) element; Object value = node.getValue(); if (value instanceof IRemoteAgentInstaller) { String label = ((IRemoteAgentInstaller) value).getLabel(); return label == null ? Messages.getString("ConnectionSettingsPage.UnlabeledPackageLabel") //$NON-NLS-1$ : label; } return value.toString(); } @Override public Image getImage(Object element) { if (element.equals(LOADING_CONTENT_TREENODE)) return null; TreeNode node = (TreeNode) element; Object value = node.getValue(); if (value instanceof IRemoteAgentInstaller) return ((IRemoteAgentInstaller) value).getImage(); return FOLDER_ICON_IMG; } }); installerTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { TreeNode node = (TreeNode) ((StructuredSelection) event.getSelection()).getFirstElement(); if (node == null) return; Object value = node.getValue(); boolean isPackage = value instanceof IRemoteAgentInstaller; boolean installable = false; String information = null; if (isPackage) { IRemoteAgentInstaller installer = (IRemoteAgentInstaller) value; installable = installer.fileSupportsInstall(); information = installer.getInformation(); } if (information != null) installerInfoText.setText(information); else installerInfoText.setText(""); //$NON-NLS-1$ installButton.setEnabled(isPackage && installable); installerSaveButton.setEnabled(isPackage); } }); installerInfoText = new Text(installerSashForm, SWT.READ_ONLY | SWT.BORDER | SWT.WRAP); String errorText = Messages.getString("ConnectionSettingsPage.NoInstallerDataInfoString"); //$NON-NLS-1$ errorText += "\n" + Messages.getString("ConnectionSettingsPage.NoInstallerDataInfoString2"); //$NON-NLS-1$ //$NON-NLS-2$ installerInfoText.setText(errorText); installerInfoText.setData(UID, "installerInfoText"); //$NON-NLS-1$ installerSashForm.setWeights(new int[] { 160, 100 }); Composite buttonsArea = new Composite(installDebugAgentComposite, SWT.NONE); buttonsArea.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false)); gridLayout = new GridLayout(); gridLayout.numColumns = 2; buttonsArea.setLayout(gridLayout); installerSaveButton = new Button(buttonsArea, SWT.NONE); final GridData gd_saveButton = new GridData(SWT.RIGHT, SWT.CENTER, false, false); gd_saveButton.widthHint = 125; installerSaveButton.setLayoutData(gd_saveButton); installerSaveButton.setText(Messages.getString("ConnectionSettingsPage.SaveButtonLabel")); //$NON-NLS-1$ installerSaveButton.setEnabled(false); installerSaveButton.setToolTipText(Messages.getString("ConnectionSettingsPage.SaveButtonToolTip")); //$NON-NLS-1$ installerSaveButton.setData(UID, "installerSaveButton"); //$NON-NLS-1$ installerSaveButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { Display.getDefault().syncExec(new Runnable() { public void run() { try { IRemoteAgentInstaller installer = getCurrentInstaller(); saveAs(installer.getPackageContents(getContainer())); } catch (Exception e) { RemoteConnectionsActivator.logError(e); } } }); } }); installButton = new Button(buttonsArea, SWT.NONE); final GridData gd_installButton = new GridData(SWT.RIGHT, SWT.CENTER, false, false); gd_installButton.widthHint = 125; installButton.setLayoutData(gd_installButton); installButton.setText(Messages.getString("ConnectionSettingsPage.InstallButtonLabel")); //$NON-NLS-1$ installButton.setEnabled(false); installButton.setToolTipText(Messages.getString("ConnectionSettingsPage.InstallButtonToolTip")); //$NON-NLS-1$ installButton.setData(UID, "installButton"); //$NON-NLS-1$ installButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { Display.getDefault().syncExec(new Runnable() { public void run() { try { IRemoteAgentInstaller installer = getCurrentInstaller(); attemptInstall(installer.getPackageContents(getContainer())); } catch (Exception e) { RemoteConnectionsActivator.logError(e); } } }); } }); }
From source file:com.nokia.carbide.remoteconnections.view.ConnectionsView.java
License:Open Source License
public void createPartControl(Composite parent) { viewer = new TreeViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL); TreeViewerColumn nameColumn = new TreeViewerColumn(viewer, SWT.LEFT); nameColumn.setLabelProvider(new TreeColumnViewerLabelProvider(new NameLabelProvider())); nameColumn.getColumn().setText(Messages.getString("ConnectionsView.NameColumnHeader")); //$NON-NLS-1$ nameColumn.setEditingSupport(new NameEditingSupport(nameColumn.getViewer())); ColumnViewerEditorActivationStrategy activationStrategy = new ColumnViewerEditorActivationStrategy( nameColumn.getViewer()) {/* ww w . j a va 2 s.co m*/ @Override protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) { return event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC; } }; TreeViewerEditor.create(viewer, activationStrategy, ColumnViewerEditor.DEFAULT); boldViewerFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT); TreeViewerColumn typeColumn = new TreeViewerColumn(viewer, SWT.LEFT); typeColumn.setLabelProvider(new TypeLabelProvider()); typeColumn.getColumn().setText(Messages.getString("ConnectionsView.TypeColumnHeader")); //$NON-NLS-1$ TreeViewerColumn statusColumn = new TreeViewerColumn(viewer, SWT.LEFT); statusColumn.setLabelProvider(new StatusLabelProvider()); statusColumn.getColumn().setText(Messages.getString("ConnectionsView.StatusColumnHeader")); //$NON-NLS-1$ TreeViewerColumn descriptionColumn = new TreeViewerColumn(viewer, SWT.LEFT); descriptionColumn.setLabelProvider(new DescriptionLabelProvider(this, descriptionColumn)); descriptionColumn.getColumn().setText(Messages.getString("ConnectionsView.DescriptionColumnHeader")); //$NON-NLS-1$ viewer.setContentProvider(new TreeNodeContentProvider()); viewer.setInput(loadConnections()); viewer.expandAll(); viewer.getTree().setHeaderVisible(true); viewer.getControl().setData(UID, "viewer"); //$NON-NLS-1$ viewer.setSorter(new ViewerSorter() { @Override public int compare(Viewer viewer, Object e1, Object e2) { return getNodeDisplayName(e1).compareToIgnoreCase(getNodeDisplayName(e2)); } }); viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { enableConnectionSelectedActions(false); enableServiceSelectedActions(false); ISelection selection = event.getSelection(); if (!selection.isEmpty()) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; TreeNode treeNode = (TreeNode) structuredSelection.getFirstElement(); Object value = treeNode.getValue(); if (value instanceof IConnection) { enableConnectionSelectedActions(true); } else if (value instanceof IConnectedService) { enableServiceSelectedActions(true); } } } }); viewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { ISelection selection = event.getSelection(); if (!selection.isEmpty()) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; TreeNode treeNode = (TreeNode) structuredSelection.getFirstElement(); Object value = treeNode.getValue(); if (value instanceof IConnection) { SettingsWizard wizard = new SettingsWizard((IConnection) value); wizard.open(getViewSite().getShell()); } else if (value instanceof IConnectedService) { if (RemoteConnectionsActivator.getDefault().getShouldTestServices()) { IConnectedService connectedService = (IConnectedService) value; connectedService.setEnabled(true); connectedService.testStatus(); ((EnableConnectedServiceAction) getAction(ENABLE_SERVICE_ACTION)).updateLabel(); } } } } }); packColumns(); makeActions(); hookContextMenu(); contributeToActionBars(); hookAccelerators(); connectionStoreChangedListener = new IConnectionsManagerListener() { public void connectionStoreChanged() { Display.getDefault().asyncExec(new Runnable() { public void run() { viewer.setInput(loadConnections()); viewer.expandAll(); packColumns(); if (viewer.getSelection().isEmpty() && viewer.getTree().getItemCount() > 0) { TreeItem item = viewer.getTree().getItem(0); if (item != null) { viewer.getTree().select(item); } } viewer.setSelection(viewer.getSelection()); // force selection changed } }); } public void displayChanged() { refreshViewer(); } }; Registry.instance().addConnectionStoreChangedListener(connectionStoreChangedListener); connectionListener = new IConnectionListener() { public void currentConnectionSet(IConnection connection) { refreshViewer(); } public void connectionRemoved(IConnection connection) { // presumably the viewer itself handles this... } public void connectionAdded(IConnection connection) { // presumably the viewer itself handles this... } }; Registry.instance().addConnectionListener(connectionListener); RemoteConnectionsActivator.setHelp(parent, ".connections_view"); //$NON-NLS-1$ }
From source file:com.nokia.s60ct.cenrep.gui.editors.CRBrowser.java
License:Open Source License
@Override protected void createPages() { createModel();/*from ww w .j a v a 2 s .c o m*/ { ViewerPane viewerPane = new ViewerPane(getSite().getPage(), CRBrowser.this) { public Viewer createViewer(Composite composite) { TreeViewer treeViewer = new TreeViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.VIRTUAL); TextCellEditor textCellEditot = new TextCellEditor(treeViewer.getTree()); CellEditor[] cellEditor = { textCellEditot }; String[] properties = { "Main" }; treeViewer.setCellEditors(cellEditor); treeViewer.setColumnProperties(properties); TreeEditor treeEditor = new TreeEditor(treeViewer.getTree()); treeEditor.horizontalAlignment = SWT.LEFT; treeEditor.minimumWidth = 10; return treeViewer; } public void requestActivation() { super.requestActivation(); setCurrentViewerPane(this); } }; viewerPane.createControl(getContainer()); viewerPane2NameFeatures.put(viewerPane, NAME_FEATURES_UID_NAME); selectionViewer = (TreeViewer) viewerPane.getViewer(); selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(byNameAdapterFactory)); selectionViewer.setInput(editingDomain.getResourceSet()); selectionViewer.setSelection( new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true); createContextMenuFor(selectionViewer); int pageIndex = addPage(viewerPane.getControl()); setPageText(pageIndex, "UidName"); } { ViewerPane viewerPane = new ViewerPane(getSite().getPage(), CRBrowser.this) { public Viewer createViewer(Composite composite) { TreeViewer treeViewer = new TreeViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.VIRTUAL); TextCellEditor textCellEditot = new TextCellEditor(treeViewer.getTree()); CellEditor[] cellEditor = { textCellEditot }; String[] properties = { "Main" }; treeViewer.setCellEditors(cellEditor); treeViewer.setColumnProperties(properties); TreeEditor treeEditor = new TreeEditor(treeViewer.getTree()); treeEditor.horizontalAlignment = SWT.LEFT; treeEditor.minimumWidth = 10; return treeViewer; } public void requestActivation() { super.requestActivation(); setCurrentViewerPane(this); } }; viewerPane.createControl(getContainer()); viewerPane2NameFeatures.put(viewerPane, NAME_FEATURES_UID_VALUE); parentViewer = (TreeViewer) viewerPane.getViewer(); parentViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); parentViewer.setLabelProvider(new AdapterFactoryLabelProvider(byValueAdapterFactory)); parentViewer.setInput(editingDomain.getResourceSet()); parentViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true); createContextMenuFor(parentViewer); int pageIndex = addPage(viewerPane.getControl()); setPageText(pageIndex, "UidValue"); addExpandAndCollapseButtons(viewerPane.getControl().getParent()); } }
From source file:com.nokia.s60ct.gui.editors.ConfigurationBrowser.java
License:Open Source License
@Override protected void createPages() { createModel();/* w w w . j av a 2s . c o m*/ { ViewerPane viewerPane = new ViewerPane(getSite().getPage(), ConfigurationBrowser.this) { public Viewer createViewer(Composite composite) { TreeViewer treeViewer = new TreeViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.VIRTUAL); TextCellEditor textCellEditot = new TextCellEditor(treeViewer.getTree()); CellEditor[] cellEditor = { textCellEditot }; String[] properties = { "Main" }; treeViewer.setCellEditors(cellEditor); treeViewer.setColumnProperties(properties); TreeEditor treeEditor = new TreeEditor(treeViewer.getTree()); treeEditor.horizontalAlignment = SWT.LEFT; treeEditor.minimumWidth = 10; treeViewer.addFilter(FeatureViewFilter.INSTANCE); treeViewer.addFilter(ReadOnlyFilter.INSTANCE); ReadOnlyFilter.INSTANCE.addViewer(treeViewer); treeViewer.getTree().setData("name", getString("_UI_Configuration_pane")); return treeViewer; } public void requestActivation() { super.requestActivation(); setCurrentViewerPane(this); } }; viewerPane.createControl(getContainer()); selectionViewer = (TreeViewer) viewerPane.getViewer(); selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); selectionViewer.setInput(editingDomain.getResourceSet()); selectionViewer.setSelection( new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true); createContextMenuFor(selectionViewer); int pageIndex = addPage(viewerPane.getControl()); setPageText(pageIndex, getString("_UI_Configuration_pane")); } { ViewerPane viewerPane = new ViewerPane(getSite().getPage(), ConfigurationBrowser.this) { public Viewer createViewer(Composite composite) { TreeViewer treeViewer = new TreeViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.VIRTUAL); TextCellEditor textCellEditot = new TextCellEditor(treeViewer.getTree()); CellEditor[] cellEditor = { textCellEditot }; String[] properties = { "Main" }; treeViewer.setCellEditors(cellEditor); treeViewer.setColumnProperties(properties); TreeEditor treeEditor = new TreeEditor(treeViewer.getTree()); treeEditor.horizontalAlignment = SWT.LEFT; treeEditor.minimumWidth = 10; treeViewer.addFilter(FeatureViewFilter.INSTANCE); treeViewer.addFilter(new FeaturePathFilter()); treeViewer.setComparator(new ViewerComparator() { @Override public int compare(Viewer viewer, Object e1, Object e2) { // Auto-generated method stub if (e1 instanceof Feature) { Feature f1 = (Feature) e1; Feature f2 = (Feature) e2; return super.compare(viewer, f1.getName(), f2.getName()); } else if (e1 instanceof Setting) //should setting be here in alphabetical order or in the same order as in confml? { Setting s1 = (Setting) e1; Setting s2 = (Setting) e2; return super.compare(viewer, s1.getName(), s2.getName()); } else { return super.compare(viewer, e1, e2); } } }); treeViewer.addFilter(ReadOnlyFilter.INSTANCE); ReadOnlyFilter.INSTANCE.addViewer(treeViewer); return treeViewer; } public void requestActivation() { super.requestActivation(); setCurrentViewerPane(this); } }; viewerPane.createControl(getContainer()); parentViewer = (TreeViewer) viewerPane.getViewer(); parentViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); parentViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); parentViewer.setInput(editingDomain.getResourceSet()); parentViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true); createContextMenuFor(parentViewer); int pageIndex = addPage(viewerPane.getControl()); setPageText(pageIndex, getString("_UI_Feature_pane")); } { ViewerPane viewerPane = new ViewerPane(getSite().getPage(), ConfigurationBrowser.this) { @Override public Viewer createViewer(Composite composite) { TreeViewer treeViewer = new TreeViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.VIRTUAL); TextCellEditor textCellEditot = new TextCellEditor(treeViewer.getTree()); CellEditor[] cellEditor = { textCellEditot }; String[] properties = { "Main" }; treeViewer.setCellEditors(cellEditor); treeViewer.setColumnProperties(properties); TreeEditor treeEditor = new TreeEditor(treeViewer.getTree()); treeEditor.horizontalAlignment = SWT.LEFT; treeEditor.minimumWidth = 10; treeViewer.addFilter(FeatureViewFilter.INSTANCE); treeViewer.addFilter(new ViewPathFilter()); treeViewer.addFilter(ReadOnlyFilter.INSTANCE); ReadOnlyFilter.INSTANCE.addViewer(treeViewer); return treeViewer; } @Override public void requestActivation() { super.requestActivation(); setCurrentViewerPane(this); } }; viewerPane.createControl(getContainer()); parentViewer = (TreeViewer) viewerPane.getViewer(); parentViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); parentViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); parentViewer.setInput(editingDomain.getResourceSet()); parentViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true); createContextMenuFor(parentViewer); int pageIndex = addPage(viewerPane.getControl()); setPageText(pageIndex, getString("_UI_View_pane")); addExpandAndCollapseButtons(viewerPane.getControl().getParent()); } }
From source file:com.nokia.s60tools.analyzetool.ui.MainView.java
License:Open Source License
/** * Creates memory results view// w ww . ja va2 s. com * * @param parent * View parent ( CTabFolder ) */ public void createMainView(CTabFolder parent) { // Create SashForm this form includes all the current view components SashForm sashForm = new SashForm(parent, SWT.HORIZONTAL); mainTab = new CTabItem(parent, SWT.NONE); mainTab.setControl(sashForm); mainTab.setText(Constants.MAIN_TAB_TITLE); // create new treeviewer to shown memory analysis runs and leaks runView = new TreeViewer(sashForm, SWT.VIRTUAL); // create SashForm to display call stack addresses and more detailed // information // of selected run or leak SashForm callstackForm = new SashForm(sashForm, SWT.VERTICAL); // set content and label providers runView.setContentProvider(new ViewContentProvider()); runView.setLabelProvider(new ViewLabelProvider()); // get init content runView.setInput(getStartupContent()); // add listener to provide selection change events runView.addTreeListener(this); runView.setAutoExpandLevel(2); // create new information label // this label contains more detailed information of selected item informationLabel = new Label(callstackForm, SWT.BORDER | SWT.CENTER); // create grid data => this provides layout changes GridData data = new GridData(); // add grid data to label, this enables label ui modifications e.g. line // feed informationLabel.setLayoutData(data); // set init text informationLabel.setText(Constants.INFO_NO_DATA); // create new call stack view // this components contains information of one memory leak call stack // addresses callstackView = new TreeViewer(callstackForm, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); // modify UI components layouts // reserve more space for left side of UI sashForm.setWeights(new int[] { 5, 3 }); callstackForm.setWeights(new int[] { 2, 8 }); // add content and label providers callstackView.setContentProvider(new ViewContentProvider()); callstackView.setLabelProvider(new ViewLabelProvider()); // make actions and construct click listeners makeActions(); hookContextMenu(); hookDoubleClickAction(); hookClicks(); contributeToActionBars(); // set view title viewTitle = String.format(Constants.ANALYZE_TOOL_TITLE_WITH_VERSION, Util.getAToolFeatureVersionNumber()); this.setContentDescription(viewTitle); // add selection listener if (getSite() != null) { getSite().getPage().addSelectionListener(this); runView.getControl().addKeyListener(this); } // set actionlistener Activator.setActionListener(this); // set help shortcuts PlatformUI.getWorkbench().getHelpSystem().setHelp(callstackView.getControl(), AnalyzeToolHelpContextIDs.ANALYZE_MAIN); PlatformUI.getWorkbench().getHelpSystem().setHelp(runView.getControl(), AnalyzeToolHelpContextIDs.ANALYZE_MAIN); ResourcesPlugin.getWorkspace().addResourceChangeListener(new ATResourceListener()); IPreferenceStore store = Activator.getPreferences(); store.setValue(Constants.LOGGING_FAST_ENABLED, true); // get default value for logging mode preferenceChanged(); }
From source file:com.nokia.s60tools.compatibilityanalyser.ui.views.MainView.java
License:Open Source License
private TreeViewer createTreeViewer(SashForm sash) { TreeViewer tree_viewer = new TreeViewer(sash, SWT.BORDER | SWT.FULL_SELECTION); GridData gd = new GridData(GridData.FILL_BOTH); gd.widthHint = 450;/*from w ww . j a va 2 s . c om*/ tree_viewer.getTree().setLayoutData(gd); TreeColumn issue_column = new TreeColumn(tree_viewer.getTree(), SWT.NONE); issue_column.setText("Compatibility issues"); issue_column.setWidth(300); issue_column.setResizable(true); TreeColumn severity_column = new TreeColumn(tree_viewer.getTree(), SWT.NONE); severity_column.setText("Severity"); severity_column.setWidth(100); severity_column.setResizable(false); tree_viewer.getTree().setLinesVisible(true); tree_viewer.getTree().setHeaderVisible(true); return tree_viewer; }