current work at override settings
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 2 Jun 2008 07:04:38 +0000 (09:04 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 2 Jun 2008 07:04:38 +0000 (09:04 +0200)
src/net/pterodactylus/jsite/gui/FileManager.java
src/net/pterodactylus/jsite/i18n/jSite.properties
src/net/pterodactylus/jsite/i18n/jSite_de.properties

index cdfc9d1..56cf245 100644 (file)
@@ -43,6 +43,8 @@ import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javax.swing.AbstractAction;
+import javax.swing.Action;
 import javax.swing.BorderFactory;
 import javax.swing.JButton;
 import javax.swing.JCheckBox;
@@ -139,6 +141,24 @@ public class FileManager extends JDialog implements I18nable, ActionListener, Tr
        /** The “override” label. */
        private I18nLabel fileSettingsLabel;
 
+       /** The “insert default” label. */
+       private I18nLabel insertDefaultLabel;
+
+       /** The “insert default” checkbox. */
+       private JCheckBox insertDefaultCheckBox;
+
+       /** The “override insert default” action. */
+       private I18nAction overrideInsertDefaultAction;
+
+       /** The “override insert default” checkbox. */
+       private JCheckBox overrideInsertDefaultCheckBox;
+
+       /** The “override insert” action. */
+       private Action insertOverrideAction;
+
+       /** The “override insert” checkbox. */
+       private JCheckBox insertOverrideCheckBox;
+
        /** The context menu for the tree. */
        private JPopupMenu treeContextMenu;
 
@@ -287,6 +307,48 @@ public class FileManager extends JDialog implements I18nable, ActionListener, Tr
                                removeOverride();
                        }
                };
+               overrideInsertDefaultAction = new I18nAction("fileManager.checkbox.overrideInsertDefault") {
+
+                       /**
+                        * {@inheritDoc}
+                        */
+                       @SuppressWarnings("synthetic-access")
+                       public void actionPerformed(ActionEvent actionEvent) {
+                               boolean overrideInsert = overrideInsertDefaultCheckBox.isSelected();
+                               insertOverrideAction.setEnabled(overrideInsert);
+                               List<ProjectFileWrapper> selectedProjectFileWrappers = getSelectedProjectFileWrappers(true);
+                               ProjectFileWrapper projectFileWrapper = selectedProjectFileWrappers.get(0);
+                               ProjectFile projectFile = projectFileWrapper.getProjectFile();
+                               FileOverride fileOverride = project.getFileOverride(projectFile);
+                               if (overrideInsert) {
+                                       if (fileOverride == null) {
+                                               fileOverride = new FileOverride();
+                                               project.addFileOverride(projectFile, fileOverride);
+                                               fileOverride.setInsert(!projectFile.isHidden());
+                                       }
+                               } else {
+                                       fileOverride.setInsert(null);
+                                       if (fileOverride.isEmpty()) {
+                                               project.removeFileOverride(projectFile);
+                                       }
+                               }
+                       }
+               };
+               insertOverrideAction = new AbstractAction() {
+
+                       /**
+                        * {@inheritDoc}
+                        */
+                       public void actionPerformed(ActionEvent actionEvent) {
+                               boolean insertOverride = insertOverrideCheckBox.isSelected();
+                               List<ProjectFileWrapper> selectedProjectFileWrappers = getSelectedProjectFileWrappers(true);
+                               ProjectFileWrapper projectFileWrapper = selectedProjectFileWrappers.get(0);
+                               ProjectFile projectFile = projectFileWrapper.getProjectFile();
+                               FileOverride fileOverride = project.getFileOverride(projectFile);
+                               fileOverride.setInsert(insertOverride);
+                       }
+               };
+               insertOverrideAction.setEnabled(false);
        }
 
        /**
@@ -350,33 +412,43 @@ public class FileManager extends JDialog implements I18nable, ActionListener, Tr
 
                filePropertiesLabel = new I18nLabel("fileManager.label.fileProperties");
                filePropertiesLabel.setFont(filePropertiesLabel.getFont().deriveFont(Font.BOLD));
-               propertiesPanel.add(filePropertiesLabel, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
+               propertiesPanel.add(filePropertiesLabel, new GridBagConstraints(0, 0, 4, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
 
                filePathLabel = new I18nLabel("fileManager.label.filePath");
                filePathTextField = new JTextField();
                filePathTextField.setEditable(false);
                propertiesPanel.add(filePathLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(12, 24, 0, 0), 0, 0));
-               propertiesPanel.add(filePathTextField, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(12, 12, 0, 0), 0, 0));
+               propertiesPanel.add(filePathTextField, new GridBagConstraints(1, 1, 3, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(12, 12, 0, 0), 0, 0));
 
                fileNameLabel = new I18nLabel("fileManager.label.fileName");
                fileNameTextField = new JTextField();
                fileNameTextField.setEditable(false);
                propertiesPanel.add(fileNameLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(12, 24, 0, 0), 0, 0));
-               propertiesPanel.add(fileNameTextField, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(12, 12, 0, 0), 0, 0));
+               propertiesPanel.add(fileNameTextField, new GridBagConstraints(1, 2, 3, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(12, 12, 0, 0), 0, 0));
 
                fileSizeLabel = new I18nLabel("fileManager.label.fileSize");
                fileSizeTextField = new JTextField();
                fileSizeTextField.setEditable(false);
                propertiesPanel.add(fileSizeLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(12, 24, 0, 0), 0, 0));
-               propertiesPanel.add(fileSizeTextField, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(12, 12, 0, 0), 0, 0));
+               propertiesPanel.add(fileSizeTextField, new GridBagConstraints(1, 3, 3, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(12, 12, 0, 0), 0, 0));
 
-               /* override settings. */
+               /* file settings. */
                fileSettingsLabel = new I18nLabel("fileManager.label.fileSettings");
                fileSettingsLabel.setFont(fileSettingsLabel.getFont().deriveFont(Font.BOLD));
-               propertiesPanel.add(fileSettingsLabel, new GridBagConstraints(0, 4, 2, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(24, 0, 0, 0), 0, 0));
+               propertiesPanel.add(fileSettingsLabel, new GridBagConstraints(0, 4, 4, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(24, 0, 0, 0), 0, 0));
+
+               insertDefaultLabel = new I18nLabel("fileManager.label.insertDefault");
+               propertiesPanel.add(insertDefaultLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(12, 24, 0, 0), 0, 0));
+               insertDefaultCheckBox = new JCheckBox();
+               insertDefaultCheckBox.setEnabled(false);
+               propertiesPanel.add(insertDefaultCheckBox, new GridBagConstraints(1, 5, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(12, 12, 0, 0), 0, 0));
+               overrideInsertDefaultCheckBox = new JCheckBox(overrideInsertDefaultAction);
+               propertiesPanel.add(overrideInsertDefaultCheckBox, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(12, 12, 0, 0), 0, 0));
+               insertOverrideCheckBox = new JCheckBox(insertOverrideAction);
+               propertiesPanel.add(insertOverrideCheckBox, new GridBagConstraints(3, 5, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(12, 12, 0, 0), 0, 0));
 
                /* glue panel. */
-               propertiesPanel.add(new JPanel(), new GridBagConstraints(0, 7, 2, 1, 1.0, 1.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
+               propertiesPanel.add(new JPanel(), new GridBagConstraints(0, 6, 4, 1, 1.0, 1.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
 
                /* action button panel */
                JPanel actionButtonPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 12, 12));
@@ -589,17 +661,12 @@ public class FileManager extends JDialog implements I18nable, ActionListener, Tr
         * {@inheritDoc}
         */
        public void valueChanged(TreeSelectionEvent treeSelectionEvent) {
-               TreePath[] selectedPaths = fileTree.getSelectionPaths();
+               List<ProjectFileWrapper> selectedProjectFileWrappers = getSelectedProjectFileWrappers(true);
                filePathTextField.setText("");
                fileNameTextField.setText("");
                fileSizeTextField.setText("");
-               if ((selectedPaths != null) && (selectedPaths.length == 1)) {
-                       Object lastPathComponent = selectedPaths[0].getLastPathComponent();
-                       if (!(lastPathComponent instanceof ProjectFileWrapper)) {
-                               logger.log(Level.SEVERE, "lastPathComponent is not a ProjectFileWrapper!");
-                               return;
-                       }
-                       ProjectFileWrapper projectFileWrapper = (ProjectFileWrapper) lastPathComponent;
+               if (selectedProjectFileWrappers.size() == 1) {
+                       ProjectFileWrapper projectFileWrapper = selectedProjectFileWrappers.get(0);
                        ProjectFile projectFile = projectFileWrapper.getProjectFile();
                        if (projectFile.isFile()) {
                                String completePath = projectFile.getCompletePath();
@@ -611,9 +678,32 @@ public class FileManager extends JDialog implements I18nable, ActionListener, Tr
                                }
                                fileNameTextField.setText(projectFile.getName());
                                fileSizeTextField.setText(String.valueOf(projectFile.getSize()));
+                               overrideInsertDefaultCheckBox.setEnabled(true);
+                               insertDefaultCheckBox.setSelected(!projectFile.isHidden());
+                               FileOverride fileOverride = project.getFileOverride(projectFile);
+                               if (fileOverride != null) {
+                                       Boolean overrideInsert = fileOverride.isInsert();
+                                       insertOverrideCheckBox.setEnabled(overrideInsert != null);
+                                       if (overrideInsert != null) {
+                                               overrideInsertDefaultCheckBox.setSelected(true);
+                                               insertOverrideCheckBox.setSelected(overrideInsert);
+                                       } else {
+                                               overrideInsertDefaultCheckBox.setSelected(false);
+                                               insertOverrideCheckBox.setSelected(!projectFile.isHidden());
+                                       }
+                               } else {
+                                       overrideInsertDefaultCheckBox.setSelected(false);
+                                       insertOverrideCheckBox.setEnabled(false);
+                                       insertOverrideCheckBox.setSelected(!projectFile.isHidden());
+                               }
                        }
-               } else if ((selectedPaths != null) && (selectedPaths.length > 1)) {
-                       /* TODO */
+               } else if (selectedProjectFileWrappers.size() > 1) {
+                       insertDefaultCheckBox.setEnabled(false);
+                       insertDefaultCheckBox.setSelected(false);
+                       overrideInsertDefaultAction.setEnabled(false);
+                       overrideInsertDefaultCheckBox.setSelected(false);
+                       insertOverrideAction.setEnabled(false);
+                       insertOverrideCheckBox.setSelected(false);
                }
        }
 
@@ -700,11 +790,18 @@ public class FileManager extends JDialog implements I18nable, ActionListener, Tr
                        }
                        ProjectFileWrapper projectFileWrapper = (ProjectFileWrapper) value;
                        ProjectFile projectFile = projectFileWrapper.getProjectFile();
+                       FileOverride fileOverride = project.getFileOverride(projectFile);
                        String completePath = projectFile.getCompletePath();
                        boolean paintBold = false;
                        boolean paintHalfColor = false;
-                       if (projectFile.isFile() && projectFile.isHidden()) {
-                               /* TODO - check override */
+                       boolean showFile = !projectFile.isHidden();
+                       if (fileOverride != null) {
+                               Boolean insertOverride = fileOverride.isInsert();
+                               if (insertOverride != null) {
+                                       showFile = insertOverride;
+                               }
+                       }
+                       if (projectFile.isFile() && !showFile) {
                                paintHalfColor = true;
                        } else if (completePath.equals(project.getDefaultFile())) {
                                paintBold = true;
index b5bdb61..25599b6 100644 (file)
@@ -364,6 +364,15 @@ fileManager.label.fileSize.mnemonic: VK_UNDEFINED
 fileManager.label.fileSettings.name: File Settings
 fileManager.label.fileSettings.mnemonic: VK_UNDEFINED
 
+fileManager.label.insertDefault.name: Insert Default
+fileManager.label.insertDefault.mnemonic: VK_UNDEFINED
+
+fileManager.checkbox.overrideInsertDefault.name: Override
+fileManager.checkbox.overrideInsertDefault.mnemonic: VK_I
+fileManager.checkbox.overrideInsertDefault.accelerator: VK_UNDEFINED
+fileManager.checkbox.overrideInsertDefault.shortDescription: Overrides the default \u201cInsert\u201d setting
+fileManager.checkbox.overrideInsertDefault.longDescription: Overrides the default \u201cInsert\u201d setting
+
 fileManager.menu.item.setDefaultFile.name: Set as default file
 fileManager.menu.item.setDefaultFile.mnemonic: VK_D
 fileManager.menu.item.setDefaultFile.accelerator: VK_UNDEFINED
index 72f68a8..04a3317 100644 (file)
@@ -364,6 +364,15 @@ fileManager.label.fileSize.mnemonic: VK_UNDEFINED
 fileManager.label.fileSettings.name: Dateieinstellungen
 fileManager.label.fileSettings.mnemonic: VK_UNDEFINED
 
+fileManager.label.insertDefault.name: Einf\u00fcgen
+fileManager.label.insertDefault.mnemonic: VK_UNDEFINED
+
+fileManager.checkbox.overrideInsertDefault.name: \u00dcberschreiben
+fileManager.checkbox.overrideInsertDefault.mnemonic: VK_E
+fileManager.checkbox.overrideInsertDefault.accelerator: VK_UNDEFINED
+fileManager.checkbox.overrideInsertDefault.shortDescription: \u00dcberschreibt die \u201eEinf\u00fcgen\u201c-Einstellung
+fileManager.checkbox.overrideInsertDefault.longDescription: \u00dcberschreibt die \u201eEinf\u00fcgen\u201c-Einstellung
+
 fileManager.menu.item.setDefaultFile.name: Als Indexdatei benutzen
 fileManager.menu.item.setDefaultFile.mnemonic: VK_I
 fileManager.menu.item.setDefaultFile.accelerator: VK_UNDEFINED