📄 deleteitem.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -