Java Code Examples for org.eclipse.jface.viewers.DoubleClickEvent#getSelection()

The following examples show how to use org.eclipse.jface.viewers.DoubleClickEvent#getSelection() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CheckConfigurationConfigureDialog.java    From eclipse-cs with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * @see IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
 */
@Override
public void doubleClick(DoubleClickEvent event) {
  if (event.getViewer() == mTableViewer) {
    openModule(event.getSelection());
  } else if (event.getViewer() == mTreeViewer) {
    IStructuredSelection selection = (IStructuredSelection) event.getSelection();
    Object element = selection.getFirstElement();

    if (element instanceof RuleGroupMetadata) {
      mTreeViewer.setExpandedState(element, !mTreeViewer.getExpandedState(element));
    } else {
      newModule(event.getSelection());
    }
  }
}
 
Example 2
Source File: ToolboxExplorer.java    From tlaplus with MIT License 6 votes vote down vote up
/**
 * Open on double-click
 */
protected void handleDoubleClick(DoubleClickEvent anEvent)
{
    super.handleDoubleClick(anEvent);
    // open the model
    if (anEvent.getSelection() instanceof IStructuredSelection) {
    	IStructuredSelection iss = (IStructuredSelection) anEvent.getSelection();
    	Object firstElement = iss.getFirstElement();
    	if (firstElement instanceof Module) {
    		final Map<String, String> parameters = new HashMap<String, String>();
    		parameters.put(OpenModuleHandler.PARAM_MODULE, ((Module) firstElement).getModuleName());
UIHelper.runCommand(OpenModuleHandler.COMMAND_ID, parameters);
    	} else if (firstElement instanceof IGroup) {
    		// No-Op
    	} else if (firstElement instanceof Spec && ((Spec) firstElement).isCurrentSpec()) {
    		// No-op, do not re-open an open spec again.
    	} else {
    		UIHelper.runCommand(ToolboxExplorer.COMMAND_ID, new HashMap<String, String>());
    	}
    }
}
 
Example 3
Source File: TreeExpandingDoubleClickListener.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
public void doubleClick(DoubleClickEvent event) {
	IStructuredSelection selection = (IStructuredSelection) event
			.getSelection();
	Object firstElement = selection.getFirstElement();
	if (treeViewer.isExpandable(firstElement)) {
		boolean expanded = treeViewer.getExpandedState(firstElement);
		treeViewer.setExpandedState(firstElement, !expanded);
	} else {
		// FIXME :: does not trigger validation
		boolean newState = !treeViewer.getChecked(firstElement);
		treeViewer.setChecked(firstElement, newState);
		if (checkStateListener != null) {
			checkStateListener
					.checkStateChanged(new CheckStateChangedEvent(
							treeViewer, firstElement, newState));
		}
	}
}
 
Example 4
Source File: GamaNavigator.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void handleDoubleClick(final DoubleClickEvent anEvent) {
	final IStructuredSelection selection = (IStructuredSelection) anEvent.getSelection();
	final Object element = selection.getFirstElement();
	if (element instanceof VirtualContent && ((VirtualContent<?>) element).handleDoubleClick()) {
		if (element instanceof Tag) {
			Tag t = (Tag) element;
			findControl.searchFor(t.getName());
			return;
		}
	} else {
		super.handleDoubleClick(anEvent);
	}
	if (element instanceof WrappedContainer || element instanceof TopLevelFolder) {
		final CommonViewer tree = getCommonViewer();
		if (tree.getExpandedState(element)) {
			final Object[] contents = ((VirtualContent<?>) element).getNavigatorChildren();
			if (contents.length > 0) {
				tree.reveal(contents[contents.length - 1]);
			}
		}
	}
}
 
Example 5
Source File: RepositoriesView.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * The mouse has been double-clicked in the tree, perform appropriate
 * behaviour.
 */
