下面列出了org.eclipse.ui.PartInitException#printStackTrace ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* open the file document which is refered to in the bibtex entry. The path
* has to start from the root of the project where the bibtex entry is
* included.
*/
private void openPdf() {
IFile res = Utils.getIFilefromDocument(document);
if (res == null || res.getProject() == null) {
MessageDialog.openInformation(this.getSite().getShell(), "Bibtex" + document.getKey(), "Root or Resource not found");
return;
}
IFile file = res.getProject().getFile(document.getFile());
if (file.exists()) {
IFileStore fileStore = EFS.getLocalFileSystem().getStore(file.getLocation());
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
IDE.openEditorOnFileStore(page, fileStore);
} catch (PartInitException e) {
e.printStackTrace();
}
} else {
MessageDialog.openInformation(this.getSite().getShell(), "Bibtex" + document.getKey(), "Document not found");
}
}
@Override
public boolean performFinish() {
if (!page.isPageComplete()) {
return false;
}
IFile file = page.createNewFile();
boolean result = file != null;
if (result) {
try {
IDE.openEditor(workbench.getActiveWorkbenchWindow().getActivePage(), file);
} catch (PartInitException e) {
e.printStackTrace();
}
}
return result;
}
protected void schedulePerspectiveSwitchJob(final String perspectiveID) {
Job switchJob = new UIJob(DebugUIPlugin.getStandardDisplay(), "Perspective Switch Job") { //$NON-NLS-1$
public IStatus runInUIThread(IProgressMonitor monitor) {
IWorkbenchWindow window = DebugUIPlugin.getActiveWorkbenchWindow();
if (window != null && !(isCurrentPerspective(window, perspectiveID))) {
switchToPerspective(window, perspectiveID);
}
// Force the debug view to open
if (window != null) {
try {
window.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(SIMULATION_VIEW_ID);
} catch (PartInitException e) {
e.printStackTrace();
}
}
return Status.OK_STATUS;
}
};
switchJob.setSystem(true);
switchJob.setPriority(Job.INTERACTIVE);
switchJob.setRule(AsynchronousSchedulingRuleFactory.getDefault().newSerialPerObjectRule(this));
switchJob.schedule();
}
public MessageConsoleStream getMessageStream() {
MessageConsole myConsole = findConsole("Yang Console"); //calls function to find/create the Yang console
if (myConsole != null) {
IWorkbench wb = PlatformUI.getWorkbench();
IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
IWorkbenchPage page = win.getActivePage();
String id = IConsoleConstants.ID_CONSOLE_VIEW;
IConsoleView view;
try {
view = (IConsoleView) page.showView(id);
view.display(myConsole);
return myConsole.newMessageStream();
} catch (PartInitException e) {
e.printStackTrace();
}
}
return null;
}
@Override
public boolean performFinish() {
// here the chart is passed to the view.
// create the diagram
ICommunicationView view = null;
try {
view = (ICommunicationView) PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage()
.showView(chartViewId);
view.setAndRenderChart(myChart);
} catch (PartInitException e1) {
e1.printStackTrace();
}
try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getActivePage().showView(chartViewId);
} catch (PartInitException e) {
e.printStackTrace();
}
return true;
}
@Override
public void run(IAction action) {
IResource resource = (IResource)select.getFirstElement();
String url = resource.getLocation().toOSString();
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if(window == null) return;
IWorkbenchPage page = window.getActivePage();
if(page == null) return;
WebBrowserView part = (WebBrowserView)page.findView("com.aptana.browser.views.webbrowser");
if(part != null) {
page.bringToTop(part);
part.setURL(url);
return;
}
try {
WebBrowserView view = (WebBrowserView)page.showView("com.aptana.browser.views.webbrowser");
view.setURL(url);
} catch (PartInitException e) {
e.printStackTrace();
}
}
@Override
public void run(IAction action) {
IFile file = null;
IEditorInput input = targetEditor.getEditorInput();
if(input instanceof IFileEditorInput) {
file = ((IFileEditorInput) input).getFile();
}
String url = file.getLocation().toOSString();
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if(window == null) return;
IWorkbenchPage page = window.getActivePage();
if(page == null) return;
WebBrowserView part = (WebBrowserView)page.findView("com.aptana.browser.views.webbrowser");
if(part != null) {
page.bringToTop(part);
part.setURL(url);
return;
}
try {
WebBrowserView view = (WebBrowserView)page.showView("com.aptana.browser.views.webbrowser");
view.setURL(url);
} catch (PartInitException e) {
e.printStackTrace();
}
}
@Override
public void onTargetDoubleClicked(CodeRecommendationTarget target) {
IPath location = target.getFile().getLocation();
try {
IDE.openEditorOnFileStore(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(),
EFS.getLocalFileSystem().getStore(location));
} catch (PartInitException e) {
e.printStackTrace();
MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error",
"Unexpected error during opening file \n" + location + "\n" + e);
}
}
@Override
public void onNewViewPartView() {
try {
ExampleModel model = new ExampleModel();
IExampleView view = ExampleViewPartView.open(ExampleViewPartView.ID, "Part_" + (new Random().nextLong()));
ExampleController controller = new ExampleController(this, model, view);
controller.init();
} catch (PartInitException e) {
e.printStackTrace();
}
}
@Override
protected void addPages()
{
try
{
// This code moves the tabs to the top of the page.
// This makes them more obvious to the user.
if (getContainer() instanceof CTabFolder)
{
final CTabFolder cTabFolder = (CTabFolder) getContainer();
cTabFolder.setTabPosition(SWT.TOP);
// If there is only the editor but no PDF shown next to it, the tab bar of the
// ctabfolder just wastes screen estate.
if (cTabFolder.getItemCount() <= 1) {
cTabFolder.setTabHeight(0);
} else {
cTabFolder.setTabHeight(-1);
}
}
tlaEditor = new TLAEditor();
addPage(tlaEditorIndex, tlaEditor, tlaEditorInput);
setPageText(tlaEditorIndex, "TLA Module");
} catch (PartInitException e)
{
// I hope you don't choke swallowing all those exceptions...
e.printStackTrace();
}
}
public void openEditor() {
IWorkbenchPage workbenchPage = Activator.getDefault().getWorkbench()
.getActiveWorkbenchWindow().getActivePage();
try {
IDE.openEditor(workbenchPage, getInput(),
"com.apicloud.customapploader");
} catch (PartInitException e1) {
e1.printStackTrace();
}
}
@Override
protected void addPages() {
this.jsonEditor = new StructuredTextEditor();
jsonEditor.setEditorPart(this);
try {
// Add pages like overview, etc
doAddPages();
// Add source page
jsonEditorIndex = addPage(jsonEditor, getEditorInput());
setPageText(jsonEditorIndex, "Source");
} catch (PartInitException e) {
e.printStackTrace();
}
}
public static IEditorPart openSubmachineEditor(Diagram diagram, String context) {
try {
IFile file = WorkspaceSynchronizer.getFile(diagram.eResource());
IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
final IWorkbenchPage wbPage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
return wbPage.openEditor(new SubmachineEditorInput(diagram, context), desc.getId());
} catch (PartInitException e) {
e.printStackTrace();
}
return null;
}
public static void open(IWorkbenchPage page) {
try {
IDE.openEditor(page , input, "com.apicloud.navigator.APICloudWizard");
} catch (PartInitException e) {
e.printStackTrace();
}
}
/**
* @see IActionDelegate#run(IAction)
*/
public void run(IAction action) {
if (!isEnabled()) {
MessageDialog.openInformation(
new Shell(),
"Logfile Viewer",
"Wrong Selection");
return;
}
for (int i=0;i<resource.length;i++) {
if (resource[i] == null)
continue;
String full_path = resource[i].getClass().toString().replaceFirst("class ", "") + System.getProperty("file.separator") + resource[i].getName();
LogViewer view = null;
try {
view = (LogViewer) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("de.anbos.eclipse.logviewer.plugin.LogViewer");
} catch (PartInitException e) {
e.printStackTrace();
}
view.checkAndOpenFile(LogFileType.LOGFILE_ECLIPSE_CONSOLE, full_path, null, false);
}
}
public static void openPage(final String string) {
try {
final IGamaView.Html view =
(Html) WorkbenchHelper.getPage().openEditor(new NullEditorInput(), "msi.gama.application.browser");
view.setUrl(string);
} catch (final PartInitException e) {
e.printStackTrace();
}
}
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
SettingsDialog settingsDialog = new SettingsDialog(HandlerUtil.getActiveShell(event), SWT.DIALOG_TRIM);
try {
IViewPart part = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().showView("chart.view.chartview");
settingsDialog.setViewPart(part);
} catch (PartInitException e) {
e.printStackTrace();
}
settingsDialog.open();
return null;
}
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
// TODO: seems to be there is some refactoring needed in here
ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
if (selection == null || !(selection instanceof IStructuredSelection)) {
return null;
}
IStructuredSelection currentSelection = (IStructuredSelection) selection;
IViewPart part = null;
try {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
if (window != null) {
IWorkbenchPage page = window.getActivePage();
if (page != null) {
part = page.showView(chartViewId);
}
}
} catch (PartInitException e) {
e.printStackTrace();
return null;
}
if (part instanceof ICommunicationView) {
view = (ICommunicationView) part;
} else {
return null;
}
view.getPreview().setTextToShow(noDataToDisplay);
if (currentSelection.size() == 1) {
view.getPreview().setDataPresent(true);
ChartDataProvider provider = new ChartDataProvider();
Term input = (Term) currentSelection.getFirstElement();
Map<String, Integer> citeChartData = provider.calculateNumberOfPapersPerClass(input);
BarChartConfiguration.get().getGeneralSettings().setChartTitle("Number of cites per subclass of " + input.getName());
BarChartConfiguration.get().setTermSort(TermSort.SUBCLASS);
Chart citeChart = ChartGenerator.createCiteBar(citeChartData);
view.setAndRenderChart(citeChart);
} else {
view.setAndRenderChart(null);
}
return null;
}
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
// TODO: seems to be there is some refactoring needed in here
ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
if (selection == null || !(selection instanceof IStructuredSelection)) {
return null;
}
IStructuredSelection currentSelection = (IStructuredSelection) selection;
IViewPart part = null;
try {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
if (window != null) {
IWorkbenchPage page = window.getActivePage();
if (page != null) {
part = page.showView(chartViewId);
}
}
} catch (PartInitException e) {
e.printStackTrace();
return null;
}
if (part instanceof ICommunicationView) {
view = (ICommunicationView) part;
} else {
return null;
}
view.getPreview().setTextToShow(noDataToDisplay);
if (currentSelection.size() == 2) {
view.getPreview().setDataPresent(true);
ChartDataProvider provider = new ChartDataProvider();
@SuppressWarnings("unchecked")
Iterator<Term> selectionIterator = currentSelection.iterator();
Term first = selectionIterator.next();
Term second = selectionIterator.next();
List<BubbleDataContainer> bubbleChartData = provider.calculateBubbleChartData(first, second);
BubbleChartConfiguration.get().getGeneralSettings().setChartTitle("Intersection of " + first.getName() + " and " + second.getName());
Chart bubbleChart = ChartGenerator.createBubble(bubbleChartData,first,second);
view.setAndRenderChart(bubbleChart);
} else {
view.setAndRenderChart(null);
}
return null;
}
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
// TODO: seems to be there is some refactoring needed in here
ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
if (selection == null || !(selection instanceof IStructuredSelection)) {
return null;
}
IStructuredSelection currentSelection = (IStructuredSelection) selection;
IViewPart part = null;
try {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
if (window != null) {
IWorkbenchPage page = window.getActivePage();
if (page != null) {
part = page.showView(chartViewId);
}
}
} catch (PartInitException e) {
e.printStackTrace();
return null;
}
if (part instanceof ICommunicationView) {
view = (ICommunicationView) part;
} else {
return null;
}
view.getPreview().setTextToShow(noDataToDisplay);
if (currentSelection.size() == 1) {
view.getPreview().setDataPresent(true);
ChartDataProvider provider = new ChartDataProvider();
Term input = (Term) currentSelection.getFirstElement();
Map<String, Integer> citeChartData = provider.calculateNumberOfPapersPerClass(input);
PieChartConfiguration.get().getGeneralSettings().setChartTitle("Number of cites per subclass of " + input.getName());
PieChartConfiguration.get().setPieTermSort(TermSort.SUBCLASS);
Chart citeChart = ChartGenerator.createPie(citeChartData);
view.setAndRenderChart(citeChart);
} else {
view.setAndRenderChart(null);
}
return null;
}