eclipse plugin: Fix for bug #17875.
Set the initial input to the Workspace root and refresh the view once a new project has been created.
This commit is contained in:
parent
7e3c55997d
commit
4c8ac0431a
4 changed files with 46 additions and 9 deletions
|
@ -39,13 +39,14 @@ public class WesnothProjectsExplorer extends CommonNavigator implements IAdaptab
|
|||
}
|
||||
|
||||
@Override
|
||||
public void saveState(IMemento memento)
|
||||
protected Object getInitialInput()
|
||||
{
|
||||
return;
|
||||
return ResourcesPlugin.getWorkspace().getRoot();
|
||||
}
|
||||
|
||||
public IAdaptable createElement(IMemento memento)
|
||||
{
|
||||
return ResourcesPlugin.getWorkspace().getRoot();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.eclipse.ui.console.IConsoleConstants;
|
|||
|
||||
public class WMLPerspective implements IPerspectiveFactory
|
||||
{
|
||||
private static final String WESNOTH_PROJ_EXPLORER_ID = "wesnoth_eclipse_plugin.views.projects"; //$NON-NLS-1$
|
||||
public static final String WESNOTH_PROJ_EXPLORER_ID = "wesnoth_eclipse_plugin.views.projects"; //$NON-NLS-1$
|
||||
|
||||
@Override
|
||||
public void createInitialLayout(IPageLayout layout)
|
||||
|
|
|
@ -144,6 +144,9 @@ public class ProjectUtils
|
|||
TemplateProvider.getInstance().getProcessedTemplate("build_xml", param), true); //$NON-NLS-1$
|
||||
}
|
||||
monitor.worked(10);
|
||||
|
||||
WorkspaceUtils.getProjectsExplorer().getCommonViewer().refresh();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -38,6 +38,8 @@ import org.eclipse.jface.viewers.IStructuredSelection;
|
|||
import org.eclipse.jface.window.Window;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.ui.IViewPart;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.IWorkingSet;
|
||||
import org.eclipse.ui.IWorkingSetManager;
|
||||
|
@ -46,7 +48,9 @@ import org.wesnoth.Activator;
|
|||
import org.wesnoth.Constants;
|
||||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.Messages;
|
||||
import org.wesnoth.navigator.WesnothProjectsExplorer;
|
||||
import org.wesnoth.preferences.Preferences;
|
||||
import org.wesnoth.product.WMLPerspective;
|
||||
|
||||
|
||||
public class WorkspaceUtils
|
||||
|
@ -185,7 +189,6 @@ public class WorkspaceUtils
|
|||
return (IContainer) selection.getFirstElement();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the selected resource(file/folder/project) or null if none selected
|
||||
* @return
|
||||
|
@ -206,6 +209,15 @@ public class WorkspaceUtils
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current workbench
|
||||
* @return
|
||||
*/
|
||||
public static IWorkbench getWorkbench()
|
||||
{
|
||||
return Activator.getDefault().getWorkbench();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first WorkbenchWindow available. This is not always the same
|
||||
* with ActiveWorkbecnWindow
|
||||
|
@ -214,11 +226,13 @@ public class WorkspaceUtils
|
|||
*/
|
||||
public static IWorkbenchWindow getWorkbenchWindow()
|
||||
{
|
||||
if (Activator.getDefault().getWorkbench().getActiveWorkbenchWindow() != null)
|
||||
return Activator.getDefault().getWorkbench().getActiveWorkbenchWindow();
|
||||
if (Activator.getDefault().getWorkbench().getWorkbenchWindowCount() == 0)
|
||||
if (getWorkbench().getActiveWorkbenchWindow() != null)
|
||||
return getWorkbench().getActiveWorkbenchWindow();
|
||||
|
||||
if (getWorkbench().getWorkbenchWindowCount() == 0)
|
||||
return null;
|
||||
return Activator.getDefault().getWorkbench().getWorkbenchWindows()[0];
|
||||
|
||||
return getWorkbench().getWorkbenchWindows()[0];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -227,7 +241,26 @@ public class WorkspaceUtils
|
|||
*/
|
||||
public static IWorkingSetManager getWorkingSetManager()
|
||||
{
|
||||
return getWorkbenchWindow().getWorkbench().getWorkingSetManager();
|
||||
return getWorkbench().getWorkingSetManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the view with the specified id or null if none found
|
||||
* @param id The id of the searched View
|
||||
* @return
|
||||
*/
|
||||
public static IViewPart getView(String id)
|
||||
{
|
||||
return getWorkbenchWindow().getActivePage().findView(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Wesnoth Projects Explorer view
|
||||
* @return
|
||||
*/
|
||||
public static WesnothProjectsExplorer getProjectsExplorer()
|
||||
{
|
||||
return (WesnothProjectsExplorer)getView(WMLPerspective.WESNOTH_PROJ_EXPLORER_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue