Java Code Examples for org.eclipse.ui.IEditorInput

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project ceylon-ide-eclipse, under directory /plugins/com.redhat.ceylon.eclipse.ui/src/com/redhat/ceylon/eclipse/code/editor/.

Source file: CeylonEditor.java

  24 
vote

private void initializeParseController(){
  IEditorInput editorInput=getEditorInput();
  IFile file=getFile(editorInput);
  IPath filePath=getPath(editorInput);
  parseController=new CeylonParseController();
  IProject project=file != null && file.exists() ? file.getProject() : null;
  parseController.initialize(filePath,project,annotationCreator);
}
 

Example 2

From project dawn-common, under directory /org.dawb.common.ui/src/org/dawb/common/ui/util/.

Source file: EclipseUtils.java

  23 
vote

/** 
 * Opens an external editor on a file path
 * @param filename
 * @throws PartInitException
 */
public static IEditorPart openExternalEditor(String filename) throws PartInitException {
  final IWorkbenchPage page=EclipseUtils.getPage();
  IEditorDescriptor desc=PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(filename);
  if (desc == null)   desc=PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(filename + ".txt");
  final IFileStore externalFile=EFS.getLocalFileSystem().fromLocalFile(new File(filename));
  final IEditorInput store=new FileStoreEditorInput(externalFile);
  final String id=desc.getId();
  return page.openEditor(store,id);
}
 

Example 3

From project dawn-isenciaui, under directory /com.teaminabox.eclipse.wiki/src/com/teaminabox/eclipse/wiki/editors/.

Source file: WikiEditor.java

  23 
vote

private boolean isTempWiki(){
  IEditorInput editorInput=getEditorInput();
  if (editorInput instanceof FileEditorInput) {
    return isTempWiki(((FileEditorInput)editorInput).getFile());
  }
  return false;
}
 

Example 4

From project bioclipse.vscreen, under directory /net.bioclipse.vscreen.ui/src/net/bioclipse/vscreen/ui/wizards/.

Source file: NewVscreenWizard.java

  22 
vote

public boolean performFinish(){
  IEditorInput input=createEditorInput();
  IWorkbenchPage page=activeWindow.getActivePage();
  try {
    page.openEditor(input,"net.bioclipse.jseditor.editor");
  }
 catch (  PartInitException e) {
    e.printStackTrace();
  }
  return true;
}
 

Example 5

From project bndtools, under directory /bndtools.core/src/bndtools/editor/contents/.

Source file: PrivatePackagesPart.java

  22 
vote

private IJavaProject getJavaProject(){
  IFormPage page=(IFormPage)getManagedForm().getContainer();
  IEditorInput input=page.getEditorInput();
  if (!IFileEditorInput.class.isInstance(input)) {
    return null;
  }
  IProject project=((IFileEditorInput)input).getFile().getProject();
  return JavaCore.create(project);
}
 

Example 6

From project BPMN2-Editor-for-Eclipse, under directory /org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/editor/.

Source file: BPMN2Editor.java

  22 
vote

/** 
 * Beware, creates a new input and changes this editor!
 */
private IEditorInput createNewDiagramEditorInput() throws CoreException {
  IPath fullPath=modelFile.getFullPath();
  modelUri=URI.createPlatformResourceURI(fullPath.toString(),true);
  IFolder folder=BPMN2DiagramCreator.getTempFolder(fullPath);
  diagramFile=BPMN2DiagramCreator.getTempFile(fullPath,folder);
  BPMN2DiagramCreator creator=new BPMN2DiagramCreator();
  creator.setDiagramFile(diagramFile);
  IEditorInput input=creator.createDiagram(false);
  diagramUri=creator.getUri();
  return input;
}
 

Example 7

From project ccw, under directory /ccw.core/src/java/ccw/.

Source file: ClojureCore.java

  22 
vote

/** 
 * Tries to open a clojure file in an editor
 * @return an editor input if the file has been found, or null
 */
private static IEditorInput findEditorInput(IPackageFragmentRoot packageFragmentRoot,String searchedPackage,String searchedFileName) throws JavaModelException {
  IPackageFragment packageFragment=packageFragmentRoot.getPackageFragment(searchedPackage);
  IEditorInput editorInput=findEditorInput(packageFragment,searchedPackage,searchedFileName);
  if (editorInput != null) {
    return editorInput;
  }
  return findEditorInputInSourceAttachment(packageFragmentRoot,searchedPackage,searchedFileName);
}
 

Example 8

From project dawn-tango, under directory /org.dawb.tango.extensions/src/org/dawb/tango/extensions/editors/actions/.

Source file: OpenSpecMonitorHandler.java

  22 
vote

