⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 maingui.java

📁 CD Manager光盘资料管家婆源代码
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
				event.display.getShells()[0].setMinimized(false);
				event.display.getShells()[0].setActive();	
			}
			else if(event.type == SWT.MenuDetect)
				trayMenu.setVisible(true);
		}
	};
	
	/**
	 * 主面板最小化及关闭事件 
	 */
	private ShellListener minCloseListener = new ShellListener(){
		
		public void shellActivated(ShellEvent e) {
		}

		public void shellClosed(ShellEvent e) {
			
			/* e.doit = false; 
        	 shell.setVisible(!shell.isVisible());    
             tray.getItem(0).setVisible(!shell.isVisible());    */
		}

		public void shellDeactivated(ShellEvent e) {
		}

		public void shellDeiconified(ShellEvent e) {
		}

		public void shellIconified(ShellEvent e) {

			shell.setVisible(!shell.isVisible());    
			tray.getItem(0).setVisible(!shell.isVisible());    
		}
		
	};
	
	/**
	 * 托盘菜单项打开事件
	 */
	private SelectionListener openListener = new SelectionListener(){

		public void widgetDefaultSelected(SelectionEvent e) {
		}

		public void widgetSelected(SelectionEvent e) {
			
			shell.setVisible(!shell.getVisible());
			shell.setMinimized(false);
			shell.setActive();	
		}
		
	};
	
	/**
	 * 关于事件
	 */
	private SelectionListener aboutListener = new SelectionListener(){

		public void widgetDefaultSelected(SelectionEvent e) {
		}

		public void widgetSelected(SelectionEvent e) {
			
			AboutDialog about = new AboutDialog(e.display.getShells()[0],SWT.NONE);
			about.open();		
		}
		
	};
	/**
	 * 帮助事件
	 */
	private SelectionListener helpListener = new SelectionListener() {
		public void widgetSelected(final SelectionEvent e) {
			
			HelpBrowserDialog  help = new HelpBrowserDialog(shell,SWT.NONE);
			help.open();
			
			/*try {
				Runtime.getRuntime().exec("cmd.exe /c help.chm");
			} catch (IOException e1) {
				e1.printStackTrace();
			}*/
		}

		public void widgetDefaultSelected(SelectionEvent e) {
		}
	};
	
	/**
	 * 关闭事件
	 */
	private SelectionListener exitListener = new SelectionListener(){

		public void widgetDefaultSelected(SelectionEvent e) {
		}

		public void widgetSelected(SelectionEvent e) {
			
			shell.dispose();
			tray.dispose();
		}
		
	};
	
	/**
	 * 新建专辑
	 */
	private SelectionListener newAlbumListener = new SelectionListener(){

		public void widgetDefaultSelected(SelectionEvent e) {
		}

		public void widgetSelected(SelectionEvent e) {
		
			TheObject newItem = new AddTreeItem();
			newItem.setObject(albumTree.getSelection()[0]);
			newItem.initial();		
		}
		
	};
	
	/**
	 * 新建光盘
	 */
	private SelectionListener newCDListener = new SelectionListener(){

		public void widgetDefaultSelected(SelectionEvent e) {
		}

		public void widgetSelected(SelectionEvent e) {
			
			if (albumTree.getSelection()[0].getImage()
					.equals(
							SWTResourceManager.getImage(MainGUI.class,
									ImageFactory.CD))) {
				MessageBox msgBox = new MessageBox(albumTree.getShell(),
						SWT.ICON_ERROR | SWT.OK);
				msgBox.setText("错误");
				msgBox.setMessage("不能在光盘中建立光盘");
				msgBox.open();
				return;
			}
			 CreateCDDialog createCD = new CreateCDDialog(e.display.getShells()[0]);
			 createCD.open();
			
		}
		
	};
	
	/**
	 * 设置密码 
	 */
	private SelectionListener setPassListener = new SelectionListener(){

		public void widgetDefaultSelected(SelectionEvent e) {
		}

		public void widgetSelected(SelectionEvent e) {
			
			if(CDManager.action.getConfig().isPasswordSetted()){
				ModifyPasswdDialog modify = new ModifyPasswdDialog(e.display.getShells()[0],SWT.NONE);
				modify.open();
			}else{
				CreatePasswdDialog create = new CreatePasswdDialog(e.display.getShells()[0],SWT.NONE);
				create.open();
			}
		}
		
	};
	
	/**
	 * 导出索引
	 */
	private SelectionListener exportListener = new SelectionListener(){

		public void widgetDefaultSelected(SelectionEvent e) {
		}

		public void widgetSelected(SelectionEvent e) {
			
			TreeItem treeItem = ((Tree)((Composite)((SashForm)((SashForm)((Group)e.display.getShells()[0].getChildren()[1])
                     .getChildren()[0]).getChildren()[0]).getChildren()[0])
                     .getChildren()[0]).getSelection()[0];
			if(treeItem.getImage().equals(SWTResourceManager.getImage(MainGUI.class, ImageFactory.CD))){
				ExportIndexDialog export = new ExportIndexDialog(e.display.getShells()[0],SWT.NONE);
				export.open();
			}
			else{
				MessageBox msgBox = new MessageBox(e.display.getShells()[0], SWT.ICON_ERROR
						| SWT.OK);
				msgBox.setText("错误");
				msgBox.setMessage("请选择一张光盘!");
				msgBox.open();
			}
		}
		
	};
	

	/**
	 * 重命名
	 */
	private SelectionListener renameListener = new SelectionListener(){

		public void widgetDefaultSelected(SelectionEvent e) {
		}

		public void widgetSelected(SelectionEvent e) {
	
			if (albumTree.getSelection()[0].getImage()
					.equals(
							SWTResourceManager.getImage(MainGUI.class,
									ImageFactory.CD))) {
				TheObject rename = new RenameCDItem();
				rename.setObject(albumTree);
				rename.initial();
			} else {
				TheObject rename = new RenameAlbumItem();
				rename.setObject(albumTree);
				rename.initial();
			}
		}	
		
	};
	
	/**
	 * 添加注释
	 */
	private SelectionListener addDescriptionListener = new SelectionListener(){

		public void widgetDefaultSelected(SelectionEvent e) {
		}

		public void widgetSelected(SelectionEvent e) {

			if (albumTree.getSelection()[0].getImage()
					.equals(
							SWTResourceManager.getImage(MainGUI.class,
									ImageFactory.CD))) {
				descriptionText.setEditable(true);
			} else {
				MessageBox msgBox = new MessageBox(albumTree.getShell(),
						SWT.ICON_ERROR | SWT.OK);
				msgBox.setText("错误");
				msgBox.setMessage("未选中光盘");
				msgBox.open();
			}
		}
		
	};
	
	/**
	 * 硬盘搜索
	 */
	private SelectionListener hardDiskSacnListener = new SelectionListener(){

		public void widgetDefaultSelected(SelectionEvent e) {
		}

		public void widgetSelected(SelectionEvent e) {
			
			SearchDialog search = new SearchDialog(e.display.getShells()[0]);
			search.open();
		}

	};
	
	/**
	 * 查看日志
	 */
	private SelectionListener logListener = new SelectionListener(){

		public void widgetDefaultSelected(SelectionEvent e) {
		}

		public void widgetSelected(SelectionEvent e) {
	
			LogDialog log = new LogDialog(e.display.getShells()[0],SWT.NONE);
			log.open();
		}
		
	};
	
	/**
	 * 向上
	 */
	private SelectionListener upToolListener = new SelectionListener(){

		public void widgetDefaultSelected(SelectionEvent e) {
		}

		public void widgetSelected(SelectionEvent e) {
		
			if (!canUP)
				return;
			if (entranceDoc == null && table.getItemCount() <= 0)
				return;
			Document doc;
			ArrayList<Document> docs;
			if (table.getItemCount() <= 0) {
				doc = entranceDoc;
				docs = CDManager.action.getBrothers(doc);
			} else {
				doc = MainGUI.tableMap.get(table.getItem(0));
				docs = CDManager.action.getSeniors(doc);
			}

			if (docs.size() == 0)
				return;
			table.removeAll();
			SetTableItem setTableItem = new SetTableItem();
			setTableItem.setObject(table);
			setTableItem.setDocs(docs);
			setTableItem.initial();
		}
		
	};
	
	/**
	 * 光盘搜索框焦点
	 */
	private FocusListener cdSearchFocuseListener = new FocusListener(){

		public void focusGained(FocusEvent e) {
			
			cdSearchText.setText("");	
		}

		public void focusLost(FocusEvent e) {
		
			if(cdSearchText.getText() == ""){
				cdSearchText.setText("搜索光盘文件...");
			}
		}
		
	};
	
	/**
	 * 光盘搜索框内容变更
	 */
	private ModifyListener cdSearchModifyListener = new ModifyListener(){

		public void modifyText(ModifyEvent e) {

			canUP = false;
			displaySearch();
		}
		
	};
	
	/**
	 * 光盘搜索框按钮
	 */
	private MouseListener searchButtonListener = new MouseListener(){

		public void mouseDoubleClick(MouseEvent e) {
		}

		public void mouseDown(MouseEvent e) {
		}

		public void mouseUp(MouseEvent e) {
			
			String keyword = cdSearchText.getText().trim();
			if (keyword.length() < 2) {
				MessageBox msgBox = new MessageBox(
						e.display.getShells()[0], SWT.ICON_ERROR | SWT.OK);
				msgBox.setText("关键词过短错误");
				msgBox.setMessage("您输入的关键词过短,请重新输入!");
				msgBox.open();
				return;
			} else {
				if(keyword.equals("搜索光盘文件..."))
					return;
				canUP = false;
				displaySearch();
			}
		}
		
	};
	
	/**
	 * 光盘树的展开与关闭
	 */
	private TreeListener albumTreeListener = new TreeListener(){

		public void treeCollapsed(TreeEvent e) {
			
			TreeItem ti = (TreeItem) e.item;
			ti.setImage(SWTResourceManager.getImage(MainGUI.class,
					ImageFactory.ALBUM));
		}

		public void treeExpanded(TreeEvent e) {
			
			TreeItem ti = (TreeItem) e.item;
			ti.setImage(SWTResourceManager.getImage(MainGUI.class,
					ImageFactory.ALBUM));
		}
		
	};
	
	/**
	 * 光盘树鼠标选择
	 */
	private MouseListener albumTreeMouseListener = new MouseListener(){

		public void mouseDoubleClick(MouseEvent e) {

			if (albumTree.getSelection()[0].getImage()
					.equals(
							SWTResourceManager.getImage(MainGUI.class,
									ImageFactory.CD))) {
				TheObject rename = new RenameCDItem();

⌨️ 快捷键说明

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