⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 id3editor.java

📁 eclise rcp 项目,是非常好的学习源码
💻 JAVA
字号:
/*******************************************************************************
 * Copyright (c) 2007 Siemens AG
 * 
 * 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:
 *    Kai T鰀ter - initial API and implementation
 *******************************************************************************/

package com.siemens.ct.mp3m.ui.editors.id3;

import java.io.File;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPathEditorInput;
import org.eclipse.ui.forms.editor.FormEditor;

import com.siemens.ct.mp3m.model.IMP3Info;
import com.siemens.ct.mp3m.model.MP3Infos;
import com.siemens.ct.mp3m.model.logical.Artists;
import com.siemens.ct.mp3m.utilities.LogUtil;

public class Id3Editor extends FormEditor {
    public static final String ID = "com.siemens.ct.mp3m.ui.editors.ids.Id3Editor"; //$NON-NLS-1$

    private String fullPath;

    private Id3TagPage tagPage;

    public Id3Editor() {
    }

    @Override
    protected void addPages() {
        try {
            IMP3Info mp3Info = MP3Infos.getMP3Info(fullPath);
            tagPage = new Id3TagPage(
                    this,
                    Id3Editor.ID,
                    Messages.getString("Id3Editor.Song_Info"), fullPath, mp3Info, Id3TagPage.SONG_INFO); //$NON-NLS-1$
            addPage(tagPage);
            addPage(new Id3TagPage(
                    this,
                    Id3Editor.ID,
                    Messages.getString("Id3Editor.Tech_Info"), fullPath, mp3Info, Id3TagPage.TECH_INFO)); //$NON-NLS-1$

        } catch (Exception e) {
        	LogUtil.logError("com.siemens.ct.mp3m.ui.editors.id3",e);
        }
    }

    @Override
    public void doSave(IProgressMonitor monitor) {
        tagPage.doSave(monitor);
        editorDirtyStateChanged();
        Artists.recomputeModel();
    }

    @Override
    public void doSaveAs() {
        // to be implemented
    }

    @Override
    public boolean isSaveAsAllowed() {
        return false;
    }

    protected void setInput(IEditorInput input) {
        super.setInput(input);

        if (input instanceof IPathEditorInput) {
            fullPath = ((IPathEditorInput) input).getPath().toOSString();
            String title = fullPath;
            int index = fullPath.lastIndexOf(File.separatorChar);
            if (index != -1) {
                title = fullPath.substring(index + 1);
            }
            setPartName(title);
        }  else {
             IFile file = (IFile) input.getAdapter(IFile.class);
             if(file != null) {
                 fullPath = file.getRawLocation().toPortableString();
             }
        }
    }

    /**
     * Gets the fullPath.
     * 
     * @return Returns the fullPath.
     */
    public String getFullPath() {
        return fullPath;
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.eclipse.ui.forms.editor.FormEditor#isDirty()
     */

    @Override
    public boolean isDirty() {
        return tagPage.isDirty();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -