📄 addtreeitem.java
字号:
package com.galaxyworkstation.view;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.TreeItem;
import com.galaxyworkstation.control.CDManager;
import com.galaxyworkstation.model.Album;
import com.galaxyworkstation.model.ImageFactory;
import com.galaxyworkstation.model.SWTResourceManager;
/**
*
* The AddTreeItem class which is to create new a TreeItem of an album
*
*/
public class AddTreeItem implements TheObject {
private TreeItem treeItem;
/**
* the setObject method which is to set the parent TreeItem
*/
public void setObject(Object object) {
this.treeItem = (TreeItem)object;
}
/**
* The initial method is the main method of the class
*/
public void initial() {
if(treeItem.getImage().equals(SWTResourceManager.getImage(MainGUI.class, ImageFactory.CD))){
MessageBox msgBox = new MessageBox(treeItem.getParent().getShell(),SWT.ICON_ERROR|SWT.OK);
msgBox.setText("错误");
msgBox.setMessage("不能在光盘中建立专辑");
msgBox.open();
return;
}
TreeItem newItem = new TreeItem(this.treeItem,SWT.SINGLE);
newItem.setText("新建专辑");
newItem.getParent().setSelection(newItem);
newItem.setImage(SWTResourceManager.getImage(MainGUI.class, ImageFactory.ALBUM));
Album newAlbum = CDManager.action.CreateNewAlbum(newItem.getText(), MainGUI.albumMap.get(treeItem));
MainGUI.albumMap.put(newItem, newAlbum);
TheObject rename = new RenameAlbumItem();
rename.setObject(this.treeItem.getParent());
rename.initial();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -