📄 playlistviewer.java
字号:
/*******************************************************************************
* Copyright (c) 2004 Berthold Daum. All rights reserved. This program and the
* accompanying materials are made available under the terms of the Common
* Public License v1.0 which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors: Berthold Daum
******************************************************************************/
package com.bdaum.jukebox;
import java.io.File;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.*;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.*;
import org.eclipse.swt.dnd.DropTarget;
import org.eclipse.swt.dnd.DropTargetListener;
import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
/**
* This class implements a viewer for playlists.
*/
public class PlaylistViewer extends TableViewer {
// File extension for for playlists
public final static String PLS = ".jpl";
// Filter for the selection of playlist files
public final static String[] PLAYLISTEXTENSIONS = new String[]{"*"
+ PLS};
// Filter for the selection of sound files
public final static String[] SOUNDEXTENSIONS = new String[]{
"*.m3u;*.wsz;*.mpg;*.snd;*.aifc;*.aif;*.wav;*.au;*.mp1;*.mp2;*.mp3;*.ogg",
"*.*"};
// Filter for the selection of image files
public final static String[] IMAGEEXTENSIONS = new String[]{
"*.gif; *.jpg; *.jpeg; *.png; *.bmp; *.tif",
"*.*"};
// the playlist model instance
private IPlaylist playlistModel;
// the label provider for the table
private ITableLabelProvider labelProvider;
// Widgets
private MenuItem newPlaylistItem, openPlaylistItem;
private Label statusLine;
private ToolItem insertButton, deleteButton, upButton,
downButton;
private ICellModifier cellModifier = new ICellModifier() {
// Get value from model
public Object getValue(Object element, String property) {
return playlistModel.getFeature(element, property);
}
// All elements may be modified by the end user
public boolean canModify(Object element, String property) {
return true;
}
// Set value in the model
public void modify(Object element, String property,
Object value) {
// ATTENTION: A TableItem instance may be passed as
// element
// In this case we retrieve the playlist entry from
// the TableItem
if (element instanceof Item)
element = ((Item) element).getData();
// To be safe we validate the new value
if (validateFeature(property, (String) value) == null) {
// OK, we set the new value in the model
playlistModel.setFeature(element, property,
(String) value);
// Refresh the viewer so that the new value is
// shown in the table
PlaylistViewer.this.refresh();
}
}
};
/**
* Validates a feature
*
* @param tag -
* Feature name
* @param value -
* Value
* @return String
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -