001: package net.sf.memoranda.ui;
002:
003: import java.awt.AWTEvent;
004: import java.awt.BorderLayout;
005: import java.awt.Dimension;
006: import java.awt.Frame;
007: import java.awt.Point;
008: import java.awt.event.ActionEvent;
009: import java.awt.event.ActionListener;
010: import java.awt.event.InputEvent;
011: import java.awt.event.KeyEvent;
012: import java.awt.event.WindowEvent;
013: import java.io.File;
014: import java.util.Collection;
015: import java.util.Vector;
016:
017: import javax.swing.AbstractAction;
018: import javax.swing.Action;
019: import javax.swing.ImageIcon;
020: import javax.swing.JButton;
021: import javax.swing.JFileChooser;
022: import javax.swing.JFrame;
023: import javax.swing.JLabel;
024: import javax.swing.JMenu;
025: import javax.swing.JMenuBar;
026: import javax.swing.JMenuItem;
027: import javax.swing.JPanel;
028: import javax.swing.JSplitPane;
029: import javax.swing.JToolBar;
030: import javax.swing.KeyStroke;
031: import javax.swing.UIManager;
032:
033: import net.sf.memoranda.CurrentProject;
034: import net.sf.memoranda.History;
035: import net.sf.memoranda.NoteList;
036: import net.sf.memoranda.Project;
037: import net.sf.memoranda.ProjectListener;
038: import net.sf.memoranda.ResourcesList;
039: import net.sf.memoranda.TaskList;
040: import net.sf.memoranda.ui.htmleditor.HTMLEditor;
041: import net.sf.memoranda.util.Configuration;
042: import net.sf.memoranda.util.Context;
043: import net.sf.memoranda.util.Local;
044: import net.sf.memoranda.util.ProjectExporter;
045: import net.sf.memoranda.util.ProjectPackager;
046: import net.sf.memoranda.util.Util;
047:
048: /**
049: *
050: * Copyright (c) 2003 Memoranda Team. http://memoranda.sf.net
051: */
052:
053: /*$Id: AppFrame.java,v 1.33 2005/07/05 08:17:24 alexeya Exp $*/
054:
055: public class AppFrame extends JFrame {
056:
057: JPanel contentPane;
058: JMenuBar menuBar = new JMenuBar();
059: JMenu jMenuFile = new JMenu();
060: JMenuItem jMenuFileExit = new JMenuItem();
061:
062: JToolBar toolBar = new JToolBar();
063: JButton jButton3 = new JButton();
064: ImageIcon image1;
065: ImageIcon image2;
066: ImageIcon image3;
067: JLabel statusBar = new JLabel();
068: BorderLayout borderLayout1 = new BorderLayout();
069: JSplitPane splitPane = new JSplitPane();
070: ProjectsPanel projectsPanel = new ProjectsPanel();
071: boolean prPanelExpanded = false;
072:
073: JMenu jMenuEdit = new JMenu();
074: JMenu jMenuFormat = new JMenu();
075: JMenu jMenuInsert = new JMenu();
076:
077: public WorkPanel workPanel = new WorkPanel();
078: HTMLEditor editor = workPanel.dailyItemsPanel.editorPanel.editor;
079:
080: static Vector exitListeners = new Vector();
081:
082: public Action prjPackAction = new AbstractAction(
083: "Pack current project") {
084: public void actionPerformed(ActionEvent e) {
085: doPrjPack();
086: }
087: };
088:
089: public Action prjUnpackAction = new AbstractAction("Unpack project") {
090: public void actionPerformed(ActionEvent e) {
091: doPrjUnPack();
092: }
093: };
094:
095: public Action minimizeAction = new AbstractAction(
096: "Close the window") {
097: public void actionPerformed(ActionEvent e) {
098: doMinimize();
099: }
100: };
101:
102: public Action preferencesAction = new AbstractAction("Preferences") {
103: public void actionPerformed(ActionEvent e) {
104: showPreferences();
105: }
106: };
107:
108: public Action exportNotesAction = new AbstractAction(Local
109: .getString("Export notes")
110: + "...") {
111:
112: public void actionPerformed(ActionEvent e) {
113: ppExport_actionPerformed(e);
114: }
115: };
116:
117: JMenuItem jMenuFileNewPrj = new JMenuItem();
118: JMenuItem jMenuFileNewNote = new JMenuItem(
119: workPanel.dailyItemsPanel.editorPanel.newAction);
120: JMenuItem jMenuFilePackPrj = new JMenuItem(prjPackAction);
121: JMenuItem jMenuFileUnpackPrj = new JMenuItem(prjUnpackAction);
122: JMenuItem jMenuFileExportPrj = new JMenuItem(exportNotesAction);
123: JMenuItem jMenuFileExportNote = new JMenuItem(
124: workPanel.dailyItemsPanel.editorPanel.exportAction);
125: JMenuItem jMenuFileMin = new JMenuItem(minimizeAction);
126:
127: JMenuItem jMenuItem1 = new JMenuItem();
128: JMenuItem jMenuEditUndo = new JMenuItem(editor.undoAction);
129: JMenuItem jMenuEditRedo = new JMenuItem(editor.redoAction);
130: JMenuItem jMenuEditCut = new JMenuItem(editor.cutAction);
131: JMenuItem jMenuEditCopy = new JMenuItem(editor.copyAction);
132: JMenuItem jMenuEditPaste = new JMenuItem(editor.pasteAction);
133: JMenuItem jMenuEditPasteSpec = new JMenuItem(
134: editor.stylePasteAction);
135: JMenuItem jMenuEditSelectAll = new JMenuItem(editor.selectAllAction);
136: JMenuItem jMenuEditFind = new JMenuItem(editor.findAction);
137:
138: JMenu jMenuGo = new JMenu();
139: JMenuItem jMenuInsertImage = new JMenuItem(editor.imageAction);
140: JMenuItem jMenuInsertTable = new JMenuItem(editor.tableAction);
141: JMenuItem jMenuInsertLink = new JMenuItem(editor.linkAction);
142: JMenu jMenuInsertList = new JMenu();
143: JMenuItem jMenuInsertListUL = new JMenuItem(editor.ulAction);
144: JMenuItem jMenuInsertListOL = new JMenuItem(editor.olAction);
145: JMenuItem jMenuInsertBR = new JMenuItem(editor.breakAction);
146: JMenuItem jMenuInsertHR = new JMenuItem(editor.insertHRAction);
147: JMenuItem jMenuInsertChar = new JMenuItem(editor.insCharAction);
148: JMenuItem jMenuInsertDate = new JMenuItem(
149: workPanel.dailyItemsPanel.editorPanel.insertDateAction);
150: JMenuItem jMenuInsertTime = new JMenuItem(
151: workPanel.dailyItemsPanel.editorPanel.insertTimeAction);
152: JMenuItem jMenuInsertFile = new JMenuItem(
153: workPanel.dailyItemsPanel.editorPanel.importAction);
154:
155: JMenu jMenuFormatPStyle = new JMenu();
156: JMenuItem jMenuFormatP = new JMenuItem(editor.new BlockAction(
157: editor.T_P, ""));
158: JMenuItem jMenuFormatH1 = new JMenuItem(editor.new BlockAction(
159: editor.T_H1, ""));
160: JMenuItem jMenuFormatH2 = new JMenuItem(editor.new BlockAction(
161: editor.T_H2, ""));
162: JMenuItem jMenuFormatH3 = new JMenuItem(editor.new BlockAction(
163: editor.T_H3, ""));
164: JMenuItem jMenuFormatH4 = new JMenuItem(editor.new BlockAction(
165: editor.T_H4, ""));
166: JMenuItem jMenuFormatH5 = new JMenuItem(editor.new BlockAction(
167: editor.T_H5, ""));
168: JMenuItem jMenuFormatH6 = new JMenuItem(editor.new BlockAction(
169: editor.T_H6, ""));
170: JMenuItem jMenuFormatPRE = new JMenuItem(editor.new BlockAction(
171: editor.T_PRE, ""));
172: JMenuItem jMenuFormatBLCQ = new JMenuItem(editor.new BlockAction(
173: editor.T_BLOCKQ, ""));
174: JMenu jjMenuFormatChStyle = new JMenu();
175: JMenuItem jMenuFormatChNorm = new JMenuItem(
176: editor.new InlineAction(editor.I_NORMAL, ""));
177: JMenuItem jMenuFormatChEM = new JMenuItem(editor.new InlineAction(
178: editor.I_EM, ""));
179: JMenuItem jMenuFormatChSTRONG = new JMenuItem(
180: editor.new InlineAction(editor.I_STRONG, ""));
181: JMenuItem jMenuFormatChCODE = new JMenuItem(
182: editor.new InlineAction(editor.I_CODE, ""));
183: JMenuItem jMenuFormatChCite = new JMenuItem(
184: editor.new InlineAction(editor.I_CITE, ""));
185: JMenuItem jMenuFormatChSUP = new JMenuItem(editor.new InlineAction(
186: editor.I_SUPERSCRIPT, ""));
187: JMenuItem jMenuFormatChSUB = new JMenuItem(editor.new InlineAction(
188: editor.I_SUBSCRIPT, ""));
189: JMenuItem jMenuFormatChCustom = new JMenuItem(
190: editor.new InlineAction(editor.I_CUSTOM, ""));
191: JMenuItem jMenuFormatChB = new JMenuItem(editor.boldAction);
192: JMenuItem jMenuFormatChI = new JMenuItem(editor.italicAction);
193: JMenuItem jMenuFormatChU = new JMenuItem(editor.underAction);
194: JMenu jMenuFormatAlign = new JMenu();
195: JMenuItem jMenuFormatAlignL = new JMenuItem(editor.lAlignAction);
196: JMenuItem jMenuFormatAlignC = new JMenuItem(editor.cAlignAction);
197: JMenuItem jMenuFormatAlignR = new JMenuItem(editor.rAlignAction);
198: JMenu jMenuFormatTable = new JMenu();
199: JMenuItem jMenuFormatTableInsR = new JMenuItem(
200: editor.insertTableRowAction);
201: JMenuItem jMenuFormatTableInsC = new JMenuItem(
202: editor.insertTableCellAction);
203: JMenuItem jMenuFormatProperties = new JMenuItem(editor.propsAction);
204: JMenuItem jMenuGoHBack = new JMenuItem(History.historyBackAction);
205: JMenuItem jMenuGoFwd = new JMenuItem(History.historyForwardAction);
206:
207: JMenuItem jMenuGoDayBack = new JMenuItem(
208: workPanel.dailyItemsPanel.calendar.dayBackAction);
209: JMenuItem jMenuGoDayFwd = new JMenuItem(
210: workPanel.dailyItemsPanel.calendar.dayForwardAction);
211: JMenuItem jMenuGoToday = new JMenuItem(
212: workPanel.dailyItemsPanel.calendar.todayAction);
213:
214: JMenuItem jMenuEditPref = new JMenuItem(preferencesAction);
215:
216: JMenu jMenuInsertSpecial = new JMenu();
217:
218: JMenu jMenuHelp = new JMenu();
219:
220: JMenuItem jMenuHelpGuide = new JMenuItem();
221: JMenuItem jMenuHelpWeb = new JMenuItem();
222: JMenuItem jMenuHelpBug = new JMenuItem();
223: JMenuItem jMenuHelpAbout = new JMenuItem();
224:
225: //Construct the frame
226: public AppFrame() {
227: enableEvents(AWTEvent.WINDOW_EVENT_MASK);
228: try {
229: jbInit();
230: } catch (Exception e) {
231: new ExceptionDialog(e);
232: }
233: }
234:
235: //Component initialization
236: private void jbInit() throws Exception {
237: this .setIconImage(new ImageIcon(AppFrame.class
238: .getResource("resources/icons/jnotes16.png"))
239: .getImage());
240: contentPane = (JPanel) this .getContentPane();
241: contentPane.setLayout(borderLayout1);
242: //this.setSize(new Dimension(800, 500));
243: this .setTitle("Memoranda - " + CurrentProject.get().getTitle());
244: //Added a space to App.VERSION_INFO to make it look some nicer
245: statusBar.setText(" Version:" + App.VERSION_INFO + " (Build "
246: + App.BUILD_INFO + " )");
247:
248: jMenuFile.setText(Local.getString("File"));
249: jMenuFileExit.setText(Local.getString("Exit"));
250: jMenuFileExit.addActionListener(new ActionListener() {
251: public void actionPerformed(ActionEvent e) {
252: doExit();
253: }
254: });
255: jMenuHelp.setText(Local.getString("Help"));
256:
257: jMenuHelpGuide.setText(Local.getString("Online user's guide"));
258: jMenuHelpGuide.setIcon(new ImageIcon(AppFrame.class
259: .getResource("resources/icons/help.png")));
260: jMenuHelpGuide.addActionListener(new ActionListener() {
261: public void actionPerformed(ActionEvent e) {
262: jMenuHelpGuide_actionPerformed(e);
263: }
264: });
265:
266: jMenuHelpWeb.setText(Local.getString("Memoranda web site"));
267: jMenuHelpWeb.setIcon(new ImageIcon(AppFrame.class
268: .getResource("resources/icons/web.png")));
269: jMenuHelpWeb.addActionListener(new ActionListener() {
270: public void actionPerformed(ActionEvent e) {
271: jMenuHelpWeb_actionPerformed(e);
272: }
273: });
274:
275: jMenuHelpBug.setText(Local.getString("Report a bug"));
276: jMenuHelpBug.addActionListener(new ActionListener() {
277: public void actionPerformed(ActionEvent e) {
278: jMenuHelpBug_actionPerformed(e);
279: }
280: });
281:
282: jMenuHelpAbout.setText(Local.getString("About Memoranda"));
283: jMenuHelpAbout.addActionListener(new ActionListener() {
284: public void actionPerformed(ActionEvent e) {
285: jMenuHelpAbout_actionPerformed(e);
286: }
287: });
288: //jButton3.setIcon(image3);
289: jButton3.setToolTipText(Local.getString("Help"));
290: splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
291:
292: splitPane.setContinuousLayout(true);
293: splitPane.setDividerSize(3);
294: //splitPane.setOneTouchExpandable(true);
295: splitPane.setDividerLocation(28);
296: //projectsPanel.setMaximumSize(new Dimension(2147483647, 200));
297: projectsPanel.setMinimumSize(new Dimension(10, 28));
298: projectsPanel.setPreferredSize(new Dimension(10, 28));
299: /*workPanel.setMinimumSize(new Dimension(734, 300));
300: workPanel.setPreferredSize(new Dimension(1073, 300));*/
301: splitPane.setDividerLocation(28);
302:
303: /* jMenuFileNewPrj.setText(Local.getString("New project") + "...");
304: jMenuFileNewPrj.addActionListener(new ActionListener() {
305: public void actionPerformed(ActionEvent e) {
306: ProjectDialog.newProject();
307: }
308: });
309: */
310: jMenuFileNewPrj.setAction(projectsPanel.newProjectAction);
311:
312: jMenuFileUnpackPrj.setText(Local.getString("Unpack project")
313: + "...");
314: jMenuFileExportNote.setText(Local
315: .getString("Export current note")
316: + "...");
317: jMenuFilePackPrj.setText(Local.getString("Pack project")
318: + "...");
319: jMenuFileMin.setText(Local.getString("Close the window"));
320: jMenuFileMin.setAccelerator(KeyStroke.getKeyStroke(
321: KeyEvent.VK_F10, InputEvent.ALT_MASK));
322:
323: jMenuEdit.setText(Local.getString("Edit"));
324:
325: jMenuEditUndo.setText(Local.getString("Undo"));
326: jMenuEditUndo.setToolTipText(Local.getString("Undo"));
327: jMenuEditRedo.setText(Local.getString("Redo"));
328: jMenuEditRedo.setToolTipText(Local.getString("Redo"));
329: jMenuEditCut.setText(Local.getString("Cut"));
330: jMenuEditCut.setToolTipText(Local.getString("Cut"));
331: jMenuEditCopy.setText((String) Local.getString("Copy"));
332: jMenuEditCopy.setToolTipText(Local.getString("Copy"));
333: jMenuEditPaste.setText(Local.getString("Paste"));
334: jMenuEditPaste.setToolTipText(Local.getString("Paste"));
335: jMenuEditPasteSpec.setText(Local.getString("Paste special"));
336: jMenuEditPasteSpec.setToolTipText(Local
337: .getString("Paste special"));
338: jMenuEditSelectAll.setText(Local.getString("Select all"));
339:
340: jMenuEditFind
341: .setText(Local.getString("Find & replace") + "...");
342:
343: jMenuEditPref.setText(Local.getString("Preferences") + "...");
344:
345: jMenuInsert.setText(Local.getString("Insert"));
346:
347: jMenuInsertImage.setText(Local.getString("Image") + "...");
348: jMenuInsertImage
349: .setToolTipText(Local.getString("Insert Image"));
350: jMenuInsertTable.setText(Local.getString("Table") + "...");
351: jMenuInsertTable
352: .setToolTipText(Local.getString("Insert Table"));
353: jMenuInsertLink.setText(Local.getString("Hyperlink") + "...");
354: jMenuInsertLink.setToolTipText(Local
355: .getString("Insert Hyperlink"));
356: jMenuInsertList.setText(Local.getString("List"));
357:
358: jMenuInsertListUL.setText(Local.getString("Unordered"));
359: jMenuInsertListUL.setToolTipText(Local
360: .getString("Insert Unordered"));
361: jMenuInsertListOL.setText(Local.getString("Ordered"));
362:
363: jMenuInsertSpecial.setText(Local.getString("Special"));
364: jMenuInsertBR.setText(Local.getString("Line break"));
365: jMenuInsertHR.setText(Local.getString("Horizontal rule"));
366:
367: jMenuInsertListOL.setToolTipText(Local
368: .getString("Insert Ordered"));
369:
370: jMenuInsertChar.setText(Local.getString("Special character")
371: + "...");
372: jMenuInsertChar.setToolTipText(Local
373: .getString("Insert Special character"));
374: jMenuInsertDate.setText(Local.getString("Current date"));
375: jMenuInsertTime.setText(Local.getString("Current time"));
376: jMenuInsertFile.setText(Local.getString("File") + "...");
377:
378: jMenuFormat.setText(Local.getString("Format"));
379: jMenuFormatPStyle.setText(Local.getString("Paragraph style"));
380: jMenuFormatP.setText(Local.getString("Paragraph"));
381: jMenuFormatH1.setText(Local.getString("Header") + " 1");
382: jMenuFormatH2.setText(Local.getString("Header") + " 2");
383: jMenuFormatH3.setText(Local.getString("Header") + " 3");
384: jMenuFormatH4.setText(Local.getString("Header") + " 4");
385: jMenuFormatH5.setText(Local.getString("Header") + " 5");
386: jMenuFormatH6.setText(Local.getString("Header") + " 6");
387: jMenuFormatPRE.setText(Local.getString("Preformatted text"));
388: jMenuFormatBLCQ.setText(Local.getString("Blockquote"));
389: jjMenuFormatChStyle.setText(Local.getString("Character style"));
390: jMenuFormatChNorm.setText(Local.getString("Normal"));
391: jMenuFormatChEM.setText(Local.getString("Emphasis"));
392: jMenuFormatChSTRONG.setText(Local.getString("Strong"));
393: jMenuFormatChCODE.setText(Local.getString("Code"));
394: jMenuFormatChCite.setText(Local.getString("Cite"));
395: jMenuFormatChSUP.setText(Local.getString("Superscript"));
396: jMenuFormatChSUB.setText(Local.getString("Subscript"));
397: jMenuFormatChCustom.setText(Local.getString("Custom style")
398: + "...");
399: jMenuFormatChB.setText(Local.getString("Bold"));
400: jMenuFormatChB.setToolTipText(Local.getString("Bold"));
401: jMenuFormatChI.setText(Local.getString("Italic"));
402: jMenuFormatChI.setToolTipText(Local.getString("Italic"));
403: jMenuFormatChU.setText(Local.getString("Underline"));
404: jMenuFormatChU.setToolTipText(Local.getString("Underline"));
405: jMenuFormatAlign.setText(Local.getString("Alignment"));
406: jMenuFormatAlignL.setText(Local.getString("Left"));
407: jMenuFormatAlignL.setToolTipText(Local.getString("Left"));
408: jMenuFormatAlignC.setText(Local.getString("Center"));
409: jMenuFormatAlignC.setToolTipText(Local.getString("Center"));
410: jMenuFormatAlignR.setText(Local.getString("Right"));
411: jMenuFormatAlignR.setToolTipText(Local.getString("Right"));
412: jMenuFormatTable.setText(Local.getString("Table"));
413: jMenuFormatTableInsR.setText(Local.getString("Insert row"));
414: jMenuFormatTableInsC.setText(Local.getString("Insert cell"));
415: jMenuFormatProperties.setText(Local
416: .getString("Object properties")
417: + "...");
418: jMenuFormatProperties.setToolTipText(Local
419: .getString("Object properties"));
420:
421: jMenuGo.setText(Local.getString("Go"));
422: jMenuGoHBack.setText(Local.getString("History back"));
423: jMenuGoHBack.setToolTipText(Local.getString("History back"));
424: jMenuGoFwd.setText(Local.getString("History forward"));
425: jMenuGoFwd.setToolTipText(Local.getString("History forward"));
426: jMenuGoDayBack.setText(Local.getString("One day back"));
427: jMenuGoDayFwd.setText(Local.getString("One day forward"));
428: jMenuGoToday.setText(Local.getString("To today"));
429:
430: jMenuInsertSpecial.setText(Local.getString("Special"));
431: jMenuInsertBR.setText(Local.getString("Line break"));
432: jMenuInsertBR.setToolTipText(Local.getString("Insert break"));
433: jMenuInsertHR.setText(Local.getString("Horizontal rule"));
434: jMenuInsertHR.setToolTipText(Local
435: .getString("Insert Horizontal rule"));
436:
437: toolBar.add(jButton3);
438: jMenuFile.add(jMenuFileNewPrj);
439: jMenuFile.add(jMenuFileNewNote);
440: jMenuFile.addSeparator();
441: jMenuFile.add(jMenuFilePackPrj);
442: jMenuFile.add(jMenuFileUnpackPrj);
443: jMenuFile.addSeparator();
444: jMenuFile.add(jMenuFileExportPrj);
445: jMenuFile.add(jMenuFileExportNote);
446: jMenuFile.addSeparator();
447: jMenuFile.add(jMenuEditPref);
448: jMenuFile.addSeparator();
449: jMenuFile.add(jMenuFileMin);
450: jMenuFile.addSeparator();
451: jMenuFile.add(jMenuFileExit);
452:
453: jMenuHelp.add(jMenuHelpGuide);
454: jMenuHelp.add(jMenuHelpWeb);
455: jMenuHelp.add(jMenuHelpBug);
456: jMenuHelp.addSeparator();
457: jMenuHelp.add(jMenuHelpAbout);
458:
459: menuBar.add(jMenuFile);
460: menuBar.add(jMenuEdit);
461: menuBar.add(jMenuInsert);
462: menuBar.add(jMenuFormat);
463: menuBar.add(jMenuGo);
464: menuBar.add(jMenuHelp);
465: this .setJMenuBar(menuBar);
466: //contentPane.add(toolBar, BorderLayout.NORTH);
467: contentPane.add(statusBar, BorderLayout.SOUTH);
468: contentPane.add(splitPane, BorderLayout.CENTER);
469: splitPane.add(projectsPanel, JSplitPane.TOP);
470: splitPane.add(workPanel, JSplitPane.BOTTOM);
471: jMenuEdit.add(jMenuEditUndo);
472: jMenuEdit.add(jMenuEditRedo);
473: jMenuEdit.addSeparator();
474: jMenuEdit.add(jMenuEditCut);
475: jMenuEdit.add(jMenuEditCopy);
476: jMenuEdit.add(jMenuEditPaste);
477: jMenuEdit.add(jMenuEditPasteSpec);
478: jMenuEdit.addSeparator();
479: jMenuEdit.add(jMenuEditSelectAll);
480: jMenuEdit.addSeparator();
481: jMenuEdit.add(jMenuEditFind);
482:
483: jMenuInsert.add(jMenuInsertImage);
484: jMenuInsert.add(jMenuInsertTable);
485: jMenuInsert.add(jMenuInsertLink);
486: jMenuInsert.add(jMenuInsertList);
487: //jMenuInsert.add(jMenuInsertSpecial);
488: jMenuInsertList.add(jMenuInsertListUL);
489: jMenuInsertList.add(jMenuInsertListOL);
490: jMenuInsert.addSeparator();
491: jMenuInsert.add(jMenuInsertBR);
492: jMenuInsert.add(jMenuInsertHR);
493: jMenuInsert.add(jMenuInsertChar);
494: jMenuInsert.addSeparator();
495: jMenuInsert.add(jMenuInsertDate);
496: jMenuInsert.add(jMenuInsertTime);
497: jMenuInsert.addSeparator();
498: jMenuInsert.add(jMenuInsertFile);
499:
500: jMenuFormat.add(jMenuFormatPStyle);
501: jMenuFormat.add(jjMenuFormatChStyle);
502: jMenuFormat.add(jMenuFormatAlign);
503: jMenuFormat.addSeparator();
504: jMenuFormat.add(jMenuFormatTable);
505: jMenuFormat.addSeparator();
506: jMenuFormat.add(jMenuFormatProperties);
507: jMenuFormatPStyle.add(jMenuFormatP);
508: jMenuFormatPStyle.addSeparator();
509: jMenuFormatPStyle.add(jMenuFormatH1);
510: jMenuFormatPStyle.add(jMenuFormatH2);
511: jMenuFormatPStyle.add(jMenuFormatH3);
512: jMenuFormatPStyle.add(jMenuFormatH4);
513: jMenuFormatPStyle.add(jMenuFormatH5);
514: jMenuFormatPStyle.add(jMenuFormatH6);
515: jMenuFormatPStyle.addSeparator();
516: jMenuFormatPStyle.add(jMenuFormatPRE);
517: jMenuFormatPStyle.add(jMenuFormatBLCQ);
518: jjMenuFormatChStyle.add(jMenuFormatChNorm);
519: jjMenuFormatChStyle.addSeparator();
520: jjMenuFormatChStyle.add(jMenuFormatChB);
521: jjMenuFormatChStyle.add(jMenuFormatChI);
522: jjMenuFormatChStyle.add(jMenuFormatChU);
523: jjMenuFormatChStyle.addSeparator();
524: jjMenuFormatChStyle.add(jMenuFormatChEM);
525: jjMenuFormatChStyle.add(jMenuFormatChSTRONG);
526: jjMenuFormatChStyle.add(jMenuFormatChCODE);
527: jjMenuFormatChStyle.add(jMenuFormatChCite);
528: jjMenuFormatChStyle.addSeparator();
529: jjMenuFormatChStyle.add(jMenuFormatChSUP);
530: jjMenuFormatChStyle.add(jMenuFormatChSUB);
531: jjMenuFormatChStyle.addSeparator();
532: jjMenuFormatChStyle.add(jMenuFormatChCustom);
533: jMenuFormatAlign.add(jMenuFormatAlignL);
534: jMenuFormatAlign.add(jMenuFormatAlignC);
535: jMenuFormatAlign.add(jMenuFormatAlignR);
536: jMenuFormatTable.add(jMenuFormatTableInsR);
537: jMenuFormatTable.add(jMenuFormatTableInsC);
538: jMenuGo.add(jMenuGoHBack);
539: jMenuGo.add(jMenuGoFwd);
540: jMenuGo.addSeparator();
541: jMenuGo.add(jMenuGoDayBack);
542: jMenuGo.add(jMenuGoDayFwd);
543: jMenuGo.add(jMenuGoToday);
544:
545: splitPane.setBorder(null);
546: workPanel.setBorder(null);
547:
548: setEnabledEditorMenus(false);
549:
550: projectsPanel.AddExpandListener(new ActionListener() {
551: public void actionPerformed(ActionEvent e) {
552: if (prPanelExpanded) {
553: prPanelExpanded = false;
554: splitPane.setDividerLocation(28);
555: } else {
556: prPanelExpanded = true;
557: splitPane.setDividerLocation(0.2);
558: }
559: }
560: });
561:
562: java.awt.event.ActionListener setMenusDisabled = new java.awt.event.ActionListener() {
563: public void actionPerformed(ActionEvent e) {
564: setEnabledEditorMenus(false);
565: }
566: };
567:
568: this .workPanel.dailyItemsPanel.taskB
569: .addActionListener(setMenusDisabled);
570: this .workPanel.dailyItemsPanel.alarmB
571: .addActionListener(setMenusDisabled);
572:
573: this .workPanel.tasksB.addActionListener(setMenusDisabled);
574: this .workPanel.eventsB.addActionListener(setMenusDisabled);
575: this .workPanel.filesB.addActionListener(setMenusDisabled);
576: this .workPanel.agendaB.addActionListener(setMenusDisabled);
577:
578: this .workPanel.notesB
579: .addActionListener(new java.awt.event.ActionListener() {
580: public void actionPerformed(ActionEvent e) {
581: setEnabledEditorMenus(true);
582: }
583: });
584:
585: Object fwo = Context.get("FRAME_WIDTH");
586: Object fho = Context.get("FRAME_HEIGHT");
587: if ((fwo != null) && (fho != null)) {
588: int w = new Integer((String) fwo).intValue();
589: int h = new Integer((String) fho).intValue();
590: this .setSize(w, h);
591: } else
592: this .setExtendedState(Frame.MAXIMIZED_BOTH);
593:
594: Object xo = Context.get("FRAME_XPOS");
595: Object yo = Context.get("FRAME_YPOS");
596: if ((xo != null) && (yo != null)) {
597: int x = new Integer((String) xo).intValue();
598: int y = new Integer((String) yo).intValue();
599: this .setLocation(x, y);
600: }
601:
602: String pan = (String) Context.get("CURRENT_PANEL");
603: if (pan != null) {
604: workPanel.selectPanel(pan);
605: setEnabledEditorMenus(pan.equalsIgnoreCase("NOTES"));
606: }
607:
608: CurrentProject.addProjectListener(new ProjectListener() {
609:
610: public void projectChange(Project prj, NoteList nl,
611: TaskList tl, ResourcesList rl) {
612: }
613:
614: public void projectWasChanged() {
615: setTitle("Memoranda - "
616: + CurrentProject.get().getTitle());
617: }
618: });
619:
620: }
621:
622: protected void jMenuHelpBug_actionPerformed(ActionEvent e) {
623: Util.runBrowser(App.BUGS_TRACKER_URL);
624: }
625:
626: protected void jMenuHelpWeb_actionPerformed(ActionEvent e) {
627: Util.runBrowser(App.WEBSITE_URL);
628: }
629:
630: protected void jMenuHelpGuide_actionPerformed(ActionEvent e) {
631: Util.runBrowser(App.GUIDE_URL);
632: }
633:
634: //File | Exit action performed
635: public void doExit() {
636: if (Configuration.get("ASK_ON_EXIT").equals("yes")) {
637: Dimension frmSize = this .getSize();
638: Point loc = this .getLocation();
639:
640: ExitConfirmationDialog dlg = new ExitConfirmationDialog(
641: this , Local.getString("Exit"));
642: dlg.setLocation((frmSize.width - dlg.getSize().width) / 2
643: + loc.x, (frmSize.height - dlg.getSize().height)
644: / 2 + loc.y);
645: dlg.setVisible(true);
646: if (dlg.CANCELLED)
647: return;
648: }
649:
650: Context.put("FRAME_WIDTH", new Integer(this .getWidth()));
651: Context.put("FRAME_HEIGHT", new Integer(this .getHeight()));
652: Context.put("FRAME_XPOS", new Integer(this .getLocation().x));
653: Context.put("FRAME_YPOS", new Integer(this .getLocation().y));
654: exitNotify();
655: System.exit(0);
656: }
657:
658: public void doMinimize() {
659: exitNotify();
660: App.closeWindow();
661: }
662:
663: //Help | About action performed
664: public void jMenuHelpAbout_actionPerformed(ActionEvent e) {
665: AppFrame_AboutBox dlg = new AppFrame_AboutBox(this );
666: Dimension dlgSize = dlg.getSize();
667: Dimension frmSize = getSize();
668: Point loc = getLocation();
669: dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x,
670: (frmSize.height - dlgSize.height) / 2 + loc.y);
671: dlg.setModal(true);
672: dlg.setVisible(true);
673: }
674:
675: protected void processWindowEvent(WindowEvent e) {
676: if (e.getID() == WindowEvent.WINDOW_CLOSING) {
677: if (Configuration.get("ON_CLOSE").equals("exit"))
678: doExit();
679: else
680: doMinimize();
681: } else if ((e.getID() == WindowEvent.WINDOW_ICONIFIED)
682: && Configuration.get("ON_MINIMIZE").equals("systray")
683: && !App.sysTrayDisabled) {
684: super .processWindowEvent(new WindowEvent(this ,
685: WindowEvent.WINDOW_CLOSING));
686: doMinimize();
687: } else
688: super .processWindowEvent(e);
689: }
690:
691: public static void addExitListener(ActionListener al) {
692: exitListeners.add(al);
693: }
694:
695: public static Collection getExitListeners() {
696: return exitListeners;
697: }
698:
699: private static void exitNotify() {
700: for (int i = 0; i < exitListeners.size(); i++)
701: ((ActionListener) exitListeners.get(i))
702: .actionPerformed(null);
703: }
704:
705: public void setEnabledEditorMenus(boolean enabled) {
706: this .jMenuEdit.setEnabled(enabled);
707: this .jMenuFormat.setEnabled(enabled);
708: this .jMenuInsert.setEnabled(enabled);
709: this .jMenuFileNewNote.setEnabled(enabled);
710: this .jMenuFileExportNote.setEnabled(enabled);
711: }
712:
713: public void doPrjPack() {
714: // Fix until Sun's JVM supports more locales...
715: UIManager.put("FileChooser.saveInLabelText", Local
716: .getString("Save in:"));
717: UIManager.put("FileChooser.upFolderToolTipText", Local
718: .getString("Up One Level"));
719: UIManager.put("FileChooser.newFolderToolTipText", Local
720: .getString("Create New Folder"));
721: UIManager.put("FileChooser.listViewButtonToolTipText", Local
722: .getString("List"));
723: UIManager.put("FileChooser.detailsViewButtonToolTipText", Local
724: .getString("Details"));
725: UIManager.put("FileChooser.fileNameLabelText", Local
726: .getString("File Name:"));
727: UIManager.put("FileChooser.filesOfTypeLabelText", Local
728: .getString("Files of Type:"));
729: UIManager.put("FileChooser.saveButtonText", Local
730: .getString("Save"));
731: UIManager.put("FileChooser.saveButtonToolTipText", Local
732: .getString("Save selected file"));
733: UIManager.put("FileChooser.cancelButtonText", Local
734: .getString("Cancel"));
735: UIManager.put("FileChooser.cancelButtonToolTipText", Local
736: .getString("Cancel"));
737:
738: JFileChooser chooser = new JFileChooser();
739: chooser.setFileHidingEnabled(false);
740: chooser.setDialogTitle(Local.getString("Pack project"));
741: chooser.setAcceptAllFileFilterUsed(false);
742: chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
743: //chooser.addChoosableFileFilter(new AllFilesFilter(AllFilesFilter.RTF));
744: chooser.addChoosableFileFilter(new AllFilesFilter(
745: AllFilesFilter.ZIP));
746: // fixes XP style look cosmetical problems JVM 1.4.2 and 1.4.2_01
747: chooser.setPreferredSize(new Dimension(550, 375));
748:
749: //Added to fix the problem with packing a file then deleting that file.
750: //(jcscoobyrs) 17-Nov-2003 at 14:57:06 PM
751: //---------------------------------------------------------------------
752: File lastSel = null;
753:
754: try {
755: lastSel = (java.io.File) Context
756: .get("LAST_SELECTED_PACK_FILE");
757: } catch (ClassCastException cce) {
758: lastSel = new File(System.getProperty("user.dir")
759: + File.separator);
760: }
761: //---------------------------------------------------------------------
762:
763: if (lastSel != null)
764: chooser.setCurrentDirectory(lastSel);
765: if (chooser.showSaveDialog(this ) != JFileChooser.APPROVE_OPTION)
766: return;
767: Context.put("LAST_SELECTED_PACK_FILE", chooser
768: .getSelectedFile());
769: java.io.File f = chooser.getSelectedFile();
770: ProjectPackager.pack(CurrentProject.get(), f);
771: }
772:
773: public void doPrjUnPack() {
774: // Fix until Sun's JVM supports more locales...
775: UIManager.put("FileChooser.lookInLabelText", Local
776: .getString("Look in:"));
777: UIManager.put("FileChooser.upFolderToolTipText", Local
778: .getString("Up One Level"));
779: UIManager.put("FileChooser.newFolderToolTipText", Local
780: .getString("Create New Folder"));
781: UIManager.put("FileChooser.listViewButtonToolTipText", Local
782: .getString("List"));
783: UIManager.put("FileChooser.detailsViewButtonToolTipText", Local
784: .getString("Details"));
785: UIManager.put("FileChooser.fileNameLabelText", Local
786: .getString("File Name:"));
787: UIManager.put("FileChooser.filesOfTypeLabelText", Local
788: .getString("Files of Type:"));
789: UIManager.put("FileChooser.openButtonText", Local
790: .getString("Open"));
791: UIManager.put("FileChooser.openButtonToolTipText", Local
792: .getString("Open selected file"));
793: UIManager.put("FileChooser.cancelButtonText", Local
794: .getString("Cancel"));
795: UIManager.put("FileChooser.cancelButtonToolTipText", Local
796: .getString("Cancel"));
797:
798: JFileChooser chooser = new JFileChooser();
799: chooser.setFileHidingEnabled(false);
800: chooser.setDialogTitle(Local.getString("Unpack project"));
801: chooser.setAcceptAllFileFilterUsed(false);
802: chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
803: chooser.addChoosableFileFilter(new AllFilesFilter(
804: AllFilesFilter.ZIP));
805: //chooser.addChoosableFileFilter(new AllFilesFilter(AllFilesFilter.RTF));
806: // fixes XP style look cosmetical problems JVM 1.4.2 and 1.4.2_01
807: chooser.setPreferredSize(new Dimension(550, 375));
808:
809: //Added to fix the problem with packing a file then deleting that file.
810: //(jcscoobyrs) 17-Nov-2003 at 14:57:06 PM
811: //---------------------------------------------------------------------
812: File lastSel = null;
813:
814: try {
815: lastSel = (java.io.File) Context
816: .get("LAST_SELECTED_PACK_FILE");
817: } catch (ClassCastException cce) {
818: lastSel = new File(System.getProperty("user.dir")
819: + File.separator);
820: }
821: //---------------------------------------------------------------------
822:
823: if (lastSel != null)
824: chooser.setCurrentDirectory(lastSel);
825: if (chooser.showOpenDialog(this ) != JFileChooser.APPROVE_OPTION)
826: return;
827: Context.put("LAST_SELECTED_PACK_FILE", chooser
828: .getSelectedFile());
829: java.io.File f = chooser.getSelectedFile();
830: ProjectPackager.unpack(f);
831: projectsPanel.prjTablePanel.updateUI();
832: }
833:
834: public void showPreferences() {
835: PreferencesDialog dlg = new PreferencesDialog(this );
836: dlg.pack();
837: dlg.setLocationRelativeTo(this );
838: dlg.setVisible(true);
839: }
840:
841: protected void ppExport_actionPerformed(ActionEvent e) {
842: // Fix until Sun's JVM supports more locales...
843: UIManager.put("FileChooser.lookInLabelText", Local
844: .getString("Save in:"));
845: UIManager.put("FileChooser.upFolderToolTipText", Local
846: .getString("Up One Level"));
847: UIManager.put("FileChooser.newFolderToolTipText", Local
848: .getString("Create New Folder"));
849: UIManager.put("FileChooser.listViewButtonToolTipText", Local
850: .getString("List"));
851: UIManager.put("FileChooser.detailsViewButtonToolTipText", Local
852: .getString("Details"));
853: UIManager.put("FileChooser.fileNameLabelText", Local
854: .getString("File Name:"));
855: UIManager.put("FileChooser.filesOfTypeLabelText", Local
856: .getString("Files of Type:"));
857: UIManager.put("FileChooser.saveButtonText", Local
858: .getString("Save"));
859: UIManager.put("FileChooser.saveButtonToolTipText", Local
860: .getString("Save selected file"));
861: UIManager.put("FileChooser.cancelButtonText", Local
862: .getString("Cancel"));
863: UIManager.put("FileChooser.cancelButtonToolTipText", Local
864: .getString("Cancel"));
865:
866: JFileChooser chooser = new JFileChooser();
867: chooser.setFileHidingEnabled(false);
868: chooser.setDialogTitle(Local.getString("Export notes"));
869: chooser.setAcceptAllFileFilterUsed(false);
870: chooser
871: .setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
872: chooser.addChoosableFileFilter(new AllFilesFilter(
873: AllFilesFilter.XHTML));
874: chooser.addChoosableFileFilter(new AllFilesFilter(
875: AllFilesFilter.HTML));
876:
877: String lastSel = (String) Context
878: .get("LAST_SELECTED_EXPORT_FILE");
879: if (lastSel != null)
880: chooser.setCurrentDirectory(new File(lastSel));
881:
882: ProjectExportDialog dlg = new ProjectExportDialog(App
883: .getFrame(), Local.getString("Export notes"), chooser);
884: String enc = (String) Context.get("EXPORT_FILE_ENCODING");
885: if (enc != null)
886: dlg.encCB.setSelectedItem(enc);
887: String spl = (String) Context.get("EXPORT_SPLIT_NOTES");
888: if (spl != null)
889: dlg.splitChB.setSelected(spl.equalsIgnoreCase("true"));
890: String ti = (String) Context.get("EXPORT_TITLES_AS_HEADERS");
891: if (ti != null)
892: dlg.titlesAsHeadersChB.setSelected(ti
893: .equalsIgnoreCase("true"));
894: Dimension dlgSize = new Dimension(550, 500);
895: dlg.setSize(dlgSize);
896: Dimension frmSize = App.getFrame().getSize();
897: Point loc = App.getFrame().getLocation();
898: dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x,
899: (frmSize.height - dlgSize.height) / 2 + loc.y);
900: dlg.setVisible(true);
901: if (dlg.CANCELLED)
902: return;
903:
904: Context.put("LAST_SELECTED_EXPORT_FILE", chooser
905: .getSelectedFile().getPath());
906: Context.put("EXPORT_SPLIT_NOTES", new Boolean(dlg.splitChB
907: .isSelected()).toString());
908: Context.put("EXPORT_TITLES_AS_HEADERS", new Boolean(
909: dlg.titlesAsHeadersChB.isSelected()).toString());
910:
911: int ei = dlg.encCB.getSelectedIndex();
912: enc = null;
913: if (ei == 1)
914: enc = "UTF-8";
915: boolean nument = (ei == 2);
916: File f = chooser.getSelectedFile();
917: boolean xhtml = chooser.getFileFilter().getDescription()
918: .indexOf("XHTML") > -1;
919: CurrentProject.save();
920: ProjectExporter.export(CurrentProject.get(), chooser
921: .getSelectedFile(), enc, xhtml, dlg.splitChB
922: .isSelected(), true, nument, dlg.titlesAsHeadersChB
923: .isSelected(), false);
924: }
925:
926: }
|