private void handleDoubleClick(DoubleClickEvent e) {
    // Only act on single selection
    ISelection selection = e.getSelection();
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection structured = (IStructuredSelection)selection;
        if (structured.size() == 1) {
            Object first = structured.getFirstElement();
            if (first instanceof ISVNRemoteFile) {
                // It's a file, open it.
                openAction.selectionChanged(null, selection);
                openAction.run(null);
            } else {
                // Try to expand/contract
                treeViewer.setExpandedState(first, !treeViewer.getExpandedState(first));
            }
        }
    } 
}
 
Example 6
Source File: LibraryExplorerTreeViewPage.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Handles a double-click event from the viewer.
 * 
 * @param event
 *            the double-click event
 */
protected void handleDoubleClick( DoubleClickEvent event )
{
	IStructuredSelection selection = (IStructuredSelection) event.getSelection( );
	Object element = selection.getFirstElement( );
	TreeViewer viewer = getTreeViewer( );

	if ( element instanceof ResourceEntryWrapper )
	{
		switch ( ( (ResourceEntryWrapper) element ).getType( ) )
		{
			case ResourceEntryWrapper.LIBRARY :
				return;

			case ResourceEntryWrapper.CSS_STYLE_SHEET :
			default :
				break;
		}
	}

	if ( viewer.isExpandable( element ) )
	{
		viewer.setExpandedState( element,
				!viewer.getExpandedState( element ) );
	}
}
 
