Java Code Examples for org.eclipse.ui.IEditorPart

The following are top voted examples for showing how to use org.eclipse.ui.IEditorPart. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Open_Source_ECOA_Toolset_AS5   File: IntLogicalSysEditor.java   Source Code and License 6 votes vote down vote up
@Override
public void resourceChanged(IResourceChangeEvent event) {
	if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
				for (int i = 0; i < pages.length; i++) {
					if (((FileEditorInput) getEditorInput()).getFile().getProject().equals(event.getResource())) {
						IEditorPart editorPart = pages[i].findEditor(getEditorInput());
						pages[i].closeEditor(editorPart, true);
					}
				}
			}
		});
	}
}
 
Example 2
Project: n4js   File: AbstractBuilderParticipantTest.java   Source Code and License 6 votes vote down vote up
private IEditorPart getFileEditor(final IFile file1, final IWorkbenchPage page) {
	internalFileEditor = null;
	Display.getCurrent().syncExec(new Runnable() {

		@Override
		public void run() {
			try {
				internalFileEditor = IDE.openEditor(page, file1, getEditorId(), true);
			} catch (PartInitException e) {
				e.printStackTrace();
			}
		}
	});
	long start = System.currentTimeMillis();
	long end = start;
	do {
		end = System.currentTimeMillis();
	} while (page.getActiveEditor() != internalFileEditor && (end - start) < 5000);
	return internalFileEditor;
}
 
Example 3
Project: n4js   File: OpenTypeSelectionDialogHandler.java   Source Code and License 6 votes vote down vote up
/**
 * Computes and returns the initial pattern for the type search dialog.
 *
 * If no initial pattern can be computed, an empty string is returned.
 */
private String computeInitialPattern() {
	IEditorPart activeEditor = HandlerServiceUtils.getActiveEditor().orNull();

	if (activeEditor instanceof N4JSEditor) {
		Point range = ((N4JSEditor) activeEditor).getSourceViewer2().getSelectedRange();
		try {
			String text = ((N4JSEditor) activeEditor).getDocument().get(range.x, range.y);

			if (N4JSLanguageUtils.isValidIdentifier(text)
					&& !startWithLowercaseLetter(text)
					&& !languageHelper.isReservedIdentifier(text)) {
				return text;
			}
		} catch (BadLocationException e) {
			LOGGER.error("Failed to infer type search pattern from editor selection.", e);
		}

	}
	return "";
}
 
Example 4
Project: n4js   File: N4JSResourceLinkHelper.java   Source Code and License 6 votes vote down vote up
@Override
public void activateEditor(final IWorkbenchPage page, final IStructuredSelection selection) {
	if (null != selection && !selection.isEmpty()) {
		final Object firstElement = selection.getFirstElement();
		if (firstElement instanceof ResourceNode) {
			final File fileResource = ((ResourceNode) firstElement).getResource();
			if (fileResource.exists() && fileResource.isFile()) {
				final URI uri = URI.createFileURI(fileResource.getAbsolutePath());
				final IResource resource = externalLibraryWorkspace.getResource(uri);
				if (resource instanceof IFile) {
					final IEditorInput editorInput = EditorUtils.createEditorInput(new URIBasedStorage(uri));
					final IEditorPart editor = page.findEditor(editorInput);
					if (null != editor) {
						page.bringToTop(editor);
						return;
					}
				}
			}
		}
	}
	super.activateEditor(page, selection);
}
 
Example 5
Project: OCCI-Studio   File: SlaActionBarContributor.java   Source Code and License 6 votes vote down vote up
/**
 * When the active editor changes, this remembers the change and registers with it as a selection provider.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setActiveEditor(IEditorPart part) {
	super.setActiveEditor(part);
	activeEditorPart = part;

	// Switch to the new selection provider.
	//
	if (selectionProvider != null) {
		selectionProvider.removeSelectionChangedListener(this);
	}
	if (part == null) {
		selectionProvider = null;
	}
	else {
		selectionProvider = part.getSite().getSelectionProvider();
		selectionProvider.addSelectionChangedListener(this);

		// Fake a selection changed event to update the menus.
		//
		if (selectionProvider.getSelection() != null) {
			selectionChanged(new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection()));
		}
	}
}
 
Example 6
Project: time4sys   File: GqamActionBarContributor.java   Source Code and License 6 votes vote down vote up
/**
 * When the active editor changes, this remembers the change and registers with it as a selection provider.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setActiveEditor(IEditorPart part) {
	super.setActiveEditor(part);
	activeEditorPart = part;

	// Switch to the new selection provider.
	//
	if (selectionProvider != null) {
		selectionProvider.removeSelectionChangedListener(this);
	}
	if (part == null) {
		selectionProvider = null;
	}
	else {
		selectionProvider = part.getSite().getSelectionProvider();
		selectionProvider.addSelectionChangedListener(this);

		// Fake a selection changed event to update the menus.
		//
		if (selectionProvider.getSelection() != null) {
			selectionChanged(new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection()));
		}
	}
}
 
Example 7
Project: OCCI-Studio   File: PlatformActionBarContributor.java   Source Code and License 6 votes vote down vote up
/**
 * When the active editor changes, this remembers the change and registers with it as a selection provider.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setActiveEditor(IEditorPart part) {
	super.setActiveEditor(part);
	activeEditorPart = part;

	// Switch to the new selection provider.
	//
	if (selectionProvider != null) {
		selectionProvider.removeSelectionChangedListener(this);
	}
	if (part == null) {
		selectionProvider = null;
	}
	else {
		selectionProvider = part.getSite().getSelectionProvider();
		selectionProvider.addSelectionChangedListener(this);

		// Fake a selection changed event to update the menus.
		//
		if (selectionProvider.getSelection() != null) {
			selectionChanged(new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection()));
		}
	}
}
 
Example 8
Project: Tarski   File: MarkerFactory.java   Source Code and License 6 votes vote down vote up
/**
 * Note: it compares marker's resource file name and open editors' file name.
 *
 * @param marker
 * @return if marker's editor is open, return editor, else return null
 */
public static IEditorPart getOpenEditorOfMarker(final IMarker marker) {
  final IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
  for (final IWorkbenchWindow iWorkbenchWindow : windows) {
    final IWorkbenchPage[] pages = iWorkbenchWindow.getPages();
    for (final IWorkbenchPage iWorkbenchPage : pages) {
      final IEditorReference[] editors = iWorkbenchPage.getEditorReferences();
      for (final IEditorReference iEditorReference : editors) {
        try {
          if (iEditorReference instanceof IFileEditorInput) {
            final IFileEditorInput input = (IFileEditorInput) iEditorReference.getEditorInput();
            final IFile file = input.getFile();
            // TODO Caused by: java.lang.NullPointerException when delete marker on ecore editor.
            if (file.getFullPath().equals(marker.getResource().getFullPath())) {
              return iEditorReference.getEditor(false);
            }
          }
        } catch (final PartInitException e) {
          e.printStackTrace();
        }
      }
    }
  }
  return null;
}
 
Example 9
Project: ContentAssist   File: EditorUtilities.java   Source Code and License 6 votes vote down vote up
/**
 * Obtains all editors that are currently opened.
 * @return the collection of the opened editors
 */
public static List<IEditorPart> getEditors() {
    List<IEditorPart> editors = new ArrayList<IEditorPart>();
    IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
    
    for (IWorkbenchWindow window : windows) {
        IWorkbenchPage[] pages = window.getPages();
        
        for (IWorkbenchPage page : pages) {
            IEditorReference[] refs = page.getEditorReferences();
            
            for (IEditorReference ref : refs) {
                IEditorPart part = ref.getEditor(false);
                if (part != null) {
                    editors.add(part);
                }
            }
        }
    }
    return editors;
}
 
Example 10
Project: iTrace-Archive   File: ITrace.java   Source Code and License 6 votes vote down vote up
/**
  * The constructor
  */
 public ITrace() {
 	IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
 	/*
 	if(editorPart != null){
  	StyledText styledText = (StyledText) editorPart.getAdapter(Control.class);
  	if(styledText != null){
	ITextOperationTarget t = (ITextOperationTarget) activeEditor.getAdapter(ITextOperationTarget.class);
	if(t instanceof ProjectionViewer){
		ProjectionViewer projectionViewer = (ProjectionViewer)t;
		tokenHighlighters.put(activeEditor, new TokenHighlighter(styledText, showTokenHighlights, projectionViewer));
	}
}
 	}
 	*/
 	eventBroker = PlatformUI.getWorkbench().getService(IEventBroker.class);
 	eventBroker.subscribe("iTrace/newgaze", this);
 	jsonSolver = new JSONGazeExportSolver();
 	xmlSolver = new XMLGazeExportSolver();
 	eventBroker.subscribe("iTrace/jsonOutput", jsonSolver);
 	eventBroker.subscribe("iTrace/xmlOutput", xmlSolver);
 }
 
Example 11
Project: gemoc-studio-modeldebugging   File: EMFEditorUtils.java   Source Code and License 6 votes vote down vote up
/**
 * Selects the given instruction in the given {@link IEditorPart}.
 * 
 * @param editorPart
 *            the {@link IEditorPart}
 * @param instructionUri
 *            the instruction {@link URI}
 */
public static void selectInstruction(IEditorPart editorPart, final URI instructionUri) {
	if (editorPart instanceof IViewerProvider) {
		if (editorPart instanceof IEditingDomainProvider) {
			final EditingDomain domain = ((IEditingDomainProvider)editorPart).getEditingDomain();
			final EObject selection = domain.getResourceSet().getEObject(instructionUri, false);
			if (selection != null) {
				((IViewerProvider)editorPart).getViewer().setSelection(
						new StructuredSelection(selection), true);
			} else {
				DebugIdeUiPlugin.getPlugin().log(
						new IllegalStateException("can't find source for " + instructionUri));
			}
		}
	}
}
 
Example 12
Project: convertigo-eclipse   File: XslRuleEditor.java   Source Code and License 6 votes vote down vote up
public void propertyChanged(Object source, int propId) {
	// When a property from the xslEditor Changes, walk the list all the listeners and notify them.
	Object listeners[] = listenerList.getListeners();
	for (int i = 0; i < listeners.length; i++) {
		IPropertyListener listener = (IPropertyListener) listeners[i];
		listener.propertyChanged(this, propId);
	}

	if (propId == IEditorPart.PROP_DIRTY) {
		if (!xmlEditor.isDirty()) {
			// We changed from Dirty to non dirty ==> User has saved so,
			// launch Convertigo engine

			// "touch" the parent style sheet ==> Convertigo engine will
			// recompile it
			
			IPath path;
			path = file.getRawLocation();
			path = path.append("../../" + parentStyleSheetUrl);
			File parentFile = path.toFile();
			parentFile.setLastModified(System.currentTimeMillis());
		}
	}
}
 
Example 13
Project: convertigo-eclipse   File: SequenceTreeObject.java   Source Code and License 6 votes vote down vote up
public void openSequenceEditor() {
	Sequence sequence = getObject();
	synchronized (sequence) {
		IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
		if (activePage != null) {
			IEditorPart editorPart = getSequenceEditor(activePage, sequence);
			
			if (editorPart != null) {
				activePage.activate(editorPart);
			}
			else {
				try {
					editorPart = activePage.openEditor(new SequenceEditorInput(sequence),
									"com.twinsoft.convertigo.eclipse.editors.sequence.SequenceEditor");
				} catch (PartInitException e) {
					ConvertigoPlugin.logException(e,
							"Error while loading the sequence editor '"
									+ sequence.getName() + "'");
				}
			}
		}
	}
}
 
Example 14
Project: time4sys   File: AbstractNewModelWizard.java   Source Code and License 6 votes vote down vote up
/**
 * Open the dashboard representation containing in the representation file
 * of this Modeling project.
 *
 * @param curProject
 *            The modeling project containing the representations file.
 */
public void openDashboard(IProject curProject) {
	final Option<ModelingProject> opionalModelingProject = ModelingProject.asModelingProject(curProject);
	if (opionalModelingProject.some()) {
		final Session session = opionalModelingProject.get().getSession();
		if (session != null) {
			final boolean initialValue = ActivityExplorerActivator.getDefault().getPreferenceStore()
					.getBoolean(PreferenceConstants.P_OPEN_ACTIVITY_EXPLORER);
			// in order to open activity explorer at project creation the
			// preference store
			// P_OPEN_ACTIVITY_EXPLORER need to be set to true
			ActivityExplorerActivator.getDefault().getPreferenceStore()
					.setValue(PreferenceConstants.P_OPEN_ACTIVITY_EXPLORER, true);

			final IEditorPart part = ActivityExplorerManager.INSTANCE.getEditorFromSession(session);
			if (part != null) {
				// Activity explorer already opened
				PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().activate(part);
			} else {
				ActivityExplorerManager.INSTANCE.openEditor(session);
			}
			ActivityExplorerActivator.getDefault().getPreferenceStore()
					.setValue(PreferenceConstants.P_OPEN_ACTIVITY_EXPLORER, initialValue);
		}
	}
}
 
Example 15
Project: convertigo-eclipse   File: MyAbstractAction.java   Source Code and License 6 votes vote down vote up
public IEditorPart getJscriptTransactionEditor(Transaction transaction) {
	IEditorPart editorPart = null;
	IWorkbenchPage activePage = getActivePage();
	if (activePage != null) {
		if (transaction != null) {
			IEditorReference[] editorRefs = activePage.getEditorReferences();
			for (int i=0;i<editorRefs.length;i++) {
				IEditorReference editorRef = (IEditorReference)editorRefs[i];
				try {
					IEditorInput editorInput = editorRef.getEditorInput();
					if ((editorInput != null) && (editorInput instanceof JscriptTransactionEditorInput)) {
						if (((JscriptTransactionEditorInput)editorInput).transaction.equals(transaction)) {
							editorPart = editorRef.getEditor(false);
							break;
						}
					}
				}
				catch(PartInitException e) {
					//ConvertigoPlugin.logException(e, "Error while retrieving the jscript transaction editor '" + editorRef.getName() + "'");
				}
			}
		}
	}
	return editorPart;
}
 
Example 16
Project: eclipse-bash-editor   File: AbstractBashEditorHandler.java   Source Code and License 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWorkbench workbench = PlatformUI.getWorkbench();
	if (workbench==null){
		return null;
	}
	IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
	if (activeWorkbenchWindow==null){
		return null;
	}
	IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
	if (activePage==null){
		return null;
	}
	IEditorPart editor = activePage.getActiveEditor();
	
	if (editor instanceof BashEditor){
		executeOnBashEditor((BashEditor) editor);
	}
	return null;
}
 
Example 17
Project: eZooKeeper   File: BaseAction.java   Source Code and License 6 votes vote down vote up
public boolean canRun() {

        InputType inputType = getInputType();

        if (inputType.isStructuredSelection()) {
            IStructuredSelection structuredSelection = getCurrentStructuredSelection();
            if (canRunWithStructuredSelection(structuredSelection)) {
                return true;
            }
        }
        else if (inputType.isEditorInput()) {

            IEditorPart editor = getActiveEditor();
            IEditorInput editorInput = (editor != null) ? editor.getEditorInput() : null;

            if (canRunWithEditorInput(editorInput)) {
                return true;
            }
        }
        else if (canRunWithNothing()) {
            return true;
        }

        return false;

    }
 
Example 18
Project: Open_Source_ECOA_Toolset_AS5   File: TypesEditorContributor.java   Source Code and License 6 votes vote down vote up
public void setActivePage(IEditorPart part) {
	if (activeEditorPart == part)
		return;

	activeEditorPart = part;

	IActionBars actionBars = getActionBars();
	if (actionBars != null) {

		ITextEditor editor = (part instanceof ITextEditor) ? (ITextEditor) part : null;

		actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), getAction(editor, ITextEditorActionConstants.DELETE));
		actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), getAction(editor, ITextEditorActionConstants.UNDO));
		actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), getAction(editor, ITextEditorActionConstants.REDO));
		actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), getAction(editor, ITextEditorActionConstants.CUT));
		actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), getAction(editor, ITextEditorActionConstants.COPY));
		actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), getAction(editor, ITextEditorActionConstants.PASTE));
		actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), getAction(editor, ITextEditorActionConstants.SELECT_ALL));
		actionBars.setGlobalActionHandler(ActionFactory.FIND.getId(), getAction(editor, ITextEditorActionConstants.FIND));
		actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), getAction(editor, IDEActionFactory.BOOKMARK.getId()));
		actionBars.updateActionBars();
	}
}
 
Example 19
Project: Open_Source_ECOA_Toolset_AS5   File: ServicesEditor.java   Source Code and License 6 votes vote down vote up
/**
 * Closes all project files on project close.
 */
public void resourceChanged(final IResourceChangeEvent event) {
	if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
				for (int i = 0; i < pages.length; i++) {
					if (((FileEditorInput) editor.getEditorInput()).getFile().getProject().equals(event.getResource())) {
						IEditorPart editorPart = pages[i].findEditor(editor.getEditorInput());
						pages[i].closeEditor(editorPart, true);
					}
				}
			}
		});
	}
}
 
Example 20
Project: eZooKeeper   File: FileEditor.java   Source Code and License 6 votes vote down vote up
public static IEditorPart editFile(File file, boolean preferIdeEditor) throws IOException, PartInitException {

        if (file == null || !file.exists() || !file.isFile() || !file.canRead()) {
            throw new IOException("Invalid file: '" + file + "'");
        }

        IWorkbench workBench = PlatformUI.getWorkbench();
        IWorkbenchPage page = workBench.getActiveWorkbenchWindow().getActivePage();
        IPath location = Path.fromOSString(file.getAbsolutePath());

        IFileStore fileStore = EFS.getLocalFileSystem().getStore(location);
        FileStoreEditorInput fileStoreEditorInput = new FileStoreEditorInput(fileStore);

        String editorId = IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID;
        if (preferIdeEditor) {
            IEditorDescriptor editorDescriptor = workBench.getEditorRegistry().getDefaultEditor(file.getName());
            if (editorDescriptor != null) {
                editorId = editorDescriptor.getId();
            }
        }

        return page.openEditor(fileStoreEditorInput, editorId);
    }
 
Example 21
Project: avro-schema-editor   File: SearchNodeControl.java   Source Code and License 6 votes vote down vote up
protected void search(String pattern, SearchType type, boolean withRef) {    	    	
	IWorkbench workbench = PlatformUI.getWorkbench();
    IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
    IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
    IEditorPart editorPart = workbenchPage.getActiveEditor();
    if (editorPart instanceof IWithAvroSchemaEditor) {
    	AvroSchemaEditor schemaEditor = ((IWithAvroSchemaEditor) editorPart).getEditor();        	
    	AvroContext masterContext = schemaEditor.getContext().getMaster();
    	SearchNodeContext searchNodeContext = masterContext.getSearchNodeContext();
    	if (pattern == null || pattern.trim().isEmpty()) {
    		searchNodeContext.reset();
    	} else if (searchNodeContext.searchNodes(type, pattern, withRef)) {
    		AvroNode node = searchNodeContext.next();
    		schemaEditor.getContentPart()
    			.getSchemaViewer(AvroContext.Kind.MASTER)
    			.setSelection(new StructuredSelection(node), true);
    	}
    	refreshCommands(editorPart, SearchNodePropertyTester.PROPERTIES);
    }
}
 
Example 22
Project: Open_Source_ECOA_Toolset_AS5   File: CompDefEditor.java   Source Code and License 6 votes vote down vote up
/**
 * Closes all project files on project close.
 */
public void resourceChanged(final IResourceChangeEvent event) {
	if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
				for (int i = 0; i < pages.length; i++) {
					if (((FileEditorInput) editor.getEditorInput()).getFile().getProject().equals(event.getResource())) {
						IEditorPart editorPart = pages[i].findEditor(editor.getEditorInput());
						pages[i].closeEditor(editorPart, true);
					}
				}
			}
		});
	}
}
 
Example 23
Project: Open_Source_ECOA_Toolset_AS5   File: ImageSaveUtil.java   Source Code and License 6 votes vote down vote up
private static String getSaveFilePath(IEditorPart editorPart, GraphicalViewer viewer, int format) {
	FileDialog fileDialog = new FileDialog(editorPart.getEditorSite().getShell(), SWT.SAVE);
	String[] filterExtensions = new String[] { "*.jpeg",
			"*.bmp"/*
					 * , "*.ico" , "*.png", "*.gif"
					 */ };
	if (format == SWT.IMAGE_BMP)
		filterExtensions = new String[] { "*.bmp" };
	else if (format == SWT.IMAGE_JPEG)
		filterExtensions = new String[] { "*.jpeg" };
	// else if (format == SWT.IMAGE_ICO)
	// filterExtensions = new String[] { "*.ico" };
	fileDialog.setFilterExtensions(filterExtensions);

	return fileDialog.open();
}
 
Example 24
Project: pgcodekeeper   File: FileUtilsUi.java   Source Code and License 6 votes vote down vote up
/**
 * Saves the content as a temp-file, opens it using SQL-editor
 * and ensures that UTF-8 is used for everything.
 */
public static void saveOpenTmpSqlEditor(String content, String filenamePrefix) throws IOException, CoreException {
    Log.log(Log.LOG_INFO, "Creating file " + filenamePrefix); //$NON-NLS-1$
    Path path = Files.createTempFile(filenamePrefix + '_', ".sql"); //$NON-NLS-1$
    Files.write(path, content.getBytes(StandardCharsets.UTF_8));
    IFileStore externalFile = EFS.getLocalFileSystem().fromLocalFile(path.toFile());
    IEditorInput input = new FileStoreEditorInput(externalFile);

    IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
            .openEditor(input, EDITOR.SQL);
    if (part instanceof ITextEditor) {
        IDocumentProvider prov = ((ITextEditor) part).getDocumentProvider();
        if (prov instanceof TextFileDocumentProvider) {
            ((TextFileDocumentProvider) prov).setEncoding(input, ApgdiffConsts.UTF_8);
            prov.resetDocument(input);
        }
    }
}
 
Example 25
Project: convertigo-eclipse   File: ConnectorTreeObject.java   Source Code and License 6 votes vote down vote up
private IEditorPart getConnectorEditor(IWorkbenchPage activePage, Connector connector) {
	IEditorPart editorPart = null;
	if (activePage != null) {
		if (connector != null) {
			IEditorReference[] editorRefs = activePage.getEditorReferences();
			for (int i=0;i<editorRefs.length;i++) {
				IEditorReference editorRef = (IEditorReference)editorRefs[i];
				try {
					IEditorInput editorInput = editorRef.getEditorInput();
					if ((editorInput != null) && (editorInput instanceof ConnectorEditorInput)) {
						if (((ConnectorEditorInput)editorInput).is(connector)) {
							editorPart = editorRef.getEditor(false);
							break;
						}
					}
				}
				catch(PartInitException e) {
					//ConvertigoPlugin.logException(e, "Error while retrieving the connector editor '" + editorRef.getName() + "'");
				}
			}
		}
	}
	return editorPart;
}
 
Example 26
Project: convertigo-eclipse   File: SequenceTreeObject.java   Source Code and License 6 votes vote down vote up
private IEditorPart getSequenceEditor(IWorkbenchPage activePage, Sequence sequence) {
	IEditorPart editorPart = null;
	if (activePage != null) {
		if (sequence != null) {
			IEditorReference[] editorRefs = activePage.getEditorReferences();
			for (int i=0;i<editorRefs.length;i++) {
				IEditorReference editorRef = (IEditorReference)editorRefs[i];
				try {
					IEditorInput editorInput = editorRef.getEditorInput();
					if ((editorInput != null) && (editorInput instanceof SequenceEditorInput)) {
						if (((SequenceEditorInput)editorInput).is(sequence)) {
							editorPart = editorRef.getEditor(false);
							break;
						}
					}
				} catch(PartInitException e) {
					//ConvertigoPlugin.logException(e, "Error while retrieving the sequence editor '" + editorRef.getName() + "'");
				}
			}
		}
	}
	return editorPart;
}
 
Example 27
Project: neoscada   File: AbstractConfigurationEditor.java   Source Code and License 6 votes vote down vote up
@Override
protected void setInput ( final IEditorInput input )
{
    final ConfigurationEditorInput configurationInput = (ConfigurationEditorInput)input;

    if ( !this.nested )
    {
        configurationInput.performLoad ( new NullProgressMonitor () );
    }

    this.dirtyValue = configurationInput.getDirtyValue ();
    this.dirtyValue.addValueChangeListener ( new IValueChangeListener () {

        @Override
        public void handleValueChange ( final ValueChangeEvent event )
        {
            firePropertyChange ( IEditorPart.PROP_DIRTY );
        }
    } );

    super.setInput ( input );
}
 
Example 28
Project: time4sys   File: SrmActionBarContributor.java   Source Code and License 6 votes vote down vote up
/**
 * When the active editor changes, this remembers the change and registers with it as a selection provider.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setActiveEditor(IEditorPart part) {
	super.setActiveEditor(part);
	activeEditorPart = part;

	// Switch to the new selection provider.
	//
	if (selectionProvider != null) {
		selectionProvider.removeSelectionChangedListener(this);
	}
	if (part == null) {
		selectionProvider = null;
	}
	else {
		selectionProvider = part.getSite().getSelectionProvider();
		selectionProvider.addSelectionChangedListener(this);

		// Fake a selection changed event to update the menus.
		//
		if (selectionProvider.getSelection() != null) {
			selectionChanged(new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection()));
		}
	}
}
 
Example 29
Project: Hydrograph   File: HydrographUiClientSocket.java   Source Code and License 6 votes vote down vote up
/**
 * 
 * Called by web socket server, message contain execution tracking status that updated on job canvas.
 *
 * @param message the message
 * @param session the session
 */
@OnMessage
public void updateJobTrackingStatus(String message, Session session) { 

	final String status = message; 
	Display.getDefault().asyncExec(new Runnable() {
		public void run() {
			Gson gson = new Gson();
			ExecutionStatus executionStatus=gson.fromJson(status, ExecutionStatus.class);
			IWorkbenchPage page = PlatformUI.getWorkbench().getWorkbenchWindows()[0].getActivePage();
			IEditorReference[] refs = page.getEditorReferences();
			for (IEditorReference ref : refs){
				IEditorPart editor = ref.getEditor(false);
				if(editor instanceof ELTGraphicalEditor){
					ELTGraphicalEditor editPart=(ELTGraphicalEditor)editor;
					if(editPart.getJobId().equals(executionStatus.getJobId()) || (((editPart.getContainer()!=null) && 
							(editPart.getContainer().getUniqueJobId().equals(executionStatus.getJobId()))) && editPart.getContainer().isOpenedForTracking() )){
							TrackingStatusUpdateUtils.INSTANCE.updateEditorWithCompStatus(executionStatus, (ELTGraphicalEditor)editor,false);
					}
				}
			}
		}
	});
}
 
Example 30
Project: Open_Source_ECOA_Toolset_AS5   File: IntDeploymentEditor.java   Source Code and License 6 votes vote down vote up
@Override
public void resourceChanged(IResourceChangeEvent event) {
	if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
				for (int i = 0; i < pages.length; i++) {
					if (((FileEditorInput) getEditorInput()).getFile().getProject().equals(event.getResource())) {
						IEditorPart editorPart = pages[i].findEditor(getEditorInput());
						pages[i].closeEditor(editorPart, true);
					}
				}
			}
		});
	}
}
 
Example 31
Project: gemoc-studio   File: FsmActionBarContributor.java   Source Code and License 6 votes vote down vote up
/**
 * When the active editor changes, this remembers the change and registers with it as a selection provider.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setActiveEditor(IEditorPart part) {
	super.setActiveEditor(part);
	activeEditorPart = part;

	// Switch to the new selection provider.
	//
	if (selectionProvider != null) {
		selectionProvider.removeSelectionChangedListener(this);
	}
	if (part == null) {
		selectionProvider = null;
	}
	else {
		selectionProvider = part.getSite().getSelectionProvider();
		selectionProvider.addSelectionChangedListener(this);

		// Fake a selection changed event to update the menus.
		//
		if (selectionProvider.getSelection() != null) {
			selectionChanged(new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection()));
		}
	}
}
 
Example 32
Project: n4js   File: EditorsUtil.java   Source Code and License 5 votes vote down vote up
/** If {@link IWorkbenchPage} is available, will try to force close (without save) provided editor. */
public static final void forceCloseEditor(IEditorPart editor) {
	Display.getDefault().syncExec(() -> {
		IWorkbenchPage page = unsafeGetWorkbenchPage();
		if (page != null) {
			boolean allClosed = page.closeEditor(editor, false);
			logger.info("Editor closed: " + allClosed);
		} else {
			logger.info(" Closing all editors: No active page.");
		}
	});
}
 
Example 33
Project: gw4e.project   File: UpdateEditorAction.java   Source Code and License 5 votes vote down vote up
public void openclose() {
	Job job = new WorkspaceJob("GW4E Open/Close Editor Job") {
		@Override
		public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
			Display.getDefault().syncExec(new Runnable() {
				@Override
				public void run() {
					IWorkbenchWindow ww = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
					if (ww != null) {
						IWorkbenchPage page = ww.getActivePage();
						if (page != null) {
							IEditorReference[] editors = page.getEditorReferences();
							for (IEditorReference iEditorReference : editors) {
								try {
									IEditorInput input = iEditorReference.getEditorInput();
									if (input instanceof FileEditorInput) {
										FileEditorInput feditorInput = (FileEditorInput) input;
										if (previousPath.equals(feditorInput.getFile().getFullPath())) {
											IEditorPart editorPart = iEditorReference.getEditor(false);
											page.closeEditor(editorPart, false);
											JDTManager.openEditor(currentFile,PreferenceManager.getGW4EEditorName(),null);
										}
									}
								} catch (PartInitException e) {
									ResourceManager.logException(e);
								}
							}
						}
					}
				}
			});
			return Status.OK_STATUS;
		}
	};
	job.setRule(project); // lock so that we serialize the
									// refactoring
	job.setUser(true);
	job.schedule();
}
 
Example 34
Project: n4js   File: AbstractBuilderParticipantTest.java   Source Code and License 5 votes vote down vote up
/***/
protected XtextEditor openAndGetXtextEditor(final IFile file1, final IWorkbenchPage page) {
	IEditorPart fileEditor = getFileEditor(file1, page);
	assertTrue(fileEditor instanceof XtextEditor);
	XtextEditor fileXtextEditor = (XtextEditor) fileEditor;
	return fileXtextEditor;
}
 
Example 35
Project: n4js   File: LaunchXpectShortcut.java   Source Code and License 5 votes vote down vote up
@Override
public void launch(IEditorPart editor, String mode) {
	try {
		IEditorInput editorInput = editor.getEditorInput();
		if (editorInput instanceof IFileEditorInput) {
			IFile selectObj = ((IFileEditorInput) editorInput).getFile();
			launchFile(selectObj, mode);
		} else {
			showDialogNotImplemented(editor.getClass().getName());
		}
	} catch (CoreException e) {
		System.out.println(e.getLocalizedMessage() + "\n");
	}
}
 
Example 36
Project: bdf2   File: PropEditorContributor.java   Source Code and License 5 votes vote down vote up
public void setActivePage(IEditorPart part) {
	if (activeEditorPart == part)
		return;

	activeEditorPart = part;

	IActionBars actionBars = getActionBars();
	if (actionBars != null) {

		ITextEditor editor = (part instanceof ITextEditor) ? (ITextEditor) part : null;

		actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(),
				getAction(editor, ITextEditorActionConstants.DELETE));
		actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(),
				getAction(editor, ITextEditorActionConstants.UNDO));
		actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(),
				getAction(editor, ITextEditorActionConstants.REDO));
		actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(),
				getAction(editor, ITextEditorActionConstants.CUT));
		actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(),
				getAction(editor, ITextEditorActionConstants.COPY));
		actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(),
				getAction(editor, ITextEditorActionConstants.PASTE));
		actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(),
				getAction(editor, ITextEditorActionConstants.SELECT_ALL));
		actionBars.setGlobalActionHandler(ActionFactory.FIND.getId(),
				getAction(editor, ITextEditorActionConstants.FIND));
		actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(),
				getAction(editor, IDEActionFactory.BOOKMARK.getId()));
		actionBars.updateActionBars();
	}
}
 
Example 37
Project: n4js   File: OpenGeneratedSourceInEditorHandler.java   Source Code and License 5 votes vote down vote up
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {

	final ISelection selection = getCurrentSelection(event);
	if (null == selection) {
		return null;
	}

	if (selection.isEmpty()) {
		return null;
	}

	final AtomicReference<IFile> fileRef = new AtomicReference<>();

	if (selection instanceof IStructuredSelection) {
		final Object element = ((IStructuredSelection) selection).getFirstElement();
		if (element instanceof IFile) {
			fileRef.set((IFile) element);
		}
	} else if (selection instanceof ITextSelection) {
		final IEditorPart editorPart = getActiveEditor(event);
		if (null != editorPart) {
			final IEditorInput input = editorPart.getEditorInput();
			if (input instanceof IFileEditorInput) {
				fileRef.set(((IFileEditorInput) input).getFile());
			}
		}
	}

	if (null != fileRef.get()) {
		final Optional<IFile> generatedSource = fileLocator.tryGetGeneratedSourceForN4jsFile(fileRef.get());
		if (generatedSource.isPresent()) {
			tryOpenFileInEditor(fileRef.get(), generatedSource.get());
		}
	}

	return null;
}
 
Example 38
Project: n4js   File: FileExtensionBasedPropertTester.java   Source Code and License 5 votes vote down vote up
private IFile tryGetFileFromActiveEditor() {
	final Optional<IEditorPart> editor = getActiveEditor();
	if (editor.isPresent() && editor.get().getEditorInput() instanceof IFileEditorInput) {
		return ((IFileEditorInput) editor.get().getEditorInput()).getFile();
	}
	return null;

}
 
Example 39
Project: Hydrograph   File: DeleteHandler.java   Source Code and License 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWorkbenchPart part = HandlerUtil.getActivePart(event);
	if(part instanceof CommonNavigator){
		DeleteAction action=new DeleteAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite());
		action.run();
	}
	
	else if (part instanceof ELTGraphicalEditor) {
		IEditorPart editor = HandlerUtil.getActiveEditor(event);
		((ELTGraphicalEditor) editor).deleteSelection();
		((ELTGraphicalEditor) editor).hideToolTip();
	}
	return null;
}
 
Example 40
Project: n4js   File: ChangeManager.java   Source Code and License 5 votes vote down vote up
private XtextEditor getEditor(URI uri) {
	// note: trimming fragment in previous line makes this more stable in case of changes to the
	// Xtext editor's contents (we are not interested in a particular element, just the editor)
	final URI uriToEditor = uri != null ? uri.trimFragment() : null;
	if (uriToEditor != null) {
		final IEditorPart editor = getEditorOpener().open(uriToEditor, false);
		if (editor instanceof XtextEditor)
			return (XtextEditor) editor;
	}
	return null;
}
 
Example 41
Project: Tarski   File: LoadSpecificationFromEditorHandler.java   Source Code and License 5 votes vote down vote up
@Override
public String getFilePath() {
  IEditorPart editor;
  editor = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage()
      .getActiveEditor();
  String result = null;
  final IFile file = ResourceUtil.getFile(editor.getEditorInput());
  result = file.getLocation().makeAbsolute().toOSString();
  return result;
}
 