@Override public Object execute(ExecutionEvent event) throws ExecutionException {
  try {
    final File tmp=File.createTempFile("sharedMemoryMonitor","mon");
    tmp.createNewFile();
    final IWorkbenchPage page=EclipseUtils.getActivePage();
    final IFileStore externalFile=EFS.getLocalFileSystem().fromLocalFile(tmp);
    final IEditorInput store=new FileStoreEditorInput(externalFile);
    page.openEditor(store,"org.dawb.tango.extensions.sharedMemEditor",true);
  }
 catch (  Exception ne) {
    throw new ExecutionException("Cannot open shared memory monitor!",ne);
  }
  return Boolean.TRUE;
}
 

Example 9

From project dawn-ui, under directory /org.dawb.workbench.plotting/src/org/dawb/workbench/plotting/views/.

Source file: ToolPageView.java

  22 
vote

private String getString(IWorkbenchPart part){
  if (part == null)   return null;
  if (part.getSite() == null)   return null;
  if (part instanceof IEditorPart) {
    final IEditorInput input=((IEditorPart)part).getEditorInput();
    if (input == null)     return null;
    return input instanceof IURIEditorInput ? ((IURIEditorInput)input).getURI().getRawPath() : input.getName();
  }
 else {
    return part.getSite().getId();
  }
}
 

Example 10

From project dozer, under directory /eclipse-plugin/net.sf.dozer.eclipse.plugin/src/org/dozer/eclipse/plugin/editorpage/utils/.

Source file: DozerUiUtils.java

  22 
vote

public void setEditorInput(IEditorInput editorInput,FormToolkit toolkit){
  IEditorInput oldInput=this.editorInput;
  this.editorInput=editorInput;
  DozerUiUtils.setToolKit(toolkit);
  if (oldInput != editorInput) {
    init();
  }
}
 

Example 11

From project droolsjbpm-tools, under directory /drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/editors/completion/.

Source file: DefaultCompletionProcessor.java

  22 
vote

private IJavaProject getCurrentJavaProject(){
  IEditorInput input=getEditor().getEditorInput();
  if (!(input instanceof IFileEditorInput)) {
    return null;
  }
  IProject project=((IFileEditorInput)input).getFile().getProject();
  IJavaProject javaProject=JavaCore.create(project);
  return javaProject;
}
 

Example 12

From project eclim, under directory /org.eclim.pdt/java/org/eclim/plugin/pdt/project/.

Source file: PhpProjectManager.java

  22 
vote

/** 
 * {@inheritDoc}
 * @see org.eclim.plugin.core.project.ProjectManager#refresh(IProject,IFile)
 */
@Override public void refresh(IProject project,IFile file) throws Exception {
  IEditorInput input=new FileEditorInput(file);
  ISourceModule module=PHPUiPlugin.getEditorInputTypeRoot(input);
  if (module != null) {
    module.makeConsistent(new NullProgressMonitor());
  }
}
 

Example 13

From project eclipse-task-editor, under directory /plugins/de.sebastianbenz.task.ui/src/de/sebastianbenz/task/ui/editor/.

Source file: ExtLinkedXtextEditorMatchingStrategy.java

  22 
vote

public boolean matches(IEditorReference editor,IEditorInput input){
  IEditorPart part=(IEditorPart)editor.getPart(false);
  if (part == null)   return false;
  IEditorInput editorInput=part.getEditorInput();
  if (editorInput instanceof FileEditorInput && input instanceof FileStoreEditorInput) {
    FileEditorInput fei=(FileEditorInput)editorInput;
    FileStoreEditorInput fsei=(FileStoreEditorInput)input;
    if (fei.getFile().isLinked() && fei.getURI().equals(fsei.getURI()))     return true;
  }
  return editorInput.equals(input);
}
 

Example 14

From project eclipsefp, under directory /net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/editors/cabal/.

Source file: CabalHyperlinkDetector.java

  22 
vote

private IContainer getContainer(){
  IContainer result=null;
  IEditorInput input=editor.getEditorInput();
  if (input instanceof IFileEditorInput) {
    IFileEditorInput fei=(IFileEditorInput)input;
    IFile file=fei.getFile();
    if (file != null && file.exists()) {
      result=file.getParent();
    }
  }
  return result;
}
 

Example 15

From project grails-ide, under directory /org.grails.ide.eclipse.ui/src/org/grails/ide/eclipse/ui/internal/launch/.

Source file: GrailsLaunchShortcut.java

  22 
vote

public void launch(IEditorPart editor,String mode){
  IEditorInput input=editor.getEditorInput();
  if (input instanceof IFileEditorInput) {
    IFile file=((IFileEditorInput)input).getFile();
    launch(file,mode);
  }
}
 

Example 16

From project libra, under directory /plugins/org.eclipse.libra.framework.editor.ui/src/org/eclipse/libra/framework/editor/ui/internal/overview/.

Source file: BundleInformationDetailsPart.java

  22 
vote

private void openBundleEditor(IBundle bundle){
  try {
    String fileName="META-INF/MANIFEST.MF";
    IEditorInput input=getEditorInput(getBundleRoot(bundle),fileName);
    IEditorDescriptor desc=PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(fileName,getContentType());
    IWorkbenchPage page=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    page.openEditor(input,desc.getId());
  }
 catch (  Exception e) {
    EditorUIPlugin.log(e);
  }
}
 

Example 17

From project aws-toolkit-for-eclipse, under directory /com.amazonaws.eclipse.core/src/com/amazonaws/eclipse/explorer/s3/.

Source file: OpenBucketEditorAction.java

  21 
vote

@Override public void run(){
  String endpoint=RegionUtils.getCurrentRegion().getServiceEndpoints().get(ServiceAbbreviations.S3);
  String accountId=AwsToolkitCore.getDefault().getCurrentAccountId();
  final IEditorInput input=new BucketEditorInput(bucketName,endpoint,accountId);
  Display.getDefault().asyncExec(new Runnable(){
    public void run(){
      try {
        IWorkbenchWindow activeWindow=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        activeWindow.getActivePage().openEditor(input,"com.amazonaws.eclipse.explorer.s3.bucketEditor");
      }
 catch (      PartInitException e) {
        String errorMessage="Unable to open the Amazon S3 bucket editor: " + e.getMessage();
        Status status=new Status(Status.ERROR,AwsToolkitCore.PLUGIN_ID,errorMessage,e);
        StatusManager.getManager().handle(status,StatusManager.LOG);
      }
    }
  }
);
}
 

Example 18

From project bpelunit, under directory /tycho/net.bpelunit.framework.client.eclipse/src/net/bpelunit/framework/client/eclipse/launch/.

Source file: BPELLaunchMainTab.java

  21 
vote

/** 
 * Returns the current file context in the active workbench page or <code>null</code> if none.
 * @return current file in the active page or <code>null</code>
 */
protected IFile getContext(){
  IWorkbenchPage page=getActivePage();
  if (page != null) {
    ISelection selection=page.getSelection();
    if (selection instanceof IStructuredSelection) {
      IStructuredSelection ss=(IStructuredSelection)selection;
      if (!ss.isEmpty()) {
        Object obj=ss.getFirstElement();
        if (obj instanceof IFile) {
          return (IFile)obj;
        }
      }
    }
    IEditorPart part=page.getActiveEditor();
    if (part != null) {
      IEditorInput input=part.getEditorInput();
      return (IFile)input.getAdapter(IFile.class);
    }
  }
  return null;
}
 

Example 19

From project bundlemaker, under directory /main/org.bundlemaker.core.ui/src/org/bundlemaker/core/ui/handler/.

Source file: RunTransformationScriptHandler.java

  21 
vote

@Override protected void execute(ExecutionEvent event,ISelection selection) throws Exception {
  IFile scriptFile=null;
  if (selection instanceof ITextSelection) {
    IEditorPart editor=HandlerUtil.getActiveEditor(event);
    if (editor != null) {
      IEditorInput editorInput=editor.getEditorInput();
      scriptFile=(IFile)editorInput.getAdapter(IFile.class);
    }
  }
 else {
    List<IFile> files=getSelectedObject(selection,IFile.class);
    if (files.size() > 0) {
      scriptFile=files.get(0);
    }
  }
  if (scriptFile == null) {
    return;
  }
  IBundleMakerProject bundleMakerProject=selectBundleMakerProject();
  if (bundleMakerProject == null) {
    return;
  }
  String moduleName=TransformHandler.getModuleName(scriptFile);
  TransformHandler.transform(bundleMakerProject,moduleName,scriptFile);
}
 

Example 20

From project cilia-workbench, under directory /cilia-workbench-designer/src/fr/liglab/adele/cilia/workbench/designer/view/repositoryview/common/.

Source file: RepositoryView.java

  21 
vote

/** 
 * Finds open editors, which are editing a file located in the repository. Filters results using the editor title : title must end with prefix.
 * @param prefix
 * @return
 */
protected List<IEditorReference> getRelevantFileStoreEditors(String prefix){
  List<IEditorReference> retval=new ArrayList<IEditorReference>();
  IEditorReference[] ref=getViewSite().getPage().getEditorReferences();
  for (  IEditorReference editor : ref) {
    try {
      IEditorInput input=editor.getEditorInput();
      if (input instanceof IURIEditorInput) {
        IURIEditorInput fileStore=(IURIEditorInput)input;
        URI uri=fileStore.getURI();
        String scheme=uri.getScheme();
        if (scheme.equals("file")) {
          String path=uri.getPath();
          if (path.startsWith(getRepositoryDirectory().getAbsolutePath()))           if (editor.getTitle().toLowerCase().endsWith(prefix))           retval.add(editor);
        }
      }
    }
 catch (    PartInitException e) {
      e.printStackTrace();
    }
  }
  return retval;
}
 

Example 21

From project dawn-workflow, under directory /org.dawb.passerelle.actors/src/org/dawb/passerelle/editors/.

Source file: EdnaActorMultiPageEditor.java

  21 
vote