Example 7
Source File: ICEResourceView.java    From ice with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This method listens for a double click event on a resource. If the
 * selected resource is valid, then it will be displayed on the view's
 * associated {@link ICEResourceView#resourcePage}.
 */
@Override
public void doubleClick(DoubleClickEvent event) {

	// Get the associated resource
	ISelection selection = event.getSelection();
	ICEResource selectedResource = getResourceFromSelection(selection);

	// If it's valid, try to display it on the ResourcePage
	if (selectedResource != null) {
		try {
			resourcePage.getEditor().setActivePage(resourcePage.getId());
			resourcePage.showResource(selectedResource);
		} catch (PartInitException e) {
			logger.error(getClass().getName() + " Exception!", e);
		}
	}

	return;
}
 
Example 8
Source File: CodeSelectorFactory.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Returns the {@link IDoubleClickListener} used on the Viewer of this
 * {@link CodeSelectorFactory}. Default implementation passes the selected {@link Object}
 * directly to the code selector target (manage via {@link CodeSelectorHandler}). If a
 * {@link Leistungsblock} is selected it will pass its contained elements to the code selector
 * target. </br>
 * </br>
 * Should be overridden by subclasses for special behaviour.
 * 
 * @return
 */
public IDoubleClickListener getDoubleClickListener(){
	return new IDoubleClickListener() {
		
		@Override
		public void doubleClick(DoubleClickEvent event){
			ISelection selection = event.getSelection();
			if (selection instanceof IStructuredSelection) {
				IStructuredSelection structuredSelection = (IStructuredSelection) selection;
				if (!structuredSelection.isEmpty()) {
					ICodeSelectorTarget target =
						CodeSelectorHandler.getInstance().getCodeSelectorTarget();
					if (target != null) {
						Object obj = structuredSelection.getFirstElement();
						// TODO implement for block
						target.codeSelected(obj);
					}
				}
			}
		}
	};
}
 
Example 9
Source File: RealTimeGroupTab.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
protected void handleDoubleClick ( final DoubleClickEvent event )
{
    if ( event.getSelection () instanceof IStructuredSelection )
    {
        final Object o = ( (IStructuredSelection)event.getSelection () ).getFirstElement ();
        if ( o instanceof ListEntry )
        {
            final DataItemDetailsDialog dlg = new DataItemDetailsDialog ( this.shell, ( (ListEntry)o ).getItem () );
            dlg.open ();
        }
    }
}
 
Example 10
Source File: PackageExplorerActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
void handleDoubleClick(DoubleClickEvent event) {
	TreeViewer viewer= fPart.getTreeViewer();
	IStructuredSelection selection= (IStructuredSelection)event.getSelection();
	Object element= selection.getFirstElement();
	if (viewer.isExpandable(element)) {
		if (doubleClickGoesInto()) {
			// don't zoom into compilation units and class files
			if (element instanceof ICompilationUnit || element instanceof IClassFile)
				return;
			if (element instanceof IOpenable || element instanceof IContainer || element instanceof IWorkingSet) {
				fZoomInAction.run();
			}
		} else {
			IAction openAction= fNavigateActionGroup.getOpenAction();
			if (openAction != null && openAction.isEnabled() && OpenStrategy.getOpenMethod() == OpenStrategy.DOUBLE_CLICK)
				return;
			if (selection instanceof ITreeSelection) {
				TreePath[] paths= ((ITreeSelection)selection).getPathsFor(element);
				for (int i= 0; i < paths.length; i++) {
					viewer.setExpandedState(paths[i], !viewer.getExpandedState(paths[i]));
				}
			} else {
				viewer.setExpandedState(element, !viewer.getExpandedState(element));
			}
		}
	} else if (element instanceof IProject && !((IProject) element).isOpen()) {
		OpenProjectAction openProjectAction= fProjectActionGroup.getOpenProjectAction();
		if (openProjectAction.isEnabled()) {
			openProjectAction.run();
		}
	}
}
 
Example 11
Source File: WhiteSpaceTabPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void doubleClick(DoubleClickEvent event) {
    final ISelection selection= event.getSelection();
    if (selection instanceof IStructuredSelection) {
        final Node node= (Node)((IStructuredSelection)selection).getFirstElement();
        fTreeViewer.setExpandedState(node, !fTreeViewer.getExpandedState(node));
    }
}
 
Example 12
Source File: LineWrappingTabPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void doubleClick(DoubleClickEvent event) {
    final ISelection selection= event.getSelection();
    if (selection instanceof IStructuredSelection) {
        final Category node= (Category)((IStructuredSelection)selection).getFirstElement();
        fCategoriesViewer.setExpandedState(node, !fCategoriesViewer.getExpandedState(node));
    }
}
 
Example 13
Source File: ExpressionBuilder.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void doubleClick( DoubleClickEvent event )
{
	IStructuredSelection selection = (IStructuredSelection) event.getSelection( );
	if ( selection.isEmpty( ) )
	{
		return;
	}
	if ( event.getSource( ) == functionTable )
	{
		insertSelection( selection );
		return;
	}
}
 
Example 14
Source File: CommonViewer.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public void doubleClick(DoubleClickEvent event){
	if (dlListeners != null) {
		Iterator<PoDoubleClickListener> it = dlListeners.iterator();
		while (it.hasNext()) {
			PoDoubleClickListener dl = it.next();
			if (viewerConfigurer.poSelectionRenderer != null) {
				List<PersistentObject> selected =
					viewerConfigurer.poSelectionRenderer.getSelection();
				if (!selected.isEmpty()) {
					dl.doubleClicked(selected.get(0), this);
				}
			} else {
				IStructuredSelection sel = (IStructuredSelection) event.getSelection();
				if ((sel != null) && (!sel.isEmpty())) {
					Object element = sel.getFirstElement();
					if (element instanceof Tree<?>) {
						element = ((Tree<?>) element).contents;
					}
					if (element instanceof PersistentObject) {
						dl.doubleClicked((PersistentObject) element, this);
					}
				}
			}
		}
	}
	
}
 
Example 15
Source File: DiffTreeViewer.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private DiffNode getSelected(DoubleClickEvent event) {
	if (event.getSelection().isEmpty())
		return null;
	if (!(event.getSelection() instanceof IStructuredSelection))
		return null;
	IStructuredSelection selection = (IStructuredSelection) event
			.getSelection();
	if (selection.size() > 1)
		return null;
	DiffNode selected = (DiffNode) selection.getFirstElement();
	if (selected.isModelTypeNode())
		return null;
	return selected;
}
 
Example 16
Source File: JsonTreeViewer.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void onDoubleClick(DoubleClickEvent e) {
	IStructuredSelection sel = (IStructuredSelection) e.getSelection();
	JsonNode node = (JsonNode) sel.getFirstElement();
	if (!node.getElement().isJsonPrimitive())
		return;
	new TextDiffDialog(node, action).open();
}