Example 42
Project: n4js   File: TestDiscoveryUIUtils.java   Source Code and License 5 votes vote down vote up
/**
 * Derives a location URI as expected by {@link TestDiscoveryHelper#collectTests(URI...)} from an editor.
 */
public static final URI getLocationForEditor(IEditorPart editor) {
	final IEditorInput input = editor.getEditorInput();
	if (input instanceof IFileEditorInput)
		return getLocationForEditorInput((IFileEditorInput) input);
	return null;
}
 
Example 43
Project: ec4e   File: EditorTracker.java   Source Code and License 5 votes vote down vote up
private void editorClosed(IEditorPart part) {
	if (part instanceof AbstractTextEditor) {
		ApplyEditorConfig apply = applies.remove(part);
		if (apply != null) {
			apply.uninstall();
			Assert.isTrue(null == applies.get(part),
					"An old ApplyEditorConfig is not un-installed on Text Editor instance");
		}
	}
}
 
Example 44
Project: avro-schema-editor   File: UIUtils.java   Source Code and License 5 votes vote down vote up
public static AvroSchemaEditor pickAvroSchemaEditorFromEditorParts() {
  	
  	AvroSchemaEditor editor = null;
  	
  	List<IEditorReference> schemaEditorRefList = new ArrayList<>();

IEditorReference[] editorReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
for (IEditorReference editorRef : editorReferences) {
	IEditorPart editorPart = editorRef.getEditor(false);
	if (editorPart != null && editorPart instanceof IWithAvroSchemaEditor) {
		schemaEditorRefList.add(editorRef);
	}
}

if (schemaEditorRefList.size() == 1) {
	editor = ((IWithAvroSchemaEditor) schemaEditorRefList.get(0).getEditor(false)).getEditor();
} else if (schemaEditorRefList.size() > 1) {
	// we have to ask the user to choose an editor
	// with a dialog
	ListDialog dialog = new ListDialog(Display.getCurrent().getActiveShell());
	dialog.setLabelProvider(new LabelProvider() {				
		@Override
		public String getText(Object element) {
			return ((IEditorReference) element).getPartName();
		}
	});
	dialog.setContentProvider(new ArrayContentProvider());
	dialog.setInput(schemaEditorRefList);
	int result = dialog.open();
	if (result == ListDialog.OK) {
		Object[] selectedEditor = dialog.getResult();
		IEditorReference selectedEditorRef = (IEditorReference) selectedEditor[0];
		editor = ((IWithAvroSchemaEditor) selectedEditorRef.getEditor(false)).getEditor();
	}
}		
  	
return editor;

  }
 
Example 45
Project: Hydrograph   File: SelectAllHandler.java   Source Code and License 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

	IEditorPart editor = HandlerUtil.getActiveEditor(event);
	if (editor instanceof ELTGraphicalEditor)
		((ELTGraphicalEditor) editor).selectAllSelection();

	return null;
}
 
Example 46
Project: ContentAssist   File: EditorUtilities.java   Source Code and License 5 votes vote down vote up
/**
 * Obtains the styled text of an editor.
 * @param editor the editor
 * @return the styled text of the editor
 */
public static StyledText getStyledText(IEditorPart editor) {
    ISourceViewer viewer = getSourceViewer(editor);
    if (viewer != null) {
        return viewer.getTextWidget();
    }
    return null;
}
 
Example 47
Project: vertigo-chroma-kspplugin   File: UiUtils.java   Source Code and License 5 votes vote down vote up
public static IFile getEditorFile(IEditorPart editor) {
	if (editor == null) {
		return null;
	}
	IEditorInput editorInput = editor.getEditorInput();
	if (!(editorInput instanceof FileEditorInput)) {
		return null;
	}

	FileEditorInput fileInput = (FileEditorInput) editorInput;

	return fileInput.getFile();
}
 
Example 48
Project: ContentAssist   File: EditorUtilities.java   Source Code and License 5 votes vote down vote up
/**
 * Obtains the document of a file existing on an editor.
 * @param editor the editor
 * @return the document of the file, or <code>null</code> if none
 */
public static IDocument getDocument(IEditorPart editor) {
    IFile file = getInputFile(editor);
    if (file != null) {
        return getDocument(file);
    }
    return null;
}
 
Example 49
Project: ContentAssist   File: EditorUtilities.java   Source Code and License 5 votes vote down vote up
/**
 * Obtains the contents of source code appearing in an editor.
 * @param editor the editor
 * @return the contents of the source code, or <code>null</code> if the source code is not valid
 */
public static String getSourceCode(IEditorPart editor) {
    IDocument doc = getDocument(editor);
    if (doc != null) {
        return doc.get();
    }
    return null;
}
 
Example 50
Project: avro-schema-editor   File: SearchNodeControl.java   Source Code and License 5 votes vote down vote up
protected void refreshCommands(IEditorPart editorPart, String... properties) {
IEvaluationService evalService = (IEvaluationService) editorPart.getEditorSite().getService(IEvaluationService.class);
if (evalService != null) {
	for (String property: properties) {
		evalService.requestEvaluation(property);
	}
}        
  }
 
Example 51
Project: ContentAssist   File: EditorUtilities.java   Source Code and License 5 votes vote down vote up
/**
 * Obtains an editor that is currently active.
 * @return the active editor, or <code>null</code> if none
 */
public static IEditorPart getActiveEditor() {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window != null) {
        IEditorPart part = window.getActivePage().getActiveEditor();
        return part;
    }
    return null;
}
 
Example 52
Project: ContentAssist   File: EditorUtilities.java   Source Code and License 5 votes vote down vote up
/**
 * Obtains the path of a active file existing on an editor.
 * @return the path of the file, which is relative to the path of the workspace
 */
public static String getActiveInputFilePath() {
    IEditorPart editor = getActiveEditor();
    if (editor != null) {
        return getInputFilePath(editor);
    }
    return null;
}
 