@Override protected void createPages(){
  try {
    final IFile inputFile=(IFile)ResourcesPlugin.getWorkspace().getRoot().findMember(linkerProps.getProperty("org.dawb.edna.input"));
    final IEditorInput input=new FileEditorInput(inputFile);
    this.inputEditor=new XMLSubstitutionEditor(linkerProps.getProperty("org.dawb.edna.name"),linkerProps.getProperty("org.dawb.edna.moml"));
    addPage(0,inputEditor,input);
    setPageText(0,"Input");
    setPageImage(0,Activator.getImageDescriptor("icons/edna_input.gif").createImage());
    final IFile outputFile=(IFile)ResourcesPlugin.getWorkspace().getRoot().findMember(linkerProps.getProperty("org.dawb.edna.output"));
    final IEditorInput output=new FileEditorInput(outputFile);
    this.outputEditor=new XPathEditor(linkerProps.getProperty("org.dawb.edna.name"),linkerProps.getProperty("org.dawb.edna.moml"));
    addPage(1,outputEditor,output);
    setPageText(1,"Output");
    setPageImage(1,Activator.getImageDescriptor("icons/edna_output.gif").createImage());
  }
 catch (  Exception e) {
    logger.error("Cannot initiate " + getClass().getName() + "!",e);
  }
}
 

Example 22

From project Diver, under directory /ca.uvic.chisel.diver.mylyn.logger/src/ca/uvic/chisel/diver/mylyn/logger/logging/.

Source file: PartListener.java

  21 
vote

@Override public void partActivated(IWorkbenchPart part){
  String eventString="event=activation\tpart=" + part.getSite().getId();
  MylynLogger.getDefault().logEvent(eventString);
  if (part instanceof ITextEditor) {
    if (activeTextEditor != null) {
      ISelectionProvider provider=activeTextEditor.getSelectionProvider();
      provider.removeSelectionChangedListener(textSelectionChangedListener);
      if (provider instanceof IPostSelectionProvider) {
        ((IPostSelectionProvider)provider).removePostSelectionChangedListener(textSelectionChangedListener);
      }
    }
    activeTextEditor=(ITextEditor)part;
    ISelectionProvider provider=activeTextEditor.getSelectionProvider();
    if (provider instanceof IPostSelectionProvider) {
      ((IPostSelectionProvider)provider).addPostSelectionChangedListener(textSelectionChangedListener);
    }
 else {
      provider.addSelectionChangedListener(textSelectionChangedListener);
    }
    IEditorInput input=activeTextEditor.getEditorInput();
    ITypeRoot typeRoot=null;
    if (input instanceof IClassFileEditorInput) {
      typeRoot=((IClassFileEditorInput)input).getClassFile();
    }
 else     if (input instanceof IFileEditorInput) {
      IFile file=((IFileEditorInput)input).getFile();
      IJavaElement element=JavaCore.create(file);
      if (element instanceof ITypeRoot) {
        typeRoot=(ITypeRoot)element;
      }
    }
  }
}
 

Example 23

From project dolphin, under directory /org.adarsh.jutils/src/com/tan/actions/.

Source file: EditplusAction.java

  21 
vote

public void run(){
  if (window == null)   return;
  IEditorPart editorPart=window.getActivePage().getActiveEditor();
  IEditorInput editorInput=editorPart.getEditorInput();
  IFile file=null;
  if (editorInput instanceof org.eclipse.ui.part.FileEditorInput) {
    FileEditorInput fileEditorInput=(FileEditorInput)editorInput;
    file=fileEditorInput.getFile();
  }
  Workspace workspace=(Workspace)ResourcesPlugin.getWorkspace();
  IProject project=file.getProject();
  String projectName=project.getName();
  IPath xx=project.getFullPath();
  ResourceInfo resource=workspace.getResourceInfo(xx,true,false);
  URI uri=resource.getFileStoreRoot().computeURI(xx);
  String workspacePath=uri.getPath();
  String projectPath=xx.toString();
  int idx=workspacePath.indexOf(projectPath);
  if (idx >= 0) {
    workspacePath=workspacePath.substring(0,idx);
  }
  String path=workspacePath + file.getFullPath().toOSString();
  if (path.charAt(0) == '/') {
    path=path.substring(1);
  }
  path=path.replace('/',File.separatorChar).replace('\\',File.separatorChar);
  if (isFile(path)) {
    command(" \"" + path + "\"");
  }
 else {
    path=StringUtil.replace(path,projectName + File.separatorChar,"");
    if (isFile(path)) {
      command(" \"" + path + "\"");
    }
  }
}
 

Example 24

From project Eclipse, under directory /com.mobilesorcery.sdk.html5/src/com/mobilesorcery/sdk/html5/ui/.

Source file: EvaluateHandler.java

  21 
vote

@Override public Object execute(ExecutionEvent event) throws ExecutionException {
  IEditorPart editor=HandlerUtil.getActiveEditor(event);
  IEditorInput input=editor.getEditorInput();
  IProject project=null;
  IResource resource=(IResource)input.getAdapter(IResource.class);
  if (resource != null) {
    project=resource.getProject();
  }
  ISelection selection=editor.getSite().getSelectionProvider().getSelection();
  if (project != null && selection instanceof ITextSelection) {
    ITextSelection textSelection=(ITextSelection)selection;
    final String expression=textSelection.getText();
    Thread t=new Thread(new Runnable(){
      @Override public void run(){
        IProcessConsole console=CoreMoSyncPlugin.getDefault().createConsole(MoSyncBuilder.CONSOLE_ID);
        JSODDServer server=Html5Plugin.getDefault().getReloadServer();
        Set<Integer> sessionIds=server.getSessions();
        for (        Integer sessionId : sessionIds) {
          try {
            Object result=server.evaluate(sessionId,expression,null);
            String sessionIdStr="";
            if (sessionIds.size() > 1) {
              ReloadVirtualMachine vm=server.getVM(sessionId);
              sessionIdStr="IP: " + vm.getRemoteAddr();
            }
            console.addMessage(sessionIdStr + ">" + result);
          }
 catch (          Exception e) {
          }
        }
      }
    }
);
    t.start();
  }
  return null;
}
 

Example 25

From project eclipse-instasearch, under directory /instasearch/src/it/unibz/instasearch/ui/.

Source file: MatchHighlightJob.java

  21 
vote

/** 
 * @param doc
 * @param selectedLineMatches
 * @param contentProvider 
 * @param workbenchPage 
 * @throws Exception 
 */
public MatchHighlightJob(SearchResultDoc doc,MatchLine selectedLineMatches,ResultContentProvider contentProvider,Job searchJob,IWorkbenchPage workbenchPage) throws Exception {
  super("Highlight Matches");
  this.doc=doc;
  this.selectedLineMatches=selectedLineMatches;
  this.contentProvider=contentProvider;
  this.searchJob=searchJob;
  this.workbenchPage=workbenchPage;
  IEditorInput input=contentProvider.getEditorInput(doc);
  IEditorDescriptor editorDesc=IDE.getEditorDescriptor(doc.getFileName());
  IEditorPart editorPart=IDE.openEditor(workbenchPage,input,editorDesc.getId());
  this.editor=getTextEditor(input,editorPart);
  this.document=editor.getDocumentProvider().getDocument(editor.getEditorInput());
  IStorage storage=contentProvider.getStorage(doc);
  this.file=null;
  if (storage instanceof IFile)   file=(IFile)storage;
}
 

Example 26

From project eclipse-integration-commons, under directory /org.springsource.ide.eclipse.commons.ui/src/org/springsource/ide/eclipse/commons/ui/.

Source file: SpringUIUtils.java

  21 
vote

public static void revealInEditor(IEditorPart editor,int line){
  ITextEditor textEditor=getTextEditor(editor);
  if (textEditor != null && line > 0) {
    IDocumentProvider provider=textEditor.getDocumentProvider();
    IEditorInput input=editor.getEditorInput();
    try {
      provider.connect(input);
    }
 catch (    CoreException e) {
      return;
    }
    IDocument document=provider.getDocument(input);
    try {
      IRegion lineRegion=document.getLineInformation(line - 1);
      textEditor.selectAndReveal(lineRegion.getOffset(),lineRegion.getLength());
    }
 catch (    BadLocationException e) {
    }
    provider.disconnect(input);
  }
}
 

Example 27

From project eclipse-integration-gradle, under directory /org.springsource.ide.eclipse.gradle.ui/src/org/springsource/ide/eclipse/gradle/ui/launch/.

Source file: GradleLaunchTasksTab.java

  21 
vote

private GradleProject getContext(){
  IWorkbench wb=PlatformUI.getWorkbench();
  IWorkbenchWindow win=wb.getActiveWorkbenchWindow();
  IWorkbenchPage page=win == null ? null : win.getActivePage();
  if (page != null) {
    ISelection selection=page.getSelection();
    if (selection instanceof IStructuredSelection) {
      IStructuredSelection ss=(IStructuredSelection)selection;
      if (!ss.isEmpty()) {
        Object obj=ss.getFirstElement();
        if (obj instanceof IResource) {
          IResource rsrc=(IResource)obj;
          IProject prj=rsrc.getProject();
          if (prj != null) {
            return GradleCore.create(prj);
          }
        }
      }
    }
    IEditorPart part=page.getActiveEditor();
    if (part != null) {
      IEditorInput input=part.getEditorInput();
      IResource rsrc=(IResource)input.getAdapter(IResource.class);
      if (rsrc != null) {
        IProject prj=rsrc.getProject();
        if (prj != null) {
          return GradleCore.create(prj);
        }
      }
    }
  }
  return null;
}
 

Example 28

From project eik, under directory /plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/internal/.

Source file: WorkbenchActionProvider.java

  21 
vote

