当前位置: 首页>>代码示例>>Java>>正文


Java IEditorPart类代码示例

本文整理汇总了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);
					}
				}
			}
		});
	}
}
 
开发者ID:dstl,项目名称:Open_Source_ECOA_Toolset_AS5,代码行数:17,代码来源:IntLogicalSysEditor.java

示例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;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:21,代码来源:AbstractBuilderParticipantTest.java

示例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 "";
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:26,代码来源:OpenTypeSelectionDialogHandler.java

示例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);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:23,代码来源:N4JSResourceLinkHelper.java

示例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()));
		}
	}
}
 
开发者ID:occiware,项目名称:OCCI-Studio,代码行数:31,代码来源:SlaActionBarContributor.java

示例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;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:31,代码来源:MarkerFactory.java

示例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;
}
 
开发者ID:liaoziyang,项目名称:ContentAssist,代码行数:25,代码来源:EditorUtilities.java

示例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);
 }
 
开发者ID:SERESLab,项目名称:iTrace-Archive,代码行数:25,代码来源:ITrace.java

示例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));
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:24,代码来源:EMFEditorUtils.java

示例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());
		}
	}
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:25,代码来源:XslRuleEditor.java

示例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() + "'");
				}
			}
		}
	}
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:24,代码来源:SequenceTreeObject.java

示例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);
		}
	}
}
 
开发者ID:polarsys,项目名称:time4sys,代码行数:33,代码来源:AbstractNewModelWizard.java

示例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;
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:26,代码来源:MyAbstractAction.java

示例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;
}
 
开发者ID:de-jcup,项目名称:eclipse-bash-editor,代码行数:22,代码来源:AbstractBashEditorHandler.java

示例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;

    }
 
开发者ID:baloise,项目名称:eZooKeeper,代码行数:27,代码来源:BaseAction.java


注:本文中的org.eclipse.ui.IEditorPart类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。