@Override public void init(IEditorSite site, IEditorInput input) throws PartInitException { super.init(site, input); if (site == null) { return; } IWorkbenchPage page = site.getPage(); if (page == null) { return; } // workaround to show action set for block mode etc. // https://www.eclipse.org/forums/index.php/t/366630/ page.showActionSet("org.eclipse.ui.edit.text.actionSet.presentation"); }
@Override public void init ( final IEditorSite site, final IEditorInput input ) throws PartInitException { setSite ( site ); setInput ( input ); final IFileEditorInput fileInput = AdapterHelper.adapt ( input, IFileEditorInput.class ); if ( fileInput != null ) { this.loader = new FileLoader ( fileInput ); setContentDescription ( fileInput.getName () ); setPartName ( fileInput.getName () ); } if ( this.loader == null ) { throw new PartInitException ( "Invalid editor input. Unable to load data" ); } }
@Override public void init(IEditorSite site, IEditorInput input) throws PartInitException { setSite(site); setInput(input); applicationEditorInput = (ApplicationComponentEditorInput) input; ApplicationComponent application = applicationEditorInput.application; Project project = application.getProject(); datasetDir = new File(project.getDirPath() + "/dataset"); datasetDir.mkdirs(); devicePref = new File(Engine.USER_WORKSPACE_PATH, "studio/device-" + project.getName() + ".json"); setPartName(project.getName() + " [A: " + application.getName() + "]"); terminateNode(); }
public void init(IEditorSite site, IEditorInput input) throws PartInitException { super.init(site, input); setSite(site); setPartName(input.getName()); setInputWithNotify(input); site.setSelectionProvider(this); if (getEditorInput() instanceof FileEditorInput) { FileEditorInput fei = (FileEditorInput) getEditorInput(); IFile file = fei.getFile(); gWGraph = ResourceManager.load(file); Display.getDefault().asyncExec(new Runnable() { @Override public void run() { gWGraph.initialize(getGraphicalViewer().getEditPartRegistry()); if (!ResourceManager.isEditable(file)) { gWGraph.setReadOnly(true); getGraphicalViewer().getControl().setEnabled(false); String title = MessageUtil.getString("conversion"); String message = MessageUtil.getString("not_formatted_as_json_convert_it"); DialogManager.displayWarning(title, message); } } }); } }
@Override public void init(IEditorSite site, IEditorInput input) throws PartInitException { if (!(input instanceof ProjectEditorInput)) { throw new PartInitException(Messages.ProjectEditorDiffer_error_bad_input_type); } ProjectEditorInput in = (ProjectEditorInput) input; Exception ex = in.getError(); if (ex != null) { throw new PartInitException(in.getError().getLocalizedMessage(), ex); } setInput(input); setSite(site); setPartName(in.getName()); proj = new PgDbProject(in.getProject()); sp = new ProjectEditorSelectionProvider(proj.getProject()); // message box if(!site.getPage().getPerspective().getId().equals(PERSPECTIVE.MAIN)){ askPerspectiveChange(site); } getSite().setSelectionProvider(sp); }
@Override public void init(final IEditorSite site, final IEditorInput input) throws PartInitException { if (!(input instanceof WorkItemEditorInput)) { throw new PartInitException("Invalid Input: Must be WITQueryResultsEditorInput"); //$NON-NLS-1$ } setSite(site); setInput(input); final WorkItemEditorInput editorInput = (WorkItemEditorInput) getEditorInput(); final WorkItem workItem = editorInput.getWorkItem(); stateListener = new StateListener(); workItem.addWorkItemStateListener(stateListener); fieldTracker = new FieldTracker(); }
/** * @see org.eclipse.ui.part.MultiPageEditorPart#init(org.eclipse.ui.IEditorSite, * org.eclipse.ui.IEditorInput) */ @Override public void init(final IEditorSite site, final IEditorInput input) throws PartInitException { if (!(input instanceof BuildExplorerEditorInput)) { throw new PartInitException("Invalid Input: Must be BuildExplorerEditorInput"); //$NON-NLS-1$ } buildDefinition = ((BuildExplorerEditorInput) input).getBuildDefinition(); buildServer = buildDefinition.getBuildServer(); pollInterval = 30000; refreshAction.setActiveEditor(this); super.init(site, input); }
/** * Returns an OSGi service from {@link ExecutionEvent}. It looks up a service in the following * locations (if exist) in the given order: * * {@code HandlerUtil.getActiveSite(event)} * {@code HandlerUtil.getActiveEditor(event).getEditorSite()} * {@code HandlerUtil.getActiveEditor(event).getSite()} * {@code HandlerUtil.getActiveWorkbenchWindow(event)} * {@code PlatformUI.getWorkbench()} */ public static <T> T getService(ExecutionEvent event, Class<T> api) { IWorkbenchSite activeSite = HandlerUtil.getActiveSite(event); if (activeSite != null) { return activeSite.getService(api); } IEditorPart activeEditor = HandlerUtil.getActiveEditor(event); if (activeEditor != null) { IEditorSite editorSite = activeEditor.getEditorSite(); if (editorSite != null) { return editorSite.getService(api); } IWorkbenchPartSite site = activeEditor.getSite(); if (site != null) { return site.getService(api); } } IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event); if (workbenchWindow != null) { return workbenchWindow.getService(api); } return PlatformUI.getWorkbench().getService(api); }
@Override public void init(IEditorSite site, IEditorInput input) throws PartInitException { isDirty = false; try { if (input instanceof FileEditorInput) { File file = FileUtils.getFile(((FileEditorInput) input).getFile()); if (FileUtils.getExtension(file).equals(NETWORK_PARTITIONING)) { partitioning = new XmlNetworkPartitioningReader().load(file); setPartName(file.getName()); } else { throw new Exception("Invalid input"); } } } catch (Exception e) { throw new PartInitException("Input file is corrupted or not valid"); } setSite(site); setInput(input); }
@Override public void init(IEditorSite site, IEditorInput input) throws PartInitException { isDirty = false; try { if (input instanceof FileEditorInput) { File file = FileUtils.getFile(((FileEditorInput) input).getFile()); if (FileUtils.getExtension(file).equals(NETWORK_WEIGHT)) { weights = new XmlNetworkWeightReader().load(file); setPartName(file.getName()); } else { throw new Exception("Invalid input"); } } } catch (Exception e) { throw new PartInitException("Input file is corrupted or not valid"); } setSite(site); setInput(input); }
@Override public void init(IEditorSite site, IEditorInput input) throws PartInitException { isDirty = false; try { if (input instanceof FileEditorInput) { File file = FileUtils.getFile(((FileEditorInput) input).getFile()); if (FileUtils.getExtension(file).equals(BUFFER_SIZE)) { bufferSize = new XmlBufferSizeReader().load(file); setPartName(file.getName()); } else { throw new Exception("Invalid input"); } } } catch (Exception e) { throw new PartInitException("Input file is corrupted or not valid"); } setSite(site); setInput(input); }
@Override public void init(IEditorSite site, IEditorInput editorInput) throws PartInitException { setSite(site); setInput(editorInput); setPartName(editorInput.getName()); try { IFile file = ((FileEditorInput) editorInput).getFile(); htmlText = toHtml(file); htmlText = HtmlUtils.appendStyle(htmlText, css.toArray(new String[0])); htmlText = HtmlUtils.appendJs(htmlText, js.toArray(new String[0])); } catch (Exception e) { htmlText = "<p>Error processing the file</p>"; file = null; } }
@Override public void init(IEditorSite site, IEditorInput input) throws PartInitException { isDirty = false; try { if (input instanceof FileEditorInput) { File file = FileUtils.getFile(((FileEditorInput) input).getFile()); if (FileUtils.getExtension(file).equals(CONFIGURATION)) { configuration = Configuration.load(file); setPartName(file.getName()); } else { throw new Exception("Invalid input"); } } } catch (Exception e) { throw new PartInitException("Input file is corrupted or not valid"); } setSite(site); setInput(input); }
/** * Tries to set the given message on the workbench's status line. This is a * best effort method which fails to set the status line if there is no * active editor present from where the statuslinemanager can be looked up. * * @param msg * The message to be shown on the status line */ public static void setStatusLineMessage(final String msg) { IStatusLineManager statusLineManager = null; ISelectionProvider selectionService = null; // First try to get the StatusLineManager from the IViewPart and only // resort back to the editor if a view isn't active right now. final IWorkbenchPart workbenchPart = getActiveWindow().getActivePage().getActivePart(); if (workbenchPart instanceof IViewPart) { final IViewPart viewPart = (IViewPart) workbenchPart; statusLineManager = viewPart.getViewSite().getActionBars().getStatusLineManager(); selectionService = viewPart.getViewSite().getSelectionProvider(); } else if (getActiveEditor() != null) { final IEditorSite editorSite = getActiveEditor().getEditorSite(); statusLineManager = editorSite.getActionBars().getStatusLineManager(); selectionService = editorSite.getSelectionProvider(); } if (statusLineManager != null && selectionService != null) { statusLineManager.setMessage(msg); selectionService.addSelectionChangedListener(new StatusLineMessageEraser(statusLineManager, selectionService)); } }
public void init(IEditorSite site, IEditorInput input) throws PartInitException { tlaEditorInput = input; if (input instanceof FileEditorInput) { FileEditorInput finput = (FileEditorInput) input; if (finput != null) { if (ResourceHelper.isModule(finput.getFile())) { this.setPartName(finput.getFile().getName()); } if (ResourceHelper.isRoot(finput.getFile())) { setTitleImage(rootImage); } } } super.init(site, input); }
@Override public void init(IEditorSite site, IEditorInput input) { super.init(site, input); // String serviceName = null; if (server != null) { cfServer = (CloudFoundryServer) server.loadAdapter(CloudFoundryServer.class, null); update(); // serviceName = // CloudFoundryBrandingExtensionPoint.getServiceName(server.getServerType().getId()); } // if (serviceName == null) { sectionTitle = Messages.COMMONTXT_ACCOUNT_INFO; // } // else { // sectionTitle = serviceName + " Account"; // } }
protected SourceViewerConfiguration createSourceViewerConfiguration(SourceViewer sourceViewer, IEditorInput editorInput) { SourceViewerConfiguration sourceViewerConfiguration = null; if (editorInput != null && getEditor(sourceViewer) != null) { DefaultMergeEditor mergeEditor = getEditor(sourceViewer); sourceViewerConfiguration = mergeEditor.getXtextSourceViewerConfiguration(); try { mergeEditor.init((IEditorSite) mergeEditor.getSite(), editorInput); mergeEditor.createActions(); } catch (PartInitException partInitException) { throw new WrappedException(partInitException); } } else { sourceViewerConfiguration = sourceViewerConfigurationProvider.get(); } return sourceViewerConfiguration; }
/** * Constructor. * @param site editor site * @param file file opened */ public DefaultBundleGroupStrategy(IEditorSite site, IFile file) { super(); this.file = file; this.site = site; String patternCore = "((_[a-z]{2,3})|(_[a-z]{2,3}_[A-Z]{2})" //$NON-NLS-1$ + "|(_[a-z]{2,3}_[A-Z]{2}_\\w*))?(\\." //$NON-NLS-1$ + file.getFileExtension() + ")$"; //$NON-NLS-1$ // Compute and cache name String namePattern = "^(.*?)" + patternCore; //$NON-NLS-1$ this.baseName = file.getName().replaceFirst( namePattern, "$1"); //$NON-NLS-1$ // File matching pattern this.fileMatchPattern = "^(" + baseName + ")" + patternCore; //$NON-NLS-1$//$NON-NLS-2$ }
@Override public void init(IEditorSite site, IEditorInput input) { super.init(site, input); // String serviceName = null; if (server != null) { cfServer = (DockerFoundryServer) server.loadAdapter(DockerFoundryServer.class, null); update(); // serviceName = // CloudFoundryBrandingExtensionPoint.getServiceName(server.getServerType().getId()); } // if (serviceName == null) { sectionTitle = Messages.COMMONTXT_ACCOUNT_INFO; // } // else { // sectionTitle = serviceName + " Account"; // } }
private void closeIfAreadyOpen(IEditorSite site, IFile file) { IWorkbenchPage[] pages = site.getWorkbenchWindow().getPages(); for (int i = 0; i < pages.length; i++) { IWorkbenchPage page = pages[i]; IEditorReference[] editors = page.getEditorReferences(); for (int j = 0; j < editors.length; j++) { IEditorPart editor = editors[j].getEditor(false); if (editor instanceof MessagesEditor) { MessagesEditor rbe = (MessagesEditor) editor; if (rbe.isBundleMember(file)) { page.closeEditor(editor, true); } } } } }
public void init(IEditorSite site, IEditorInput editorInput) throws PartInitException { if (!(editorInput instanceof IFileEditorInput) && !(editorInput instanceof DiagramEditorInput)) throw new PartInitException("Invalid Input: Must be Activiti Diagram or BPMN2.0 XML"); // checks if the editor was opened with non Diagram file if (editorInput instanceof IFileEditorInput) { if (isBPM2FileType((IFileEditorInput) editorInput)) { associatedBPMN2File = ((IFileEditorInput) editorInput).getFile(); final IFile diagramFile = getAssociatedDiagramIFile(associatedBPMN2File); if(diagramFile.exists() == false) { String bpmnFile = associatedBPMN2File.getRawLocation().toFile().getAbsolutePath(); String processName = bpmnFile.substring(bpmnFile.lastIndexOf(File.separator) + 1); processName = processName.replace(".xml", ""); processName = processName.replace(".bpmn20", ""); ImportBpmnUtil.createDiagram(processName, bpmnFile, associatedBPMN2File.getProject(), associatedBPMN2File.getParent()); } final IEditorInput diagramFileEditorInput = new FileEditorInput(diagramFile); // creates DiagramEditorInput from FileEditorInput editorInput = new DiagramEditorFactory().createEditorInput(diagramFileEditorInput); } } super.init(site, editorInput); }
protected void refreshKeyTreeModel() { String selectedKey = getSelectedKey(); // memorize if (messagesBundleGroup == null) { messagesBundleGroup = MessagesBundleGroupFactory.createBundleGroup( (IEditorSite) getSite(), file); } AbstractKeyTreeModel oldModel = this.keyTreeModel; this.keyTreeModel = new AbstractKeyTreeModel(messagesBundleGroup); for (IMessagesEditorChangeListener listener : changeListeners) { listener.keyTreeModelChanged(oldModel, this.keyTreeModel); } i18nPage.getTreeViewer().expandAll(); if (selectedKey != null) { setSelectedKey(selectedKey); } }
protected void closeIfAreadyOpen(IEditorSite site, IFile file) { IWorkbenchPage[] pages = site.getWorkbenchWindow().getPages(); for (int i = 0; i < pages.length; i++) { IWorkbenchPage page = pages[i]; IEditorReference[] editors = page.getEditorReferences(); for (int j = 0; j < editors.length; j++) { IEditorPart editor = editors[j].getEditor(false); if (editor instanceof AbstractMessagesEditor) { AbstractMessagesEditor rbe = (AbstractMessagesEditor) editor; if (rbe.isBundleMember(file)) { page.closeEditor(editor, true); } } } } }
/** * Constructor. * * @param site * editor site * @param file * file opened */ public DefaultBundleGroupStrategy(IEditorSite site, IFile file) { super(); this.file = file; this.site = site; String patternCore = "((_[a-z]{2,3})|(_[a-z]{2,3}_[A-Z]{2})" //$NON-NLS-1$ + "|(_[a-z]{2,3}_[A-Z]{2}_\\w*))?(\\." //$NON-NLS-1$ + file.getFileExtension() + ")$"; //$NON-NLS-1$ // Compute and cache name String namePattern = "^(.*?)" + patternCore; //$NON-NLS-1$ this.baseName = file.getName().replaceFirst(namePattern, "$1"); //$NON-NLS-1$ // File matching pattern this.fileMatchPattern = "^(" + baseName + ")" + patternCore; //$NON-NLS-1$//$NON-NLS-2$ }
private IStatusLineManager getStatusLineManager() { IWorkbench wb = PlatformUI.getWorkbench(); IWorkbenchWindow win = wb.getActiveWorkbenchWindow(); IWorkbenchPage page = win.getActivePage(); IWorkbenchPart part = page.getActivePart(); if (part == null) return null; IWorkbenchPartSite site = part.getSite(); IActionBars actionBars = null; if (site instanceof IEditorSite) actionBars = ((IEditorSite) site).getActionBars(); else if (site instanceof IViewSite) actionBars = ((IViewSite) site).getActionBars(); if (actionBars == null) return null; return actionBars.getStatusLineManager(); }
private IStatusLineManager getStatusLineManager() { IWorkbench wb = PlatformUI.getWorkbench(); IWorkbenchWindow win = wb.getActiveWorkbenchWindow(); IWorkbenchPage page = win.getActivePage(); if (page == null) return null; IWorkbenchPart part = page.getActivePart(); if (part == null) return null; IWorkbenchPartSite site = part.getSite(); IActionBars actionBars = null; if (site instanceof IEditorSite) actionBars = ((IEditorSite) site).getActionBars(); else if (site instanceof IViewSite) actionBars = ((IViewSite) site).getActionBars(); if (actionBars == null) return null; return actionBars.getStatusLineManager(); }
@Override public void init(IEditorSite site, IEditorInput input) throws PartInitException { IFile file = null; if (input instanceof FileStoreEditorInput) { input = FileUtils.checkAndConvertEditorInput(input, new NullProgressMonitor()); init(site, input); return; } else if (input instanceof IFileEditorInput) { file = ((IFileEditorInput) input).getFile(); } try { getJrContext(file); setSite(site); setPartName(input.getName()); setInput(input); } catch (Exception e) { throw new PartInitException(e.getMessage(), e); } }
@Override public void init(IEditorSite site, IEditorInput input) throws PartInitException { log.info("Call editor.init() " + uuid.toString()); setSite(site); setInput(input); setPartName(input.getName()); diagramFile = getFile(input); try { // use invokeAndWait to make sure the initialization is finished before SWT proceeds SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { // initialize embedded panel here (and not in createPartControl) to avoid ugly scrollbars embeddedPanel = guiComponents.initEclipseGui(); } }); } catch (Exception e) { throw new PartInitException("Create DiagramHandler interrupted", e); } }
@Override public void init(IEditorSite site, IEditorInput input) throws PartInitException { setSite(site); setInput(input); if (input instanceof WebBrowserEditorInput) { WebBrowserEditorInput wbei = (WebBrowserEditorInput) input; initialURL = null; if (wbei.getURL() != null) initialURL = wbei.getURL().toExternalForm(); if (webBrowser != null) { webBrowser.setURL(initialURL); site.getWorkbenchWindow().getActivePage().activate(this); } setPartName(wbei.getName()); setTitleToolTip(wbei.getToolTipText()); Image oldImage = image; ImageDescriptor id = wbei.getImageDescriptor(); image = id.createImage(); setTitleImage(image); if (oldImage != null && !oldImage.isDisposed()) oldImage.dispose(); } }
/** * The <code>MultiPageEditorExample</code> implementation of this method * checks that the input is an instance of <code>IFileEditorInput</code>. */ @Override public void init(IEditorSite site, IEditorInput editorInput) throws PartInitException { if (!(editorInput instanceof DocumentStorageEditorInput)) { PartInitException pie = new PartInitException("Invalid Input: Must be DocumentStorageEditorInput"); pie.printStackTrace(); throw pie; } super.init(site, editorInput); setPartName(editorInput.getName()); site.getPage().addPartListener(partListener); extractDocument(editorInput); getActionBarContributor().setActiveEditor(BibtexEditor.this); setSelection(getSelection()); ModelRegistryPlugin.getModelRegistry().setActiveDocument(document); }
/** * This is called during startup. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void init(IEditorSite site, IEditorInput editorInput) { setSite(site); setInputWithNotify(editorInput); setPartName(editorInput.getName()); site.setSelectionProvider(this); site.getPage().addPartListener(partListener); ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_CHANGE); }
/** * Records the file open operation when the editor is instantiated. * @param site the editor site * @param input the editor input * @exception PartInitException if this editor was not initialized successfully */ @Override public void init(IEditorSite site, IEditorInput input) throws PartInitException { super.init(site, input); if (historyManager == null) { historyManager = HistoryManager.getInstance(); historyManager.start(this); historyManager.recordFileOpenOperation(getInputFile(), getSourceCode()); } }