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

📄 ganttactionlistener.java

📁 Owing to the applet Gantt chart source yard, already Chinese melt, Gantt chart can demonstrate a Chi
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		if (task == null)			return;		JDialog jf = new JDialog(mainWindow, Messages				.getString("AsignationEditor.title")); //$NON-NLS-1$				jf.getContentPane().add(new AsignationEditor(jf, pvm, task));		jf.pack();		jf.setSize(new Dimension(300, 200));		Point p = mainWindow.getLocation();		jf.setLocation(p.x + 100, p.y + 100);		jf.setVisible(true);	}	/**	 * Obtiene una referencia al archivo que contiene los colores de usuario.	 * 	 * @return referencia al archivo.	 */	File getSettingsFile() {		String userDir = System.getProperty("user.home");		return new File(userDir, ".lgantt_user_colors");	}	/**	 * Carga los colores del usuario	 */	private void cmdLoadUserColors() {		// cargar si los hay		File source = getSettingsFile();		try {			InputStream is = new FileInputStream(source);			GraphColors gc = IOManager.loadGraphColors(is);			// asignar			pvModel.getProject().setGraphColors(gc);			is.close();			mainWindow.repaint();		} catch (Exception ex) {			ex.printStackTrace();		}	}	/**	 * graba los colores en un archivo personal	 */	private void cmdDefineUserColors() {		// Crear nombre de archivo		File source = getSettingsFile();		try {			OutputStream os = new FileOutputStream(source);			IOManager.serialize(pvModel.getProject().getGraphColors(), os);			os.close();		} catch (Exception ex) {			ex.printStackTrace();		}	}	/**	 * Genera una imagen en formato y la graba en el disco	 */	private void cmdExportImage() {		try {			BufferedImage img = pvModel.makeImage();			JDialog f = new JDialog(mainWindow, "Export Image", true);			f.getContentPane().setLayout(new BorderLayout());			JLabel imgLabel = new JLabel(new ImageIcon(img));			f.getContentPane().add(new JScrollPane(imgLabel),					BorderLayout.CENTER);			f.pack();			f.setVisible(true);			JFileChooser chooser = getImageFileChooser();			if (JFileChooser.APPROVE_OPTION == chooser					.showSaveDialog(mainWindow)) {				File dest = chooser.getSelectedFile();				pvModel.exportImage(dest);			}			f.dispose();		} catch (Exception ex) {			System.err.println(Messages					.getString("MainFrame.error.actionException")); //$NON-NLS-1$			ex.printStackTrace(System.err);		}	}	/**	 * Carga un archivo .lgantt o xml	 * 	 * @throws ParserConfigurationException	 * @throws SAXException	 * @throws IOException	 * @throws FileNotFoundException	 * @throws ParseException	 * @throws GanttException	 */	private void cmdOpen() throws SAXException, IOException,			FileNotFoundException, ParseException, GanttException {		File f = getOpenFile();		if (f!=null) {			pvModel.setProject(IOManager.loadFrom(f), f);			updWindowTitle();            JGanttMain.addLastUsed(f);		}	}	/**	 * Carga un archivo .lgantt o xml	 * 	 * @throws ParserConfigurationException	 * @throws SAXException	 * @throws IOException	 * @throws FileNotFoundException	 * @throws ParseException	 * @throws GanttException	 */	private void cmdLoadProject() throws SAXException, IOException,			FileNotFoundException, ParseException, GanttException {		//File f = getOpenFile();		//if (f!=null) {			pvModel.setProject(IOManager.loadFromDbForTest());			updWindowTitle();            //JGanttMain.addLastUsed(f);		//}	}	/**	 * retorna una referencia a un archivo seleccionado por el usuario	 * 	 * @return	 * @throws ParseException	 * @throws GanttException	 * @throws FileNotFoundException	 * @throws SAXException	 * @throws IOException	 */	private File getOpenFile() throws ParseException, GanttException,			FileNotFoundException, SAXException, IOException {		JFileChooser chooser = getLGanttFileChooser();		if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(mainWindow)) {			return chooser.getSelectedFile();		}		return null;	}	/**	 * @throws IOException	 *             Si hay problemas con la lectura del archivo	 * @throws SAXException	 * @throws GanttException	 * @throws ParseException	 * @throws FileNotFoundException	 */	void cmdMergeProject() throws FileNotFoundException, ParseException,			GanttException, SAXException, IOException {		File f = getOpenFile();		if (f == null)			return;		Project p = IOManager.loadFrom(f);		// copiar las tareas como hijas de la tarea actual		Task resumeTask = pvModel.getCurrentTask();		if (resumeTask == null)			resumeTask = pvModel.getProject().getMainTask();		resumeTask.addChild(p);	}	/**	 * Crea un nuevo proyecto y lo asigna.	 */	private void cmdNew() {		pvModel.setProject(IOManager.createEmptyProject(), null);		updWindowTitle();	}	/**	 * Graba el proyecto en un archivo con un nombre.	 * 	 * @throws FileNotFoundException	 * @throws IOException	 */	private void cmdSaveAs() throws FileNotFoundException, IOException {		JFileChooser chooser = getLGanttFileChooser();		if (pvModel.getFile() != null)			chooser.setCurrentDirectory(pvModel.getFile().getParentFile());		if (JFileChooser.APPROVE_OPTION == chooser.showSaveDialog(mainWindow)) {			File dest = chooser.getSelectedFile();			IOManager.saveAs(pvModel.getProject(), dest);			pvModel.setFile(dest);			updWindowTitle();            JGanttMain.addLastUsed(dest);		}	}	/**	 * Graba el contenido del proyecto con el nombre actual.	 * 	 * @throws FileNotFoundException	 * @throws IOException	 */	private void cmdSave() throws FileNotFoundException, IOException {		if (pvModel.getFile() == null) {			cmdSaveAs();		} else {			IOManager.saveAs(pvModel.getProject(), pvModel.getFile());			updWindowTitle();		}	}	/**	 * Muestra una tabla con los recursos.	 */	private void cmdResourcesTable() {		JDialog jf = new JDialog(mainWindow, CMD_RESOURCES_TABLE);		ProjectViewModel pvm = (ProjectViewModel) ganttDisplay				.getProjectViewModel();		jf.getContentPane().add(new ResourcesTable(pvm), BorderLayout.CENTER);		jf.pack();		jf.setSize(new Dimension(400, 200));		Point p = mainWindow.getLocation();		jf.setLocation(p.x + 200, p.y + 250);		jf.setVisible(true);	}	/**	 * Opciones de visualizacion, tamano de la grilla, etc.	 */	private void cmdViewOptions() {		JDialog jf = new JDialog(mainWindow, Messages				.getString("MainFrame.ViewOptionsFrame.title")); //$NON-NLS-1$		jf.getContentPane().add(new OptionsEditor(jf, pvModel));		jf.pack();		Point p = mainWindow.getLocation();		jf.setLocation(p.x + 300, p.y + 80);		jf.setVisible(true);	}	/**	 * Edita las caracteristicas del proyecto.	 */	private void cmdEditProject() {		JDialog jf = new JDialog(mainWindow, Messages				.getString("MainFrame.ProjectEditorFrame.title")); //$NON-NLS-1$		ProjectViewModel pvm = (ProjectViewModel) ganttDisplay				.getProjectViewModel();		jf.getContentPane().add(new ProjectEditor(jf, pvm));		jf.pack();		Point p = mainWindow.getLocation();		jf.setLocation(p.x + 150, p.y + 80);		jf.setVisible(true);	}	/**	 * Edita los colores que se usan en los graficos	 */	private void cmdGraphColors() {		JDialog jf = new JDialog(mainWindow, Messages				.getString("MainFrame.GraphColors.title"));		// ProjectViewModel pvm = (ProjectViewModel)		// ganttDisplay.getProjectViewModel();		jf.getContentPane().add(new GraphColorsEditor(pvModel));		jf.pack();		Point p = mainWindow.getLocation();		jf.setLocation(p.x + 150, p.y + 80);		jf.setVisible(true);	}	/**	 * Crea una foto del contenido del proyecto.	 */	public void cmdSnapShot() {		String def = "New SnapShot";		InputDialog id = new InputDialog("Take SnapShot", def);		Point p = mainWindow.getLocation();		id.setLocation(p.x + 150, p.y + 80);		if (id.execute()) {			String title = id.getInputString();			if (title != null) {				pvModel.getProject().takeSnapshot(title);			}		}	}	/**	 * Remueve el snapshot seleccionado si hay alguno.	 */	public void cmdSnapShotRemove() {		Date d = pvModel.getCurrentSnapShot();		pvModel.getProject().removeSnapshot(d);	}	/**	 * Undo the last action	 */	void cmdUndo() {		pvModel.getProject().undo();	}	/**	 * Redo the last undoed action	 */	void cmdRedo() {		pvModel.getProject().redo();	}	/**	 * Cambia el titulo de la ventana	 */	public void updWindowTitle() {		if (mainWindow == null)			return;		((MainFrame) mainWindow).updWindowTitle();	}	JFileChooser getImageFileChooser() {		// chooser.setCurrentDirectory(pvModel.getFile().getParentFile());		chooser.resetChoosableFileFilters();		chooser.setFileFilter(new StdFileFilter("Image (*.jpg)", ".jpg"));		return chooser;	}	JFileChooser getLGanttFileChooser() {		// chooser.setCurrentDirectory(pvModel.getFile().getParentFile());		chooser.resetChoosableFileFilters();		FileFilter f1 = new StdFileFilter("Archivos lGantt (*.lgantt,*.xml)",				IOManager.STD_FILE_EXT + " " + IOManager.SEC_FILE_EXT);		FileFilter f2 = new StdFileFilter("lGantt standard (*.lgantt)",				IOManager.STD_FILE_EXT);		FileFilter f3 = new StdFileFilter("lGantt simple (*.xml)",				IOManager.SEC_FILE_EXT);		chooser.addChoosableFileFilter(f1);		chooser.addChoosableFileFilter(f2);		chooser.addChoosableFileFilter(f3);		chooser.setFileFilter(f1);		return chooser;	}	/**	 * StdFileFilter	 * 	 * @author Carlos	 */	static class StdFileFilter extends FileFilter {		String ext = null;		String des = null;		public StdFileFilter(String typeDescription, String comaExtensions) {			ext = typeDescription;			des = comaExtensions;		}		public boolean accept(File f) {			if (f.isDirectory())				return true;			String name = f.getName();			int i = name.lastIndexOf(".");			if (i < 0)				return false;			String x = name.substring(i);			return ext.indexOf(x) >= 0;		}		public String getDescription() {			return des;		}	}}

⌨️ 快捷键说明

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