Search in sources :

Example 1 with ProtocolPanelProvider

use of com.mucommander.protocol.ui.ProtocolPanelProvider 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 "vsphere";
        }

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

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

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

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

        @Override
        public int priority() {
            return 9000;
        }
    };
    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 2 with ProtocolPanelProvider

use of com.mucommander.protocol.ui.ProtocolPanelProvider 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 "http";
        }

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

        @Override
        public SchemeHandler getSchemeHandler() {
            return new DefaultSchemeHandler(new DefaultSchemeParser(true), 80, "/", AuthenticationType.AUTHENTICATION_OPTIONAL, null);
        }
    };
    FileProtocolService service2 = new FileProtocolService() {

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

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

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

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

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

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

        @Override
        public Class<? extends ServerPanel> getPanelClass() {
            return HTTPPanel.class;
        }
    };
    serviceRegistration = context.registerService(FileProtocolService.class, service, null);
    service2Registration = context.registerService(FileProtocolService.class, service2, 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 3 with ProtocolPanelProvider

use of com.mucommander.protocol.ui.ProtocolPanelProvider 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 "ovirt";
        }

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

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

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

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

        @Override
        public int priority() {
            return 7000;
        }
    };
    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 4 with ProtocolPanelProvider

use of com.mucommander.protocol.ui.ProtocolPanelProvider in project mucommander by mucommander.

the class DrivePopupButton method getPopupMenu.

// //////////////////////////////
// PopupButton implementation //
// //////////////////////////////
@Override
public JPopupMenu getPopupMenu() {
    JPopupMenu popupMenu = new JPopupMenu();
    // Update the list of volumes in case new ones were mounted
    volumes = getDisplayableVolumes();
    // Add volumes
    int nbVolumes = volumes.length;
    final MainFrame mainFrame = folderPanel.getMainFrame();
    // Provides mnemonics and ensures uniqueness
    MnemonicHelper mnemonicHelper = new MnemonicHelper();
    JMenuItem item;
    MuAction action;
    String volumeName;
    boolean useExtendedDriveNames = fileSystemView != null;
    ArrayList<JMenuItem> itemsV = new ArrayList<JMenuItem>();
    for (int i = 0; i < nbVolumes; i++) {
        action = new CustomOpenLocationAction(mainFrame, new Hashtable<String, Object>(), volumes[i]);
        volumeName = volumes[i].getName();
        // volume's path, to disambiguate
        for (int j = 0; j < nbVolumes; j++) {
            if (j != i && volumes[j].getName().equalsIgnoreCase(volumeName)) {
                action.setLabel(volumes[i].getAbsolutePath());
                break;
            }
        }
        item = popupMenu.add(action);
        setMnemonic(item, mnemonicHelper);
        // Set icon from cache
        Icon icon = iconCache.get(volumes[i]);
        if (icon != null) {
            item.setIcon(icon);
        }
        if (useExtendedDriveNames) {
            // Use the last known value (if any) while we update it in a separate thread
            String previousExtendedName = extendedNameCache.get(volumes[i]);
            if (previousExtendedName != null)
                item.setText(previousExtendedName);
        }
        // JMenu offers no way to retrieve a particular JMenuItem, so we have to keep them
        itemsV.add(item);
    }
    new RefreshDriveNamesAndIcons(popupMenu, itemsV).start();
    popupMenu.add(new JSeparator());
    // Add boookmarks
    java.util.List<Bookmark> bookmarks = BookmarkManager.getBookmarks();
    if (!bookmarks.isEmpty()) {
        for (Bookmark bookmark : bookmarks) {
            item = popupMenu.add(new CustomOpenLocationAction(mainFrame, new Hashtable<String, Object>(), bookmark));
            setMnemonic(item, mnemonicHelper);
        }
    } else {
        // No bookmark : add a disabled menu item saying there is no bookmark
        popupMenu.add(Translator.get("bookmarks_menu.no_bookmark")).setEnabled(false);
    }
    popupMenu.add(new JSeparator());
    // Add 'Network shares' shortcut
    if (FileFactory.isRegisteredProtocol(FileProtocols.SMB)) {
        action = new CustomOpenLocationAction(mainFrame, new Hashtable<String, Object>(), new Bookmark(Translator.get("drive_popup.network_shares"), "smb:///"));
        action.setIcon(IconManager.getIcon(IconManager.FILE_ICON_SET, CustomFileIconProvider.NETWORK_ICON_NAME));
        setMnemonic(popupMenu.add(action), mnemonicHelper);
    }
    // Add Bonjour services menu
    setMnemonic(popupMenu.add(new BonjourMenu() {

        @Override
        public MuAction getMenuItemAction(BonjourService bs) {
            return new CustomOpenLocationAction(mainFrame, new Hashtable<String, Object>(), bs);
        }
    }), mnemonicHelper);
    popupMenu.add(new JSeparator());
    // Add 'connect to server' shortcuts
    schemaToPanelProvider.values().stream().sorted(Comparator.comparing(ProtocolPanelProvider::priority)).map(this::toServerConnectAction).map(popupMenu::add).forEach(menuItem -> setMnemonic(menuItem, mnemonicHelper));
    return popupMenu;
}
Also used : Hashtable(java.util.Hashtable) ProtocolPanelProvider(com.mucommander.protocol.ui.ProtocolPanelProvider) ArrayList(java.util.ArrayList) MnemonicHelper(com.mucommander.commons.util.ui.helper.MnemonicHelper) JPopupMenu(javax.swing.JPopupMenu) JSeparator(javax.swing.JSeparator) Bookmark(com.mucommander.bookmark.Bookmark) BonjourService(com.mucommander.bonjour.BonjourService) MuAction(com.mucommander.ui.action.MuAction) BonjourMenu(com.mucommander.bonjour.BonjourMenu) Icon(javax.swing.Icon) JMenuItem(javax.swing.JMenuItem)

