当前位置: 首页>>代码示例>>Java>>正文


Java IWorkbenchAdapter类代码示例

本文整理汇总了Java中org.eclipse.ui.model.IWorkbenchAdapter的典型用法代码示例。如果您正苦于以下问题:Java IWorkbenchAdapter类的具体用法?Java IWorkbenchAdapter怎么用?Java IWorkbenchAdapter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IWorkbenchAdapter类属于org.eclipse.ui.model包,在下文中一共展示了IWorkbenchAdapter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSelectedClasspathEntries

import org.eclipse.ui.model.IWorkbenchAdapter; //导入依赖的package包/类
private Collection<IPackageFragmentRoot> getSelectedClasspathEntries(ISelection selection) {
  if (!(selection instanceof ITreeSelection)) {
    return Collections.emptyList();
  }
  ITreeSelection structuredSelection = (ITreeSelection) selection;
  Set<IPackageFragmentRoot> fragments = new LinkedHashSet<>(structuredSelection.size());
  for (Object o : structuredSelection.toList()) {
    if (o instanceof IPackageFragmentRoot) {
      IPackageFragmentRoot pfr = (IPackageFragmentRoot) o;
      if (ClasspathUtils.isBinaryFragment(pfr) && belongsToPluginContainer(structuredSelection, pfr)) {
        fragments.add(pfr);
      }
    } else if (isPluginContainer(o)) {
      IAdaptable adaptable = (IAdaptable) o;
      IWorkbenchAdapter wa = adaptable.getAdapter(IWorkbenchAdapter.class);
      if (wa != null) {
        Object[] children = wa.getChildren(o);
        if (children instanceof IAdaptable[]) {
          IAdaptable[] adaptables = (IAdaptable[]) children;
          fragments.addAll(filterPackageFragmentRoots(adaptables));
        }
      }
    }
  }
  return fragments;
}
 
开发者ID:fbricon,项目名称:pde.source.lookup,代码行数:27,代码来源:DownloadSourcesHandler.java

示例2: getAdapter

import org.eclipse.ui.model.IWorkbenchAdapter; //导入依赖的package包/类
@Override
public Object getAdapter(final Object adaptableObject, final Class adapterType) {
    if (adaptableObject instanceof ChangeItem) {
        final ChangeItem changeItem = (ChangeItem) adaptableObject;
        if (adapterType == IPropertySource.class) {
            if (changeItem.getType() == ChangeItemType.CHANGESET) {
                return new ChangePropertySource(changeItem.getChange());
            } else {
                return new PendingChangePropertySource(
                    changeItem.getPendingChange(),
                    changeItem.getPropertyValues());
            }
        }
        if (adapterType == IWorkbenchAdapter.class) {
            return ChangeItemWorkbenchAdapter.INSTANCE;
        }
    }

    return null;
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:21,代码来源:ChangeItemAdapterFactory.java

示例3: getAdapter

import org.eclipse.ui.model.IWorkbenchAdapter; //导入依赖的package包/类
/**
 * Method declared on IAdapterFactory.
    * Get the given adapter for the given object
 */
public Object getAdapter(Object adaptableObject, Class adapterType) {
	if (IWorkbenchAdapter.class == adapterType) {
		return getWorkbenchAdapter(adaptableObject);
	}

	if(IDeferredWorkbenchAdapter.class == adapterType) {
		 Object o = getWorkbenchAdapter(adaptableObject);
		 if(o != null && o instanceof IDeferredWorkbenchAdapter) {
		 	return o;
		 }
		 return null;
	}

	if (IPropertySource.class == adapterType) {
		return getPropertySource(adaptableObject);
	}
       
       if(IHistoryPageSource.class == adapterType) {
         return pageHistoryParticipant;
       }
       
	return null;
}
 
开发者ID:subclipse,项目名称:subclipse,代码行数:28,代码来源:SVNAdapterFactory.java

示例4: getChildren

import org.eclipse.ui.model.IWorkbenchAdapter; //导入依赖的package包/类
public Object[] getChildren(Object parentElement) {
	if (parentElement instanceof ISVNLocalResource) {
		Object[] rootChildren = new Object[3];
		rootChildren[0] = ((ISVNLocalResource)parentElement).getRepository();
		rootChildren[1] = branches;
		rootChildren[2] = tags;
		return rootChildren;
	}
	if (parentElement instanceof Branches) return ((Branches)parentElement).getBranches();
	if (parentElement instanceof Tags) return ((Tags)parentElement).getTags();
	IWorkbenchAdapter adapter = getAdapter(parentElement);
	if (adapter instanceof SVNModelElement) {
		Object[] children = ((SVNModelElement)adapter).getChildren(parentElement);
		ArrayList folderArray = new ArrayList();
		for (int i = 0; i < children.length; i++) {
			if (children[i] instanceof ISVNRemoteFolder) folderArray.add(children[i]);
		}
		children = new Object[folderArray.size()];
		folderArray.toArray(children);
		return children;
	}
	return super.getChildren(parentElement);
}
 
开发者ID:subclipse,项目名称:subclipse,代码行数:24,代码来源:SvnWizardConfigureTagsPage.java

示例5: getColumnText

import org.eclipse.ui.model.IWorkbenchAdapter; //导入依赖的package包/类
@Override
public String getColumnText(Object element, int columnIndex) {
  GraphNode node = getGraphNode(element);
  if (null != node) {
    switch (columnIndex) {
    case INDEX_NAME:
      return node.toString();
    case INDEX_RANK:
      return getRank(node);
    case INDEX_PREDS:
      return getPredecessorCount(node);
    case INDEX_SUCCS:
      return getSuccessorCount(node);
    }
  }
  IWorkbenchAdapter item = getWorkbenchAdapter(element);
  if (null != item) {
    switch (columnIndex) {
    case INDEX_NAME:
      return item.getLabel(element);
    }
  }
  return null;
}
 
开发者ID:google,项目名称:depan,代码行数:25,代码来源:NodeStatsTableControl.java

示例6: getColumnImage

import org.eclipse.ui.model.IWorkbenchAdapter; //导入依赖的package包/类
@Override
public Image getColumnImage(Object element, int columnIndex) {
  GraphNode node = getGraphNode(element);
  if (null != node) {
    switch (columnIndex) {
    case INDEX_ROOT:
      return PlatformResources.getOnOff(isRoot(node));
    }
  }

  IWorkbenchAdapter item = getWorkbenchAdapter(element);
  if (null != item) {
    switch (columnIndex) {
    case INDEX_NAME:
      return null; // TODO: versus - item.getImageDescriptor(element)...
    }
  }
  // Fall through and unknown type
  return null;
}
 
开发者ID:google,项目名称:depan,代码行数:21,代码来源:NodeStatsTableControl.java

示例7: getColumnText

import org.eclipse.ui.model.IWorkbenchAdapter; //导入依赖的package包/类
@Override
public String getColumnText(Object element, int columnIndex) {
  GraphNode node = getGraphNode(element);
  if (null != node) {
    switch (columnIndex) {
    case INDEX_NAME:
      return node.toString();
    case INDEX_XPOS:
      return getXPos(node);
    case INDEX_YPOS:
      return getYPos(node);
    case INDEX_COLOR:
      return getColorName(node);
    case INDEX_SIZE:
      return getSizeName(node);
    }
  }
  IWorkbenchAdapter item = getWorkbenchAdapter(element);
  if (null != item) {
    switch (columnIndex) {
    case INDEX_NAME:
      return item.getLabel(element);
    }
  }
  return null;
}
 
开发者ID:google,项目名称:depan,代码行数:27,代码来源:NodeDisplayTableControl.java

示例8: getColumnImage

import org.eclipse.ui.model.IWorkbenchAdapter; //导入依赖的package包/类
@Override
public Image getColumnImage(Object element, int columnIndex) {
  GraphNode node = getGraphNode(element);
  if (null != node) {
    switch (columnIndex) {
    case INDEX_SELECTED:
      return PlatformResources.getOnOff(isNodeSelected(node));
    case INDEX_VISIBLE:
      return PlatformResources.getOnOff(isVisible(node));
    }
  }

  IWorkbenchAdapter item = getWorkbenchAdapter(element);
  if (null != item) {
    switch (columnIndex) {
    case INDEX_NAME:
      return null; // TODO: versus - item.getImageDescriptor(element)...
    }
  }
  // Fall through and unknown type
  return null;
}
 
开发者ID:google,项目名称:depan,代码行数:23,代码来源:NodeDisplayTableControl.java

示例9: getImage

import org.eclipse.ui.model.IWorkbenchAdapter; //导入依赖的package包/类
@Override
public Image getImage(Object element) {
    if (element instanceof BuildJob) {
        Doxyfile doxyfile = ((BuildJob) element).getDoxyfile();
        IFile ifile = doxyfile.getIFile();
        if (ifile != null) {
            Image result = null;
            IResource resourse = (IResource) ifile;
            IWorkbenchAdapter workbenchAdapter = (IWorkbenchAdapter) resourse.getAdapter(IWorkbenchAdapter.class);
            if (workbenchAdapter != null) {
                result = workbenchAdapter.getImageDescriptor(ifile).createImage();
            }
            return result;
        } else {
            return Plugin.getImage(Images.USER.getId());
        }
    }
    return null;
}
 
开发者ID:anb0s,项目名称:eclox,代码行数:20,代码来源:BuildJobLabelProvider.java

示例10: updateImageDescriptor

import org.eclipse.ui.model.IWorkbenchAdapter; //导入依赖的package包/类
private static void updateImageDescriptor(IMarker marker, TimelineMarker timelineMarker)
throws CoreException
{
	final Object markerPluginId = marker.getAttribute(MarkerConstants.PLUGIN_ID);
	final Object imageDescriptorPath = marker.getAttribute(MarkerConstants.IMAGE_DESCRIPTOR_PATH);
	ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin
		(String.valueOf(markerPluginId), String.valueOf(imageDescriptorPath));

	if(imageDescriptor == null)
	{
		IWorkbenchAdapter adapter = (IWorkbenchAdapter) Platform.getAdapterManager().getAdapter(marker, IWorkbenchAdapter.class);
		if (adapter != null) {
			timelineMarker.setImageDescriptor(adapter.getImageDescriptor(marker));
		}
	} else {
		timelineMarker.setImageDescriptor(imageDescriptor);
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:19,代码来源:FileResourceMarkerService.java

示例11: getStyledTextLabel

import org.eclipse.ui.model.IWorkbenchAdapter; //导入依赖的package包/类
/**
 * Returns the styled label of the given object. The object must be of type {@link IJavaElement} or adapt to {@link IWorkbenchAdapter}.
 * If the element type is not known, the empty string is returned.
 * The returned label is BiDi-processed with {@link TextProcessor#process(String, String)}.
 *
 * @param obj object to get the label for
 * @param flags the rendering flags
 * @return the label or the empty string if the object type is not supported
 *
 * @since 3.4
 */
public static StyledString getStyledTextLabel(Object obj, long flags) {
	if (obj instanceof IJavaElement) {
		return getStyledElementLabel((IJavaElement) obj, flags);

	} else if (obj instanceof IResource) {
		return getStyledResourceLabel((IResource) obj);

	} else if (obj instanceof ClassPathContainer) {
		ClassPathContainer container= (ClassPathContainer) obj;
		return getStyledContainerEntryLabel(container.getClasspathEntry().getPath(), container.getJavaProject());

	} else if (obj instanceof IStorage) {
		return getStyledStorageLabel((IStorage) obj);

	} else if (obj instanceof IAdaptable) {
		IWorkbenchAdapter wbadapter= (IWorkbenchAdapter) ((IAdaptable)obj).getAdapter(IWorkbenchAdapter.class);
		if (wbadapter != null) {
			return Strings.markLTR(new StyledString(wbadapter.getLabel(obj)));
		}
	}
	return new StyledString();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:34,代码来源:JavaElementLabels.java

示例12: getNonJavaElementLabel

import org.eclipse.ui.model.IWorkbenchAdapter; //导入依赖的package包/类
private String getNonJavaElementLabel(Viewer viewer, Object element) {
	// try to use the workbench adapter for non - java resources or if not available, use the viewers label provider
	if (element instanceof IResource) {
		return ((IResource) element).getName();
	}
	if (element instanceof IStorage) {
		return ((IStorage) element).getName();
	}
	if (element instanceof IAdaptable) {
		IWorkbenchAdapter adapter= (IWorkbenchAdapter) ((IAdaptable) element).getAdapter(IWorkbenchAdapter.class);
		if (adapter != null) {
			return adapter.getLabel(element);
		}
	}
	if (viewer instanceof ContentViewer) {
		IBaseLabelProvider prov = ((ContentViewer) viewer).getLabelProvider();
		if (prov instanceof ILabelProvider) {
			return ((ILabelProvider) prov).getText(element);
		}
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:JavaElementComparator.java

示例13: open

import org.eclipse.ui.model.IWorkbenchAdapter; //导入依赖的package包/类
private void open(KeyReference keyReference) {
	if (keyReference == null)
		return;

	try {
		IEditorPart part= keyReference.element != null ? EditorUtility.openInEditor(keyReference.element, true) : EditorUtility.openInEditor(keyReference.resource, true);
		if (part != null)
			EditorUtility.revealInEditor(part, keyReference.offset, keyReference.length);
	} catch (PartInitException x) {

		String message= null;

		IWorkbenchAdapter wbAdapter= (IWorkbenchAdapter)((IAdaptable)keyReference).getAdapter(IWorkbenchAdapter.class);
		if (wbAdapter != null)
			message= Messages.format(PropertiesFileEditorMessages.OpenAction_error_messageArgs,
					new String[] { wbAdapter.getLabel(keyReference), x.getLocalizedMessage() } );

		if (message == null)
			message= Messages.format(PropertiesFileEditorMessages.OpenAction_error_message, x.getLocalizedMessage());

		MessageDialog.openError(fShell,
			PropertiesFileEditorMessages.OpenAction_error_messageProblems,
			message);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:PropertyKeyHyperlink.java

示例14: tryStructuredSelection

import org.eclipse.ui.model.IWorkbenchAdapter; //导入依赖的package包/类
private SearchPatternData tryStructuredSelection(IStructuredSelection selection) {
	if (selection == null || selection.size() > 1)
		return null;

	Object o= selection.getFirstElement();
	SearchPatternData res= null;
	if (o instanceof IJavaElement) {
		res= determineInitValuesFrom((IJavaElement) o);
	} else if (o instanceof LogicalPackage) {
		LogicalPackage lp= (LogicalPackage)o;
		return new SearchPatternData(PACKAGE, REFERENCES, 0, fIsCaseSensitive, lp.getElementName(), null, getLastIncludeMask());
	} else if (o instanceof IAdaptable) {
		IJavaElement element= (IJavaElement) ((IAdaptable) o).getAdapter(IJavaElement.class);
		if (element != null) {
			res= determineInitValuesFrom(element);
		}
	}
	if (res == null && o instanceof IAdaptable) {
		IWorkbenchAdapter adapter= (IWorkbenchAdapter)((IAdaptable)o).getAdapter(IWorkbenchAdapter.class);
		if (adapter != null) {
			return new SearchPatternData(TYPE, REFERENCES, 0, fIsCaseSensitive, adapter.getLabel(o), null, getLastIncludeMask());
		}
	}
	return res;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:JavaSearchPage.java

示例15: updateTitle

import org.eclipse.ui.model.IWorkbenchAdapter; //导入依赖的package包/类
/**
 * The superclass does not deal with the content description, handle it
 * here.
 * 
 * @noreference
 */
public void updateTitle() {
	super.updateTitle();
	Object input = getCommonViewer().getInput();

	if (input == null || input instanceof IAggregateWorkingSet) {
		setContentDescription(""); //$NON-NLS-1$
		return;
	}

	if (!(input instanceof IResource)) {
		if (input instanceof IAdaptable) {
			IWorkbenchAdapter wbadapter = (IWorkbenchAdapter) ((IAdaptable) input)
					.getAdapter(IWorkbenchAdapter.class);
			if (wbadapter != null) {
				setContentDescription(wbadapter.getLabel(input));
				return;
			}
		}
		setContentDescription(input.toString());
		return;
	}

	IResource res = (IResource) input;
	setContentDescription(res.getName());
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:32,代码来源:ProjectExplorer.java


注:本文中的org.eclipse.ui.model.IWorkbenchAdapter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。