Java 类org.eclipse.ui.IPerspectiveRegistry 实例源码
项目:OpenSPIFe
文件:EnsembleBasicNewProjectResourceWizard.java
/**
* Adds to the list all perspective IDs in the Workbench who's original ID
* matches the given ID.
*
* @param perspectiveIds
* the list of perspective IDs to supplement.
* @param id
* the id to query.
* @since 3.0
*/
@SuppressWarnings({ "unchecked" })
private static void addPerspectiveAndDescendants(List perspectiveIds,
String id) {
IPerspectiveRegistry registry = PlatformUI.getWorkbench()
.getPerspectiveRegistry();
IPerspectiveDescriptor[] perspectives = registry.getPerspectives();
for (int i = 0; i < perspectives.length; i++) {
// @issue illegal ref to workbench internal class;
// consider adding getOriginalId() as API on IPerspectiveDescriptor
PerspectiveDescriptor descriptor = ((PerspectiveDescriptor) perspectives[i]);
if (descriptor.getOriginalId().equals(id)) {
perspectiveIds.add(descriptor.getId());
}
}
}
项目:elexis-3-core
文件:PerspektiveImportHandler.java
@SuppressWarnings("restriction")
private IPerspectiveDescriptor savePerspectiveToRegistryLegacy(MPerspective perspective){
IPerspectiveRegistry perspectiveRegistry =
(PerspectiveRegistry) PlatformUI.getWorkbench().getPerspectiveRegistry();
IPerspectiveDescriptor pd =
perspectiveRegistry.findPerspectiveWithId(perspective.getElementId());
if (pd == null) {
((PerspectiveRegistry) perspectiveRegistry).addPerspective(perspective);
pd = perspectiveRegistry.findPerspectiveWithId(perspective.getElementId());
} else {
LoggerFactory.getLogger(PerspektiveImportHandler.class)
.error("perspective descriptor already exists for perspective id: "
+ perspective.getElementId());
}
return pd;
}
项目:elexis-3-core
文件:PerspectiveImportService.java
@Override
public int deletePerspective(String perspectiveId){
IPerspectiveRegistry iPerspectiveRegistry =
PlatformUI.getWorkbench().getPerspectiveRegistry();
MApplication mApplication = getService(MApplication.class);
IPerspectiveDescriptor existingPerspectiveDescriptor =
iPerspectiveRegistry.findPerspectiveWithId(perspectiveId);
int idx = -1;
if (existingPerspectiveDescriptor != null) {
idx = closePerspective(existingPerspectiveDescriptor);
//NOT WORKING IF PERSPECTIVE IS PREDEFINED - workaround with generics
iPerspectiveRegistry.deletePerspective(existingPerspectiveDescriptor);
PerspectiveImportService.genericInvokMethod(iPerspectiveRegistry, "removeSnippet",
MSnippetContainer.class, String.class, mApplication,
existingPerspectiveDescriptor.getId());
}
return idx;
}
项目:elexis-3-base
文件:PerspektivenContribution.java
@Override
public void fill(ToolBar parent, int index) {
IPerspectiveRegistry pr = PlatformUI.getWorkbench().
getPerspectiveRegistry();
String cfg = CoreHub.localCfg.get(Preferences.CFG_PERSPEKTIVEN, "");
String[] ids = cfg.split(",");
if (cfg == "") return;
for (String id: ids) {
IPerspectiveDescriptor pd = pr.findPerspectiveWithId(id);
if (pd == null) continue;
ToolItem ti = new ToolItem(parent, SWT.PUSH);
ImageDescriptor idesc = pd.getImageDescriptor();
Image im = (idesc != null ? idesc.createImage() : null);
if (im != null)
ti.setImage(im);
else
ti.setText(pd.getLabel());
ti.setToolTipText(pd.getLabel());
ti.addSelectionListener(new TISelListener(pd.getId()));
}
parent.update();
}
项目:Hydrograph
文件:PerspectiveRemover.java
/**
* Removes the unwanted perspectives from your RCP application
*/
public void removeUnWantedPerspectives() {
IPerspectiveRegistry perspectiveRegistry = PlatformUI.getWorkbench().getPerspectiveRegistry();
IPerspectiveDescriptor[] perspectiveDescriptors = getAllRegisteredPerspectiveDescriptors();
ArrayList<IPerspectiveDescriptor> ignorePerspectiveList = getIgnorePerspectiveList(perspectiveDescriptors);
removePerspetives(perspectiveRegistry, ignorePerspectiveList);
}
项目:Hydrograph
文件:PerspectiveRemover.java
private void removePerspetives(IPerspectiveRegistry perspectiveRegistry, List<IPerspectiveDescriptor> removePerspectiveDesc) {
// If the list is non-empty then remove all such perspectives from the IExtensionChangeHandler
if(perspectiveRegistry instanceof IExtensionChangeHandler && !removePerspectiveDesc.isEmpty()) {
IExtensionChangeHandler extChgHandler = (IExtensionChangeHandler) perspectiveRegistry;
extChgHandler.removeExtension(null, removePerspectiveDesc.toArray());
}
}
项目:typescript.java
文件:AbstractNewProjectWizard.java
/**
* Adds to the list all perspective IDs in the Workbench who's original ID
* matches the given ID.
*
* @param perspectiveIds
* the list of perspective IDs to supplement.
* @param id
* the id to query.
* @since 3.0
*/
private static void addPerspectiveAndDescendants(List perspectiveIds, String id) {
IPerspectiveRegistry registry = PlatformUI.getWorkbench().getPerspectiveRegistry();
IPerspectiveDescriptor[] perspectives = registry.getPerspectives();
for (int i = 0; i < perspectives.length; i++) {
// @issue illegal ref to workbench internal class;
// consider adding getOriginalId() as API on IPerspectiveDescriptor
PerspectiveDescriptor descriptor = ((PerspectiveDescriptor) perspectives[i]);
if (descriptor.getOriginalId().equals(id)) {
perspectiveIds.add(descriptor.getId());
}
}
}
项目:statecharts
文件:PerspectiveUtil.java
public static void switchToModelingPerspective(IWorkbenchWindow window) {
IPreferenceStore prefs = UIPluginActivator.getDefault()
.getPreferenceStore();
boolean hide = prefs.getBoolean(AUTO_SWITCH_PERSPECTIVE);
IWorkbenchPage page = window.getActivePage();
if (!hide) {
IWorkbench workbench = window.getWorkbench();
IPerspectiveRegistry registry = workbench.getPerspectiveRegistry();
IPerspectiveDescriptor descriptor = registry
.findPerspectiveWithId(IYakinduSctPerspectives.ID_PERSPECTIVE_SCT_MODELING);
if ((page != null) && (page.getPerspective() != descriptor)) {
MessageDialogWithToggle dialog = MessageDialogWithToggle
.openYesNoQuestion(
window.getShell(),
"Confirm Perspective Switch",
"This kind of editor is associated with the YAKINDU Modeling perspective. Do you want to switch to this perspective now?",
"Do not offer to switch perspective in the future",
hide, prefs, AUTO_SWITCH_PERSPECTIVE);
if (dialog.getReturnCode() == 2)
page.setPerspective(descriptor);
hide = dialog.getToggleState();
prefs.setValue(AUTO_SWITCH_PERSPECTIVE, hide);
try {
InstanceScope.INSTANCE.getNode(UIPluginActivator.PLUGIN_ID)
.flush();
} catch (BackingStoreException e) {
e.printStackTrace();
}
}
}
}
项目:scouter
文件:RCPUtil.java
public static void preLoadingPerspective(String[] ids){
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
if (page != null) {
IPerspectiveRegistry registry = PlatformUI.getWorkbench().getPerspectiveRegistry();
IPerspectiveDescriptor active = page.getPerspective();
for (int idx = ids.length - 1; idx >= 0; idx--) {
if (active == null || !active.getId().equals(ids[idx])) {
IPerspectiveDescriptor perspective = registry.findPerspectiveWithId(ids[idx]);
page.setPerspective(perspective);
}
}
page.setPerspective(active);
}
}
项目:scouter
文件:RCPUtil.java
public static void hidePerspectives(String[] ids) {
IPerspectiveRegistry registry = PlatformUI.getWorkbench().getPerspectiveRegistry();
IPerspectiveDescriptor[] descriptors = registry.getPerspectives();
List ignoredPerspectives = Arrays.asList(ids);
List removePerspectiveDesc = new ArrayList();
for (IPerspectiveDescriptor desc : descriptors) {
if (ignoredPerspectives.contains(desc.getId())) {
removePerspectiveDesc.add(desc);
}
}
if (registry instanceof IExtensionChangeHandler && !removePerspectiveDesc.isEmpty()) {
IExtensionChangeHandler extChgHandler = (IExtensionChangeHandler) registry;
extChgHandler.removeExtension(null, removePerspectiveDesc.toArray());
}
}
项目:scouter
文件:RCPUtil.java
public static void printPerspectives(){
System.out.println("=== Perspectives ===");
IPerspectiveRegistry registry = PlatformUI.getWorkbench().getPerspectiveRegistry();
IPerspectiveDescriptor[] descriptors = registry.getPerspectives();
for (int idx = 0; idx < descriptors.length; idx++) {
System.out.println(descriptors[idx].getId());
}
}
项目:jo-widgets
文件:PartSupport.java
public void showEmptyPerspective() {
final IPerspectiveRegistry perspectiveRegistry = PlatformUI.getWorkbench().getPerspectiveRegistry();
final IPerspectiveDescriptor perspectiveDescriptor = perspectiveRegistry.findPerspectiveWithId(DynamicPerspective.ID);
final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
activePage.setPerspective(perspectiveDescriptor);
perspectiveRegistry.setDefaultPerspective(DynamicPerspective.ID);
}
项目:jo-widgets
文件:PartSupport.java
public void showPerspective(
final ComponentNodeContext componentTreeNodeContext,
final ComponentContext componentContext,
final ILayout perspective) {
if (perspective == null) {
showEmptyPerspective();
return;
}
final String perspectiveId = getPerspectiveId(perspective, componentTreeNodeContext);
final IPerspectiveRegistry perspectiveRegistry = PlatformUI.getWorkbench().getPerspectiveRegistry();
IPerspectiveDescriptor newPerspective = perspectiveRegistry.findPerspectiveWithId(perspectiveId);
if (newPerspective == null) {
final IPerspectiveDescriptor perspectiveDescriptor = perspectiveRegistry.findPerspectiveWithId(DynamicPerspective.ID);
newPerspective = perspectiveRegistry.clonePerspective(
perspectiveId,
String.valueOf(perspective.getLabel()),
perspectiveDescriptor);
final IViewContainerContext context = registerViews(perspectiveId, perspective.getLayoutContainer(), componentContext);
viewContainerContextMap.put(perspectiveId, context);
}
final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
activePage.setPerspective(newPerspective);
// initialize views to update view titles from view model
initializeViews();
}
项目:elexis-3-core
文件:ApplicationWorkbenchAdvisor.java
@Override
public String getInitialWindowPerspectiveId(){
String initPerspective = cod.getInitialPerspective();
// avoid that nothing opens up after login in case the stored perspective can't be found
IPerspectiveRegistry perspectiveRegistry =
PlatformUI.getWorkbench().getPerspectiveRegistry();
if (perspectiveRegistry.findPerspectiveWithId(initPerspective) == null) {
initPerspective = UiResourceConstants.PatientPerspektive_ID;
}
return initPerspective;
}
项目:limpet
文件:ApplicationWorkbenchWindowAdvisor.java
public void postWindowRestore() throws WorkbenchException
{
IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
IWorkbenchWindow window = configurer.getWindow();
int index = getWorkbench().getWorkbenchWindowCount() - 1;
AboutInfo[] welcomePerspectiveInfos =
wbAdvisor.getWelcomePerspectiveInfos();
if (index >= 0 && welcomePerspectiveInfos != null
&& index < welcomePerspectiveInfos.length)
{
// find a page that exist in the window
IWorkbenchPage page = window.getActivePage();
if (page == null)
{
IWorkbenchPage[] pages = window.getPages();
if (pages != null && pages.length > 0)
{
page = pages[0];
}
}
// if the window does not contain a page, create one
String perspectiveId =
welcomePerspectiveInfos[index].getWelcomePerspectiveId();
if (page == null)
{
IAdaptable root = wbAdvisor.getDefaultPageInput();
page = window.openPage(perspectiveId, root);
}
else
{
IPerspectiveRegistry reg = getWorkbench().getPerspectiveRegistry();
IPerspectiveDescriptor desc = reg.findPerspectiveWithId(perspectiveId);
if (desc != null)
{
page.setPerspective(desc);
}
}
// set the active page and open the welcome editor
window.setActivePage(page);
page.openEditor(new WelcomeEditorInput(welcomePerspectiveInfos[index]),
WELCOME_EDITOR_ID, true);
}
cleanUpEditorArea();
}
项目:elexis-3-core
文件:PerspectiveImportService.java
@SuppressWarnings("restriction")
private IPerspectiveDescriptor importPerspectiveFromStream(InputStream in, IStateCallback iStateHandle,
boolean openPerspectiveIfAdded) throws IOException{
MPerspective mPerspective = loadPerspectiveFromStream(in);
if (mPerspective != null) {
IPerspectiveRegistry iPerspectiveRegistry =
PlatformUI.getWorkbench().getPerspectiveRegistry();
// the perspective id to import
String id = mPerspective.getElementId();
IPerspectiveDescriptor existingPerspectiveDescriptor =
iPerspectiveRegistry.findPerspectiveWithId(id);
// the active perspective id
String activePerspectiveId = getActivePerspectiveId();
// check if the import should be done
if (existingPerspectiveDescriptor == null || iStateHandle == null
|| iStateHandle.state(State.OVERRIDE)) {
IPerspectiveDescriptor activePd =
iPerspectiveRegistry.findPerspectiveWithId(activePerspectiveId);
// delete if a perspective with the id already exists
int idx = deletePerspective(id);
// add the new perspective to the registry
((PerspectiveRegistry) iPerspectiveRegistry).addPerspective(mPerspective);
IPerspectiveDescriptor createdPd = iPerspectiveRegistry.findPerspectiveWithId(id);
if (createdPd != null) {
((PerspectiveDescriptor) createdPd).setHasCustomDefinition(false); //no original descriptor should exists
}
// check if the new perspective should be opened
if (idx > -1 || openPerspectiveIfAdded) {
openPerspective(createdPd);
// there was already an opened active perspective switch back to it
openPerspective(activePd);
}
return createdPd;
}
}
return null;
}
项目:elexis-3-core
文件:PerspectiveImportService.java
public int isPerspectiveInStack(String perspectiveId){
IPerspectiveRegistry iPerspectiveRegistry =
PlatformUI.getWorkbench().getPerspectiveRegistry();
return isPerspectiveInsideStack(iPerspectiveRegistry.findPerspectiveWithId(perspectiveId));
}