Example 5 with ProtocolPanelProvider

use of com.mucommander.protocol.ui.ProtocolPanelProvider 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 "gdrive";
        }

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

        @Override
        public SchemeHandler getSchemeHandler() {
            return new DefaultSchemeHandler(new DefaultSchemeParser(), 21, "/", AuthenticationType.NO_AUTHENTICATION, new Credentials("anonymous", "anonymous_coward@mucommander.com"));
        }
    };
    ProtocolPanelProvider panelProvider = new ProtocolPanelProvider() {

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

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

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

        @Override
        public Class<? extends ServerPanel> getPanelClass() {
            return GoogleDrivePanel.class;
        }
    };
    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) Credentials(com.mucommander.commons.file.Credentials) FileProtocolService(com.mucommander.commons.file.osgi.FileProtocolService) DefaultSchemeHandler(com.mucommander.commons.file.DefaultSchemeHandler)

Aggregations

ProtocolPanelProvider (com.mucommander.protocol.ui.ProtocolPanelProvider)14 DefaultSchemeHandler (com.mucommander.commons.file.DefaultSchemeHandler)12 DefaultSchemeParser (com.mucommander.commons.file.DefaultSchemeParser)12 FileProtocolService (com.mucommander.commons.file.osgi.FileProtocolService)12 ServerPanelListener (com.mucommander.protocol.ui.ServerPanelListener)12 JFrame (javax.swing.JFrame)12 Credentials (com.mucommander.commons.file.Credentials)4 BonjourMenu (com.mucommander.bonjour.BonjourMenu)1 BonjourService (com.mucommander.bonjour.BonjourService)1 Bookmark (com.mucommander.bookmark.Bookmark)1 FileURL (com.mucommander.commons.file.FileURL)1 MnemonicHelper (com.mucommander.commons.util.ui.helper.MnemonicHelper)1 MuAction (com.mucommander.ui.action.MuAction)1 ArrayList (java.util.ArrayList)1 Hashtable (java.util.Hashtable)1 Icon (javax.swing.Icon)1 JMenuItem (javax.swing.JMenuItem)1 JPopupMenu (javax.swing.JPopupMenu)1 JSeparator (javax.swing.JSeparator)1