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

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

Introduction

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

Prototype

StructuredSelection EMPTY

To view the source code for org.eclipse.jface.viewers StructuredSelection EMPTY.

Click Source Link

Document

The canonical empty selection.

Usage

From source file:de.quamoco.qm.diagram.navigator.QmNavigatorLinkHelper.java

License:Apache License

/**
 * @generated/*w w  w  . ja v a2  s. c  o  m*/
 */
public IStructuredSelection findSelection(IEditorInput anInput) {
    IDiagramDocument document = QmDiagramEditorPlugin.getInstance().getDocumentProvider()
            .getDiagramDocument(anInput);
    if (document == null) {
        return StructuredSelection.EMPTY;
    }
    Diagram diagram = document.getDiagram();
    IFile file = WorkspaceSynchronizer.getFile(diagram.eResource());
    if (file != null) {
        QmNavigatorItem item = new QmNavigatorItem(diagram, file, false);
        return new StructuredSelection(item);
    }
    return StructuredSelection.EMPTY;
}

From source file:de.quamoco.qm.diagram.part.QmDiagramEditor.java

License:Apache License

/**
 * @generated/*from   ww w  .j  av  a  2  s. c  om*/
 */
private ISelection getNavigatorSelection() {
    IDiagramDocument document = getDiagramDocument();
    if (document == null) {
        return StructuredSelection.EMPTY;
    }
    Diagram diagram = document.getDiagram();
    IFile file = WorkspaceSynchronizer.getFile(diagram.eResource());
    if (file != null) {
        QmNavigatorItem item = new QmNavigatorItem(diagram, file, false);
        return new StructuredSelection(item);
    }
    return StructuredSelection.EMPTY;
}

From source file:de.quamoco.qm.diagram.part.QmNewDiagramFileWizard.java

License:Apache License

/**
 * @generated//  w  w  w. j a  v a 2 s. c  o m
 */
public QmNewDiagramFileWizard(URI domainModelURI, EObject diagramRoot,
        TransactionalEditingDomain editingDomain) {
    assert domainModelURI != null : "Domain model uri must be specified"; //$NON-NLS-1$
    assert diagramRoot != null : "Doagram root element must be specified"; //$NON-NLS-1$
    assert editingDomain != null : "Editing domain must be specified"; //$NON-NLS-1$

    myFileCreationPage = new WizardNewFileCreationPage(Messages.QmNewDiagramFileWizard_CreationPageName,
            StructuredSelection.EMPTY);
    myFileCreationPage.setTitle(Messages.QmNewDiagramFileWizard_CreationPageTitle);
    myFileCreationPage.setDescription(
            NLS.bind(Messages.QmNewDiagramFileWizard_CreationPageDescription, QualityModelEditPart.MODEL_ID));
    IPath filePath;
    String fileName = URI.decode(domainModelURI.trimFileExtension().lastSegment());
    if (domainModelURI.isPlatformResource()) {
        filePath = new Path(domainModelURI.trimSegments(1).toPlatformString(true));
    } else if (domainModelURI.isFile()) {
        filePath = new Path(domainModelURI.trimSegments(1).toFileString());
    } else {
        // TODO : use some default path
        throw new IllegalArgumentException("Unsupported URI: " + domainModelURI); //$NON-NLS-1$
    }
    myFileCreationPage.setContainerFullPath(filePath);
    myFileCreationPage.setFileName(QmDiagramEditorUtil.getUniqueFileName(filePath, fileName, "qm_diagram")); //$NON-NLS-1$

    diagramRootElementSelectionPage = new DiagramRootElementSelectionPage(
            Messages.QmNewDiagramFileWizard_RootSelectionPageName);
    diagramRootElementSelectionPage.setTitle(Messages.QmNewDiagramFileWizard_RootSelectionPageTitle);
    diagramRootElementSelectionPage
            .setDescription(Messages.QmNewDiagramFileWizard_RootSelectionPageDescription);
    diagramRootElementSelectionPage.setModelElement(diagramRoot);

    myEditingDomain = editingDomain;
}

From source file:de.tobject.findbugs.view.explorer.RefreshJob.java

License:Open Source License

