Search in sources :

Example 11 with DefaultSchemeHandler

use of com.mucommander.commons.file.DefaultSchemeHandler in project mucommander by mucommander.

the class Activator method start.

@Override
public void start(BundleContext context) throws Exception {
    FileProtocolService service = new FileProtocolService() {

        @Override
        public String getSchema() {
            return "hdfs";
        }

        @Override
        public ProtocolProvider getProtocolProvider() {
            return new HDFSProtocolProvider();
        }

        @Override
        public SchemeHandler getSchemeHandler() {
            return new DefaultSchemeHandler(new DefaultSchemeParser(true), 8020, "/", AuthenticationType.AUTHENTICATION_OPTIONAL, null);
        }
    };
    ProtocolPanelProvider panelProvider = new ProtocolPanelProvider() {

        @Override
        public String getSchema() {
            return "hdfs";
        }

        @Override
        public ServerPanel get(ServerPanelListener listener, JFrame mainFrame) {
            return new HDFSPanel(listener, mainFrame);
        }

        @Override
        public int priority() {
            return Integer.MAX_VALUE;
        }
    };
    serviceRegistration = context.registerService(FileProtocolService.class, service, null);
    uiServiceRegistration = context.registerService(ProtocolPanelProvider.class, panelProvider, null);
}
Also used : ServerPanelListener(com.mucommander.protocol.ui.ServerPanelListener) DefaultSchemeParser(com.mucommander.commons.file.DefaultSchemeParser) JFrame(javax.swing.JFrame) ProtocolPanelProvider(com.mucommander.protocol.ui.ProtocolPanelProvider) FileProtocolService(com.mucommander.commons.file.osgi.FileProtocolService) DefaultSchemeHandler(com.mucommander.commons.file.DefaultSchemeHandler)

Example 12 with DefaultSchemeHandler

use of com.mucommander.commons.file.DefaultSchemeHandler in project mucommander by mucommander.

the class Activator method start.

@Override
public void start(BundleContext context) throws Exception {
    FileProtocolService service = new FileProtocolService() {

        @Override
        public String getSchema() {
            return "smb";
        }

        @Override
        public ProtocolProvider getProtocolProvider() {
            return new SMBProtocolProvider();
        }

        @Override
        public SchemeHandler getSchemeHandler() {
            return new DefaultSchemeHandler(new DefaultSchemeParser(), -1, "/", AuthenticationType.AUTHENTICATION_REQUIRED, new Credentials("GUEST", "")) {

                @Override
                public FileURL getRealm(FileURL location) {
                    FileURL realm = new FileURL(this);
                    String newPath = location.getPath();
                    // Find first path token (share)
                    int pos = newPath.indexOf('/', 1);
                    newPath = newPath.substring(0, pos == -1 ? newPath.length() : pos + 1);
                    realm.setPath(newPath);
                    realm.setScheme(location.getScheme());
                    realm.setHost(location.getHost());
                    realm.setPort(location.getPort());
                    // Copy properties (if any)
                    realm.importProperties(location);
                    return realm;
                }
            };
        }
    };
    ProtocolPanelProvider panelProvider = new ProtocolPanelProvider() {

        @Override
        public String getSchema() {
            return "smb";
        }

        @Override
        public ServerPanel get(ServerPanelListener listener, JFrame mainFrame) {
            return new SMBPanel(listener, mainFrame);
        }

        @Override
        public int priority() {
            return 4000;
        }

        @Override
        public Class<? extends ServerPanel> getPanelClass() {
            return SMBPanel.class;
        }
    };
    serviceRegistration = context.registerService(FileProtocolService.class, service, null);
    uiServiceRegistration = context.registerService(ProtocolPanelProvider.class, panelProvider, null);
}
Also used : FileURL(com.mucommander.commons.file.FileURL) ServerPanelListener(com.mucommander.protocol.ui.ServerPanelListener) DefaultSchemeParser(com.mucommander.commons.file.DefaultSchemeParser) JFrame(javax.swing.JFrame) ProtocolPanelProvider(com.mucommander.protocol.ui.ProtocolPanelProvider) Credentials(com.mucommander.commons.file.Credentials) FileProtocolService(com.mucommander.commons.file.osgi.FileProtocolService) DefaultSchemeHandler(com.mucommander.commons.file.DefaultSchemeHandler)

Aggregations

DefaultSchemeHandler (com.mucommander.commons.file.DefaultSchemeHandler)12 DefaultSchemeParser (com.mucommander.commons.file.DefaultSchemeParser)12 FileProtocolService (com.mucommander.commons.file.osgi.FileProtocolService)12 ProtocolPanelProvider (com.mucommander.protocol.ui.ProtocolPanelProvider)12 ServerPanelListener (com.mucommander.protocol.ui.ServerPanelListener)12 JFrame (javax.swing.JFrame)12 Credentials (com.mucommander.commons.file.Credentials)4 FileURL (com.mucommander.commons.file.FileURL)1