removemusicfolderaction.java

来自「eclise rcp 项目,是非常好的学习源码」· Java 代码 · 共 57 行

JAVA
57
字号
/******************************************************************************* * 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.actions;import org.eclipse.jface.action.IAction;import org.eclipse.jface.viewers.ISelection;import org.eclipse.jface.viewers.StructuredSelection;import org.eclipse.ui.IWorkbenchWindow;import org.eclipse.ui.IWorkbenchWindowActionDelegate;import com.siemens.ct.mp3m.ModelInitializer;import com.siemens.ct.mp3m.model.physical.Mp3Directory;import com.siemens.ct.mp3m.model.physical.MusicFolders;public class RemoveMusicFolderAction implements IWorkbenchWindowActionDelegate {	private String selectedDirectory;	public void run(IAction action) {		MusicFolders.removeMusicFolder(selectedDirectory);		ModelInitializer.createTree();	}	public void dispose() {		// TODO Auto-generated method stub	}	public void init(IWorkbenchWindow window) {	}	public void selectionChanged(IAction action, ISelection selection) {		if (!selection.isEmpty()) {			StructuredSelection structuredSelection = (StructuredSelection) selection;			if (structuredSelection.getFirstElement() instanceof Mp3Directory) {				String folder = ((Mp3Directory) structuredSelection.getFirstElement()).getName();				if (MusicFolders.contains(folder)) {					action.setEnabled(true);					selectedDirectory = folder;					return;				} else {					action.setEnabled(false);				}			}		}		action.setEnabled(false);	}}

⌨️ 快捷键说明

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