alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*******************************************************************************
 * Copyright (c) 2000, 2006 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.pde.internal.ui.editor;

import java.io.File;
import org.eclipse.core.resources.IStorage;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.pde.internal.ui.PDEPlugin;
import org.eclipse.ui.*;

public class SystemFileEditorInput implements IStorageEditorInput, IPersistableElement {
	private SystemFileStorage storage;
	private static final String FACTORY_ID = PDEPlugin.getPluginId() + ".systemFileEditorInputFactory"; //$NON-NLS-1$

	public SystemFileEditorInput(File file) {
		storage = new SystemFileStorage(file);
	}

	public boolean exists() {
		return storage.getFile().exists();
	}

	public Object getAdapter(Class adapter) {
		if (adapter.equals(File.class))
			return storage.getFile();
		return null;
	}

	public ImageDescriptor getImageDescriptor() {
		return null;
	}

	public String getName() {
		return storage.getFile().getName();
	}

	public IPersistableElement getPersistable() {
		return this;
	}

	public void saveState(IMemento memento) {
		memento.putString("path", storage.getFile().getAbsolutePath()); //$NON-NLS-1$
	}

	public String getFactoryId() {
		return FACTORY_ID;
	}

	public IStorage getStorage() {
		return storage;
	}

	public String getToolTipText() {
		return storage.getFile().getAbsolutePath();
	}

	public boolean equals(Object object) {
		return object instanceof SystemFileEditorInput && getStorage().equals(((SystemFileEditorInput) object).getStorage());
	}

	public int hashCode() {
		return getStorage().hashCode();
	}
}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.