public void addManifestation() { final FileDialog fileDialog = new FileDialog(getSite().getShell(), SWT.OPEN); fileDialog.setFilterExtensions(new String[] {"*.xml;*.raid", "*.raid"}); fileDialog.setFilterNames( new String[] {"Fichiers chronosRAID (*.xml,*.raid)", "Projet ChronosRAID (*.raid)"}); final String fileName = fileDialog.open(); if (fileName != null) { ProjectManager.openProject(fileName); } }
@Override public void createPartControl(final Composite parent) { final GridData gridData1 = new GridData(); gridData1.horizontalAlignment = FILL; gridData1.verticalAlignment = GridData.CENTER; final GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 1; final GridData gridData = new GridData(); gridData.grabExcessVerticalSpace = true; gridData.horizontalAlignment = FILL; gridData.verticalAlignment = FILL; gridData.grabExcessHorizontalSpace = true; final Composite top = new Composite(parent, SWT.NONE); top.setLayout(gridLayout); labelTitre = new Label(top, SWT.NONE); labelTitre.setText("Navigateur"); labelTitre.setLayoutData(gridData1); tree = new Tree(top, SWT.MULTI); tree.setLayoutData(gridData); treeViewer = new TreeViewer(tree); getSite().setSelectionProvider(treeViewer); final Image fondImage = ImageReg.getImg(IMG_VIEW_BG); tree.setBackgroundImage(fondImage); tree.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent element) { labelTitre.setText(tree.getSelection()[0].getText()); try { getViewSite().getPage().showView(NAVIGATOR_VIEW_ID); } catch (PartInitException e) { e.printStackTrace(); } } }); applyNavigatorDoubleClick(tree, getSite().getWorkbenchWindow()); treeViewer.setLabelProvider(new NavigatorLabelProvider()); treeViewer.setContentProvider(createContentProvider()); final ProjectManager manager = getProjectManager(); manager.addProjectManagerListener(this); treeViewer.setInput(manager); defineWorkbenchPopupMenu(getSite(), treeViewer); initDragAndDrop(); applyTooltipNavigator(tree); final TreeEditor editor = new TreeEditor(tree); editor.horizontalAlignment = SWT.CENTER; editor.grabHorizontal = true; editor.grabVertical = true; tree.addKeyListener(new TreeEditing(tree, editor)); final Clipboard clipboard = new Clipboard(getSite().getShell().getDisplay()); final IActionBars bars = getViewSite().getActionBars(); bars.setGlobalActionHandler(CUT.getId(), new CutStepAction(treeViewer, clipboard)); bars.setGlobalActionHandler(COPY.getId(), new CopyStepAction(treeViewer, clipboard)); bars.setGlobalActionHandler(PASTE.getId(), new PasteTreeGadgetAction(treeViewer, clipboard)); }