@Override public void init(final ICommonActionExtensionSite aSite){
  super.init(aSite);
  aSite.getStructuredViewer().addDoubleClickListener(new IDoubleClickListener(){
    @Override public void doubleClick(    final DoubleClickEvent event){
      if (!(event.getSelection() instanceof IStructuredSelection)) {
        return;
      }
      final IStructuredSelection structuredSelection=(IStructuredSelection)event.getSelection();
      if (structuredSelection.size() > 1) {
        return;
      }
      final Object element=structuredSelection.getFirstElement();
      if (!(element instanceof IProject)) {
        return;
      }
      final IProject project=(IProject)element;
      final IKarafProject karafProject=(IKarafProject)project.getAdapter(IKarafProject.class);
      final IEditorInput editorInput=new KarafPlatformEditorInput(karafProject);
      try {
        final IWorkbenchPage page=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        page.openEditor(editorInput,KarafPlatformEditorPart.ID);
      }
 catch (      final PartInitException e) {
        KarafWorkbenchActivator.getLogger().error("Unable to open editor for " + karafProject.getName(),e);
      }
    }
  }
);
}
 

Example 29

From project EMF-IncQuery, under directory /plugins/org.eclipse.viatra2.emf.incquery.tooling.gui/src/org/eclipse/viatra2/emf/incquery/queryexplorer/util/.

Source file: FileEditorPartListener.java

  21 
vote

@Override public void partClosed(IWorkbenchPart part){
  if (part != null && part instanceof IEditorPart) {
    IEditorPart closedEditor=(IEditorPart)part;
    IEditorInput editorInput=closedEditor.getEditorInput();
    if (editorInput != null && editorInput instanceof FileEditorInput) {
      IFile file=((FileEditorInput)editorInput).getFile();
      if (file != null && file.getFileExtension().matches("eiq") && PatternRegistry.getInstance().getFiles().contains(file)) {
        String question="There are patterns (from file named '" + file.getName() + "') registered in the Query Explorer.\nWould you like to unregister them?";
        boolean answer=MessageDialog.openQuestion(closedEditor.getSite().getShell(),dialogTitle,question);
        if (answer) {
          RuntimeMatcherUnRegistrator job=new RuntimeMatcherUnRegistrator(file);
          job.run();
        }
      }
    }
  }
}
 

Example 30

From project gda-common-rcp, under directory /uk.ac.gda.common.rcp/src/uk/ac/gda/common/rcp/util/.

Source file: EclipseUtils.java

  21 
vote

/** 
 * Returns the active project based on active selection
 */
public static IProject getActiveProject(){
  final IWorkbenchPage page=EclipseUtils.getActivePage();
  if (page == null)   return null;
  final IEditorPart activeEditor=page.getActiveEditor();
  if (activeEditor != null) {
    final IEditorInput input=activeEditor.getEditorInput();
    if (input instanceof FileEditorInput) {
      return ((FileEditorInput)input).getFile().getProject();
    }
  }
  final ISelectionService service=page.getWorkbenchWindow().getSelectionService();
  final ISelection sel=service.getSelection();
  if (!(sel instanceof IStructuredSelection))   return null;
  final IStructuredSelection ss=(IStructuredSelection)sel;
  final Object element=ss.getFirstElement();
  if (element instanceof IResource)   return ((IResource)element).getProject();
  if (!(element instanceof IAdaptable))   return null;
  IAdaptable adaptable=(IAdaptable)element;
  Object adapter=adaptable.getAdapter(IResource.class);
  return ((IResource)adapter).getProject();
}
 

Example 31

From project koneki.ldt, under directory /plugins/org.eclipse.koneki.ldt.debug.ui/src/org/eclipse/koneki/ldt/debug/ui/internal/actions/.

Source file: GotoFunctionDefinitionAction.java

  21 
vote

/** 
 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
 */
@Override public void run(IAction action){
  FunctionData data=((LuaFunctionType)value.getType()).getData(value);
  ISourceLocator locator=value.getDebugTarget().getLaunch().getSourceLocator();
  ISourceLookupResult result=DebugUITools.lookupSource(data.getPath(),locator);
  if (result.getSourceElement() == null) {
    String title=Messages.GotoFunctionDefinitionAction_name;
    String message=Messages.GotoFunctionDefinitionAction_open_error_msg;
    String cause=Messages.GotoFunctionDefinitionAction_lookup_failed_msg;
    ErrorDialog.openError(DLTKDebugUIPlugin.getActiveWorkbenchShell(),title,message,new Status(IStatus.ERROR,Activator.PLUGIN_ID,cause));
    return;
  }
  try {
    ScriptDebugModelPresentation presentation=DLTKDebugUIPlugin.getDefault().getModelPresentation(value.getModelIdentifier());
    IEditorInput input=presentation.getEditorInput(result.getSourceElement());
    String editorId=presentation.getEditorId(input,result.getSourceElement());
    ITextEditor editor=(ITextEditor)part.getSite().getPage().openEditor(input,editorId);
    IDocument doc=editor.getDocumentProvider().getDocument(input);
    editor.selectAndReveal(doc.getLineOffset(data.getLine() - 1),0);
  }
 catch (  PartInitException e) {
    Activator.logError("Failed to open editor",e);
  }
catch (  BadLocationException e) {
    Activator.logError("Failed to set definition line",e);
  }
}
 

