类org.eclipse.ui.part.EditorPart源码实例Demo

下面列出了怎么用org.eclipse.ui.part.EditorPart的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: gef   文件: DotGraphView.java
/**
 * if the active editor is the DOT Editor, update the graph, otherwise
 * do nothing
 */
private void checkActiveEditorAndUpdateGraph(IWorkbenchPart part) {
	if (DotEditorUtils.isDotEditor(part)) {
		IEditorInput editorInput = ((EditorPart) part).getEditorInput();
		if (editorInput instanceof FileEditorInput) {
			IFile file = ((FileEditorInput) editorInput).getFile();
			try {
				File resolvedFile = DotFileUtils
						.resolve(file.getLocationURI().toURL());
				if (!resolvedFile.equals(currentFile)) {
					updateGraph(resolvedFile);
				}
			} catch (MalformedURLException e) {
				DotActivatorEx.logError(e);
			}
		}
	}
}
 
/**
 * This method will get the DesignerProject for the current XPage and return it. 
 * @param compEditor
 * @return
 */
private DesignerProject getDesignerProjectForEditor(CompositeEditor compEditor){
    IWorkbenchPart part = super.getWorkBenchPart();
    if(part instanceof EditorPart){
        EditorPart editor = (EditorPart)part;
        IEditorInput input = editor.getEditorInput();
        if(input instanceof IFileEditorInput){
            IFileEditorInput fileInput = (IFileEditorInput)input;
            IFile xpageFile = fileInput.getFile();
            if(null != xpageFile){
                IProject project = xpageFile.getProject();
                if(null != project){
                    DesignerProject designerProj = DesignerResource.getDesignerProject(project);
                    if(null != designerProj){
                        return designerProj;
                    }
                }
            }
        }
    }
    return null;
}
 
源代码3 项目: gef   文件: SyncGraphvizExportHandler.java
/**
 * if the active editor is the DOT Editor, export the graph, otherwise do
 * nothing
 */
private void checkActiveEditorAndExportGraph(IWorkbenchPart part) {
	if (DotEditorUtils.isDotEditor(part)) {
		IEditorInput editorInput = ((EditorPart) part).getEditorInput();
		if (editorInput instanceof FileEditorInput) {
			IFile file = ((FileEditorInput) editorInput).getFile();
			exportGraph(file);
		}
	}
}
 
源代码4 项目: ermasterr   文件: ERDiagramActionBarContributor.java
public void initRetargetActions(final EditorPart newEditor) {
    final Iterator iter = getActionRegistry().getActions();

    while (iter.hasNext()) {
        final IAction action = (IAction) iter.next();
        if (action instanceof RetargetAction) {
            ((RetargetAction) action).partActivated(newEditor);
        }
    }
}
 
源代码5 项目: jbt   文件: BTEditor.java
/**
 * 
 * @see org.eclipse.ui.part.EditorPart#doSaveAs()
 */
public void doSaveAs() {
	/* First, check if the tree has no structural errors. */
	if (!checkTree()) {
		StandardDialogs.errorDialog("Tree not saved",
				"Errors were detected while validating the tree");
		return;
	}

	SaveBTAsAction action = new SaveBTAsAction(this.tree, this.getEditorInput().getName());

	try {
		action.run();
		if (action.getSelectedFile() != null) {
			BTEditorInput editorInput = (BTEditorInput) getEditorInput();
			editorInput.setTreeName(action.getSelectedFile());
			this.dirty = false;
			setIsFromFile(true);

			/*
			 * If the tree comes from a guard, it must be dissociated from
			 * its original tree. From then on, this BTEditor will be
			 * managed as a normal BTEditor.
			 */
			if (isFromGuard()) {
				dissociateFromParentTree();
			}

			setPartName(editorInput.getName());

			firePropertyChange(EditorPart.PROP_DIRTY);
			firePropertyChange(PROP_TITLE);
		}
	} catch (Exception e) {
		StandardDialogs.exceptionDialog("Error saving the tree",
				"There was an error when saving the tree", e);
	}
}
 
源代码6 项目: tesb-studio-se   文件: SaveAsRoutesAction.java
public SaveAsRoutesAction(EditorPart editorPart) {
    this.editorPart = editorPart;
}
 
源代码7 项目: jbt   文件: BTEditor.java
/**
 * 
 * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
 */
public void doSave(IProgressMonitor monitor) {
	/* First, check if the tree has no structural errors. */
	if (!checkTree()) {
		StandardDialogs.errorDialog("Tree not saved",
				"Errors were detected while validating the tree");
		monitor.setCanceled(true);
		return;
	}

	/*
	 * The save the tree.
	 */
	try {
		if (this.isFromFile()) {
			/* If the tree comes from a file, save the tree into a file. */
			new SaveBTAction(this.tree, ((BTEditorInput) getEditorInput()).getTreeName()).run();
			this.dirty = false;
			firePropertyChange(EditorPart.PROP_DIRTY);
		} else if (this.isFromGuard()) {
			/*
			 * If the tree comes from a guard, then set the tree as a guard
			 * of the "this.guardNode". Note that we set a clone of the
			 * guard, not the original one. By doing so, the guard of the
			 * original node will not be modified even if this editor's tree
			 * is modified.
			 */
			BTNode guard = this.tree.getRoot().getChildren().get(0);
			if (guard != null) {
				this.guardNode.setGuard(guard.clone());
				this.guardTree.fireTreeChanged(this);
				BTEditorInput editorInput = (BTEditorInput) this.getEditorInput();
				Utilities.getBTEditor(Long.parseLong(editorInput.getTreeName().split(
						File.pathSeparator)[0])).viewer.refresh();
			}
			this.dirty = false;
			firePropertyChange(EditorPart.PROP_DIRTY);
		} else {
			/* Otherwise, do a save as. */
			doSaveAs();
		}
	} catch (Exception e) {
		StandardDialogs.exceptionDialog("Tree not saved",
				"Errors were detected while saving the tree", e);
		monitor.setCanceled(true);
	}
}
 
源代码8 项目: jbt   文件: BTEditor.java
/**
 * 
 * @see jbt.tools.bteditor.event.ITreeModifierListener#treeModified(jbt.tools.bteditor.event.TreeModifiedEvent)
 */
public void treeModified(TreeModifiedEvent event) {
	this.dirty = true;
	firePropertyChange(EditorPart.PROP_DIRTY);
}
 
源代码9 项目: jbt   文件: Utilities.java
/**
 * Activates an editor.
 * 
 * @param editor
 *            the editor to activate.
 */
public static void activateEditor(EditorPart editor) {
	IWorkbenchPage page = editor.getSite().getPage();
	page.activate(editor);
}
 
 类所在包
 同包方法