org.eclipse.ui.part.EditorPart Java Examples

The following examples show how to use org.eclipse.ui.part.EditorPart. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DotGraphView.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * 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);
			}
		}
	}
}
 
Example #2
Source File: AbstractDesignElementPicker.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #3
Source File: SyncGraphvizExportHandler.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * 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);
		}
	}
}
 
Example #4
Source File: ERDiagramActionBarContributor.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
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);
        }
    }
}
 
Example #5
Source File: BTEditor.java    From jbt with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * @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);
	}
}
 
Example #6
Source File: SaveAsRoutesAction.java    From tesb-studio-se with Apache License 2.0 4 votes vote down vote up
public SaveAsRoutesAction(EditorPart editorPart) {
    this.editorPart = editorPart;
}
 
Example #7
Source File: BTEditor.java    From jbt with Apache License 2.0 4 votes vote down vote up
/**
 * 
 * @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);
	}
}
 
Example #8
Source File: BTEditor.java    From jbt with Apache License 2.0 4 votes vote down vote up
/**
 * 
 * @see jbt.tools.bteditor.event.ITreeModifierListener#treeModified(jbt.tools.bteditor.event.TreeModifiedEvent)
 */
public void treeModified(TreeModifiedEvent event) {
	this.dirty = true;
	firePropertyChange(EditorPart.PROP_DIRTY);
}
 
Example #9
Source File: Utilities.java    From jbt with Apache License 2.0 2 votes vote down vote up
/**
 * Activates an editor.
 * 
 * @param editor
 *            the editor to activate.
 */
public static void activateEditor(EditorPart editor) {
	IWorkbenchPage page = editor.getSite().getPage();
	page.activate(editor);
}