本文整理匯總了Java中org.eclipse.ui.IViewPart類的典型用法代碼示例。如果您正苦於以下問題:Java IViewPart類的具體用法?Java IViewPart怎麽用?Java IViewPart使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IViewPart類屬於org.eclipse.ui包,在下文中一共展示了IViewPart類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setStatusLineMessage
import org.eclipse.ui.IViewPart; //導入依賴的package包/類
/**
* Tries to set the given message on the workbench's status line. This is a
* best effort method which fails to set the status line if there is no
* active editor present from where the statuslinemanager can be looked up.
*
* @param msg
* The message to be shown on the status line
*/
public static void setStatusLineMessage(final String msg) {
IStatusLineManager statusLineManager = null;
ISelectionProvider selectionService = null;
// First try to get the StatusLineManager from the IViewPart and only
// resort back to the editor if a view isn't active right now.
final IWorkbenchPart workbenchPart = getActiveWindow().getActivePage().getActivePart();
if (workbenchPart instanceof IViewPart) {
final IViewPart viewPart = (IViewPart) workbenchPart;
statusLineManager = viewPart.getViewSite().getActionBars().getStatusLineManager();
selectionService = viewPart.getViewSite().getSelectionProvider();
} else if (getActiveEditor() != null) {
final IEditorSite editorSite = getActiveEditor().getEditorSite();
statusLineManager = editorSite.getActionBars().getStatusLineManager();
selectionService = editorSite.getSelectionProvider();
}
if (statusLineManager != null && selectionService != null) {
statusLineManager.setMessage(msg);
selectionService.addSelectionChangedListener(new StatusLineMessageEraser(statusLineManager,
selectionService));
}
}
示例2: getExistingInstances
import org.eclipse.ui.IViewPart; //導入依賴的package包/類
/**
* Utility method to get all open views that are instances of CommonNavigator
* @param clazz the class type which extends EnsembleCommonNavigator
* @return the list of viewers that are of type EnsembleCommonNavigator
*/
public static List<EnsembleCommonNavigator> getExistingInstances(Class<? extends EnsembleCommonNavigator> clazz) {
List<EnsembleCommonNavigator> commonNavigators = new ArrayList<EnsembleCommonNavigator>();
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow[] workbenchWindows = workbench.getWorkbenchWindows();
for(IWorkbenchWindow workbenchWindow : workbenchWindows) {
IWorkbenchPage[] pages = workbenchWindow.getPages();
for(IWorkbenchPage page : pages) {
IViewReference[] viewReferences = page.getViewReferences();
for(IViewReference viewReference : viewReferences) {
IViewPart view = viewReference.getView(false);
if(view != null) {
boolean assignableFrom = clazz.isAssignableFrom(view.getClass());
if(assignableFrom) {
commonNavigators.add((EnsembleCommonNavigator)view);
}
}
}
}
}
return commonNavigators;
}
示例3: getCurrentSelection
import org.eclipse.ui.IViewPart; //導入依賴的package包/類
protected static IStructuredSelection getCurrentSelection() {
IStructuredSelection structuredSeleciton = StructuredSelection.EMPTY;
IWorkbench workbench = PlatformUI.getWorkbench();
IViewReference[] viewReferences = workbench.getActiveWorkbenchWindow().getActivePage().getViewReferences();
IViewPart viewPart = null;
for(IViewReference viewReference : viewReferences) {
IViewPart view = viewReference.getView(false);
if(view instanceof CommonViewer) {
viewPart = view;
}
}
if(viewPart != null) {
ISelectionProvider selectionProvider = viewPart.getSite().getSelectionProvider();
ISelection selection = selectionProvider.getSelection();
if(selection instanceof IStructuredSelection) {
structuredSeleciton = (IStructuredSelection)selection;
}
}
return structuredSeleciton;
}
示例4: testCreateConstraintsView
import org.eclipse.ui.IViewPart; //導入依賴的package包/類
public void testCreateConstraintsView() throws Exception {
if (PlatformUI.isWorkbenchRunning() == false) {
return; // TODO: obtain a workbench
}
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
IViewPart view = null;
// Make the view
view = workbenchPage.showView(
"gov.nasa.arc.spife.core.constraints.view.ConstraintsView",
null,
IWorkbenchPage.VIEW_CREATE);
assertNotNull(view);
}
示例5: run
import org.eclipse.ui.IViewPart; //導入依賴的package包/類
@Override
public void run ()
{
try
{
final IViewPart viewPart = getViewSite ().getWorkbenchWindow ().getActivePage ().showView ( ChartConfiguratorView.VIEW_ID );
if ( viewPart instanceof ChartConfiguratorView )
{
( (ChartConfiguratorView)viewPart ).setChartConfiguration ( getConfiguration () );
}
}
catch ( final PartInitException e )
{
StatusManager.getManager ().handle ( e.getStatus (), StatusManager.BLOCK );
}
}
示例6: execute
import org.eclipse.ui.IViewPart; //導入依賴的package包/類
@Override
public Object execute ( final ExecutionEvent event ) throws ExecutionException
{
try
{
// the following cast might look a bit weird. But first an adapter is requested and it only adapts to "core" connection services.
final ConnectionService connectionService = (ConnectionService)SelectionHelper.first ( getSelection (), org.eclipse.scada.core.connection.provider.ConnectionService.class );
final IViewPart view = getActivePage ().showView ( SummaryExplorerViewPart.VIEW_ID, "" + this.counter++, IWorkbenchPage.VIEW_ACTIVATE );
( (SummaryExplorerViewPart)view ).setConnectionService ( connectionService );
}
catch ( final PartInitException e )
{
throw new ExecutionException ( "Failed to open view", e );
}
return null;
}
示例7: getProjectExplorerView
import org.eclipse.ui.IViewPart; //導入依賴的package包/類
public ProjectExplorerView getProjectExplorerView() {
if (projectExplorerView == null) {
try {
IViewPart viewPart = PlatformUI
.getWorkbench()
.getActiveWorkbenchWindow()
.getActivePage()
.findView("com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView");
if (viewPart != null)
projectExplorerView = (ProjectExplorerView)viewPart;
}
catch (Exception e) {;}
}
return projectExplorerView;
}
示例8: getProjectExplorerView
import org.eclipse.ui.IViewPart; //導入依賴的package包/類
/**
* Gets the projects explorer view.
* !!MUST BE CALLED IN A UI-THREAD!!
* @return ProjectExplorerView : the explorer view of Convertigo Plugin
*/
public ProjectExplorerView getProjectExplorerView() {
ProjectExplorerView projectExplorerView = null;
IWorkbenchPage activePage = getActivePage();
if (activePage != null) {
IViewPart viewPart = activePage.findView("com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView");
if (viewPart != null)
projectExplorerView = (ProjectExplorerView)viewPart;
else {
IWorkbench workbench = PlatformUI.getWorkbench();
try {
IWorkbenchPage page = workbench.showPerspective(ConvertigoPlugin.PLUGIN_PERSPECTIVE_ID, workbench.getActiveWorkbenchWindow());
viewPart = page.findView("com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView");
if (viewPart != null) {
projectExplorerView = (ProjectExplorerView)viewPart;
}
} catch (WorkbenchException e) {}
}
}
return projectExplorerView;
}
示例9: getMobileDebugView
import org.eclipse.ui.IViewPart; //導入依賴的package包/類
/**
* Gets the source picker view.
* !!MUST BE CALLED IN A UI-THREAD!!
* @return SourcePickerView : the source picker view of Convertigo Plugin
* @throws
*/
public MobileDebugView getMobileDebugView() {
MobileDebugView mobileDebugView = null;
try {
IWorkbenchPage activePage = getActivePage();
if (activePage != null) {
IViewPart viewPart = activePage.findView("com.twinsoft.convertigo.eclipse.views.mobile.MobileDebugView");
if (viewPart != null)
mobileDebugView = (MobileDebugView) viewPart;
}
if (mobileDebugView == null) {
mobileDebugView = (MobileDebugView) getActivePage().showView("com.twinsoft.convertigo.eclipse.views.mobile.MobileDebugView");
}
} catch (PartInitException e) {
logException(e, "Failed to get the MobileDebugView");
}
return mobileDebugView;
}
示例10: showQueue
import org.eclipse.ui.IViewPart; //導入依賴的package包/類
private void showQueue() throws Exception {
IViewReference[] refs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences();
boolean foundStatus = false;
for (IViewReference vr : refs) {
if (StatusQueueView.ID.equals(vr.getId())) foundStatus = true;
}
if (!foundStatus) {
String secondId = XcenServices.getQueueViewSecondaryId();
IViewPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(StatusQueueView.ID+":"+secondId, null, IWorkbenchPage.VIEW_VISIBLE);
if (part !=null && part instanceof StatusQueueView) {
StatusQueueView view = (StatusQueueView)part;
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().bringToTop(view);
view.refresh();
}
}
}
示例11: showValidationResultsView
import org.eclipse.ui.IViewPart; //導入依賴的package包/類
private void showValidationResultsView(ValidateResults validateResults) {
PlatformUI.getWorkbench().getDisplay().asyncExec(() -> {
try {
if (PageUtil.getPage().findView(ValidateResultsView.ID) == null) {
IViewPart viewPart = PageUtil.getPage().showView(ValidateResultsView.ID);
if (viewPart instanceof ValidateResultsView) {
ValidateResultsView validateResultsView = (ValidateResultsView)viewPart;
validateResultsView.update(validateResults);
}
} else {
PageUtil.getPage().showView(ValidateResultsView.ID);
}
} catch (PartInitException e) {
logger.warn("Unable to show validate results view " + e);
}
});
}
示例12: getDeviceInformation
import org.eclipse.ui.IViewPart; //導入依賴的package包/類
private Collection<DeviceInformation<?>> getDeviceInformation() throws ScanningException {
IViewReference[] refs = PageUtil.getPage().getViewReferences();
for (IViewReference iViewReference : refs) {
IViewPart part = iViewReference.getView(false);
if (part==null) continue;
Object info = part.getAdapter(DeviceInformation.class);
if (info!=null && info instanceof Collection) { // A collection of device information
return (Collection<DeviceInformation<?>>)info;
}
}
// We cannot find a part which has the temp information so
// we use the server information.
return dservice.getDeviceInformation();
}
示例13: selectionChanged
import org.eclipse.ui.IViewPart; //導入依賴的package包/類
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection structureSelection = (IStructuredSelection) selection;
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewPart view = activePage.findView(IMAGEVIEW_BUNDLE_ID);
Bundle dataBundle = Platform.getBundle(XWING_DATA_BUNDLE_ID);
if (structureSelection.getFirstElement() instanceof PilotTreeNode) {
PilotTreeNode pilot = (PilotTreeNode) structureSelection.getFirstElement();
Pilot p = (Pilot) pilot.getValue();
if (view != null) {
loadPilotImage(view, dataBundle, p);
}
} else if (structureSelection instanceof TreeSelection) {
try {
UpgradeTypeTreeNode upgradeNode = (UpgradeTypeTreeNode) structureSelection.getFirstElement();
loadUpgradeImage(view, dataBundle, (Upgrade)upgradeNode.getValue());
} catch (ClassCastException ex) {
}
}
}
}
示例14: selectionChanged
import org.eclipse.ui.IViewPart; //導入依賴的package包/類
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
if (!(selection instanceof IStructuredSelection)) {
return;
}
IStructuredSelection structuredSeleciton = (IStructuredSelection) selection;
MapMetaData map = (MapMetaData) structuredSeleciton.getFirstElement();
IViewPart view = findImageViewer();
if (view == null) {
return;
}
loadAndSaveImage(map, view);
}
示例15: showDynamicHelp
import org.eclipse.ui.IViewPart; //導入依賴的package包/類
public static void showDynamicHelp() {
// This may take a while, so use the busy indicator
BusyIndicator.showWhile(null, new Runnable() {
public void run() {
getActiveWindow().getWorkbench().getHelpSystem().displayDynamicHelp();
// the following ensure that the help view receives focus
// prior to adding this, it would not receive focus if
// it was opened into a folder or was already
// open in a folder in which another part had focus
IViewPart helpView = findView("org.eclipse.help.ui.HelpView");
if (helpView != null && getActiveWindow() != null && getActiveWindow().getActivePage() != null) {
getActiveWindow().getActivePage().activate(helpView);
}
}
});
}