Java Code Examples for org.eclipse.ui.IEditorInput#getName()

The following examples show how to use org.eclipse.ui.IEditorInput#getName() . 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: TestEditor.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
private void initializeTitle(final IEditorInput input) {

        final Image oldImage = fTitleImage;
        fTitleImage = null;
        String title = ""; //$NON-NLS-1$

        if (input != null) {
            final IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry();
            final IEditorDescriptor editorDesc = editorRegistry.findEditor(getSite().getId());
            final ImageDescriptor imageDesc = editorDesc != null ? editorDesc.getImageDescriptor() : null;

            fTitleImage = imageDesc != null ? imageDesc.createImage() : null;
            title = input.getName();
        }

        setTitleImage(fTitleImage);
        setPartName(title);

        firePropertyChange(PROP_DIRTY);

        if (oldImage != null && !oldImage.isDisposed())
            oldImage.dispose();
    }
 
Example 2
Source File: ImageViewer.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Set the part name based on the editor input.
 */
void setPartName(final IEditorInput input) {
	String imageName = null;
	if (input instanceof IStorageEditorInput) {
		try {
			imageName = ((IStorageEditorInput) input).getStorage().getName();
		} catch (final CoreException ex) {
			// intentionally blank
		}
	}
	// this will catch ImageDataEditorInput as well
	if (imageName == null) {
		imageName = input.getName();
	}
	if (imageName == null) {
		imageName = getSite().getRegisteredName();
	}
	setPartName(imageName);
}
 
Example 3
Source File: ResolveTreeConflictWizard.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void partClosed(IWorkbenchPartReference partRef) {
	IWorkbenchPart part = partRef.getPart(false);
	if (part instanceof CompareEditor) {
		CompareEditor editor = (CompareEditor)part;
		IEditorInput input = editor.getEditorInput();
		String name = input.getName();
		if (name != null && name.startsWith(compareName)) {
			targetPart.getSite().getPage().removePartListener(this);
			if (MessageDialog.openQuestion(getShell(), Messages.ResolveTreeConflictWizard_editorClosed, Messages.ResolveTreeConflictWizard_promptToReolve + treeConflict.getResource().getName() + "?")) { //$NON-NLS-1$
				ResolveTreeConflictWizard wizard = new ResolveTreeConflictWizard(treeConflict, targetPart);
				WizardDialog dialog = new SizePersistedWizardDialog(Display.getDefault().getActiveShell(), wizard, "ResolveTreeConflict"); //$NON-NLS-1$
				dialog.open();
			}
		}
	}
}
 
Example 4
Source File: EditorUtility.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public static String getEditorID(IEditorInput input) throws PartInitException {
	Assert.isNotNull(input);
	if (input instanceof IFileEditorInput)
		return IDE.getEditorDescriptor(((IFileEditorInput)input).getFile()).getId();

	String name= input.getName();

	if (input instanceof IClassFileEditorInput) {
		boolean hasSource;
		try {
			hasSource= ((IClassFileEditorInput) input).getClassFile().getSourceRange() != null;
		} catch (JavaModelException e) {
			hasSource= false;
		}

		if (!hasSource)
			name= "*.class without source"; //$NON-NLS-1$
	}

	return IDE.getEditorDescriptor(name).getId();
}
 
Example 5
Source File: JavaSpellingReconcileStrategy.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public void accept(SpellingProblem problem) {
	IProblemRequestor requestor= fRequestor;
	if (requestor != null) {
		try {
			int line= getDocument().getLineOfOffset(problem.getOffset()) + 1;
			String word= getDocument().get(problem.getOffset(), problem.getLength());
			boolean dictionaryMatch= false;
			boolean sentenceStart= false;
			if (problem instanceof JavaSpellingProblem) {
				dictionaryMatch= ((JavaSpellingProblem)problem).isDictionaryMatch();
				sentenceStart= ((JavaSpellingProblem) problem).isSentenceStart();
			}
			// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=81514
			IEditorInput editorInput= fEditor.getEditorInput();
			if (editorInput != null) {
				CoreSpellingProblem iProblem= new CoreSpellingProblem(problem.getOffset(), problem.getOffset() + problem.getLength() - 1, line, problem.getMessage(), word, dictionaryMatch, sentenceStart, getDocument(), editorInput.getName());
				requestor.acceptProblem(iProblem);
			}
		} catch (BadLocationException x) {
			// drop this SpellingProblem
		}
	}
}
 
