Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /
 
 
 package org.apache.cayenne.modeler.dialog.pref;
 
 import java.io.File;
 import java.util.List;
 
 
 
 public class ClasspathPreferences extends CayenneController {
 
     protected ClasspathPreferencesView view;
     protected PreferenceEditor editor;
     protected List classPathEntries;
     protected ClasspathTableModel tableModel;
 
     public ClasspathPreferences(PreferenceDialog parentController) {
         super(parentController);
 
         this. = parentController.getEditor();
         this. = new ClasspathPreferencesView();
         this. = getClassLoaderDomain().getDetails();
         this. = new ClasspathTableModel();
 
         initBindings();
     }
 
     public Component getView() {
         return ;
     }
 
     protected Domain getClassLoaderDomain() {
         return 
                 .editableInstance(getApplication().getPreferenceDomain())
                 .getSubdomain(FileClassLoadingService.class);
     }
 
     protected void initBindings() {
         .getTable().setModel();
 
 
             public void actionPerformed(ActionEvent e) {
                 addClassDirectoryAction();
             }
         });
 
 
             public void actionPerformed(ActionEvent e) {
                 removeEntryAction();
             }
         });
 
 
             public void actionPerformed(ActionEvent e) {
                 addJarOrZipAction();
             }
         });
     }
 
     protected void addJarOrZipAction() {
         chooseClassEntry(
                 FileFilters.getClassArchiveFilter(),
                 "Select JAR or ZIP File.",
                 .);
     }
    protected void addClassDirectoryAction() {
        chooseClassEntry(
                null,
                "Select Java Class Directory.",
                .);
    }
    protected void removeEntryAction() {
        int selected = .getTable().getSelectedRow();
        if (selected < 0) {
            return;
        }
        PreferenceDetail selection = (PreferenceDetail.remove(selected);
        .deleteDetail(getClassLoaderDomain(), selection.getKey());
        .fireTableRowsDeleted(selectedselected);
    }
    protected void chooseClassEntry(FileFilter filterString titleint selectionMode) {
        JFileChooser chooser = new JFileChooser();
        chooser.setFileSelectionMode(selectionMode);
        chooser.setDialogType(.);
        chooser.setAcceptAllFileFilterUsed(true);
        getLastDirectory().updateChooser(chooser);
        if (filter != null) {
            chooser.addChoosableFileFilter(filter);
        }
        chooser.setDialogTitle(title);
        File selected = null;
        int result = chooser.showOpenDialog();
        if (result == .) {
            selected = chooser.getSelectedFile();
        }
        if (selected != null) {
            // store last dir in preferences
            getLastDirectory().updateFromChooser(chooser);
            int len = .size();
            String key = selected.getAbsolutePath();
            .fireTableRowsInserted(lenlen);
        }
    }
    class ClasspathTableModel extends AbstractTableModel {
        public int getColumnCount() {
            return 1;
        }
        public int getRowCount() {
            return .size();
        }
        public Object getValueAt(int rowIndexint columnIndex) {
            PreferenceDetail preference = (PreferenceDetail
                    .get(rowIndex);
            return preference.getKey();
        }
        public String getColumnName(int column) {
            return "Custom ClassPath";
        }
    }
New to GrepCode? Check out our FAQ X