Example 32

From project acceleo-modules, under directory /psm-gen-scala/plugins/com.github.sbegaudeau.acceleo.modules.psm.gen.scala.editor/src-gen/com/github/sbegaudeau/acceleo/modules/psm/gen/scala/model/scala/presentation/.

Source file: ScalaEditor.java

  19 
vote

/** 
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
protected void doSaveAs(URI uri,IEditorInput editorInput){
  (editingDomain.getResourceSet().getResources().get(0)).setURI(uri);
  setInputWithNotify(editorInput);
  setPartName(editorInput.getName());
  IProgressMonitor progressMonitor=getActionBars().getStatusLineManager() != null ? getActionBars().getStatusLineManager().getProgressMonitor() : new NullProgressMonitor();
  doSave(progressMonitor);
}
 

Example 33

From project acceleo-webapp-generator, under directory /plugins/org.eclipse.acceleo.tutorial.webapp.editor/src-gen/org/eclipse/acceleo/tutorial/webapp/presentation/.

Source file: WebappEditor.java

  19 
vote

/** 
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
protected void doSaveAs(URI uri,IEditorInput editorInput){
  (editingDomain.getResourceSet().getResources().get(0)).setURI(uri);
  setInputWithNotify(editorInput);
  setPartName(editorInput.getName());
  IProgressMonitor progressMonitor=getActionBars().getStatusLineManager() != null ? getActionBars().getStatusLineManager().getProgressMonitor() : new NullProgressMonitor();
  doSave(progressMonitor);
}
 

Example 34

From project Archimedes, under directory /br.org.archimedes.core/src/br/org/archimedes/gui/rca/editor/.

Source file: DrawingEditor.java

  19 
vote

@Override public void init(IEditorSite site,IEditorInput input) throws PartInitException {
  if (cursors == null) {
    cursors=DrawingEditor.createCursors(site.getShell().getDisplay());
  }
  setSite(site);
  setInput(input);
  setPartName(input.getName());
  openGL=br.org.archimedes.Utils.getOpenGLWrapper();
  visualHelper=new VisualHelper(openGL,br.org.archimedes.Utils.getWorkspace(),br.org.archimedes.Utils.getInputController());
  getDrawing().addObserver(this);
  getSite().setSelectionProvider(this);
  getEditorSite().getWorkbenchWindow().getPartService().addPartListener(new IPartListener(){
    private IWorkbenchPart lastActivated;
    public void partActivated(    IWorkbenchPart part){
      if (part == DrawingEditor.this) {
        System.out.println("Ativando: " + getDrawing().getTitle());
        lastActivated=part;
        br.org.archimedes.Utils.getInputController().setDrawing(getDrawing());
      }
    }
    public void partBroughtToTop(    IWorkbenchPart part){
    }
    public void partClosed(    IWorkbenchPart part){
      br.org.archimedes.Utils.getInputController().setDrawing(null);
      partActivated(lastActivated);
    }
    public void partDeactivated(    IWorkbenchPart part){
      if (part == DrawingEditor.this) {
        System.out.println("Desativando: " + getDrawing().getTitle());
        lastActivated=null;
      }
    }
    public void partOpened(    IWorkbenchPart part){
    }
  }
);
}
 

Example 35

From project bel-editor, under directory /org.openbel.editor.ui/src/org/openbel/editor/ui/editor/.

Source file: BELScriptEditor.java

  19 
vote

/** 
 * {@inheritDoc}
 */
@Override protected void connectPartitioningToElement(IEditorInput input,IDocument document){
  if (document instanceof IDocumentExtension3) {
    IDocumentExtension3 extension=(IDocumentExtension3)document;
    if (extension.getDocumentPartitioner(BELPartitions.PARTITIONING) == null) {
      BELTextTools tools=Activator.getDefault().getTextTools();
      tools.setupDocumentPartitioner(document,BELPartitions.PARTITIONING);
    }
  }
}
 

Example 36

From project Bio-PEPA, under directory /uk.ac.ed.inf.biopepa.ui/src/uk/ac/ed/inf/biopepa/ui/editors/.

Source file: BioPEPAEditor.java

  19 
vote

public void init(IEditorSite site,IEditorInput input) throws PartInitException {
  super.init(site,input);
  IResource resource=(IResource)input.getAdapter(IResource.class);
  model=BioPEPAPlugin.getDefault().getBioPEPAManager().getModel(resource);
  BioPEPAPlugin.getDefault().getBioPEPAManager().editorOpened(this);
  checkPerspective(site.getPage());
}
 

Example 37

From project bioclipse.seneca, under directory /plugins/net.bioclipse.seneca/src/net/bioclipse/seneca/editor/.