Example 53
Project: ide-plugins   File: InsertGluonFunctionHandler.java   Source Code and License 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (activeWorkbenchWindow == null) {
        return null;
    }
    IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
    if (activePage == null) {
        return null;
    }
    IEditorPart editor = activePage.getActiveEditor();
    if (editor == null) {
        return null;
    }
    IEditorInput input = editor.getEditorInput();
    if (input == null || ! (input instanceof FileEditorInput)) {
        return null;
    }
    IFile file = ((FileEditorInput) input).getFile();
    if (file != null && file.getType() == IResource.FILE && file.getFileExtension().equals("java")) {
        utils = new ProjectUtils(file.getProject());
        if (utils.isGluonMobileProject()) {
            ISelection selection = HandlerUtil.getCurrentSelection(event);
            Display.getDefault().asyncExec(() -> new JCode(utils, selection,  (JavaEditor) editor));
        }
    }
    return null;
}
 
Example 54
Project: ide-plugins   File: InsertFunctionTester.java   Source Code and License 5 votes vote down vote up
@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
    if ("gluonMobileFound".equals(property)) {
        try {
            IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
            if (activeWorkbenchWindow == null) {
                return false;
            }
            IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
            if (activePage == null) {
                return false;
            }
            IWorkbenchPart activePart = activePage.getActivePart();
            if (activePart == null || ! (activePart instanceof CompilationUnitEditor)) {
                return false;
            }
            IEditorPart editor = activePage.getActiveEditor();
            if (editor == null) {
                return false;
            }
            IEditorInput input = editor.getEditorInput();
            if (input == null || ! (input instanceof FileEditorInput)) {
                return false;
            }
            IFile file = ((FileEditorInput) input).getFile();
            if (file != null && file.getType() == IResource.FILE && file.getFileExtension().equals("java")) {
                ProjectUtils utils = new ProjectUtils(file.getProject());
            return utils.isGluonMobileProject();
            }
        } catch (Exception e) { }
    }
    return false;
}
 
Example 55
Project: eclipse-jenkins-editor   File: JenkinsEditorPreferences.java   Source Code and License 5 votes vote down vote up
protected void updateEditorColors(IEditorPart editor) {
	if (! (editor instanceof JenkinsEditor)){
		return;
	}
	JenkinsEditor geditor = (JenkinsEditor) editor;
	geditor.handleColorSettingsChanged();
}
 
Example 56
Project: visuflow-plugin   File: JavaToCFGHandler.java   Source Code and License 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
	IFileEditorInput input = (IFileEditorInput) part.getEditorInput();
	IFile file = input.getFile();
	if (part instanceof ITextEditor) {
		final ITextEditor editor = (ITextEditor) part;
		IVerticalRulerInfo ruleInfo = editor.getAdapter(IVerticalRulerInfo.class);
		IDocumentProvider provider = editor.getDocumentProvider();
		IDocument document = provider.getDocument(editor.getEditorInput());
		int lineNumber = ruleInfo.getLineOfLastMouseButtonActivity();
		String className = file.getName().substring(0, file.getName().lastIndexOf('.'));
		HashMap<VFUnit, VFMethod> resultantUnit = getSelectedUnit(className, document, lineNumber);
		List<VFNode> unit = new ArrayList<>();
		if (resultantUnit.size() > 0) {
			if (event.getCommand().getId().equals("JavaHandler.NavigateToJimple")) {
				NavigationHandler handler = new NavigationHandler();
				handler.highlightJimpleSource(new ArrayList<>(resultantUnit.keySet()));
			} else {
				for (VFUnit vfUnit : resultantUnit.keySet()) {
					unit.add(new VFNode(vfUnit, 0));
				}
				try {
					ServiceUtil.getService(DataModel.class).filterGraph(unit, true, true, null);

				} catch (Exception e) {
					e.printStackTrace();
				}
			}

		}

		// call graph highlighting code here
	} else {
		logger.error("Editor not a  Text Editor");
	}
	return null;
}
 
Example 57
Project: gemoc-studio-modeldebugging   File: DSLDebugModelPresentation.java   Source Code and License 5 votes vote down vote up
@Override
public boolean addAnnotations(IEditorPart editorPart, IStackFrame frame) {
	if (frame instanceof DSLStackFrameAdapter) {
		changeCurrentStackFrame(frame);
		if (editorPart instanceof DialectEditor) {
			final EObject instruction = ((DSLStackFrameAdapter)frame).getCurrentInstruction();
			SiriusEditorUtils.showInstruction((DialectEditor)editorPart, instruction);
		} else {
			super.addAnnotations(editorPart, frame);
		}
	}

	return true;
}
 
Example 58
Project: eclipse-bash-editor   File: BashEditorUtil.java   Source Code and License 5 votes vote down vote up
public static void removeScriptErrors(IEditorPart editor) {
	if (editor == null) {
		return;
	}
	IEditorInput input = editor.getEditorInput();
	if (input == null) {
		return;
	}
	IResource editorResource = input.getAdapter(IResource.class);
	if (editorResource == null) {
		return;
	}
	scriptProblemMarkerHelper.removeMarkers(editorResource);
}
 
Example 59
Project: neoscada   File: ItemActionBarContributor.java   Source Code and License 5 votes vote down vote up
/**
 * When the active editor changes, this remembers the change and registers with it as a selection provider.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setActiveEditor ( IEditorPart part )
{
    super.setActiveEditor ( part );
    activeEditorPart = part;

    // Switch to the new selection provider.
    //
    if ( selectionProvider != null )
    {
        selectionProvider.removeSelectionChangedListener ( this );
    }
    if ( part == null )
    {
        selectionProvider = null;
    }
    else
    {
        selectionProvider = part.getSite ().getSelectionProvider ();
        selectionProvider.addSelectionChangedListener ( this );

        // Fake a selection changed event to update the menus.
        //
        if ( selectionProvider.getSelection () != null )
        {
            selectionChanged ( new SelectionChangedEvent ( selectionProvider, selectionProvider.getSelection () ) );
        }
    }
}
 
Example 60
Project: eclipse-batch-editor   File: BatchEditorUtil.java   Source Code and License 5 votes vote down vote up
public static void removeScriptErrors(IEditorPart editor) {
	if (editor == null) {
		return;
	}
	IEditorInput input = editor.getEditorInput();
	if (input == null) {
		return;
	}

}