Example 6
Source File: TestEditor.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
private void initializeTitle(IEditorInput input) {

		Image oldImage = fTitleImage;
		fTitleImage = null;
		String title = ""; //$NON-NLS-1$

		if (input != null) {
			IEditorRegistry editorRegistry = PlatformUI.getWorkbench()
					.getEditorRegistry();
			IEditorDescriptor editorDesc = editorRegistry.findEditor(getSite()
					.getId());
			ImageDescriptor imageDesc = editorDesc != null ? editorDesc
					.getImageDescriptor() : null;

			fTitleImage = imageDesc != null ? imageDesc.createImage() : null;
			title = input.getName();
		}

		setTitleImage(fTitleImage);
		setPartName(title);

		firePropertyChange(PROP_DIRTY);

		if (oldImage != null && !oldImage.isDisposed())
			oldImage.dispose();
	}
 
Example 7
Source File: SaveUtils.java    From txtUML with Eclipse Public License 1.0 5 votes vote down vote up
public static ArrayList<IEditorPart> getAffectedDirtyEditors(String projectName, String modelName,
		Iterable<String> descriptions) {
	HashSet<String> packageElements = getPackageElements(projectName, modelName, descriptions);
	IEditorPart[] dirtyEditors = getDitryEditors();
	ArrayList<IEditorPart> affectedEditors = new ArrayList<IEditorPart>(dirtyEditors.length);

	for (IEditorPart part : dirtyEditors) {
		IEditorInput input = part.getEditorInput();

		if (input instanceof IFileEditorInput) {
			IJavaElement javaPackage = JavaCore.create(((IFileEditorInput) input).getFile().getParent());
			if (javaPackage == null) {
				continue;
			}

			String packageName = javaPackage.getElementName();
			String fileName = input.getName();
			String fullName = packageName + "." + fileName;

			if (packageElements.contains(fullName)) {
				affectedEditors.add(part);
			}
		}
	}

	return affectedEditors;
}
 
Example 8
Source File: PreviewCascadingMenuGroup.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private boolean isEnable( )
{
	IEditorPart editor = UIUtil.getActiveEditor( true );
	if ( editor == null )
	{
		return false;
	}
	IEditorInput input = editor.getEditorInput();
	if ( input == null )
	{
		return false;
	}
	String name = input.getName();
	if ( name == null )
	{
		return false;
	}
	IContentTypeManager manager = Platform.getContentTypeManager();
	if ( manager != null )
	{
		IContentType[] contentTypes = Platform.getContentTypeManager( )
				.findContentTypesFor( editor.getEditorInput( ).getName( ) );
		for ( IContentType type : contentTypes )
		{
			if ( type.getId( )
					.equals( "org.eclipse.birt.report.designer.ui.editors.reportdesign" ) //$NON-NLS-1$
					|| type.getId( )
							.equals( "org.eclipse.birt.report.designer.ui.editors.reporttemplate" ) ) //$NON-NLS-1$
				return true;
		}
	}
	return false;
}
 
Example 9
Source File: PySourceLocator.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public String getEditorId(IEditorInput input, Object element) {
    String name = input.getName();
    if (PythonPathHelper.isValidSourceFile(name)) {
        return PyEdit.EDITOR_ID;
    }
    String ret = EditorUtils.getEditorId(input, element);
    if (ret == null) {
        //If not found, use the pydev editor by default.
        ret = PyEdit.EDITOR_ID;
    }
    return ret;
}
 
Example 10
Source File: PyToggleTargetAdapter.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public static boolean canToggleFor(ITextEditor iTextEditor) {
    IEditorInput editorInput = iTextEditor.getEditorInput();
    if (editorInput != null) {
        String name = editorInput.getName();
        if (name != null) {
            if (name.endsWith(".html") || name.endsWith(".htm") || name.endsWith(".djhtml")) {
                //System.err.println("PyToggleTargetAdapter.getAdapter: " + iTextEditor);
                return true;
            }
        }
    }
    return false;
}
 
Example 11
Source File: ResourceElementEvent.java    From scava with Eclipse Public License 2.0 4 votes vote down vote up
public ResourceElementEvent(IEditorInput input, ResourceElementStateType type) {
	title = input.getName();
	this.type = type;
}