Example usage for org.eclipse.jface.viewers StructuredSelection StructuredSelection

List of usage examples for org.eclipse.jface.viewers StructuredSelection StructuredSelection

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers StructuredSelection StructuredSelection.

Prototype

public StructuredSelection(List elements) 

Source Link

Document

Creates a structured selection from the given List.

Usage

From source file:ca.mcgill.cs.swevo.qualyzer.providers.TreeDropListener.java

License:Open Source License

/**
 * Performs the drop based on the data. The length of the data determines where the data is coming from 
 * (the tree or the table). Parses the data and then creates, copies or moves any necessary nodes.
 *//*from w w  w .  j av  a2  s  .  c  om*/
@Override
public boolean performDrop(Object data) {
    String info = (String) data;
    String[] values = info.split(SPLIT);

    if (fTarget != null) {
        if (values.length == TREE_DATA_SIZE) {
            Long id = Long.parseLong(values[0]);
            Node toMove = findNode(values[1], id);

            if (fCopy) {
                toMove = toMove.copy();
            } else {
                Node oldParent = toMove.getParent();
                oldParent.getChildren().remove(toMove.getPersistenceId());
            }

            toMove.setParent(fTarget);
            toMove.updatePaths();

            refreshEditor();
            fViewer.setSelection(new StructuredSelection(toMove), true);
            return true;
        } else if (values.length == TABLE_DATA_SIZE) {
            long childID = Long.parseLong(((String) data).split(":")[1]); //$NON-NLS-1$
            fTarget.addChild((String) data);
            Node child = fTarget.getChild(childID);
            refreshEditor();
            fViewer.setSelection(new StructuredSelection(child), true);
            return true;
        }
    }

    return false;
}

From source file:ca.mcgill.cs.swevo.qualyzer.TestUtil.java

License:Open Source License

public static final void setProjectExplorerSelection(Object element) {
    CommonNavigator view = (CommonNavigator) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
            .getActivePage().findView(QualyzerActivator.PROJECT_EXPLORER_VIEW_ID);
    view.getCommonViewer().refresh();/* w w  w . j av a 2s.  c o m*/
    view.getCommonViewer().expandAll();
    IStructuredSelection selection = new StructuredSelection(element);
    view.selectReveal(selection);
}

From source file:ca.mcgill.cs.swevo.qualyzer.TestUtil.java

License:Open Source License

public static final void setProjectExplorerSelection(Object[] elements) {
    CommonNavigator view = (CommonNavigator) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
            .getActivePage().findView(QualyzerActivator.PROJECT_EXPLORER_VIEW_ID);
    view.getCommonViewer().refresh();//from   ww w.  jav a 2s . co  m
    view.getCommonViewer().expandAll();
    IStructuredSelection selection = new StructuredSelection(elements);
    view.selectReveal(selection);
}

From source file:ca.mcgill.cs.swevo.qualyzer.wizards.ProjectExportWizard.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override// w ww .  j ava  2s .  c om
public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
    this.fSelection = currentSelection;
    List selectedResources = IDE.computeSelectedResources(currentSelection);
    if (!selectedResources.isEmpty()) {
        this.fSelection = new StructuredSelection(selectedResources);
    }

    setWindowTitle(DataTransferMessages.DataTransfer_export);
    setDefaultPageImageDescriptor(IDEWorkbenchPlugin.getIDEImageDescriptor("wizban/exportzip_wiz.png")); //$NON-NLS-1$
    setNeedsProgressMonitor(true);
}

From source file:ca.usask.cs.srlab.simclipse.clone.comparison.CloneCompareAction.java

License:Open Source License

public void run(IAction action) {

    if (!action.isEnabled() || comparatorInput == null || view == null || selection == null)
        return;/*from www. j  a v a  2  s. c  o m*/

    if (!(selection instanceof StructuredSelection))
        return;

    if (!(((StructuredSelection) selection).getFirstElement() instanceof CloneSetDisplayModel))
        return;

    IProject project = ((CloneSetDisplayModel) ((StructuredSelection) selection).getFirstElement())
            .getParentProject().getProject();
    List<IFile> tmpFileList = new ArrayList<IFile>(
            ((CloneSetDisplayModel) ((StructuredSelection) selection).getFirstElement()).size());

    IFolder simclipseDataFolder = (IFolder) project.findMember(SimClipseConstants.SIMCLIPSE_DATA_FOLDER);
    IFolder simclipseTmpFolder = simclipseDataFolder.getFolder(SimClipseConstants.SIMCLIPSE_TMP_SRC_FOLDER);

    FileUtil.deleteDirectory(simclipseTmpFolder.getLocation().toFile());

    for (ICloneViewItem cvi : ((CloneSetDisplayModel) ((StructuredSelection) selection).getFirstElement())
            .getCloneFragmentModels()) {
        CloneFragmentDisplayModel clonefragment = (CloneFragmentDisplayModel) cvi;
        IFile originalIFile = (IFile) clonefragment.getResource();

        LineNumberReader lineNumberReader = null;
        PrintWriter pwr = null;
        try {

            IPath originalIFilePath = originalIFile.getProjectRelativePath();
            IFolder virtualForderToCreate = simclipseTmpFolder
                    .getFolder(originalIFilePath.removeLastSegments(1));
            IFile linkedVistualFile = (IFile) virtualForderToCreate.getFile(originalIFilePath
                    .addFileExtension(
                            "part(" + clonefragment.getFromLine() + "-" + clonefragment.getToLine() + ")")
                    .lastSegment());

            prepareVirtualFolder(virtualForderToCreate, true);

            //local filesystem 
            IPath linkedActualFile = project.getLocation().removeLastSegments(1)
                    .append(linkedVistualFile.getFullPath());

            if (!linkedActualFile.removeLastSegments(1).toFile().exists()) {
                linkedActualFile.removeLastSegments(1).toFile().mkdirs();
            }

            File partFile = linkedActualFile.toFile();

            if (partFile.exists()) {
                partFile.delete();
            }

            pwr = new PrintWriter(partFile);
            pwr.println(clonefragment.toShortString());

            String line = null;
            lineNumberReader = new LineNumberReader(new FileReader(originalIFile.getLocation().toFile()));

            while ((line = lineNumberReader.readLine()) != null) {
                int lineNumber = lineNumberReader.getLineNumber();
                if (lineNumber >= clonefragment.getFromLine() && lineNumber <= clonefragment.getToLine()) {
                    pwr.println(line);
                }
            }
            pwr.close();
            partFile.setReadOnly();
            partFile.setWritable(false);
            partFile.deleteOnExit();

            try {
                linkedVistualFile.createLink(partFile.toURI(), IResource.REPLACE | IResource.HIDDEN, null);
            } catch (CoreException e) {
                e.printStackTrace();
            }

            IFile newIFile = (IFile) project.findMember(linkedActualFile.makeRelativeTo(project.getLocation()));
            tmpFileList.add(newIFile);

        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        } finally {
            //Close the BufferedWriter
            try {
                if (lineNumberReader != null) {
                    lineNumberReader.close();
                }

                if (pwr != null)
                    pwr.close();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }

    selection = new StructuredSelection(tmpFileList);

    boolean ok = comparatorInput.setSelection(selection, view.getSite().getShell(), showSelectAncestorDialog);
    if (!ok)
        return;

    try {

        comparatorInput.initializeCompareConfiguration();
        CompareUI.openCompareEditorOnPage(comparatorInput, fWorkbenchPage);
        comparatorInput = null; // don't reuse this input!
    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
    }
}

From source file:ca.usask.cs.srlab.simclipse.clone.comparison.CloneCompareAction.java

License:Open Source License

protected boolean isEnabled(ISelection selection) {

    if (!(selection instanceof StructuredSelection)) {
        return false;
    }/*from   www .ja va  2s .  c  o  m*/

    IStructuredSelection ssel = (IStructuredSelection) selection;
    if (ssel.size() < 1) {
        return false;
    }

    if ((((StructuredSelection) selection).getFirstElement() instanceof CloneSetDisplayModel)) {
        List<IFile> fileList = new ArrayList<IFile>(
                ((CloneSetDisplayModel) ((StructuredSelection) selection).getFirstElement()).size());

        List<? extends ICloneViewItem> cloneFragmentModels = ((CloneSetDisplayModel) ((StructuredSelection) selection)
                .getFirstElement()).getCloneFragmentModels();
        if (cloneFragmentModels.size() > 2) {

            //            MessageDialog
            //                  .openWarning(
            //                        SimClipsePlugin.getActiveWorkbenchShell(),
            //                        "Warning!",
            //                        "Fragments more than two cannot be compared. Please select any two fragments and click compare");
            return false;
        }

        for (ICloneViewItem cvi : cloneFragmentModels) {
            CloneFragmentDisplayModel tempObj = (CloneFragmentDisplayModel) cvi;
            IFile ifile = (IFile) tempObj.getResource();
            fileList.add(ifile);
        }
        selection = new StructuredSelection(fileList);
    }

    if (comparatorInput == null) {
        CompareConfiguration cc = new CompareConfiguration();
        // buffered merge mode: don't ask for confirmation
        // when switching between modified resources

        //cc.setProperty(CompareEditor.CONFIRM_SAVE_PROPERTY, new Boolean(false));

        // uncomment following line to have separate outline view
        //cc.setProperty(CompareConfiguration.USE_OUTLINE_VIEW, new Boolean(true));

        comparatorInput = new ResourceCompareInput(cc);
    }
    return comparatorInput.isEnabled(selection);
}

From source file:ca.usask.cs.srlab.simclipse.clone.comparison.CompareWithOtherResourceDialog.java

License:Open Source License

private boolean isComparePossible() {
    IResource[] resources;/*from w w w.  j  ava  2 s .  c o m*/
    if (ancestorPanel.getResource() == null)
        resources = new IResource[] { leftPanel.getResource(), rightPanel.getResource() };
    else
        resources = new IResource[] { ancestorPanel.getResource(), leftPanel.getResource(),
                rightPanel.getResource() };

    ResourceCompareInput r = new ResourceCompareInput(new CompareConfiguration());
    return r.isEnabled(new StructuredSelection(resources));
}

From source file:ca.uvic.chisel.javasketch.ui.internal.presentation.ExpandToRootRunnable.java

License:Open Source License

@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    monitor.beginTask("Expanding chart along callpath", pathToRoot.size());
    ILabelProvider lp = (ILabelProvider) viewer.getLabelProvider();
    if (pathToRoot.size() <= 0) {
        monitor.done();/*from   ww w  . j a  v a 2  s .  c  om*/
        return;
    }
    //if the last element is already visible, there is no need to
    //expand, just quit early.
    if (viewer.isVisible(pathToRoot.getLast())) {
        return;
    }
    ITraceModel modelElement = (ITraceModel) pathToRoot.get(0);
    IProgramSketch sketch = SketchPlugin.getDefault().getSketch(modelElement);
    if (sketch == null) {
        monitor.done();
        return;
    }
    PresentationData pd = PresentationData.connect(sketch);
    try {
        viewer.getChart().setRedraw(false);
        for (Object o : pathToRoot) {
            IActivation a = (IActivation) o;

            //make sure that the activation is visible in its groups
            if (pd != null) {
                ITargetMessage arrival = a.getArrival();
                if (arrival != null) {
                    IOriginMessage origin = arrival.getOrigin();
                    if (origin != null) {
                        IActivation pa = origin.getActivation();
                        if (pa != null) {
                            boolean refreshParent = false;
                            ASTMessageGroupingTree groupRoot = pd.getGroups(pa);
                            if (groupRoot != null) {
                                ASTMessageGroupingTree targetGroup = groupRoot.getMessageContainer(origin);
                                while (targetGroup != null && targetGroup != groupRoot) {
                                    if (targetGroup.isLoop() && !pd.isGroupVisible(pa, targetGroup)) {
                                        refreshParent = true;
                                        pd.swapLoop(pa, targetGroup, false);
                                    }
                                    targetGroup = targetGroup.getParent();
                                }
                            }
                            if (refreshParent) {
                                viewer.refresh(pa);
                            }
                        }

                    }
                }

            }
            monitor.subTask(lp.getText(a));
            viewer.setExpanded(a, true);
            viewer.refresh(a);
            if (monitor.isCanceled())
                break;
            monitor.worked(1);
            runEventLoop();
        }

        if (setToRoot) {
            int end = pathToRoot.size() - 1;
            while (end >= 0) {
                viewer.setRootActivation(pathToRoot.get(end));
                if (viewer.getRootActivation() == pathToRoot.get(end)) {
                    break;
                }
                end--;
            }

        }
    } finally {
        pd.disconnect();
        monitor.done();
        viewer.getChart().setRedraw(true);
        if (!viewer.isVisible(pathToRoot.getFirst())) {
            viewer.setRootActivation(pathToRoot.getFirst());
        }
    }
    viewer.reveal(pathToRoot.getLast());
    viewer.setSelection(new StructuredSelection(pathToRoot.getLast()));

}

From source file:ca.uvic.chisel.javasketch.ui.internal.presentation.JavaThreadSequenceView.java

License:Open Source License

/**
 * @param page/*from w  ww.  j av  a2  s .co m*/
 */
private void createTimeRange(Composite page, IThread thread) {
    Composite rangeComposite = new Composite(page, SWT.NONE);
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    rangeComposite.setLayoutData(gd);
    GridLayout layout = new GridLayout(3, false);
    layout.horizontalSpacing = 3;
    layout.verticalSpacing = 0;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    rangeComposite.setLayout(layout);
    minTime = new TimeField(rangeComposite, SWT.NONE);
    gd = new GridData(SWT.FILL, SWT.FILL, false, false);
    gd.heightHint = 15;
    minTime.setLayoutData(gd);
    timeRange = new RangeSlider(rangeComposite, SWT.NONE);
    timeRange.setForeground(page.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
    timeRange.setBackground(page.getDisplay().getSystemColor(SWT.COLOR_GREEN));
    gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gd.heightHint = 15;
    timeRange.setLayoutData(gd);
    if (thread != null) {
        long min = thread.getRoot().getActivation().getTime();
        long max = thread.getRoot().getActivation().getDuration() + min;
        timeRange.setMinimum(min);
        timeRange.setMaximum(max);
        timeRange.setSelectedMinimum(min);
        timeRange.setSelectedMaximum(max);
    }
    maxTime = new TimeField(rangeComposite, SWT.NONE);
    gd = new GridData(SWT.FILL, SWT.FILL, false, false);
    gd.heightHint = 15;
    maxTime.setLayoutData(gd);
    minTime.setTime(timeRange.getMinimum());
    maxTime.setTime(timeRange.getMaximum());
    timeRange.addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            if (e.width < 0 || e.height < 0) {
                if (e.data instanceof InvocationReference) {
                    InvocationReference ref = (InvocationReference) e.data;
                    StructuredSelection selection = new StructuredSelection(ref.activation);
                    selectionProvider.setSelection(selection);
                }
                return;
            }
            boolean changed = false;
            if (minTime.getTime() != timeRange.getSelectedMinimum()) {
                minTime.setTime(timeRange.getSelectedMinimum());
                changed = true;
            }
            if (maxTime.getTime() != timeRange.getSelectedMaximum()) {
                maxTime.setTime(timeRange.getSelectedMaximum());
                changed = true;
            }
            if (changed) {
                refreshJob.cancel();
                refreshJob.schedule(2000);
            }
        }
    });
    viewer.addFilter(new TimeFilter(timeRange));
    ModifyListener typedTimeListener = new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            if (e.widget == maxTime) {
                timeRange.setSelectedMaximum(maxTime.getTime());
            } else if (e.widget == minTime) {
                timeRange.setSelectedMinimum(minTime.getTime());
            }
            refreshJob.cancel();
            refreshJob.schedule(2000);
        }
    };
    minTime.addModifyListener(typedTimeListener);
    maxTime.addModifyListener(typedTimeListener);
    rangeComposite.pack();

    rangeJob = new MarkRangeForSelectionJob(this);
    new TimeLineTooltip(this);
    new TimeLineAnnotationHook(this);
}

