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:ac.soton.fmusim.components.presentation.ComponentsEditor.java

License:Open Source License

/**
 * Handles what to do with changed resources on activation.
 * <!-- begin-user-doc -->//from   ww w  .  ja v  a 2 s  .c o m
 * <!-- end-user-doc -->
 * @generated
 */
protected void handleChangedResources() {
    if (!changedResources.isEmpty() && (!isDirty() || handleDirtyConflict())) {
        if (isDirty()) {
            changedResources.addAll(editingDomain.getResourceSet().getResources());
        }
        editingDomain.getCommandStack().flush();

        updateProblemIndication = false;
        for (Resource resource : changedResources) {
            if (resource.isLoaded()) {
                resource.unload();
                try {
                    resource.load(Collections.EMPTY_MAP);
                } catch (IOException exception) {
                    if (!resourceToDiagnosticMap.containsKey(resource)) {
                        resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
                    }
                }
            }
        }

        if (AdapterFactoryEditingDomain.isStale(editorSelection)) {
            setSelection(StructuredSelection.EMPTY);
        }

        updateProblemIndication = true;
        updateProblemIndication();
    }
}

From source file:ac.soton.fmusim.components.presentation.ComponentsEditor.java

License:Open Source License

/**
 * This makes sure that one content viewer, either for the current page or the outline view, if it has focus,
 * is the current one.//from   w  w w . j a  v a 2s  . c o  m
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setCurrentViewer(Viewer viewer) {
    // If it is changing...
    //
    if (currentViewer != viewer) {
        if (selectionChangedListener == null) {
            // Create the listener on demand.
            //
            selectionChangedListener = new ISelectionChangedListener() {
                // This just notifies those things that are affected by the section.
                //
                public void selectionChanged(SelectionChangedEvent selectionChangedEvent) {
                    setSelection(selectionChangedEvent.getSelection());
                }
            };
        }

        // Stop listening to the old one.
        //
        if (currentViewer != null) {
            currentViewer.removeSelectionChangedListener(selectionChangedListener);
        }

        // Start listening to the new one.
        //
        if (viewer != null) {
            viewer.addSelectionChangedListener(selectionChangedListener);
        }

        // Remember it.
        //
        currentViewer = viewer;

        // Set the editors selection based on the current viewer's selection.
        //
        setSelection(currentViewer == null ? StructuredSelection.EMPTY : currentViewer.getSelection());
    }
}

From source file:ac.soton.multisim.diagram.navigator.MultisimNavigatorLinkHelper.java

License:Open Source License

/**
 * @generated//  w  w  w.j  av a  2 s  .  c  om
 */
public IStructuredSelection findSelection(IEditorInput anInput) {
    IDiagramDocument document = MultisimDiagramEditorPlugin.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) {
        MultisimNavigatorItem item = new MultisimNavigatorItem(diagram, file, false);
        return new StructuredSelection(item);
    }
    return StructuredSelection.EMPTY;
}

From source file:ac.soton.multisim.diagram.part.MultisimDiagramEditor.java

License:Open Source License

/**
 * @generated// w w  w .  j a  v  a 2  s  .com
 */
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) {
        MultisimNavigatorItem item = new MultisimNavigatorItem(diagram, file, false);
        return new StructuredSelection(item);
    }
    return StructuredSelection.EMPTY;
}

From source file:ac.soton.multisim.diagram.part.MultisimNewDiagramFileWizard.java

License:Open Source License

/**
 * @generated//w  w w . j a  v a2  s  . c  o m
 */