@Override
protected IStatus run(final IProgressMonitor monitor) {
    List<DeltaInfo> deltas = fetchDeltas();
    int totalWork = deltas.size();
    monitor.beginTask("Updating bug markers", totalWork);

    if (!checkCancellation(monitor) && !deltas.isEmpty()) {

        final Set<BugGroup> changedParents = contentProvider.updateContent(deltas);
        final boolean fullRefreshNeeded = changedParents.isEmpty() || containsRoot(changedParents);

        Display.getDefault().syncExec(new Runnable() {
            public void run() {
                if (checkCancellation(monitor)) {
                    return;
                }/* www.j a  v a  2  s. c  o m*/
                viewer.getControl().setRedraw(false);
                try {
                    if (fullRefreshNeeded) {
                        // Attempt to fix https://sourceforge.net/p/findbugs/bugs/1213/
                        // discard selection (if any) before refreshing content
                        viewer.setSelection(StructuredSelection.EMPTY);
                        viewer.refresh();
                        if (BugContentProvider.DEBUG) {
                            System.out.println("Refreshing ROOT!!!");
                        }
                    } else {
                        // update the viewer based on the marker changes.
                        for (BugGroup parent : changedParents) {
                            if (BugContentProvider.DEBUG) {
                                System.out.println("Refreshing: " + parent);
                            }
                            if (checkCancellation(monitor)) {
                                break;
                            }
                            viewer.refresh(parent, true);
                        }
                    }
                } finally {
                    if (viewer != null && !viewer.getControl().isDisposed()) {
                        viewer.getControl().setRedraw(true);
                    }
                }
            }
        });
    }
    if (!monitor.isCanceled()) {
        monitor.worked(totalWork);
        monitor.done();
    }
    return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
}

From source file:de.tub.tfs.muvitor.animation.AnimatedElement.java

License:Open Source License

/**
 * Called by {@link AnimatingCommand}, initializes the animation by doing
 * the following://from w w w .  j a v  a 2s  .c o  m
 * 
 * <ul>
 * <li>determine the viewer having the {@link #topModel} as contents
 * <li>get the figure representing the {@link #animatedModel} in this viewer
 * <li>create an extra layer for this particular figure and move the figure
 * to it
 * <li>register this as LayoutListener to the new layer. This will do the
 * job that Animator does in GEF.
 * <li>call {@link #prepareLocalizers()}
 * <li>check if this figure can be animated at all
 * <li>set the figure' bounds to the initial (or final for undo) position
 * </ul>
 * 
 * @param isUndo
 *            set <code>true</code> if the element should be prepared for
 *            backwards undo animation
 * @param doFlush
 *            if <code>true</code> the viewer will be flushed before
 *            animation
 * 
 * @see #findViewerShowing(EObject)
 */
final void prepareForAnimation(final boolean isUndo, final boolean doFlush) {
    viewer = findViewerShowing(topModel);
    // short test if an animation is possible at all
    if (viewer == null || startIndex == -1 || !viewer.getControl().isVisible()) {
        canPerform = false;
        return;
    }

    // to remove disturbing handles: set empty selection
    viewer.setSelection(StructuredSelection.EMPTY);
    /*
     * there may be a new figure that has just been created, flush the
     * viewer to layout it correctly first! this is in the responsibility of
     * the user!
     */
    if (doFlush) {
        viewer.flush();
    }

    // prepare and check localizers
    prepareLocalizers();
    /*
     * ensure that this can only be animated if the localizers (after
     * startIndex) have been sufficiently resolved/interpolated
     */
    for (int i = startIndex; i < path.size(); i++) {
        final Localizer localizer = path.get(i);
        if (localizer.needsInterpolation(true) || localizer.needsInterpolation(false)) {
            canPerform = false;
            return;
        }
    }

    /*
     * retrieve a figure from the viewer whenever a model has been specified
     * so the animated figure can still be accessed after animation
     */
    if (animatedModel != null) {
        final GraphicalEditPart editPart = (GraphicalEditPart) viewer.getEditPartRegistry().get(animatedModel);
        if (editPart == null) {
            canPerform = false;
            return;
        }

        // the figure of the passed model has to be animated
        animatedFigure = editPart.getFigure();
        // store original parent of the model's figure
        originalParent = animatedFigure.getParent();
        originalPosition = originalParent.getChildren().indexOf(animatedFigure);
        originalLocation = animatedFigure.getBounds().getLocation();
    }

    figureCenterOffset = animatedFigure.getSize().scale(-0.5);
    // System.out.println("figureCenterOffset : " + figureCenterOffset);

    // store initial and final locations of the animated figure
    initialLocation = path.get(startIndex).resolvedLocation;
    if (initialLocation != null) {
        initialLocation.getTranslated(figureCenterOffset);
    }
    finalLocation = path.get(path.size() - 1).resolvedLocation;
    if (finalLocation != null) {
        finalLocation.getTranslated(figureCenterOffset);
    }

    /*
     * get the ScalableFreeformLayeredPane of the
     * ScalableFreeformRootEditPart to put the animated figure on it
     */
    final ScalableFreeformRootEditPart root = (ScalableFreeformRootEditPart) viewer.getRootEditPart();
    layer = LayerManager.Helper.find(root).getLayer(LayerConstants.SCALABLE_LAYERS);

    /*
     * install sub-ScalableLayeredPanes on the pane to support scale
     * manipulation of each animated element
     */
    pane = new ScalableFreeformLayeredPane();
    layer.add(pane);
    pane.add(animatedFigure);

    pane.validate();
    pane.addLayoutListener(this);
    // let the MultipleAnimator know which AnimatedElement is
    // responsible for this pane (and to access data)
    paneAnimatedElementMap.put(pane, this);

    // draw optional debug path line
    if (AnimatingCommand.isDebug()) {
        // when debugging show the path as a polyline
        debugLine = new Polyline();
        debugLine.setForegroundColor(ColorConstants.red);
        // use rectangle centers for the debugLine
        if (isUndo) {
            debugLine.setStart(finalLocation);
        } else {
            debugLine.setStart(initialLocation);
        }
        // FIXED: I don't know why, but the line has to been added *before*
        // the animated figure. Does not matter any more, as I use an extra
        // pane for each animated figure
        layer.add(debugLine);
    }

    canPerform = true;
}

From source file:de.tud.cs.st.vespucci.diagram.supports.VespucciCreationWizardCommandHandler.java

License:Open Source License

@Override
public Object execute(final ExecutionEvent event) {
    final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();

    final VespucciCreationWizard wizard = new VespucciCreationWizard();

    final ISelection selection = window.getSelectionService().getSelection();

    if (selection instanceof IStructuredSelection) {
        wizard.init(window.getWorkbench(), (IStructuredSelection) selection);
    } else {/*  ww  w . j  a v  a  2  s.  c o m*/
        wizard.init(window.getWorkbench(), StructuredSelection.EMPTY);
    }

    final Shell parent = window.getShell();
    final WizardDialog dialog = new WizardDialog(parent, wizard);
    dialog.create();
    dialog.open();

    return null;
}

From source file:de.tud.cs.st.vespucci.vespucci_model.diagram.navigator.VespucciNavigatorLinkHelper.java

License:Open Source License

/**
 * @generated/*from  w  w w  .j  a v  a 2s. com*/
 */
public IStructuredSelection findSelection(IEditorInput anInput) {
    IDiagramDocument document = de.tud.cs.st.vespucci.vespucci_model.diagram.part.VespucciDiagramEditorPlugin
            .getInstance().getDocumentProvider().getDiagramDocument(anInput);
    if (document == null) {
        return StructuredSelection.EMPTY;
    }
    Diagram diagram = document.getDiagram();
    if (diagram == null || diagram.eResource() == null) {
        return StructuredSelection.EMPTY;
    }
    IFile file = WorkspaceSynchronizer.getFile(diagram.eResource());
    if (file != null) {
        de.tud.cs.st.vespucci.vespucci_model.diagram.navigator.VespucciNavigatorItem item = new de.tud.cs.st.vespucci.vespucci_model.diagram.navigator.VespucciNavigatorItem(
                diagram, file, false);
        return new StructuredSelection(item);
    }
    return StructuredSelection.EMPTY;
}

From source file:de.tud.cs.st.vespucci.vespucci_model.diagram.part.VespucciDiagramEditor.java

License:Open Source License

/**
 * @generated/*from  ww w  . ja  v a  2 s. c o  m*/
 */
private ISelection getNavigatorSelection() {
    IDiagramDocument document = getDiagramDocument();
    if (document == null) {
        return StructuredSelection.EMPTY;
    }
    Diagram diagram = document.getDiagram();
    if (diagram == null || diagram.eResource() == null) {
        return StructuredSelection.EMPTY;
    }
    IFile file = WorkspaceSynchronizer.getFile(diagram.eResource());
    if (file != null) {
        de.tud.cs.st.vespucci.vespucci_model.diagram.navigator.VespucciNavigatorItem item = new de.tud.cs.st.vespucci.vespucci_model.diagram.navigator.VespucciNavigatorItem(
                diagram, file, false);
        return new StructuredSelection(item);
    }
    return StructuredSelection.EMPTY;
}

From source file:de.tud.cs.st.vespucci.vespucci_model.diagram.part.VespucciNewDiagramFileWizard.java

License:Open Source License

/**
 * @generated/*from   w  w w.  j av  a2  s  . co  m*/
 */
public VespucciNewDiagramFileWizard(URI domainModelURI, EObject diagramRoot,
        TransactionalEditingDomain editingDomain) {
    assert domainModelURI != null : "Domain model uri must be specified"; //$NON-NLS-1$
    assert diagramRoot != null : "Doagram root element must be specified"; //$NON-NLS-1$
    assert editingDomain != null : "Editing domain must be specified"; //$NON-NLS-1$

    myFileCreationPage = new WizardNewFileCreationPage(
            de.tud.cs.st.vespucci.vespucci_model.diagram.part.Messages.VespucciNewDiagramFileWizard_CreationPageName,
            StructuredSelection.EMPTY);
    myFileCreationPage.setTitle(
            de.tud.cs.st.vespucci.vespucci_model.diagram.part.Messages.VespucciNewDiagramFileWizard_CreationPageTitle);
    myFileCreationPage.setDescription(NLS.bind(
            de.tud.cs.st.vespucci.vespucci_model.diagram.part.Messages.VespucciNewDiagramFileWizard_CreationPageDescription,
            de.tud.cs.st.vespucci.vespucci_model.diagram.edit.parts.ShapesDiagramEditPart.MODEL_ID));
    IPath filePath;
    String fileName = URI.decode(domainModelURI.trimFileExtension().lastSegment());
    if (domainModelURI.isPlatformResource()) {
        filePath = new Path(domainModelURI.trimSegments(1).toPlatformString(true));
    } else if (domainModelURI.isFile()) {
        filePath = new Path(domainModelURI.trimSegments(1).toFileString());
    } else {
        // TODO : use some default path
        throw new IllegalArgumentException("Unsupported URI: " + domainModelURI); //$NON-NLS-1$
    }
    myFileCreationPage.setContainerFullPath(filePath);
    myFileCreationPage.setFileName(de.tud.cs.st.vespucci.vespucci_model.diagram.part.VespucciDiagramEditorUtil
            .getUniqueFileName(filePath, fileName, "sad")); //$NON-NLS-1$

    diagramRootElementSelectionPage = new DiagramRootElementSelectionPage(
            de.tud.cs.st.vespucci.vespucci_model.diagram.part.Messages.VespucciNewDiagramFileWizard_RootSelectionPageName);
    diagramRootElementSelectionPage.setTitle(
            de.tud.cs.st.vespucci.vespucci_model.diagram.part.Messages.VespucciNewDiagramFileWizard_RootSelectionPageTitle);
    diagramRootElementSelectionPage.setDescription(
            de.tud.cs.st.vespucci.vespucci_model.diagram.part.Messages.VespucciNewDiagramFileWizard_RootSelectionPageDescription);
    diagramRootElementSelectionPage.setModelElement(diagramRoot);

    myEditingDomain = editingDomain;
}

From source file:de.uni_jena.iaa.linktype.atomic.model.pepper.wizard.PepperWizardPageFormat.java

License:Apache License

/**
 * {@inheritDoc}//from w w w  .jav a2s. co m
 */
@Override
public void setVisible(boolean visible) {
    if (visible) {
        EList<FormatDefinition> supportedFormats = pepperWizard.getSupportedFormats();
        tableViewer.setInput(supportedFormats);

        FormatDefinition formatDefinition = supportedFormats.size() == 1 ? supportedFormats.get(0)
                : pepperWizard.getFormatDefinition();

        if (formatDefinition == null) {
            formatDefinition = pepperWizard.getPreferredFormatDefinition();
        }

        tableViewer.setSelection(formatDefinition != null ? new StructuredSelection(formatDefinition)
                : StructuredSelection.EMPTY);
    }

    super.setVisible(visible);
}