deleteitem.java

来自「CD Manager光盘资料管家婆源代码」· Java 代码 · 共 62 行

JAVA
62
字号
package com.galaxyworkstation.view;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;

import com.galaxyworkstation.control.CDManager;


/**
 * 
 * The DeleteItem class which is to delete an album TreeItem from the Tree
 *
 */
public class DeleteItem implements TheObject {
	
	TreeItem treeItem;
	
	/**
	 * The initial method is the main method of the class
	 */
	public void initial() {
		
		Tree tree = treeItem.getParent();
		if(!treeItem.equals(tree.getItem(0))){
			if(treeItem.getItemCount() == 0){
				tree.setSelection(treeItem.getParentItem());
				TheObject renameItem = new RenameAlbumItem();
				renameItem.setObject(treeItem.getParent());
				CDManager.action.deleteAlbum(MainGUI.albumMap.get(treeItem));
				MainGUI.albumMap.remove(treeItem);
				tree.setSelection(treeItem.getParentItem());
				treeItem.dispose();
			}
			else{

				MessageBox msgBox = new MessageBox(treeItem.getParent().getShell(),SWT.ICON_ERROR|SWT.OK);
				msgBox.setText("错误");
				msgBox.setMessage("此专辑尚有子目录存在,不能删除");
				msgBox.open();
				return;
			}
		}
		else{
			MessageBox msgBox = new MessageBox(treeItem.getParent().getShell(),SWT.ICON_ERROR|SWT.OK);
			msgBox.setText("错误");
			msgBox.setMessage("此专辑不能删除");
			msgBox.open();
			return;
		}
	}

	/**
	 * The setObject method which is to set the parent TreeItem
	 */
	public void setObject(Object object) {
		this.treeItem = (TreeItem)object;
	}

}

⌨️ 快捷键说明

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