public MultisimNewDiagramFileWizard(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.MultisimNewDiagramFileWizard_CreationPageName,
            StructuredSelection.EMPTY);
    myFileCreationPage.setTitle(Messages.MultisimNewDiagramFileWizard_CreationPageTitle);
    myFileCreationPage.setDescription(NLS.bind(Messages.MultisimNewDiagramFileWizard_CreationPageDescription,
            ComponentDiagramEditPart.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(MultisimDiagramEditorUtil.getUniqueFileName(filePath, fileName, "msd")); //$NON-NLS-1$

    diagramRootElementSelectionPage = new DiagramRootElementSelectionPage(
            Messages.MultisimNewDiagramFileWizard_RootSelectionPageName);
    diagramRootElementSelectionPage.setTitle(Messages.MultisimNewDiagramFileWizard_RootSelectionPageTitle);
    diagramRootElementSelectionPage
            .setDescription(Messages.MultisimNewDiagramFileWizard_RootSelectionPageDescription);
    diagramRootElementSelectionPage.setModelElement(diagramRoot);

    myEditingDomain = editingDomain;
}

From source file:ac.soton.rms.components.diagram.part.ComponentsNewDiagramFileWizard.java

License:Open Source License

/**
 * @generated//from   ww w  .  j  a v a  2s . c  o m
 */
public ComponentsNewDiagramFileWizard(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.ComponentsNewDiagramFileWizard_CreationPageName,
            StructuredSelection.EMPTY);
    myFileCreationPage.setTitle(Messages.ComponentsNewDiagramFileWizard_CreationPageTitle);
    myFileCreationPage.setDescription(NLS.bind(Messages.ComponentsNewDiagramFileWizard_CreationPageDescription,
            ComponentDiagramEditPart.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(ComponentsDiagramEditorUtil.getUniqueFileName(filePath, fileName, "rmd")); //$NON-NLS-1$

    diagramRootElementSelectionPage = new DiagramRootElementSelectionPage(
            Messages.ComponentsNewDiagramFileWizard_RootSelectionPageName);
    diagramRootElementSelectionPage.setTitle(Messages.ComponentsNewDiagramFileWizard_RootSelectionPageTitle);
    diagramRootElementSelectionPage
            .setDescription(Messages.ComponentsNewDiagramFileWizard_RootSelectionPageDescription);
    diagramRootElementSelectionPage.setModelElement(diagramRoot);

    myEditingDomain = editingDomain;
}

From source file:ar.com.fluxit.jqa.wizard.page.UsageDefinitionWizardPage.java

License:Open Source License

@Override
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;/*from  w w  w  . j  a v  a2  s .  c  o m*/
    container.setLayout(layout);

    viewer = new GraphViewer(container, SWT.BORDER);
    viewer.setContentProvider(new LayersGraphContentProvider());
    viewer.setLabelProvider(new LayersGraphLabelProvider());
    viewer.setConnectionStyle(ZestStyles.CONNECTIONS_DIRECTED);
    LayoutAlgorithm graphLayout = new TreeLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING);
    graphLayout.setEntityAspectRatio(0.95);
    viewer.setLayoutAlgorithm(graphLayout, true);
    viewer.applyLayout();
    viewer.getGraphControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    viewer.addPostSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            StructuredSelection selection = (StructuredSelection) event.getSelection();
            if (!selection.isEmpty()) {
                @SuppressWarnings("unchecked")
                List<Object> selectedObjects = selection.toList();
                EntityConnectionData connection = findConnection(selectedObjects);
                if (connection == null) {
                    if (selectedObjects.size() > 1) {
                        LayerDescriptor sourceLayer = (LayerDescriptor) selectedObjects.get(0);
                        LayerDescriptor destinationLayer = (LayerDescriptor) selectedObjects.get(1);
                        sourceLayer.addUsage(destinationLayer);
                        viewer.refresh();
                        viewer.setSelection(StructuredSelection.EMPTY);
                    }
                } else {
                    ((LayerDescriptor) connection.source).removeUsage((LayerDescriptor) connection.dest);
                    viewer.refresh();
                    viewer.setSelection(StructuredSelection.EMPTY);
                }
            }
        }
    });

    final Menu menu = new Menu(viewer.getGraphControl());

    MenuItem layoutMenuItem = new MenuItem(menu, SWT.PUSH);
    layoutMenuItem.setText("Layout");
    layoutMenuItem.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            viewer.applyLayout();
        }
    });

    MenuItem resetMenuItem = new MenuItem(menu, SWT.PUSH);
    resetMenuItem.setText("Reset");
    resetMenuItem.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            boolean openConfirm = MessageDialog.openConfirm(menu.getShell(), "Confirm reset", "Are you sure?");
            if (openConfirm) {
                for (LayerDescriptor layer : getArchitectureDescriptor().getLayers()) {
                    layer.clearUsages();
                    viewer.refresh();
                }
            }
        }
    });

    viewer.getGraphControl().setMenu(menu);
    setControl(container);
    ((WizardDialog) getContainer()).addPageChangedListener(this);
}

From source file:at.bitandart.zoubek.mervin.model.modelreview.presentation.ModelReviewEditor.java

License:Open Source License

/**
 * This makes sure that one content viewer, either for the current page or
 * the outline view, if it has focus, is the current one. <!--
 * begin-user-doc --> <!-- end-user-doc -->
 * /*w w w  . j  av  a  2 s. c o  m*/
 * @generated
 */
public void setCurrentViewer(Viewer viewer) {
    // If it is changing...
    //
    if (currentViewer != viewer) {
        if (selectionChangedListener == null) {
            // Create the listener on demand.
            //
            selectionChangedListener = new ISelectionChangedListener() {
                // This just notifies those things that are affected by the
                // section.
                //
                public void selectionChanged(SelectionChangedEvent selectionChangedEvent) {
                    setSelection(selectionChangedEvent.getSelection());
                }
            };
        }

        // Stop listening to the old one.
        //
        if (currentViewer != null) {
            currentViewer.removeSelectionChangedListener(selectionChangedListener);
        }

        // Start listening to the new one.
        //
        if (viewer != null) {
            viewer.addSelectionChangedListener(selectionChangedListener);
        }

        // Remember it.
        //
        currentViewer = viewer;

        // Set the editors selection based on the current viewer's
        // selection.
        //
        setSelection(currentViewer == null ? StructuredSelection.EMPTY : currentViewer.getSelection());
    }
}

From source file:at.bitandart.zoubek.mervin.swt.comments.CommentListViewer.java

License:Open Source License

@Override
public ISelection getSelection() {
    // This viewer does not support selection (yet)
    return StructuredSelection.EMPTY;
}

From source file:at.bitandart.zoubek.mervin.swt.diff.tree.TreeDiffViewer.java

License:Open Source License

@Override
public ISelection getSelection() {
    return StructuredSelection.EMPTY;
}