From source file:ca.uvic.chisel.logging.eclipse.internal.ui.WorkbenchLoggerPreferencePage.java

License:Open Source License

@Override
protected Control createContents(Composite parent) {
    Composite page = new Composite(parent, SWT.NONE);
    page.setLayout(new GridLayout(2, false));

    // create a list viewer that will display all of the
    // different loggers

    viewer = CheckboxTableViewer.newCheckList(page, SWT.BORDER | SWT.SINGLE);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new LoggingCategoryLabelProvider());
    viewer.setInput(WorkbenchLoggingPlugin.getDefault().getCategoryManager().getCategories());
    // set all of the enabled categories to the checked state
    boolean stale = false;
    for (ILoggingCategory category : WorkbenchLoggingPlugin.getDefault().getCategoryManager().getCategories()) {
        if (category.isEnabled()) {
            enabledCategories.add(category.getCategoryID());
            viewer.setChecked(category, true);
        }//from w ww . j  av  a 2 s. c  o  m
        // also set the stale state... used for enabling the upload button.
        stale |= ((LoggingCategory) category).isStale();
    }
    viewer.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            if (event.getElement() instanceof ILoggingCategory) {
                ILoggingCategory category = (ILoggingCategory) event.getElement();
                if (event.getChecked()) {
                    enabledCategories.add(category.getCategoryID());
                } else {
                    enabledCategories.remove(category.getCategoryID());
                }
            }
        }
    });
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            if (aboutButton != null && !aboutButton.isDisposed()) {
                aboutButton.setEnabled(!event.getSelection().isEmpty());
            }
        }
    });

    viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    // create a button area
    Composite buttonArea = new Composite(page, SWT.NONE);
    buttonArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    buttonArea.setLayout(new GridLayout());

    GridDataFactory gdf = GridDataFactory.createFrom(new GridData(SWT.FILL, SWT.FILL, true, false));
    Button selectAll = new Button(buttonArea, SWT.PUSH);
    selectAll.setText("Select All");
    selectAll.setLayoutData(gdf.create());
    selectAll.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            viewer.setAllChecked(true);
            for (ILoggingCategory category : WorkbenchLoggingPlugin.getDefault().getCategoryManager()
                    .getCategories()) {
                enabledCategories.add(category.getCategoryID());
            }
        }
    });

    Button selectNone = new Button(buttonArea, SWT.PUSH);
    selectNone.setText("Select None");
    selectNone.setLayoutData(gdf.create());
    selectNone.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            viewer.setAllChecked(false);
            enabledCategories.clear();
        }
    });

    Control spacer = new Composite(buttonArea, SWT.NONE);
    GridData d = gdf.create();
    d.heightHint = 40;
    spacer.setLayoutData(d);

    aboutButton = new Button(buttonArea, SWT.PUSH);
    aboutButton.setText("About...");
    aboutButton.setLayoutData(gdf.create());
    aboutButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            ISelection selection = viewer.getSelection();
            if (selection instanceof IStructuredSelection) {
                IStructuredSelection ss = (IStructuredSelection) selection;
                if (!ss.isEmpty() && ss.getFirstElement() instanceof ILoggingCategory) {
                    AboutCategoryDialog dialog = new AboutCategoryDialog(getShell(),
                            (ILoggingCategory) ss.getFirstElement());
                    dialog.open();
                }
            }
        }
    });
    aboutButton.setEnabled(false);

    spacer = new Composite(buttonArea, SWT.NONE);
    d = gdf.create();
    d.heightHint = 40;
    spacer.setLayoutData(d);

    Button uploadButton = new Button(buttonArea, SWT.PUSH);
    uploadButton.setText("Upload Now...");
    uploadButton.setLayoutData(gdf.create());
    uploadButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            WizardDialog dialog = new WizardDialog(getShell(), new UploadWizard());
            dialog.open();
        }
    });
    uploadButton.setEnabled(stale);
    Composite intervalComposite = new Composite(page, SWT.NONE);
    GridData gd = gdf.create();
    gd.grabExcessVerticalSpace = false;
    gd.grabExcessHorizontalSpace = true;
    intervalComposite.setLayoutData(gd);
    intervalComposite.setLayout(new GridLayout(2, false));
    Label intervalLabel = new Label(intervalComposite, SWT.NONE);
    intervalLabel.setText("Upload Interval: ");
    gd = gdf.create();
    gd.grabExcessVerticalSpace = false;
    gd.grabExcessHorizontalSpace = false;
    intervalLabel.setLayoutData(gd);
    intervalViewer = new ComboViewer(intervalComposite, SWT.BORDER | SWT.SINGLE);
    Long[] intervals = new Long[] { UploadJob.UPLOAD_INTERVAL_DAILY, UploadJob.UPLOAD_INTERVAL_WEEKLY,
            UploadJob.UPLOAD_INTERVAL_MONTHLY };
    intervalViewer.setContentProvider(new ArrayContentProvider());
    intervalViewer.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            if (element instanceof Long) {
                long interval = (Long) element;
                if (interval == UploadJob.UPLOAD_INTERVAL_DAILY) {
                    return "Daily";
                } else if (interval == UploadJob.UPLOAD_INTERVAL_WEEKLY) {
                    return "Every Seven Days";
                } else if (interval == UploadJob.UPLOAD_INTERVAL_MONTHLY) {
                    return "Every Thirty Days";
                }
            }
            return super.getText(element);
        }
    });
    intervalViewer.setInput(intervals);
    long interval = WorkbenchLoggingPlugin.getDefault().getPreferenceStore()
            .getLong(UploadJob.UPLOAD_INTERVAL_KEY);
    if (interval <= 0) {
        interval = WorkbenchLoggingPlugin.getDefault().getPreferenceStore()
                .getDefaultLong(UploadJob.UPLOAD_INTERVAL_KEY);
    }
    intervalViewer.setSelection(new StructuredSelection(interval));
    intervalViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

    spacer = new Composite(page, SWT.NONE);
    gd = gdf.create();
    gd.grabExcessVerticalSpace = false;
    gd.grabExcessHorizontalSpace = false;
    gd.heightHint = 2;
    spacer.setLayoutData(gd);
    Composite uidComposite = new Composite(page, SWT.NONE);
    uidComposite.setLayout(new GridLayout(2, false));
    gd = gdf.create();
    gd.grabExcessVerticalSpace = false;
    gd.grabExcessHorizontalSpace = false;
    gd.horizontalSpan = 2;
    uidComposite.setLayoutData(gd);
    Label uidLabel = new Label(uidComposite, SWT.NONE);
    uidLabel.setText("User ID:");
    gd = gdf.create();
    gd.grabExcessVerticalSpace = false;
    gd.grabExcessHorizontalSpace = false;
    uidLabel.setLayoutData(gd);
    final Text uidText = new Text(uidComposite, SWT.SINGLE | SWT.READ_ONLY);
    uidText.setText(WorkbenchLoggingPlugin.getDefault().getLocalUser());
    uidText.addMouseListener(new MouseAdapter() {
        /* (non-Javadoc)
         * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
         */
        @Override
        public void mouseUp(MouseEvent e) {
            uidText.selectAll();
        }
    });
    MenuManager manager = new MenuManager();
    Menu menu = manager.createContextMenu(uidText);
    uidText.setMenu(menu);
    CommandContributionItemParameter parameters = new CommandContributionItemParameter(
            WorkbenchLoggingPlugin.getDefault().getWorkbench(), null, EDIT_COPY, SWT.PUSH);
    manager.add(new CommandContributionItem(parameters));
    return page;
}