Source file: SenecaJobEditor.java

  19 
vote

public void init(IEditorSite site,IEditorInput editorInput) throws PartInitException {
  if (!(editorInput instanceof IFileEditorInput))   throw new PartInitException("Invalid Input: Must be IFileEditorInput");
  super.init(site,editorInput);
  Object file=editorInput.getAdapter(IFile.class);
  if (!(file instanceof IFile)) {
    throw new PartInitException("Invalid editor input: Does not provide an IFile");
  }
  this.inputFile=(IFile)file;
  ISenecaManager manager=(ISenecaManager)Activator.getDefault().getJavaSenecaManager();
  try {
    this.specification=manager.getJobSpecification(inputFile);
  }
 catch (  BioclipseException e) {
    throw new PartInitException("Problems reading file",e);
  }
  setPartName(inputFile.getName());
}
 

Example 38

From project bioclipse.speclipse, under directory /plugins/net.bioclipse.specmol/src/net/bioclipse/specmol/editor/.

Source file: SpecMolEditor.java

  19 
vote

/** 
 * Gets a CMLSpectrum from the editorInput
 * @return The CMLSpectrum in the editorInput, null if not possible
 * @throws BioclipseException 
 */
private CMLCml getModelFromEditorInput(IEditorInput input) throws BioclipseException {
  Object file=input.getAdapter(IFile.class);
  if (!(file instanceof IFile)) {
    throw new BioclipseException("Invalid editor input: Does not provide an IFile");
  }
  IFile inputFile=(IFile)file;
  try {
    ISpecmolManager specmolManager=Activator.getDefault().getJavaSpecmolManager();
    return specmolManager.loadSpecmol(inputFile).getJumboObject();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  return null;
}
 

Example 39

From project Database-Designer, under directory /plugins/org.obeonetwork.dsl.database.editor/src/org/obeonetwork/dsl/database/presentation/.

Source file: DatabaseEditor.java

  19 
vote

/** 
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
protected void doSaveAs(URI uri,IEditorInput editorInput){
  (editingDomain.getResourceSet().getResources().get(0)).setURI(uri);
  setInputWithNotify(editorInput);
  setPartName(editorInput.getName());
  IProgressMonitor progressMonitor=getActionBars().getStatusLineManager() != null ? getActionBars().getStatusLineManager().getProgressMonitor() : new NullProgressMonitor();
  doSave(progressMonitor);
}
 

Example 40

From project eclipse-integration-cloudfoundry, under directory /org.cloudfoundry.ide.eclipse.server.ui/src/org/cloudfoundry/ide/eclipse/internal/server/ui/editor/.

Source file: CloudFoundryAccountSection.java

  19 
vote

@Override public void init(IEditorSite site,IEditorInput input){
  super.init(site,input);
  if (server != null) {
    cfServer=(CloudFoundryServer)server.loadAdapter(CloudFoundryServer.class,null);
    update();
  }
  sectionTitle="Account Information";
}
 

Example 41

From project fr.obeo.performance, under directory /fr.obeo.performance.editor/src-gen/fr/obeo/performance/presentation/.

Source file: PerformanceEditor.java

  19 
vote

/** 
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
protected void doSaveAs(URI uri,IEditorInput editorInput){
  (editingDomain.getResourceSet().getResources().get(0)).setURI(uri);
  setInputWithNotify(editorInput);
  setPartName(editorInput.getName());
  IProgressMonitor progressMonitor=getActionBars().getStatusLineManager() != null ? getActionBars().getStatusLineManager().getProgressMonitor() : new NullProgressMonitor();
  doSave(progressMonitor);
}
 

Example 42

From project hackergarten-moreunit, under directory /org.moreunit.core/src/org/moreunit/core/commands/.

Source file: JumpActionHandler.java

  19 
vote

private static IEditorInput getActiveEditorInput(ExecutionEvent event){
  Object o=HandlerUtil.getVariable(event,ISources.ACTIVE_EDITOR_INPUT_NAME);
  if (o instanceof IEditorInput) {
    return (IEditorInput)o;
  }
  return null;
}
 

Example 43

From project ivyde, under directory /org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/editors/.

Source file: IvyModuleDescriptorEditor.java

  19 
vote

protected void setInput(IEditorInput input){
  IvyFileEditorInput ivyFileEditorInput=null;
  if (input instanceof FileEditorInput) {
    FileEditorInput fei=(FileEditorInput)input;
    IFile file=fei.getFile();
    ivyFileEditorInput=new IvyFileEditorInput(file);
  }
 else   if (input instanceof IvyFileEditorInput) {
    ivyFileEditorInput=(IvyFileEditorInput)input;
  }
  super.setInput(ivyFileEditorInput);
  if (ivyFileEditorInput.getFile() != null) {
    if (xmlEditor != null) {
      xmlEditor.setFile(ivyFileEditorInput.getFile());
    }
  }
  setPartName(ivyFileEditorInput.getFile().getName());
}