List of usage examples for org.eclipse.jface.viewers TreeViewer TreeViewer
public TreeViewer(Composite parent, int style)
From source file:com.nokia.s60tools.stif.configeditor.editors.ConfigEditor.java
License:Open Source License
/** * Creates modules page// w ww. j av a2 s .c om */ void createModulesPage() { modulesMainForm = toolkit.createScrolledForm(getContainer()); modulesMainForm.setText("STIF modules settings"); ColumnLayout modulesMainFormLayout = new ColumnLayout(); modulesMainFormLayout.maxNumColumns = 1; Section modulesSection = toolkit.createSection(modulesMainForm.getBody(), Section.TITLE_BAR); modulesSection.setText("Modules"); Composite modulesSectionClient = toolkit.createComposite(modulesSection); TableWrapLayout modulesSectionLayout = new TableWrapLayout(); modulesSectionLayout.numColumns = 2; modulesSectionClient.setLayout(modulesSectionLayout); modulesSectionClient.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); modulesSection.setClient(modulesSectionClient); modulesTreeViewer = new TreeViewer(modulesSectionClient, SWT.SINGLE); toolkit.adapt(modulesTreeViewer.getTree(), true, true); TableWrapData modulesTreeViewerLayoutData = new TableWrapData(TableWrapData.FILL_GRAB); modulesTreeViewerLayoutData.valign = TableWrapData.FILL; modulesTreeViewer.getTree().setLayoutData(modulesTreeViewerLayoutData); modulesTreeViewer.addSelectionChangedListener(this); Composite buttonsGroup = toolkit.createComposite(modulesSectionClient); TableWrapData buttonsGroupLayoutData = new TableWrapData(); buttonsGroupLayoutData.heightHint = SWT.MAX; buttonsGroupLayoutData.valign = TableWrapData.FILL; buttonsGroup.setLayoutData(buttonsGroupLayoutData); TableWrapLayout buttonsGroupLayout = new TableWrapLayout(); buttonsGroupLayout.numColumns = 1; buttonsGroupLayout.topMargin = 0; buttonsGroup.setLayout(buttonsGroupLayout); addModuleButton = toolkit.createButton(buttonsGroup, "Add module", SWT.PUSH); addModuleButton.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); addModuleButton.addSelectionListener(this); addTestCaseFileButton = toolkit.createButton(buttonsGroup, "Add test case file", SWT.PUSH); addTestCaseFileButton.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); addTestCaseFileButton.addSelectionListener(this); addIniFileButton = toolkit.createButton(buttonsGroup, "Add ini file", SWT.PUSH); addIniFileButton.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); addIniFileButton.addSelectionListener(this); editButton = toolkit.createButton(buttonsGroup, "Edit", SWT.PUSH); editButton.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); editButton.addSelectionListener(this); removeButton = toolkit.createButton(buttonsGroup, "Remove", SWT.PUSH); removeButton.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); removeButton.addSelectionListener(this); // Final initializations modulesMainForm.getBody().setLayout(modulesMainFormLayout); modulesSectionClient.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); toolkit.paintBordersFor(modulesSectionClient); modulesPageIndex = addPage(modulesMainForm); setPageText(modulesPageIndex, "Modules"); modulesTreeRoot = new ModulesTreeNode(); modulesTreeViewer.setContentProvider(new ModulesTreeContentProvider()); modulesTreeViewer.setLabelProvider(new ModulesTreeLabelProvider()); modulesTreeViewer.setInput(modulesTreeRoot); }
From source file:com.nokia.sdt.symbian.ui.appeditor.TestEditorPage.java
License:Open Source License
@Override protected void createFormContent(IManagedForm managedForm) { FormToolkit toolkit = managedForm.getToolkit(); ScrolledForm form = managedForm.getForm(); form.setText("Model Tree View"); Composite body = form.getBody(); final FillLayout fillLayout = new FillLayout(SWT.VERTICAL); fillLayout.marginHeight = 10;/*from w w w . j a v a 2s. com*/ fillLayout.marginWidth = 10; body.setLayout(fillLayout); toolkit.paintBordersFor(body); final Section section = toolkit.createSection(body, SWT.NONE); section.setText(dataModelEditor.getDataModel().getModelSpecifier().getDisplayName()); final Composite composite = toolkit.createComposite(section, SWT.NONE); composite.setLayout(new FillLayout(SWT.VERTICAL)); toolkit.paintBordersFor(composite); section.setClient(composite); treeViewer = new TreeViewer(composite, SWT.NONE); treeViewer.setLabelProvider(new TreeLabelProvider()); treeViewer.setContentProvider(new TreeContentProvider()); treeViewer.setInput(dataModelEditor); tree = treeViewer.getTree(); toolkit.adapt(tree, true, true); treeViewer.expandAll(); treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { ISelection selection = event.getSelection(); if (selectionManager != null) { setSelectionToSelectionManager(selection); } } }); if (selectionManager != null) { selectionManager.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { setSelectionToTree(event.getSelection()); } }); } }
From source file:com.nokia.testfw.codegen.ui.preferences.TESTFWTemplatePreferencePage.java
License:Open Source License
protected Control createContents(Composite ancestor) { Composite parent = new Composite(ancestor, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2;//from w ww. j av a 2s . c o m layout.marginHeight = 0; layout.marginWidth = 0; parent.setLayout(layout); Composite innerParent = new Composite(parent, SWT.NONE); GridLayout innerLayout = new GridLayout(); innerLayout.numColumns = 2; innerLayout.marginHeight = 0; innerLayout.marginWidth = 0; innerParent.setLayout(innerLayout); GridData gd = new GridData(GridData.FILL_BOTH); gd.horizontalSpan = 2; innerParent.setLayoutData(gd); Composite treeComposite = new Composite(innerParent, SWT.NONE); GridData data = new GridData(GridData.FILL_BOTH); data.widthHint = 360; data.heightHint = convertHeightInCharsToPixels(10); treeComposite.setLayoutData(data); FillLayout treeLayout = new FillLayout(); treeComposite.setLayout(treeLayout); TESTFWTemplateAdapter adapter = new TESTFWTemplateAdapter(); iTreeViewer = new TreeViewer(treeComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); iTreeViewer.setLabelProvider(new TESTFWTemplateLabelProvider()); iTreeViewer.setContentProvider(adapter); iTreeViewer.addSelectionChangedListener(adapter); iTreeViewer.addDoubleClickListener(adapter); iTreeViewer.setComparator(new ViewerComparator() { public int compare(Viewer viewer, Object object1, Object object2) { if ((object1 instanceof PathNode) && (object2 instanceof PathNode)) { String leftName = ((PathNode) object1).getName(); String rightName = ((PathNode) object2).getName(); int result = Collator.getInstance().compare(leftName, rightName); return result; } return super.compare(viewer, object1, object2); } public boolean isSorterProperty(Object element, String property) { return true; } }); Composite buttons = new Composite(innerParent, SWT.NONE); buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; buttons.setLayout(layout); iAddButton = new Button(buttons, SWT.PUSH); iAddButton.setText(Messages.getString("TemplatePreferencePage_new")); iAddButton.setLayoutData(new GridData(768)); iAddButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { add(); } }); iEditButton = new Button(buttons, SWT.PUSH); iEditButton.setText(Messages.getString("TemplatePreferencePage_edit")); iEditButton.setLayoutData(new GridData(768)); iEditButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { edit(); } }); iRemoveButton = new Button(buttons, SWT.PUSH); iRemoveButton.setText(Messages.getString("TemplatePreferencePage_remove")); iRemoveButton.setLayoutData(new GridData(768)); iRemoveButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { remove(); } }); createSeparator(buttons); iRestoreButton = new Button(buttons, SWT.PUSH); iRestoreButton.setText(Messages.getString("TemplatePreferencePage_restore")); iRestoreButton.setLayoutData(new GridData(768)); iRestoreButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { restoreDeleted(); } }); iRevertButton = new Button(buttons, SWT.PUSH); iRevertButton.setText(Messages.getString("TemplatePreferencePage_revert")); iRevertButton.setLayoutData(new GridData(768)); iRevertButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { revert(); } }); createSeparator(buttons); iImportButton = new Button(buttons, SWT.PUSH); iImportButton.setText(Messages.getString("TemplatePreferencePage_import")); iImportButton.setLayoutData(new GridData(768)); iImportButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { import_(); } }); iExportButton = new Button(buttons, SWT.PUSH); iExportButton.setText(Messages.getString("TemplatePreferencePage_export")); iExportButton.setLayoutData(new GridData(768)); iExportButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { export(); } }); iPatternViewer = createViewer(parent, 2); iTreeViewer.setInput(getTemplateStore()); updateButtons(); Dialog.applyDialogFont(parent); innerParent.layout(); return parent; }
From source file:com.nokia.testfw.codegen.ui.wizard.GenTestMethodPage.java
License:Open Source License
/** * Implement method of IDialogPage to create UI of this wizard page *///from w w w. j av a 2 s.co m public void createControl(Composite aComposite) { initializeDialogUnits(aComposite); final Composite lComposite = new Composite(aComposite, SWT.NONE); { lComposite.setLayout(new GridLayout(1, false)); lComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); setControl(lComposite); iTreeViewer = new TreeViewer(lComposite, SWT.BORDER); // Content Provider iTreeViewer.setContentProvider(new ClassMethodContentProvider()); // Label Provider iTreeViewer.setLabelProvider(new ClassMethodLabelProvider()); // Filter iTreeViewer.addFilter(new ClassMethodViewerFilter()); // Selection Changed listener iTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { checkButtonState(); } }); iTreeViewer.setComparator(new ViewerComparator()); // Double Click Listener iTreeViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); iSelectedItem = (NodeImpl) selection.getFirstElement(); if (iSelectedItem instanceof MethodNodeImpl) { iBtnEditMethod.notifyListeners(SWT.Selection, null); } } }); iTree = iTreeViewer.getTree(); iTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); } final Composite lBtnComposite = new Composite(lComposite, SWT.NONE); { lBtnComposite.setLayout(new GridLayout(4, true)); lBtnComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // Add Method Button iBtnAddMethod = new Button(lBtnComposite, SWT.PUSH); iBtnAddMethod.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); iBtnAddMethod.setText(Messages.getString("GenTestMethodPage.AddMethod")); iBtnAddMethod.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { try { MethodEditDialog dialog = new MethodEditDialog(lBtnComposite.getShell(), Messages.getString("MethodDialog.AddMethodTitle"), iClassNode); if (dialog.open()) { addMethod(dialog.getMethodItem().getName()); iTreeViewer.refresh(); } setPageComplete(isPageComplete()); } catch (Exception e) { IStatus lStatus = new Status(IStatus.WARNING, GenTestMethodPage.class.getName(), "Exception was thrown while adding method.", e); CodegenUIPlugin.getDefault().getLog().log(lStatus); } } }); // Edit Method Button iBtnEditMethod = new Button(lBtnComposite, SWT.PUSH); iBtnEditMethod.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); iBtnEditMethod.setText(Messages.getString("GenTestMethodPage.EditMethod")); iBtnEditMethod.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { MethodNodeImpl item = (MethodNodeImpl) iSelectedItem; MethodEditDialog dialog = new MethodEditDialog(lBtnComposite.getShell(), Messages.getString("MethodDialog.EditMethodTitle"), item); if (dialog.open()) { iTreeViewer.update(item, null); } setPageComplete(isPageComplete()); } }); // Delete Method Button iBtnDeleteMethod = new Button(lBtnComposite, SWT.PUSH); iBtnDeleteMethod.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); iBtnDeleteMethod.setText(Messages.getString("GenTestMethodPage.DeleteMethod")); iBtnDeleteMethod.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { MethodNodeImpl item = (MethodNodeImpl) iSelectedItem; boolean rlt = MessageDialog.openQuestion(lBtnComposite.getShell(), Messages.getString("GenTestMethodPage.ConfirmDelete"), Messages.getString("GenTestMethodPage.WhetherDeleteMethod", item.getName())); if (rlt) { ((ClassNodeImpl) item.getParent()).removeChild(item); iTreeViewer.remove(item); } setPageComplete(isPageComplete()); } }); // HeaderButton iHeaderButton = new Button(lBtnComposite, SWT.PUSH); iHeaderButton.setText(Messages.getString("GenTestMethodPage.BindMethod")); iHeaderButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); iHeaderButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { iHeaderButton.setEnabled(false); IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { iTargetProject = ((AbstractTemplateWizard) getWizard()).getTargetProject(); if (iTargetProject == null) { try { iTargetProject = ((AbstractTemplateWizard) getWizard()) .createTargetProject(monitor); } catch (CoreException e) { CodegenUIPlugin.getDefault().getLog().log(e.getStatus()); MessageDialog.openError(getShell(), "Exception was thrown while generating files", e.getMessage()); } } } }; try { new ProgressMonitorDialog(getShell()).run(true, false, op); } catch (InterruptedException e) { } catch (InvocationTargetException e) { IStatus lStatus = new Status(IStatus.ERROR, AbstractTemplateWizard.class.getName(), "Exception was thrown while creating project.", e.getTargetException()); CodegenUIPlugin.getDefault().getLog().log(lStatus); MessageDialog.openError(getShell(), "Exception was thrown while creating project.", e.getTargetException().getMessage()); } ISymbianSDK sdk = ((AbstractTemplateWizard) getWizard()).getDefaultSDK(); GenTestMethodDialog dialog = new GenTestMethodDialog(iHeaderButton.getShell(), iTargetProject, sdk); try { if (dialog.open()) { IPath includePath = new Path(dialog.getHeaderFilePath()); iClassNode.addIIncludeHeader(includePath.lastSegment()); includePath = includePath.removeLastSegments(1); int match = includePath.matchingFirstSegments(new Path(sdk.getEPOCROOT())); if (match > 0) { includePath = includePath.removeFirstSegments(match); } includePath = includePath.setDevice(null); iProjectNode.getSystemIncludes().add(includePath.toString()); iProjectNode.getLibrarys().add(dialog.getLib()); for (INode classNode : dialog.getHeaderNode().getChildren()) { for (INode methodNode : classNode.getChildren()) { if (((UIMethodNode) methodNode).isSelected()) { addMethod(classNode.getName() + "_" + methodNode.getName()); } } } iTreeViewer.refresh(); setPageComplete(isPageComplete()); } } catch (Exception e) { IStatus lStatus = new Status(IStatus.ERROR, AbstractTemplateWizard.class.getName(), "Exception was thrown while creating project.", e); CodegenUIPlugin.getDefault().getLog().log(lStatus); } finally { iHeaderButton.setEnabled(true); } } }); } }
From source file:com.nokia.testfw.codegen.ui.wizard.TestCasePreviewPage.java
License:Open Source License
public void createControl(Composite parent) { container = new Composite(parent, SWT.NONE); container.setLayout(new GridLayout(1, true)); // table to display all files that are going to be changed Label label1 = new Label(container, SWT.SINGLE); label1.setText("Files to be modified"); iTreeViewer = new TreeViewer(container, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); iTreeViewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); PathNodeTreeContentLabelProvoder provider = new PathNodeTreeContentLabelProvoder(); iTreeViewer.setLabelProvider(provider); iTreeViewer.setContentProvider(provider); iTreeViewer.setComparator(new PathNodeTreeViewerComparator()); iTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { ITreeSelection sel = (ITreeSelection) event.getSelection(); if (sel != null) { PathNode node = (PathNode) sel.getFirstElement(); if (node != null) { setSelectElement((ChangeElement) node.getData()); }/*ww w . j a v a2 s . c o m*/ } } }); // UI elements to show the CompareViewerSwitchingPane SashForm sashForm = new SashForm(container, SWT.VERTICAL); sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); sashForm.setBackground(new Color(getShell().getDisplay(), 0, 0, 0)); previewContainer = new PageBook(sashForm, SWT.NONE); comparePreview = new ComparePreviewer(previewContainer, false, false); setSelectElement(null); setControl(container); /** * We want to be informed about pageChanged event in order to generate * content. */ ((WizardDialog) getContainer()).addPageChangedListener(this); ((WizardDialog) getContainer()).addPageChangingListener(this); }
From source file:com.nokia.testfw.stf.configeditor.editors.ConfigEditor.java
License:Open Source License
/** * Creates modules page/*from ww w . j a va 2 s.c o m*/ */ void createModulesPage() { modulesMainForm = toolkit.createScrolledForm(getContainer()); modulesMainForm.setText("STF modules settings"); ColumnLayout modulesMainFormLayout = new ColumnLayout(); modulesMainFormLayout.maxNumColumns = 1; Section modulesSection = toolkit.createSection(modulesMainForm.getBody(), Section.TITLE_BAR); modulesSection.setText("Modules"); Composite modulesSectionClient = toolkit.createComposite(modulesSection); TableWrapLayout modulesSectionLayout = new TableWrapLayout(); modulesSectionLayout.numColumns = 2; modulesSectionClient.setLayout(modulesSectionLayout); modulesSectionClient.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); modulesSection.setClient(modulesSectionClient); modulesTreeViewer = new TreeViewer(modulesSectionClient, SWT.SINGLE); toolkit.adapt(modulesTreeViewer.getTree(), true, true); TableWrapData modulesTreeViewerLayoutData = new TableWrapData(TableWrapData.FILL_GRAB); modulesTreeViewerLayoutData.valign = TableWrapData.FILL; modulesTreeViewer.getTree().setLayoutData(modulesTreeViewerLayoutData); modulesTreeViewer.addSelectionChangedListener(this); Composite buttonsGroup = toolkit.createComposite(modulesSectionClient); TableWrapData buttonsGroupLayoutData = new TableWrapData(); buttonsGroupLayoutData.heightHint = SWT.MAX; buttonsGroupLayoutData.valign = TableWrapData.FILL; buttonsGroup.setLayoutData(buttonsGroupLayoutData); TableWrapLayout buttonsGroupLayout = new TableWrapLayout(); buttonsGroupLayout.numColumns = 1; buttonsGroupLayout.topMargin = 0; buttonsGroup.setLayout(buttonsGroupLayout); addModuleButton = toolkit.createButton(buttonsGroup, "Add module", SWT.PUSH); addModuleButton.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); addModuleButton.addSelectionListener(this); addTestCaseFileButton = toolkit.createButton(buttonsGroup, "Add test case file", SWT.PUSH); addTestCaseFileButton.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); addTestCaseFileButton.addSelectionListener(this); addIniFileButton = toolkit.createButton(buttonsGroup, "Add ini file", SWT.PUSH); addIniFileButton.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); addIniFileButton.addSelectionListener(this); editButton = toolkit.createButton(buttonsGroup, "Edit", SWT.PUSH); editButton.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); editButton.addSelectionListener(this); removeButton = toolkit.createButton(buttonsGroup, "Remove", SWT.PUSH); removeButton.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); removeButton.addSelectionListener(this); // Final initializations modulesMainForm.getBody().setLayout(modulesMainFormLayout); modulesSectionClient.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); toolkit.paintBordersFor(modulesSectionClient); modulesPageIndex = addPage(modulesMainForm); setPageText(modulesPageIndex, "Modules"); modulesTreeRoot = new ModulesTreeNode(); modulesTreeViewer.setContentProvider(new ModulesTreeContentProvider()); modulesTreeViewer.setLabelProvider(new ModulesTreeLabelProvider()); modulesTreeViewer.setInput(modulesTreeRoot); }
From source file:com.nokia.tools.s60.editor.ui.views.ActiveLayersPage.java
License:Open Source License
/** * This is a callback that will allow us to create the viewer and initialize * it.//from w w w. jav a 2s.c om */ public void createControl(Composite parent) { treeTabComposite = new Composite(parent, SWT.NONE); treeTabComposite.setLayout(new FillLayout()); treeViewer = new TreeViewer(treeTabComposite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL); colorizingHelper = new ColorizingHelper(getEditor(), ((GraphicsEditorPart) getWorkbenchPart()).getCommandStack(), treeViewer); addDragDropSupport(); treeViewer.setContentProvider(new TreeViewContentProvider()); treeViewerLabelProvider = new TreeViewLabelProvider(); treeViewer.setLabelProvider(treeViewerLabelProvider); treeViewer.setInput(image); treeViewer.addSelectionChangedListener(this); // add double click support treeViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { Object eff = ((IStructuredSelection) treeViewer.getSelection()).getFirstElement(); if (eff instanceof ILayerEffect) { // make sure that properties view is visible IWorkbenchPage page = getSite().getWorkbenchWindow().getActivePage(); if (page.findView("org.eclipse.ui.views.PropertySheet") == null) { try { page.showView("org.eclipse.ui.views.PropertySheet", null, IWorkbenchPage.VIEW_CREATE); } catch (PartInitException e) { e.printStackTrace(); } } } else if (eff instanceof ILayer) { ILayer layer = (ILayer) eff; if (layer.isBitmapImage()) { AbstractEditAction action = new EditImageInBitmapEditorAction(treeViewer, getCommandStack()); action.run(); } else if (layer.isSvgImage()) { AbstractEditAction action = new EditImageInSVGEditorAction(treeViewer, getCommandStack()); action.run(); } } } }); // add ctrl+c, ctrl+v support treeViewer.getTree().addKeyListener(new CopyPasteKeyAdapter(treeViewer)); colorPickerTooltip = colorizingHelper.createTooltip(); hookContextMenu(); contributeToActionBars(); getSite().setSelectionProvider(treeViewer); }
From source file:com.nokia.tools.s60.editor.ui.views.LayersPage.java
License:Open Source License
/** * This is a callback that will allow us to create the viewer and initialize * it.//w w w . ja v a 2 s. c o m */ public void createControl(Composite parent) { treeTabComposite = new Composite(parent, SWT.NONE); treeTabComposite.setLayout(new FillLayout()); treeViewer = new TreeViewer(treeTabComposite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL); colorizingHelper = new ColorizingHelper(owningEditor, getCommandStack(), treeViewer); treeViewer.setContentProvider(new TreeViewContentProvider()); treeViewerLabelProvider = new TreeViewLabelProvider(); treeViewer.setLabelProvider(treeViewerLabelProvider); treeViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { Object sel = ((IStructuredSelection) treeViewer.getSelection()).getFirstElement(); if (sel instanceof Object[]) { if (AbstractAction.TYPE_IMAGE.equals(((Object[]) sel)[3])) { ILayer layer = (ILayer) ((Object[]) sel)[1]; if (layer.isBackground()) return; if (layer.isBitmapImage()) { AbstractEditAction action = new EditImageInBitmapEditorAction(treeViewer, getCommandStack()); action.run(); } else { AbstractEditAction action = new EditImageInSVGEditorAction(treeViewer, getCommandStack()); action.run(); } } else if (AbstractAction.TYPE_MASK.equals(((Object[]) sel)[3])) { // execute open-mask-in-editor action AbstractEditAction action = new EditMaskAction(treeViewer, getCommandStack()); action.run(); } else if (AbstractAction.TYPE_LAYER.equals(((Object[]) sel)[3])) { ILayer layer = (ILayer) ((Object[]) sel)[1]; if (layer.hasImage() || layer.isBackground()) { // open editor if (layer.isBitmapImage() || layer.isBackground()) { AbstractEditAction action = new EditImageInBitmapEditorAction(treeViewer, getCommandStack()); action.run(); } else { AbstractEditAction action = new EditImageInSVGEditorAction(treeViewer, getCommandStack()); action.run(); } } } else if (AbstractAction.TYPE_COLOR.equals(((Object[]) sel)[3]) || AbstractAction.TYPE_COLOR_GROUP.equals(((Object[]) sel)[3])) { RGB rgb = (RGB) ((Object[]) sel)[4]; String hashColor = ColorUtil.asHashString(rgb); CssColorDialog dialog = new CssColorDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); dialog.setRGBString(hashColor); if (dialog.open() == CssColorDialog.CANCEL) { return; } RGB newColor = dialog.getRGB(); colorizingHelper.handleColorChange(newColor, sel); } } } }); colorPickerTooltip = colorizingHelper.createTooltip(); addDragAndDropSupport(); hookContextMenu(); contributeToActionBars(); }
From source file:com.nokia.tools.s60.views.ColorViewPage.java
License:Open Source License
public void createCompositeArea(Composite parent) { Composite dialogArea = parent; parent.getParent().addFocusListener(new FocusAdapter() { // this is to ensure that after opening when user selects pattern // input he can see // all items @Override//from w ww . ja v a2s . com public void focusGained(FocusEvent event) { try { treeViewer.getLabelProvider().dispose(); treeViewer.setInput(createInput()); } catch (Exception e) { e.printStackTrace(); } } }); treeViewer = new TreeViewer(dialogArea, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL); Tree tree = treeViewer.getTree(); tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); treeViewer.setContentProvider(new TreeViewContentProvider()); treeViewer.setLabelProvider(new TreeViewLabelProvider()); treeViewer.getLabelProvider().dispose(); treeViewer.setInput(createInput()); addDragAndDropSupport(); hookContextMenu(); createTooltip(treeViewer.getTree()); }
From source file:com.nokia.tools.s60.wizards.PluginContentViewer.java
License:Open Source License
public PluginContentViewer(Composite parent) { SashForm sash = new SashForm(parent, SWT.NONE); GridData gd = new GridData(GridData.FILL_BOTH); gd.minimumHeight = 28;//from w w w.j av a 2 s. c o m sash.setLayoutData(gd); treeViewer = new TreeViewer(sash, SWT.BORDER); PluginContentProvider provider = new PluginContentProvider(); treeViewer.setContentProvider(provider); treeViewer.setLabelProvider(new PluginLabelProvider(provider)); treeViewer.setInput(PluginContentProvider.EMPTY_INPUT); treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { /* * (non-Javadoc) * * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) */ public void selectionChanged(SelectionChangedEvent event) { ISelection selection = event.getSelection(); if (selection instanceof IStructuredSelection) { Object input = ((IStructuredSelection) selection).getFirstElement(); if (input != null) { tableViewer.setInput(input); } } } }); tableViewer = new TableViewer(sash, SWT.FULL_SELECTION | SWT.BORDER); tableViewer.setContentProvider(new PluginPropertiesContentProvider(provider)); tableViewer.setLabelProvider(new PluginPropertiesLabelProvider(provider)); Table table = tableViewer.getTable(); final TableColumn colPro = new TableColumn(table, SWT.LEFT, 0); colPro.setText("Property"); final TableColumn colVal = new TableColumn(table, SWT.LEFT, 1); colVal.setText("Value"); table.setHeaderVisible(true); table.setLinesVisible(true); tableViewer.getTable().addListener(SWT.Resize, new Listener() { public void handleEvent(Event event) { if (updateColSizes) { Table tbl = tableViewer.getTable(); int w = tbl.getClientArea().width; int c1 = w / 3 * 2; int c2 = w - c1; updateColSizes = false; colPro.setWidth(c2); colVal.setWidth(c1); updateColSizes = true; } } }); sash.setWeights(new int[] { 50, 50 }); }