Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: IBM Corporation - initial API and implementation /
 
 package org.eclipse.team.internal.ccvs.ui.repo;
 
 import  org.eclipse.swt.SWT;
 import  org.eclipse.swt.events.KeyAdapter;
 import  org.eclipse.swt.events.KeyEvent;
 import  org.eclipse.swt.widgets.*;
This class acts as a superclass to all remote CVS tree views.
 
 public abstract class RemoteViewPart extends ViewPart implements ISelectionListener {
 	
 	// The tree viewer
 	protected TreeViewer viewer;
 
 	// Drill down adapter
 	
 	private Action refreshAction;
 	
 	
 
 	private static final String SELECTED_WORKING_SET = "SelectedWorkingSet"//$NON-NLS-1$
 
 	/* package */ class DecoratingRepoLabelProvider extends WorkbenchLabelProvider {
 		protected String decorateText(String inputObject element) {
 			//Used to process RTL locales only
 			return TextProcessor.process(input":@/"); //$NON-NLS-1$
 		}
 	}
 	
 	protected RemoteViewPart(String partName) {
 		IDialogSettings workbenchSettings = CVSUIPlugin.getPlugin().getDialogSettings();
 		 = workbenchSettings.getSection(partName);
 		if ( == null) {
 			 = workbenchSettings.addNewSection(partName);
 		}
 		IWorkingSet set = null;
 		if (name != null)
 			set = PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(name);
 		setWorkingSet(setfalse);
 	}

See also:
org.eclipse.ui.part.WorkbenchPart.createPartControl(org.eclipse.swt.widgets.Composite)
 
 	public void createPartControl(Composite parent) {
 		 = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
 		.setLabelProvider(new DecoratingRepoLabelProvider()/*WorkbenchLabelProvider()*/);
 		.getControl().addKeyListener(getKeyListener());
 		
 		
 
 		// F1 Help
 		String helpID = getHelpContextId();
 		if (helpID != null)
             PlatformUI.getWorkbench().getHelpSystem().setHelp(.getControl(), helpID);
 	}

See also:
WorkbenchPart.setFocus
	public void setFocus() {
		.getControl().setFocus();
	}

Method getHelpContextId should be overridden by subclasses to provide the appropriate help id.

Returns:
String
	protected String getHelpContextId() {
		return null;
	}

Method getTreeInput.

Returns:
Object
	protected abstract Object getTreeInput();

See also:
org.eclipse.team.internal.ccvs.ui.repo.RemoteViewPart.getContentProvider()
		if ( == null) {
		}
	};
	protected KeyAdapter getKeyListener() {
		return new KeyAdapter() {
			public void keyPressed(KeyEvent event) {
				if (event.keyCode == SWT.F5) {
				}
			}
		};
	}
	protected void initializeListeners() {
		// listen for selection changes in the repo view
	}
	protected IWorkingSet getWorkingSet() {
	}
	protected void setWorkingSet(IWorkingSet workingSetboolean refreshViewer) {
		if ( != null) {
			String name = null;
			if (workingSet != null)
				name = workingSet.getName();
		}
		String toolTip;
		if (workingSet == null) {
			toolTip = null;
else {
			toolTip = NLS.bind(.new String[] { workingSet.getName() }); 
		}
		if (refreshViewerrefreshViewer();
	}

Contribute actions to the view
	protected void contributeActions() {
		final Shell shell = getShell();
		// Refresh (toolbar)
		CVSUIPlugin plugin = CVSUIPlugin.getPlugin();
			public void run() {
			}
		};
			public void run() {
			}
		};
		// Working Set action group
		IPropertyChangeListener workingSetUpdater = new IPropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent event) {
                String property = event.getProperty();
                if (.
                        .equals(property)) {
                    Object newValue = event.getNewValue();
                    setWorkingSet((IWorkingSetnewValuetrue);
                }
            }
        };
		setActionGroup(new WorkingSetFilterActionGroup(shellworkingSetUpdater));
		// Create the popup menu
		MenuManager menuMgr = new MenuManager();
		Tree tree = .getTree();
		Menu menu = menuMgr.createContextMenu(tree);
			public void menuAboutToShow(IMenuManager manager) {
			}
		});
		menuMgr.setRemoveAllWhenShown(true);
		tree.setMenu(menu);
		// Create the local tool bar
		tbm.add(new Separator());
		tbm.update(false);
		// Register the open handler
			public void open(OpenEvent event) {
				handleOpen(event);
			}
		});
	}

    
Returns the action group.

Returns:
the action group
        return ;
    }

    
Sets the action group.

Parameters:
actionGroup the action group
    private void setActionGroup(WorkingSetFilterActionGroup actionGroup) {
        this. = actionGroup;
    }

Add the menu actions that were contributed in plugin.xml

Parameters:
manager
	protected void addWorkbenchActions(IMenuManager manager) {
		// File actions go first (view file)
		// Misc additions
		manager.add(new Separator("checkoutGroup")); //$NON-NLS-1$
		manager.add(new Separator("tagGroup")); //$NON-NLS-1$
		manager.add(new Separator("miscGroup")); //$NON-NLS-1$
	}

Method getShell.

Returns:
Shell
	protected Shell getShell() {
		return .getTree().getShell();
	}
	protected void refreshAll() {
		//CVSUIPlugin.getPlugin().getRepositoryManager().clearCaches();
	}
	protected void refreshViewer() {
		if ( == nullreturn;
        .getControl().setRedraw(false);
        .getControl().setRedraw(true);
	}
	public void collapseAll() {
		if ( == nullreturn;
		.getControl().setRedraw(false);
		.getControl().setRedraw(true);
	}
Handle open request.
	/* package */ void handleOpen(OpenEvent 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 ICVSRemoteFile) {
					// It's a file, open it.
					.selectionChanged(nullselection);
else {
					// Try to expand/contract
				}
			}
		}
	}

Returns the viewer.

Returns:
TreeViewer
	public TreeViewer getViewer() {
		return ;
	}

See also:
org.eclipse.ui.ISelectionListener.selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
	public void selectionChanged(IWorkbenchPart partISelection selection) {
	}

See also:
org.eclipse.ui.IWorkbenchPart.dispose()
	public void dispose() {
        if (getWorkingSetActionGroup() != null) {
            getWorkingSetActionGroup().dispose();
        }
		super.dispose();
		 = null;
	}
New to GrepCode? Check out our FAQ X