1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-09 03:23:07 +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:
Uwe Stieber 2015-05-08 07:51:37 +02:00
parent ebc9a45689
commit d78fd29834
14 changed files with 117 additions and 12 deletions

View file

@ -95,6 +95,7 @@ public abstract class AbstractAction extends AbstractTerminalAction {
*
* @param data The terminal custom data node or <code>null</code>.
*/
@SuppressWarnings("cast")
protected void executeCommand(Object data) {
// Get the command service from the workbench
ICommandService service = (ICommandService)PlatformUI.getWorkbench().getAdapter(ICommandService.class);
@ -112,7 +113,7 @@ public abstract class AbstractAction extends AbstractTerminalAction {
// Apply the selection to the "activeMenuSelection" and "selection" variable too
context.addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, selection);
context.addVariable(ISources.ACTIVE_MENU_SELECTION_NAME, selection);
// Allow plugin activation
// Allow plug-in activation
context.setAllowPluginActivation(true);
// And execute the event
try {

View file

@ -69,6 +69,7 @@ public class ToggleCommandFieldAction extends AbstractTerminalAction {
*
* @return The command input field handler or <code>null</code>.
*/
@SuppressWarnings("cast")
protected TabCommandFieldHandler getCommandFieldHandler() {
TabCommandFieldHandler handler = null;
// Get the active tab item from the tab folder manager

View file

@ -28,6 +28,7 @@ public class PropertyTester extends org.eclipse.core.expressions.PropertyTester
/* (non-Javadoc)
* @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
*/
@SuppressWarnings("cast")
@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
if ("hasApplicableLauncherDelegates".equals(property)) { //$NON-NLS-1$

View file

@ -37,6 +37,7 @@ public abstract class AbstractTriggerCommandHandler extends AbstractHandler {
* @param commandId The command id. Must not be <code>null</code>.
* @param selection The selection to pass on to the command or <code>null</code>.
*/
@SuppressWarnings("cast")
protected void triggerCommand(String commandId, ISelection selection) {
Assert.isNotNull(commandId);

View file

@ -28,6 +28,7 @@ public class DisconnectTerminalCommandHandler extends AbstractHandler {
/* (non-Javadoc)
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
@SuppressWarnings("cast")
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
CTabItem item = null;

View file

@ -284,6 +284,7 @@ public class LauncherDelegateManager {
* @param selection The selection or <code>null</code>.
* @return The list of applicable terminal launcher delegates or an empty array.
*/
@SuppressWarnings("cast")
public ILauncherDelegate[] getApplicableLauncherDelegates(ISelection selection) {
List<ILauncherDelegate> applicable = new ArrayList<ILauncherDelegate>();

View file

@ -65,6 +65,7 @@ public class WorkbenchPartListener implements IPartListener2 {
/* (non-Javadoc)
* @see org.eclipse.ui.IPartListener2#partActivated(org.eclipse.ui.IWorkbenchPartReference)
*/
@SuppressWarnings("cast")
@Override
public void partActivated(IWorkbenchPartReference partRef) {
if ("org.eclipse.tm.terminal.view.ui.TerminalsView".equals(partRef.getId())) { //$NON-NLS-1$
@ -86,6 +87,7 @@ public class WorkbenchPartListener implements IPartListener2 {
/* (non-Javadoc)
* @see org.eclipse.ui.IPartListener2#partDeactivated(org.eclipse.ui.IWorkbenchPartReference)
*/
@SuppressWarnings("cast")
@Override
public void partDeactivated(IWorkbenchPartReference partRef) {
if ("org.eclipse.tm.terminal.view.ui.TerminalsView".equals(partRef.getId())) { //$NON-NLS-1$

View file

@ -424,6 +424,7 @@ public class ConsoleManager {
* @param data The custom terminal data node or <code>null</code>.
* @param flags The flags controlling how the console is opened or <code>null</code> to use defaults.
*/
@SuppressWarnings("cast")
public CTabItem openConsole(String id, String secondaryId, String title, String encoding, ITerminalConnector connector, Object data, Map<String, Boolean> flags) {
Assert.isNotNull(title);
Assert.isNotNull(connector);
@ -496,6 +497,7 @@ public class ConsoleManager {
*
* @return The corresponding console tab item or <code>null</code>.
*/
@SuppressWarnings("cast")
public CTabItem findConsole(String id, String secondaryId, String title, ITerminalConnector connector, Object data) {
Assert.isNotNull(title);
Assert.isNotNull(connector);
@ -520,6 +522,7 @@ public class ConsoleManager {
* @param control The terminal control. Must not be <code>null</code>.
* @return The corresponding console tab item or <code>null</code>.
*/
@SuppressWarnings("cast")
public CTabItem findConsole(ITerminalControl control) {
Assert.isNotNull(control);
@ -562,6 +565,7 @@ public class ConsoleManager {
*
* @return The corresponding console tab item or <code>null</code>.
*/
@SuppressWarnings("cast")
private CTabItem findConsoleForTerminalConnector(String id, String title, ITerminalConnector connector, Object data) {
Assert.isNotNull(title);
Assert.isNotNull(connector);

View file

@ -55,6 +55,7 @@ public class TabCommandFieldHandler implements IDisposable, IAdaptable {
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Object getAdapter(Class adapter) {
if (TabFolderManager.class.equals(adapter)) {

View file

@ -200,7 +200,8 @@ public class TabFolderManager extends PlatformObject implements ISelectionProvid
*
* @return The tab folder or <code>null</code>.
*/
protected final CTabFolder getTabFolder() {
@SuppressWarnings("cast")
protected final CTabFolder getTabFolder() {
return (CTabFolder) getParentView().getAdapter(CTabFolder.class);
}
@ -237,7 +238,7 @@ public class TabFolderManager extends PlatformObject implements ISelectionProvid
*
* @return The created tab item or <code>null</code> if failed.
*/
@SuppressWarnings("unused")
@SuppressWarnings({ "unused", "cast" })
public CTabItem createTabItem(String title, String encoding, ITerminalConnector connector, Object data, Map<String, Boolean> flags) {
Assert.isNotNull(title);
Assert.isNotNull(connector);
@ -341,7 +342,7 @@ public class TabFolderManager extends PlatformObject implements ISelectionProvid
* @param oldItem The old dragged tab item. Must not be <code>null</code>.
* @return The new dropped tab item.
*/
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "cast" })
public CTabItem cloneTabItemAfterDrop(CTabItem oldItem) {
Assert.isNotNull(oldItem);

View file

@ -130,7 +130,8 @@ public class TabFolderMenuHandler extends PlatformObject {
*
* @return The tab folder or <code>null</code>.
*/
protected final CTabFolder getTabFolder() {
@SuppressWarnings("cast")
protected final CTabFolder getTabFolder() {
return (CTabFolder) getParentView().getAdapter(CTabFolder.class);
}
@ -201,7 +202,8 @@ public class TabFolderMenuHandler extends PlatformObject {
/**
* Create the context menu actions.
*/
protected void doCreateContextMenuActions() {
@SuppressWarnings("cast")
protected void doCreateContextMenuActions() {
// Create and add the copy action
add(new TerminalActionCopy() {
/* (non-Javadoc)
@ -215,7 +217,7 @@ public class TabFolderMenuHandler extends PlatformObject {
// Create and add the paste action
add(new TerminalActionPaste() {
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked" })
@Override
public void run() {
// Determine if pasting to the active tab require backslash translation
@ -309,7 +311,8 @@ public class TabFolderMenuHandler extends PlatformObject {
*
* @return The currently active terminal control or <code>null</code>.
*/
protected ITerminalViewControl getActiveTerminalViewControl() {
@SuppressWarnings("cast")
protected ITerminalViewControl getActiveTerminalViewControl() {
ITerminalViewControl terminal = null;
// Get the active tab item from the tab folder manager
@ -366,6 +369,7 @@ public class TabFolderMenuHandler extends PlatformObject {
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#getAdapter(java.lang.Class)
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Object getAdapter(Class adapter) {
if (MenuManager.class.isAssignableFrom(adapter)) {

View file

@ -101,7 +101,8 @@ public class TabFolderToolbarHandler extends PlatformObject {
*
* @return The tab folder or <code>null</code>.
*/
protected final CTabFolder getTabFolder() {
@SuppressWarnings("cast")
protected final CTabFolder getTabFolder() {
return (CTabFolder) getParentView().getAdapter(CTabFolder.class);
}
@ -110,7 +111,8 @@ public class TabFolderToolbarHandler extends PlatformObject {
*
* @return The currently active terminal control or <code>null</code>.
*/
public ITerminalViewControl getActiveTerminalViewControl() {
@SuppressWarnings("cast")
public ITerminalViewControl getActiveTerminalViewControl() {
ITerminalViewControl terminal = null;
// Get the active tab item from the tab folder manager
@ -347,6 +349,7 @@ public class TabFolderToolbarHandler extends PlatformObject {
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#getAdapter(java.lang.Class)
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Object getAdapter(Class adapter) {
if (IToolBarManager.class.isAssignableFrom(adapter)) {

View file

@ -0,0 +1,82 @@
/*******************************************************************************
* 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.core.runtime.Assert;
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;
/**
* Old terminals view handler implementation.
* <p>
* 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$
/* (non-Javadoc)
* @see org.eclipse.ui.IStartup#earlyStartup()
*/
@Override
public void earlyStartup() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = window != null ? window.getActivePage() : null;
if (page != null) handleOldTerminalsView(page);
// Register ourself as perspective listener
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;
}
// Show the new terminals view if necessary
if (showNewView) {
try {
page.showView(IUIConstants.ID);
}
catch (PartInitException e) { /* ignored on purpose */ }
}
}
}

View file

@ -607,7 +607,8 @@ public class TerminalsView extends ViewPart implements ITerminalsView, IShowInTa
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#getAdapter(java.lang.Class)
*/
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Object getAdapter(Class adapter) {
if (CTabFolder.class.isAssignableFrom(adapter)) {
return tabFolderControl;
@ -667,7 +668,8 @@ public class TerminalsView extends ViewPart implements ITerminalsView, IShowInTa
/* (non-Javadoc)
* @see org.eclipse.ui.part.IShowInTarget#show(org.eclipse.ui.part.ShowInContext)
*/
@Override
@SuppressWarnings("cast")
@Override
public boolean show(ShowInContext context) {
if (context != null) {
// Get the selection from the context