org.eclipse.jface.viewers.OpenEvent Java Examples

The following examples show how to use org.eclipse.jface.viewers.OpenEvent. 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: BonitaCompareEditorInput.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Viewer createDiffViewer(final Composite parent) {
    viewer = new DiffTreeViewer(parent, getCompareConfiguration());
    viewer.addOpenListener(new IOpenListener() {

        @Override
        public void open(final OpenEvent event) {
            final IStructuredSelection sel = (IStructuredSelection) event.getSelection();
            final DiffNode obj = (DiffNode) sel.getFirstElement();
            obj.setDontExpand(false);
        }
    });
    viewer.setFilters(getFilters());
    viewer.setLabelProvider(new DiffTreeLabelProvider());
    viewer.setContentProvider(new BonitaScriptRefactoringContentProvider());
    viewer.setInput(root);
    viewer.expandAll();

    return viewer;
}
 
Example #2
Source File: FileSearchPage.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void handleOpen(OpenEvent event) {
    if (showLineMatches()) {
        Object firstElement = ((IStructuredSelection) event.getSelection()).getFirstElement();
        if (firstElement instanceof IFile) {
            if (getDisplayedMatchCount(firstElement) == 0) {
                try {
                    fEditorOpener.open(getSite().getPage(), (IFile) firstElement, false);
                } catch (PartInitException e) {
                    ErrorDialog.openError(getSite().getShell(),
                            SearchMessages.FileSearchPage_open_file_dialog_title,
                            SearchMessages.FileSearchPage_open_file_failed, e.getStatus());
                }
                return;
            }
        }
    }
    super.handleOpen(event);
}
 
Example #3
Source File: AbstractSearchIndexResultPage.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void handleOpen(OpenEvent event) {
    Object firstElement = ((IStructuredSelection) event.getSelection()).getFirstElement();
    if (getDisplayedMatchCount(firstElement) == 0) {
        try {
            if (firstElement instanceof IAdaptable) {
                IAdaptable iAdaptable = (IAdaptable) firstElement;
                IFile file = iAdaptable.getAdapter(IFile.class);
                if (file != null) {

                    open(getSite().getPage(), file, false);
                }
            }
        } catch (PartInitException e) {
            ErrorDialog.openError(getSite().getShell(),
                    "Open File",
                    "Opening the file failed.", e.getStatus());
        }
        return;
    }
    super.handleOpen(event);
}
 
Example #4
Source File: JavaSearchResultPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void handleOpen(OpenEvent event) {
	Object firstElement= ((IStructuredSelection)event.getSelection()).getFirstElement();
	if (firstElement instanceof ICompilationUnit ||
			firstElement instanceof IClassFile ||
			firstElement instanceof IMember) {
		if (getDisplayedMatchCount(firstElement) == 0) {
			try {
				fEditorOpener.openElement(firstElement);
			} catch (CoreException e) {
				ExceptionHandler.handle(e, getSite().getShell(), SearchMessages.JavaSearchResultPage_open_editor_error_title, SearchMessages.JavaSearchResultPage_open_editor_error_message);
			}
			return;
		}
	}
	super.handleOpen(event);
}
 
Example #5
Source File: TypeScriptSearchResultPage.java    From typescript.java with MIT License 6 votes vote down vote up
protected void handleOpen(OpenEvent event) {
	if (showLineMatches()) {
		Object firstElement= ((IStructuredSelection)event.getSelection()).getFirstElement();
		if (firstElement instanceof IFile) {
			if (getDisplayedMatchCount(firstElement) == 0) {
				try {
					open(getSite().getPage(), (IFile)firstElement, false);
				} catch (PartInitException e) {
					ErrorDialog.openError(getSite().getShell(), SearchMessages.FileSearchPage_open_file_dialog_title, SearchMessages.FileSearchPage_open_file_failed, e.getStatus());
				}
				return;
			}
		}
	}
	super.handleOpen(event);
}
 
Example #6
Source File: NavigationService.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public void open(OpenEvent openEvent, boolean select) {
	ISelection selection = openEvent.getSelection();
	if (selection instanceof IStructuredSelection) {
		Iterator<?> iterator = ((IStructuredSelection) selection).iterator();
		while (iterator.hasNext()) {
			Object element = iterator.next();
			if (element instanceof INavigatable) {
				open((INavigatable) element, select);
			}
		}
	}
}
 
Example #7
Source File: TreeViewerNavigator.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private void internalSetSelection(TreeItem ti) {
	if (ti != null) {
		Object data = ti.getData();
		if (data != null) {
			ISelection selection = new StructuredSelection(data);
			viewer.setSelection(selection, true);
			page.handleOpen(new OpenEvent(viewer, selection));
		}
	}
}
 
Example #8
Source File: ReferenceSearchViewPage.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected OpenAndLinkWithEditorHelper createOpenAndLinkWithEditorHandler() {
	return navigationService.installNavigationSupport(viewer, new Procedures.Procedure1<OpenEvent>() {

		@Override
		public void apply(OpenEvent openEvent) {
			handleOpen(openEvent);
		}

	});
}
 
Example #9
Source File: BreadcrumbViewer.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Notifies all open listeners.
 */
void fireOpen() {
  fireOpen(new OpenEvent(this, getSelection()));
}
 
Example #10
Source File: TreeConflictsView.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public void createPartControl(Composite parent) {
	GridLayout layout = new GridLayout();
	layout.marginWidth = 0;
	layout.marginHeight = 0;
	layout.numColumns = 1;
	parent.setLayout(layout);		

	treeViewer = new TreeViewer(parent, SWT.FULL_SELECTION);
	treeViewer.setLabelProvider(new ConflictsLabelProvider());
	treeViewer.setContentProvider(new ConflictsContentProvider());
	treeViewer.setUseHashlookup(true);
	GridData layoutData = new GridData();
	layoutData.grabExcessHorizontalSpace = true;
	layoutData.grabExcessVerticalSpace = true;
	layoutData.horizontalAlignment = GridData.FILL;
	layoutData.verticalAlignment = GridData.FILL;
	treeViewer.getControl().setLayoutData(layoutData);
	TableLayout tableLayout = new TableLayout();
	treeViewer.getTree().setLayout(tableLayout);

	DisposeListener disposeListener = new DisposeListener() {
		public void widgetDisposed(DisposeEvent e) {
			TreeColumn col = (TreeColumn)e.getSource();
			if (col.getWidth() > 0) settings.put("TreeConflictsView.col." + col.getText(), col.getWidth()); //$NON-NLS-1$
		}			
	};
	for (int i = 0; i < columnHeaders.length; i++) {
		TreeColumn tc = new TreeColumn(treeViewer.getTree(), SWT.NONE,i);
		tc.setResizable(columnLayouts[i].resizable);
		tc.setText(columnHeaders[i]);
		setColumnWidth(tableLayout, disposeListener, tc, i);
	}
	
	treeViewer.getTree().setHeaderVisible(true);
	treeViewer.getTree().setLinesVisible(false);
	
	treeViewer.setInput(this);

	treeViewer.addOpenListener(new IOpenListener() {
		public void open(OpenEvent evt) {
			openAction.run();
		}	
	});
	
	createMenus();
	createToolbar();
	
	String path = settings.get("TreeConflictsView.resource"); //$NON-NLS-1$
	if (path != null) {
		boolean container = settings.getBoolean("TreeConflictsView.container"); //$NON-NLS-1$
		if (container) resource = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(new Path(path));
		else resource = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path(path));
	}
	if (resource == null)
		setContentDescription(Policy.bind("TreeConflictsView.noResource")); //$NON-NLS-1$
	else
		setContentDescription(resource.getFullPath().toString());
}
 
Example #11
Source File: BibtexOpenListener.java    From slr-toolkit with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void open(OpenEvent event) {
	openEditor(event.getSelection(), false);
}
 
Example #12
Source File: ReferenceSearchViewPage.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected void handleOpen(OpenEvent openEvent) {
	navigationService.open(openEvent);
}
 
Example #13
Source File: BreadcrumbViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Notifies all open listeners.
 */
void fireOpen() {
	fireOpen(new OpenEvent(this, getSelection()));
}
 
Example #14
Source File: LibraryExplorerTreeViewPage.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Handles an open event from the viewer. Opens an editor on the selected
 * library.
 * 
 * @param event
 *            the open event
 * @throws IOException
 *             if an I/O error occurs.
 */
protected void handleOpen( OpenEvent event ) throws IOException
{
	IStructuredSelection selection = (IStructuredSelection) event.getSelection( );
	Object element = selection.getFirstElement( );

	if ( element instanceof ResourceEntryWrapper
			&& ( (ResourceEntryWrapper) element ).isFile( ) )
	{
		switch ( ( (ResourceEntryWrapper) element ).getType( ) )
		{
			case ResourceEntryWrapper.RPTDESIGN :
			case ResourceEntryWrapper.LIBRARY :
				File file = null;
				URL url = ( (ResourceEntryWrapper) element ).getURL( );

				if ( ( (ResourceEntryWrapper) element ).getEntry( ) instanceof FragmentResourceEntry )
				{
					file = ResourceAction.convertToFile( Platform.getBundle( IResourceLocator.FRAGMENT_RESOURCE_HOST )
							.getEntry( url.getPath( ) ) );
				}
				else
				{
					file = ResourceAction.convertToFile( url );
				}

				if ( file != null && file.exists( ) && file.isFile( ) )
				{
					if ( ( (ResourceEntryWrapper) element ).getType( ) == ResourceEntryWrapper.LIBRARY )
					{
						ResourceAction.openLibrary( this, file, false );
					}
					else if ( ( (ResourceEntryWrapper) element ).getType( ) == ResourceEntryWrapper.RPTDESIGN )
					{
						ResourceAction.openDesigner( this, file, false );
					}
				}
				else
				{
					if ( ( (ResourceEntryWrapper) element ).getType( ) == ResourceEntryWrapper.LIBRARY )
					{
						if ( MessageDialog.openConfirm( getSite( ).getShell( ),
								Messages.getString( "LibraryNotExist.Dialog.Title" ), //$NON-NLS-1$
								Messages.getString( "LibraryNotExist.Dialog.Message" ) ) ) //$NON-NLS-1$
						{
							refreshRoot( );
						}
					}
					else if ( ( (ResourceEntryWrapper) element ).getType( ) == ResourceEntryWrapper.RPTDESIGN )
					{
						if ( MessageDialog.openConfirm( getSite( ).getShell( ),
								Messages.getString( "DesignerNotExist.Dialog.Title" ), //$NON-NLS-1$
								Messages.getString( "DesignerNotExist.Dialog.Message" ) ) ) //$NON-NLS-1$
						{
							refreshRoot( );
						}
					}
				}
				break;

			case ResourceEntryWrapper.CSS_STYLE_SHEET :
			default :
				break;
		}
	}
}
 
Example #15
Source File: BreadcrumbViewer.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Notifies all open listeners.
 */
void fireOpen( )
{
	fireOpen( new OpenEvent( this, getSelection( ) ) );
}
 
Example #16
Source File: NavigationService.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public OpenAndLinkWithEditorHelper installNavigationSupport(StructuredViewer viewer, boolean select) {
	return installNavigationSupport(viewer, (OpenEvent openEvent) -> open(openEvent, select));
}
 
Example #17
Source File: NavigationService.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void open(OpenEvent openEvent) {
	open(openEvent, true);
}
 
Example #18
Source File: BreadcrumbViewer.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * The given element was selected from a drop down menu.
 * 
 * @param element the selected element
 */
void fireMenuSelection(Object element) {
  fireOpen(new OpenEvent(this, new StructuredSelection(element)));
}
 
Example #19
Source File: BreadcrumbViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * The given element was selected from a drop down menu.
 *
 * @param element the selected element
 */
void fireMenuSelection(Object element) {
	fireOpen(new OpenEvent(this, new StructuredSelection(element)));
}
 
Example #20
Source File: BreadcrumbViewer.java    From birt with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * The given element was selected from a drop down menu.
 * 
 * @param element
 *            the selected element
 */
void fireMenuSelection( Object element )
{
	fireOpen( new OpenEvent( this, new StructuredSelection( element ) ) );
}