本文整理汇总了Java中org.eclipse.ui.IEditorPart类的典型用法代码示例。如果您正苦于以下问题:Java IEditorPart类的具体用法?Java IEditorPart怎么用?Java IEditorPart使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IEditorPart类属于org.eclipse.ui包,在下文中一共展示了IEditorPart类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resourceChanged
import org.eclipse.ui.IEditorPart; //导入依赖的package包/类
@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);
}
}
}
});
}
}
示例2: getFileEditor
import org.eclipse.ui.IEditorPart; //导入依赖的package包/类
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;
}
示例3: computeInitialPattern
import org.eclipse.ui.IEditorPart; //导入依赖的package包/类
/**
* 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 "";
}
示例4: activateEditor
import org.eclipse.ui.IEditorPart; //导入依赖的package包/类
@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);
}
示例5: setActiveEditor
import org.eclipse.ui.IEditorPart; //导入依赖的package包/类
/**
* 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()));
}
}
}
示例6: getOpenEditorOfMarker
import org.eclipse.ui.IEditorPart; //导入依赖的package包/类
/**
* 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;
}
示例7: getEditors
import org.eclipse.ui.IEditorPart; //导入依赖的package包/类
/**
* 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;
}
示例8: ITrace
import org.eclipse.ui.IEditorPart; //导入依赖的package包/类
/**
* 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);
}
示例9: selectInstruction
import org.eclipse.ui.IEditorPart; //导入依赖的package包/类
/**
* 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));
}
}
}
}
示例10: propertyChanged
import org.eclipse.ui.IEditorPart; //导入依赖的package包/类
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());
}
}
}
示例11: openSequenceEditor
import org.eclipse.ui.IEditorPart; //导入依赖的package包/类
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() + "'");
}
}
}
}
}
示例12: openDashboard
import org.eclipse.ui.IEditorPart; //导入依赖的package包/类
/**
* 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);
}
}
}
示例13: getJscriptTransactionEditor
import org.eclipse.ui.IEditorPart; //导入依赖的package包/类
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;
}
示例14: execute
import org.eclipse.ui.IEditorPart; //导入依赖的package包/类
@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;
}
示例15: canRun
import org.eclipse.ui.IEditorPart; //导入依赖的package包/类
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;
}