mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-31 04:45:38 +02:00
View: Bug 466644 - A "Could not create the view:" error appears after
updating from TCF Terminals to TM Terrminal
This commit is contained in:
parent
b0c888065d
commit
0591b91356
3 changed files with 26 additions and 109 deletions
|
@ -24,7 +24,7 @@
|
|||
<!-- Contribute another view with the old ID to handle the ID change -->
|
||||
<view
|
||||
allowMultiple="true"
|
||||
class="org.eclipse.tm.terminal.view.ui.view.OldTerminalsViewHandler2"
|
||||
class="org.eclipse.tm.terminal.view.ui.view.OldTerminalsViewHandler"
|
||||
icon="icons/eview16/terminal_view.gif"
|
||||
id="org.eclipse.tcf.te.ui.terminals.TerminalsView"
|
||||
name="%TerminalsView.name.old">
|
||||
|
|
|
@ -9,16 +9,13 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.tm.terminal.view.ui.view;
|
||||
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.tm.terminal.view.ui.interfaces.IUIConstants;
|
||||
import org.eclipse.ui.IPerspectiveDescriptor;
|
||||
import org.eclipse.ui.IStartup;
|
||||
import org.eclipse.ui.IViewPart;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.PartInitException;
|
||||
import org.eclipse.ui.PerspectiveAdapter;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.part.ViewPart;
|
||||
|
||||
/**
|
||||
* Old terminals view handler implementation.
|
||||
|
@ -26,58 +23,40 @@ import org.eclipse.ui.PlatformUI;
|
|||
* If invoked, the view implementation opens the new terminals view and
|
||||
* closes itself afterwards.
|
||||
*/
|
||||
public class OldTerminalsViewHandler extends PerspectiveAdapter implements IStartup {
|
||||
private final static String OLD_VIEW_ID = "org.eclipse.tcf.te.ui.terminals.TerminalsView"; //$NON-NLS-1$
|
||||
public class OldTerminalsViewHandler extends ViewPart {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public OldTerminalsViewHandler() {
|
||||
super();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IStartup#earlyStartup()
|
||||
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
|
||||
*/
|
||||
@Override
|
||||
public void earlyStartup() {
|
||||
public void createPartControl(Composite parent) {
|
||||
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
|
||||
IWorkbenchPage page = window != null ? window.getActivePage() : null;
|
||||
|
||||
if (page != null) handleOldTerminalsView(page);
|
||||
|
||||
// Register ourself as perspective listener
|
||||
if (window != null) window.addPerspectiveListener(this);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.PerspectiveAdapter#perspectiveActivated(org.eclipse.ui.IWorkbenchPage, org.eclipse.ui.IPerspectiveDescriptor)
|
||||
*/
|
||||
@Override
|
||||
public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) {
|
||||
super.perspectiveActivated(page, perspective);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for the old terminals view ID and close any view with
|
||||
* that ID. If found in the perspective, it attempts to open the
|
||||
* new terminals view.
|
||||
*
|
||||
* @param page The active workbench page. Must not be <code>null</code>.
|
||||
*/
|
||||
protected void handleOldTerminalsView(IWorkbenchPage page) {
|
||||
Assert.isNotNull(page);
|
||||
|
||||
boolean showNewView = false;
|
||||
|
||||
// Search all view references in the current workbench page
|
||||
// matching the old terminals view ID
|
||||
IViewPart oldView = page.findView(OLD_VIEW_ID);
|
||||
while (oldView != null) {
|
||||
page.hideView(oldView);
|
||||
showNewView = true;
|
||||
oldView = page.findView(OLD_VIEW_ID);
|
||||
}
|
||||
|
||||
// Show the new terminals view if necessary
|
||||
if (showNewView) {
|
||||
if (page != null) {
|
||||
// Show the new view
|
||||
try {
|
||||
page.showView(IUIConstants.ID);
|
||||
}
|
||||
catch (PartInitException e) { /* ignored on purpose */ }
|
||||
|
||||
// Hide ourself in the current perspective
|
||||
page.hideView(this);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.part.WorkbenchPart#setFocus()
|
||||
*/
|
||||
@Override
|
||||
public void setFocus() {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 Wind River Systems, Inc. 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:
|
||||
* Wind River Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.tm.terminal.view.ui.view;
|
||||
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.tm.terminal.view.ui.interfaces.IUIConstants;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.PartInitException;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.part.ViewPart;
|
||||
|
||||
/**
|
||||
* Old terminals view handler implementation.
|
||||
* <p>
|
||||
* If invoked, the view implementation opens the new terminals view and
|
||||
* closes itself afterwards.
|
||||
*/
|
||||
public class OldTerminalsViewHandler2 extends ViewPart {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public OldTerminalsViewHandler2() {
|
||||
super();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
|
||||
*/
|
||||
@Override
|
||||
public void createPartControl(Composite parent) {
|
||||
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
|
||||
IWorkbenchPage page = window != null ? window.getActivePage() : null;
|
||||
|
||||
if (page != null) {
|
||||
// Show the new view
|
||||
try {
|
||||
page.showView(IUIConstants.ID);
|
||||
}
|
||||
catch (PartInitException e) { /* ignored on purpose */ }
|
||||
|
||||
// Hide ourself in the current perspective
|
||||
page.hideView(this);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.part.WorkbenchPart#setFocus()
|
||||
*/
|
||||
@Override
|
||||
public void setFocus() {
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue